mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-13 05:57:00 -04:00
Added I_TAILCALL to dependency analysis.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1418 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -173,6 +173,8 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
|
|||||||
|
|
||||||
// Analyze the current instruction
|
// Analyze the current instruction
|
||||||
Instruction i = *instr++;
|
Instruction i = *instr++;
|
||||||
|
// If a scope is created, destroy it at end of block.
|
||||||
|
scoped_ptr<LocalScope> scope;
|
||||||
switch (i.instr) {
|
switch (i.instr) {
|
||||||
case I_NOP: break;
|
case I_NOP: break;
|
||||||
// Push a constant (as normal)
|
// Push a constant (as normal)
|
||||||
@@ -261,9 +263,8 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function call (as normal)
|
// Function call (as normal)
|
||||||
case I_CALL: {
|
case I_CALL: scope.reset(new LocalScope(*this)); //new scope
|
||||||
// new scope
|
case I_TAILCALL: {
|
||||||
size_t scope = openScope();
|
|
||||||
// prepare arguments
|
// prepare arguments
|
||||||
for (unsigned int j = 0 ; j < i.data ; ++j) {
|
for (unsigned int j = 0 ; j < i.data ; ++j) {
|
||||||
setVariable((Variable)instr[i.data - j - 1].data, stack.back());
|
setVariable((Variable)instr[i.data - j - 1].data, stack.back());
|
||||||
@@ -272,8 +273,6 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
|
|||||||
instr += i.data; // skip arguments, there had better not be any jumps into the argument list
|
instr += i.data; // skip arguments, there had better not be any jumps into the argument list
|
||||||
// get function and call
|
// get function and call
|
||||||
stack.back() = stack.back()->dependencies(*this, dep);
|
stack.back() = stack.back()->dependencies(*this, dep);
|
||||||
// restore scope
|
|
||||||
closeScope(scope);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user