X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcontext.c;h=d4510ebc579d1af794c4bd89b8c563c4b373d935;hb=6d8fda8d1cd382e6d6626df5353d285176bd9bf2;hp=11b2abd00dcf1265e607e8b23e378aeaa7dfa316;hpb=f74ce3f29e2dadd9f839c33ad5292e56e9203efd;p=m6w6%2Fext-psi diff --git a/src/context.c b/src/context.c index 11b2abd..d4510eb 100644 --- a/src/context.c +++ b/src/context.c @@ -97,10 +97,25 @@ struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_o T.types = psi_plist_add(T.types, &def); } for (predef_const = &psi_predef_consts[0]; predef_const->type_tag; ++predef_const) { - struct psi_impl_def_val *val = psi_impl_def_val_init(predef_const->val_type_tag, predef_const->val_text); struct psi_const_type *type = psi_const_type_init(predef_const->type_tag, predef_const->type_name); - struct psi_const *constant = psi_const_init(type, predef_const->var_name, val); + struct psi_impl_def_val *val; + struct psi_const *constant; + switch (type->type) { + case PSI_T_INT: + val = psi_impl_def_val_init(PSI_T_INT, NULL); + val->ival.zend.lval = predef_const->value.lval; + break; + case PSI_T_STRING: + val = psi_impl_def_val_init(PSI_T_STRING, NULL); + val->ival.zend.str = zend_string_init(predef_const->value.ptr, strlen(predef_const->value.ptr), 1); + break; + default: + assert(0); + break; + } + + constant = psi_const_init(type, predef_const->var_name, val); T.consts = psi_plist_add(T.consts, &constant); } for (predef_composite = &psi_predef_composites[0]; predef_composite->type_tag; ++predef_composite) { @@ -289,7 +304,7 @@ zend_function_entry *psi_context_compile(struct psi_context *C) continue; } - zc.name = zend_string_init(c->name + (c->name[0] == '\\'), strlen(c->name) - (c->name[0] == '\\'), 1); + zc.name = zend_string_init(c->name, strlen(c->name), 1); switch (c->type->type) { case PSI_T_BOOL: @@ -303,7 +318,7 @@ zend_function_entry *psi_context_compile(struct psi_context *C) break; case PSI_T_STRING: case PSI_T_QUOTED_STRING: - ZVAL_NEW_STR(&zc.value, zend_string_init(c->val->text, strlen(c->val->text), 1)); + ZVAL_NEW_STR(&zc.value, zend_string_copy(c->val->ival.zend.str)); break; default: assert(0); @@ -358,7 +373,22 @@ ZEND_RESULT_CODE psi_context_call(struct psi_context *C, zend_execute_data *exec return FAILURE; } + if (SUCCESS != psi_call_frame_do_assert(frame, PSI_ASSERT_PRE)) { + psi_call_frame_do_return(frame, return_value); + psi_call_frame_free(frame); + + return FAILURE; + } + psi_call_frame_do_call(frame); + + if (SUCCESS != psi_call_frame_do_assert(frame, PSI_ASSERT_POST)) { + psi_call_frame_do_return(frame, return_value); + psi_call_frame_free(frame); + + return FAILURE; + } + psi_call_frame_do_return(frame, return_value); psi_call_frame_do_set(frame); psi_call_frame_do_free(frame);