mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-27 01:30:35 +08:00
JS: fix overflow behaviour of unary minus
This commit is contained in:
parent
0064d399be
commit
02e8955abc
@ -836,6 +836,18 @@ public class StatementRenderer implements ExprVisitor, StatementVisitor {
|
||||
precedence = Precedence.min();
|
||||
expr.getOperand().acceptVisitor(this);
|
||||
writer.append(')');
|
||||
} else if (expr.getType() == OperationType.INT) {
|
||||
if (outerPrecedence.ordinal() > Precedence.BITWISE_OR.ordinal()) {
|
||||
writer.append('(');
|
||||
}
|
||||
writer.append(" -");
|
||||
precedence = Precedence.UNARY;
|
||||
expr.getOperand().acceptVisitor(this);
|
||||
writer.ws().append("|").ws();
|
||||
writer.append("0");
|
||||
if (outerPrecedence.ordinal() > Precedence.BITWISE_OR.ordinal()) {
|
||||
writer.append(')');
|
||||
}
|
||||
} else {
|
||||
if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) {
|
||||
writer.append('(');
|
||||
|
Loading…
Reference in New Issue
Block a user