1 24 25 package org.aspectj.compiler.base.bcg; 26 27 import java.io.DataOutputStream ; 28 import java.io.IOException ; 29 30 public class Label { 31 boolean anchored; 32 Label(boolean anchored) { this.anchored = anchored; } 33 34 boolean isAnchored() { return anchored; } 35 36 Code target; 37 38 void setTarget(Code target) { 39 this.target = target; 40 target.addLabel(this); 41 } 42 Code getTarget() { return target; } 43 44 int getPc() { return target.getPc(); } 45 46 void writeRelativeShort(int src, DataOutputStream stream) throws IOException { 47 int relative = target.getPc() - src; 48 if (! Asserts.isShort(relative)) { 49 throw new CodeBuilder.TooWideJumpException(); 50 } else { 51 stream.writeShort((short) relative); 52 } 53 } 54 void writeRelativeInt(int src, DataOutputStream stream) throws IOException { 55 long relative = target.getPc() - src; 56 stream.writeInt((int) relative); 57 } 58 59 static int labelCount = 0; 61 int myLabelNum = -1; 62 public String toString() { 63 if (getTarget().getPc() != -1) return "" + getTarget().getPc(); 64 Label l = (CodeBuilder.DEBUG) ? this : (Label) getTarget().getLabels().get(0); 65 if (l.myLabelNum == -1) l.myLabelNum = labelCount++; 66 return "_" + l.myLabelNum; 67 } 68 } 69 | Popular Tags |