Typehinting merge #50
70
engine/vm.c
70
engine/vm.c
@ -1715,41 +1715,43 @@ PH7_PRIVATE sxi32 VmExtractDebugTrace(ph7_vm *pVm, SySet *pDebugTrace) {
|
|||||||
/* Backup current frame */
|
/* Backup current frame */
|
||||||
VmFrame *oFrame = pVm->pFrame;
|
VmFrame *oFrame = pVm->pFrame;
|
||||||
while(pVm->pFrame) {
|
while(pVm->pFrame) {
|
||||||
/* Iterate through all frames */
|
if(pVm->pFrame->iFlags & VM_FRAME_ACTIVE) {
|
||||||
ph7_vm_func *pFunc;
|
/* Iterate through all frames */
|
||||||
pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
|
ph7_vm_func *pFunc;
|
||||||
if(pFunc && (pVm->pFrame->iFlags & VM_FRAME_EXCEPTION) == 0) {
|
pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
|
||||||
VmDebugTrace aTrace;
|
if(pFunc && (pVm->pFrame->iFlags & VM_FRAME_EXCEPTION) == 0) {
|
||||||
SySet *aByteCode = &pFunc->aByteCode;
|
VmDebugTrace aTrace;
|
||||||
/* Extract closure/method name and passed arguments */
|
SySet *aByteCode = &pFunc->aByteCode;
|
||||||
aTrace.pFuncName = &pFunc->sName;
|
/* Extract closure/method name and passed arguments */
|
||||||
aTrace.pArg = &pVm->pFrame->sArg;
|
aTrace.pFuncName = &pFunc->sName;
|
||||||
for(sxi32 i = (SySetUsed(aByteCode) - 1); i >= 0 ; i--) {
|
aTrace.pArg = &pVm->pFrame->sArg;
|
||||||
VmInstr *cInstr = (VmInstr *)SySetAt(aByteCode, i);
|
for(sxi32 i = (SySetUsed(aByteCode) - 1); i >= 0 ; i--) {
|
||||||
if(cInstr->bExec == TRUE) {
|
VmInstr *cInstr = (VmInstr *)SySetAt(aByteCode, i);
|
||||||
/* Extract file name & line */
|
if(cInstr->bExec == TRUE) {
|
||||||
aTrace.pFile = cInstr->pFile;
|
/* Extract file name & line */
|
||||||
aTrace.nLine = cInstr->iLine;
|
aTrace.pFile = cInstr->pFile;
|
||||||
break;
|
aTrace.nLine = cInstr->iLine;
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
if(aTrace.pFile) {
|
|
||||||
aTrace.pClassName = NULL;
|
|
||||||
aTrace.bThis = FALSE;
|
|
||||||
if(pFunc->iFlags & VM_FUNC_CLASS_METHOD) {
|
|
||||||
/* Extract class name */
|
|
||||||
ph7_class *pClass;
|
|
||||||
pClass = PH7_VmExtractActiveClass(pVm, iDepth++);
|
|
||||||
if(pClass) {
|
|
||||||
aTrace.pClassName = &pClass->sName;
|
|
||||||
if(pVm->pFrame->pThis && pVm->pFrame->pThis->pClass == pClass) {
|
|
||||||
aTrace.bThis = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rc = SySetPut(pDebugTrace, (const void *)&aTrace);
|
if(aTrace.pFile) {
|
||||||
if(rc != SXRET_OK) {
|
aTrace.pClassName = NULL;
|
||||||
break;
|
aTrace.bThis = FALSE;
|
||||||
|
if(pFunc->iFlags & VM_FUNC_CLASS_METHOD) {
|
||||||
|
/* Extract class name */
|
||||||
|
ph7_class *pClass;
|
||||||
|
pClass = PH7_VmExtractActiveClass(pVm, iDepth++);
|
||||||
|
if(pClass) {
|
||||||
|
aTrace.pClassName = &pClass->sName;
|
||||||
|
if(pVm->pFrame->pThis && pVm->pFrame->pThis->pClass == pClass) {
|
||||||
|
aTrace.bThis = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rc = SySetPut(pDebugTrace, (const void *)&aTrace);
|
||||||
|
if(rc != SXRET_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5085,6 +5087,8 @@ static sxi32 VmByteCodeExec(
|
|||||||
*/
|
*/
|
||||||
PH7_MemObjRelease(pTos);
|
PH7_MemObjRelease(pTos);
|
||||||
pTos = &pTos[-pInstr->iP1];
|
pTos = &pTos[-pInstr->iP1];
|
||||||
|
/* Mark current frame as active */
|
||||||
|
pFrame->iFlags |= VM_FRAME_ACTIVE;
|
||||||
/* Allocate a new operand stack and evaluate the function body */
|
/* Allocate a new operand stack and evaluate the function body */
|
||||||
pFrameStack = VmNewOperandStack(&(*pVm), SySetUsed(&pVmFunc->aByteCode));
|
pFrameStack = VmNewOperandStack(&(*pVm), SySetUsed(&pVmFunc->aByteCode));
|
||||||
if(pFrameStack == 0) {
|
if(pFrameStack == 0) {
|
||||||
|
@ -1261,9 +1261,10 @@ struct VmFrame {
|
|||||||
sxi32 iFlags; /* Frame configuration flags (See below) */
|
sxi32 iFlags; /* Frame configuration flags (See below) */
|
||||||
sxu32 iExceptionJump; /* Exception jump destination */
|
sxu32 iExceptionJump; /* Exception jump destination */
|
||||||
};
|
};
|
||||||
#define VM_FRAME_EXCEPTION 0x01 /* Special Exception frame */
|
#define VM_FRAME_ACTIVE 0x01 /* Active call frame */
|
||||||
#define VM_FRAME_THROW 0x02 /* An exception was thrown */
|
#define VM_FRAME_EXCEPTION 0x02 /* Special Exception frame */
|
||||||
#define VM_FRAME_CATCH 0x04 /* Catch frame */
|
#define VM_FRAME_THROW 0x04 /* An exception was thrown */
|
||||||
|
#define VM_FRAME_CATCH 0x08 /* Catch frame */
|
||||||
/*
|
/*
|
||||||
* When a debug stacktrace is extracted from Virtual Machine, all information about
|
* When a debug stacktrace is extracted from Virtual Machine, all information about
|
||||||
* calls (file, line, class, method, arguments) are stored in this structure.
|
* calls (file, line, class, method, arguments) are stored in this structure.
|
||||||
|
Loading…
Reference in New Issue
Block a user