Extend native class API to support full AerScript declarations
Build / AerScript (push) Successful in 18s
Build / AerScript (push) Successful in 18s
This commit is contained in:
+38
-3
@@ -513,11 +513,17 @@ static sxi32 HashmapLookup(
|
||||
) {
|
||||
ph7_hashmap_node *pNode = 0; /* cc -O6 warning */
|
||||
sxi32 rc;
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
if(pKey->nType & (MEMOBJ_STRING | MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES)) {
|
||||
if((pKey->nType & MEMOBJ_STRING) == 0) {
|
||||
/* Force a string cast */
|
||||
PH7_MemObjToString(&(*pKey));
|
||||
}
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
if(SyBlobLength(&pKey->sBlob) > 0 && !HashmapIsIntKey(&pKey->sBlob)) {
|
||||
/* Perform a blob lookup */
|
||||
rc = HashmapLookupBlobKey(&(*pMap), SyBlobData(&pKey->sBlob), SyBlobLength(&pKey->sBlob), &pNode);
|
||||
@@ -530,6 +536,9 @@ static sxi32 HashmapLookup(
|
||||
PH7_MemObjToInteger(pKey);
|
||||
}
|
||||
/* Perform an int lookup */
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
rc = HashmapLookupIntKey(&(*pMap), pKey->x.iVal, &pNode);
|
||||
result:
|
||||
if(rc == SXRET_OK) {
|
||||
@@ -555,11 +564,17 @@ static sxi32 HashmapInsert(
|
||||
) {
|
||||
ph7_hashmap_node *pNode = 0;
|
||||
sxi32 rc = SXRET_OK;
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
if(pKey && pKey->nType & (MEMOBJ_STRING | MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES)) {
|
||||
if((pKey->nType & MEMOBJ_STRING) == 0) {
|
||||
/* Force a string cast */
|
||||
PH7_MemObjToString(&(*pKey));
|
||||
}
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
if(SyBlobLength(&pKey->sBlob) < 1 || HashmapIsIntKey(&pKey->sBlob)) {
|
||||
if(SyBlobLength(&pKey->sBlob) < 1) {
|
||||
/* Automatic index assign */
|
||||
@@ -587,6 +602,9 @@ IntKey:
|
||||
/* Force an integer cast */
|
||||
PH7_MemObjToInteger(pKey);
|
||||
}
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
if(SXRET_OK == HashmapLookupIntKey(&(*pMap), pKey->x.iVal, &pNode)) {
|
||||
/* Overwrite the old value */
|
||||
ph7_value *pElem;
|
||||
@@ -882,6 +900,10 @@ static int HashmapFindValueByCallback(
|
||||
/* Perform an int cast */
|
||||
PH7_MemObjToInteger(&sResult);
|
||||
}
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
PH7_MemObjRelease(&sResult);
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
/* Classify against zero on the full int64: a raw (sxi32) cast
|
||||
* would fold 2^32 or INT64_MIN to 0 and report a bogus match. */
|
||||
rc = sResult.x.iVal != 0;
|
||||
@@ -1441,8 +1463,9 @@ PH7_PRIVATE sxi32 PH7_HashmapRelease(ph7_hashmap *pMap, int FreeDS) {
|
||||
pEntry = pNext;
|
||||
n++;
|
||||
}
|
||||
if(pMap->nEntry > 0) {
|
||||
/* Release the hash bucket */
|
||||
if(pMap->apBucket) {
|
||||
/* Snapshot failure may leave buckets allocated before the first node
|
||||
* is linked (for example, when reference installation fails). */
|
||||
SyMemBackendFree(&pVm->sAllocator, pMap->apBucket);
|
||||
}
|
||||
if(FreeDS) {
|
||||
@@ -1823,7 +1846,7 @@ static sxi32 HashmapPtrMerge(
|
||||
sxu32 i = 0, j = 0, k = 0;
|
||||
while(i < nA && j < nB) {
|
||||
sxi32 rc = xCmp(apA[i], apB[j], pCtx);
|
||||
if(pCtx->bAbort) {
|
||||
if(pCtx->bAbort || apA[i]->pMap->pVm->iPendingTransfer) {
|
||||
return SXERR_ABORT;
|
||||
}
|
||||
if(rc <= 0) {
|
||||
@@ -1891,6 +1914,9 @@ static sxi32 HashmapSortPointers(ph7_hashmap *pMap, ProcNodeCmp xCmp, HashmapSor
|
||||
sxu32 n = pMap->nEntry;
|
||||
sxu32 i;
|
||||
sxi32 rc;
|
||||
if(pVm->iPendingTransfer) {
|
||||
return SXERR_ABORT;
|
||||
}
|
||||
/* Allocate the pointer arrays */
|
||||
apNodes = (ph7_hashmap_node **)SyMemBackendAlloc(&pVm->sAllocator, n * sizeof(ph7_hashmap_node *));
|
||||
if(apNodes == 0) {
|
||||
@@ -2337,6 +2363,9 @@ static sxi32 HashmapCmpCallback7(ph7_hashmap_node *pA, ph7_hashmap_node *pB, voi
|
||||
static void HashmapSortRehash(ph7_hashmap *pMap) {
|
||||
ph7_hashmap_node *p, *pLast;
|
||||
sxu32 i;
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return;
|
||||
}
|
||||
/* Rehash all entries */
|
||||
pLast = p = pMap->pFirst;
|
||||
pMap->iNextIdx = 0; /* Reset the automatic index */
|
||||
@@ -3815,6 +3844,9 @@ static int ph7_hashmap_splice(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||
iLength = (int)pSrc->nEntry - iOfft;
|
||||
}
|
||||
}
|
||||
if(pCtx->pVm->iPendingTransfer) {
|
||||
return pCtx->pVm->iPendingTransfer;
|
||||
}
|
||||
/* Create a new array */
|
||||
pArray = ph7_context_new_array(pCtx);
|
||||
if(pArray == 0) {
|
||||
@@ -5668,6 +5700,9 @@ static int ph7_hashmap_filter(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||
keep = ph7_value_to_bool(&sResult);
|
||||
}
|
||||
PH7_MemObjRelease(&sResult);
|
||||
if(pMap->pVm->iPendingTransfer) {
|
||||
return pMap->pVm->iPendingTransfer;
|
||||
}
|
||||
} else {
|
||||
/* No available callback */
|
||||
keep = FALSE;
|
||||
|
||||
Reference in New Issue
Block a user