Remove variable-variable parsing and dynamic local-name dispatch
Build / AerScript (push) Successful in 37s

This commit is contained in:
2026-10-28 19:55:25 +01:00
parent 4980848a8d
commit 5f75319be9
3 changed files with 16 additions and 54 deletions
+7 -36
View File
@@ -3331,30 +3331,16 @@ Resume:
/*
* LOADV: * * P3
*
* Load a variable where it's name is taken from the top of the stack or
* from the P3 operand.
* Load a variable whose name is given by the P3 operand.
*/
case PH7_OP_LOADV: {
ph7_value *pObj;
SyString sName;
if(pInstr->p3 == 0) {
/* Take the variable name from the top of the stack */
if(pTos < pStack) {
goto Abort;
}
#
/* Force a string cast */
if((pTos->nType & MEMOBJ_STRING) == 0) {
PH7_MemObjToString(pTos);
}
SyStringInitFromBuf(&sName, SyBlobData(&pTos->sBlob), SyBlobLength(&pTos->sBlob));
} else {
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
/* Reserve a room for the target object */
pTos++;
}
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
/* Reserve a room for the target object */
pTos++;
/* Extract the requested memory object */
pObj = VmExtractMemObj(&(*pVm), &sName, pInstr->p3 ? FALSE : TRUE);
pObj = VmExtractMemObj(&(*pVm), &sName, FALSE);
if(pObj == 0) {
/* Fatal error */
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Variable '$%z' undeclared (first use in this method/closure)", &sName);
@@ -3628,31 +3614,16 @@ Resume:
}
}
break;
} else if(pInstr->p3 == 0) {
/* Take the variable name from the next on the stack */
if((pTos->nType & MEMOBJ_STRING) == 0) {
/* Force a string cast */
PH7_MemObjToString(pTos);
}
SyStringInitFromBuf(&sName, SyBlobData(&pTos->sBlob), SyBlobLength(&pTos->sBlob));
pTos--;
if(pTos < pStack) {
goto Abort;
}
} else {
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
}
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
/* Extract the desired variable if available */
pObj = VmExtractMemObj(&(*pVm), &sName, pInstr->p3 ? FALSE : TRUE);
pObj = VmExtractMemObj(&(*pVm), &sName, FALSE);
if(pObj == 0) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Variable '$%z' undeclared (first use in this method/closure)", &sName);
} else if(pObj->iFlags != MEMOBJ_VARIABLE) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot re-assign a value of '$%z' statement", &sName);
}
if(!pInstr->p3) {
PH7_MemObjRelease(&pTos[1]);
}
/* Perform the store operation */
rc = PH7_MemObjSafeStore(pTos, pObj);
if(rc != SXRET_OK) {