Short-circuiting "and" and "or" operators

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1461 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2010-07-23 23:52:34 +00:00
parent 603442e75b
commit 0625cd0aff
6 changed files with 65 additions and 6 deletions
+19
View File
@@ -74,6 +74,25 @@ ScriptValueP Context::eval(const Script& script, bool useScope) {
}
break;
}
// Short-circuiting and/or = conditional jump without pop
case I_JUMP_SC_AND: {
bool condition = *stack.back();
if (!condition) {
instr = &script.instructions[0] + i.data;
} else {
stack.pop_back();
}
break;
}
case I_JUMP_SC_OR: {
bool condition = *stack.back();
if (condition) {
instr = &script.instructions[0] + i.data;
} else {
stack.pop_back();
}
break;
}
// Get a variable
case I_GET_VAR: {