5 public class Test extends JS {
6 public static void main(String[] args) throws Exception {
7 if(args.length == 0) { System.err.println("Usage Test filename"); System.exit(1); }
8 JS f = JS.fromReader(args[0],0,new FileReader(args[0]));
9 System.out.println(((JSFunction)f).dump());
10 JSScope s = new JSScope(null);
11 s.put(JS.S("sys"),new Test());
12 f = JS.cloneWithNewParentScope(f,s);
13 JS ret = f.call(null,null,null,null,0);
14 System.out.println("Script returned: " + JS.toString(ret));
17 public JS get(JS key) throws JSExn {
18 if(!JS.isString(key)) return null;
19 if("print".equals(JS.toString(key))) return METHOD;
20 return super.get(key);
23 public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
24 if(!JS.isString(method)) return null;
25 if("print".equals(JS.toString(method))) {
26 System.out.println(JS.toString(a0));