More JS API fixes

This commit is contained in:
Alexey Andreev 2015-10-11 18:49:57 +03:00
parent 94368935ab
commit 5592862c70
3 changed files with 15 additions and 6 deletions

View File

@ -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) {

View File

@ -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;")

View File

@ -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();