JS f = JS.fromReader(args[0],1,new FileReader(args[0]));
System.out.println(((JSFunction)f).dump());
JS s = new JS.O();
- s.put(JS.S("sys"),new Test());
- f = JS.cloneWithNewGlobalScope(f,s);
+ s.put(Script.S("sys"),new Test());
+ f = Script.cloneWithNewGlobalScope(f,s);
//JS ret = f.call(null,null,null,null,0);
Interpreter i = new Interpreter((JSFunction)f, true, new JS[0]);
JS ret = (JS)i.run(null);
}
public void put(JS key, JS val) throws JSExn {
- if("bgput".equals(JS.toString(key))) {
- action = JS.toString(val);
+ if("bgput".equals(Script.toString(key))) {
+ action = Script.toString(val);
try {
Script.pause();
} catch(Pausable.NotPausableException e) {
}
return;
}
- if("exit".equals(JS.toString(key))) {
- System.exit(JS.toInt(val));
+ if("exit".equals(Script.toString(key))) {
+ System.exit(Script.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.debugToString(a0));
+ if("print".equals(Script.toString(method))) {
+ System.out.println(Script.str(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);
+ if("clone".equals(Script.toString(method))) return a0 == null ? null : a0.jsclone();
+ if("firethis".equals(Script.toString(method))) {
+ String action = Script.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"));
+ else if(action.equals("put")) a1.putAndTriggerTraps(key,Script.S("some value"));
+ else if(action.equals("trigger")) return target.justTriggerTraps(key,Script.S("some trigger value"));
return null;
}
return null;