Skip to content

Commit 9cb18bc

Browse files
committed
a[pt++] |= .... fix
1 parent 740a91d commit 9cb18bc

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed
12 Bytes
Binary file not shown.
12 Bytes
Binary file not shown.

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ public boolean visit(Assignment node) {
21852185
}
21862186

21872187
/**
2188-
* We must fix
2188+
* We must fix
21892189
*
21902190
* this.ctype[low++] = (this.ctype[low++]|(4)|0);
21912191
*
@@ -2201,22 +2201,25 @@ public boolean visit(Assignment node) {
22012201
* @return
22022202
*/
22032203
private boolean fixAssignArray(int ptArray, int ptArray2, boolean wasArray) {
2204-
2204+
22052205
if (ptArray >= 0) {
2206-
trailingBuffer.addType("j");
2207-
String left = buffer.substring(ptArray, ptArray2); // zzz[xxx]
2208-
String right = buffer.substring(ptArray2);
2209-
buffer.setLength(ptArray);
2206+
String left = buffer.substring(ptArray, ptArray2); // zzz[xxx]
22102207
int ptIndex = left.indexOf("[") + 1;
2211-
String left0 = left.substring(0, ptIndex);
2212-
buffer.append(left0);
2213-
buffer.append("$j$=");
2214-
buffer.append(left.substring(ptIndex));
2215-
ptIndex = right.indexOf(left);
2216-
buffer.append(right.substring(0, ptIndex));
2217-
buffer.append(left0);
2218-
buffer.append("$j$]");
2219-
buffer.append(right.substring(ptIndex + left.length()));
2208+
if (left.length() - ptIndex >= 4) {
2209+
// at least as long as zzz[i++]
2210+
String right = buffer.substring(ptArray2);
2211+
trailingBuffer.addType("j");
2212+
buffer.setLength(ptArray);
2213+
String left0 = left.substring(0, ptIndex);
2214+
buffer.append(left0);
2215+
buffer.append("$j$=");
2216+
buffer.append(left.substring(ptIndex));
2217+
ptIndex = right.indexOf(left);
2218+
buffer.append(right.substring(0, ptIndex));
2219+
buffer.append(left0);
2220+
buffer.append("$j$]");
2221+
buffer.append(right.substring(ptIndex + left.length()));
2222+
}
22202223
isArray = wasArray;
22212224
}
22222225
return false;

0 commit comments

Comments
 (0)