Revert context frame implementation
All checks were successful
Build / AerScript (push) Successful in 32s
All checks were successful
Build / AerScript (push) Successful in 32s
This commit is contained in:
parent
566997d080
commit
cd924eb066
@ -1879,8 +1879,6 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
|
|||||||
pTmp = pGen->pEnd;
|
pTmp = pGen->pEnd;
|
||||||
pGen->pEnd = pEnd;
|
pGen->pEnd = pEnd;
|
||||||
sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData));
|
sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData));
|
||||||
/* Emit the OP_CF_START instruction to enter a context frame */
|
|
||||||
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_CF_START, 0, 0, 0, 0);
|
|
||||||
if(nKey & (PH7_KEYWORD_AUTO | PH7_KEYWORD_TYPEDEF)) {
|
if(nKey & (PH7_KEYWORD_AUTO | PH7_KEYWORD_TYPEDEF)) {
|
||||||
/* Compile variable */
|
/* Compile variable */
|
||||||
PH7_CompileVar(&(*pGen));
|
PH7_CompileVar(&(*pGen));
|
||||||
@ -1982,8 +1980,6 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
|
|||||||
PH7_GenStateFixJumps(pForBlock, -1, PH7_VmInstrLength(pGen->pVm));
|
PH7_GenStateFixJumps(pForBlock, -1, PH7_VmInstrLength(pGen->pVm));
|
||||||
/* Release the loop block */
|
/* Release the loop block */
|
||||||
PH7_GenStateLeaveBlock(pGen, 0);
|
PH7_GenStateLeaveBlock(pGen, 0);
|
||||||
/* Emit the OP_CF_STOP instruction to leave the context frame */
|
|
||||||
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_CF_STOP, 0, 0, 0, 0);
|
|
||||||
/* Statement successfully compiled */
|
/* Statement successfully compiled */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ 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) {
|
||||||
if(pVm->pFrame->iFlags & (VM_FRAME_ACTIVE | VM_FRAME_CONTEXT)) {
|
if(pVm->pFrame->iFlags & VM_FRAME_ACTIVE) {
|
||||||
/* Iterate through all frames */
|
/* Iterate through all frames */
|
||||||
ph7_vm_func *pFunc;
|
ph7_vm_func *pFunc;
|
||||||
pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
|
pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
|
||||||
@ -116,12 +116,6 @@ static const char *VmInstrToString(sxi32 nOp) {
|
|||||||
case PH7_OP_JMPNZ:
|
case PH7_OP_JMPNZ:
|
||||||
zOp = "JMPNZ";
|
zOp = "JMPNZ";
|
||||||
break;
|
break;
|
||||||
case PH7_OP_CF_START:
|
|
||||||
zOp = "CF_START";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CF_STOP:
|
|
||||||
zOp = "CF_STOP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LF_START:
|
case PH7_OP_LF_START:
|
||||||
zOp = "LF_START";
|
zOp = "LF_START";
|
||||||
break;
|
break;
|
||||||
|
35
engine/vm.c
35
engine/vm.c
@ -1394,7 +1394,7 @@ static ph7_value *VmExtractMemObj(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(pFrame->pParent && pFrame->iFlags & (VM_FRAME_CONTEXT | VM_FRAME_LOOP | VM_FRAME_EXCEPTION | VM_FRAME_CATCH | VM_FRAME_FINALLY)) {
|
if(pFrame->pParent && pFrame->iFlags & (VM_FRAME_LOOP | VM_FRAME_EXCEPTION | VM_FRAME_CATCH | VM_FRAME_FINALLY)) {
|
||||||
pFrame = pFrame->pParent;
|
pFrame = pFrame->pParent;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -1908,14 +1908,14 @@ static sxi32 VmByteCodeExec(
|
|||||||
VmLeaveFrame(&(*pVm));
|
VmLeaveFrame(&(*pVm));
|
||||||
}
|
}
|
||||||
} else if(pVm->pFrame->iFlags & VM_FRAME_LOOP) {
|
} else if(pVm->pFrame->iFlags & VM_FRAME_LOOP) {
|
||||||
while(pVm->pFrame->pParent && (pVm->pFrame->iFlags & (VM_FRAME_ACTIVE | VM_FRAME_CONTEXT)) == 0) {
|
while(pVm->pFrame->pParent && (pVm->pFrame->iFlags & VM_FRAME_ACTIVE) == 0) {
|
||||||
VmLeaveFrame(&(*pVm));
|
VmLeaveFrame(&(*pVm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pResult) {
|
if(pResult) {
|
||||||
/* Execution result */
|
/* Execution result */
|
||||||
PH7_MemObjStore(pTos, pResult);
|
PH7_MemObjStore(pTos, pResult);
|
||||||
if(!pInstr->iP2 && pVm->pFrame->iFlags & (VM_FRAME_ACTIVE | VM_FRAME_CONTEXT)) {
|
if(!pInstr->iP2 && pVm->pFrame->iFlags & VM_FRAME_ACTIVE) {
|
||||||
ph7_vm_func *pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
|
ph7_vm_func *pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
|
||||||
if(pFunc->nType) {
|
if(pFunc->nType) {
|
||||||
if((pFunc->nType & MEMOBJ_MIXED) == 0) {
|
if((pFunc->nType & MEMOBJ_MIXED) == 0) {
|
||||||
@ -2027,33 +2027,6 @@ static sxi32 VmByteCodeExec(
|
|||||||
VmPopOperand(&pTos, 1);
|
VmPopOperand(&pTos, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
* CF_START: * * *
|
|
||||||
*
|
|
||||||
* Creates and enters the active context frame.
|
|
||||||
*/
|
|
||||||
case PH7_OP_CF_START: {
|
|
||||||
VmFrame *pFrame = 0;
|
|
||||||
/* Enter the context frame */
|
|
||||||
rc = VmEnterFrame(&(*pVm), pVm->pFrame->pUserData, pVm->pFrame->pThis, &pFrame);
|
|
||||||
if(rc != SXRET_OK) {
|
|
||||||
PH7_VmMemoryError(&(*pVm));
|
|
||||||
}
|
|
||||||
pFrame->iFlags = VM_FRAME_CONTEXT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* CF_STOP: * * *
|
|
||||||
*
|
|
||||||
* Leaves and destroys the active context frame.
|
|
||||||
*/
|
|
||||||
case PH7_OP_CF_STOP: {
|
|
||||||
/* Leave the context frame */
|
|
||||||
if(pVm->pFrame->iFlags & VM_FRAME_CONTEXT) {
|
|
||||||
VmLeaveFrame(&(*pVm));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* LF_START: * * *
|
* LF_START: * * *
|
||||||
*
|
*
|
||||||
@ -2347,7 +2320,7 @@ static sxi32 VmByteCodeExec(
|
|||||||
/* Candidate for expansion via user defined callbacks */
|
/* Candidate for expansion via user defined callbacks */
|
||||||
for(;;) {
|
for(;;) {
|
||||||
pEntry = SyHashGet(&pFrame->hConst, SyBlobData(&pObj->sBlob), SyBlobLength(&pObj->sBlob));
|
pEntry = SyHashGet(&pFrame->hConst, SyBlobData(&pObj->sBlob), SyBlobLength(&pObj->sBlob));
|
||||||
if(pEntry == 0 && pFrame->iFlags & (VM_FRAME_CONTEXT | VM_FRAME_LOOP) && pFrame->pParent) {
|
if(pEntry == 0 && pFrame->iFlags & VM_FRAME_LOOP && pFrame->pParent) {
|
||||||
pFrame = pFrame->pParent;
|
pFrame = pFrame->pParent;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -1249,12 +1249,11 @@ struct VmFrame {
|
|||||||
sxu32 iExceptionJump; /* Exception jump destination */
|
sxu32 iExceptionJump; /* Exception jump destination */
|
||||||
};
|
};
|
||||||
#define VM_FRAME_ACTIVE 0x01 /* Active call frame */
|
#define VM_FRAME_ACTIVE 0x01 /* Active call frame */
|
||||||
#define VM_FRAME_CONTEXT 0x02 /* Active context frame */
|
#define VM_FRAME_LOOP 0x02 /* Active loop frame */
|
||||||
#define VM_FRAME_LOOP 0x04 /* Active loop frame */
|
#define VM_FRAME_EXCEPTION 0x04 /* Special Exception frame */
|
||||||
#define VM_FRAME_EXCEPTION 0x08 /* Special Exception frame */
|
#define VM_FRAME_THROW 0x08 /* An exception was thrown */
|
||||||
#define VM_FRAME_THROW 0x10 /* An exception was thrown */
|
#define VM_FRAME_CATCH 0x10 /* Catch frame */
|
||||||
#define VM_FRAME_CATCH 0x20 /* Catch frame */
|
#define VM_FRAME_FINALLY 0x20 /* Finally frame */
|
||||||
#define VM_FRAME_FINALLY 0x40 /* Finally 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.
|
||||||
@ -1389,8 +1388,6 @@ enum ph7_vm_op {
|
|||||||
PH7_OP_JMP, /* Unconditional jump */
|
PH7_OP_JMP, /* Unconditional jump */
|
||||||
PH7_OP_JMPZ, /* Jump on zero (FALSE jump) */
|
PH7_OP_JMPZ, /* Jump on zero (FALSE jump) */
|
||||||
PH7_OP_JMPNZ, /* Jump on non-zero (TRUE jump) */
|
PH7_OP_JMPNZ, /* Jump on non-zero (TRUE jump) */
|
||||||
PH7_OP_CF_START, /* Context frame start */
|
|
||||||
PH7_OP_CF_STOP, /* Context frame stop */
|
|
||||||
PH7_OP_LF_START, /* Loop frame start */
|
PH7_OP_LF_START, /* Loop frame start */
|
||||||
PH7_OP_LF_STOP, /* Loop frame stop */
|
PH7_OP_LF_STOP, /* Loop frame stop */
|
||||||
PH7_OP_POP, /* Stack POP */
|
PH7_OP_POP, /* Stack POP */
|
||||||
|
@ -23,7 +23,7 @@ class Base32 {
|
|||||||
}
|
}
|
||||||
string[] $fiveBitBinaryArray = str_split($binaryString, 5);
|
string[] $fiveBitBinaryArray = str_split($binaryString, 5);
|
||||||
string $base32 = '';
|
string $base32 = '';
|
||||||
int $i = 0;
|
$i = 0;
|
||||||
while($i < sizeof($fiveBitBinaryArray)) {
|
while($i < sizeof($fiveBitBinaryArray)) {
|
||||||
$base32 += Base32::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5,'0'), 2, 10)];
|
$base32 += Base32::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5,'0'), 2, 10)];
|
||||||
$i++;
|
$i++;
|
||||||
@ -50,7 +50,7 @@ class Base32 {
|
|||||||
$input = str_replace('=','', $input);
|
$input = str_replace('=','', $input);
|
||||||
char[] $aInput = str_split($input);
|
char[] $aInput = str_split($input);
|
||||||
string $binaryString = '';
|
string $binaryString = '';
|
||||||
for(int $i = 0; $i < sizeof($aInput); $i = $i + 8) {
|
for($i = 0; $i < sizeof($aInput); $i = $i + 8) {
|
||||||
string $x = '';
|
string $x = '';
|
||||||
if(!in_array($input[$i], Base32::$map))
|
if(!in_array($input[$i], Base32::$map))
|
||||||
return '';
|
return '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user