- case Lexer.FUNCTION:
- return new JS.Function() {
- public String toString() { return right.sourceName + ":" + right.line; }
- public String getSourceName() throws JS.Exn { return right.sourceName; }
- public Object _call(final JS.Array args) throws JS.Exn {
- Function save = JS.getCurrentFunction();
- JS.currentFunction.put(java.lang.Thread.currentThread(), this);
- JS.Scope scope = new JS.Scope(s) {
- // FIXME
- public String getSourceName() { return sourceName; }
- public Object get(Object key) throws JS.Exn {
- if (key.equals("trapee")) return org.xwt.Trap.currentTrapee();
- else if (key.equals("cascade")) return org.xwt.Trap.cascadeFunction;
- else if (key.equals("arguments")) return args;
- return super.get(key);
- }
- };
- int i = 0;
- ExprList list = (ExprList)left;
- for(i=0; i<list.size(); i++) {
- scope.declare(list.elementAt(i).string);
- scope.put(list.elementAt(i).string, args.get(new Integer(i)));
- }
- try {
- return right.eval(scope);
- } catch (ReturnException r) {
- return r.retval;
- } catch (ControlTransferException c) {
- throw new EvaluatorException("error, ControlTransferException tried to leave a function: "
- + c);
- } finally {
- if (save == null) JS.currentFunction.remove(java.lang.Thread.currentThread());
- else JS.currentFunction.put(java.lang.Thread.currentThread(), save);
- }
- }
- };
-