Fixed bug in dependency checker that caused it to overwrite variables outside its scope

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1063 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-05 17:02:32 +00:00
parent 0ebf7cc1f1
commit dd006b9eca
3 changed files with 20 additions and 7 deletions
+10
View File
@@ -265,12 +265,22 @@ ScriptValueP Context::makeClosure(const ScriptValueP& fun) {
size_t Context::openScope() {
level += 1;
#ifdef _DEBUG
scopes.push_back(shadowed.size());
assert(scopes.size() == level);
#endif
return shadowed.size();
}
void Context::closeScope(size_t scope) {
assert(level > 0);
assert(scope <= shadowed.size());
level -= 1;
#ifdef _DEBUG
assert(!scopes.empty());
assert(scopes.back() == scope);
scopes.pop_back();
assert(scopes.size() == level);
#endif
// restore shadowed variables
while (shadowed.size() > scope) {
variables[shadowed.back().variable] = shadowed.back().value;