Script cleanup for standards-compliance (not going out of bounds on vectors).

I_POP is no longer considered a binary instruction because all other binary instructions expect the stack to have at least two elements - adding a manual check is kludgy
Added I_TAILCALL to accomodate indended optimizations



git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1417 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
coppro
2009-08-02 01:30:59 +00:00
parent 7af4cd4bd0
commit 79b18c1e72
5 changed files with 37 additions and 26 deletions
+7 -2
View File
@@ -99,7 +99,11 @@ ScriptValueP Script::dependencies(Context& ctx, const Dependency& dep) const {
static const unsigned int INVALID_ADDRESS = 0x03FFFFFF;
unsigned int Script::addInstruction(InstructionType t) {
assert( t == I_JUMP || t == I_JUMP_IF_NOT || t == I_LOOP || t == I_LOOP_WITH_KEY);
assert( t == I_JUMP
|| t == I_JUMP_IF_NOT
|| t == I_LOOP
|| t == I_LOOP_WITH_KEY
|| t == I_POP);
Instruction i = {t, {INVALID_ADDRESS}};
instructions.push_back(i);
return getLabel() - 1;
@@ -179,7 +183,6 @@ String Script::dumpInstr(unsigned int pos, Instruction i) const {
break;
case I_BINARY: ret += _("binary\t");
switch (i.instr2) {
case I_POP: ret += _("pop"); break;
case I_ITERATOR_R: ret += _("iterator_r"); break;
case I_MEMBER: ret += _("member"); break;
case I_ADD: ret += _("+"); break;
@@ -210,6 +213,8 @@ String Script::dumpInstr(unsigned int pos, Instruction i) const {
}
break;
case I_DUP: ret += _("dup"); break;
case I_POP: ret += _("pop"); break;
case I_TAILCALL: ret += _("tailcall"); break;
}
// arg
switch (i.instr) {