- Added a RETI instruction for returning 15-bit signed immediate values.
- Changed Actor's Damage property into an actual function. All access to the damage property must now be done through GetMissileDamage. actor->GetMissileDamage(0, 1) is equivalent to the former actor->Damage, for the case where actor->Damage was not an expression. (I suppose I will probably need to make a thunk for DECORATE expressions that want to read it.) - Cleaned up some decorate expression evaluation functions that are no longer used. SVN r3919 (scripting)
This commit is contained in:
parent
5e184260ac
commit
6e88529324
23 changed files with 270 additions and 195 deletions
|
|
@ -490,6 +490,27 @@ size_t VMFunctionBuilder::EmitLoadInt(int regnum, int value)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// VMFunctionBuilder :: EmitRetInt
|
||||
//
|
||||
// Returns an integer, using either an immediate value or a constant
|
||||
// register, as appropriate.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
size_t VMFunctionBuilder::EmitRetInt(int retnum, bool final, int value)
|
||||
{
|
||||
if (value >= -16384 && value <= 16383)
|
||||
{
|
||||
return Emit(OP_RETI, retnum, value | (final << 15));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Emit(OP_RETI, retnum, REGT_INT | REGT_KONST | (final ? REGT_FINAL : 0), GetConstantInt(value));
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// VMFunctionBuilder :: Backpatch
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
size_t Emit(int opcode, int opa, VM_SHALF opbc);
|
||||
size_t Emit(int opcode, int opabc);
|
||||
size_t EmitLoadInt(int regnum, int value);
|
||||
size_t EmitRetInt(int retnum, bool final, int value);
|
||||
|
||||
void Backpatch(size_t addr, size_t target);
|
||||
void BackpatchToHere(size_t addr);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#define RII16 MODE_AI | MODE_BCJOINT | MODE_BCIMMS
|
||||
#define I24 MODE_ABCJOINT
|
||||
#define I8 MODE_AIMMZ | MODE_BUNUSED | MODE_CUNUSED
|
||||
#define I8I16 MODE_AIMMZ | MODE_BCIMMZ
|
||||
#define __BCP MODE_AUNUSED | MODE_BCJOINT | MODE_BCPARAM
|
||||
#define RPI8 MODE_AP | MODE_BIMMZ | MODE_CUNUSED
|
||||
#define KPI8 MODE_AKP | MODE_BIMMZ | MODE_CUNUSED
|
||||
|
|
@ -246,6 +247,22 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
|
|||
}
|
||||
break;
|
||||
|
||||
case OP_RETI:
|
||||
if (a == 0 && code[i].i16 & 0x8000)
|
||||
{
|
||||
col = printf_wrapper(out, "%d", (code[i].i16 << 17) >> 17);
|
||||
}
|
||||
else
|
||||
{
|
||||
col = print_reg(out, 0, a, (mode & MODE_ATYPE) >> MODE_ASHIFT, 24, func);
|
||||
col += print_reg(out, col, (code[i].i16 << 17) >> 17, MODE_IMMS, 16, func);
|
||||
if (code[i].i16 & 0x8000)
|
||||
{
|
||||
col += printf_wrapper(out, " [final]");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((mode & MODE_BCTYPE) == MODE_BCCAST)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -593,6 +593,18 @@ begin:
|
|||
return a < numret ? a + 1 : numret;
|
||||
}
|
||||
NEXTOP;
|
||||
OP(RETI):
|
||||
assert(ret != NULL || numret == 0);
|
||||
if (a < numret)
|
||||
{
|
||||
// Shifting by 17 to wipe out the final bit
|
||||
ret[a].SetInt(((pc[-1].i16) << 17) >> 17);
|
||||
}
|
||||
if (pc[-1].i16 & 0x8000)
|
||||
{
|
||||
return a < numret ? a + 1 : numret;
|
||||
}
|
||||
NEXTOP;
|
||||
OP(RESULT):
|
||||
// This instruction is just a placeholder to indicate where a return
|
||||
// value should be stored. It does nothing on its own and should not
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ xx(TAIL, tail, RPI8), // Call+Ret in a single instruction
|
|||
xx(TAIL_K, tail, KPI8),
|
||||
xx(RESULT, result, __BCP), // Result should go in register encoded in BC (in caller, after CALL)
|
||||
xx(RET, ret, I8BCP), // Copy value from register encoded in BC to return value A, possibly returning
|
||||
xx(RETI, reti, I8I16), // Copy immediate from BC to return value A, possibly returning
|
||||
xx(TRY, try, I24), // When an exception is thrown, start searching for a handler at pc + ABC
|
||||
xx(UNTRY, untry, I8), // Pop A entries off the exception stack
|
||||
xx(THROW, throw, THROW), // A == 0: Throw exception object pB
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue