]> granicus.if.org Git - php/commitdiff
New $GLOBALS init
authorZeev Suraski <zeev@php.net>
Fri, 4 Jun 1999 13:09:24 +0000 (13:09 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 4 Jun 1999 13:09:24 +0000 (13:09 +0000)
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_execute.c
Zend/zend_opcode.c

index b9f5ef12762b34040af6ac007447f961e7f3e0bd..c9f6841a327afd41bee24d6dacd33cd4f0690042 100644 (file)
@@ -159,17 +159,12 @@ void do_binary_assign_op(int op, znode *result, znode *op1, znode *op2 CLS_DC)
 
 void do_fetch_globals(znode *varname CLS_DC)
 {
-       if (!CG(active_op_array)->initialized_globals
+       if (!CG(active_op_array)->uses_globals
                && varname->op_type == IS_CONST
                && varname->u.constant.type == IS_STRING
                && varname->u.constant.value.str.len == (sizeof("GLOBALS")-1)
                && !memcmp(varname->u.constant.value.str.val, "GLOBALS", sizeof("GLOBALS")-1)) {
-               zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
-
-               opline->opcode = ZEND_INIT_GLOBALS;
-               SET_UNUSED(opline->op1);
-               SET_UNUSED(opline->op2);
-               CG(active_op_array)->initialized_globals = 1;
+               CG(active_op_array)->uses_globals = 1;
        }
 }
 
index 4439d16c17068ad6eff7347fe37399c869bf9f91..7bc619336180833d4ec165c3de0775eb04593408 100644 (file)
@@ -102,7 +102,7 @@ struct _zend_op_array {
        zend_brk_cont_element *brk_cont_array;
        int last_brk_cont;
        int current_brk_cont;
-       unsigned char initialized_globals;
+       unsigned char uses_globals;
 
        /* static variables support */
        HashTable *static_variables;
@@ -482,12 +482,10 @@ int zendlex(znode *zendlval CLS_DC);
 
 #define ZEND_DECLARE_FUNCTION_OR_CLASS 91
 
-#define ZEND_INIT_GLOBALS                      92
-
-#define ZEND_EXT_STMT                          93
-#define ZEND_EXT_FCALL_BEGIN           94
-#define ZEND_EXT_FCALL_END                     95
-#define ZEND_EXT_NOP                           96
+#define ZEND_EXT_STMT                          92
+#define ZEND_EXT_FCALL_BEGIN           93
+#define ZEND_EXT_FCALL_END                     94
+#define ZEND_EXT_NOP                           95
 
 /* end of block */
 
index 0cc01e898a0a2e4e16e12fe556672ebc3e736cf9..5f8660da2074aa107a5f6e4fa397dc5d69bd0901 100644 (file)
@@ -849,6 +849,18 @@ void execute(zend_op_array *op_array ELS_DC)
         */
        function_state.function_symbol_table = NULL;
 #endif
+       
+       if (op_array->uses_globals) {
+               zval *globals = (zval *) emalloc(sizeof(zval));
+
+               globals->refcount=1;
+               globals->is_ref=1;
+               globals->type = IS_ARRAY;
+               globals->value.ht = &EG(symbol_table);
+               if (zend_hash_add(EG(active_symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL)==FAILURE) {
+                       efree(globals);
+               }
+       }
 
        while (opline<end) {
                switch(opline->opcode) {
@@ -1889,16 +1901,6 @@ send_by_ref:
                        case ZEND_DECLARE_FUNCTION_OR_CLASS:
                                do_bind_function_or_class(opline, EG(function_table), EG(class_table));
                                break;
-                       case ZEND_INIT_GLOBALS: {
-                                       zval *globals = (zval *) emalloc(sizeof(zval));
-
-                                       globals->refcount=1;
-                                       globals->is_ref=1;
-                                       globals->type = IS_ARRAY;
-                                       globals->value.ht = &EG(symbol_table);
-                                       zend_hash_add(EG(active_symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL);
-                               }
-                               break;
                        case ZEND_EXT_NOP:
                        case ZEND_NOP:
                                break;
index 0d7ac819ac0e36f3a5b3c65259c3a0fa7e735d82..96ff8687dcb0369584035f284632f12d4022a933 100644 (file)
@@ -93,7 +93,7 @@ void init_op_array(zend_op_array *op_array, int initial_ops_size)
 
        op_array->static_variables = NULL;
 
-       op_array->initialized_globals = 0;
+       op_array->uses_globals = 0;
 
        zend_llist_apply_with_argument(&zend_extensions, (void (*)(void *, void *)) zend_extension_op_array_ctor_handler, op_array);
 }