Lines 43-53
Link Here
|
43 |
/** |
43 |
/** |
44 |
* Add a forward refrence for the array. |
44 |
* Add a forward refrence for the array. |
45 |
*/ |
45 |
*/ |
46 |
void addForwardReference(int iPos) { |
46 |
void addForwardReference(int pos) { |
|
|
47 |
int[] refs = this.forwardReferences; |
48 |
for (int i = 0, count = this.forwardReferenceCount; i < count; i++) { |
49 |
if (refs[i] == pos) return; // already recorded |
50 |
} |
47 |
int length; |
51 |
int length; |
48 |
if (forwardReferenceCount >= (length = forwardReferences.length)) |
52 |
if (forwardReferenceCount >= (length = refs.length)) |
49 |
System.arraycopy(forwardReferences, 0, (forwardReferences = new int[2*length]), 0, length); |
53 |
System.arraycopy(refs, 0, (this.forwardReferences = new int[2*length]), 0, length); |
50 |
forwardReferences[forwardReferenceCount++] = iPos; |
54 |
this.forwardReferences[this.forwardReferenceCount++] = pos; |
51 |
} |
55 |
} |
52 |
|
56 |
|
53 |
/** |
57 |
/** |
Lines 56-69
Link Here
|
56 |
public void appendForwardReferencesFrom(Label otherLabel) { |
60 |
public void appendForwardReferencesFrom(Label otherLabel) { |
57 |
int otherCount = otherLabel.forwardReferenceCount; |
61 |
int otherCount = otherLabel.forwardReferenceCount; |
58 |
if (otherCount == 0) return; |
62 |
if (otherCount == 0) return; |
59 |
int length = forwardReferences.length; |
63 |
int count = this.forwardReferenceCount; |
60 |
int neededSpace = otherCount + forwardReferenceCount; |
64 |
int[] refs = this.forwardReferences; |
61 |
if (neededSpace >= length){ |
65 |
int neededSpace = count + otherCount; |
62 |
System.arraycopy(forwardReferences, 0, (forwardReferences = new int[neededSpace]), 0, forwardReferenceCount); |
66 |
if (neededSpace >= refs.length){ |
|
|
67 |
System.arraycopy(refs, 0, (this.forwardReferences = refs = new int[neededSpace]), 0, count); |
63 |
} |
68 |
} |
64 |
// append other forward references at the end, so they will get updated as well |
69 |
// append other forward references at the end, so they will get updated as well |
65 |
System.arraycopy(otherLabel.forwardReferences, 0, forwardReferences, forwardReferenceCount, otherCount); |
70 |
int[] otherRefs = otherLabel.forwardReferences; |
66 |
forwardReferenceCount = neededSpace; |
71 |
otherLoop: for (int i = 0; i < otherCount; i++) { |
|
|
72 |
int otherRef = otherRefs[i]; |
73 |
for (int j = 0; j < count; j++) { |
74 |
if (refs[j] == otherRef) continue otherLoop; // already recorded |
75 |
} |
76 |
refs[count++] = otherRef; |
77 |
} |
78 |
this.forwardReferenceCount = count; |
67 |
} |
79 |
} |
68 |
|
80 |
|
69 |
/* |
81 |
/* |
Lines 94-100
Link Here
|
94 |
if (position == POS_NOT_SET) { |
106 |
if (position == POS_NOT_SET) { |
95 |
addForwardReference(codeStream.position); |
107 |
addForwardReference(codeStream.position); |
96 |
// Leave 4 bytes free to generate the jump offset afterwards |
108 |
// Leave 4 bytes free to generate the jump offset afterwards |
97 |
this.tagBits |= WIDE; |
109 |
this.tagBits |= WIDE; |
98 |
codeStream.position += 4; |
110 |
codeStream.position += 4; |
99 |
codeStream.classFileOffset += 4; |
111 |
codeStream.classFileOffset += 4; |
100 |
} else { //Position is set. Write it! |
112 |
} else { //Position is set. Write it! |