diff --git a/core/src/main/java/org/teavm/javascript/Renderer.java b/core/src/main/java/org/teavm/javascript/Renderer.java index f8c218ce4..e9ffad9af 100644 --- a/core/src/main/java/org/teavm/javascript/Renderer.java +++ b/core/src/main/java/org/teavm/javascript/Renderer.java @@ -1525,6 +1525,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext case NEGATE: if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) { writer.append('('); + } else if (outerPrecedence.ordinal() >= Precedence.ADDITION.ordinal()) { + writer.append(' '); } writer.append("-"); precedence = Precedence.UNARY; @@ -1661,11 +1663,15 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext pushLocation(expr.getLocation()); } String str = constantToString(expr.getValue()); - if (str.startsWith("-") && precedence.ordinal() > Precedence.MULTIPLICATION.ordinal()) { - writer.append('('); + if (str.startsWith("-")) { + if (precedence.ordinal() >= Precedence.UNARY.ordinal()) { + writer.append('('); + } else { + writer.append(' '); + } } writer.append(str); - if (str.startsWith("-") && precedence.ordinal() > Precedence.MULTIPLICATION.ordinal()) { + if (str.startsWith("-") && precedence.ordinal() >= Precedence.UNARY.ordinal()) { writer.append(')'); } if (expr.getLocation() != null) { diff --git a/jso/apis/src/main/java/org/teavm/jso/browser/Window.java b/jso/apis/src/main/java/org/teavm/jso/browser/Window.java index ba4c8c629..edffaeeeb 100644 --- a/jso/apis/src/main/java/org/teavm/jso/browser/Window.java +++ b/jso/apis/src/main/java/org/teavm/jso/browser/Window.java @@ -50,13 +50,13 @@ public abstract class Window implements JSObject, EventTarget, StorageProvider { @JSBody(params = { "timeoutId" }, script = "clearTimeout(timeoutId);") public static native void clearTimeout(int timeoutId); - @JSBody(params = { "handler", "delay" }, script = "return setInverval(handler, delay);") + @JSBody(params = { "handler", "delay" }, script = "return setInterval(handler, delay);") public static native int setInterval(TimerHandler handler, int delay); - @JSBody(params = { "handler", "delay" }, script = "return setInverval(handler, delay);") + @JSBody(params = { "handler", "delay" }, script = "return setInterval(handler, delay);") public static native int setInterval(TimerHandler handler, double delay); - @JSBody(params = { "timeoutId" }, script = "clearInverval(timeoutId);") + @JSBody(params = { "timeoutId" }, script = "clearInterval(timeoutId);") public static native void clearInterval(int timeoutId); @JSBody(params = {}, script = "return window;") diff --git a/jso/apis/src/main/java/org/teavm/jso/typedarrays/ArrayBufferView.java b/jso/apis/src/main/java/org/teavm/jso/typedarrays/ArrayBufferView.java index 8a1c0e517..2ade2c315 100644 --- a/jso/apis/src/main/java/org/teavm/jso/typedarrays/ArrayBufferView.java +++ b/jso/apis/src/main/java/org/teavm/jso/typedarrays/ArrayBufferView.java @@ -23,6 +23,9 @@ import org.teavm.jso.JSProperty; * @author Alexey Andreev */ public abstract class ArrayBufferView implements JSObject { + private ArrayBufferView() { + } + @JSProperty public abstract int getLength();