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

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@994 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-06-18 23:25:26 +00:00
parent e86d546c4a
commit 13157f6d67
+3 -1
View File
@@ -398,16 +398,18 @@ ScriptValueP ScriptClosure::simplify() {
}
ScriptValueP ScriptClosure::eval(Context& ctx) const {
LocalScope scope(ctx);
applyBindings(ctx);
return fun->eval(ctx);
}
ScriptValueP ScriptClosure::dependencies(Context& ctx, const Dependency& dep) const {
LocalScope scope(ctx);
applyBindings(ctx);
return fun->dependencies(ctx, dep);
}
void ScriptClosure::applyBindings(Context& ctx) const {
FOR_EACH_CONST(b, bindings) {
if (ctx.getVariableScope(b.first) != 0) {
if (ctx.getVariableScope(b.first) != 1) {
ctx.setVariable(b.first, b.second);
}
}