Allow addition operator (+) to concatenate strings.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
3a994221ce
commit
9a56751879
48
engine/vm.c
48
engine/vm.c
|
@ -3406,9 +3406,29 @@ static sxi32 VmByteCodeExec(
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Perform the addition */
|
if(pNos->iFlags & MEMOBJ_STRING || pTos->iFlags & MEMOBJ_STRING) {
|
||||||
PH7_MemObjAdd(pNos, pTos, FALSE);
|
/* Perform the string addition */
|
||||||
VmPopOperand(&pTos, 1);
|
ph7_value *pCur;
|
||||||
|
if((pNos->iFlags & MEMOBJ_STRING) == 0) {
|
||||||
|
PH7_MemObjToString(pNos);
|
||||||
|
}
|
||||||
|
pCur = &pNos[1];
|
||||||
|
while(pCur <= pTos) {
|
||||||
|
if((pCur->iFlags & MEMOBJ_STRING) == 0) {
|
||||||
|
PH7_MemObjToString(pCur);
|
||||||
|
}
|
||||||
|
if(SyBlobLength(&pCur->sBlob) > 0) {
|
||||||
|
PH7_MemObjStringAppend(pNos, (const char *)SyBlobData(&pCur->sBlob), SyBlobLength(&pCur->sBlob));
|
||||||
|
}
|
||||||
|
SyBlobRelease(&pCur->sBlob);
|
||||||
|
pCur++;
|
||||||
|
}
|
||||||
|
pTos = pNos;
|
||||||
|
} else {
|
||||||
|
/* Perform the number addition */
|
||||||
|
PH7_MemObjAdd(pNos, pTos, FALSE);
|
||||||
|
VmPopOperand(&pTos, 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -3420,19 +3440,29 @@ static sxi32 VmByteCodeExec(
|
||||||
case PH7_OP_ADD_STORE: {
|
case PH7_OP_ADD_STORE: {
|
||||||
ph7_value *pNos = &pTos[-1];
|
ph7_value *pNos = &pTos[-1];
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
sxu32 nIdx;
|
|
||||||
#ifdef UNTRUST
|
#ifdef UNTRUST
|
||||||
if(pNos < pStack) {
|
if(pNos < pStack) {
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Perform the addition */
|
if(pTos->iFlags & MEMOBJ_STRING) {
|
||||||
nIdx = pTos->nIdx;
|
/* Perform the string addition */
|
||||||
PH7_MemObjAdd(pTos, pNos, TRUE);
|
if((pNos->iFlags & MEMOBJ_STRING) == 0) {
|
||||||
|
/* Force a string cast */
|
||||||
|
PH7_MemObjToString(pNos);
|
||||||
|
}
|
||||||
|
/* Perform the concatenation (Reverse order) */
|
||||||
|
if(SyBlobLength(&pNos->sBlob) > 0) {
|
||||||
|
PH7_MemObjStringAppend(pTos, (const char *)SyBlobData(&pNos->sBlob), SyBlobLength(&pNos->sBlob));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Perform the number addition */
|
||||||
|
PH7_MemObjAdd(pTos, pNos, TRUE);
|
||||||
|
}
|
||||||
/* Perform the store operation */
|
/* Perform the store operation */
|
||||||
if(nIdx == SXU32_HIGH) {
|
if(pTos->nIdx == SXU32_HIGH) {
|
||||||
PH7_VmThrowError(&(*pVm), 0, PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
|
PH7_VmThrowError(&(*pVm), 0, PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");
|
||||||
} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, nIdx)) != 0) {
|
} else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) {
|
||||||
PH7_MemObjStore(pTos, pObj);
|
PH7_MemObjStore(pTos, pObj);
|
||||||
}
|
}
|
||||||
/* Ticket 1433-35: Perform a stack dup */
|
/* Ticket 1433-35: Perform a stack dup */
|
||||||
|
|
Loading…
Reference in New Issue