Browse Source

Add missing data types.

pull/50/head
Rafal Kupiec 3 years ago
parent
commit
8b48786f29
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
  1. 46
      engine/compiler.c
  2. 26
      include/ph7int.h

46
engine/compiler.c

@ -2909,12 +2909,24 @@ static sxi32 PH7_GenStateCollectFuncArgs(ph7_vm_func *pFunc, ph7_gen_state *pGen
sArg.nType = MEMOBJ_HASHMAP;
} else if(nKey & PH7_KEYWORD_BOOL) {
sArg.nType = MEMOBJ_BOOL;
} else if(nKey & PH7_KEYWORD_CALLBACK) {
sArg.nType = MEMOBJ_CALL;
} else if(nKey & PH7_KEYWORD_CHAR) {
sArg.nType = MEMOBJ_CHAR;
} else if(nKey & PH7_KEYWORD_FLOAT) {
sArg.nType = MEMOBJ_REAL;
} else if(nKey & PH7_KEYWORD_INT) {
sArg.nType = MEMOBJ_INT;
} else if(nKey & PH7_KEYWORD_MIXED) {
sArg.nType = MEMOBJ_MIXED;
} else if(nKey & PH7_KEYWORD_OBJECT) {
sArg.nType = MEMOBJ_OBJ;
} else if(nKey & PH7_KEYWORD_RESOURCE) {
sArg.nType = MEMOBJ_RES;
} else if(nKey & PH7_KEYWORD_STRING) {
sArg.nType = MEMOBJ_STRING;
} else if(nKey & PH7_KEYWORD_FLOAT) {
sArg.nType = MEMOBJ_REAL;
} else if(nKey & PH7_KEYWORD_VOID) {
sArg.nType = MEMOBJ_VOID;
} else {
PH7_GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine,
"Unknown data type name '%z'",
@ -3007,23 +3019,45 @@ static sxi32 PH7_GenStateCollectFuncArgs(ph7_vm_func *pFunc, ph7_gen_state *pGen
/* Hashmap aka 'array' */
c = 'h';
break;
case MEMOBJ_BOOL:
/* Bool */
c = 'b';
break;
case MEMOBJ_CALL:
/* Callback */
c = 'a';
break;
case MEMOBJ_CHAR:
/* Callback */
c = 'c';
break;
case MEMOBJ_INT:
/* Integer */
c = 'i';
break;
case MEMOBJ_BOOL:
/* Bool */
c = 'b';
case MEMOBJ_MIXED:
/* Mixed */
c = 'm';
break;
case MEMOBJ_OBJ:
/* Object */
c = 'o';
break;
case MEMOBJ_REAL:
/* Float */
c = 'f';
break;
case MEMOBJ_RES:
/* Resource */
c = 'r';
break;
case MEMOBJ_STRING:
/* String */
c = 's';
break;
default:
case MEMOBJ_VOID:
/* Void */
c = 'v';
break;
}
SyBlobAppend(&sSig, (const void *)&c, sizeof(char));

26
include/ph7int.h

@ -631,23 +631,27 @@ struct ph7_value {
};
/* Allowed value types.
*/
#define MEMOBJ_STRING 0x001 /* Memory value is a UTF-8 string */
#define MEMOBJ_INT 0x002 /* Memory value is an integer */
#define MEMOBJ_REAL 0x004 /* Memory value is a real number */
#define MEMOBJ_BOOL 0x008 /* Memory value is a boolean */
#define MEMOBJ_NULL 0x020 /* Memory value is NULL */
#define MEMOBJ_HASHMAP 0x040 /* Memory value is a hashmap aka 'array' in the PHP jargon */
#define MEMOBJ_OBJ 0x080 /* Memory value is an object [i.e: class instance] */
#define MEMOBJ_RES 0x100 /* Memory value is a resource [User private data] */
#define MEMOBJ_REFERENCE 0x400 /* Memory value hold a reference (64-bit index) of another ph7_value */
#define MEMOBJ_BOOL 0x0001 /* Memory value is a boolean */
#define MEMOBJ_CALL 0x0002 /* Memory value is a callback */
#define MEMOBJ_CHAR 0x0004 /* Memory value is a char */
#define MEMOBJ_INT 0x0008 /* Memory value is an integer */
#define MEMOBJ_OBJ 0x0010 /* Memory value is an object [i.e: class instance] */
#define MEMOBJ_REAL 0x0020 /* Memory value is a real number */
#define MEMOBJ_RES 0x0040 /* Memory value is a resource [User private data] */
#define MEMOBJ_STRING 0x0080 /* Memory value is a UTF-8 string */
#define MEMOBJ_VOID 0x0100 /* Memory value is a void */
#define MEMOBJ_MIXED 0x0200 /* Memory value is mixed */
#define MEMOBJ_REFERENCE 0x0400 /* Memory value hold a reference (64-bit index) of another ph7_value */
#define MEMOBJ_HASHMAP 0x0800 /* Memory value is a hashmap aka 'array' in the PHP jargon */
#define MEMOBJ_NULL 0x1000 /* Memory value is NULL */
/* Mask of all known types */
#define MEMOBJ_ALL (MEMOBJ_STRING|MEMOBJ_INT|MEMOBJ_REAL|MEMOBJ_BOOL|MEMOBJ_NULL|MEMOBJ_HASHMAP|MEMOBJ_OBJ|MEMOBJ_RES)
#define MEMOBJ_ALL (MEMOBJ_STRING|MEMOBJ_INT|MEMOBJ_REAL|MEMOBJ_BOOL|MEMOBJ_NULL|MEMOBJ_HASHMAP|MEMOBJ_OBJ|MEMOBJ_RES|MEMOBJ_CALL|MEMOBJ_CHAR|MEMOBJ_VOID)
/* Scalar variables
* According to the PHP language reference manual
* Scalar variables are those containing an integer, float, string or boolean.
* Types array, object and resource are not scalar.
*/
#define MEMOBJ_SCALAR (MEMOBJ_STRING|MEMOBJ_INT|MEMOBJ_REAL|MEMOBJ_BOOL|MEMOBJ_NULL)
#define MEMOBJ_SCALAR (MEMOBJ_STRING|MEMOBJ_INT|MEMOBJ_REAL|MEMOBJ_BOOL|MEMOBJ_CHAR|MEMOBJ_VOID|MEMOBJ_NULL)
#define MEMOBJ_AUX (MEMOBJ_REFERENCE)
/*
* The following macro clear the current ph7_value type and replace

Loading…
Cancel
Save