fix: don't use Context.NULL in global scope
This commit is contained in:
parent
662dcc1ac1
commit
ccf75d6066
@ -1,4 +1,4 @@
|
|||||||
project_group = me.topchetoeu
|
project_group = me.topchetoeu
|
||||||
project_name = jscript
|
project_name = jscript
|
||||||
project_version = 0.9.4-beta
|
project_version = 0.9.5-beta
|
||||||
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
main_class = me.topchetoeu.jscript.utils.JScriptRepl
|
||||||
|
@ -24,12 +24,12 @@ public class GlobalScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object define(Context ctx, String name) {
|
public Object define(Context ctx, String name) {
|
||||||
if (Values.hasMember(Context.NULL, obj, name, false)) return name;
|
if (Values.hasMember(ctx, obj, name, false)) return name;
|
||||||
obj.defineProperty(Context.NULL, name, null);
|
obj.defineProperty(ctx, name, null);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
public void define(Context ctx, String name, Variable val) {
|
public void define(Context ctx, String name, Variable val) {
|
||||||
obj.defineProperty(Context.NULL, name,
|
obj.defineProperty(ctx, name,
|
||||||
new NativeFunction("get " + name, args -> val.get(args.ctx)),
|
new NativeFunction("get " + name, args -> val.get(args.ctx)),
|
||||||
new NativeFunction("set " + name, args -> { val.set(args.ctx, args.get(0)); return null; }),
|
new NativeFunction("set " + name, args -> { val.set(args.ctx, args.get(0)); return null; }),
|
||||||
true, true
|
true, true
|
||||||
@ -42,7 +42,7 @@ public class GlobalScope {
|
|||||||
for (var n : names) define(ctx, n);
|
for (var n : names) define(ctx, n);
|
||||||
}
|
}
|
||||||
public void define(Context ctx, boolean readonly, FunctionValue val) {
|
public void define(Context ctx, boolean readonly, FunctionValue val) {
|
||||||
define(null, val.name, readonly, val);
|
define(ctx, val.name, readonly, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object get(Context ctx, String name) {
|
public Object get(Context ctx, String name) {
|
||||||
|
@ -8,7 +8,7 @@ public class NativeWrapper extends ObjectValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectValue getPrototype(Context ctx) {
|
public ObjectValue getPrototype(Context ctx) {
|
||||||
if (prototype == NATIVE_PROTO) return ctx.environment.wrappers.getProto(wrapped.getClass());
|
if (ctx.environment != null && prototype == NATIVE_PROTO) return ctx.environment.wrappers.getProto(wrapped.getClass());
|
||||||
else return super.getPrototype(ctx);
|
else return super.getPrototype(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user