deleted: export="true"
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / codegen / CaseLabel.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.codegen;
12
13 public class CaseLabel extends Label {
14         public int instructionPosition = POS_NOT_SET;
15         public int backwardsBranch = POS_NOT_SET;
16 /**
17  * CaseLabel constructor comment.
18  * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
19  */
20 public CaseLabel(CodeStream codeStream) {
21         super(codeStream);
22 }
23 /*
24 * Put down  a refernece to the array at the location in the codestream.
25 */
26 void branch() {
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);
34         }
35 }
36 /*
37 * Put down  a refernece to the array at the location in the codestream.
38 */
39 void branchWide() {
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);
46         }
47 }
48 public boolean isStandardLabel(){
49         return false;
50 }
51 /*
52 * Put down  a reference to the array at the location in the codestream.
53 */
54 public void place() {
55         position = codeStream.position;
56         if (instructionPosition == POS_NOT_SET)
57                 backwardsBranch = position;
58         else {
59                 int offset = position - instructionPosition;
60                 for (int i = 0; i < forwardReferenceCount; i++) {
61                         codeStream.writeSignedWord(forwardReferences[i], offset);
62                 }
63                 // add the label int the codeStream labels collection
64                 codeStream.addLabel(this);
65         }
66 }
67 /*
68 * Put down  a refernece to the array at the location in the codestream.
69 */
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;
78                 }
79         }
80 }
81 }