Permissions and filesystems #9
@ -18,7 +18,6 @@ import me.topchetoeu.jscript.parsing.Parsing;
|
|||||||
public class Context {
|
public class Context {
|
||||||
private final Stack<Environment> env = new Stack<>();
|
private final Stack<Environment> env = new Stack<>();
|
||||||
private final ArrayList<CodeFrame> frames = new ArrayList<>();
|
private final ArrayList<CodeFrame> frames = new ArrayList<>();
|
||||||
public final Data data;
|
|
||||||
public final Engine engine;
|
public final Engine engine;
|
||||||
|
|
||||||
public Environment environment() {
|
public Environment environment() {
|
||||||
@ -101,7 +100,6 @@ public class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Context(Engine engine) {
|
public Context(Engine engine) {
|
||||||
this.data = new Data();
|
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
}
|
}
|
||||||
public Context(Engine engine, Environment env) {
|
public Context(Engine engine, Environment env) {
|
||||||
|
@ -81,20 +81,6 @@ public class Engine implements DebugController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFramePop(Context ctx, CodeFrame frame) {
|
|
||||||
if (debugging && debugger != null) debugger.onFramePop(ctx, frame);
|
|
||||||
}
|
|
||||||
@Override public boolean onInstruction(Context ctx, CodeFrame frame, Instruction instruction, Object returnVal, EngineException error, boolean caught) {
|
|
||||||
if (debugging && debugger != null) return debugger.onInstruction(ctx, frame, instruction, returnVal, error, caught);
|
|
||||||
else return false;
|
|
||||||
}
|
|
||||||
@Override public void onSource(Filename filename, String source, TreeSet<Location> breakpoints) {
|
|
||||||
if (!debugging) return;
|
|
||||||
if (debugger != null) debugger.onSource(filename, source, breakpoints);
|
|
||||||
sources.put(filename, source);
|
|
||||||
bpts.put(filename, breakpoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runTask(Task task) {
|
private void runTask(Task task) {
|
||||||
try {
|
try {
|
||||||
task.notifier.next(task.func.call(task.ctx, task.thisArg, task.args));
|
task.notifier.next(task.func.call(task.ctx, task.thisArg, task.args));
|
||||||
@ -150,6 +136,20 @@ public class Engine implements DebugController {
|
|||||||
return pushMsg(micro, ctx, new UncompiledFunction(filename, raw), thisArg, args);
|
return pushMsg(micro, ctx, new UncompiledFunction(filename, raw), thisArg, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void onFramePop(Context ctx, CodeFrame frame) {
|
||||||
|
if (debugging && debugger != null) debugger.onFramePop(ctx, frame);
|
||||||
|
}
|
||||||
|
@Override public boolean onInstruction(Context ctx, CodeFrame frame, Instruction instruction, Object returnVal, EngineException error, boolean caught) {
|
||||||
|
if (debugging && debugger != null) return debugger.onInstruction(ctx, frame, instruction, returnVal, error, caught);
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
@Override public void onSource(Filename filename, String source, TreeSet<Location> breakpoints) {
|
||||||
|
if (!debugging) return;
|
||||||
|
if (debugger != null) debugger.onSource(filename, source, breakpoints);
|
||||||
|
sources.put(filename, source);
|
||||||
|
bpts.put(filename, breakpoints);
|
||||||
|
}
|
||||||
|
|
||||||
public Engine(boolean debugging) {
|
public Engine(boolean debugging) {
|
||||||
this.debugging = debugging;
|
this.debugging = debugging;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,11 @@ public class NativeWrapperProvider implements WrappersProvider {
|
|||||||
public static ObjectValue makeProto(Environment ctx, Class<?> clazz) {
|
public static ObjectValue makeProto(Environment ctx, Class<?> clazz) {
|
||||||
var res = new ObjectValue();
|
var res = new ObjectValue();
|
||||||
|
|
||||||
|
var name = clazz.getName();
|
||||||
|
var classNat = clazz.getAnnotation(Native.class);
|
||||||
|
if (classNat != null && !classNat.value().trim().equals("")) name = classNat.value().trim();
|
||||||
|
res.defineProperty(null, ctx.symbol("Symbol.typeName"), name);
|
||||||
|
|
||||||
for (var overload : clazz.getDeclaredMethods()) {
|
for (var overload : clazz.getDeclaredMethods()) {
|
||||||
var init = overload.getAnnotation(NativeInit.class);
|
var init = overload.getAnnotation(NativeInit.class);
|
||||||
if (init == null || init.value() != InitType.PROTOTYPE) continue;
|
if (init == null || init.value() != InitType.PROTOTYPE) continue;
|
||||||
|
@ -4,16 +4,13 @@ import java.util.Iterator;
|
|||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeConstructor;
|
import me.topchetoeu.jscript.interop.NativeConstructor;
|
||||||
import me.topchetoeu.jscript.interop.NativeGetter;
|
import me.topchetoeu.jscript.interop.NativeGetter;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
import me.topchetoeu.jscript.interop.NativeSetter;
|
import me.topchetoeu.jscript.interop.NativeSetter;
|
||||||
|
|
||||||
@Native("Array") public class ArrayLib {
|
@Native("Array") public class ArrayLib {
|
||||||
@ -369,8 +366,4 @@ import me.topchetoeu.jscript.interop.NativeSetter;
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Array");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeConstructor;
|
import me.topchetoeu.jscript.interop.NativeConstructor;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
|
|
||||||
@Native("Boolean") public class BooleanLib {
|
@Native("Boolean") public class BooleanLib {
|
||||||
public static final BooleanLib TRUE = new BooleanLib(true);
|
public static final BooleanLib TRUE = new BooleanLib(true);
|
||||||
@ -30,7 +27,4 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
public BooleanLib(boolean val) {
|
public BooleanLib(boolean val) {
|
||||||
this.value = val;
|
this.value = val;
|
||||||
}
|
}
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Boolean");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,6 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Error");
|
|
||||||
target.defineProperty(null, "name", "Error");
|
target.defineProperty(null, "name", "Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,12 @@ package me.topchetoeu.jscript.lib;
|
|||||||
|
|
||||||
import me.topchetoeu.jscript.Location;
|
import me.topchetoeu.jscript.Location;
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.engine.values.CodeFunction;
|
import me.topchetoeu.jscript.engine.values.CodeFunction;
|
||||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.engine.values.NativeFunction;
|
import me.topchetoeu.jscript.engine.values.NativeFunction;
|
||||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
|
||||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
|
|
||||||
@Native("Function") public class FunctionLib {
|
@Native("Function") public class FunctionLib {
|
||||||
@Native(thisArg = true) public static Object location(Context ctx, FunctionValue func) {
|
@Native(thisArg = true) public static Object location(Context ctx, FunctionValue func) {
|
||||||
@ -55,8 +51,4 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
@Native public static FunctionValue generator(FunctionValue func) {
|
@Native public static FunctionValue generator(FunctionValue func) {
|
||||||
return new GeneratorFunctionLib(func);
|
return new GeneratorFunctionLib(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Function");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeConstructor;
|
import me.topchetoeu.jscript.interop.NativeConstructor;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
|
|
||||||
@Native("Number") public class NumberLib {
|
@Native("Number") public class NumberLib {
|
||||||
@Native public static final double EPSILON = java.lang.Math.ulp(1.0);
|
@Native public static final double EPSILON = java.lang.Math.ulp(1.0);
|
||||||
@ -52,8 +49,4 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
public NumberLib(double val) {
|
public NumberLib(double val) {
|
||||||
this.value = val;
|
this.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Number");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
package me.topchetoeu.jscript.lib;
|
package me.topchetoeu.jscript.lib;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeConstructor;
|
import me.topchetoeu.jscript.interop.NativeConstructor;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
|
|
||||||
@Native("Object") public class ObjectLib {
|
@Native("Object") public class ObjectLib {
|
||||||
@Native public static ObjectValue assign(Context ctx, ObjectValue dst, Object... src) {
|
@Native public static ObjectValue assign(Context ctx, ObjectValue dst, Object... src) {
|
||||||
@ -212,8 +209,4 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
// else if (arg instanceof Symbol) return SymbolPolyfill.constructor(ctx, thisArg, arg);
|
// else if (arg instanceof Symbol) return SymbolPolyfill.constructor(ctx, thisArg, arg);
|
||||||
else return arg;
|
else return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Object");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.engine.values.NativeFunction;
|
import me.topchetoeu.jscript.engine.values.NativeFunction;
|
||||||
@ -14,9 +13,7 @@ import me.topchetoeu.jscript.engine.values.ObjectValue;
|
|||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.exceptions.InterruptException;
|
import me.topchetoeu.jscript.exceptions.InterruptException;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
|
|
||||||
@Native("Promise") public class PromiseLib {
|
@Native("Promise") public class PromiseLib {
|
||||||
private static class Handle {
|
private static class Handle {
|
||||||
@ -352,8 +349,4 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
public PromiseLib() {
|
public PromiseLib() {
|
||||||
this(STATE_PENDING, null);
|
this(STATE_PENDING, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Promise");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "RangeError");
|
|
||||||
target.defineProperty(null, "name", "RangeError");
|
target.defineProperty(null, "name", "RangeError");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,17 +3,14 @@ package me.topchetoeu.jscript.lib;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
import me.topchetoeu.jscript.engine.values.ArrayValue;
|
||||||
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
import me.topchetoeu.jscript.engine.values.FunctionValue;
|
||||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeConstructor;
|
import me.topchetoeu.jscript.interop.NativeConstructor;
|
||||||
import me.topchetoeu.jscript.interop.NativeGetter;
|
import me.topchetoeu.jscript.interop.NativeGetter;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
|
|
||||||
// TODO: implement index wrapping properly
|
// TODO: implement index wrapping properly
|
||||||
@Native("String") public class StringLib {
|
@Native("String") public class StringLib {
|
||||||
@ -263,8 +260,4 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
public StringLib(String val) {
|
public StringLib(String val) {
|
||||||
this.value = val;
|
this.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "String");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,13 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.engine.Context;
|
import me.topchetoeu.jscript.engine.Context;
|
||||||
import me.topchetoeu.jscript.engine.Environment;
|
|
||||||
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
import me.topchetoeu.jscript.engine.values.ObjectValue;
|
||||||
import me.topchetoeu.jscript.engine.values.Symbol;
|
import me.topchetoeu.jscript.engine.values.Symbol;
|
||||||
import me.topchetoeu.jscript.engine.values.Values;
|
import me.topchetoeu.jscript.engine.values.Values;
|
||||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||||
import me.topchetoeu.jscript.interop.InitType;
|
|
||||||
import me.topchetoeu.jscript.interop.Native;
|
import me.topchetoeu.jscript.interop.Native;
|
||||||
import me.topchetoeu.jscript.interop.NativeConstructor;
|
import me.topchetoeu.jscript.interop.NativeConstructor;
|
||||||
import me.topchetoeu.jscript.interop.NativeGetter;
|
import me.topchetoeu.jscript.interop.NativeGetter;
|
||||||
import me.topchetoeu.jscript.interop.NativeInit;
|
|
||||||
|
|
||||||
@Native("Symbol") public class SymbolLib {
|
@Native("Symbol") public class SymbolLib {
|
||||||
private static final Map<String, Symbol> symbols = new HashMap<>();
|
private static final Map<String, Symbol> symbols = new HashMap<>();
|
||||||
@ -63,8 +60,4 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
public SymbolLib(Symbol val) {
|
public SymbolLib(Symbol val) {
|
||||||
this.value = val;
|
this.value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "Symbol");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,9 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
@Native("SyntaxError") public class SyntaxErrorLib extends ErrorLib {
|
@Native("SyntaxError") public class SyntaxErrorLib extends ErrorLib {
|
||||||
@NativeConstructor(thisArg = true) public static ObjectValue constructor(Context ctx, Object thisArg, Object message) {
|
@NativeConstructor(thisArg = true) public static ObjectValue constructor(Context ctx, Object thisArg, Object message) {
|
||||||
var target = ErrorLib.constructor(ctx, thisArg, message);
|
var target = ErrorLib.constructor(ctx, thisArg, message);
|
||||||
target.defineProperty(ctx, "name", "SyntaxError");
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "SyntaxError");
|
|
||||||
target.defineProperty(null, "name", "SyntaxError");
|
target.defineProperty(null, "name", "SyntaxError");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,11 +11,9 @@ import me.topchetoeu.jscript.interop.NativeInit;
|
|||||||
@Native("TypeError") public class TypeErrorLib extends ErrorLib {
|
@Native("TypeError") public class TypeErrorLib extends ErrorLib {
|
||||||
@NativeConstructor(thisArg = true) public static ObjectValue constructor(Context ctx, Object thisArg, Object message) {
|
@NativeConstructor(thisArg = true) public static ObjectValue constructor(Context ctx, Object thisArg, Object message) {
|
||||||
var target = ErrorLib.constructor(ctx, thisArg, message);
|
var target = ErrorLib.constructor(ctx, thisArg, message);
|
||||||
target.defineProperty(ctx, "name", "TypeError");
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
@NativeInit(InitType.PROTOTYPE) public static void init(Environment env, ObjectValue target) {
|
||||||
target.defineProperty(null, env.symbol("Symbol.typeName"), "TypeError");
|
|
||||||
target.defineProperty(null, "name", "TypeError");
|
target.defineProperty(null, "name", "TypeError");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user