static inline int validate_set_value_handler(set_value *set) {
switch (set->func->type) {
- case PSI_T_TO_BOOL:
- set->func->handler = psi_to_bool;
- break;
- case PSI_T_TO_INT:
- set->func->handler = psi_to_int;
- break;
- case PSI_T_TO_FLOAT:
- set->func->handler = psi_to_double;
- break;
- case PSI_T_TO_STRING:
- set->func->handler = psi_to_string;
- break;
- case PSI_T_TO_ARRAY:
- set->func->handler = psi_to_array;
- break;
- case PSI_T_TO_OBJECT:
- set->func->handler = psi_to_object;
- break;
- case PSI_T_VOID:
- set->func->handler = psi_to_void;
- break;
+ case PSI_T_TO_BOOL: set->func->handler = psi_to_bool; break;
+ case PSI_T_TO_INT: set->func->handler = psi_to_int; break;
+ case PSI_T_TO_FLOAT: set->func->handler = psi_to_double; break;
+ case PSI_T_TO_STRING: set->func->handler = psi_to_string; break;
+ case PSI_T_TO_ARRAY: set->func->handler = psi_to_array; break;
+ case PSI_T_TO_OBJECT: set->func->handler = psi_to_object; break;
+ case PSI_T_VOID: set->func->handler = psi_to_void; break;
+ case PSI_T_ZVAL: set->func->handler = psi_to_zval; break;
case PSI_T_ELLIPSIS:
if (set->outer.set && set->outer.set->func->type == PSI_T_TO_ARRAY) {
set->func->handler = psi_to_recursive;
case PSI_T_PATHVAL: func->handler = psi_let_pathval; break;
case PSI_T_ARRVAL: func->handler = psi_let_arrval; break;
case PSI_T_OBJVAL: func->handler = psi_let_objval; break;
+ case PSI_T_ZVAL: func->handler = psi_let_zval; break;
EMPTY_SWITCH_DEFAULT_CASE();
}
return 1;
RETVAL_NULL();
}
+void psi_to_zval(zval *return_value, set_value *set, impl_val *ret_val) {
+ RETVAL_ZVAL(ret_val->ptr, 1, 0);
+}
+
+impl_val *psi_let_zval(impl_val *tmp, decl_type *type, impl_arg *iarg, void **to_free)
+{
+ *to_free = tmp->ptr = emalloc(sizeof(zval));
+ ZVAL_COPY_VALUE(tmp->ptr, iarg->_zv);
+ return tmp;
+}
+
void psi_to_bool(zval *return_value, set_value *set, impl_val *ret_val)
{
psi_to_int(return_value, set, ret_val);
return tmp;
}
+
void psi_to_recursive(zval *return_value, set_value *set, impl_val *r_val);
void psi_to_array(zval *return_value, set_value *set, impl_val *ret_val);
void psi_to_object(zval *return_value, set_value *set, impl_val *ret_val);
+void psi_to_zval(zval *return_value, set_value *set, impl_val *ret_val);
void *psi_array_to_struct(decl_struct *s, HashTable *arr);
void psi_from_zval(impl_val *mem, decl_arg *spec, zval *zv, void **tmp);
impl_val *psi_let_strlen(impl_val *tmp, decl_type *type, impl_arg *iarg, void **to_free);
impl_val *psi_let_arrval(impl_val *tmp, decl_type *type, impl_arg *iarg, void **to_free);
impl_val *psi_let_objval(impl_val *tmp, decl_type *type, impl_arg *iarg, void **to_free);
+impl_val *psi_let_zval(impl_val *tmp, decl_type *type, impl_arg *iarg, void **to_free);
#endif
zend_string *str;
zend_fcall *cb;
} zend;
+ zval zval;
void *ptr;
- uint8_t _dbg[sizeof(void *)];
} impl_val;
typedef struct decl_type {
'BOOLVAL' {RETURN(PSI_T_BOOLVAL);}
'ARRVAL' {RETURN(PSI_T_ARRVAL);}
'OBJVAL' {RETURN(PSI_T_OBJVAL);}
+ 'ZVAL' {RETURN(PSI_T_ZVAL);}
'CALLOC' {RETURN(PSI_T_CALLOC);}
'TO_OBJECT' {RETURN(PSI_T_TO_OBJECT);}
'TO_ARRAY' {RETURN(PSI_T_TO_ARRAY);}
#define PSI_T_RETURN 10
#define PSI_T_CALLOC 11
#define PSI_T_CALLBACK 12
-#define PSI_T_LIB 13
-#define PSI_T_STRING 14
-#define PSI_T_EOF 15
-#define PSI_T_EOS 16
-#define PSI_T_QUOTED_STRING 17
-#define PSI_T_ENUM 18
-#define PSI_T_LBRACE 19
-#define PSI_T_RBRACE 20
-#define PSI_T_COMMA 21
-#define PSI_T_EQUALS 22
-#define PSI_T_UNION 23
-#define PSI_T_STRUCT 24
-#define PSI_T_COLON 25
-#define PSI_T_LPAREN 26
-#define PSI_T_NUMBER 27
-#define PSI_T_RPAREN 28
-#define PSI_T_BOOL 29
-#define PSI_T_INT 30
-#define PSI_T_FLOAT 31
-#define PSI_T_CONST 32
-#define PSI_T_NSNAME 33
-#define PSI_T_TYPEDEF 34
-#define PSI_T_VOID 35
-#define PSI_T_LBRACKET 36
-#define PSI_T_RBRACKET 37
-#define PSI_T_ELLIPSIS 38
-#define PSI_T_CHAR 39
-#define PSI_T_SHORT 40
-#define PSI_T_LONG 41
-#define PSI_T_DOUBLE 42
-#define PSI_T_UNSIGNED 43
-#define PSI_T_SIGNED 44
-#define PSI_T_INT8 45
-#define PSI_T_UINT8 46
-#define PSI_T_INT16 47
-#define PSI_T_UINT16 48
-#define PSI_T_INT32 49
-#define PSI_T_UINT32 50
-#define PSI_T_INT64 51
-#define PSI_T_UINT64 52
-#define PSI_T_FUNCTION 53
-#define PSI_T_NULL 54
-#define PSI_T_TRUE 55
-#define PSI_T_FALSE 56
-#define PSI_T_DOLLAR_NAME 57
-#define PSI_T_OBJVAL 58
-#define PSI_T_ARRVAL 59
-#define PSI_T_PATHVAL 60
-#define PSI_T_STRLEN 61
-#define PSI_T_STRVAL 62
-#define PSI_T_FLOATVAL 63
-#define PSI_T_INTVAL 64
-#define PSI_T_BOOLVAL 65
-#define PSI_T_TO_OBJECT 66
-#define PSI_T_TO_ARRAY 67
-#define PSI_T_TO_STRING 68
-#define PSI_T_TO_INT 69
-#define PSI_T_TO_FLOAT 70
-#define PSI_T_TO_BOOL 71
-#define PSI_T_MIXED 72
-#define PSI_T_ARRAY 73
-#define PSI_T_OBJECT 74
-#define PSI_T_CALLABLE 75
-#define PSI_T_AMPERSAND 76
+#define PSI_T_ZVAL 13
+#define PSI_T_LIB 14
+#define PSI_T_STRING 15
+#define PSI_T_EOF 16
+#define PSI_T_EOS 17
+#define PSI_T_QUOTED_STRING 18
+#define PSI_T_ENUM 19
+#define PSI_T_LBRACE 20
+#define PSI_T_RBRACE 21
+#define PSI_T_COMMA 22
+#define PSI_T_EQUALS 23
+#define PSI_T_UNION 24
+#define PSI_T_STRUCT 25
+#define PSI_T_COLON 26
+#define PSI_T_LPAREN 27
+#define PSI_T_NUMBER 28
+#define PSI_T_RPAREN 29
+#define PSI_T_BOOL 30
+#define PSI_T_INT 31
+#define PSI_T_FLOAT 32
+#define PSI_T_CONST 33
+#define PSI_T_NSNAME 34
+#define PSI_T_TYPEDEF 35
+#define PSI_T_VOID 36
+#define PSI_T_LBRACKET 37
+#define PSI_T_RBRACKET 38
+#define PSI_T_ELLIPSIS 39
+#define PSI_T_CHAR 40
+#define PSI_T_SHORT 41
+#define PSI_T_LONG 42
+#define PSI_T_DOUBLE 43
+#define PSI_T_UNSIGNED 44
+#define PSI_T_SIGNED 45
+#define PSI_T_INT8 46
+#define PSI_T_UINT8 47
+#define PSI_T_INT16 48
+#define PSI_T_UINT16 49
+#define PSI_T_INT32 50
+#define PSI_T_UINT32 51
+#define PSI_T_INT64 52
+#define PSI_T_UINT64 53
+#define PSI_T_FUNCTION 54
+#define PSI_T_NULL 55
+#define PSI_T_TRUE 56
+#define PSI_T_FALSE 57
+#define PSI_T_DOLLAR_NAME 58
+#define PSI_T_OBJVAL 59
+#define PSI_T_ARRVAL 60
+#define PSI_T_PATHVAL 61
+#define PSI_T_STRLEN 62
+#define PSI_T_STRVAL 63
+#define PSI_T_FLOATVAL 64
+#define PSI_T_INTVAL 65
+#define PSI_T_BOOLVAL 66
+#define PSI_T_TO_OBJECT 67
+#define PSI_T_TO_ARRAY 68
+#define PSI_T_TO_STRING 69
+#define PSI_T_TO_INT 70
+#define PSI_T_TO_FLOAT 71
+#define PSI_T_TO_BOOL 72
+#define PSI_T_MIXED 73
+#define PSI_T_ARRAY 74
+#define PSI_T_OBJECT 75
+#define PSI_T_CALLABLE 76
+#define PSI_T_AMPERSAND 77
%nonassoc NAME.
%left PLUS MINUS.
%left SLASH ASTERISK.
-%fallback NAME TEMP FREE SET LET RETURN CALLOC CALLBACK LIB STRING.
+%fallback NAME TEMP FREE SET LET RETURN CALLOC CALLBACK ZVAL LIB STRING.
file ::= blocks.
let_calloc(alloc) ::= num_exp(nmemb) COMMA num_exp(size). {
alloc = init_let_calloc(nmemb, size);
}
-%token_class let_func_token OBJVAL ARRVAL PATHVAL STRLEN STRVAL FLOATVAL INTVAL BOOLVAL.
+%token_class let_func_token ZVAL OBJVAL ARRVAL PATHVAL STRLEN STRVAL FLOATVAL INTVAL BOOLVAL.
%type let_func {let_func*}
%destructor let_func {free_let_func($$);}
let_func(func) ::= let_func_token(T) LPAREN impl_var(var) RPAREN. {
vals = add_inner_set_value(vals_, val);
}
-%token_class set_func_token TO_OBJECT TO_ARRAY TO_STRING TO_INT TO_FLOAT TO_BOOL VOID.
+%token_class set_func_token TO_OBJECT TO_ARRAY TO_STRING TO_INT TO_FLOAT TO_BOOL ZVAL VOID.
%type set_func {set_func*}
%destructor set_func {free_set_func($$);}
set_func(func) ::= set_func_token(T). {