Commit 23317050 authored by twanvl's avatar twanvl

Make ScriptClosure work correctly in combination with ScriptCompose: have a local scope.

parent c5fd6e40
...@@ -398,16 +398,18 @@ ScriptValueP ScriptClosure::simplify() { ...@@ -398,16 +398,18 @@ ScriptValueP ScriptClosure::simplify() {
} }
ScriptValueP ScriptClosure::eval(Context& ctx) const { ScriptValueP ScriptClosure::eval(Context& ctx) const {
LocalScope scope(ctx);
applyBindings(ctx); applyBindings(ctx);
return fun->eval(ctx); return fun->eval(ctx);
} }
ScriptValueP ScriptClosure::dependencies(Context& ctx, const Dependency& dep) const { ScriptValueP ScriptClosure::dependencies(Context& ctx, const Dependency& dep) const {
LocalScope scope(ctx);
applyBindings(ctx); applyBindings(ctx);
return fun->dependencies(ctx, dep); return fun->dependencies(ctx, dep);
} }
void ScriptClosure::applyBindings(Context& ctx) const { void ScriptClosure::applyBindings(Context& ctx) const {
FOR_EACH_CONST(b, bindings) { FOR_EACH_CONST(b, bindings) {
if (ctx.getVariableScope(b.first) != 0) { if (ctx.getVariableScope(b.first) != 1) {
ctx.setVariable(b.first, b.second); ctx.setVariable(b.first, b.second);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment