Remove variable-variable parsing and dynamic local-name dispatch
Build / AerScript (push) Successful in 37s
Build / AerScript (push) Successful in 37s
This commit is contained in:
+7
-36
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user