context: avoid duplicate registration of enum constants
[m6w6/ext-psi] / src / context.c
index 584994f3fd38be672509fca4f49ea15ae26d5c1d..bc3fb4506bdd125012885e9e1274c824ccae1137 100644 (file)
@@ -332,7 +332,18 @@ zend_function_entry *psi_context_compile(struct psi_context *C)
                        struct psi_decl_enum_item *item;
 
                        while (psi_plist_get(e->items, j++, &item)) {
-                               zend_string *name = strpprintf(0, "psi\\%s\\%s", e->name, item->name);
+                               zend_string *name;
+
+                               if (psi_decl_type_is_anon(e->name, "enum")) {
+                                       name = strpprintf(0, "psi\\%s", item->name);
+                               } else {
+                                       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));
@@ -374,7 +385,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);