2003/11/22 06:44:39
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:03 +0000 (07:42 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:03 +0000 (07:42 +0000)
darcs-hash:20040130074203-2ba56-4b29fa2de87634944dc7f59d57a7a7660a60727d.gz

src/org/xwt/js/Interpreter.java
src/org/xwt/js/JS.java
src/org/xwt/util/Preprocessor.java

index c049088..fe118e5 100644 (file)
@@ -182,7 +182,7 @@ class Interpreter implements ByteCodes, Tokens {
                             }
                         }
                         scope = ((CallMarker)o).scope;
-                        pc = ((CallMarker)o).pc;
+                        pc = ((CallMarker)o).pc - 1;
                         f = (JSFunction)((CallMarker)o).f;
                         stack.push(retval);
                         continue OUTER;
@@ -290,7 +290,6 @@ class Interpreter implements ByteCodes, Tokens {
                         stack.pop();
                     }
                 }
-
                 Object[] rest = numArgs > 3 ? new Object[numArgs - 3] : null;
                 for(int i=numArgs - 1; i>2; i--) rest[i-3] = stack.pop();
                 Object a2 = numArgs <= 2 ? null : stack.pop();
index 0f5373c..5ade735 100644 (file)
@@ -18,7 +18,7 @@ public class JS {
 
     public static String getSourceName() {
         Interpreter c = Interpreter.current();
-        return c.f == null ? null : c.f.sourceName;
+        return c == null || c.f == null ? null : c.f.sourceName;
     } 
 
     public static class PausedException extends Exception { PausedException() { } }
index cc6d34d..7290e14 100644 (file)
@@ -153,8 +153,8 @@ PROCESS:
                 if (expEnd - expStart <= 1) { err.add(new Error("badly formed #switch statement")); continue PROCESS; }
                 String expr = trimmed.substring(expStart, expEnd);
 
-                out.println("final String ccSwitch"+enumSwitch+" = (String)("+expr+");"+
-                    "switch(ccSwitch"+enumSwitch+".length()) {");
+                out.println("final String ccSwitch"+enumSwitch+" = (String)("+expr+");");
+                out.println("SUCCESS:do { switch(ccSwitch"+enumSwitch+".length()) {");
 
                 Hashtable[] byLength = new Hashtable[255];
                 String key = null;
@@ -196,8 +196,9 @@ PROCESS:
                     buildTrie("", byLength[i]);
                     out.println("}; break; }");
                 }
-                if (Default != null) out.println("default: { " + Default + " }");
                 out.println("} //switch");
+                if (Default != null) out.println(Default);
+                out.println("} while(false); //OUTER");
                 enumSwitch++;
 
             } else {
@@ -231,7 +232,7 @@ PROCESS:
                 String code = (String)cases.get(keys.elementAt(i));
                 code = code.substring(0, code.length() - 1);
                 String key = (String)keys.elementAt(i);
-                out.println("if (\""+key+"\".equals(ccSwitch"+enumSwitch+")) { " + code + " } break; ");
+                out.println("if (\""+key+"\".equals(ccSwitch"+enumSwitch+")) { if (true) do { " + code + " } while(false); break SUCCESS; } break; ");
             }
         }
     }