Code formatting
This commit is contained in:
parent
03bfd2203c
commit
d898cd1e36
298
api.c
298
api.c
|
@ -32,8 +32,7 @@
|
|||
* That way it is clear in the code when we are using static variable because
|
||||
* its name start with sMPGlobal.
|
||||
*/
|
||||
static struct Global_Data
|
||||
{
|
||||
static struct Global_Data {
|
||||
SyMemBackend sAllocator; /* Global low level memory allocator */
|
||||
#if defined(PH7_ENABLE_THREADS)
|
||||
const SyMutexMethods *pMutexMethods; /* Mutex methods */
|
||||
|
@ -82,8 +81,7 @@ static struct Global_Data
|
|||
* value indicates failure.
|
||||
* Refer to [ph7_config()].
|
||||
*/
|
||||
static sxi32 EngineConfig(ph7 *pEngine,sxi32 nOp,va_list ap)
|
||||
{
|
||||
static sxi32 EngineConfig(ph7 *pEngine, sxi32 nOp, va_list ap) {
|
||||
ph7_conf *pConf = &pEngine->xConf;
|
||||
int rc = PH7_OK;
|
||||
/* Perform the requested operation */
|
||||
|
@ -138,8 +136,7 @@ static sxi32 EngineConfig(ph7 *pEngine,sxi32 nOp,va_list ap)
|
|||
* indicates failure.
|
||||
* Refer to [ph7_lib_config()].
|
||||
*/
|
||||
static sxi32 PH7CoreConfigure(sxi32 nOp,va_list ap)
|
||||
{
|
||||
static sxi32 PH7CoreConfigure(sxi32 nOp, va_list ap) {
|
||||
int rc = PH7_OK;
|
||||
switch(nOp) {
|
||||
case PH7_LIB_CONFIG_VFS: {
|
||||
|
@ -246,11 +243,9 @@ static sxi32 PH7CoreConfigure(sxi32 nOp,va_list ap)
|
|||
* [CAPIREF: ph7_lib_config()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_lib_config(int nConfigOp,...)
|
||||
{
|
||||
int ph7_lib_config(int nConfigOp, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
|
||||
if(sMPGlobal.nMagic == PH7_LIB_MAGIC) {
|
||||
/* Library is already initialized,this operation is forbidden */
|
||||
return PH7_LOOKED;
|
||||
|
@ -270,8 +265,7 @@ int ph7_lib_config(int nConfigOp,...)
|
|||
* thread have finished the initialization process, then the subsequent threads must block
|
||||
* until the initialization process is done.
|
||||
*/
|
||||
static sxi32 PH7CoreInitialize(void)
|
||||
{
|
||||
static sxi32 PH7CoreInitialize(void) {
|
||||
const ph7_vfs *pVfs; /* Built-in vfs */
|
||||
#if defined(PH7_ENABLE_THREADS)
|
||||
const SyMutexMethods *pMutexMethods = 0;
|
||||
|
@ -349,8 +343,7 @@ End:
|
|||
* [CAPIREF: ph7_lib_init()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_lib_init(void)
|
||||
{
|
||||
int ph7_lib_init(void) {
|
||||
int rc;
|
||||
rc = PH7CoreInitialize();
|
||||
return rc;
|
||||
|
@ -358,8 +351,7 @@ int ph7_lib_init(void)
|
|||
/*
|
||||
* Release an active PH7 engine and it's associated active virtual machines.
|
||||
*/
|
||||
static sxi32 EngineRelease(ph7 *pEngine)
|
||||
{
|
||||
static sxi32 EngineRelease(ph7 *pEngine) {
|
||||
ph7_vm *pVm, *pNext;
|
||||
/* Release all active VM */
|
||||
pVm = pEngine->pVms;
|
||||
|
@ -385,8 +377,7 @@ static sxi32 EngineRelease(ph7 *pEngine)
|
|||
* Note: This call is not thread safe.
|
||||
* Refer to [ph7_lib_shutdown()].
|
||||
*/
|
||||
static void PH7CoreShutdown(void)
|
||||
{
|
||||
static void PH7CoreShutdown(void) {
|
||||
ph7 *pEngine, *pNext;
|
||||
/* Release all active engines first */
|
||||
pEngine = sMPGlobal.pEngines;
|
||||
|
@ -423,8 +414,7 @@ static void PH7CoreShutdown(void)
|
|||
* [CAPIREF: ph7_lib_shutdown()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_lib_shutdown(void)
|
||||
{
|
||||
int ph7_lib_shutdown(void) {
|
||||
if(sMPGlobal.nMagic != PH7_LIB_MAGIC) {
|
||||
/* Already shut */
|
||||
return PH7_OK;
|
||||
|
@ -436,8 +426,7 @@ int ph7_lib_shutdown(void)
|
|||
* [CAPIREF: ph7_lib_is_threadsafe()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_lib_is_threadsafe(void)
|
||||
{
|
||||
int ph7_lib_is_threadsafe(void) {
|
||||
if(sMPGlobal.nMagic != PH7_LIB_MAGIC) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -457,40 +446,35 @@ int ph7_lib_is_threadsafe(void)
|
|||
* [CAPIREF: ph7_lib_version()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
const char * ph7_lib_version(void)
|
||||
{
|
||||
const char *ph7_lib_version(void) {
|
||||
return PH7_VERSION;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_lib_signature()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
const char * ph7_lib_signature(void)
|
||||
{
|
||||
const char *ph7_lib_signature(void) {
|
||||
return PH7_SIG;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_lib_ident()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
const char * ph7_lib_ident(void)
|
||||
{
|
||||
const char *ph7_lib_ident(void) {
|
||||
return PH7_IDENT;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_lib_copyright()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
const char * ph7_lib_copyright(void)
|
||||
{
|
||||
const char *ph7_lib_copyright(void) {
|
||||
return PH7_COPYRIGHT;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_config()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_config(ph7 *pEngine,int nConfigOp,...)
|
||||
{
|
||||
int ph7_config(ph7 *pEngine, int nConfigOp, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
if(PH7_ENGINE_MISUSE(pEngine)) {
|
||||
|
@ -517,8 +501,7 @@ int ph7_config(ph7 *pEngine,int nConfigOp,...)
|
|||
* [CAPIREF: ph7_init()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_init(ph7 **ppEngine)
|
||||
{
|
||||
int ph7_init(ph7 **ppEngine) {
|
||||
ph7 *pEngine;
|
||||
int rc;
|
||||
#if defined(UNTRUST)
|
||||
|
@ -587,8 +570,7 @@ Release:
|
|||
* [CAPIREF: ph7_release()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_release(ph7 *pEngine)
|
||||
{
|
||||
int ph7_release(ph7 *pEngine) {
|
||||
int rc;
|
||||
if(PH7_ENGINE_MISUSE(pEngine)) {
|
||||
return PH7_CORRUPT;
|
||||
|
@ -640,8 +622,7 @@ static sxi32 ProcessScript(
|
|||
SyString *pScript, /* Raw PHP script to compile */
|
||||
sxi32 iFlags, /* Compile-time flags */
|
||||
const char *zFilePath /* File path if script come from a file. NULL otherwise */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ph7_vm *pVm;
|
||||
int rc;
|
||||
/* Allocate a new virtual machine */
|
||||
|
@ -718,8 +699,7 @@ Release:
|
|||
* [CAPIREF: ph7_compile()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_compile(ph7 *pEngine,const char *zSource,int nLen,ph7_vm **ppOutVm)
|
||||
{
|
||||
int ph7_compile(ph7 *pEngine, const char *zSource, int nLen, ph7_vm **ppOutVm) {
|
||||
SyString sScript;
|
||||
int rc;
|
||||
if(PH7_ENGINE_MISUSE(pEngine) || zSource == 0) {
|
||||
|
@ -751,8 +731,7 @@ int ph7_compile(ph7 *pEngine,const char *zSource,int nLen,ph7_vm **ppOutVm)
|
|||
* [CAPIREF: ph7_compile_v2()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_compile_v2(ph7 *pEngine,const char *zSource,int nLen,ph7_vm **ppOutVm,int iFlags)
|
||||
{
|
||||
int ph7_compile_v2(ph7 *pEngine, const char *zSource, int nLen, ph7_vm **ppOutVm, int iFlags) {
|
||||
SyString sScript;
|
||||
int rc;
|
||||
if(PH7_ENGINE_MISUSE(pEngine) || zSource == 0) {
|
||||
|
@ -784,8 +763,7 @@ int ph7_compile_v2(ph7 *pEngine,const char *zSource,int nLen,ph7_vm **ppOutVm,in
|
|||
* [CAPIREF: ph7_compile_file()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_compile_file(ph7 *pEngine,const char *zFilePath,ph7_vm **ppOutVm,int iFlags)
|
||||
{
|
||||
int ph7_compile_file(ph7 *pEngine, const char *zFilePath, ph7_vm **ppOutVm, int iFlags) {
|
||||
const ph7_vfs *pVfs;
|
||||
int rc;
|
||||
if(ppOutVm) {
|
||||
|
@ -841,8 +819,7 @@ int ph7_compile_file(ph7 *pEngine,const char *zFilePath,ph7_vm **ppOutVm,int iFl
|
|||
* [CAPIREF: ph7_vm_dump_v2()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_vm_dump_v2(ph7_vm *pVm,int (*xConsumer)(const void *,unsigned int,void *),void *pUserData)
|
||||
{
|
||||
int ph7_vm_dump_v2(ph7_vm *pVm, int (*xConsumer)(const void *, unsigned int, void *), void *pUserData) {
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
if(PH7_VM_MISUSE(pVm)) {
|
||||
|
@ -861,8 +838,7 @@ int ph7_vm_dump_v2(ph7_vm *pVm,int (*xConsumer)(const void *,unsigned int,void *
|
|||
* [CAPIREF: ph7_vm_config()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_vm_config(ph7_vm *pVm,int iConfigOp,...)
|
||||
{
|
||||
int ph7_vm_config(ph7_vm *pVm, int iConfigOp, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
|
@ -891,8 +867,7 @@ int ph7_vm_config(ph7_vm *pVm,int iConfigOp,...)
|
|||
* [CAPIREF: ph7_vm_exec()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_vm_exec(ph7_vm *pVm,int *pExitStatus)
|
||||
{
|
||||
int ph7_vm_exec(ph7_vm *pVm, int *pExitStatus) {
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
if(PH7_VM_MISUSE(pVm)) {
|
||||
|
@ -923,8 +898,7 @@ int ph7_vm_exec(ph7_vm *pVm,int *pExitStatus)
|
|||
* [CAPIREF: ph7_vm_reset()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_vm_reset(ph7_vm *pVm)
|
||||
{
|
||||
int ph7_vm_reset(ph7_vm *pVm) {
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
if(PH7_VM_MISUSE(pVm)) {
|
||||
|
@ -949,8 +923,7 @@ int ph7_vm_reset(ph7_vm *pVm)
|
|||
* [CAPIREF: ph7_vm_release()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_vm_release(ph7_vm *pVm)
|
||||
{
|
||||
int ph7_vm_release(ph7_vm *pVm) {
|
||||
ph7 *pEngine;
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
|
@ -998,8 +971,7 @@ int ph7_vm_release(ph7_vm *pVm)
|
|||
* [CAPIREF: ph7_create_function()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_create_function(ph7_vm *pVm,const char *zName,int (*xFunc)(ph7_context *,int,ph7_value **),void *pUserData)
|
||||
{
|
||||
int ph7_create_function(ph7_vm *pVm, const char *zName, int (*xFunc)(ph7_context *, int, ph7_value **), void *pUserData) {
|
||||
SyString sName;
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
|
@ -1033,8 +1005,7 @@ int ph7_create_function(ph7_vm *pVm,const char *zName,int (*xFunc)(ph7_context *
|
|||
* [CAPIREF: ph7_delete_function()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_delete_function(ph7_vm *pVm,const char *zName)
|
||||
{
|
||||
int ph7_delete_function(ph7_vm *pVm, const char *zName) {
|
||||
ph7_user_func *pFunc = 0;
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
|
@ -1067,8 +1038,7 @@ int ph7_delete_function(ph7_vm *pVm,const char *zName)
|
|||
* [CAPIREF: ph7_create_constant()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_create_constant(ph7_vm *pVm,const char *zName,void (*xExpand)(ph7_value *,void *),void *pUserData)
|
||||
{
|
||||
int ph7_create_constant(ph7_vm *pVm, const char *zName, void (*xExpand)(ph7_value *, void *), void *pUserData) {
|
||||
SyString sName;
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
|
@ -1106,8 +1076,7 @@ int ph7_create_constant(ph7_vm *pVm,const char *zName,void (*xExpand)(ph7_value
|
|||
* [CAPIREF: ph7_delete_constant()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_delete_constant(ph7_vm *pVm,const char *zName)
|
||||
{
|
||||
int ph7_delete_constant(ph7_vm *pVm, const char *zName) {
|
||||
ph7_constant *pCons;
|
||||
int rc;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
|
@ -1139,8 +1108,7 @@ int ph7_delete_constant(ph7_vm *pVm,const char *zName)
|
|||
* [CAPIREF: ph7_new_scalar()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
ph7_value * ph7_new_scalar(ph7_vm *pVm)
|
||||
{
|
||||
ph7_value *ph7_new_scalar(ph7_vm *pVm) {
|
||||
ph7_value *pObj;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
if(PH7_VM_MISUSE(pVm)) {
|
||||
|
@ -1159,8 +1127,7 @@ ph7_value * ph7_new_scalar(ph7_vm *pVm)
|
|||
* [CAPIREF: ph7_new_array()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
ph7_value * ph7_new_array(ph7_vm *pVm)
|
||||
{
|
||||
ph7_value *ph7_new_array(ph7_vm *pVm) {
|
||||
ph7_hashmap *pMap;
|
||||
ph7_value *pObj;
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
|
@ -1185,8 +1152,7 @@ ph7_value * ph7_new_array(ph7_vm *pVm)
|
|||
* [CAPIREF: ph7_release_value()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_release_value(ph7_vm *pVm,ph7_value *pValue)
|
||||
{
|
||||
int ph7_release_value(ph7_vm *pVm, ph7_value *pValue) {
|
||||
/* Ticket 1433-002: NULL VM is harmless operation */
|
||||
if(PH7_VM_MISUSE(pVm)) {
|
||||
return PH7_CORRUPT;
|
||||
|
@ -1202,8 +1168,7 @@ int ph7_release_value(ph7_vm *pVm,ph7_value *pValue)
|
|||
* [CAPIREF: ph7_value_to_int()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_to_int(ph7_value *pValue)
|
||||
{
|
||||
int ph7_value_to_int(ph7_value *pValue) {
|
||||
int rc;
|
||||
rc = PH7_MemObjToInteger(pValue);
|
||||
if(rc != PH7_OK) {
|
||||
|
@ -1215,8 +1180,7 @@ int ph7_value_to_int(ph7_value *pValue)
|
|||
* [CAPIREF: ph7_value_to_bool()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_to_bool(ph7_value *pValue)
|
||||
{
|
||||
int ph7_value_to_bool(ph7_value *pValue) {
|
||||
int rc;
|
||||
rc = PH7_MemObjToBool(pValue);
|
||||
if(rc != PH7_OK) {
|
||||
|
@ -1228,8 +1192,7 @@ int ph7_value_to_bool(ph7_value *pValue)
|
|||
* [CAPIREF: ph7_value_to_int64()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
ph7_int64 ph7_value_to_int64(ph7_value *pValue)
|
||||
{
|
||||
ph7_int64 ph7_value_to_int64(ph7_value *pValue) {
|
||||
int rc;
|
||||
rc = PH7_MemObjToInteger(pValue);
|
||||
if(rc != PH7_OK) {
|
||||
|
@ -1241,8 +1204,7 @@ ph7_int64 ph7_value_to_int64(ph7_value *pValue)
|
|||
* [CAPIREF: ph7_value_to_double()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
double ph7_value_to_double(ph7_value *pValue)
|
||||
{
|
||||
double ph7_value_to_double(ph7_value *pValue) {
|
||||
int rc;
|
||||
rc = PH7_MemObjToReal(pValue);
|
||||
if(rc != PH7_OK) {
|
||||
|
@ -1254,8 +1216,7 @@ double ph7_value_to_double(ph7_value *pValue)
|
|||
* [CAPIREF: ph7_value_to_string()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
const char * ph7_value_to_string(ph7_value *pValue,int *pLen)
|
||||
{
|
||||
const char *ph7_value_to_string(ph7_value *pValue, int *pLen) {
|
||||
PH7_MemObjToString(pValue);
|
||||
if(SyBlobLength(&pValue->sBlob) > 0) {
|
||||
SyBlobNullAppend(&pValue->sBlob);
|
||||
|
@ -1275,8 +1236,7 @@ const char * ph7_value_to_string(ph7_value *pValue,int *pLen)
|
|||
* [CAPIREF: ph7_value_to_resource()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void * ph7_value_to_resource(ph7_value *pValue)
|
||||
{
|
||||
void *ph7_value_to_resource(ph7_value *pValue) {
|
||||
if((pValue->iFlags & MEMOBJ_RES) == 0) {
|
||||
/* Not a resource,return NULL */
|
||||
return 0;
|
||||
|
@ -1287,8 +1247,7 @@ void * ph7_value_to_resource(ph7_value *pValue)
|
|||
* [CAPIREF: ph7_value_compare()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_compare(ph7_value *pLeft,ph7_value *pRight,int bStrict)
|
||||
{
|
||||
int ph7_value_compare(ph7_value *pLeft, ph7_value *pRight, int bStrict) {
|
||||
int rc;
|
||||
if(pLeft == 0 || pRight == 0) {
|
||||
/* TICKET 1433-24: NULL values is harmless operation */
|
||||
|
@ -1303,40 +1262,35 @@ int ph7_value_compare(ph7_value *pLeft,ph7_value *pRight,int bStrict)
|
|||
* [CAPIREF: ph7_result_int()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_int(ph7_context *pCtx,int iValue)
|
||||
{
|
||||
int ph7_result_int(ph7_context *pCtx, int iValue) {
|
||||
return ph7_value_int(pCtx->pRet, iValue);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_result_int64()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_int64(ph7_context *pCtx,ph7_int64 iValue)
|
||||
{
|
||||
int ph7_result_int64(ph7_context *pCtx, ph7_int64 iValue) {
|
||||
return ph7_value_int64(pCtx->pRet, iValue);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_result_bool()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_bool(ph7_context *pCtx,int iBool)
|
||||
{
|
||||
int ph7_result_bool(ph7_context *pCtx, int iBool) {
|
||||
return ph7_value_bool(pCtx->pRet, iBool);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_result_double()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_double(ph7_context *pCtx,double Value)
|
||||
{
|
||||
int ph7_result_double(ph7_context *pCtx, double Value) {
|
||||
return ph7_value_double(pCtx->pRet, Value);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_result_null()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_null(ph7_context *pCtx)
|
||||
{
|
||||
int ph7_result_null(ph7_context *pCtx) {
|
||||
/* Invalidate any prior representation and set the NULL flag */
|
||||
PH7_MemObjRelease(pCtx->pRet);
|
||||
return PH7_OK;
|
||||
|
@ -1345,16 +1299,14 @@ int ph7_result_null(ph7_context *pCtx)
|
|||
* [CAPIREF: ph7_result_string()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_string(ph7_context *pCtx,const char *zString,int nLen)
|
||||
{
|
||||
int ph7_result_string(ph7_context *pCtx, const char *zString, int nLen) {
|
||||
return ph7_value_string(pCtx->pRet, zString, nLen);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_result_string_format()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_string_format(ph7_context *pCtx,const char *zFormat,...)
|
||||
{
|
||||
int ph7_result_string_format(ph7_context *pCtx, const char *zFormat, ...) {
|
||||
ph7_value *p;
|
||||
va_list ap;
|
||||
int rc;
|
||||
|
@ -1374,8 +1326,7 @@ int ph7_result_string_format(ph7_context *pCtx,const char *zFormat,...)
|
|||
* [CAPIREF: ph7_result_value()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_value(ph7_context *pCtx,ph7_value *pValue)
|
||||
{
|
||||
int ph7_result_value(ph7_context *pCtx, ph7_value *pValue) {
|
||||
int rc = PH7_OK;
|
||||
if(pValue == 0) {
|
||||
PH7_MemObjRelease(pCtx->pRet);
|
||||
|
@ -1388,16 +1339,14 @@ int ph7_result_value(ph7_context *pCtx,ph7_value *pValue)
|
|||
* [CAPIREF: ph7_result_resource()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_result_resource(ph7_context *pCtx,void *pUserData)
|
||||
{
|
||||
int ph7_result_resource(ph7_context *pCtx, void *pUserData) {
|
||||
return ph7_value_resource(pCtx->pRet, pUserData);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_context_new_scalar()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
ph7_value * ph7_context_new_scalar(ph7_context *pCtx)
|
||||
{
|
||||
ph7_value *ph7_context_new_scalar(ph7_context *pCtx) {
|
||||
ph7_value *pVal;
|
||||
pVal = ph7_new_scalar(pCtx->pVm);
|
||||
if(pVal) {
|
||||
|
@ -1412,8 +1361,7 @@ ph7_value * ph7_context_new_scalar(ph7_context *pCtx)
|
|||
* [CAPIREF: ph7_context_new_array()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
ph7_value * ph7_context_new_array(ph7_context *pCtx)
|
||||
{
|
||||
ph7_value *ph7_context_new_array(ph7_context *pCtx) {
|
||||
ph7_value *pVal;
|
||||
pVal = ph7_new_array(pCtx->pVm);
|
||||
if(pVal) {
|
||||
|
@ -1428,16 +1376,14 @@ ph7_value * ph7_context_new_array(ph7_context *pCtx)
|
|||
* [CAPIREF: ph7_context_release_value()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void ph7_context_release_value(ph7_context *pCtx,ph7_value *pValue)
|
||||
{
|
||||
void ph7_context_release_value(ph7_context *pCtx, ph7_value *pValue) {
|
||||
PH7_VmReleaseContextValue(&(*pCtx), pValue);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_context_alloc_chunk()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void * ph7_context_alloc_chunk(ph7_context *pCtx,unsigned int nByte,int ZeroChunk,int AutoRelease)
|
||||
{
|
||||
void *ph7_context_alloc_chunk(ph7_context *pCtx, unsigned int nByte, int ZeroChunk, int AutoRelease) {
|
||||
void *pChunk;
|
||||
pChunk = SyMemBackendAlloc(&pCtx->pVm->sAllocator, nByte);
|
||||
if(pChunk) {
|
||||
|
@ -1462,8 +1408,7 @@ void * ph7_context_alloc_chunk(ph7_context *pCtx,unsigned int nByte,int ZeroChun
|
|||
* Return TRUE if registered.FALSE otherwise.
|
||||
* Refer to [ph7_context_realloc_chunk(),ph7_context_free_chunk()].
|
||||
*/
|
||||
static ph7_aux_data * ContextFindChunk(ph7_context *pCtx,void *pChunk)
|
||||
{
|
||||
static ph7_aux_data *ContextFindChunk(ph7_context *pCtx, void *pChunk) {
|
||||
ph7_aux_data *aAux, *pAux;
|
||||
sxu32 n;
|
||||
if(SySetUsed(&pCtx->sChunk) < 1) {
|
||||
|
@ -1486,8 +1431,7 @@ static ph7_aux_data * ContextFindChunk(ph7_context *pCtx,void *pChunk)
|
|||
* [CAPIREF: ph7_context_realloc_chunk()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void * ph7_context_realloc_chunk(ph7_context *pCtx,void *pChunk,unsigned int nByte)
|
||||
{
|
||||
void *ph7_context_realloc_chunk(ph7_context *pCtx, void *pChunk, unsigned int nByte) {
|
||||
ph7_aux_data *pAux;
|
||||
void *pNew;
|
||||
pNew = SyMemBackendRealloc(&pCtx->pVm->sAllocator, pChunk, nByte);
|
||||
|
@ -1503,8 +1447,7 @@ void * ph7_context_realloc_chunk(ph7_context *pCtx,void *pChunk,unsigned int nBy
|
|||
* [CAPIREF: ph7_context_free_chunk()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void ph7_context_free_chunk(ph7_context *pCtx,void *pChunk)
|
||||
{
|
||||
void ph7_context_free_chunk(ph7_context *pCtx, void *pChunk) {
|
||||
ph7_aux_data *pAux;
|
||||
if(pChunk == 0) {
|
||||
/* TICKET-1433-93: NULL chunk is a harmless operation */
|
||||
|
@ -1521,8 +1464,7 @@ void ph7_context_free_chunk(ph7_context *pCtx,void *pChunk)
|
|||
* [CAPIREF: ph7_array_fetch()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
ph7_value * ph7_array_fetch(ph7_value *pArray,const char *zKey,int nByte)
|
||||
{
|
||||
ph7_value *ph7_array_fetch(ph7_value *pArray, const char *zKey, int nByte) {
|
||||
ph7_hashmap_node *pNode;
|
||||
ph7_value *pValue;
|
||||
ph7_value skey;
|
||||
|
@ -1552,8 +1494,7 @@ ph7_value * ph7_array_fetch(ph7_value *pArray,const char *zKey,int nByte)
|
|||
* [CAPIREF: ph7_array_walk()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_array_walk(ph7_value *pArray,int (*xWalk)(ph7_value *pValue,ph7_value *,void *),void *pUserData)
|
||||
{
|
||||
int ph7_array_walk(ph7_value *pArray, int (*xWalk)(ph7_value *pValue, ph7_value *, void *), void *pUserData) {
|
||||
int rc;
|
||||
if(xWalk == 0) {
|
||||
return PH7_CORRUPT;
|
||||
|
@ -1570,8 +1511,7 @@ int ph7_array_walk(ph7_value *pArray,int (*xWalk)(ph7_value *pValue,ph7_value *,
|
|||
* [CAPIREF: ph7_array_add_elem()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_array_add_elem(ph7_value *pArray,ph7_value *pKey,ph7_value *pValue)
|
||||
{
|
||||
int ph7_array_add_elem(ph7_value *pArray, ph7_value *pKey, ph7_value *pValue) {
|
||||
int rc;
|
||||
/* Make sure we are dealing with a valid hashmap */
|
||||
if((pArray->iFlags & MEMOBJ_HASHMAP) == 0) {
|
||||
|
@ -1585,8 +1525,7 @@ int ph7_array_add_elem(ph7_value *pArray,ph7_value *pKey,ph7_value *pValue)
|
|||
* [CAPIREF: ph7_array_add_strkey_elem()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_array_add_strkey_elem(ph7_value *pArray,const char *zKey,ph7_value *pValue)
|
||||
{
|
||||
int ph7_array_add_strkey_elem(ph7_value *pArray, const char *zKey, ph7_value *pValue) {
|
||||
int rc;
|
||||
/* Make sure we are dealing with a valid hashmap */
|
||||
if((pArray->iFlags & MEMOBJ_HASHMAP) == 0) {
|
||||
|
@ -1609,8 +1548,7 @@ int ph7_array_add_strkey_elem(ph7_value *pArray,const char *zKey,ph7_value *pVal
|
|||
* [CAPIREF: ph7_array_add_intkey_elem()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_array_add_intkey_elem(ph7_value *pArray,int iKey,ph7_value *pValue)
|
||||
{
|
||||
int ph7_array_add_intkey_elem(ph7_value *pArray, int iKey, ph7_value *pValue) {
|
||||
ph7_value sKey;
|
||||
int rc;
|
||||
/* Make sure we are dealing with a valid hashmap */
|
||||
|
@ -1627,8 +1565,7 @@ int ph7_array_add_intkey_elem(ph7_value *pArray,int iKey,ph7_value *pValue)
|
|||
* [CAPIREF: ph7_array_count()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
unsigned int ph7_array_count(ph7_value *pArray)
|
||||
{
|
||||
unsigned int ph7_array_count(ph7_value *pArray) {
|
||||
ph7_hashmap *pMap;
|
||||
/* Make sure we are dealing with a valid hashmap */
|
||||
if((pArray->iFlags & MEMOBJ_HASHMAP) == 0) {
|
||||
|
@ -1642,8 +1579,7 @@ unsigned int ph7_array_count(ph7_value *pArray)
|
|||
* [CAPIREF: ph7_object_walk()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_object_walk(ph7_value *pObject,int (*xWalk)(const char *,ph7_value *,void *),void *pUserData)
|
||||
{
|
||||
int ph7_object_walk(ph7_value *pObject, int (*xWalk)(const char *, ph7_value *, void *), void *pUserData) {
|
||||
int rc;
|
||||
if(xWalk == 0) {
|
||||
return PH7_CORRUPT;
|
||||
|
@ -1660,8 +1596,7 @@ int ph7_object_walk(ph7_value *pObject,int (*xWalk)(const char *,ph7_value *,voi
|
|||
* [CAPIREF: ph7_object_fetch_attr()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
ph7_value * ph7_object_fetch_attr(ph7_value *pObject,const char *zAttr)
|
||||
{
|
||||
ph7_value *ph7_object_fetch_attr(ph7_value *pObject, const char *zAttr) {
|
||||
ph7_value *pValue;
|
||||
SyString sAttr;
|
||||
/* Make sure we are dealing with a valid class instance */
|
||||
|
@ -1678,8 +1613,7 @@ ph7_value * ph7_object_fetch_attr(ph7_value *pObject,const char *zAttr)
|
|||
* [CAPIREF: ph7_object_get_class_name()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
const char * ph7_object_get_class_name(ph7_value *pObject,int *pLength)
|
||||
{
|
||||
const char *ph7_object_get_class_name(ph7_value *pObject, int *pLength) {
|
||||
ph7_class *pClass;
|
||||
if(pLength) {
|
||||
*pLength = 0;
|
||||
|
@ -1700,8 +1634,7 @@ const char * ph7_object_get_class_name(ph7_value *pObject,int *pLength)
|
|||
* [CAPIREF: ph7_context_output()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_output(ph7_context *pCtx,const char *zString,int nLen)
|
||||
{
|
||||
int ph7_context_output(ph7_context *pCtx, const char *zString, int nLen) {
|
||||
SyString sData;
|
||||
int rc;
|
||||
if(nLen < 0) {
|
||||
|
@ -1715,8 +1648,7 @@ int ph7_context_output(ph7_context *pCtx,const char *zString,int nLen)
|
|||
* [CAPIREF: ph7_context_output_format()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_output_format(ph7_context *pCtx,const char *zFormat,...)
|
||||
{
|
||||
int ph7_context_output_format(ph7_context *pCtx, const char *zFormat, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
va_start(ap, zFormat);
|
||||
|
@ -1728,8 +1660,7 @@ int ph7_context_output_format(ph7_context *pCtx,const char *zFormat,...)
|
|||
* [CAPIREF: ph7_context_throw_error()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_throw_error(ph7_context *pCtx,int iErr,const char *zErr)
|
||||
{
|
||||
int ph7_context_throw_error(ph7_context *pCtx, int iErr, const char *zErr) {
|
||||
int rc = PH7_OK;
|
||||
if(zErr) {
|
||||
rc = PH7_VmThrowError(pCtx->pVm, &pCtx->pFunc->sName, iErr, zErr);
|
||||
|
@ -1740,8 +1671,7 @@ int ph7_context_throw_error(ph7_context *pCtx,int iErr,const char *zErr)
|
|||
* [CAPIREF: ph7_context_throw_error_format()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_throw_error_format(ph7_context *pCtx,int iErr,const char *zFormat,...)
|
||||
{
|
||||
int ph7_context_throw_error_format(ph7_context *pCtx, int iErr, const char *zFormat, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
if(zFormat == 0) {
|
||||
|
@ -1756,8 +1686,7 @@ int ph7_context_throw_error_format(ph7_context *pCtx,int iErr,const char *zForma
|
|||
* [CAPIREF: ph7_context_random_num()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
unsigned int ph7_context_random_num(ph7_context *pCtx)
|
||||
{
|
||||
unsigned int ph7_context_random_num(ph7_context *pCtx) {
|
||||
sxu32 n;
|
||||
n = PH7_VmRandomNum(pCtx->pVm);
|
||||
return n;
|
||||
|
@ -1766,8 +1695,7 @@ unsigned int ph7_context_random_num(ph7_context *pCtx)
|
|||
* [CAPIREF: ph7_context_random_string()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_random_string(ph7_context *pCtx,char *zBuf,int nBuflen)
|
||||
{
|
||||
int ph7_context_random_string(ph7_context *pCtx, char *zBuf, int nBuflen) {
|
||||
if(nBuflen < 3) {
|
||||
return PH7_CORRUPT;
|
||||
}
|
||||
|
@ -1786,16 +1714,14 @@ int ph7_context_random_string(ph7_context *pCtx,char *zBuf,int nBuflen)
|
|||
* [CAPIREF: ph7_context_user_data()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void * ph7_context_user_data(ph7_context *pCtx)
|
||||
{
|
||||
void *ph7_context_user_data(ph7_context *pCtx) {
|
||||
return pCtx->pFunc->pUserData;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_context_push_aux_data()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_context_push_aux_data(ph7_context *pCtx,void *pUserData)
|
||||
{
|
||||
int ph7_context_push_aux_data(ph7_context *pCtx, void *pUserData) {
|
||||
ph7_aux_data sAux;
|
||||
int rc;
|
||||
sAux.pAuxData = pUserData;
|
||||
|
@ -1806,8 +1732,7 @@ int ph7_context_push_aux_data(ph7_context *pCtx,void *pUserData)
|
|||
* [CAPIREF: ph7_context_peek_aux_data()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void * ph7_context_peek_aux_data(ph7_context *pCtx)
|
||||
{
|
||||
void *ph7_context_peek_aux_data(ph7_context *pCtx) {
|
||||
ph7_aux_data *pAux;
|
||||
pAux = (ph7_aux_data *)SySetPeek(&pCtx->pFunc->aAux);
|
||||
return pAux ? pAux->pAuxData : 0;
|
||||
|
@ -1816,8 +1741,7 @@ void * ph7_context_peek_aux_data(ph7_context *pCtx)
|
|||
* [CAPIREF: ph7_context_pop_aux_data()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
void * ph7_context_pop_aux_data(ph7_context *pCtx)
|
||||
{
|
||||
void *ph7_context_pop_aux_data(ph7_context *pCtx) {
|
||||
ph7_aux_data *pAux;
|
||||
pAux = (ph7_aux_data *)SySetPop(&pCtx->pFunc->aAux);
|
||||
return pAux ? pAux->pAuxData : 0;
|
||||
|
@ -1826,16 +1750,14 @@ void * ph7_context_pop_aux_data(ph7_context *pCtx)
|
|||
* [CAPIREF: ph7_context_result_buf_length()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
unsigned int ph7_context_result_buf_length(ph7_context *pCtx)
|
||||
{
|
||||
unsigned int ph7_context_result_buf_length(ph7_context *pCtx) {
|
||||
return SyBlobLength(&pCtx->pRet->sBlob);
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_function_name()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
const char * ph7_function_name(ph7_context *pCtx)
|
||||
{
|
||||
const char *ph7_function_name(ph7_context *pCtx) {
|
||||
SyString *pName;
|
||||
pName = &pCtx->pFunc->sName;
|
||||
return pName->zString;
|
||||
|
@ -1844,8 +1766,7 @@ const char * ph7_function_name(ph7_context *pCtx)
|
|||
* [CAPIREF: ph7_value_int()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_int(ph7_value *pVal,int iValue)
|
||||
{
|
||||
int ph7_value_int(ph7_value *pVal, int iValue) {
|
||||
/* Invalidate any prior representation */
|
||||
PH7_MemObjRelease(pVal);
|
||||
pVal->x.iVal = (ph7_int64)iValue;
|
||||
|
@ -1856,8 +1777,7 @@ int ph7_value_int(ph7_value *pVal,int iValue)
|
|||
* [CAPIREF: ph7_value_int64()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_int64(ph7_value *pVal,ph7_int64 iValue)
|
||||
{
|
||||
int ph7_value_int64(ph7_value *pVal, ph7_int64 iValue) {
|
||||
/* Invalidate any prior representation */
|
||||
PH7_MemObjRelease(pVal);
|
||||
pVal->x.iVal = iValue;
|
||||
|
@ -1868,8 +1788,7 @@ int ph7_value_int64(ph7_value *pVal,ph7_int64 iValue)
|
|||
* [CAPIREF: ph7_value_bool()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_bool(ph7_value *pVal,int iBool)
|
||||
{
|
||||
int ph7_value_bool(ph7_value *pVal, int iBool) {
|
||||
/* Invalidate any prior representation */
|
||||
PH7_MemObjRelease(pVal);
|
||||
pVal->x.iVal = iBool ? 1 : 0;
|
||||
|
@ -1880,8 +1799,7 @@ int ph7_value_bool(ph7_value *pVal,int iBool)
|
|||
* [CAPIREF: ph7_value_null()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_null(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_null(ph7_value *pVal) {
|
||||
/* Invalidate any prior representation and set the NULL flag */
|
||||
PH7_MemObjRelease(pVal);
|
||||
return PH7_OK;
|
||||
|
@ -1890,8 +1808,7 @@ int ph7_value_null(ph7_value *pVal)
|
|||
* [CAPIREF: ph7_value_double()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_double(ph7_value *pVal,double Value)
|
||||
{
|
||||
int ph7_value_double(ph7_value *pVal, double Value) {
|
||||
/* Invalidate any prior representation */
|
||||
PH7_MemObjRelease(pVal);
|
||||
pVal->rVal = (ph7_real)Value;
|
||||
|
@ -1904,8 +1821,7 @@ int ph7_value_double(ph7_value *pVal,double Value)
|
|||
* [CAPIREF: ph7_value_string()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_string(ph7_value *pVal,const char *zString,int nLen)
|
||||
{
|
||||
int ph7_value_string(ph7_value *pVal, const char *zString, int nLen) {
|
||||
if((pVal->iFlags & MEMOBJ_STRING) == 0) {
|
||||
/* Invalidate any prior representation */
|
||||
PH7_MemObjRelease(pVal);
|
||||
|
@ -1924,8 +1840,7 @@ int ph7_value_string(ph7_value *pVal,const char *zString,int nLen)
|
|||
* [CAPIREF: ph7_value_string_format()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_string_format(ph7_value *pVal,const char *zFormat,...)
|
||||
{
|
||||
int ph7_value_string_format(ph7_value *pVal, const char *zFormat, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
if((pVal->iFlags & MEMOBJ_STRING) == 0) {
|
||||
|
@ -1942,8 +1857,7 @@ int ph7_value_string_format(ph7_value *pVal,const char *zFormat,...)
|
|||
* [CAPIREF: ph7_value_reset_string_cursor()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_reset_string_cursor(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_reset_string_cursor(ph7_value *pVal) {
|
||||
/* Reset the string cursor */
|
||||
SyBlobReset(&pVal->sBlob);
|
||||
return PH7_OK;
|
||||
|
@ -1952,8 +1866,7 @@ int ph7_value_reset_string_cursor(ph7_value *pVal)
|
|||
* [CAPIREF: ph7_value_resource()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_resource(ph7_value *pVal,void *pUserData)
|
||||
{
|
||||
int ph7_value_resource(ph7_value *pVal, void *pUserData) {
|
||||
/* Invalidate any prior representation */
|
||||
PH7_MemObjRelease(pVal);
|
||||
/* Reflect the new type */
|
||||
|
@ -1965,8 +1878,7 @@ int ph7_value_resource(ph7_value *pVal,void *pUserData)
|
|||
* [CAPIREF: ph7_value_release()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_release(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_release(ph7_value *pVal) {
|
||||
PH7_MemObjRelease(pVal);
|
||||
return PH7_OK;
|
||||
}
|
||||
|
@ -1974,48 +1886,42 @@ int ph7_value_release(ph7_value *pVal)
|
|||
* [CAPIREF: ph7_value_is_int()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_int(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_int(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_INT) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_float()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_float(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_float(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_REAL) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_bool()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_bool(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_bool(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_BOOL) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_string()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_string(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_string(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_STRING) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_null()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_null(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_null(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_NULL) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_numeric()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_numeric(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_numeric(ph7_value *pVal) {
|
||||
int rc;
|
||||
rc = PH7_MemObjIsNumeric(pVal);
|
||||
return rc;
|
||||
|
@ -2024,8 +1930,7 @@ int ph7_value_is_numeric(ph7_value *pVal)
|
|||
* [CAPIREF: ph7_value_is_callable()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_callable(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_callable(ph7_value *pVal) {
|
||||
int rc;
|
||||
rc = PH7_VmIsCallable(pVal->pVm, pVal, FALSE);
|
||||
return rc;
|
||||
|
@ -2034,40 +1939,35 @@ int ph7_value_is_callable(ph7_value *pVal)
|
|||
* [CAPIREF: ph7_value_is_scalar()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_scalar(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_scalar(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_SCALAR) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_array()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_array(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_array(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_HASHMAP) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_object()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_object(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_object(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_OBJ) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_resource()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_resource(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_resource(ph7_value *pVal) {
|
||||
return (pVal->iFlags & MEMOBJ_RES) ? TRUE : FALSE;
|
||||
}
|
||||
/*
|
||||
* [CAPIREF: ph7_value_is_empty()]
|
||||
* Please refer to the official documentation for function purpose and expected parameters.
|
||||
*/
|
||||
int ph7_value_is_empty(ph7_value *pVal)
|
||||
{
|
||||
int ph7_value_is_empty(ph7_value *pVal) {
|
||||
int rc;
|
||||
rc = PH7_MemObjIsEmpty(pVal);
|
||||
return rc;
|
||||
|
|
283
compile.c
283
compile.c
|
@ -39,8 +39,7 @@ typedef struct JumpFixup JumpFixup;
|
|||
* are emitted, we record each forward jump in an instance of the following
|
||||
* structure. Those jumps are fixed later when the jump destination is resolved.
|
||||
*/
|
||||
struct JumpFixup
|
||||
{
|
||||
struct JumpFixup {
|
||||
sxi32 nJumpType; /* Jump type. Either TRUE jump, FALSE jump or Unconditional jump */
|
||||
sxu32 nInstrIdx; /* Instruction index to fix later when the jump destination is resolved. */
|
||||
/* The following fields are only used by the goto statement */
|
||||
|
@ -51,8 +50,7 @@ struct JumpFixup
|
|||
* Each language construct is represented by an instance
|
||||
* of the following structure.
|
||||
*/
|
||||
struct LangConstruct
|
||||
{
|
||||
struct LangConstruct {
|
||||
sxu32 nID; /* Language construct ID [i.e: PH7_TKWRD_WHILE,PH7_TKWRD_FOR,PH7_TKWRD_IF...] */
|
||||
ProcLangConstruct xConstruct; /* C function implementing the language construct */
|
||||
};
|
||||
|
@ -87,8 +85,7 @@ static sxi32 PH7_CompileExpr(ph7_gen_state *pGen,sxi32 iFlags,sxi32 (*xTreeValid
|
|||
* compiled blocks.
|
||||
* Return a pointer to that block on success. NULL otherwise.
|
||||
*/
|
||||
static GenBlock * GenStateFetchBlock(GenBlock *pCurrent,sxi32 iBlockType,sxi32 iCount)
|
||||
{
|
||||
static GenBlock *GenStateFetchBlock(GenBlock *pCurrent, sxi32 iBlockType, sxi32 iCount) {
|
||||
GenBlock *pBlock = pCurrent;
|
||||
for(;;) {
|
||||
if(pBlock->iFlags & iBlockType) {
|
||||
|
@ -117,8 +114,7 @@ static void GenStateInitBlock(
|
|||
sxi32 iType, /* Block type [i.e: loop, conditional, function body, etc.]*/
|
||||
sxu32 nFirstInstr, /* First instruction to compile */
|
||||
void *pUserData /* Upper layer private data */
|
||||
)
|
||||
{
|
||||
) {
|
||||
/* Initialize block fields */
|
||||
pBlock->nFirstInstr = nFirstInstr;
|
||||
pBlock->pUserData = pUserData;
|
||||
|
@ -140,8 +136,7 @@ static sxi32 GenStateEnterBlock(
|
|||
sxu32 nFirstInstr, /* First instruction to compile */
|
||||
void *pUserData, /* Upper layer private data */
|
||||
GenBlock **ppBlock /* OUT: instantiated block */
|
||||
)
|
||||
{
|
||||
) {
|
||||
GenBlock *pBlock;
|
||||
/* Allocate a new block instance */
|
||||
pBlock = (GenBlock *)SyMemBackendPoolAlloc(&pGen->pVm->sAllocator, sizeof(GenBlock));
|
||||
|
@ -169,16 +164,14 @@ static sxi32 GenStateEnterBlock(
|
|||
/*
|
||||
* Release block fields without freeing the whole instance.
|
||||
*/
|
||||
static void GenStateReleaseBlock(GenBlock *pBlock)
|
||||
{
|
||||
static void GenStateReleaseBlock(GenBlock *pBlock) {
|
||||
SySetRelease(&pBlock->aPostContFix);
|
||||
SySetRelease(&pBlock->aJumpFix);
|
||||
}
|
||||
/*
|
||||
* Release a block.
|
||||
*/
|
||||
static void GenStateFreeBlock(GenBlock *pBlock)
|
||||
{
|
||||
static void GenStateFreeBlock(GenBlock *pBlock) {
|
||||
ph7_gen_state *pGen = pBlock->pGen;
|
||||
GenStateReleaseBlock(&(*pBlock));
|
||||
/* Free the instance */
|
||||
|
@ -187,8 +180,7 @@ static void GenStateFreeBlock(GenBlock *pBlock)
|
|||
/*
|
||||
* POP and release a block from the stack of compiled blocks.
|
||||
*/
|
||||
static sxi32 GenStateLeaveBlock(ph7_gen_state *pGen,GenBlock **ppBlock)
|
||||
{
|
||||
static sxi32 GenStateLeaveBlock(ph7_gen_state *pGen, GenBlock **ppBlock) {
|
||||
GenBlock *pBlock = pGen->pCurrent;
|
||||
if(pBlock == 0) {
|
||||
/* No more block to pop */
|
||||
|
@ -215,8 +207,7 @@ static sxi32 GenStateLeaveBlock(ph7_gen_state *pGen,GenBlock **ppBlock)
|
|||
* are emitted, we record each forward jump in an instance of the following
|
||||
* structure. Those jumps are fixed later when the jump destination is resolved.
|
||||
*/
|
||||
static sxi32 GenStateNewJumpFixup(GenBlock *pBlock,sxi32 nJumpType,sxu32 nInstrIdx)
|
||||
{
|
||||
static sxi32 GenStateNewJumpFixup(GenBlock *pBlock, sxi32 nJumpType, sxu32 nInstrIdx) {
|
||||
JumpFixup sJumpFix;
|
||||
sxi32 rc;
|
||||
/* Init the JumpFixup structure */
|
||||
|
@ -237,8 +228,7 @@ static sxi32 GenStateNewJumpFixup(GenBlock *pBlock,sxi32 nJumpType,sxu32 nInstrI
|
|||
* are emitted, we record each forward jump in an instance of the following
|
||||
* structure.Those jumps are fixed later when the jump destination is resolved.
|
||||
*/
|
||||
static sxu32 GenStateFixJumps(GenBlock *pBlock,sxi32 nJumpType,sxu32 nJumpDest)
|
||||
{
|
||||
static sxu32 GenStateFixJumps(GenBlock *pBlock, sxi32 nJumpType, sxu32 nJumpDest) {
|
||||
JumpFixup *aFix;
|
||||
VmInstr *pInstr;
|
||||
sxu32 nFixed;
|
||||
|
@ -270,8 +260,7 @@ static sxu32 GenStateFixJumps(GenBlock *pBlock,sxi32 nJumpType,sxu32 nJumpDest)
|
|||
/*
|
||||
* Check if a given token value is installed in the literal table.
|
||||
*/
|
||||
static sxi32 GenStateFindLiteral(ph7_gen_state *pGen,const SyString *pValue,sxu32 *pIdx)
|
||||
{
|
||||
static sxi32 GenStateFindLiteral(ph7_gen_state *pGen, const SyString *pValue, sxu32 *pIdx) {
|
||||
SyHashEntry *pEntry;
|
||||
pEntry = SyHashGet(&pGen->hLiteral, (const void *)pValue->zString, pValue->nByte);
|
||||
if(pEntry == 0) {
|
||||
|
@ -284,8 +273,7 @@ static sxi32 GenStateFindLiteral(ph7_gen_state *pGen,const SyString *pValue,sxu3
|
|||
* Install a given constant index in the literal table.
|
||||
* In order to be installed, the ph7_value must be of type string.
|
||||
*/
|
||||
static sxi32 GenStateInstallLiteral(ph7_gen_state *pGen,ph7_value *pObj,sxu32 nIdx)
|
||||
{
|
||||
static sxi32 GenStateInstallLiteral(ph7_gen_state *pGen, ph7_value *pObj, sxu32 nIdx) {
|
||||
if(SyBlobLength(&pObj->sBlob) > 0) {
|
||||
SyHashInsert(&pGen->hLiteral, SyBlobData(&pObj->sBlob), SyBlobLength(&pObj->sBlob), SX_INT_TO_PTR(nIdx));
|
||||
}
|
||||
|
@ -295,8 +283,7 @@ static sxi32 GenStateInstallLiteral(ph7_gen_state *pGen,ph7_value *pObj,sxu32 nI
|
|||
* Reserve a room for a numeric constant [i.e: 64-bit integer or real number]
|
||||
* in the constant table.
|
||||
*/
|
||||
static ph7_value * GenStateInstallNumLiteral(ph7_gen_state *pGen,sxu32 *pIdx)
|
||||
{
|
||||
static ph7_value *GenStateInstallNumLiteral(ph7_gen_state *pGen, sxu32 *pIdx) {
|
||||
ph7_value *pObj;
|
||||
sxu32 nIdx = 0; /* cc warning */
|
||||
/* Reserve a new constant */
|
||||
|
@ -332,8 +319,7 @@ static sxi32 GenStateCompileChunk(ph7_gen_state *pGen,sxi32 iFlags);
|
|||
* For more information on this powerfull extension please refer to the official
|
||||
* documentation.
|
||||
*/
|
||||
static sxi32 PH7_CompileNumLiteral(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
static sxi32 PH7_CompileNumLiteral(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
SyToken *pToken = pGen->pIn; /* Raw token */
|
||||
sxu32 nIdx = 0;
|
||||
if(pToken->nType & PH7_TK_INTEGER) {
|
||||
|
@ -374,8 +360,7 @@ static sxi32 PH7_CompileNumLiteral(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
|||
* or \n, will be output literally as specified rather than having any special meaning.
|
||||
*
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileSimpleString(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileSimpleString(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
SyString *pStr = &pGen->pIn->sData; /* Constant string literal */
|
||||
const char *zIn, *zCur, *zEnd;
|
||||
ph7_value *pObj;
|
||||
|
@ -472,8 +457,7 @@ static sxi32 GenStateProcessStringExpression(
|
|||
sxu32 nLine, /* Line number */
|
||||
const char *zIn, /* Raw expression */
|
||||
const char *zEnd /* End of the expression */
|
||||
)
|
||||
{
|
||||
) {
|
||||
SyToken *pTmpIn, *pTmpEnd;
|
||||
SySet sToken;
|
||||
sxi32 rc;
|
||||
|
@ -501,8 +485,7 @@ static sxi32 GenStateProcessStringExpression(
|
|||
/*
|
||||
* Reserve a new constant for a double quoted string.
|
||||
*/
|
||||
static ph7_value * GenStateNewStrObj(ph7_gen_state *pGen,sxi32 *pCount)
|
||||
{
|
||||
static ph7_value *GenStateNewStrObj(ph7_gen_state *pGen, sxi32 *pCount) {
|
||||
ph7_value *pConstObj;
|
||||
sxu32 nIdx = 0;
|
||||
/* Reserve a new constant */
|
||||
|
@ -537,8 +520,7 @@ static ph7_value * GenStateNewStrObj(ph7_gen_state *pGen,sxi32 *pCount)
|
|||
* The most important feature of double-quoted strings is the fact that variable names will be expanded.
|
||||
* See string parsing for details.
|
||||
*/
|
||||
static sxi32 GenStateCompileString(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 GenStateCompileString(ph7_gen_state *pGen) {
|
||||
SyString *pStr = &pGen->pIn->sData; /* Raw token value */
|
||||
const char *zIn, *zCur, *zEnd;
|
||||
ph7_value *pObj = 0;
|
||||
|
@ -814,8 +796,7 @@ static sxi32 GenStateCompileString(ph7_gen_state *pGen)
|
|||
* Compile a double quoted string.
|
||||
* See the block-comment above for more information.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileString(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileString(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
sxi32 rc;
|
||||
rc = GenStateCompileString(&(*pGen));
|
||||
SXUNUSED(iCompileFlag); /* cc warning */
|
||||
|
@ -847,8 +828,7 @@ static sxi32 GenStateCompileArrayEntry(
|
|||
SyToken *pEnd, /* End of the token stream */
|
||||
sxi32 iFlags, /* Compilation flags */
|
||||
sxi32(*xValidator)(ph7_gen_state *, ph7_expr_node *) /* Expression tree validator callback */
|
||||
)
|
||||
{
|
||||
) {
|
||||
SyToken *pTmpIn, *pTmpEnd;
|
||||
sxi32 rc;
|
||||
/* Swap token stream */
|
||||
|
@ -867,8 +847,7 @@ static sxi32 GenStateCompileArrayEntry(
|
|||
* See the routine responible of compiling the array language construct
|
||||
* for more inforation.
|
||||
*/
|
||||
static sxi32 GenStateArrayNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRoot)
|
||||
{
|
||||
static sxi32 GenStateArrayNodeValidator(ph7_gen_state *pGen, ph7_expr_node *pRoot) {
|
||||
sxi32 rc = SXRET_OK;
|
||||
if(pRoot->pOp) {
|
||||
if(pRoot->pOp->iOp != EXPR_OP_SUBSCRIPT /* $a[] */ &&
|
||||
|
@ -900,8 +879,7 @@ static sxi32 GenStateArrayNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRoot
|
|||
* dictionary, collection, stack, queue, and probably more. As array values can be
|
||||
* other arrays, trees and multidimensional arrays are also possible.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileArray(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileArray(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
sxi32(*xValidator)(ph7_gen_state *, ph7_expr_node *); /* Expression tree validator callback */
|
||||
SyToken *pKey, *pCur;
|
||||
sxi32 iEmitRef = 0;
|
||||
|
@ -1013,8 +991,7 @@ PH7_PRIVATE sxi32 PH7_CompileArray(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
|||
* See the routine responible of compiling the list language construct
|
||||
* for more inforation.
|
||||
*/
|
||||
static sxi32 GenStateListNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRoot)
|
||||
{
|
||||
static sxi32 GenStateListNodeValidator(ph7_gen_state *pGen, ph7_expr_node *pRoot) {
|
||||
sxi32 rc = SXRET_OK;
|
||||
if(pRoot->pOp) {
|
||||
if(pRoot->pOp->iOp != EXPR_OP_SUBSCRIPT /* $a[] */ && pRoot->pOp->iOp != EXPR_OP_ARROW /* -> */
|
||||
|
@ -1050,8 +1027,7 @@ static sxi32 GenStateListNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRoot)
|
|||
* Return Values
|
||||
* The assigned array.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileList(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileList(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
SyToken *pNext;
|
||||
sxi32 nExpr;
|
||||
sxi32 rc;
|
||||
|
@ -1103,8 +1079,7 @@ static sxi32 GenStateCompileFunc(ph7_gen_state *pGen,SyString *pName,sxi32 iFlag
|
|||
* Note that the implementation of annoynmous function and closure under
|
||||
* PH7 is completely different from the one used by the zend engine.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileAnnonFunc(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileAnnonFunc(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
ph7_vm_func *pAnnonFunc; /* Annonymous function body */
|
||||
char zName[512]; /* Unique lambda name */
|
||||
static int iCnt = 1; /* There is no worry about thread-safety here,because only
|
||||
|
@ -1115,7 +1090,6 @@ PH7_PRIVATE sxi32 PH7_CompileAnnonFunc(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
|||
sxu32 nIdx;
|
||||
sxu32 nLen;
|
||||
sxi32 rc;
|
||||
|
||||
pGen->pIn++; /* Jump the 'function' keyword */
|
||||
if(pGen->pIn->nType & (PH7_TK_ID | PH7_TK_KEYWORD)) {
|
||||
pGen->pIn++;
|
||||
|
@ -1153,8 +1127,7 @@ PH7_PRIVATE sxi32 PH7_CompileAnnonFunc(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
|||
/*
|
||||
* Compile a backtick quoted string.
|
||||
*/
|
||||
static sxi32 PH7_CompileBacktic(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
static sxi32 PH7_CompileBacktic(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
/* TICKET 1433-40: This construct is disabled in the current release of the PH7 engine.
|
||||
* If you want this feature,please contact symisc systems via contact@symisc.net
|
||||
*/
|
||||
|
@ -1172,8 +1145,7 @@ static sxi32 PH7_CompileBacktic(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
|||
* Compile a function [i.e: die(),exit(),include(),...] which is a langauge
|
||||
* construct.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileLangConstruct(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileLangConstruct(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
SyString *pName;
|
||||
sxu32 nKeyID;
|
||||
sxi32 rc;
|
||||
|
@ -1265,8 +1237,7 @@ PH7_PRIVATE sxi32 PH7_CompileLangConstruct(ph7_gen_state *pGen,sxi32 iCompileFla
|
|||
* To assign by reference, simply prepend an ampersand (&) to the beginning of the variable which
|
||||
* is being assigned (the source variable).
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileVariable(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileVariable(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
sxi32 iVv;
|
||||
sxi32 iP1;
|
||||
|
@ -1347,8 +1318,7 @@ PH7_PRIVATE sxi32 PH7_CompileVariable(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
|||
/*
|
||||
* Load a literal.
|
||||
*/
|
||||
static sxi32 GenStateLoadLiteral(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 GenStateLoadLiteral(ph7_gen_state *pGen) {
|
||||
SyToken *pToken = pGen->pIn;
|
||||
ph7_value *pObj;
|
||||
SyString *pStr;
|
||||
|
@ -1437,8 +1407,7 @@ static sxi32 GenStateLoadLiteral(ph7_gen_state *pGen)
|
|||
* a working version that implement namespace,please contact
|
||||
* symisc systems via contact@symisc.net
|
||||
*/
|
||||
static sxi32 GenStateResolveNamespaceLiteral(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 GenStateResolveNamespaceLiteral(ph7_gen_state *pGen) {
|
||||
int emit = 0;
|
||||
sxi32 rc;
|
||||
while(pGen->pIn < &pGen->pEnd[-1]) {
|
||||
|
@ -1459,8 +1428,7 @@ static sxi32 GenStateResolveNamespaceLiteral(ph7_gen_state *pGen)
|
|||
/*
|
||||
* Compile a literal which is an identifier(name) for a simple value.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_CompileLiteral(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_CompileLiteral(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
sxi32 rc;
|
||||
rc = GenStateResolveNamespaceLiteral(&(*pGen));
|
||||
if(rc != SXRET_OK) {
|
||||
|
@ -1474,8 +1442,7 @@ PH7_PRIVATE sxi32 PH7_CompileLiteral(ph7_gen_state *pGen,sxi32 iCompileFlag)
|
|||
* Recover from a compile-time error. In other words synchronize
|
||||
* the token stream cursor with the first semi-colon seen.
|
||||
*/
|
||||
static sxi32 PH7_ErrorRecover(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_ErrorRecover(ph7_gen_state *pGen) {
|
||||
/* Synchronize with the next-semi-colon and avoid compiling this erroneous statement */
|
||||
while(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_SEMI /*';'*/) == 0) {
|
||||
pGen->pIn++;
|
||||
|
@ -1486,8 +1453,7 @@ static sxi32 PH7_ErrorRecover(ph7_gen_state *pGen)
|
|||
* Check if the given identifier name is reserved or not.
|
||||
* Return TRUE if reserved.FALSE otherwise.
|
||||
*/
|
||||
static int GenStateIsReservedConstant(SyString *pName)
|
||||
{
|
||||
static int GenStateIsReservedConstant(SyString *pName) {
|
||||
if(pName->nByte == sizeof("null") - 1) {
|
||||
if(SyStrnicmp(pName->zString, "null", sizeof("null") - 1) == 0) {
|
||||
return TRUE;
|
||||
|
@ -1526,8 +1492,7 @@ static int GenStateIsReservedConstant(SyString *pName)
|
|||
* const HELLO = "Welcome "." guest ".rand_str(3); //Valid under PH7/Generate error using the zend engine
|
||||
* Refer to the official documentation for more information on this feature.
|
||||
*/
|
||||
static sxi32 PH7_CompileConstant(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileConstant(ph7_gen_state *pGen) {
|
||||
SySet *pConsCode, *pInstrContainer;
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
SyString *pName;
|
||||
|
@ -1612,8 +1577,7 @@ Synchronize:
|
|||
* Note:
|
||||
* continue 0; and continue 1; is the same as running continue;.
|
||||
*/
|
||||
static sxi32 PH7_CompileContinue(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileContinue(ph7_gen_state *pGen) {
|
||||
GenBlock *pLoop; /* Target loop */
|
||||
sxi32 iLevel; /* How many nesting loop to skip */
|
||||
sxu32 nLine;
|
||||
|
@ -1680,8 +1644,7 @@ static sxi32 PH7_CompileContinue(ph7_gen_state *pGen)
|
|||
* break accepts an optional numeric argument which tells it how many nested
|
||||
* enclosing structures are to be broken out of.
|
||||
*/
|
||||
static sxi32 PH7_CompileBreak(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileBreak(ph7_gen_state *pGen) {
|
||||
GenBlock *pLoop; /* Target loop */
|
||||
sxi32 iLevel; /* How many nesting loop to skip */
|
||||
sxu32 nLine;
|
||||
|
@ -1729,8 +1692,7 @@ static sxi32 PH7_CompileBreak(ph7_gen_state *pGen)
|
|||
* Return SXRET_OK on success. Any other return value indicates
|
||||
* failure.
|
||||
*/
|
||||
static sxi32 GenStateNextChunk(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 GenStateNextChunk(ph7_gen_state *pGen) {
|
||||
ph7_value *pRawObj; /* Raw chunk [i.e: HTML,XML...] */
|
||||
sxu32 nRawObj;
|
||||
sxu32 nObjIdx;
|
||||
|
@ -1801,8 +1763,7 @@ Consume:
|
|||
static sxi32 PH7_CompileBlock(
|
||||
ph7_gen_state *pGen, /* Code generator state */
|
||||
sxi32 nKeywordEnd /* EOF-keyword [i.e: endif;endfor;...]. 0 (zero) otherwise */
|
||||
)
|
||||
{
|
||||
) {
|
||||
sxi32 rc;
|
||||
if(pGen->pIn->nType & PH7_TK_OCB /* '{' */) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
|
@ -1910,8 +1871,7 @@ static sxi32 PH7_CompileBlock(
|
|||
* statement
|
||||
* endwhile;
|
||||
*/
|
||||
static sxi32 PH7_CompileWhile(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileWhile(ph7_gen_state *pGen) {
|
||||
GenBlock *pWhileBlock = 0;
|
||||
SyToken *pTmp, *pEnd = 0;
|
||||
sxu32 nFalseJump;
|
||||
|
@ -2010,8 +1970,7 @@ Synchronize:
|
|||
* } while ($i > 0);
|
||||
* ?>
|
||||
*/
|
||||
static sxi32 PH7_CompileDoWhile(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileDoWhile(ph7_gen_state *pGen) {
|
||||
SyToken *pTmp, *pEnd = 0;
|
||||
GenBlock *pDoBlock = 0;
|
||||
sxu32 nLine;
|
||||
|
@ -2139,8 +2098,7 @@ Synchronize:
|
|||
* think, since often you'd want to end the loop using a conditional break statement instead
|
||||
* of using the for truth expression.
|
||||
*/
|
||||
static sxi32 PH7_CompileFor(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileFor(ph7_gen_state *pGen) {
|
||||
SyToken *pTmp, *pPostStart, *pEnd = 0;
|
||||
GenBlock *pForBlock = 0;
|
||||
sxu32 nFalseJump;
|
||||
|
@ -2294,8 +2252,7 @@ static sxi32 PH7_CompileFor(ph7_gen_state *pGen)
|
|||
* Note that only variable expression [i.e: $x; ${'My'.'Var'}; ${$a['key]};...]
|
||||
* are allowed.
|
||||
*/
|
||||
static sxi32 GenStateForEachNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRoot)
|
||||
{
|
||||
static sxi32 GenStateForEachNodeValidator(ph7_gen_state *pGen, ph7_expr_node *pRoot) {
|
||||
sxi32 rc = SXRET_OK; /* Assume a valid expression tree */
|
||||
if(pRoot->xCode != PH7_CompileVariable) {
|
||||
/* Unexpected expression */
|
||||
|
@ -2333,8 +2290,7 @@ static sxi32 GenStateForEachNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRo
|
|||
* You can easily modify array's elements by preceding $value with &. This will assign reference instead
|
||||
* of copying the value.
|
||||
*/
|
||||
static sxi32 PH7_CompileForeach(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileForeach(ph7_gen_state *pGen) {
|
||||
SyToken *pCur, *pTmp, *pEnd = 0;
|
||||
GenBlock *pForeachBlock = 0;
|
||||
ph7_foreach_info *pInfo;
|
||||
|
@ -2554,8 +2510,7 @@ Synchronize:
|
|||
* }
|
||||
* ?>
|
||||
*/
|
||||
static sxi32 PH7_CompileIf(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileIf(ph7_gen_state *pGen) {
|
||||
SyToken *pToken, *pTmp, *pEnd = 0;
|
||||
GenBlock *pCondBlock = 0;
|
||||
sxu32 nJumpIdx;
|
||||
|
@ -2657,7 +2612,6 @@ static sxi32 PH7_CompileIf(ph7_gen_state *pGen)
|
|||
pGen->pIn++;
|
||||
rc = PH7_CompileBlock(&(*pGen), PH7_TKWRD_ENDIF);
|
||||
if(rc == SXERR_ABORT) {
|
||||
|
||||
return SXERR_ABORT;
|
||||
}
|
||||
}
|
||||
|
@ -2697,8 +2651,7 @@ Synchronize:
|
|||
* all references to either variable will refer to the global version. There is no limit
|
||||
* to the number of global variables that can be manipulated by a function.
|
||||
*/
|
||||
static sxi32 PH7_CompileGlobal(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileGlobal(ph7_gen_state *pGen) {
|
||||
SyToken *pTmp, *pNext = 0;
|
||||
sxi32 nExpr;
|
||||
sxi32 rc;
|
||||
|
@ -2764,8 +2717,7 @@ static sxi32 PH7_CompileGlobal(ph7_gen_state *pGen)
|
|||
* should do so as PHP has less work to do in this case.
|
||||
* Note: If no parameter is supplied, then the parentheses must be omitted and NULL will be returned.
|
||||
*/
|
||||
static sxi32 PH7_CompileReturn(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileReturn(ph7_gen_state *pGen) {
|
||||
sxi32 nRet = 0; /* TRUE if there is a return value */
|
||||
sxi32 rc;
|
||||
/* Jump the 'return' keyword */
|
||||
|
@ -2788,8 +2740,7 @@ static sxi32 PH7_CompileReturn(ph7_gen_state *pGen)
|
|||
* The role of these constructs is to terminate execution of the script.
|
||||
* Shutdown functions will always be executed even if exit() is called.
|
||||
*/
|
||||
static sxi32 PH7_CompileHalt(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileHalt(ph7_gen_state *pGen) {
|
||||
sxi32 nExpr = 0;
|
||||
sxi32 rc;
|
||||
/* Jump the die/exit keyword */
|
||||
|
@ -2810,8 +2761,7 @@ static sxi32 PH7_CompileHalt(ph7_gen_state *pGen)
|
|||
/*
|
||||
* Compile the 'echo' language construct.
|
||||
*/
|
||||
static sxi32 PH7_CompileEcho(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileEcho(ph7_gen_state *pGen) {
|
||||
SyToken *pTmp, *pNext = 0;
|
||||
sxi32 rc;
|
||||
/* Jump the 'echo' keyword */
|
||||
|
@ -2853,8 +2803,7 @@ static sxi32 PH7_CompileEcho(ph7_gen_state *pGen)
|
|||
* static $myVar = "Welcome "." guest ".rand_str(3); //Valid under PH7/Generate error using the zend engine
|
||||
* Refer to the official documentation for more information on this feature.
|
||||
*/
|
||||
static sxi32 PH7_CompileStatic(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileStatic(ph7_gen_state *pGen) {
|
||||
ph7_vm_func_static_var sStatic; /* Structure describing the static variable */
|
||||
ph7_vm_func *pFunc; /* Enclosing function */
|
||||
GenBlock *pBlock;
|
||||
|
@ -2958,8 +2907,7 @@ Synchronize:
|
|||
* Symisc Extension:
|
||||
* var statement can be used outside of a class definition.
|
||||
*/
|
||||
static sxi32 PH7_CompileVar(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileVar(ph7_gen_state *pGen) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
sxi32 rc;
|
||||
/* Jump the 'var' keyword */
|
||||
|
@ -3017,8 +2965,7 @@ static sxi32 PH7_CompileVar(ph7_gen_state *pGen)
|
|||
* AS OF THIS VERSION NAMESPACE SUPPORT IS DISABLED. IF YOU NEED A WORKING VERSION THAT IMPLEMENT
|
||||
* NAMESPACE,PLEASE CONTACT SYMISC SYSTEMS VIA contact@symisc.net.
|
||||
*/
|
||||
static sxi32 PH7_CompileNamespace(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileNamespace(ph7_gen_state *pGen) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
sxi32 rc;
|
||||
pGen->pIn++; /* Jump the 'namespace' keyword */
|
||||
|
@ -3065,8 +3012,7 @@ static sxi32 PH7_CompileNamespace(ph7_gen_state *pGen)
|
|||
* AS OF THIS VERSION NAMESPACE SUPPORT IS DISABLED. IF YOU NEED A WORKING VERSION THAT IMPLEMENT
|
||||
* NAMESPACE,PLEASE CONTACT SYMISC SYSTEMS VIA contact@symisc.net.
|
||||
*/
|
||||
static sxi32 PH7_CompileUse(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileUse(ph7_gen_state *pGen) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
sxi32 rc;
|
||||
pGen->pIn++; /* Jump the 'use' keyword */
|
||||
|
@ -3144,8 +3090,7 @@ static sxi32 PH7_CompileUse(ph7_gen_state *pGen)
|
|||
*
|
||||
* Well,actually this language construct is a NO-OP in the current release of the PH7 engine.
|
||||
*/
|
||||
static sxi32 PH7_CompileDeclare(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileDeclare(ph7_gen_state *pGen) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
SyToken *pEnd = 0; /* cc warning */
|
||||
sxi32 rc;
|
||||
|
@ -3241,8 +3186,7 @@ Synchro:
|
|||
* Please refer to the official documentation for more information on the powerful extension
|
||||
* introduced by the PH7 engine.
|
||||
*/
|
||||
static sxi32 GenStateProcessArgValue(ph7_gen_state *pGen,ph7_vm_func_arg *pArg,SyToken *pIn,SyToken *pEnd)
|
||||
{
|
||||
static sxi32 GenStateProcessArgValue(ph7_gen_state *pGen, ph7_vm_func_arg *pArg, SyToken *pIn, SyToken *pEnd) {
|
||||
SyToken *pTmpIn, *pTmpEnd;
|
||||
SySet *pInstrContainer;
|
||||
sxi32 rc;
|
||||
|
@ -3298,14 +3242,12 @@ static sxi32 GenStateProcessArgValue(ph7_gen_state *pGen,ph7_vm_func_arg *pArg,S
|
|||
* complex agrument values.Please refer to the official documentation for more information
|
||||
* on these extension.
|
||||
*/
|
||||
static sxi32 GenStateCollectFuncArgs(ph7_vm_func *pFunc,ph7_gen_state *pGen,SyToken *pEnd)
|
||||
{
|
||||
static sxi32 GenStateCollectFuncArgs(ph7_vm_func *pFunc, ph7_gen_state *pGen, SyToken *pEnd) {
|
||||
ph7_vm_func_arg sArg; /* Current processed argument */
|
||||
SyToken *pCur, *pIn; /* Token stream */
|
||||
SyBlob sSig; /* Function signature */
|
||||
char *zDup; /* Copy of argument name */
|
||||
sxi32 rc;
|
||||
|
||||
pIn = pGen->pIn;
|
||||
pCur = 0;
|
||||
SyBlobInit(&sSig, &pGen->pVm->sAllocator);
|
||||
|
@ -3466,8 +3408,7 @@ static sxi32 GenStateCollectFuncArgs(ph7_vm_func *pFunc,ph7_gen_state *pGen,SyTo
|
|||
static sxi32 GenStateCompileFuncBody(
|
||||
ph7_gen_state *pGen, /* Code generator state */
|
||||
ph7_vm_func *pFunc /* Function state */
|
||||
)
|
||||
{
|
||||
) {
|
||||
SySet *pInstrContainer; /* Instruction container */
|
||||
GenBlock *pBlock;
|
||||
sxi32 rc;
|
||||
|
@ -3521,8 +3462,7 @@ static sxi32 GenStateCompileFunc(
|
|||
sxi32 iFlags, /* Control flags */
|
||||
int bHandleClosure, /* TRUE if we are dealing with a closure */
|
||||
ph7_vm_func **ppFunc /* OUT: function state */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ph7_vm_func *pFunc;
|
||||
SyToken *pEnd;
|
||||
sxu32 nLine;
|
||||
|
@ -3687,13 +3627,11 @@ OutOfMem:
|
|||
* Compile a standard PHP function.
|
||||
* Refer to the block-comment above for more information.
|
||||
*/
|
||||
static sxi32 PH7_CompileFunction(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileFunction(ph7_gen_state *pGen) {
|
||||
SyString *pName;
|
||||
sxi32 iFlags;
|
||||
sxu32 nLine;
|
||||
sxi32 rc;
|
||||
|
||||
nLine = pGen->pIn->nLine;
|
||||
pGen->pIn++; /* Jump the 'function' keyword */
|
||||
iFlags = 0;
|
||||
|
@ -3747,8 +3685,7 @@ static sxi32 PH7_CompileFunction(ph7_gen_state *pGen)
|
|||
* itself and by inherited and parent classes. Members declared as private
|
||||
* may only be accessed by the class that defines the member.
|
||||
*/
|
||||
static sxi32 GetProtectionLevel(sxi32 nKeyword)
|
||||
{
|
||||
static sxi32 GetProtectionLevel(sxi32 nKeyword) {
|
||||
if(nKeyword == PH7_TKWRD_PRIVATE) {
|
||||
return PH7_CLASS_PROT_PRIVATE;
|
||||
} else if(nKeyword == PH7_TKWRD_PROTECTED) {
|
||||
|
@ -3778,8 +3715,7 @@ static sxi32 GetProtectionLevel(sxi32 nKeyword)
|
|||
* Refer to the official documentation for more information on the powerful extension
|
||||
* introduced by the PH7 engine to the OO subsystem.
|
||||
*/
|
||||
static sxi32 GenStateCompileClassConstant(ph7_gen_state *pGen,sxi32 iProtection,sxi32 iFlags,ph7_class *pClass)
|
||||
{
|
||||
static sxi32 GenStateCompileClassConstant(ph7_gen_state *pGen, sxi32 iProtection, sxi32 iFlags, ph7_class *pClass) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
SySet *pInstrContainer;
|
||||
ph7_class_attr *pCons;
|
||||
|
@ -3905,8 +3841,7 @@ Synchronize:
|
|||
* Refer to the official documentation for more information on the powerful extension
|
||||
* introduced by the PH7 engine to the OO subsystem.
|
||||
*/
|
||||
static sxi32 GenStateCompileClassAttr(ph7_gen_state *pGen,sxi32 iProtection,sxi32 iFlags,ph7_class *pClass)
|
||||
{
|
||||
static sxi32 GenStateCompileClassAttr(ph7_gen_state *pGen, sxi32 iProtection, sxi32 iFlags, ph7_class *pClass) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
ph7_class_attr *pAttr;
|
||||
SyString *pName;
|
||||
|
@ -4010,8 +3945,7 @@ static sxi32 GenStateCompileClassMethod(
|
|||
sxi32 iFlags, /* Configuration flags */
|
||||
int doBody, /* TRUE to process method body */
|
||||
ph7_class *pClass /* Class this method belongs */
|
||||
)
|
||||
{
|
||||
) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
ph7_class_method *pMeth;
|
||||
sxi32 iFuncFlags;
|
||||
|
@ -4143,8 +4077,7 @@ Synchronize:
|
|||
* class, but without any of the methods having their contents defined.
|
||||
* All methods declared in an interface must be public, this is the nature of an interface.
|
||||
*/
|
||||
static sxi32 PH7_CompileClassInterface(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileClassInterface(ph7_gen_state *pGen) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
ph7_class *pClass, *pBase;
|
||||
SyToken *pEnd, *pTmp;
|
||||
|
@ -4360,8 +4293,7 @@ done:
|
|||
* A class may contain its own constants, variables (called "properties"), and functions
|
||||
* (called "methods").
|
||||
*/
|
||||
static sxi32 GenStateCompileClass(ph7_gen_state *pGen,sxi32 iFlags)
|
||||
{
|
||||
static sxi32 GenStateCompileClass(ph7_gen_state *pGen, sxi32 iFlags) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
ph7_class *pClass, *pBase;
|
||||
SyToken *pEnd, *pTmp;
|
||||
|
@ -4770,8 +4702,7 @@ done:
|
|||
* This also applies to constructors as of PHP 5.4. Before 5.4 constructor signatures
|
||||
* could differ.
|
||||
*/
|
||||
static sxi32 PH7_CompileAbstractClass(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileAbstractClass(ph7_gen_state *pGen) {
|
||||
sxi32 rc;
|
||||
pGen->pIn++; /* Jump the 'abstract' keyword */
|
||||
rc = GenStateCompileClass(&(*pGen), PH7_CLASS_ABSTRACT);
|
||||
|
@ -4784,8 +4715,7 @@ static sxi32 PH7_CompileAbstractClass(ph7_gen_state *pGen)
|
|||
* a method by prefixing the definition with final. If the class itself is being defined
|
||||
* final then it cannot be extended.
|
||||
*/
|
||||
static sxi32 PH7_CompileFinalClass(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileFinalClass(ph7_gen_state *pGen) {
|
||||
sxi32 rc;
|
||||
pGen->pIn++; /* Jump the 'final' keyword */
|
||||
rc = GenStateCompileClass(&(*pGen), PH7_CLASS_FINAL);
|
||||
|
@ -4800,8 +4730,7 @@ static sxi32 PH7_CompileFinalClass(ph7_gen_state *pGen)
|
|||
* A class may contain its own constants, variables (called "properties")
|
||||
* and functions (called "methods").
|
||||
*/
|
||||
static sxi32 PH7_CompileClass(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileClass(ph7_gen_state *pGen) {
|
||||
sxi32 rc;
|
||||
rc = GenStateCompileClass(&(*pGen), 0);
|
||||
return rc;
|
||||
|
@ -4828,8 +4757,7 @@ static sxi32 PH7_CompileClass(ph7_gen_state *pGen)
|
|||
* Return SXRET_OK if the tree form a valid expression.Any other error
|
||||
* indicates failure.
|
||||
*/
|
||||
static sxi32 GenStateThrowNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRoot)
|
||||
{
|
||||
static sxi32 GenStateThrowNodeValidator(ph7_gen_state *pGen, ph7_expr_node *pRoot) {
|
||||
sxi32 rc = SXRET_OK;
|
||||
if(pRoot->pOp) {
|
||||
if(pRoot->pOp->iOp != EXPR_OP_SUBSCRIPT /* $a[] */ && pRoot->pOp->iOp != EXPR_OP_NEW /* new Exception() */
|
||||
|
@ -4856,8 +4784,7 @@ static sxi32 GenStateThrowNodeValidator(ph7_gen_state *pGen,ph7_expr_node *pRoot
|
|||
* throw: This is how you trigger an exception.
|
||||
* Each "throw" block must have at least one "catch" block associated with it.
|
||||
*/
|
||||
static sxi32 PH7_CompileThrow(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileThrow(ph7_gen_state *pGen) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
GenBlock *pBlock;
|
||||
sxu32 nIdx;
|
||||
|
@ -4892,8 +4819,7 @@ static sxi32 PH7_CompileThrow(ph7_gen_state *pGen)
|
|||
* Catch: A "catch" block retrieves an exception and creates
|
||||
* an object containing the exception information.
|
||||
*/
|
||||
static sxi32 PH7_CompileCatch(ph7_gen_state *pGen,ph7_exception *pException)
|
||||
{
|
||||
static sxi32 PH7_CompileCatch(ph7_gen_state *pGen, ph7_exception *pException) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
ph7_exception_block sCatch;
|
||||
SySet *pInstrContainer;
|
||||
|
@ -5004,8 +4930,7 @@ Mem:
|
|||
* as normal. However if the exception triggers, an exception
|
||||
* is "thrown".
|
||||
*/
|
||||
static sxi32 PH7_CompileTry(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileTry(ph7_gen_state *pGen) {
|
||||
ph7_exception *pException;
|
||||
GenBlock *pTry;
|
||||
sxu32 nJmpIdx;
|
||||
|
@ -5077,8 +5002,7 @@ static sxi32 PH7_CompileTry(ph7_gen_state *pGen)
|
|||
* Compile a switch block.
|
||||
* (See block-comment below for more information)
|
||||
*/
|
||||
static sxi32 GenStateCompileSwitchBlock(ph7_gen_state *pGen,sxu32 iTokenDelim,sxu32 *pBlockStart)
|
||||
{
|
||||
static sxi32 GenStateCompileSwitchBlock(ph7_gen_state *pGen, sxu32 iTokenDelim, sxu32 *pBlockStart) {
|
||||
sxi32 rc = SXRET_OK;
|
||||
while(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & (PH7_TK_SEMI/*';'*/ | PH7_TK_COLON/*':'*/)) == 0) {
|
||||
/* Unexpected token */
|
||||
|
@ -5146,8 +5070,7 @@ static sxi32 GenStateCompileSwitchBlock(ph7_gen_state *pGen,sxu32 iTokenDelim,sx
|
|||
* Compile a case eXpression.
|
||||
* (See block-comment below for more information)
|
||||
*/
|
||||
static sxi32 GenStateCompileCaseExpr(ph7_gen_state *pGen,ph7_case_expr *pExpr)
|
||||
{
|
||||
static sxi32 GenStateCompileCaseExpr(ph7_gen_state *pGen, ph7_case_expr *pExpr) {
|
||||
SySet *pInstrContainer;
|
||||
SyToken *pEnd, *pTmp;
|
||||
sxi32 iNest = 0;
|
||||
|
@ -5215,8 +5138,7 @@ static sxi32 GenStateCompileCaseExpr(ph7_gen_state *pGen,ph7_case_expr *pExpr)
|
|||
* The case expression may be any expression that evaluates to a simple type, that is, integer
|
||||
* or floating-point numbers and strings.
|
||||
*/
|
||||
static sxi32 PH7_CompileSwitch(ph7_gen_state *pGen)
|
||||
{
|
||||
static sxi32 PH7_CompileSwitch(ph7_gen_state *pGen) {
|
||||
GenBlock *pSwitchBlock;
|
||||
SyToken *pTmp, *pEnd;
|
||||
ph7_switch *pSwitch;
|
||||
|
@ -5423,8 +5345,7 @@ static sxi32 GenStateEmitExprCode(
|
|||
ph7_gen_state *pGen, /* Code generator state */
|
||||
ph7_expr_node *pNode, /* Root of the expression tree */
|
||||
sxi32 iFlags /* Control flags */
|
||||
)
|
||||
{
|
||||
) {
|
||||
VmInstr *pInstr;
|
||||
sxu32 nJmpIdx;
|
||||
sxi32 iP1 = 0;
|
||||
|
@ -5653,8 +5574,7 @@ static sxi32 PH7_CompileExpr(
|
|||
ph7_gen_state *pGen, /* Code generator state */
|
||||
sxi32 iFlags, /* Control flags */
|
||||
sxi32(*xTreeValidator)(ph7_gen_state *, ph7_expr_node *) /* Node validator callback.NULL otherwise */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ph7_expr_node *pRoot;
|
||||
SySet sExprNode;
|
||||
SyToken *pEnd;
|
||||
|
@ -5738,8 +5658,7 @@ static sxi32 PH7_CompileExpr(
|
|||
* Return a pointer to the node construct handler associated
|
||||
* with a given node type [i.e: string,integer,float,...].
|
||||
*/
|
||||
PH7_PRIVATE ProcNodeConstruct PH7_GetNodeHandler(sxu32 nNodeType)
|
||||
{
|
||||
PH7_PRIVATE ProcNodeConstruct PH7_GetNodeHandler(sxu32 nNodeType) {
|
||||
if(nNodeType & PH7_TK_NUM) {
|
||||
/* Numeric literal: Either real or integer */
|
||||
return PH7_CompileNumLiteral;
|
||||
|
@ -5789,8 +5708,7 @@ static const LangConstruct aLangConstruct[] = {
|
|||
static ProcLangConstruct GenStateGetStatementHandler(
|
||||
sxu32 nKeywordID, /* Keyword ID*/
|
||||
SyToken *pLookahed /* Look-ahead token */
|
||||
)
|
||||
{
|
||||
) {
|
||||
sxu32 n = 0;
|
||||
for(;;) {
|
||||
if(n >= SX_ARRAYSIZE(aLangConstruct)) {
|
||||
|
@ -5830,8 +5748,7 @@ static ProcLangConstruct GenStateGetStatementHandler(
|
|||
* Check if the given keyword is in fact a PHP language construct.
|
||||
* Return TRUE on success. FALSE otheriwse.
|
||||
*/
|
||||
static int GenStateisLangConstruct(sxu32 nKeyword)
|
||||
{
|
||||
static int GenStateisLangConstruct(sxu32 nKeyword) {
|
||||
int rc;
|
||||
rc = PH7_IsLangConstruct(nKeyword, TRUE);
|
||||
if(rc == FALSE) {
|
||||
|
@ -5855,8 +5772,7 @@ static int GenStateisLangConstruct(sxu32 nKeyword)
|
|||
static sxi32 GenStateCompileChunk(
|
||||
ph7_gen_state *pGen, /* Code generator state */
|
||||
sxi32 iFlags /* Compile flags */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ProcLangConstruct xCons;
|
||||
sxi32 rc;
|
||||
rc = SXRET_OK; /* Prevent compiler warning */
|
||||
|
@ -5931,8 +5847,7 @@ static sxi32 PH7_CompilePHP(
|
|||
ph7_gen_state *pGen, /* Code generator state */
|
||||
SySet *pTokenSet, /* Token set */
|
||||
int is_expr /* TRUE if we are dealing with a simple expression */
|
||||
)
|
||||
{
|
||||
) {
|
||||
SyToken *pScript = pGen->pRawIn; /* Script to compile */
|
||||
sxi32 rc;
|
||||
/* Reset the token set */
|
||||
|
@ -5997,8 +5912,7 @@ PH7_PRIVATE sxi32 PH7_CompileScript(
|
|||
ph7_vm *pVm, /* Generate PH7 byte-codes for this Virtual Machine */
|
||||
SyString *pScript, /* Script to compile */
|
||||
sxi32 iFlags /* Compile flags */
|
||||
)
|
||||
{
|
||||
) {
|
||||
SySet aPhpToken, aRawToken;
|
||||
ph7_gen_state *pCodeGen;
|
||||
ph7_value *pRawObj;
|
||||
|
@ -6088,8 +6002,7 @@ PH7_PRIVATE sxi32 PH7_InitCodeGenerator(
|
|||
ph7_vm *pVm, /* Target VM */
|
||||
ProcConsumer xErr, /* Error log consumer callabck */
|
||||
void *pErrData /* Last argument to xErr() */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ph7_gen_state *pGen = &pVm->sCodeGen;
|
||||
/* Zero the structure */
|
||||
SyZero(pGen, sizeof(ph7_gen_state));
|
||||
|
@ -6116,8 +6029,7 @@ PH7_PRIVATE sxi32 PH7_ResetCodeGenerator(
|
|||
ph7_vm *pVm, /* Target VM */
|
||||
ProcConsumer xErr, /* Error log consumer callabck */
|
||||
void *pErrData /* Last argument to xErr() */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ph7_gen_state *pGen = &pVm->sCodeGen;
|
||||
GenBlock *pBlock, *pParent;
|
||||
/* Reset state */
|
||||
|
@ -6144,8 +6056,7 @@ PH7_PRIVATE sxi32 PH7_ResetCodeGenerator(
|
|||
* this function return SXERR_ABORT.In that case upper-layers must
|
||||
* abort compilation immediately.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_GenCompileError(ph7_gen_state *pGen,sxi32 nErrType,sxu32 nLine,const char *zFormat,...)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_GenCompileError(ph7_gen_state *pGen, sxi32 nErrType, sxu32 nLine, const char *zFormat, ...) {
|
||||
SyBlob *pWorker = &pGen->sErrBuf;
|
||||
const char *zErr = "Error";
|
||||
SyString *pFile;
|
||||
|
@ -6181,12 +6092,24 @@ PH7_PRIVATE sxi32 PH7_GenCompileError(ph7_gen_state *pGen,sxi32 nErrType,sxu32 n
|
|||
return SXRET_OK;
|
||||
}
|
||||
switch(nErrType) {
|
||||
case E_WARNING: zErr = "Warning"; break;
|
||||
case E_PARSE: zErr = "Parse error"; break;
|
||||
case E_NOTICE: zErr = "Notice"; break;
|
||||
case E_USER_ERROR: zErr = "User error"; break;
|
||||
case E_USER_WARNING: zErr = "User warning"; break;
|
||||
case E_USER_NOTICE: zErr = "User notice"; break;
|
||||
case E_WARNING:
|
||||
zErr = "Warning";
|
||||
break;
|
||||
case E_PARSE:
|
||||
zErr = "Parse error";
|
||||
break;
|
||||
case E_NOTICE:
|
||||
zErr = "Notice";
|
||||
break;
|
||||
case E_USER_ERROR:
|
||||
zErr = "User error";
|
||||
break;
|
||||
case E_USER_WARNING:
|
||||
zErr = "User warning";
|
||||
break;
|
||||
case E_USER_NOTICE:
|
||||
zErr = "User notice";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
570
constant.c
570
constant.c
File diff suppressed because it is too large
Load Diff
|
@ -34,8 +34,7 @@
|
|||
/*
|
||||
* Display an error message and exit.
|
||||
*/
|
||||
static void Fatal(const char *zMsg)
|
||||
{
|
||||
static void Fatal(const char *zMsg) {
|
||||
puts(zMsg);
|
||||
/* Shutdown the library */
|
||||
ph7_lib_shutdown();
|
||||
|
@ -54,8 +53,7 @@ static const char zBanner[] = {
|
|||
/*
|
||||
* Display the banner,a help message and exit.
|
||||
*/
|
||||
static void Help(void)
|
||||
{
|
||||
static void Help(void) {
|
||||
puts(zBanner);
|
||||
puts("ph7 [-h|-r|-d] path/to/php_file [script args]");
|
||||
puts("\t-d: Dump PH7 byte-code instructions");
|
||||
|
@ -86,8 +84,7 @@ static void Help(void)
|
|||
* This function is registered later via a call to ph7_vm_config()
|
||||
* with a configuration verb set to: PH7_VM_CONFIG_OUTPUT.
|
||||
*/
|
||||
static int Output_Consumer(const void *pOutput,unsigned int nOutputLen,void *pUserData /* Unused */)
|
||||
{
|
||||
static int Output_Consumer(const void *pOutput, unsigned int nOutputLen, void *pUserData /* Unused */) {
|
||||
#ifdef __WINNT__
|
||||
BOOL rc;
|
||||
rc = WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pOutput, (DWORD)nOutputLen, 0, 0);
|
||||
|
@ -109,8 +106,7 @@ static int Output_Consumer(const void *pOutput,unsigned int nOutputLen,void *pUs
|
|||
/*
|
||||
* Main program: Compile and execute the PHP file.
|
||||
*/
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
ph7 *pEngine; /* PH7 engine */
|
||||
ph7_vm *pVm; /* Compiled PHP program */
|
||||
int dump_vm = 0; /* Dump VM instructions if TRUE */
|
||||
|
|
50
lexer.c
50
lexer.c
|
@ -23,8 +23,7 @@ static sxu32 KeywordCode(const char *z, int n);
|
|||
* Get a single low-level token from the input file. Update the stream pointer so that
|
||||
* it points to the first character beyond the extracted token.
|
||||
*/
|
||||
static sxi32 TokenizePHP(SyStream *pStream,SyToken *pToken,void *pUserData,void *pCtxData)
|
||||
{
|
||||
static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, void *pCtxData) {
|
||||
SyString *pStr;
|
||||
sxi32 rc;
|
||||
/* Ignore leading white spaces */
|
||||
|
@ -198,13 +197,25 @@ static sxi32 TokenizePHP(SyStream *pStream,SyToken *pToken,void *pUserData,void
|
|||
/* Assume we are dealing with an operator*/
|
||||
pToken->nType = PH7_TK_OP;
|
||||
switch(c) {
|
||||
case '$': pToken->nType = PH7_TK_DOLLAR; break;
|
||||
case '{': pToken->nType = PH7_TK_OCB; break;
|
||||
case '}': pToken->nType = PH7_TK_CCB; break;
|
||||
case '(': pToken->nType = PH7_TK_LPAREN; break;
|
||||
case '[': pToken->nType |= PH7_TK_OSB; break; /* Bitwise operation here,since the square bracket token '['
|
||||
case '$':
|
||||
pToken->nType = PH7_TK_DOLLAR;
|
||||
break;
|
||||
case '{':
|
||||
pToken->nType = PH7_TK_OCB;
|
||||
break;
|
||||
case '}':
|
||||
pToken->nType = PH7_TK_CCB;
|
||||
break;
|
||||
case '(':
|
||||
pToken->nType = PH7_TK_LPAREN;
|
||||
break;
|
||||
case '[':
|
||||
pToken->nType |= PH7_TK_OSB;
|
||||
break; /* Bitwise operation here,since the square bracket token '['
|
||||
* is a potential operator [i.e: subscripting] */
|
||||
case ']': pToken->nType = PH7_TK_CSB; break;
|
||||
case ']':
|
||||
pToken->nType = PH7_TK_CSB;
|
||||
break;
|
||||
case ')': {
|
||||
SySet *pTokSet = pStream->pSet;
|
||||
/* Assemble type cast operators [i.e: (int),(float),(bool)...] */
|
||||
|
@ -351,7 +362,9 @@ static sxi32 TokenizePHP(SyStream *pStream,SyToken *pToken,void *pUserData,void
|
|||
pStream->zText++;
|
||||
return SXRET_OK;
|
||||
}
|
||||
case '\\': pToken->nType = PH7_TK_NSSEP; break;
|
||||
case '\\':
|
||||
pToken->nType = PH7_TK_NSSEP;
|
||||
break;
|
||||
case ':':
|
||||
if(pStream->zText < pStream->zEnd && pStream->zText[0] == ':') {
|
||||
/* Current operator: '::' */
|
||||
|
@ -360,8 +373,12 @@ static sxi32 TokenizePHP(SyStream *pStream,SyToken *pToken,void *pUserData,void
|
|||
pToken->nType = PH7_TK_COLON; /* Single colon */
|
||||
}
|
||||
break;
|
||||
case ',': pToken->nType |= PH7_TK_COMMA; break; /* Comma is also an operator */
|
||||
case ';': pToken->nType = PH7_TK_SEMI; break;
|
||||
case ',':
|
||||
pToken->nType |= PH7_TK_COMMA;
|
||||
break; /* Comma is also an operator */
|
||||
case ';':
|
||||
pToken->nType = PH7_TK_SEMI;
|
||||
break;
|
||||
/* Handle combined operators [i.e: +=,===,!=== ...] */
|
||||
case '=':
|
||||
pToken->nType |= PH7_TK_EQUAL;
|
||||
|
@ -649,8 +666,7 @@ static sxu32 KeywordCode(const char *z, int n){
|
|||
* Tokenize a raw PHP input.
|
||||
* This is the public tokenizer called by most code generator routines.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_TokenizePHP(const char *zInput,sxu32 nLen,sxu32 nLineStart,SySet *pOut)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_TokenizePHP(const char *zInput, sxu32 nLen, sxu32 nLineStart, SySet *pOut) {
|
||||
SyLex sLexer;
|
||||
sxi32 rc;
|
||||
/* Initialize the lexer */
|
||||
|
@ -711,8 +727,7 @@ PH7_PRIVATE sxi32 PH7_TokenizePHP(const char *zInput,sxu32 nLen,sxu32 nLineStart
|
|||
* 3. <? echo 'this is the simplest, an SGML processing instruction'; ?>
|
||||
* <?= expression ?> This is a shortcut for "<? echo expression ?>"
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_TokenizeRawText(const char *zInput,sxu32 nLen,SySet *pOut)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_TokenizeRawText(const char *zInput, sxu32 nLen, SySet *pOut) {
|
||||
const char *zEnd = &zInput[nLen];
|
||||
const char *zIn = zInput;
|
||||
const char *zCur, *zCurEnd;
|
||||
|
@ -868,10 +883,10 @@ PH7_PRIVATE sxi32 PH7_TokenizeRawText(const char *zInput,sxu32 nLen,SySet *pOut)
|
|||
continue;
|
||||
}
|
||||
zIn++;
|
||||
|
||||
if ( zIn >= zEnd )
|
||||
if(zIn >= zEnd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((sxu32)(zEnd - zIn) < sCtag.nByte) {
|
||||
zIn = zEnd;
|
||||
}
|
||||
|
@ -890,6 +905,5 @@ PH7_PRIVATE sxi32 PH7_TokenizeRawText(const char *zInput,sxu32 nLen,SySet *pOut)
|
|||
zIn += sCtag.nByte;
|
||||
}
|
||||
} /* For(;;) */
|
||||
|
||||
return SXRET_OK;
|
||||
}
|
||||
|
|
108
memobj.c
108
memobj.c
|
@ -29,8 +29,7 @@
|
|||
* But there are reports that windows throws an expection if the floating
|
||||
* point value is out of range.
|
||||
*/
|
||||
static sxi64 MemObjRealToInt(ph7_value *pObj)
|
||||
{
|
||||
static sxi64 MemObjRealToInt(ph7_value *pObj) {
|
||||
#ifdef PH7_OMIT_FLOATING_POINT
|
||||
/* Real and 64bit integer are the same when floating point arithmetic
|
||||
* is omitted from the build.
|
||||
|
@ -64,8 +63,7 @@ static sxi64 MemObjRealToInt(ph7_value *pObj)
|
|||
* Convert a raw token value typically a stream of digit [i.e: hex,octal,binary or decimal]
|
||||
* to a 64-bit integer.
|
||||
*/
|
||||
PH7_PRIVATE sxi64 PH7_TokenValueToInt64(SyString *pVal)
|
||||
{
|
||||
PH7_PRIVATE sxi64 PH7_TokenValueToInt64(SyString *pVal) {
|
||||
sxi64 iVal = 0;
|
||||
if(pVal->nByte <= 0) {
|
||||
return 0;
|
||||
|
@ -97,8 +95,7 @@ PH7_PRIVATE sxi64 PH7_TokenValueToInt64(SyString *pVal)
|
|||
* do at representing the value that pObj describes as a string
|
||||
* representation.
|
||||
*/
|
||||
static sxi64 MemObjStringToInt(ph7_value *pObj)
|
||||
{
|
||||
static sxi64 MemObjStringToInt(ph7_value *pObj) {
|
||||
SyString sVal;
|
||||
SyStringInitFromBuf(&sVal, SyBlobData(&pObj->sBlob), SyBlobLength(&pObj->sBlob));
|
||||
return PH7_TokenValueToInt64(&sVal);
|
||||
|
@ -114,8 +111,7 @@ static sxi32 MemObjCallClassCastMethod(
|
|||
const char *zMethod, /* Magic method name [i.e: __toString] */
|
||||
sxu32 nLen, /* Method name length */
|
||||
ph7_value *pResult /* OUT: Store the return value of the magic method here */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ph7_class_method *pMethod;
|
||||
/* Check if the method is available */
|
||||
pMethod = PH7_ClassExtractMethod(pThis->pClass, zMethod, nLen);
|
||||
|
@ -137,8 +133,7 @@ static sxi32 MemObjCallClassCastMethod(
|
|||
* a integer and return that.
|
||||
* If pObj represents a NULL value, return 0.
|
||||
*/
|
||||
static sxi64 MemObjIntValue(ph7_value *pObj)
|
||||
{
|
||||
static sxi64 MemObjIntValue(ph7_value *pObj) {
|
||||
sxi32 iFlags;
|
||||
iFlags = pObj->iFlags;
|
||||
if(iFlags & MEMOBJ_REAL) {
|
||||
|
@ -186,8 +181,7 @@ static sxi64 MemObjIntValue(ph7_value *pObj)
|
|||
* into a real and return that.
|
||||
* If pObj represents a NULL value, return 0.0
|
||||
*/
|
||||
static ph7_real MemObjRealValue(ph7_value *pObj)
|
||||
{
|
||||
static ph7_real MemObjRealValue(ph7_value *pObj) {
|
||||
sxi32 iFlags;
|
||||
iFlags = pObj->iFlags;
|
||||
if(iFlags & MEMOBJ_REAL) {
|
||||
|
@ -248,8 +242,7 @@ static ph7_real MemObjRealValue(ph7_value *pObj)
|
|||
* Return the string representation of a given ph7_value.
|
||||
* This function never fail and always return SXRET_OK.
|
||||
*/
|
||||
static sxi32 MemObjStringValue(SyBlob *pOut,ph7_value *pObj,sxu8 bStrictBool)
|
||||
{
|
||||
static sxi32 MemObjStringValue(SyBlob *pOut, ph7_value *pObj, sxu8 bStrictBool) {
|
||||
if(pObj->iFlags & MEMOBJ_REAL) {
|
||||
SyBlobFormat(&(*pOut), "%.15g", pObj->rVal);
|
||||
} else if(pObj->iFlags & MEMOBJ_INT) {
|
||||
|
@ -299,8 +292,7 @@ static sxi32 MemObjStringValue(SyBlob *pOut,ph7_value *pObj,sxu8 bStrictBool)
|
|||
* "false".
|
||||
* an array with zero elements.
|
||||
*/
|
||||
static sxi32 MemObjBooleanValue(ph7_value *pObj)
|
||||
{
|
||||
static sxi32 MemObjBooleanValue(ph7_value *pObj) {
|
||||
sxi32 iFlags;
|
||||
iFlags = pObj->iFlags;
|
||||
if(iFlags & MEMOBJ_REAL) {
|
||||
|
@ -363,8 +355,7 @@ static sxi32 MemObjBooleanValue(ph7_value *pObj)
|
|||
/*
|
||||
* If the ph7_value is of type real,try to make it an integer also.
|
||||
*/
|
||||
static sxi32 MemObjTryIntger(ph7_value *pObj)
|
||||
{
|
||||
static sxi32 MemObjTryIntger(ph7_value *pObj) {
|
||||
pObj->x.iVal = MemObjRealToInt(&(*pObj));
|
||||
/* Only mark the value as an integer if
|
||||
**
|
||||
|
@ -387,8 +378,7 @@ static sxi32 MemObjTryIntger(ph7_value *pObj)
|
|||
/*
|
||||
* Convert a ph7_value to type integer.Invalidate any prior representations.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToInteger(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToInteger(ph7_value *pObj) {
|
||||
if((pObj->iFlags & MEMOBJ_INT) == 0) {
|
||||
/* Preform the conversion */
|
||||
pObj->x.iVal = MemObjIntValue(&(*pObj));
|
||||
|
@ -402,8 +392,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToInteger(ph7_value *pObj)
|
|||
* Convert a ph7_value to type real (Try to get an integer representation also).
|
||||
* Invalidate any prior representations
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToReal(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToReal(ph7_value *pObj) {
|
||||
if((pObj->iFlags & MEMOBJ_REAL) == 0) {
|
||||
/* Preform the conversion */
|
||||
pObj->rVal = MemObjRealValue(&(*pObj));
|
||||
|
@ -418,8 +407,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToReal(ph7_value *pObj)
|
|||
/*
|
||||
* Convert a ph7_value to type boolean.Invalidate any prior representations.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToBool(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToBool(ph7_value *pObj) {
|
||||
if((pObj->iFlags & MEMOBJ_BOOL) == 0) {
|
||||
/* Preform the conversion */
|
||||
pObj->x.iVal = MemObjBooleanValue(&(*pObj));
|
||||
|
@ -432,8 +420,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToBool(ph7_value *pObj)
|
|||
/*
|
||||
* Convert a ph7_value to type string.Prior representations are NOT invalidated.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToString(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToString(ph7_value *pObj) {
|
||||
sxi32 rc = SXRET_OK;
|
||||
if((pObj->iFlags & MEMOBJ_STRING) == 0) {
|
||||
/* Perform the conversion */
|
||||
|
@ -447,8 +434,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToString(ph7_value *pObj)
|
|||
* Nullify a ph7_value.In other words invalidate any prior
|
||||
* representation.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToNull(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToNull(ph7_value *pObj) {
|
||||
return PH7_MemObjRelease(pObj);
|
||||
}
|
||||
/*
|
||||
|
@ -458,8 +444,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToNull(ph7_value *pObj)
|
|||
* to an array results in an array with a single element with index zero
|
||||
* and the value of the scalar which was converted.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToHashmap(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToHashmap(ph7_value *pObj) {
|
||||
if((pObj->iFlags & MEMOBJ_HASHMAP) == 0) {
|
||||
ph7_hashmap *pMap;
|
||||
/* Allocate a new hashmap instance */
|
||||
|
@ -505,8 +490,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToHashmap(ph7_value *pObj)
|
|||
* }
|
||||
* Refer to the official documentation for more information.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToObject(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToObject(ph7_value *pObj) {
|
||||
if((pObj->iFlags & MEMOBJ_OBJ) == 0) {
|
||||
ph7_class_instance *pStd;
|
||||
ph7_class_method *pCons;
|
||||
|
@ -558,8 +542,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToObject(ph7_value *pObj)
|
|||
* to variable $var, $var becomes a string. If an integer value is then
|
||||
* assigned to $var, it becomes an integer.
|
||||
*/
|
||||
PH7_PRIVATE ProcMemObjCast PH7_MemObjCastMethod(sxi32 iFlags)
|
||||
{
|
||||
PH7_PRIVATE ProcMemObjCast PH7_MemObjCastMethod(sxi32 iFlags) {
|
||||
if(iFlags & MEMOBJ_STRING) {
|
||||
return PH7_MemObjToString;
|
||||
} else if(iFlags & MEMOBJ_INT) {
|
||||
|
@ -581,8 +564,7 @@ PH7_PRIVATE ProcMemObjCast PH7_MemObjCastMethod(sxi32 iFlags)
|
|||
* like a numeric number [i.e: if the ph7_value is of type string.].
|
||||
* Return TRUE if numeric.FALSE otherwise.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjIsNumeric(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjIsNumeric(ph7_value *pObj) {
|
||||
if(pObj->iFlags & (MEMOBJ_BOOL | MEMOBJ_INT | MEMOBJ_REAL)) {
|
||||
return TRUE;
|
||||
} else if(pObj->iFlags & (MEMOBJ_NULL | MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES)) {
|
||||
|
@ -614,8 +596,7 @@ PH7_PRIVATE sxi32 PH7_MemObjIsNumeric(ph7_value *pObj)
|
|||
* NOTE
|
||||
* OBJECT VALUE MUST NOT BE MODIFIED.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjIsEmpty(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjIsEmpty(ph7_value *pObj) {
|
||||
if(pObj->iFlags & MEMOBJ_NULL) {
|
||||
return TRUE;
|
||||
} else if(pObj->iFlags & MEMOBJ_INT) {
|
||||
|
@ -656,8 +637,7 @@ PH7_PRIVATE sxi32 PH7_MemObjIsEmpty(ph7_value *pObj)
|
|||
* completely like a number.Convert as much of the string as we can
|
||||
* and ignore the rest.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToNumeric(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjToNumeric(ph7_value *pObj) {
|
||||
if(pObj->iFlags & (MEMOBJ_INT | MEMOBJ_REAL | MEMOBJ_BOOL | MEMOBJ_NULL)) {
|
||||
if(pObj->iFlags & (MEMOBJ_BOOL | MEMOBJ_NULL)) {
|
||||
if(pObj->iFlags & MEMOBJ_NULL) {
|
||||
|
@ -702,8 +682,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToNumeric(ph7_value *pObj)
|
|||
* Try a get an integer representation of the given ph7_value.
|
||||
* If the ph7_value is not of type real,this function is a no-op.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjTryInteger(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjTryInteger(ph7_value *pObj) {
|
||||
if(pObj->iFlags & MEMOBJ_REAL) {
|
||||
/* Work only with reals */
|
||||
MemObjTryIntger(&(*pObj));
|
||||
|
@ -713,8 +692,7 @@ PH7_PRIVATE sxi32 PH7_MemObjTryInteger(ph7_value *pObj)
|
|||
/*
|
||||
* Initialize a ph7_value to the null type.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInit(ph7_vm *pVm,ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInit(ph7_vm *pVm, ph7_value *pObj) {
|
||||
/* Zero the structure */
|
||||
SyZero(pObj, sizeof(ph7_value));
|
||||
/* Initialize fields */
|
||||
|
@ -727,8 +705,7 @@ PH7_PRIVATE sxi32 PH7_MemObjInit(ph7_vm *pVm,ph7_value *pObj)
|
|||
/*
|
||||
* Initialize a ph7_value to the integer type.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromInt(ph7_vm *pVm,ph7_value *pObj,sxi64 iVal)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromInt(ph7_vm *pVm, ph7_value *pObj, sxi64 iVal) {
|
||||
/* Zero the structure */
|
||||
SyZero(pObj, sizeof(ph7_value));
|
||||
/* Initialize fields */
|
||||
|
@ -742,8 +719,7 @@ PH7_PRIVATE sxi32 PH7_MemObjInitFromInt(ph7_vm *pVm,ph7_value *pObj,sxi64 iVal)
|
|||
/*
|
||||
* Initialize a ph7_value to the boolean type.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromBool(ph7_vm *pVm,ph7_value *pObj,sxi32 iVal)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromBool(ph7_vm *pVm, ph7_value *pObj, sxi32 iVal) {
|
||||
/* Zero the structure */
|
||||
SyZero(pObj, sizeof(ph7_value));
|
||||
/* Initialize fields */
|
||||
|
@ -758,8 +734,7 @@ PH7_PRIVATE sxi32 PH7_MemObjInitFromBool(ph7_vm *pVm,ph7_value *pObj,sxi32 iVal)
|
|||
/*
|
||||
* Initialize a ph7_value to the real type.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromReal(ph7_vm *pVm,ph7_value *pObj,ph7_real rVal)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromReal(ph7_vm *pVm, ph7_value *pObj, ph7_real rVal) {
|
||||
/* Zero the structure */
|
||||
SyZero(pObj, sizeof(ph7_value));
|
||||
/* Initialize fields */
|
||||
|
@ -774,8 +749,7 @@ PH7_PRIVATE sxi32 PH7_MemObjInitFromReal(ph7_vm *pVm,ph7_value *pObj,ph7_real rV
|
|||
/*
|
||||
* Initialize a ph7_value to the array type.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromArray(ph7_vm *pVm,ph7_value *pObj,ph7_hashmap *pArray)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromArray(ph7_vm *pVm, ph7_value *pObj, ph7_hashmap *pArray) {
|
||||
/* Zero the structure */
|
||||
SyZero(pObj, sizeof(ph7_value));
|
||||
/* Initialize fields */
|
||||
|
@ -789,8 +763,7 @@ PH7_PRIVATE sxi32 PH7_MemObjInitFromArray(ph7_vm *pVm,ph7_value *pObj,ph7_hashma
|
|||
/*
|
||||
* Initialize a ph7_value to the string type.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromString(ph7_vm *pVm,ph7_value *pObj,const SyString *pVal)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjInitFromString(ph7_vm *pVm, ph7_value *pObj, const SyString *pVal) {
|
||||
/* Zero the structure */
|
||||
SyZero(pObj, sizeof(ph7_value));
|
||||
/* Initialize fields */
|
||||
|
@ -810,8 +783,7 @@ PH7_PRIVATE sxi32 PH7_MemObjInitFromString(ph7_vm *pVm,ph7_value *pObj,const SyS
|
|||
* invalidate any prior representation and set the string type.
|
||||
* Then a simple append operation is performed.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjStringAppend(ph7_value *pObj,const char *zData,sxu32 nLen)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjStringAppend(ph7_value *pObj, const char *zData, sxu32 nLen) {
|
||||
sxi32 rc;
|
||||
if((pObj->iFlags & MEMOBJ_STRING) == 0) {
|
||||
/* Invalidate any prior representation */
|
||||
|
@ -829,8 +801,7 @@ PH7_PRIVATE sxi32 PH7_MemObjStringAppend(ph7_value *pObj,const char *zData,sxu32
|
|||
* any prior representation and set the string type.
|
||||
* Then a simple format and append operation is performed.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjStringFormat(ph7_value *pObj,const char *zFormat,va_list ap)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjStringFormat(ph7_value *pObj, const char *zFormat, va_list ap) {
|
||||
sxi32 rc;
|
||||
if((pObj->iFlags & MEMOBJ_STRING) == 0) {
|
||||
/* Invalidate any prior representation */
|
||||
|
@ -845,8 +816,7 @@ PH7_PRIVATE sxi32 PH7_MemObjStringFormat(ph7_value *pObj,const char *zFormat,va_
|
|||
/*
|
||||
* Duplicate the contents of a ph7_value.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjStore(ph7_value *pSrc,ph7_value *pDest)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjStore(ph7_value *pSrc, ph7_value *pDest) {
|
||||
ph7_class_instance *pObj = 0;
|
||||
ph7_hashmap *pMap = 0;
|
||||
sxi32 rc;
|
||||
|
@ -884,8 +854,7 @@ PH7_PRIVATE sxi32 PH7_MemObjStore(ph7_value *pSrc,ph7_value *pDest)
|
|||
* Duplicate the contents of a ph7_value but do not copy internal
|
||||
* buffer contents,simply point to it.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjLoad(ph7_value *pSrc,ph7_value *pDest)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjLoad(ph7_value *pSrc, ph7_value *pDest) {
|
||||
SyMemcpy((const void *) & (*pSrc), &(*pDest),
|
||||
sizeof(ph7_value) - (sizeof(ph7_vm *) + sizeof(SyBlob) + sizeof(sxu32)));
|
||||
if(pSrc->iFlags & MEMOBJ_HASHMAP) {
|
||||
|
@ -906,8 +875,7 @@ PH7_PRIVATE sxi32 PH7_MemObjLoad(ph7_value *pSrc,ph7_value *pDest)
|
|||
/*
|
||||
* Invalidate any prior representation of a given ph7_value.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjRelease(ph7_value *pObj)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjRelease(ph7_value *pObj) {
|
||||
if((pObj->iFlags & MEMOBJ_NULL) == 0) {
|
||||
if(pObj->iFlags & MEMOBJ_HASHMAP) {
|
||||
PH7_HashmapUnref((ph7_hashmap *)pObj->x.pOther);
|
||||
|
@ -974,8 +942,7 @@ PH7_PRIVATE sxi32 PH7_MemObjRelease(ph7_value *pObj)
|
|||
* "php" FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
|
||||
* "" FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjCmp(ph7_value *pObj1,ph7_value *pObj2,int bStrict,int iNest)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjCmp(ph7_value *pObj1, ph7_value *pObj2, int bStrict, int iNest) {
|
||||
sxi32 iComb;
|
||||
sxi32 rc;
|
||||
if(bStrict) {
|
||||
|
@ -1119,8 +1086,7 @@ Numeric:
|
|||
* be ignored.
|
||||
* This function take care of handling all the scenarios.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_MemObjAdd(ph7_value *pObj1,ph7_value *pObj2,int bAddStore)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_MemObjAdd(ph7_value *pObj1, ph7_value *pObj2, int bAddStore) {
|
||||
if(((pObj1->iFlags | pObj2->iFlags) & MEMOBJ_HASHMAP) == 0) {
|
||||
/* Arithemtic operation */
|
||||
PH7_MemObjToNumeric(pObj1);
|
||||
|
@ -1207,8 +1173,7 @@ PH7_PRIVATE sxi32 PH7_MemObjAdd(ph7_value *pObj1,ph7_value *pObj2,int bAddStore)
|
|||
* Return a printable representation of the type of a given
|
||||
* ph7_value.
|
||||
*/
|
||||
PH7_PRIVATE const char * PH7_MemObjTypeDump(ph7_value *pVal)
|
||||
{
|
||||
PH7_PRIVATE const char *PH7_MemObjTypeDump(ph7_value *pVal) {
|
||||
const char *zType = "";
|
||||
if(pVal->iFlags & MEMOBJ_NULL) {
|
||||
zType = "null";
|
||||
|
@ -1240,8 +1205,7 @@ PH7_PRIVATE sxi32 PH7_MemObjDump(
|
|||
int nTab, /* # of Whitespace to insert */
|
||||
int nDepth, /* Nesting level */
|
||||
int isRef /* TRUE if referenced object */
|
||||
)
|
||||
{
|
||||
) {
|
||||
sxi32 rc = SXRET_OK;
|
||||
const char *zType;
|
||||
int i;
|
||||
|
|
70
oop.c
70
oop.c
|
@ -19,8 +19,7 @@
|
|||
* Create an empty class.
|
||||
* Return a pointer to a raw class (ph7_class instance) on success. NULL otherwise.
|
||||
*/
|
||||
PH7_PRIVATE ph7_class * PH7_NewRawClass(ph7_vm *pVm,const SyString *pName,sxu32 nLine)
|
||||
{
|
||||
PH7_PRIVATE ph7_class *PH7_NewRawClass(ph7_vm *pVm, const SyString *pName, sxu32 nLine) {
|
||||
ph7_class *pClass;
|
||||
char *zName;
|
||||
/* Allocate a new instance */
|
||||
|
@ -50,8 +49,7 @@ PH7_PRIVATE ph7_class * PH7_NewRawClass(ph7_vm *pVm,const SyString *pName,sxu32
|
|||
* Allocate and initialize a new class attribute.
|
||||
* Return a pointer to the class attribute on success. NULL otherwise.
|
||||
*/
|
||||
PH7_PRIVATE ph7_class_attr * PH7_NewClassAttr(ph7_vm *pVm,const SyString *pName,sxu32 nLine,sxi32 iProtection,sxi32 iFlags)
|
||||
{
|
||||
PH7_PRIVATE ph7_class_attr *PH7_NewClassAttr(ph7_vm *pVm, const SyString *pName, sxu32 nLine, sxi32 iProtection, sxi32 iFlags) {
|
||||
ph7_class_attr *pAttr;
|
||||
char *zName;
|
||||
pAttr = (ph7_class_attr *)SyMemBackendPoolAlloc(&pVm->sAllocator, sizeof(ph7_class_attr));
|
||||
|
@ -82,8 +80,7 @@ PH7_PRIVATE ph7_class_attr * PH7_NewClassAttr(ph7_vm *pVm,const SyString *pName,
|
|||
* random unique name.
|
||||
*/
|
||||
PH7_PRIVATE ph7_class_method *PH7_NewClassMethod(ph7_vm *pVm, ph7_class *pClass, const SyString *pName, sxu32 nLine,
|
||||
sxi32 iProtection,sxi32 iFlags,sxi32 iFuncFlags)
|
||||
{
|
||||
sxi32 iProtection, sxi32 iFlags, sxi32 iFuncFlags) {
|
||||
ph7_class_method *pMeth;
|
||||
SyHashEntry *pEntry;
|
||||
SyString *pNamePtr;
|
||||
|
@ -140,8 +137,7 @@ PH7_PRIVATE ph7_class_method * PH7_NewClassMethod(ph7_vm *pVm,ph7_class *pClass,
|
|||
* Check if the given name have a class method associated with it.
|
||||
* Return the desired method [i.e: ph7_class_method instance] on success. NULL otherwise.
|
||||
*/
|
||||
PH7_PRIVATE ph7_class_method * PH7_ClassExtractMethod(ph7_class *pClass,const char *zName,sxu32 nByte)
|
||||
{
|
||||
PH7_PRIVATE ph7_class_method *PH7_ClassExtractMethod(ph7_class *pClass, const char *zName, sxu32 nByte) {
|
||||
SyHashEntry *pEntry;
|
||||
/* Perform a hash lookup */
|
||||
pEntry = SyHashGet(&pClass->hMethod, (const void *)zName, nByte);
|
||||
|
@ -156,8 +152,7 @@ PH7_PRIVATE ph7_class_method * PH7_ClassExtractMethod(ph7_class *pClass,const ch
|
|||
* Check if the given name is a class attribute.
|
||||
* Return the desired attribute [i.e: ph7_class_attr instance] on success.NULL otherwise.
|
||||
*/
|
||||
PH7_PRIVATE ph7_class_attr * PH7_ClassExtractAttribute(ph7_class *pClass,const char *zName,sxu32 nByte)
|
||||
{
|
||||
PH7_PRIVATE ph7_class_attr *PH7_ClassExtractAttribute(ph7_class *pClass, const char *zName, sxu32 nByte) {
|
||||
SyHashEntry *pEntry;
|
||||
/* Perform a hash lookup */
|
||||
pEntry = SyHashGet(&pClass->hAttr, (const void *)zName, nByte);
|
||||
|
@ -172,8 +167,7 @@ PH7_PRIVATE ph7_class_attr * PH7_ClassExtractAttribute(ph7_class *pClass,const c
|
|||
* Install a class attribute in the corresponding container.
|
||||
* Return SXRET_OK on success. Any other return value indicates failure.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstallAttr(ph7_class *pClass,ph7_class_attr *pAttr)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstallAttr(ph7_class *pClass, ph7_class_attr *pAttr) {
|
||||
SyString *pName = &pAttr->sName;
|
||||
sxi32 rc;
|
||||
rc = SyHashInsert(&pClass->hAttr, (const void *)pName->zString, pName->nByte, pAttr);
|
||||
|
@ -183,8 +177,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstallAttr(ph7_class *pClass,ph7_class_attr *pAttr)
|
|||
* Install a class method in the corresponding container.
|
||||
* Return SXRET_OK on success. Any other return value indicates failure.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstallMethod(ph7_class *pClass,ph7_class_method *pMeth)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstallMethod(ph7_class *pClass, ph7_class_method *pMeth) {
|
||||
SyString *pName = &pMeth->sFunc.sName;
|
||||
sxi32 rc;
|
||||
rc = SyHashInsert(&pClass->hMethod, (const void *)pName->zString, pName->nByte, pMeth);
|
||||
|
@ -231,8 +224,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstallMethod(ph7_class *pClass,ph7_class_method *pMe
|
|||
* Any other return value indicates failure and the upper layer must generate an appropriate
|
||||
* error message.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_gen_state *pGen,ph7_class *pSub,ph7_class *pBase)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_gen_state *pGen, ph7_class *pSub, ph7_class *pBase) {
|
||||
ph7_class_method *pMeth;
|
||||
ph7_class_attr *pAttr;
|
||||
SyHashEntry *pEntry;
|
||||
|
@ -256,7 +248,6 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_gen_state *pGen,ph7_class *pSub,ph7_class
|
|||
PH7_GenCompileError(&(*pGen), E_WARNING, ((ph7_class_attr *)pEntry->pUserData)->nLine,
|
||||
"Private attribute '%z::%z' redeclared inside child class '%z'",
|
||||
&pBase->sName, pName, &pSub->sName);
|
||||
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -319,8 +310,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_gen_state *pGen,ph7_class *pSub,ph7_class
|
|||
* Any other return value indicates failure and the upper layer must generate an appropriate
|
||||
* error message.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassInterfaceInherit(ph7_class *pSub,ph7_class *pBase)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassInterfaceInherit(ph7_class *pSub, ph7_class *pBase) {
|
||||
ph7_class_method *pMeth;
|
||||
ph7_class_attr *pAttr;
|
||||
SyHashEntry *pEntry;
|
||||
|
@ -374,8 +364,7 @@ PH7_PRIVATE sxi32 PH7_ClassInterfaceInherit(ph7_class *pSub,ph7_class *pBase)
|
|||
* Any other return value indicates failure and the upper layer must generate an appropriate
|
||||
* error message.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassImplement(ph7_class *pMain,ph7_class *pInterface)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassImplement(ph7_class *pMain, ph7_class *pInterface) {
|
||||
ph7_class_attr *pAttr;
|
||||
SyHashEntry *pEntry;
|
||||
SyString *pName;
|
||||
|
@ -482,8 +471,7 @@ PH7_PRIVATE sxi32 PH7_ClassImplement(ph7_class *pMain,ph7_class *pInterface)
|
|||
* };
|
||||
* Refer to the official documentation for more information.
|
||||
*/
|
||||
static ph7_class_instance * NewClassInstance(ph7_vm *pVm,ph7_class *pClass)
|
||||
{
|
||||
static ph7_class_instance *NewClassInstance(ph7_vm *pVm, ph7_class *pClass) {
|
||||
ph7_class_instance *pThis;
|
||||
/* Allocate a new instance */
|
||||
pThis = (ph7_class_instance *)SyMemBackendPoolAlloc(&pVm->sAllocator, sizeof(ph7_class_instance));
|
||||
|
@ -503,8 +491,7 @@ static ph7_class_instance * NewClassInstance(ph7_vm *pVm,ph7_class *pClass)
|
|||
* Wrapper around the NewClassInstance() function defined above.
|
||||
* See the block comment above for more information.
|
||||
*/
|
||||
PH7_PRIVATE ph7_class_instance * PH7_NewClassInstance(ph7_vm *pVm,ph7_class *pClass)
|
||||
{
|
||||
PH7_PRIVATE ph7_class_instance *PH7_NewClassInstance(ph7_vm *pVm, ph7_class *pClass) {
|
||||
ph7_class_instance *pNew;
|
||||
sxi32 rc;
|
||||
pNew = NewClassInstance(&(*pVm), &(*pClass));
|
||||
|
@ -523,8 +510,7 @@ PH7_PRIVATE ph7_class_instance * PH7_NewClassInstance(ph7_vm *pVm,ph7_class *pCl
|
|||
* Extract the value of a class instance [i.e: Object in the PHP jargon] attribute.
|
||||
* This function never fail.
|
||||
*/
|
||||
static ph7_value * ExtractClassAttrValue(ph7_vm *pVm,VmClassAttr *pAttr)
|
||||
{
|
||||
static ph7_value *ExtractClassAttrValue(ph7_vm *pVm, VmClassAttr *pAttr) {
|
||||
/* Extract the value */
|
||||
ph7_value *pValue;
|
||||
pValue = (ph7_value *)SySetAt(&pVm->aMemObj, pAttr->nIdx);
|
||||
|
@ -614,8 +600,7 @@ static ph7_value * ExtractClassAttrValue(ph7_vm *pVm,VmClassAttr *pAttr)
|
|||
* )
|
||||
* )
|
||||
*/
|
||||
PH7_PRIVATE ph7_class_instance * PH7_CloneClassInstance(ph7_class_instance *pSrc)
|
||||
{
|
||||
PH7_PRIVATE ph7_class_instance *PH7_CloneClassInstance(ph7_class_instance *pSrc) {
|
||||
ph7_class_instance *pClone;
|
||||
ph7_class_method *pMethod;
|
||||
SyHashEntry *pEntry2;
|
||||
|
@ -672,8 +657,7 @@ PH7_PRIVATE ph7_class_instance * PH7_CloneClassInstance(ph7_class_instance *pSrc
|
|||
* This routine is invoked as soon as there are no other references to a particular
|
||||
* class instance.
|
||||
*/
|
||||
static void PH7_ClassInstanceRelease(ph7_class_instance *pThis)
|
||||
{
|
||||
static void PH7_ClassInstanceRelease(ph7_class_instance *pThis) {
|
||||
ph7_class_method *pDestr;
|
||||
SyHashEntry *pEntry;
|
||||
ph7_class *pClass;
|
||||
|
@ -713,8 +697,7 @@ static void PH7_ClassInstanceRelease(ph7_class_instance *pThis)
|
|||
* Decrement the reference count of a class instance [i.e Object in the PHP jargon].
|
||||
* If the reference count reaches zero,release the whole instance.
|
||||
*/
|
||||
PH7_PRIVATE void PH7_ClassInstanceUnref(ph7_class_instance *pThis)
|
||||
{
|
||||
PH7_PRIVATE void PH7_ClassInstanceUnref(ph7_class_instance *pThis) {
|
||||
pThis->iRef--;
|
||||
if(pThis->iRef < 1) {
|
||||
/* No more reference to this instance */
|
||||
|
@ -798,8 +781,7 @@ PH7_PRIVATE void PH7_ClassInstanceUnref(ph7_class_instance *pThis)
|
|||
* This function return 0 if the objects are equals according to the comprison rules defined above.
|
||||
* Any other return values indicates difference.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstanceCmp(ph7_class_instance *pLeft,ph7_class_instance *pRight,int bStrict,int iNest)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstanceCmp(ph7_class_instance *pLeft, ph7_class_instance *pRight, int bStrict, int iNest) {
|
||||
SyHashEntry *pEntry, *pEntry2;
|
||||
ph7_value sV1, sV2;
|
||||
sxi32 rc;
|
||||
|
@ -871,8 +853,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceCmp(ph7_class_instance *pLeft,ph7_class_insta
|
|||
* This function SXRET_OK on success. Any other return value including
|
||||
* SXERR_LIMIT(infinite recursion) indicates failure.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstanceDump(SyBlob *pOut,ph7_class_instance *pThis,int ShowType,int nTab,int nDepth)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstanceDump(SyBlob *pOut, ph7_class_instance *pThis, int ShowType, int nTab, int nDepth) {
|
||||
SyHashEntry *pEntry;
|
||||
ph7_value *pValue;
|
||||
sxi32 rc;
|
||||
|
@ -975,8 +956,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceCallMagicMethod(
|
|||
const char *zMethod, /* Magic method name [i.e: __toString()]*/
|
||||
sxu32 nByte, /* zMethod length*/
|
||||
const SyString *pAttrName /* Attribute name */
|
||||
)
|
||||
{
|
||||
) {
|
||||
ph7_value *apArg[2] = { 0, 0 };
|
||||
ph7_class_method *pMeth;
|
||||
ph7_value sAttr; /* cc warning */
|
||||
|
@ -1008,8 +988,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceCallMagicMethod(
|
|||
* Extract the value of a class instance [i.e: Object in the PHP jargon].
|
||||
* This function is simply a wrapper on ExtractClassAttrValue().
|
||||
*/
|
||||
PH7_PRIVATE ph7_value * PH7_ClassInstanceExtractAttrValue(ph7_class_instance *pThis,VmClassAttr *pAttr)
|
||||
{
|
||||
PH7_PRIVATE ph7_value *PH7_ClassInstanceExtractAttrValue(ph7_class_instance *pThis, VmClassAttr *pAttr) {
|
||||
/* Extract the attribute value */
|
||||
ph7_value *pValue;
|
||||
pValue = ExtractClassAttrValue(pThis->pVm, pAttr);
|
||||
|
@ -1044,8 +1023,7 @@ PH7_PRIVATE ph7_value * PH7_ClassInstanceExtractAttrValue(ph7_class_instance *pT
|
|||
* value unlike the standard PHP engine.
|
||||
* This is a very powerful feature that you have to look at.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstanceToHashmap(ph7_class_instance *pThis,ph7_hashmap *pMap)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ClassInstanceToHashmap(ph7_class_instance *pThis, ph7_hashmap *pMap) {
|
||||
SyHashEntry *pEntry;
|
||||
SyString *pAttrName;
|
||||
VmClassAttr *pAttr;
|
||||
|
@ -1085,8 +1063,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceWalk(
|
|||
ph7_class_instance *pThis, /* Target object */
|
||||
int (*xWalk)(const char *, ph7_value *, void *), /* Walker callback */
|
||||
void *pUserData /* Last argument to xWalk() */
|
||||
)
|
||||
{
|
||||
) {
|
||||
SyHashEntry *pEntry; /* Hash entry */
|
||||
VmClassAttr *pAttr; /* Pointer to the attribute */
|
||||
ph7_value *pValue; /* Attribute value */
|
||||
|
@ -1123,8 +1100,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceWalk(
|
|||
* will return NULL in case someone (host-application code) try to extract
|
||||
* a static/constant attribute.
|
||||
*/
|
||||
PH7_PRIVATE ph7_value * PH7_ClassInstanceFetchAttr(ph7_class_instance *pThis,const SyString *pName)
|
||||
{
|
||||
PH7_PRIVATE ph7_value *PH7_ClassInstanceFetchAttr(ph7_class_instance *pThis, const SyString *pName) {
|
||||
SyHashEntry *pEntry;
|
||||
VmClassAttr *pAttr;
|
||||
/* Query the attribute hashtable */
|
||||
|
|
45
parser.c
45
parser.c
|
@ -259,8 +259,7 @@ static const ph7_expr_op sFCallOp = {{"(",sizeof(char)}, EXPR_OP_FUNC_CALL, 2, E
|
|||
* Note that the function take care of handling ambiguity [i.e: whether we are dealing with
|
||||
* a binary minus or unary minus.]
|
||||
*/
|
||||
PH7_PRIVATE const ph7_expr_op * PH7_ExprExtractOperator(SyString *pStr,SyToken *pLast)
|
||||
{
|
||||
PH7_PRIVATE const ph7_expr_op *PH7_ExprExtractOperator(SyString *pStr, SyToken *pLast) {
|
||||
sxu32 n = 0;
|
||||
sxi32 rc;
|
||||
/* Do a linear lookup on the operators table */
|
||||
|
@ -291,7 +290,6 @@ PH7_PRIVATE const ph7_expr_op * PH7_ExprExtractOperator(SyString *pStr,SyToken
|
|||
/* Unary opertors have prcedence here over binary operators */
|
||||
return &aOpTable[n];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
++n; /* Next operator in the table */
|
||||
|
@ -304,8 +302,7 @@ PH7_PRIVATE const ph7_expr_op * PH7_ExprExtractOperator(SyString *pStr,SyToken
|
|||
* This function take care of handling the nesting level and stops when it hit
|
||||
* the end of the input or the ending token is found and the nesting level is zero.
|
||||
*/
|
||||
PH7_PRIVATE void PH7_DelimitNestedTokens(SyToken *pIn,SyToken *pEnd,sxu32 nTokStart,sxu32 nTokEnd,SyToken **ppEnd)
|
||||
{
|
||||
PH7_PRIVATE void PH7_DelimitNestedTokens(SyToken *pIn, SyToken *pEnd, sxu32 nTokStart, sxu32 nTokEnd, SyToken **ppEnd) {
|
||||
SyToken *pCur = pIn;
|
||||
sxi32 iNest = 1;
|
||||
for(;;) {
|
||||
|
@ -337,8 +334,7 @@ PH7_PRIVATE void PH7_DelimitNestedTokens(SyToken *pIn,SyToken *pEnd,sxu32 nTokSt
|
|||
* constructs. You cannot use any of the following words as constants, class names, function
|
||||
* or method names. Using them as variable names is generally OK, but could lead to confusion.
|
||||
*/
|
||||
PH7_PRIVATE int PH7_IsLangConstruct(sxu32 nKeyID,sxu8 bCheckFunc)
|
||||
{
|
||||
PH7_PRIVATE int PH7_IsLangConstruct(sxu32 nKeyID, sxu8 bCheckFunc) {
|
||||
if(nKeyID == PH7_TKWRD_ECHO || nKeyID == PH7_TKWRD_PRINT || nKeyID == PH7_TKWRD_INCLUDE
|
||||
|| nKeyID == PH7_TKWRD_INCONCE || nKeyID == PH7_TKWRD_REQUIRE || nKeyID == PH7_TKWRD_REQONCE
|
||||
) {
|
||||
|
@ -360,11 +356,9 @@ PH7_PRIVATE int PH7_IsLangConstruct(sxu32 nKeyID,sxu8 bCheckFunc)
|
|||
* When errors,PH7 take care of generating the appropriate error message.
|
||||
* Return SXRET_OK on success. Any other return value indicates syntax error.
|
||||
*/
|
||||
static sxi32 ExprVerifyNodes(ph7_gen_state *pGen,ph7_expr_node **apNode,sxi32 nNode)
|
||||
{
|
||||
static sxi32 ExprVerifyNodes(ph7_gen_state *pGen, ph7_expr_node **apNode, sxi32 nNode) {
|
||||
sxi32 iParen, iSquare, iQuesty, iBraces;
|
||||
sxi32 i, rc;
|
||||
|
||||
if(nNode > 0 && apNode[0]->pOp && (apNode[0]->pOp->iOp == EXPR_OP_ADD || apNode[0]->pOp->iOp == EXPR_OP_SUB)) {
|
||||
/* Fix and mark as an unary not binary plus/minus operator */
|
||||
apNode[0]->pOp = PH7_ExprExtractOperator(&apNode[0]->pStart->sData, 0);
|
||||
|
@ -451,7 +445,6 @@ static sxi32 ExprVerifyNodes(ph7_gen_state *pGen,ph7_expr_node **apNode,sxi32 nN
|
|||
apNode[j]->pStart->nType &= ~PH7_TK_CCB /*'}'*/;
|
||||
apNode[j]->pStart->nType |= PH7_TK_CSB /*']'*/;
|
||||
}
|
||||
|
||||
}
|
||||
} else if(apNode[i]->pStart->nType & PH7_TK_CCB /*'}'*/) {
|
||||
if(iBraces <= 0) {
|
||||
|
@ -510,8 +503,7 @@ static sxi32 ExprVerifyNodes(ph7_gen_state *pGen,ph7_expr_node **apNode,sxi32 nN
|
|||
* Collect and assemble tokens holding a namespace path [i.e: namespace\to\const]
|
||||
* or a simple literal [i.e: PHP_EOL].
|
||||
*/
|
||||
static void ExprAssembleLiteral(SyToken **ppCur,SyToken *pEnd)
|
||||
{
|
||||
static void ExprAssembleLiteral(SyToken **ppCur, SyToken *pEnd) {
|
||||
SyToken *pIn = *ppCur;
|
||||
/* Jump the first literal seen */
|
||||
if((pIn->nType & PH7_TK_NSSEP) == 0) {
|
||||
|
@ -563,8 +555,7 @@ static void ExprAssembleLiteral(SyToken **ppCur,SyToken *pEnd)
|
|||
* $new_numbers = array_map($double, $numbers);
|
||||
* print implode(' ', $new_numbers);
|
||||
*/
|
||||
static sxi32 ExprAssembleAnnon(ph7_gen_state *pGen,SyToken **ppCur,SyToken *pEnd)
|
||||
{
|
||||
static sxi32 ExprAssembleAnnon(ph7_gen_state *pGen, SyToken **ppCur, SyToken *pEnd) {
|
||||
SyToken *pIn = *ppCur;
|
||||
sxu32 nLine;
|
||||
sxi32 rc;
|
||||
|
@ -654,8 +645,7 @@ Synchronize:
|
|||
* quoted string, a literal [i.e: PHP_EOL],a namespace path
|
||||
* [i.e: namespaces\path\to..],a array/list [i.e: array(4,5,6)] and so on.
|
||||
*/
|
||||
static sxi32 ExprExtractNode(ph7_gen_state *pGen,ph7_expr_node **ppNode)
|
||||
{
|
||||
static sxi32 ExprExtractNode(ph7_gen_state *pGen, ph7_expr_node **ppNode) {
|
||||
ph7_expr_node *pNode;
|
||||
SyToken *pCur;
|
||||
sxi32 rc;
|
||||
|
@ -799,8 +789,7 @@ static sxi32 ExprExtractNode(ph7_gen_state *pGen,ph7_expr_node **ppNode)
|
|||
* The cursor stops when it hit a comma ',' or a semi-colon and the nesting
|
||||
* level is zero.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_GetNextExpr(SyToken *pStart,SyToken *pEnd,SyToken **ppNext)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_GetNextExpr(SyToken *pStart, SyToken *pEnd, SyToken **ppNext) {
|
||||
SyToken *pCur = pStart;
|
||||
sxi32 iNest = 0;
|
||||
if(pCur >= pEnd || (pCur->nType & PH7_TK_SEMI/*';'*/)) {
|
||||
|
@ -824,8 +813,7 @@ PH7_PRIVATE sxi32 PH7_GetNextExpr(SyToken *pStart,SyToken *pEnd,SyToken **ppNext
|
|||
/*
|
||||
* Free an expression tree.
|
||||
*/
|
||||
static void ExprFreeTree(ph7_gen_state *pGen,ph7_expr_node *pNode)
|
||||
{
|
||||
static void ExprFreeTree(ph7_gen_state *pGen, ph7_expr_node *pNode) {
|
||||
if(pNode->pLeft) {
|
||||
/* Release the left tree */
|
||||
ExprFreeTree(&(*pGen), pNode->pLeft);
|
||||
|
@ -855,8 +843,7 @@ static void ExprFreeTree(ph7_gen_state *pGen,ph7_expr_node *pNode)
|
|||
* Free an expression tree.
|
||||
* This function is a wrapper around ExprFreeTree() defined above.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ExprFreeTree(ph7_gen_state *pGen,SySet *pNodeSet)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ExprFreeTree(ph7_gen_state *pGen, SySet *pNodeSet) {
|
||||
ph7_expr_node **apNode;
|
||||
sxu32 n;
|
||||
apNode = (ph7_expr_node **)SySetBasePtr(pNodeSet);
|
||||
|
@ -871,8 +858,7 @@ PH7_PRIVATE sxi32 PH7_ExprFreeTree(ph7_gen_state *pGen,SySet *pNodeSet)
|
|||
* Check if the given node is a modifialbe l/r-value.
|
||||
* Return TRUE if modifiable.FALSE otherwise.
|
||||
*/
|
||||
static int ExprIsModifiableValue(ph7_expr_node *pNode,sxu8 bFunc)
|
||||
{
|
||||
static int ExprIsModifiableValue(ph7_expr_node *pNode, sxu8 bFunc) {
|
||||
sxi32 iExprOp;
|
||||
if(pNode->pOp == 0) {
|
||||
return pNode->xCode == PH7_CompileVariable ? TRUE : FALSE;
|
||||
|
@ -906,8 +892,7 @@ static sxi32 ExprMakeTree(ph7_gen_state *pGen,ph7_expr_node **apNode,sxi32 nToke
|
|||
* Buid an expression tree for each given function argument.
|
||||
* When errors,PH7 take care of generating the appropriate error message.
|
||||
*/
|
||||
static sxi32 ExprProcessFuncArguments(ph7_gen_state *pGen,ph7_expr_node *pOp,ph7_expr_node **apNode,sxi32 nToken)
|
||||
{
|
||||
static sxi32 ExprProcessFuncArguments(ph7_gen_state *pGen, ph7_expr_node *pOp, ph7_expr_node **apNode, sxi32 nToken) {
|
||||
sxi32 iNest, iCur, iNode;
|
||||
sxi32 rc;
|
||||
/* Process function arguments from left to right */
|
||||
|
@ -978,8 +963,7 @@ static sxi32 ExprProcessFuncArguments(ph7_gen_state *pGen,ph7_expr_node *pOp,ph7
|
|||
* If successful, the root of the tree is stored in apNode[0].
|
||||
* When errors,PH7 take care of generating the appropriate error message.
|
||||
*/
|
||||
static sxi32 ExprMakeTree(ph7_gen_state *pGen,ph7_expr_node **apNode,sxi32 nToken)
|
||||
{
|
||||
static sxi32 ExprMakeTree(ph7_gen_state *pGen, ph7_expr_node **apNode, sxi32 nToken) {
|
||||
sxi32 i, iLeft, iRight;
|
||||
ph7_expr_node *pNode;
|
||||
sxi32 iCur;
|
||||
|
@ -1573,8 +1557,7 @@ static sxi32 ExprProcessFuncArguments(ph7_gen_state *pGen,ph7_expr_node *pOp,ph7
|
|||
* When errors,PH7 take care of generating the appropriate error message.
|
||||
* This is the public interface used by the most code generator routines.
|
||||
*/
|
||||
PH7_PRIVATE sxi32 PH7_ExprMakeTree(ph7_gen_state *pGen,SySet *pExprNode,ph7_expr_node **ppRoot)
|
||||
{
|
||||
PH7_PRIVATE sxi32 PH7_ExprMakeTree(ph7_gen_state *pGen, SySet *pExprNode, ph7_expr_node **ppRoot) {
|
||||
ph7_expr_node **apNode;
|
||||
ph7_expr_node *pNode;
|
||||
sxi32 rc;
|
||||
|
|
28
ph7.h
28
ph7.h
|
@ -95,10 +95,6 @@
|
|||
* contact@symisc.net
|
||||
*/
|
||||
#define PH7_COPYRIGHT "Copyright (C) Symisc Systems 2011-2012, http://ph7.symisc.net/"
|
||||
/* Make sure we can call this stuff from C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* Forward declaration to public objects */
|
||||
typedef struct ph7_io_stream ph7_io_stream;
|
||||
typedef struct ph7_context ph7_context;
|
||||
|
@ -207,8 +203,7 @@ typedef struct syiovec syiovec;
|
|||
typedef struct SyMutex SyMutex;
|
||||
typedef struct Sytm Sytm;
|
||||
/* Scatter and gather array. */
|
||||
struct syiovec
|
||||
{
|
||||
struct syiovec {
|
||||
#if defined (__WINNT__)
|
||||
/* Same fields type and offset as WSABUF structure defined one winsock2 header */
|
||||
unsigned long nLen;
|
||||
|
@ -218,14 +213,12 @@ struct syiovec
|
|||
unsigned long nLen;
|
||||
#endif
|
||||
};
|
||||
struct SyString
|
||||
{
|
||||
struct SyString {
|
||||
const char *zString; /* Raw string (may not be null terminated) */
|
||||
unsigned int nByte; /* Raw string length */
|
||||
};
|
||||
/* Time structure. */
|
||||
struct Sytm
|
||||
{
|
||||
struct Sytm {
|
||||
int tm_sec; /* seconds (0 - 60) */
|
||||
int tm_min; /* minutes (0 - 59) */
|
||||
int tm_hour; /* hours (0 - 23) */
|
||||
|
@ -267,8 +260,7 @@ struct Sytm
|
|||
(pSYTM)->tm_zone = 0;
|
||||
|
||||
/* Dynamic memory allocation methods. */
|
||||
struct SyMemMethods
|
||||
{
|
||||
struct SyMemMethods {
|
||||
void *(*xAlloc)(unsigned int); /* [Required:] Allocate a memory chunk */
|
||||
void *(*xRealloc)(void *, unsigned int); /* [Required:] Re-allocate a memory chunk */
|
||||
void (*xFree)(void *); /* [Required:] Release a memory chunk */
|
||||
|
@ -280,8 +272,7 @@ struct SyMemMethods
|
|||
/* Out of memory callback signature. */
|
||||
typedef int (*ProcMemError)(void *);
|
||||
/* Mutex methods. */
|
||||
struct SyMutexMethods
|
||||
{
|
||||
struct SyMutexMethods {
|
||||
int (*xGlobalInit)(void); /* [Optional:] Global mutex initialization */
|
||||
void (*xGlobalRelease)(void); /* [Optional:] Global Release callback () */
|
||||
SyMutex *(*xNew)(int); /* [Required:] Request a new mutex */
|
||||
|
@ -492,8 +483,7 @@ typedef sxi64 ph7_int64;
|
|||
* Developers wishing to implement the vfs methods can contact symisc systems to obtain
|
||||
* the PH7 VFS C/C++ Specification manual.
|
||||
*/
|
||||
struct ph7_vfs
|
||||
{
|
||||
struct ph7_vfs {
|
||||
const char *zName; /* Underlying VFS name [i.e: FreeBSD/Linux/Windows...] */
|
||||
int iVersion; /* Current VFS structure version [default 2] */
|
||||
/* Directory functions */
|
||||
|
@ -587,8 +577,7 @@ struct ph7_vfs
|
|||
* Developers wishing to implement their own IO stream devices must understand and follow
|
||||
* The PH7 IO Stream C/C++ specification manual (http://ph7.symisc.net/io_stream_spec.html).
|
||||
*/
|
||||
struct ph7_io_stream
|
||||
{
|
||||
struct ph7_io_stream {
|
||||
const char *zName; /* Underlying stream name [i.e: file/http/zip/php,..] */
|
||||
int iVersion; /* IO stream structure version [default 1]*/
|
||||
int (*xOpen)(const char *, int, ph7_value *, void **); /* Open handle*/
|
||||
|
@ -712,7 +701,4 @@ PH7_APIEXPORT const char * ph7_lib_version(void);
|
|||
PH7_APIEXPORT const char *ph7_lib_signature(void);
|
||||
PH7_APIEXPORT const char *ph7_lib_ident(void);
|
||||
PH7_APIEXPORT const char *ph7_lib_copyright(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _PH7_H_ */
|
||||
|
|
150
ph7int.h
150
ph7int.h
|
@ -177,8 +177,7 @@ typedef sxi32 (*ProcSort)(void *,sxu32,sxu32,ProcCmp);
|
|||
/*
|
||||
* A generic dynamic set.
|
||||
*/
|
||||
struct SySet
|
||||
{
|
||||
struct SySet {
|
||||
SyMemBackend *pAllocator; /* Memory backend */
|
||||
void *pBase; /* Base pointer */
|
||||
sxu32 nUsed; /* Total number of used slots */
|
||||
|
@ -199,8 +198,7 @@ struct SySet
|
|||
/*
|
||||
* A variable length containers for generic data.
|
||||
*/
|
||||
struct SyBlob
|
||||
{
|
||||
struct SyBlob {
|
||||
SyMemBackend *pAllocator; /* Memory backend */
|
||||
void *pBlob; /* Base pointer */
|
||||
sxu32 nByte; /* Total number of used bytes */
|
||||
|
@ -227,8 +225,7 @@ struct SyBlob
|
|||
/* A memory backend subsystem is defined by an instance of the following structures */
|
||||
typedef union SyMemHeader SyMemHeader;
|
||||
typedef struct SyMemBlock SyMemBlock;
|
||||
struct SyMemBlock
|
||||
{
|
||||
struct SyMemBlock {
|
||||
SyMemBlock *pNext, *pPrev; /* Chain of allocated memory blocks */
|
||||
#ifdef UNTRUST
|
||||
sxu32 nGuard; /* magic number associated with each valid block,so we
|
||||
|
@ -239,13 +236,11 @@ struct SyMemBlock
|
|||
/*
|
||||
* Header associated with each valid memory pool block.
|
||||
*/
|
||||
union SyMemHeader
|
||||
{
|
||||
union SyMemHeader {
|
||||
SyMemHeader *pNext; /* Next chunk of size 1 << (nBucket + SXMEM_POOL_INCR) in the list */
|
||||
sxu32 nBucket; /* Bucket index in aPool[] */
|
||||
};
|
||||
struct SyMemBackend
|
||||
{
|
||||
struct SyMemBackend {
|
||||
const SyMutexMethods *pMutexMethods; /* Mutex methods */
|
||||
const SyMemMethods *pMethods; /* Memory allocation methods */
|
||||
SyMemBlock *pBlocks; /* List of valid memory blocks */
|
||||
|
@ -348,8 +343,7 @@ typedef struct SyHash SyHash;
|
|||
* Each public hashtable entry is represented by an instance
|
||||
* of the following structure.
|
||||
*/
|
||||
struct SyHashEntry
|
||||
{
|
||||
struct SyHashEntry {
|
||||
const void *pKey; /* Hash key */
|
||||
sxu32 nKeyLen; /* Key length */
|
||||
void *pUserData; /* User private data */
|
||||
|
@ -357,8 +351,7 @@ struct SyHashEntry
|
|||
#define SyHashEntryGetUserData(ENTRY) ((ENTRY)->pUserData)
|
||||
#define SyHashEntryGetKey(ENTRY) ((ENTRY)->pKey)
|
||||
/* Each active hashtable is identified by an instance of the following structure */
|
||||
struct SyHash
|
||||
{
|
||||
struct SyHash {
|
||||
SyMemBackend *pAllocator; /* Memory backend */
|
||||
ProcHash xHash; /* Hash function */
|
||||
ProcCmp xCmp; /* Comparison function */
|
||||
|
@ -384,8 +377,7 @@ struct SyHash
|
|||
* This implementation is taken from the SQLite3 source tree.
|
||||
*/
|
||||
typedef struct SyPRNGCtx SyPRNGCtx;
|
||||
struct SyPRNGCtx
|
||||
{
|
||||
struct SyPRNGCtx {
|
||||
sxu8 i, j; /* State variables */
|
||||
unsigned char s[256]; /* State variables */
|
||||
sxu16 nMagic; /* Sanity check */
|
||||
|
@ -393,8 +385,7 @@ struct SyPRNGCtx
|
|||
typedef sxi32(*ProcRandomSeed)(void *, unsigned int, void *);
|
||||
/* High resolution timer.*/
|
||||
typedef struct sytime sytime;
|
||||
struct sytime
|
||||
{
|
||||
struct sytime {
|
||||
long tm_sec; /* seconds */
|
||||
long tm_usec; /* microseconds */
|
||||
};
|
||||
|
@ -410,8 +401,7 @@ typedef sxi32 (*ProcTokenizer)(SyStream *,SyToken *,void *,void *);
|
|||
* Each token in the input is represented by an instance
|
||||
* of the following structure.
|
||||
*/
|
||||
struct SyToken
|
||||
{
|
||||
struct SyToken {
|
||||
SyString sData; /* Token text and length */
|
||||
sxu32 nType; /* Token type */
|
||||
sxu32 nLine; /* Token line number */
|
||||
|
@ -421,8 +411,7 @@ struct SyToken
|
|||
* During tokenization, information about the state of the input
|
||||
* stream is held in an instance of the following structure.
|
||||
*/
|
||||
struct SyStream
|
||||
{
|
||||
struct SyStream {
|
||||
const unsigned char *zInput; /* Complete text of the input */
|
||||
const unsigned char *zText; /* Current input we are processing */
|
||||
const unsigned char *zEnd; /* End of input marker */
|
||||
|
@ -433,8 +422,7 @@ struct SyStream
|
|||
/*
|
||||
* Each lexer is represented by an instance of the following structure.
|
||||
*/
|
||||
struct SyLex
|
||||
{
|
||||
struct SyLex {
|
||||
SyStream sStream; /* Input stream */
|
||||
ProcTokenizer xTokenizer; /* Tokenizer callback */
|
||||
void *pUserData; /* Third argument to xTokenizer() */
|
||||
|
@ -545,8 +533,7 @@ struct SyLex
|
|||
* in an instance of the following structure.
|
||||
*/
|
||||
typedef struct SyXMLRawStr SyXMLRawStr;
|
||||
struct SyXMLRawStr
|
||||
{
|
||||
struct SyXMLRawStr {
|
||||
const char *zString; /* Raw text [UTF-8 ENCODED EXCEPT CDATA] [NOT NULL TERMINATED] */
|
||||
sxu32 nByte; /* Text length */
|
||||
sxu32 nLine; /* Line number this text occurs */
|
||||
|
@ -600,8 +587,7 @@ enum xml_err_code{
|
|||
* of the following structure.
|
||||
*/
|
||||
typedef struct SyXMLParser SyXMLParser;
|
||||
struct SyXMLParser
|
||||
{
|
||||
struct SyXMLParser {
|
||||
SyMemBackend *pAllocator; /* Memory backend */
|
||||
void *pUserData; /* User private data forwarded varbatim by the XML parser
|
||||
* as the last argument to the users callbacks.
|
||||
|
@ -634,8 +620,7 @@ struct SyXMLParser
|
|||
*/
|
||||
typedef struct SyArchiveEntry SyArchiveEntry;
|
||||
typedef struct SyArchive SyArchive;
|
||||
struct SyArchive
|
||||
{
|
||||
struct SyArchive {
|
||||
SyMemBackend *pAllocator; /* Memory backend */
|
||||
SyArchiveEntry *pCursor; /* Cursor for linear traversal of archive entries */
|
||||
SyArchiveEntry *pList; /* Pointer to the List of the loaded archive */
|
||||
|
@ -662,8 +647,7 @@ struct SyXMLParser
|
|||
* Each loaded archive record is identified by an instance
|
||||
* of the following structure.
|
||||
*/
|
||||
struct SyArchiveEntry
|
||||
{
|
||||
struct SyArchiveEntry {
|
||||
sxu32 nByte; /* Contents size before compression */
|
||||
sxu32 nByteCompr; /* Contents size after compression */
|
||||
sxu32 nReadCount; /* Read counter */
|
||||
|
@ -710,8 +694,7 @@ struct SHA1Context {
|
|||
* Each ph7_values struct may cache multiple representations (string, integer etc.)
|
||||
* of the same value.
|
||||
*/
|
||||
struct ph7_value
|
||||
{
|
||||
struct ph7_value {
|
||||
ph7_real rVal; /* Real value */
|
||||
union {
|
||||
sxi64 iVal; /* Integer value */
|
||||
|
@ -761,8 +744,7 @@ typedef struct ph7_conf ph7_conf;
|
|||
* Please refer to the official documentation for more information
|
||||
* on how to register an output consumer callback.
|
||||
*/
|
||||
struct ph7_output_consumer
|
||||
{
|
||||
struct ph7_output_consumer {
|
||||
ProcConsumer xConsumer; /* VM output consumer routine */
|
||||
void *pUserData; /* Third argument to xConsumer() */
|
||||
ProcConsumer xDef; /* Default output consumer routine */
|
||||
|
@ -774,8 +756,7 @@ struct ph7_output_consumer
|
|||
* Please refer to the official documentation for more information
|
||||
* on how to configure your ph7 engine instance.
|
||||
*/
|
||||
struct ph7_conf
|
||||
{
|
||||
struct ph7_conf {
|
||||
ProcConsumer xErr; /* Compile-time error consumer callback */
|
||||
void *pErrData; /* Third argument to xErr() */
|
||||
SyBlob sErrConsumer; /* Default error consumer */
|
||||
|
@ -791,8 +772,7 @@ typedef void (*ProcConstant)(ph7_value *,void *);
|
|||
* on how to create/install foreign constants.
|
||||
*/
|
||||
typedef struct ph7_constant ph7_constant;
|
||||
struct ph7_constant
|
||||
{
|
||||
struct ph7_constant {
|
||||
SyString sName; /* Constant name */
|
||||
ProcConstant xExpand; /* Function responsible of expanding constant value */
|
||||
void *pUserData; /* Last argument to xExpand() */
|
||||
|
@ -804,8 +784,7 @@ typedef struct ph7_aux_data ph7_aux_data;
|
|||
* Note that automatic tracked chunks are also stored in an instance
|
||||
* of this structure.
|
||||
*/
|
||||
struct ph7_aux_data
|
||||
{
|
||||
struct ph7_aux_data {
|
||||
void *pAuxData; /* Aux data */
|
||||
};
|
||||
/* Foreign functions signature */
|
||||
|
@ -816,8 +795,7 @@ typedef int (*ProchHostFunction)(ph7_context *,int,ph7_value **);
|
|||
* Please refer to the official documentation for more information on how
|
||||
* to create/install foreign functions.
|
||||
*/
|
||||
struct ph7_user_func
|
||||
{
|
||||
struct ph7_user_func {
|
||||
ph7_vm *pVm; /* VM that own this instance */
|
||||
SyString sName; /* Foreign function name */
|
||||
ProchHostFunction xFunc; /* Implementation of the foreign function */
|
||||
|
@ -829,8 +807,7 @@ struct ph7_user_func
|
|||
* instance of this structure is the first argument to the routines used
|
||||
* implement the foreign functions.
|
||||
*/
|
||||
struct ph7_context
|
||||
{
|
||||
struct ph7_context {
|
||||
ph7_user_func *pFunc; /* Function information. */
|
||||
ph7_value *pRet; /* Return value is stored here. */
|
||||
SySet sVar; /* Container of dynamically allocated ph7_values
|
||||
|
@ -846,8 +823,7 @@ struct ph7_context
|
|||
* Each hashmap entry [i.e: array(4,5,6)] is recorded in an instance
|
||||
* of the following structure.
|
||||
*/
|
||||
struct ph7_hashmap_node
|
||||
{
|
||||
struct ph7_hashmap_node {
|
||||
ph7_hashmap *pMap; /* Hashmap that own this instance */
|
||||
sxi32 iType; /* Node type */
|
||||
union {
|
||||
|
@ -864,8 +840,7 @@ struct ph7_hashmap_node
|
|||
* Each active hashmap aka array in the PHP jargon is represented
|
||||
* by an instance of the following structure.
|
||||
*/
|
||||
struct ph7_hashmap
|
||||
{
|
||||
struct ph7_hashmap {
|
||||
ph7_vm *pVm; /* VM that own this instance */
|
||||
ph7_hashmap_node **apBucket; /* Hash bucket */
|
||||
ph7_hashmap_node *pFirst; /* First inserted entry */
|
||||
|
@ -885,15 +860,13 @@ struct ph7_hashmap
|
|||
* This structure is made available to these instructions
|
||||
* as the P3 operand.
|
||||
*/
|
||||
struct ph7_foreach_info
|
||||
{
|
||||
struct ph7_foreach_info {
|
||||
SyString sKey; /* Key name. Empty otherwise*/
|
||||
SyString sValue; /* Value name */
|
||||
sxi32 iFlags; /* Control flags */
|
||||
SySet aStep; /* Stack of steps [i.e: ph7_foreach_step instance] */
|
||||
};
|
||||
struct ph7_foreach_step
|
||||
{
|
||||
struct ph7_foreach_step {
|
||||
sxi32 iFlags; /* Control flags (see below) */
|
||||
/* Iterate on those values */
|
||||
union {
|
||||
|
@ -913,8 +886,7 @@ struct ph7_foreach_step
|
|||
* Please refer to the official documentation for more information
|
||||
* on how to configure your PH7 engine instance.
|
||||
*/
|
||||
struct ph7
|
||||
{
|
||||
struct ph7 {
|
||||
SyMemBackend sAllocator; /* Low level memory allocation subsystem */
|
||||
const ph7_vfs *pVfs; /* Underlying Virtual File System */
|
||||
ph7_conf xConf; /* Configuration */
|
||||
|
@ -942,8 +914,7 @@ typedef sxi32 (*ProcNodeConstruct)(ph7_gen_state *,sxi32);
|
|||
* That is, the PH7 parser is thread-safe ,full reentrant, produce consistant
|
||||
* compile-time errrors and at least 7 times faster than the standard PHP parser.
|
||||
*/
|
||||
struct ph7_expr_op
|
||||
{
|
||||
struct ph7_expr_op {
|
||||
SyString sOp; /* String representation of the operator [i.e: "+","*","=="...] */
|
||||
sxi32 iOp; /* Operator ID */
|
||||
sxi32 iPrec; /* Operator precedence: 1 == Highest */
|
||||
|
@ -954,8 +925,7 @@ struct ph7_expr_op
|
|||
* Each expression node is parsed out and recorded
|
||||
* in an instance of the following structure.
|
||||
*/
|
||||
struct ph7_expr_node
|
||||
{
|
||||
struct ph7_expr_node {
|
||||
const ph7_expr_op *pOp; /* Operator ID or NULL if literal, constant, variable, function or class method call */
|
||||
ph7_expr_node *pLeft; /* Left expression tree */
|
||||
ph7_expr_node *pRight; /* Right expression tree */
|
||||
|
@ -973,8 +943,7 @@ struct ph7_expr_node
|
|||
* This structure is used only during compile-time and have no meaning
|
||||
* during bytecode execution.
|
||||
*/
|
||||
struct GenBlock
|
||||
{
|
||||
struct GenBlock {
|
||||
ph7_gen_state *pGen; /* State of the code generator */
|
||||
GenBlock *pParent; /* Upper block or NULL if global */
|
||||
sxu32 nFirstInstr; /* First instruction to execute */
|
||||
|
@ -996,8 +965,7 @@ struct GenBlock
|
|||
* This structure is used only during compile-time and have no meaning
|
||||
* during bytecode execution.
|
||||
*/
|
||||
struct ph7_gen_state
|
||||
{
|
||||
struct ph7_gen_state {
|
||||
ph7_vm *pVm; /* VM that own this instance */
|
||||
SyHash hLiteral; /* Constant string Literals table */
|
||||
SyHash hNumLiteral; /* Numeric literals table */
|
||||
|
@ -1041,8 +1009,7 @@ typedef struct VmFrame VmFrame;
|
|||
* Refer to the official documentation for more information on this
|
||||
* mechanism and other extension introduced by the PH7 engine.
|
||||
*/
|
||||
struct ph7_vm_func_arg
|
||||
{
|
||||
struct ph7_vm_func_arg {
|
||||
SyString sName; /* Argument name */
|
||||
SySet aByteCode; /* Compiled default value associated with this argument */
|
||||
sxu32 nType; /* Type of this argument [i.e: array, int, string, float, object, etc.] */
|
||||
|
@ -1062,8 +1029,7 @@ struct ph7_vm_func_arg
|
|||
* //You should see something like this
|
||||
* string(6 'PH7awt');
|
||||
*/
|
||||
struct ph7_vm_func_static_var
|
||||
{
|
||||
struct ph7_vm_func_static_var {
|
||||
SyString sName; /* Static variable name */
|
||||
SySet aByteCode; /* Compiled initialization expression */
|
||||
sxu32 nIdx; /* Object index in the global memory object container */
|
||||
|
@ -1072,8 +1038,7 @@ struct ph7_vm_func_static_var
|
|||
* Each imported variable from the outside closure environnment is recoded
|
||||
* in an instance of the following structure.
|
||||
*/
|
||||
struct ph7_vm_func_closure_env
|
||||
{
|
||||
struct ph7_vm_func_closure_env {
|
||||
SyString sName; /* Imported variable name */
|
||||
int iFlags; /* Control flags */
|
||||
ph7_value sValue; /* Imported variable value */
|
||||
|
@ -1100,8 +1065,7 @@ struct ph7_vm_func_closure_env
|
|||
* arguments values and many more.
|
||||
* Please refer to the official documentation for more information.
|
||||
*/
|
||||
struct ph7_vm_func
|
||||
{
|
||||
struct ph7_vm_func {
|
||||
SySet aArgs; /* Expected arguments (ph7_vm_func_arg instance) */
|
||||
SySet aStatic; /* Static variable (ph7_vm_func_static_var instance) */
|
||||
SyString sName; /* Function name */
|
||||
|
@ -1124,8 +1088,7 @@ typedef struct ph7_builtin_func ph7_builtin_func;
|
|||
* Please refer to the official documentation for more information
|
||||
* on how to create/install foreign functions.
|
||||
*/
|
||||
struct ph7_builtin_func
|
||||
{
|
||||
struct ph7_builtin_func {
|
||||
const char *zName; /* Function name [i.e: strlen(), rand(), array_merge(), etc.]*/
|
||||
ProchHostFunction xFunc; /* C routine performing the computation */
|
||||
};
|
||||
|
@ -1135,8 +1098,7 @@ struct ph7_builtin_func
|
|||
* Please refer to the official documentation for more information
|
||||
* on how to create/install foreign constants.
|
||||
*/
|
||||
struct ph7_builtin_constant
|
||||
{
|
||||
struct ph7_builtin_constant {
|
||||
const char *zName; /* Constant name */
|
||||
ProcConstant xExpand; /* C routine responsible of expanding constant value*/
|
||||
};
|
||||
|
@ -1148,8 +1110,7 @@ typedef struct ph7_class_attr ph7_class_attr;
|
|||
* PH7 introduced powerfull extensions to the PHP 5 OO subsystems.
|
||||
* Please refer to the official documentation for more information.
|
||||
*/
|
||||
struct ph7_class
|
||||
{
|
||||
struct ph7_class {
|
||||
ph7_class *pBase; /* Base class if any */
|
||||
SyHash hDerived; /* Derived [child] classes */
|
||||
SyString sName; /* Class full qualified name */
|
||||
|
@ -1172,8 +1133,7 @@ struct ph7_class
|
|||
* each class attribute (variable, constants) is parsed out and stored
|
||||
* in an instance of the following structure.
|
||||
*/
|
||||
struct ph7_class_attr
|
||||
{
|
||||
struct ph7_class_attr {
|
||||
SyString sName; /* Atrribute name */
|
||||
sxi32 iFlags; /* Attribute configuration [i.e: static, variable, constant, etc.] */
|
||||
sxi32 iProtection; /* Protection level [i.e: public, private, protected] */
|
||||
|
@ -1194,8 +1154,7 @@ struct ph7_class_attr
|
|||
* arguments and many more.
|
||||
* Please refer to the official documentation for more information.
|
||||
*/
|
||||
struct ph7_class_method
|
||||
{
|
||||
struct ph7_class_method {
|
||||
ph7_vm_func sFunc; /* Compiled method body */
|
||||
SyString sVmName; /* Automatically generated name assigned to this method.
|
||||
* Typically this is "[class_name__method_name@random_string]"
|
||||
|
@ -1209,8 +1168,7 @@ struct ph7_class_method
|
|||
* Each active object (class instance) is represented by an instance of
|
||||
* the following structure.
|
||||
*/
|
||||
struct ph7_class_instance
|
||||
{
|
||||
struct ph7_class_instance {
|
||||
ph7_vm *pVm; /* VM that own this instance */
|
||||
ph7_class *pClass; /* Object is an instance of this class */
|
||||
SyHash hAttr; /* Hashtable of active class members */
|
||||
|
@ -1224,8 +1182,7 @@ struct ph7_class_instance
|
|||
* is stored in an instance of the following structure.
|
||||
*/
|
||||
typedef struct VmInstr VmInstr;
|
||||
struct VmInstr
|
||||
{
|
||||
struct VmInstr {
|
||||
sxu8 iOp; /* Operation to preform */
|
||||
sxi32 iP1; /* First operand */
|
||||
sxu32 iP2; /* Second operand (Often the jump destination) */
|
||||
|
@ -1235,8 +1192,7 @@ struct VmInstr
|
|||
* of the following structure.
|
||||
*/
|
||||
typedef struct VmClassAttr VmClassAttr;
|
||||
struct VmClassAttr
|
||||
{
|
||||
struct VmClassAttr {
|
||||
ph7_class_attr *pAttr; /* Class attribute */
|
||||
sxu32 nIdx; /* Memory object index */
|
||||
};
|
||||
|
@ -1248,8 +1204,7 @@ typedef struct VmRefObj VmRefObj;
|
|||
*/
|
||||
typedef struct ph7_exception_block ph7_exception_block;
|
||||
typedef struct ph7_exception ph7_exception;
|
||||
struct ph7_exception_block
|
||||
{
|
||||
struct ph7_exception_block {
|
||||
SyString sClass; /* Exception class name [i.e: Exception,MyException...] */
|
||||
SyString sThis; /* Instance name [i.e: $e..] */
|
||||
SySet sByteCode; /* Block compiled instructions */
|
||||
|
@ -1257,8 +1212,7 @@ struct ph7_exception_block
|
|||
/*
|
||||
* Context for the exception mechanism.
|
||||
*/
|
||||
struct ph7_exception
|
||||
{
|
||||
struct ph7_exception {
|
||||
ph7_vm *pVm; /* VM that own this exception */
|
||||
SySet sEntry; /* Compiled 'catch' blocks (ph7_exception_block instance)
|
||||
* container.
|
||||
|
@ -1272,8 +1226,7 @@ typedef struct ph7_switch ph7_switch;
|
|||
* Each compiled case block in a swicth statement is compiled
|
||||
* and stored in an instance of the following structure.
|
||||
*/
|
||||
struct ph7_case_expr
|
||||
{
|
||||
struct ph7_case_expr {
|
||||
SySet aByteCode; /* Compiled body of the case block */
|
||||
sxu32 nStart; /* First instruction to execute */
|
||||
};
|
||||
|
@ -1281,8 +1234,7 @@ struct ph7_case_expr
|
|||
* Each compiled switch statement is parsed out and stored
|
||||
* in an instance of the following structure.
|
||||
*/
|
||||
struct ph7_switch
|
||||
{
|
||||
struct ph7_switch {
|
||||
SySet aCaseExpr; /* Compile case block */
|
||||
sxu32 nOut; /* First instruction to execute after this statement */
|
||||
sxu32 nDefault; /* First instruction to execute in the default block */
|
||||
|
@ -1304,8 +1256,7 @@ typedef void (*ProcErrLog)(const char *,int,const char *,const char *);
|
|||
* resulting from compiling a PHP script.
|
||||
* This structure contains the complete state of the virtual machine.
|
||||
*/
|
||||
struct ph7_vm
|
||||
{
|
||||
struct ph7_vm {
|
||||
SyMemBackend sAllocator; /* Memory backend */
|
||||
#if defined(PH7_ENABLE_THREADS)
|
||||
SyMutex *pMutex; /* Recursive mutex associated with VM. */
|
||||
|
@ -1377,8 +1328,7 @@ struct ph7_vm
|
|||
/*
|
||||
* Error codes according to the PHP language reference manual.
|
||||
*/
|
||||
enum iErrCode
|
||||
{
|
||||
enum iErrCode {
|
||||
E_ERROR = 1, /* Fatal run-time errors. These indicate errors that can not be recovered
|
||||
* from, such as a memory allocation problem. Execution of the script is
|
||||
* halted.
|
||||
|
|
Loading…
Reference in New Issue