Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/net.sf.j2s.core_3.1.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;

// BH 5/15/2018 -- fix for a[pt++] |= 3 incrementing pt twice (see test/Test_Or.java)
// BH 3/27/2018 -- fix for anonymous inner classes of inner classes not having this.this$0
// BH 1/5/2018 -- @j2sKeep removed; refactored into one class

Expand Down Expand Up @@ -1961,6 +1962,7 @@ void addType(String name) {
break;
default:
case 'p': // $p$
case 'j': // $j$
break;
}
added += ";\r\n";
Expand Down Expand Up @@ -2054,9 +2056,12 @@ public boolean visit(Assignment node) {
return false;
}

int ptArray = (isArray ? buffer.length() : -1);
left.accept(this);
int ptArray2 = (isArray ? buffer.length() : -1);

if ("boolean".equals(leftName)) {
// |=, &=, ^=
left.accept(this);
buffer.append(" = (");
left.accept(this);
switch (op) {
Expand All @@ -2079,20 +2084,15 @@ public boolean visit(Assignment node) {
right.accept(this);
}
buffer.append(")");
isArray = wasArray;
return false;

return fixAssignArray(ptArray, ptArray2, wasArray);
}

left.accept(this);

if (!("char".equals(leftName))) {
if (isNumericType(leftName)) {
// byte|short|int|long += ...
buffer.append(" = ");
addPrimitiveTypedExpression(left, toBinding, leftName, opType, right, rightName, null, true);
isArray = wasArray;
return false;
return fixAssignArray(ptArray, ptArray2, wasArray);
}
// not char x ....
// not boolean x....
Expand Down Expand Up @@ -2131,8 +2131,7 @@ public boolean visit(Assignment node) {
if (needParenthesis) {
buffer.append(")");
}
isArray = wasArray;
return false;
return fixAssignArray(ptArray, ptArray2, wasArray);
}

// char left op right where op is not just "="
Expand Down Expand Up @@ -2182,7 +2181,44 @@ public boolean visit(Assignment node) {
if (needCharCode)
buffer.append(CHARCODEAT0);
buffer.append(')');
isArray = wasArray;
return fixAssignArray(ptArray, ptArray2, wasArray);
}

/**
* We must fix
*
* this.ctype[low++] = (this.ctype[low++]|(4)|0);
*
* to read
*
* this.ctype[$j$=low++] = (this.ctype[$j$]|(4)|0);
*
* so that the index does not get operated upon twice.
*
* @param ptArray
* @param ptArray2
* @param wasArray
* @return
*/
private boolean fixAssignArray(int ptArray, int ptArray2, boolean wasArray) {

if (ptArray >= 0) {
trailingBuffer.addType("j");
String left = buffer.substring(ptArray, ptArray2); // zzz[xxx]
String right = buffer.substring(ptArray2);
buffer.setLength(ptArray);
int ptIndex = left.indexOf("[") + 1;
String left0 = left.substring(0, ptIndex);
buffer.append(left0);
buffer.append("$j$=");
buffer.append(left.substring(ptIndex));
ptIndex = right.indexOf(left);
buffer.append(right.substring(0, ptIndex));
buffer.append(left0);
buffer.append("$j$]");
buffer.append(right.substring(ptIndex + left.length()));
isArray = wasArray;
}
return false;
}

Expand Down
1 change: 1 addition & 0 deletions sources/net.sf.j2s.java.core/build_core_applet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
java/util/Locale.js
java/util/MapEntry.js
javajs/api/JSFunction.js
javajs/util/AjaxURLConnection.js
javajs/util/AjaxURLStreamHandlerFactory.js
javajs/util/AU.js
javajs/util/JSThread.js
Expand Down
Loading