2003/06/16 08:55:37
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:01:20 +0000 (07:01 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:01:20 +0000 (07:01 +0000)
darcs-hash:20040130070120-2ba56-4f626d19b1481a2b43c46a6c3fec5d0318af9eb6.gz

src/org/xwt/js/CompiledFunctionImpl.java
src/org/xwt/js/JS.java
src/org/xwt/js/Parser.java
src/org/xwt/util/Log.java

index 416cd94..9d61a0f 100644 (file)
@@ -17,6 +17,9 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens {
     /** the line numbers */
     private int[] line = new int[10];
 
+    /** the first line of this script */
+    private int firstLine = -1;
+
     /** the instructions */
     private int[] op = new int[10];
 
@@ -45,16 +48,12 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens {
         this.parentScope = parentScope;
         if (sourceCode == null) return;
         Parser p = new Parser(sourceCode, sourceName, firstLine);
-        try {
-            while(true) {
-                int s = size();
-                p.parseStatement(this, null);
-                if (s == size()) break;
-            }
-            add(-1, Tokens.RETURN);
-        } catch (Exception e) {
-            if (Log.on) Log.log(Parser.class, e);
+        while(true) {
+            int s = size();
+            p.parseStatement(this, null);
+            if (s == size()) break;
         }
+        add(-1, Tokens.RETURN);
     }
     
     public Object call(JS.Array args) throws JS.Exn { return call(args, new FunctionScope(sourceName, parentScope)); }
@@ -105,7 +104,7 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens {
         final Vec t = cx.stack;
         OUTER: for(pc=0; pc<size; pc++) {
             String label = null;
-            cx.line = line[op];
+            cx.line = line[pc];
             switch(op[pc]) {
             case LITERAL: t.push(arg[pc]); break;
             case OBJECT: t.push(new JS.Obj()); break;
index 24f133a..1e246b1 100644 (file)
@@ -124,7 +124,7 @@ public abstract class JS {
 
         CompiledFunction currentCompiledFunction = null;
         Vec stack = new Vec();
-        private int line = -1;
+        int line = -1;
 
         /** binds this thread to the current Java Thread */
         public void bindToCurrentJavaThread() { javaThreadToJSThread.put(java.lang.Thread.currentThread(), this); }
index cd5dfc2..c3f90ca 100644 (file)
@@ -496,7 +496,7 @@ class Parser extends Lexer implements ByteCodes {
                 consume(COMMA);
             }
             b.add(parserLine, POP);                              // pop off the topscope
-            if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1) consume(SEMI);
+            if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
             break;
         }
         case IF: {
@@ -708,7 +708,7 @@ class Parser extends Lexer implements ByteCodes {
                 pushBackToken(NAME, possiblyTheLabel);  
                 startExpr(b, -1);
                 b.add(parserLine, POP);
-                if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1) consume(SEMI);
+                if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
                 break;
             }
         }
@@ -727,7 +727,7 @@ class Parser extends Lexer implements ByteCodes {
             pushBackToken();
             startExpr(b, -1);
             b.add(parserLine, POP);
-            if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1) consume(SEMI);
+            if ((mostRecentlyReadToken != RC || peekToken() == SEMI) && peekToken() != -1 && mostRecentlyReadToken != SEMI) consume(SEMI);
             break;
         }
         }
index a367004..3a54c4d 100644 (file)
@@ -22,7 +22,7 @@ public class Log {
         if (current == null) {
             log("<none>", message);
         } else {
-            log(current.getSourceName() + current.getLine(), message);
+            log(current.getSourceName() + ":" + current.getLine(), message);
         }
     }