diff --git a/jso/apis/pom.xml b/jso/apis/pom.xml
index d4fed183e..87ae78109 100644
--- a/jso/apis/pom.xml
+++ b/jso/apis/pom.xml
@@ -34,6 +34,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
teavm-jso
${project.version}
+
+ org.teavm
+ teavm-interop
+ ${project.version}
+
junit
junit
diff --git a/jso/apis/src/main/java/org/teavm/jso/core/JSArray.java b/jso/apis/src/main/java/org/teavm/jso/core/JSArray.java
index b735c8c9a..b62178a51 100644
--- a/jso/apis/src/main/java/org/teavm/jso/core/JSArray.java
+++ b/jso/apis/src/main/java/org/teavm/jso/core/JSArray.java
@@ -15,6 +15,7 @@
*/
package org.teavm.jso.core;
+import org.teavm.interop.NoSideEffects;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSIndexer;
import org.teavm.jso.JSObject;
@@ -83,9 +84,11 @@ public abstract class JSArray implements JSArrayReader {
public abstract void setLength(int len);
@JSBody(script = "return new Array();")
+ @NoSideEffects
public static native JSArray create();
@JSBody(params = "size", script = "return new Array(size);")
+ @NoSideEffects
public static native JSArray create(int size);
@SafeVarargs
diff --git a/jso/apis/src/main/java/org/teavm/jso/core/JSBoolean.java b/jso/apis/src/main/java/org/teavm/jso/core/JSBoolean.java
index d2cf33d6f..d9c445eb4 100644
--- a/jso/apis/src/main/java/org/teavm/jso/core/JSBoolean.java
+++ b/jso/apis/src/main/java/org/teavm/jso/core/JSBoolean.java
@@ -15,6 +15,7 @@
*/
package org.teavm.jso.core;
+import org.teavm.interop.NoSideEffects;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
@@ -27,8 +28,10 @@ public abstract class JSBoolean implements JSObject {
}
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
private static native boolean booleanValue(JSBoolean value);
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
public static native JSBoolean valueOf(boolean value);
}
diff --git a/jso/apis/src/main/java/org/teavm/jso/core/JSDate.java b/jso/apis/src/main/java/org/teavm/jso/core/JSDate.java
index e9afd6fb4..ee7069e99 100644
--- a/jso/apis/src/main/java/org/teavm/jso/core/JSDate.java
+++ b/jso/apis/src/main/java/org/teavm/jso/core/JSDate.java
@@ -15,63 +15,80 @@
*/
package org.teavm.jso.core;
+import org.teavm.interop.NoSideEffects;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSMethod;
import org.teavm.jso.JSObject;
public abstract class JSDate implements JSObject {
@JSBody(script = "return new Date();")
+ @NoSideEffects
public static native JSDate create();
@JSBody(params = "millis", script = "return new Date(millis);")
+ @NoSideEffects
public static native JSDate create(double millis);
@JSBody(params = { "year", "month" }, script = "return new Date(year, month);")
+ @NoSideEffects
public static native JSDate create(int year, int month);
@JSBody(params = { "year", "month", "day" }, script = "return new Date(year, month, day);")
+ @NoSideEffects
public static native JSDate create(int year, int month, int day);
@JSBody(params = { "year", "month", "day", "hour" }, script = "return new Date(year, month, day, hour);")
+ @NoSideEffects
public static native JSDate create(int year, int month, int day, int hour);
@JSBody(params = { "year", "month", "day", "hour", "minute" },
script = "return new Date(year, month, day, hour, minute);")
+ @NoSideEffects
public static native JSDate create(int year, int month, int day, int hour, int minute);
@JSBody(params = { "year", "month", "day", "hour", "minute", "second" },
script = "return new Date(year, month, day, hour, minute, second);")
+ @NoSideEffects
public static native JSDate create(int year, int month, int day, int hour, int minute, int second);
@JSBody(params = { "year", "month", "day", "hour", "minute", "second", "millisecond" },
script = "return new Date(year, month, day, hour, minute, second, millisecond);")
+ @NoSideEffects
public static native JSDate create(int year, int month, int day, int hour, int minute, int second, int millisecond);
@JSBody(params = {}, script = "return Date.now();")
+ @NoSideEffects
public static native double now();
@JSBody(params = "stringValue", script = "return Date.parse(stringValue);")
+ @NoSideEffects
public static native double parse(String stringValue);
@JSBody(params = { "year", "month" }, script = "return Date.UTC(year, month);")
+ @NoSideEffects
public static native double UTC(int year, int month);
@JSBody(params = { "year", "month", "day" }, script = "return Date.UTC(year, month, day);")
+ @NoSideEffects
public static native double UTC(int year, int month, int day);
@JSBody(params = { "year", "month", "day", "hour" }, script = "return Date.UTC(year, month, day, hour);")
+ @NoSideEffects
public static native double UTC(int year, int month, int day, int hour);
@JSBody(params = { "year", "month", "day", "hour", "minute" },
script = "return Date.UTC(year, month, day, hour, minute);")
+ @NoSideEffects
public static native double UTC(int year, int month, int day, int hour, int minute);
@JSBody(params = { "year", "month", "day", "hour", "minute", "second" },
script = "return Date.UTC(year, month, day, hour, minute, second);")
+ @NoSideEffects
public static native double UTC(int year, int month, int day, int hour, int minute, int second);
@JSBody(params = { "year", "month", "day", "hour", "minute", "second", "millisecond" },
script = "return Date.UTC(year, month, day, hour, minute, second, millisecond);")
+ @NoSideEffects
public static native double UTC(int year, int month, int day, int hour, int minute, int second, int millisecond);
public abstract int getDate();
diff --git a/jso/apis/src/main/java/org/teavm/jso/core/JSNumber.java b/jso/apis/src/main/java/org/teavm/jso/core/JSNumber.java
index 52257a8e6..5e8a49fbf 100644
--- a/jso/apis/src/main/java/org/teavm/jso/core/JSNumber.java
+++ b/jso/apis/src/main/java/org/teavm/jso/core/JSNumber.java
@@ -15,6 +15,7 @@
*/
package org.teavm.jso.core;
+import org.teavm.interop.NoSideEffects;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
@@ -27,6 +28,7 @@ public abstract class JSNumber implements JSObject {
}
@JSBody(params = "number", script = "return number;")
+ @NoSideEffects
private static native double doubleValue(JSNumber number);
public final int intValue() {
@@ -34,6 +36,7 @@ public abstract class JSNumber implements JSObject {
}
@JSBody(params = "number", script = "return number;")
+ @NoSideEffects
private static native int intValue(JSNumber number);
public final char charValue() {
@@ -41,6 +44,7 @@ public abstract class JSNumber implements JSObject {
}
@JSBody(params = "number", script = "return number;")
+ @NoSideEffects
private static native char charValue(JSNumber number);
public final byte byteValue() {
@@ -48,6 +52,7 @@ public abstract class JSNumber implements JSObject {
}
@JSBody(params = "number", script = "return number;")
+ @NoSideEffects
private static native byte byteValue(JSNumber number);
public final short shortValue() {
@@ -55,6 +60,7 @@ public abstract class JSNumber implements JSObject {
}
@JSBody(params = "number", script = "return number;")
+ @NoSideEffects
private static native short shortValue(JSNumber number);
public final float floatValue() {
@@ -62,23 +68,30 @@ public abstract class JSNumber implements JSObject {
}
@JSBody(params = "number", script = "return number;")
+ @NoSideEffects
private static native float floatValue(JSNumber number);
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
public static native JSNumber valueOf(byte value);
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
public static native JSNumber valueOf(short value);
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
public static native JSNumber valueOf(int value);
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
public static native JSNumber valueOf(char value);
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
public static native JSNumber valueOf(float value);
@JSBody(params = "value", script = "return value;")
+ @NoSideEffects
public static native JSNumber valueOf(double value);
}
diff --git a/jso/apis/src/main/java/org/teavm/jso/core/JSObjects.java b/jso/apis/src/main/java/org/teavm/jso/core/JSObjects.java
index da4b3e875..0939c08b7 100644
--- a/jso/apis/src/main/java/org/teavm/jso/core/JSObjects.java
+++ b/jso/apis/src/main/java/org/teavm/jso/core/JSObjects.java
@@ -15,6 +15,7 @@
*/
package org.teavm.jso.core;
+import org.teavm.interop.NoSideEffects;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
@@ -23,26 +24,33 @@ public final class JSObjects {
}
@JSBody(params = "object", script = "return Object.getOwnPropertyNames(object);")
+ @NoSideEffects
public static native String[] getOwnPropertyNames(JSObject object);
@JSBody(script = "return {};")
+ @NoSideEffects
public static native T create();
@JSBody(script = "return Object.create(null);")
+ @NoSideEffects
public static native T createWithoutProto();
@JSBody(params = "object", script = "return typeof object === 'undefined';")
+ @NoSideEffects
public static native boolean isUndefined(JSObject object);
@JSBody(script = "return void 0;")
+ @NoSideEffects
public static native JSObject undefined();
@JSBody(params = "object", script = "return typeof object;")
+ @NoSideEffects
public static native String typeOf(JSObject object);
@JSBody(params = "object", script = "return object.toString();")
public static native String toString(JSObject object);
@JSBody(params = { "object", "name" }, script = "return name in object;")
+ @NoSideEffects
public static native boolean hasProperty(JSObject object, String name);
}
diff --git a/jso/apis/src/main/java/org/teavm/jso/core/JSRegExp.java b/jso/apis/src/main/java/org/teavm/jso/core/JSRegExp.java
index d60dd4da0..9f34c8552 100644
--- a/jso/apis/src/main/java/org/teavm/jso/core/JSRegExp.java
+++ b/jso/apis/src/main/java/org/teavm/jso/core/JSRegExp.java
@@ -15,15 +15,18 @@
*/
package org.teavm.jso.core;
+import org.teavm.interop.NoSideEffects;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
public abstract class JSRegExp implements JSObject {
@JSBody(params = "pattern", script = "return new RegExp(pattern);")
+ @NoSideEffects
public static native JSRegExp create(String pattern);
@JSBody(params = { "pattern", "flags" }, script = "return new RegExp(pattern, flags);")
+ @NoSideEffects
public static native JSRegExp create(String pattern, String flags);
public static JSRegExp create(String pattern, JSRegExpFlag... flags) {
diff --git a/jso/apis/src/main/java/org/teavm/jso/core/JSString.java b/jso/apis/src/main/java/org/teavm/jso/core/JSString.java
index 9c7752064..837e498ab 100644
--- a/jso/apis/src/main/java/org/teavm/jso/core/JSString.java
+++ b/jso/apis/src/main/java/org/teavm/jso/core/JSString.java
@@ -15,6 +15,7 @@
*/
package org.teavm.jso.core;
+import org.teavm.interop.NoSideEffects;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
@@ -28,12 +29,15 @@ public abstract class JSString implements JSObject {
}
@JSBody(params = "str", script = "return str;")
+ @NoSideEffects
private static native String stringValue(JSString str);
@JSBody(params = "str", script = "return str;")
+ @NoSideEffects
public static native JSString valueOf(String str);
@JSBody(params = "code", script = "return String.fromCharCode(code)")
+ @NoSideEffects
public static native JSString fromCharCode(int code);
@JSProperty
@@ -96,5 +100,6 @@ public abstract class JSString implements JSObject {
public abstract JSString trim();
@JSBody(params = "obj", script = "return typeof obj === 'string';")
+ @NoSideEffects
public static native boolean isInstance(JSObject obj);
}