49 }
50
51 public Label() {
52 }
53
54 /**
55 * Binds the label to the specified position.
56 *
57 * @param pos the position
58 */
59 protected void bind(int pos) {
60 this.position = pos;
61 assert isBound();
62 }
63
64 public boolean isBound() {
65 return position >= 0;
66 }
67
68 public void addPatchAt(int branchLocation) {
69 assert !isBound() : "Label is already bound";
70 patchPositions.add(branchLocation);
71 }
72
73 protected void patchInstructions(AbstractAssembler masm) {
74 assert isBound() : "Label should be bound";
75 int target = position;
76 for (int i = 0; i < patchPositions.size(); ++i) {
77 int pos = patchPositions.get(i);
78 masm.patchJumpTarget(pos, target);
79 }
80 }
81
82 @Override
83 public String toString() {
84 return isBound() ? String.valueOf(position()) : "?";
85 }
86 }
|
49 }
50
51 public Label() {
52 }
53
54 /**
55 * Binds the label to the specified position.
56 *
57 * @param pos the position
58 */
59 protected void bind(int pos) {
60 this.position = pos;
61 assert isBound();
62 }
63
64 public boolean isBound() {
65 return position >= 0;
66 }
67
68 public void addPatchAt(int branchLocation) {
69 assert !isBound() : "Label is already bound " + this + " " + branchLocation + " at position " + position;
70 patchPositions.add(branchLocation);
71 }
72
73 protected void patchInstructions(AbstractAssembler masm) {
74 assert isBound() : "Label should be bound";
75 int target = position;
76 for (int i = 0; i < patchPositions.size(); ++i) {
77 int pos = patchPositions.get(i);
78 masm.patchJumpTarget(pos, target);
79 }
80 }
81
82 @Override
83 public String toString() {
84 return isBound() ? String.valueOf(position()) : "?";
85 }
86 }
|