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:
@@ -627,6 +627,7 @@ struct ph7_value {
|
||||
#define MEMOBJ_VARIABLE 0 /* Memory value is variable */
|
||||
#define MEMOBJ_PARENTOBJ 1 /* Memory value is 'parent' object */
|
||||
#define MEMOBJ_THISOBJ 2 /* Memory value is 'this' object */
|
||||
#define MEMOBJ_INDEX_HANDLE 4 /* Native context forwarding handle, not a value flag */
|
||||
/* Allowed variable data types.
|
||||
*/
|
||||
#define MEMOBJ_BOOL 0x0001 /* Memory value is a boolean */
|
||||
@@ -758,6 +759,7 @@ struct ph7_context {
|
||||
sxi32 iFlags; /* Call flags */
|
||||
ph7_value *pThis; /* Stable borrowed native method receiver */
|
||||
sxi32 bResultSet; /* Distinguish explicit NULL from a bare return */
|
||||
void *pNativeFrame; /* Borrowed argument frame for indexed context operations */
|
||||
};
|
||||
/*
|
||||
* Each hashmap entry [i.e: array(4,5,6)] is recorded in an instance
|
||||
@@ -951,6 +953,9 @@ struct ph7_vm_func_arg {
|
||||
sxu32 nType; /* Type of this argument [i.e: array, int, string, float, object, etc.] */
|
||||
SyString sClass; /* Class name if the argument expect a class instance [i.e: function foo(BaseClass $bar){} ] */
|
||||
sxi32 iFlags; /* Configuration flags */
|
||||
ph7_value *pNativeDefault; /* Owned snapshot, distinct from an absent default */
|
||||
ph7_initializer_func xNativeDefault;
|
||||
void *pNativeData;
|
||||
};
|
||||
/*
|
||||
* Each static variable is parsed out and remembered in an instance
|
||||
@@ -1071,6 +1076,10 @@ struct ph7_class {
|
||||
SySet aMro; /* C3 linearization, including this class first */
|
||||
sxi32 iMroState; /* 0: unbuilt, 1: building, 2: ready */
|
||||
sxi32 bNative; /* Public native declaration */
|
||||
sxi32 iNativeState; /* 0: pending, 1: initializing, 2: usable */
|
||||
sxi32 bMounting; /* Reentrant static initializer guard */
|
||||
sxi32 bMethodsMounted; /* Concrete declarations enter the function table once */
|
||||
sxu32 nNativeWarnings; /* Accepted declaration diagnostics, delivered after commit */
|
||||
};
|
||||
/* Class configuration flags */
|
||||
#define PH7_CLASS_FINAL 0x001 /* Class is final [cannot be extended] */
|
||||
@@ -1094,6 +1103,8 @@ struct ph7_class_attr {
|
||||
sxu32 nIdx; /* Attribute index */
|
||||
sxu32 nLine; /* Line number on which this attribute was defined */
|
||||
ph7_value *pNativeInitial; /* Owned native declaration snapshot, if present */
|
||||
ph7_initializer_func xNativeInitial;
|
||||
void *pNativeData;
|
||||
};
|
||||
/* Attribute configuration */
|
||||
#define PH7_CLASS_ATTR_STATIC 0x001 /* Static attribute */
|
||||
@@ -1256,6 +1267,13 @@ struct ph7_vm {
|
||||
void *pStderr; /* STDERR IO stream */
|
||||
sxbool bDebug; /* TRUE to enable debugging */
|
||||
sxbool bErrReport; /* TRUE to report all runtime Error/Warning/Notice/Deprecated */
|
||||
SySet *pClassJournal; /* Non-reentrant, callback-free metadata preparation */
|
||||
ph7_class *pStagedClass; /* Unpublished declaration visible only to preparation */
|
||||
sxi32 bClassDeferred; /* A forward hierarchy name is not installed yet */
|
||||
sxi32 bNativeRegister; /* Callback-free declaration transaction is active */
|
||||
sxu32 nNativeReserve; /* Conservative rollback free-slot capacity bound */
|
||||
sxi32 iPendingTransfer; /* Conversion/readiness completion crossing scalar APIs */
|
||||
ph7_value sPendingTransfer;
|
||||
int nExceptDepth; /* Exception depth */
|
||||
int closure_cnt; /* Loaded closures counter */
|
||||
int json_rc; /* JSON return status [refer to json_encode()/json_decode()] */
|
||||
@@ -1286,6 +1304,7 @@ struct VmFrame {
|
||||
SyHash hConst; /* Constant hashtable for fast lookup */
|
||||
SyHash hVar; /* Variable hashtable for fast lookup */
|
||||
SySet sArg; /* Function arguments container */
|
||||
SySet sArgPin; /* Indexed reference arguments retained through reentry */
|
||||
SySet sRef; /* Local reference table (VmSlot instance) */
|
||||
SySet sConstDecl; /* Constants already declared during this invocation */
|
||||
sxi32 iFlags; /* Frame configuration flags (See below) */
|
||||
@@ -1336,6 +1355,7 @@ struct VmRefObj {
|
||||
SySet aArrEntries; /* Foreign hashmap entries [i.e: array(&$a) ] */
|
||||
sxu32 nIdx; /* Referenced object index */
|
||||
sxu32 nCapture; /* Closure owners: keep contents and index alive */
|
||||
sxu32 nBorrow; /* Active reference argument handles retain the same index */
|
||||
sxi32 iFlags; /* Configuration flags */
|
||||
VmRefObj *pNextCollide, *pPrevCollide; /* Collision link */
|
||||
VmRefObj *pNext, *pPrev; /* List of all referenced objects */
|
||||
@@ -1745,6 +1765,20 @@ PH7_PRIVATE sxi32 PH7_IsIdentifier(const char *zName, sxi32 bKeyword);
|
||||
PH7_PRIVATE sxi32 PH7_IsMethodName(const char *zName);
|
||||
PH7_PRIVATE sxi32 PH7_IsReservedConstant(const SyString *pName);
|
||||
PH7_PRIVATE sxi32 PH7_VmCreateNativeClass(ph7_vm *pVm, const ph7_class_def *pDef);
|
||||
PH7_PRIVATE const char *PH7_ClassMethodDeclarationError(ph7_class *pClass,
|
||||
const SyString *pName, sxu32 nType, sxi32 iProtection, sxi32 iFlags);
|
||||
#define PH7_INTERFACE_VISIBILITY_ERROR "interface: Access type must be public"
|
||||
PH7_PRIVATE sxi32 PH7_ClassConstantProtection(ph7_class *pClass, sxi32 iProtection);
|
||||
PH7_PRIVATE sxi32 PH7_VmContextAttr(ph7_context *pCtx, ph7_value *pObject,
|
||||
const char *zClass, const char *zName, ph7_value *pValue, sxi32 bStore);
|
||||
PH7_PRIVATE sxi32 PH7_ClassPrepareNative(ph7_vm *pVm, ph7_class *pClass);
|
||||
PH7_PRIVATE sxi32 PH7_VmContextParent(ph7_context *pCtx, const char *zMethod,
|
||||
int nArg, ph7_value **apArg, ph7_value *pResult);
|
||||
PH7_PRIVATE void PH7_VmDeferTransfer(ph7_vm *pVm, sxi32 rc, ph7_value *pValue);
|
||||
PH7_PRIVATE sxi32 PH7_VmTakeTransfer(ph7_vm *pVm, ph7_value *pResult);
|
||||
PH7_PRIVATE sxi32 PH7_VmContextVar(ph7_context *pCtx, const char *zName,
|
||||
ph7_value *pValue, sxi32 bStore);
|
||||
PH7_PRIVATE sxi32 PH7_MemObjCopy(ph7_value *pSrc, ph7_value *pDest);
|
||||
PH7_PRIVATE ph7_value *PH7_ReserveConstObj(ph7_vm *pVm, sxu32 *pIndex);
|
||||
PH7_PRIVATE sxi32 PH7_VmOutputConsume(ph7_vm *pVm, SyString *pString);
|
||||
PH7_PRIVATE sxi32 PH7_VmOutputConsumeAp(ph7_vm *pVm, const char *zFormat, va_list ap);
|
||||
|
||||
Reference in New Issue
Block a user