Finish implementing function pointers
Allow using function literals with function pointers, allow narrowing classes parameter types, and widening classes in return types, allow pointers to non-static, non-virtual functions, add null checking to function calls
This commit is contained in:
parent
23c21b23c3
commit
e61bd10bbf
8 changed files with 244 additions and 20 deletions
|
|
@ -1937,6 +1937,15 @@ static int ExecScriptFunc(VMFrameStack *stack, VMReturn *ret, int numret)
|
|||
CMPJMP(reg.a[B] == konsta[C].v);
|
||||
NEXTOP;
|
||||
|
||||
OP(NULLCHECK):
|
||||
ASSERTA(a);
|
||||
if (PA == nullptr)
|
||||
{
|
||||
ThrowAbortException(X_WRITE_NIL, nullptr);
|
||||
return 0;
|
||||
}
|
||||
NEXTOP;
|
||||
|
||||
OP(NOP):
|
||||
NEXTOP;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,4 +289,7 @@ xx(SUBA, sub, RIRPRP, NOP, 0, 0) // dA = pB - pC
|
|||
xx(EQA_R, beq, CPRR, NOP, 0, 0) // if ((pB == pkC) != A) then pc++
|
||||
xx(EQA_K, beq, CPRK, EQA_R, 4, REGT_POINTER)
|
||||
|
||||
// Null check
|
||||
xx(NULLCHECK, nullcheck, RP, NOP, 0, 0) // EmitNullPointerThrow(pA)
|
||||
|
||||
#undef xx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue