mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Mark some JS native methods as not having side effects
This commit is contained in:
parent
103affa392
commit
70ff079113
|
@ -34,6 +34,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
|
|||
<artifactId>teavm-jso</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-interop</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -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<T extends JSObject> implements JSArrayReader<T> {
|
|||
public abstract void setLength(int len);
|
||||
|
||||
@JSBody(script = "return new Array();")
|
||||
@NoSideEffects
|
||||
public static native <T extends JSObject> JSArray<T> create();
|
||||
|
||||
@JSBody(params = "size", script = "return new Array(size);")
|
||||
@NoSideEffects
|
||||
public static native <T extends JSObject> JSArray<T> create(int size);
|
||||
|
||||
@SafeVarargs
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 extends JSObject> T create();
|
||||
|
||||
@JSBody(script = "return Object.create(null);")
|
||||
@NoSideEffects
|
||||
public static native <T extends JSObject> 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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user