mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix bugs in JavaScript backend
This commit is contained in:
parent
055312055b
commit
081efd2d60
|
@ -1514,10 +1514,18 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
visitBinary(expr, "%", expr.getType() == OperationType.INT);
|
||||
break;
|
||||
case EQUALS:
|
||||
if (expr.getType() == OperationType.INT) {
|
||||
visitBinary(expr, "==", false);
|
||||
} else {
|
||||
visitBinary(expr, "===", false);
|
||||
}
|
||||
break;
|
||||
case NOT_EQUALS:
|
||||
if (expr.getType() == OperationType.INT) {
|
||||
visitBinary(expr, "!=", false);
|
||||
} else {
|
||||
visitBinary(expr, "!==", false);
|
||||
}
|
||||
break;
|
||||
case GREATER:
|
||||
visitBinary(expr, ">", false);
|
||||
|
@ -1591,7 +1599,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
}
|
||||
case NEGATE:
|
||||
if (expr.getType() == OperationType.LONG) {
|
||||
writer.append("Long_not(");
|
||||
writer.append("Long_neg(");
|
||||
precedence = Precedence.min();
|
||||
expr.getOperand().acceptVisitor(this);
|
||||
writer.append(')');
|
||||
|
@ -2231,7 +2239,11 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
String clsName = ((ValueType.Object) expr.getType()).getClassName();
|
||||
ClassHolder cls = classSource.get(clsName);
|
||||
if (cls != null && !cls.getModifiers().contains(ElementModifier.INTERFACE)) {
|
||||
precedence = Precedence.COMPARISON.next();
|
||||
boolean needsParentheses = Precedence.COMPARISON.ordinal() < precedence.ordinal();
|
||||
if (needsParentheses) {
|
||||
writer.append('(');
|
||||
}
|
||||
precedence = Precedence.CONDITIONAL.next();
|
||||
expr.getExpr().acceptVisitor(this);
|
||||
writer.append(" instanceof ").appendClass(clsName);
|
||||
if (expr.getLocation() != null) {
|
||||
|
|
|
@ -645,8 +645,10 @@ function Long_gt(a, b) {
|
|||
if (a.hi > b.hi) {
|
||||
return true;
|
||||
}
|
||||
if ((a.lo >>> 1) > (b.lo >>> 1)) {
|
||||
return true;
|
||||
var x = a.lo >>> 1;
|
||||
var y = b.lo >>> 1;
|
||||
if (x != y) {
|
||||
return x > y;
|
||||
}
|
||||
return (a.lo & 1) > (b.lo & 1);
|
||||
}
|
||||
|
@ -657,8 +659,10 @@ function Long_ge(a, b) {
|
|||
if (a.hi > b.hi) {
|
||||
return true;
|
||||
}
|
||||
if ((a.lo >>> 1) >= (b.lo >>> 1)) {
|
||||
return true;
|
||||
var x = a.lo >>> 1;
|
||||
var y = b.lo >>> 1;
|
||||
if (x != y) {
|
||||
return x >= y;
|
||||
}
|
||||
return (a.lo & 1) >= (b.lo & 1);
|
||||
}
|
||||
|
@ -669,8 +673,10 @@ function Long_lt(a, b) {
|
|||
if (a.hi < b.hi) {
|
||||
return true;
|
||||
}
|
||||
if ((a.lo >>> 1) < (b.lo >>> 1)) {
|
||||
return true;
|
||||
var x = a.lo >>> 1;
|
||||
var y = b.lo >>> 1;
|
||||
if (x != y) {
|
||||
return x < y;
|
||||
}
|
||||
return (a.lo & 1) < (b.lo & 1);
|
||||
}
|
||||
|
@ -684,6 +690,11 @@ function Long_le(a, b) {
|
|||
if ((a.lo >>> 1) <= (b.lo >>> 1)) {
|
||||
return true;
|
||||
}
|
||||
var x = a.lo >>> 1;
|
||||
var y = b.lo >>> 1;
|
||||
if (x != y) {
|
||||
return x <= y;
|
||||
}
|
||||
return (a.lo & 1) <= (b.lo & 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user