X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext.c;h=5749a73f595ecf560a8028a761757b0c814d083e;hp=6408ebeec29f374138237de87301bf4292110d38;hb=8d1d1243a8a42b0046ac670808913b3bb06c994b;hpb=4e221dbe150560ad8847606164b80020249f136e diff --git a/src/context.c b/src/context.c index 6408ebe..5749a73 100644 --- a/src/context.c +++ b/src/context.c @@ -85,10 +85,15 @@ struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_o assert(ops->call != NULL); assert(ops->compile != NULL); - /* build up predefs in a temporary PSI_Data for validation */ + /* build up predefs in a temporary psi_data for validation */ memset(&T, 0, sizeof(T)); psi_data_ctor_with_dtors(&T, error, flags); +#if PHP_DEBUG + if (psi_check_env("PSI_SKIP")) + goto skip_predefs; +#endif + for (predef_type = &psi_predef_types[0]; predef_type->type_tag; ++predef_type) { struct psi_decl_type *type = psi_decl_type_init(predef_type->type_tag, predef_type->type_name); struct psi_decl_var *var = psi_decl_var_init(predef_type->alias, 0, 0); /* FIXME: indirection */ @@ -104,7 +109,7 @@ struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_o 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; + val->ival.zend.lval = predef_const->value.zend.lval; break; case PSI_T_STRING: val = psi_impl_def_val_init(PSI_T_STRING, NULL); @@ -207,6 +212,10 @@ struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_o predef_decl = farg; } +#if PHP_DEBUG + skip_predefs: +#endif + psi_context_add_data(C, &T); return C; @@ -340,6 +349,11 @@ zend_function_entry *psi_context_compile(struct psi_context *C) name = strpprintf(0, "psi\\%s\\%s", e->name, item->name); } + if (zend_get_constant(name)) { + zend_string_release(name); + continue; + } + zc.name = zend_string_dup(name, 1); ZVAL_LONG(&zc.value, psi_long_num_exp(item->num, NULL, NULL)); zend_register_constant(&zc); @@ -380,7 +394,7 @@ ZEND_RESULT_CODE psi_context_call(struct psi_context *C, zend_execute_data *exec return FAILURE; } - psi_call_frame_do_call(frame); + C->ops->call(frame); if (SUCCESS != psi_call_frame_do_assert(frame, PSI_ASSERT_POST)) { psi_call_frame_do_return(frame, return_value);