- State code now properly calls action functions and has a RET instruction. As expected,
running with the checked VM can be quite slow, since it has asserts everywhere. Some other
fixes were needed before the code actually worked:
- A_CallSpecial needs to have its arguments cast to ints.
- Some functions that set pnum/paramnum directly did not decrement it by 1. This also applies
to A_Jump, though it just uses the value of paramnum instead of changing it.
- Renamed pnum in the PARAM macros to paramnum, since pnum is already used in a few other
places for something different, so this makes searching for it easier.
This has not been tested especially thoroughly, but a first glance seems to indicate success.
SVN r2163 (scripting)
This commit is contained in:
parent
739e684549
commit
6f1bf257e9
9 changed files with 130 additions and 108 deletions
|
|
@ -1384,7 +1384,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
|||
|
||||
static void FillReturns(const VMRegisters ®, VMFrame *frame, VMReturn *returns, const VMOP *retval, int numret)
|
||||
{
|
||||
int i, type, num;
|
||||
int i, type, regnum;
|
||||
VMReturn *ret;
|
||||
|
||||
assert(REGT_INT == 0 && REGT_FLOAT == 1 && REGT_STRING == 2 && REGT_POINTER == 3);
|
||||
|
|
@ -1392,33 +1392,35 @@ static void FillReturns(const VMRegisters ®, VMFrame *frame, VMReturn *return
|
|||
for (i = 0, ret = returns; i < numret; ++i, ++ret, ++retval)
|
||||
{
|
||||
assert(retval->op == OP_RESULT); // opcode
|
||||
ret->TagOfs = 0;
|
||||
ret->RegType = type = retval->b;
|
||||
ret->RegNum = num = retval->c;
|
||||
regnum = retval->c;
|
||||
assert(!(type & REGT_KONST));
|
||||
type &= REGT_TYPE;
|
||||
if (type < REGT_STRING)
|
||||
{
|
||||
if (type == REGT_INT)
|
||||
{
|
||||
assert(num < frame->NumRegD);
|
||||
ret->Location = ®.d[num];
|
||||
assert(regnum < frame->NumRegD);
|
||||
ret->Location = ®.d[regnum];
|
||||
}
|
||||
else // type == REGT_FLOAT
|
||||
{
|
||||
assert(num < frame->NumRegF);
|
||||
ret->Location = ®.f[num];
|
||||
assert(regnum < frame->NumRegF);
|
||||
ret->Location = ®.f[regnum];
|
||||
}
|
||||
}
|
||||
else if (type == REGT_STRING)
|
||||
{
|
||||
assert(num < frame->NumRegS);
|
||||
ret->Location = ®.s[num];
|
||||
assert(regnum < frame->NumRegS);
|
||||
ret->Location = ®.s[regnum];
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(type == REGT_POINTER);
|
||||
assert(num < frame->NumRegA);
|
||||
ret->Location = ®.a[num];
|
||||
assert(regnum < frame->NumRegA);
|
||||
ret->Location = ®.a[regnum];
|
||||
ret->TagOfs = (VM_SHALF)(&frame->GetRegATag()[regnum] - (VM_ATAG *)ret->Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1434,7 +1436,6 @@ static void FillReturns(const VMRegisters ®, VMFrame *frame, VMReturn *return
|
|||
static void SetReturn(const VMRegisters ®, VMFrame *frame, VMReturn *ret, VM_UBYTE regtype, int regnum)
|
||||
{
|
||||
const void *src;
|
||||
VM_ATAG atag;
|
||||
VMScriptFunction *func = static_cast<VMScriptFunction *>(frame->Func);
|
||||
|
||||
assert(func != NULL && !func->Native);
|
||||
|
|
@ -1498,20 +1499,12 @@ static void SetReturn(const VMRegisters ®, VMFrame *frame, VMReturn *ret, VM_
|
|||
if (regtype & REGT_KONST)
|
||||
{
|
||||
assert(regnum < func->NumKonstA);
|
||||
ret->SetPointer(func->KonstA[regnum].v);
|
||||
atag = func->KonstATags()[regnum];
|
||||
ret->SetPointer(func->KonstA[regnum].v, func->KonstATags()[regnum]);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(regnum < frame->NumRegA);
|
||||
ret->SetPointer(reg.a[regnum]);
|
||||
atag = reg.atag[regnum];
|
||||
}
|
||||
if (ret->RegNum >= 0)
|
||||
{
|
||||
VMFrame *parent = frame->ParentFrame;
|
||||
assert(parent != NULL);
|
||||
parent->GetRegATag()[ret->RegNum] = atag;
|
||||
ret->SetPointer(reg.a[regnum], reg.atag[regnum]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue