X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FCompiledFunctionImpl.java;h=951133388d792c910019d5112f0d482d033cb40c;hb=030e60db31661dd07b688774b4ef16e1f91d72e2;hp=0755251e7fc04c5cf8906c48b9608fda40cc5901;hpb=77f51cd3e157cf6fd2ae85ce774444bb85ea7b81;p=org.ibex.core.git diff --git a/src/org/xwt/js/CompiledFunctionImpl.java b/src/org/xwt/js/CompiledFunctionImpl.java index 0755251..9511333 100644 --- a/src/org/xwt/js/CompiledFunctionImpl.java +++ b/src/org/xwt/js/CompiledFunctionImpl.java @@ -4,8 +4,9 @@ package org.xwt.js; import org.xwt.util.*; import java.io.*; +// FIXME: could use some cleaning up /** a JavaScript function, compiled into bytecode */ -class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens { +class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { // Fields and Accessors /////////////////////////////////////////////// @@ -13,13 +14,12 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens { private String sourceName; public String getSourceName() throws JS.Exn { return sourceName; } - /** the first line of this function */ - private int firstLine; - public int getFirstLine() throws JS.Exn { return firstLine; } - /** 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]; @@ -48,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)); } @@ -104,9 +100,11 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens { int pc = 0; void eval(JS.Scope s) { - final Vec t = JS.Thread.fromJavaThread(java.lang.Thread.currentThread()).stack; + final JS.Thread cx = JS.Thread.fromJavaThread(java.lang.Thread.currentThread()); + final Vec t = cx.stack; OUTER: for(pc=0; pc