X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FTest.java;h=c432a6a384242b49f85386f07f3157a9a7e9ca33;hb=a19b897271a8ab6b25aba63e4b30223c2477c28d;hp=d2dd77f56726561bfc3a8f093e8bbdab6652015f;hpb=4c96b0f7e40e4689434c46e4300cc9bef9d0fab9;p=org.ibex.core.git diff --git a/src/org/ibex/js/Test.java b/src/org/ibex/js/Test.java index d2dd77f..c432a6a 100644 --- a/src/org/ibex/js/Test.java +++ b/src/org/ibex/js/Test.java @@ -14,7 +14,7 @@ public class Test extends JS { s.put(JS.S("sys"),new Test()); f = JS.cloneWithNewParentScope(f,s); //JS ret = f.call(null,null,null,null,0); - Interpreter i = new Interpreter((JSFunction)f, true, new JSArray()); + Interpreter i = new Interpreter((JSFunction)f, true, new Interpreter.JSArgs(f)); JS ret = i.resume(); while(up != null) { JS.UnpauseCallback up = Test.up; Test.up = null; @@ -31,6 +31,8 @@ public class Test extends JS { public JS get(JS key) throws JSExn { 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 { @@ -51,15 +53,29 @@ public class Test extends JS { } catch(NotPauseableException e) { throw new Error("should never happen"); } - return; - } + return; + } + if("exit".equals(JS.toString(key))) { + System.exit(JS.toInt(val)); + return; + } super.put(key,val); } public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn { if(!JS.isString(method)) return null; if("print".equals(JS.toString(method))) { - System.out.println(JS.toString(a0)); + System.out.println(JS.debugToString(a0)); + 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;