1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.codegen;
13 public class CaseLabel extends Label {
14 public int instructionPosition = POS_NOT_SET;
15 public int backwardsBranch = POS_NOT_SET;
17 * CaseLabel constructor comment.
18 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
20 public CaseLabel(CodeStream codeStream) {
24 * Put down a refernece to the array at the location in the codestream.
27 if (position == POS_NOT_SET) {
28 addForwardReference(codeStream.position);
29 // Leave 4 bytes free to generate the jump offset afterwards
30 codeStream.position += 4;
31 codeStream.classFileOffset += 4;
32 } else { //Position is set. Write it!
33 codeStream.writeSignedWord(position - codeStream.position + 1);
37 * Put down a refernece to the array at the location in the codestream.
40 if (position == POS_NOT_SET) {
41 addForwardReference(codeStream.position);
42 // Leave 4 bytes free to generate the jump offset afterwards
43 codeStream.position += 4;
44 } else { //Position is set. Write it!
45 codeStream.writeSignedWord(position - codeStream.position + 1);
48 public boolean isStandardLabel(){
52 * Put down a reference to the array at the location in the codestream.
55 position = codeStream.position;
56 if (instructionPosition == POS_NOT_SET)
57 backwardsBranch = position;
59 int offset = position - instructionPosition;
60 for (int i = 0; i < forwardReferenceCount; i++) {
61 codeStream.writeSignedWord(forwardReferences[i], offset);
63 // add the label int the codeStream labels collection
64 codeStream.addLabel(this);
68 * Put down a refernece to the array at the location in the codestream.
70 void placeInstruction() {
71 if (instructionPosition == POS_NOT_SET) {
72 instructionPosition = codeStream.position;
73 if (backwardsBranch != POS_NOT_SET) {
74 int offset = backwardsBranch - instructionPosition;
75 for (int i = 0; i < forwardReferenceCount; i++)
76 codeStream.writeSignedWord(forwardReferences[i], offset);
77 backwardsBranch = POS_NOT_SET;