X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2Fjs%2FJSFunction.java;fp=src%2Forg%2Fibex%2Fjs%2FJSFunction.java;h=d50e5661ac61812bd4405982c1ac39fc7c220a3e;hb=2c7492501427a4876792cc12492d2185a605d7c4;hp=71da16250ce8664a7a71f57ba9228da668782e9b;hpb=85c640ef9709fd71d0f12d8918ce125dbcc58461;p=org.ibex.core.git diff --git a/src/org/ibex/js/JSFunction.java b/src/org/ibex/js/JSFunction.java index 71da162..d50e566 100644 --- a/src/org/ibex/js/JSFunction.java +++ b/src/org/ibex/js/JSFunction.java @@ -5,7 +5,8 @@ import java.io.*; import org.ibex.util.*; /** A JavaScript function, compiled into bytecode */ -class JSFunction extends JS implements ByteCodes, Tokens, Task { +// FIXME: This shouldn't be public, needed for public add/delTrap (which is needed for the Template.java hack) +public class JSFunction extends JS implements ByteCodes, Tokens, Task { // Fields and Accessors /////////////////////////////////////////////// @@ -32,21 +33,6 @@ class JSFunction extends JS implements ByteCodes, Tokens, Task { i.resume(); } - /** parse and compile a function */ - public static JSFunction _fromReader(String sourceName, int firstLine, Reader sourceCode) throws IOException { - JSFunction ret = new JSFunction(sourceName, firstLine, null); - if (sourceCode == null) return ret; - Parser p = new Parser(sourceCode, sourceName, firstLine); - while(true) { - int s = ret.size; - p.parseStatement(ret, null); - if (s == ret.size) break; - } - ret.add(-1, LITERAL, null); - ret.add(-1, RETURN); - return ret; - } - public JSFunction _cloneWithNewParentScope(JSScope s) { JSFunction ret = new JSFunction(sourceName, firstLine, s); // Reuse the same op, arg, line, and size variables for the new "instance" of the function @@ -106,7 +92,7 @@ class JSFunction extends JS implements ByteCodes, Tokens, Task { sb.append("\n" + sourceName + ": " + firstLine + "\n"); for (int i=0; i < size; i++) { sb.append(prefix); - sb.append(i).append(" (").append(line[i]).append(") :"); + sb.append(i).append(" (").append(line[i]).append("): "); if (op[i] < 0) sb.append(bytecodeToString[-op[i]]); else sb.append(codeToString[op[i]]); sb.append(" "); @@ -119,6 +105,9 @@ class JSFunction extends JS implements ByteCodes, Tokens, Task { sb.append(" finally: ").append(jmps[1] < 0 ? "No finally block" : ""+(i+jmps[1])); } else if(op[i] == NEWFUNCTION) { sb.append(((JSFunction) arg[i]).dump(prefix + " ")); + } else if(op[i] == NEWSCOPE) { + int n = ((JSNumber)arg[i]).toInt(); + sb.append(" base: " + (n>>>16) + " size: " + (n&0xffff)); } sb.append("\n"); }