private Vec children = new Vec(); ///< during XML parsing, this holds the list of currently-parsed children; null otherwise
private int numunits = -1; ///< see numUnits(); -1 means that this value has not yet been computed
- private JS.CompiledFunction script = null; ///< the script on this node
+ private Function script = null; ///< the script on this node
private String fileName = "unknown"; ///< the filename this node came from; used only for debugging
private Vec preapply = new Vec(); ///< templates that should be preapplied (in the order of application)
// Instance Members that are only meaningful on root Template //////////////////////////////////////
private JS.Scope staticScope = null; ///< the scope in which the static block is executed
- private JS.CompiledFunction staticscript = null; ///< the script on the static node of this template, null already performed
+ private Function staticscript = null; ///< the script on the static node of this template, null already performed
// Only used during parsing /////////////////////////////////////////////////////////////////
JS.Scope getStatic() {
if (staticScope == null) staticScope = new JS.Scope(null);
if (staticscript == null) return staticScope;
- JS.CompiledFunction temp = staticscript;
+ Function temp = staticscript;
staticscript = null;
- temp.call(new JS.Array(), staticScope);
+ new JS.Context(temp, staticScope).resume();
return staticScope;
}
for (int i=0; children != null && i<children.size(); i++) {
Box kid = new Box();
((Template)children.elementAt(i)).apply(kid, callback, xwt, pis);
+
+ // FIXME: tailcall?
b.put(b.numChildren(), kid);
}
- if (script != null) script.call(new JS.Array(), pis);
+ if (script != null) new JS.Context(script, pis).resume();
for(int i=0; keys != null && i<keys.length; i++)
if (vals[i] instanceof String && ((String)vals[i]).charAt(0) == '$') b.put(keys[i], pis.get(vals[i]));
}
}
- private JS.CompiledFunction parseScript(boolean isstatic) {
- JS.CompiledFunction thisscript = null;
+ private Function parseScript(boolean isstatic) {
+ Function thisscript = null;
try {
thisscript = JS.parse(t.fileName + (isstatic ? "._" : ""), t.content_start, new StringReader(t.content.toString()));
} catch (IOException ioe) {
}
public boolean isTransparent() { return true; }
public Object get(Object key) {
+ if (super.has(key)) return super.get(key);
if (key.equals("xwt")) return xwt;
if (key.equals("static")) return myStatic;
- if (Box.SpecialBoxProperty.specialBoxProperties.get(key.toString()) != null) return getParentScope().get(key);
- if (super.has(key)) return super.get(key);
- Object ret = xwt.rr.get(key);
- if (ret != null) return ret;
- throw new JS.Exn("must declare " + key + " before using it!");
+ return super.get(key);
}
- public void put(Object key, Object val) {
- if (Box.SpecialBoxProperty.specialBoxProperties.get(key.toString()) != null) getParentScope().put(key, val);
- else if (super.has(key)) super.put(key, val);
- else throw new JS.Exn("must declare " + key + " before using it!");
+ public Object put(Object key, Object val) {
+ if (super.has(key)) return super.put(key, val);
+ return super.put(key, val);
}
}