hacks to cope with org.ibex.xt
authoradam <adam@megacz.com>
Tue, 19 Oct 2004 07:48:56 +0000 (07:48 +0000)
committeradam <adam@megacz.com>
Tue, 19 Oct 2004 07:48:56 +0000 (07:48 +0000)
darcs-hash:20041019074856-5007d-be85185c003a4cdbe467806139aa560f0929bd83.gz

src/org/ibex/js/JS.java
src/org/ibex/js/JSFunction.java
src/org/ibex/js/Parser.java

index 7cd1fc7..9aa9bd4 100644 (file)
@@ -8,6 +8,7 @@ import java.util.*;
 /** The minimum set of functionality required for objects which are manipulated by JavaScript */
 public class JS /*extends org.ibex.util.BalancedTree*/ implements Serializable { 
 
+    public static final long serialVersionUID = 572634985343962922L;
     public static boolean checkAssertions = false;
 
     public static final Object METHOD = new Object();
@@ -187,6 +188,12 @@ public class JS /*extends org.ibex.util.BalancedTree*/ implements Serializable {
         return ((JSFunction)j)._cloneWithNewParentScope(s);
     }
 
+    // HACK
+    public static Vec getFormalArgs(JS j) { return ((JSFunction)j).formalArgs; }
+
+    // HACK
+    public static JSScope getParentScope(JS j) { return ((JSFunction)j).parentScope; }
+
     public static Object eval(JS j) throws JSExn {
         Interpreter cx = new Interpreter((JSFunction)j, false, new JSArray(), false);
         return cx.resume();
index 4bf41e4..9dfc5db 100644 (file)
@@ -21,7 +21,7 @@ class JSFunction extends JS implements ByteCodes, Tokens, Task {
     int size = 0;                  ///< the number of instruction/argument pairs
 
     JSScope parentScope;           ///< the default scope to use as a parent scope when executing this
-
+    Vec formalArgs = new Vec();
 
     // Public //////////////////////////////////////////////////////////////////////////////
 
@@ -55,6 +55,7 @@ class JSFunction extends JS implements ByteCodes, Tokens, Task {
         ret.arg = this.arg;
         ret.line = this.line;
         ret.size = this.size;
+        ret.formalArgs = this.formalArgs;
         ret.numFormalArgs = this.numFormalArgs;
         return ret;
     }
index 51b23b8..9f62439 100644 (file)
@@ -281,7 +281,7 @@ class Parser extends Lexer implements ByteCodes {
                 if (peekToken() == NAME) {
                     consume(NAME);                                        // a named argument
                     String varName = string;
-                    
+                    b2.formalArgs.push(varName);
                     b2.add(parserLine, DUP);                              // dup the args array 
                     b2.add(parserLine, GET, JS.N(numArgs - 1));   // retrieve it from the arguments array
                     b2.add(parserLine, TOPSCOPE);