From 302c1c2237ffaf8cc39e2fcf799f054a1538a6f8 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Thu, 26 Feb 2015 23:47:57 +0300 Subject: [PATCH] Minor fixes --- .../java/org/teavm/javascript/Renderer.java | 19 +++++++++++++++++-- .../jso/plugin/JavascriptNativeProcessor.java | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java index 633b12fa6..1a27916e3 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java @@ -1094,6 +1094,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext @Override public void visit(InitClassStatement statement) { + ClassReader cls = classSource.get(statement.getClassName()); + if (cls == null) { + return; + } + MethodReader method = cls.getMethod(new MethodDescriptor("", void.class)); + if (method == null) { + return; + } try { debugEmitter.emitStatementStart(); if (statement.getLocation() != null) { @@ -1310,7 +1318,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext exitPriority(); break; case NEGATE: - enterPriority(Priority.UNARY, Associativity.RIGHT, true); + enterPriority(Priority.MULTIPLICATION, Associativity.RIGHT, true); writer.append("-"); expr.getOperand().acceptVisitor(this); exitPriority(); @@ -1425,7 +1433,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext if (expr.getLocation() != null) { pushLocation(expr.getLocation()); } - writer.append(constantToString(expr.getValue())); + String str = constantToString(expr.getValue()); + if (str.startsWith("-")) { + enterPriority(Priority.MULTIPLICATION, Associativity.RIGHT, true); + } + writer.append(str); + if (str.startsWith("-")) { + exitPriority(); + } if (expr.getLocation() != null) { popLocation(); } diff --git a/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java b/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java index 0a62d19cf..e55d0a2b9 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java +++ b/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java @@ -184,7 +184,7 @@ class JavascriptNativeProcessor { } replacement.clear(); MethodReader method = getMethod(invoke.getMethod()); - if (method.hasModifier(ElementModifier.STATIC)) { + if (method == null || method.hasModifier(ElementModifier.STATIC)) { continue; } if (method.hasModifier(ElementModifier.FINAL)) {