Skip to content

Commit cc84109

Browse files
committed
updated byte/short array handling
1 parent 096db21 commit cc84109

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed
1.15 KB
Binary file not shown.
1.15 KB
Binary file not shown.

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,7 @@ public boolean visit(Assignment node) {
20392039
// Static def new Test_Static().y++;
20402040
ASTNode parent = node.getParent();
20412041
needNewStaticParenthesis = (!haveDirectStaticAccess(left)) && !(parent instanceof Statement);
2042-
buffer.append("/*ass need " + needNewStaticParenthesis + "*/");
2042+
// ever true? buffer.append("/*ass need " + needNewStaticParenthesis + "*/");
20432043
if (needNewStaticParenthesis) {
20442044
buffer.append("(");
20452045
}
@@ -2204,11 +2204,21 @@ private boolean fixAssignArray(ArrayAccess leftArray, int ptArray, int ptArray2,
22042204
if (ptIndex2 - ptIndex1 > 3) {
22052205
// at least as long as zzz[i++]
22062206
String right = buffer.substring(ptArray2);
2207-
buffer.setLength(ptArray + ptIndex1);
2207+
buffer.setLength(ptArray);
2208+
String name = left.substring(0, ptIndex1);
2209+
if (name.indexOf("(") >= 0) {
2210+
// test/Test_Static: getByteArray()[p++] += (byte) ++p;
2211+
// ($j$=C$.getByteArray())[$k$=p++]=($j$[$k$]+((++p|0))|0);
2212+
buffer.append("($j$=" + name + ")");
2213+
name = "$j$";
2214+
trailingBuffer.addType("j");
2215+
} else {
2216+
buffer.append(name);
2217+
}
22082218
String newRight = addArrayTemps(leftArray);
22092219
int ptIndex3 = right.indexOf(left);
22102220
buffer.append(right.substring(0, ptIndex3));
2211-
buffer.append(left.substring(0, ptIndex1));
2221+
buffer.append(name);
22122222
buffer.append(newRight);
22132223
buffer.append(right.substring(ptIndex3 + left.length()));
22142224
}
@@ -2219,7 +2229,7 @@ private boolean fixAssignArray(ArrayAccess leftArray, int ptArray, int ptArray2,
22192229

22202230
private String addArrayTemps(ArrayAccess leftArray) {
22212231
String right = "";
2222-
char c = 'j';
2232+
char c = 'k';
22232233
String left = "";
22242234
while (leftArray != null) {
22252235
Expression exp = leftArray.getIndex();

0 commit comments

Comments
 (0)