X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Fnum_exp.h;h=7ec62e1c02cffe5679853e05c457a2cac6704546;hb=ad2c22df5e451fffecc7b7ebdc9c5a4bb36e543e;hp=ba44807020a44edbcf28febacc2648bd927cba2a;hpb=3b0b651ea1b555d8d023e45b43e5eb93b23d00a1;p=m6w6%2Fext-psi diff --git a/src/types/num_exp.h b/src/types/num_exp.h index ba44807..7ec62e1 100644 --- a/src/types/num_exp.h +++ b/src/types/num_exp.h @@ -46,17 +46,31 @@ struct psi_num_exp { struct psi_num_exp *lhs; struct psi_num_exp *rhs; } b; + struct { + struct psi_decl_type *typ; + struct psi_num_exp *num; + } c; + struct { + struct psi_num_exp *cond; + struct psi_num_exp *truthy; + struct psi_num_exp *falsy; + } t; struct psi_num_exp *u; struct psi_number *n; } data; token_t (*calc)(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res); }; +struct psi_num_exp *psi_num_exp_init_ternary(token_t op, + struct psi_num_exp *cond, struct psi_num_exp *truthy, + struct psi_num_exp *falsy); struct psi_num_exp *psi_num_exp_init_binary(token_t op, struct psi_num_exp *lhs, struct psi_num_exp *rhs); struct psi_num_exp *psi_num_exp_init_unary(token_t op, struct psi_num_exp *u); struct psi_num_exp *psi_num_exp_init_num(struct psi_number *n); +struct psi_num_exp *psi_num_exp_init_cast(struct psi_decl_type *typ, + struct psi_num_exp *num); void psi_num_exp_free(struct psi_num_exp **c_ptr); struct psi_num_exp *psi_num_exp_copy(struct psi_num_exp *exp); @@ -66,14 +80,16 @@ bool psi_num_exp_validate(struct psi_data *data, struct psi_num_exp *exp, struct psi_let_exp *current_let, struct psi_set_exp *current_set, struct psi_decl_enum *current_enum); -token_t psi_num_exp_exec(struct psi_num_exp *exp, impl_val *res, struct psi_call_frame *frame); +token_t psi_num_exp_exec(struct psi_num_exp *exp, impl_val *res, + struct psi_call_frame *frame, HashTable *defs); #include -static inline zend_long psi_long_num_exp(struct psi_num_exp *exp, struct psi_call_frame *frame) { +static inline zend_long psi_long_num_exp(struct psi_num_exp *exp, + struct psi_call_frame *frame, HashTable *defs) { impl_val val = {0}; - switch (psi_num_exp_exec(exp, &val, frame)) { + switch (psi_num_exp_exec(exp, &val, frame, defs)) { case PSI_T_UINT8: return val.u8; case PSI_T_UINT16: return val.u16; case PSI_T_UINT32: return val.u32;