more optimal jsfunction calls
[org.ibex.core.git] / src / org / ibex / js / Parser.java
index c6c9d9e..bcc5033 100644 (file)
@@ -431,8 +431,8 @@ class Parser extends Lexer implements ByteCodes {
             // Method calls are implemented by doing a GET_PRESERVE
             // first.  If the object supports method calls, it will
             // return JS.METHOD
-            int n = parseArgs(b, 2);
             b.add(parserLine, GET_PRESERVE);
+            int n = parseArgs(b,0);
             b.add(parserLine, CALLMETHOD, JS.N(n));
             break;
         }
@@ -475,7 +475,7 @@ class Parser extends Lexer implements ByteCodes {
 
         switch (tok) {
         case LP: {  // invocation (not grouping)
-            int n = parseArgs(b, 1);
+            int n = parseArgs(b,0);
             b.add(parserLine, CALL, JS.N(n));
             break;
         }
@@ -560,7 +560,7 @@ class Parser extends Lexer implements ByteCodes {
             i++;
             if (peekToken() != COMMA) {
                 startExpr(b, NO_COMMA);
-                b.add(parserLine, SWAP, JS.N(pushdown));
+                if(pushdown != 0) b.add(parserLine, SWAP, JS.N(pushdown));
                 if (peekToken() == RP) break;
             }
             consume(COMMA);