2003/10/31 10:57:24
[org.ibex.core.git] / src / org / xwt / js / Parser.java
index 323d1dc..7360876 100644 (file)
@@ -248,12 +248,13 @@ class Parser extends Lexer implements ByteCodes {
             b2.add(parserLine, PUT);
 
             while(peekToken() != RP) {                                    // run through the list of argument names
+                numArgs++;
                 if (peekToken() == NAME) {
                     consume(NAME);                                        // a named argument
                     String varName = string;
                     
                     b2.add(parserLine, DUP);                              // dup the args array 
-                    b2.add(parserLine, GET, new Integer(numArgs));   // retrieve it from the arguments array
+                    b2.add(parserLine, GET, new Integer(numArgs - 1));   // retrieve it from the arguments array
                     b2.add(parserLine, TOPSCOPE);
                     b2.add(parserLine, SWAP);
                     b2.add(parserLine, DECLARE, varName);                  // declare the name
@@ -264,11 +265,10 @@ class Parser extends Lexer implements ByteCodes {
                 }
                 if (peekToken() == RP) break;
                 consume(COMMA);
-                numArgs++;
             }
             consume(RP);
 
-            b2.numFormalArgs = numArgs + 1;
+            b2.numFormalArgs = numArgs;
             b2.add(parserLine, POP);                                      // pop off the arguments array
             b2.add(parserLine, POP);                                      // pop off TOPSCOPE