X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FTest.java;h=1bf62e103c72a122c4e922b3a90eb13030362f3d;hp=478ef8edcef6b6687b618808fb0e978ba6ff3b22;hb=3f8aa5300e178e8975b0edc896a5a9d303e7bdf3;hpb=b1c3851aa91d7da83b62c267596ecacb6ac73868 diff --git a/src/org/ibex/js/Test.java b/src/org/ibex/js/Test.java index 478ef8e..1bf62e1 100644 --- a/src/org/ibex/js/Test.java +++ b/src/org/ibex/js/Test.java @@ -10,9 +10,9 @@ public class Test extends JS { if(args.length == 0) { System.err.println("Usage Test filename"); System.exit(1); } JS f = JS.fromReader(args[0],1,new FileReader(args[0])); System.out.println(((JSFunction)f).dump()); - JSScope s = new JSScope(new JSScope.Global()); + JS s = new JS.O(); s.put(JS.S("sys"),new Test()); - f = JS.cloneWithNewParentScope(f,s); + f = JS.cloneWithNewGlobalScope(f,s); //JS ret = f.call(null,null,null,null,0); Interpreter i = new Interpreter((JSFunction)f, true, new Interpreter.JSArgs(f)); JS ret = i.resume(); @@ -32,6 +32,7 @@ public class Test extends JS { if(!JS.isString(key)) return null; if("print".equals(JS.toString(key))) return METHOD; if("clone".equals(JS.toString(key))) return METHOD; + if("firethis".equals(JS.toString(key))) return METHOD; if("bgget".equals(JS.toString(key))) { action = "bgget"; try { @@ -68,6 +69,15 @@ public class Test extends JS { return null; } if("clone".equals(JS.toString(method))) return a0 == null ? null : a0.jsclone(); + if("firethis".equals(JS.toString(method))) { + String action = JS.toString(a0); + JS target = a1; + JS key = a2; + if(action.equals("get")) return a1.getAndTriggerTraps(key); + else if(action.equals("put")) a1.putAndTriggerTraps(key,JS.S("some value")); + else if(action.equals("trigger")) return target.justTriggerTraps(key,JS.S("some trigger value")); + return null; + } return null; } }