Changeset 588 for trunk


Ignore:
Timestamp:
2009-04-01T10:06:38+02:00 (5 years ago)
Author:
moo
Message:

handle compile time new constant. fixed #208: null as default value for parameters with array type hint produces a fatal error

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils.c

    r555 r588  
    595595#endif 
    596596 
     597static void xc_copy_zend_constant(zend_constant *c) /* {{{ */ 
     598{ 
     599    c->name = zend_strndup(c->name, c->name_len - 1); 
     600    if (!(c->flags & CONST_PERSISTENT)) { 
     601        zval_copy_ctor(&c->value); 
     602    } 
     603} 
     604/* }}} */ 
    597605xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */ 
    598606{ 
     
    632640    h = OG(zend_constants); 
    633641    zend_hash_init_ex(&TG(zend_constants),  20, NULL, h->pDestructor, h->persistent, h->bApplyProtection); 
     642    { 
     643        zend_constant tmp_const; 
     644        zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_copy_zend_constant, (void *) &tmp_const, sizeof(tmp_const)); 
     645    } 
    634646#endif 
    635647    h = OG(function_table); 
     
    679691    /* Using ZEND_COMPILE_IGNORE_INTERNAL_CLASSES for ZEND_FETCH_CLASS_RT_NS_CHECK 
    680692     */ 
    681     CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_DELAYED_BINDING; 
     693    CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION | ZEND_COMPILE_DELAYED_BINDING; 
    682694#endif 
    683695 
     
    698710 
    699711#ifdef HAVE_XCACHE_CONSTANT 
    700     b = TG(zend_constants).pListHead; 
     712    b = /*TG(internal_constant_tail) ? TG(internal_constant_tail)->pListNext :*/ TG(zend_constants).pListHead; 
    701713    /* install constants */ 
    702714    while (b != NULL) { 
  • trunk/utils.h

    r548 r588  
    9595    HashTable tmp_class_table; 
    9696    HashTable tmp_auto_globals; 
     97#ifdef HAVE_XCACHE_CONSTANT 
     98    Bucket    *tmp_internal_constant_tail; 
     99#endif 
    97100    Bucket    *tmp_internal_function_tail; 
    98101    Bucket    *tmp_internal_class_tail; 
  • trunk/xcache.c

    r572 r588  
    18491849} 
    18501850/* }}} */ 
     1851static void xc_copy_zend_constant(zend_constant *c) /* {{{ */ 
     1852{ 
     1853    c->name = zend_strndup(c->name, c->name_len - 1); 
     1854    if (!(c->flags & CONST_PERSISTENT)) { 
     1855        zval_copy_ctor(&c->value); 
     1856    } 
     1857} 
     1858/* }}} */ 
    18511859static void xc_request_init(TSRMLS_D) /* {{{ */ 
    18521860{ 
     
    18541862 
    18551863    if (!XG(internal_table_copied)) { 
     1864#ifdef HAVE_XCACHE_CONSTANT 
     1865        zend_constant tmp_const; 
     1866#endif 
    18561867        zend_function tmp_func; 
    18571868        xc_cest_t tmp_cest; 
    18581869 
     1870#ifdef HAVE_XCACHE_CONSTANT 
     1871        zend_hash_destroy(&XG(internal_constant_table)); 
     1872#endif 
    18591873        zend_hash_destroy(&XG(internal_function_table)); 
    18601874        zend_hash_destroy(&XG(internal_class_table)); 
    18611875 
     1876#ifdef HAVE_XCACHE_CONSTANT 
     1877        zend_hash_init_ex(&XG(internal_constant_table), 20,  NULL, NULL, 1, 0); 
     1878#endif 
    18621879        zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0); 
    18631880        zend_hash_init_ex(&XG(internal_class_table),    10,  NULL, NULL, 1, 0); 
    18641881 
     1882#ifdef HAVE_XCACHE_CONSTANT 
     1883        zend_hash_copy(&XG(internal_constant_table), EG(zend_constants), (copy_ctor_func_t) xc_copy_zend_constant, &tmp_const, sizeof(tmp_const)); 
     1884#endif 
    18651885        zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func)); 
    18661886        zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest)); 
     
    19211941    memset(xcache_globals, 0, sizeof(zend_xcache_globals)); 
    19221942 
     1943#ifdef HAVE_XCACHE_CONSTANT 
     1944    zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, NULL, 1, 0); 
     1945#endif 
    19231946    zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0); 
    19241947    zend_hash_init_ex(&xcache_globals->internal_class_table,    1, NULL, NULL, 1, 0); 
     
    19521975 
    19531976    if (xcache_globals->internal_table_copied) { 
     1977#ifdef HAVE_XCACHE_CONSTANT 
     1978        zend_hash_destroy(&xcache_globals->internal_constant_table); 
     1979#endif 
    19541980        zend_hash_destroy(&xcache_globals->internal_function_table); 
    19551981        zend_hash_destroy(&xcache_globals->internal_class_table); 
  • trunk/xcache_globals.h

    r508 r588  
    2222#endif 
    2323 
     24#ifdef HAVE_XCACHE_CONSTANT 
     25    HashTable internal_constant_table; 
     26#endif 
    2427    HashTable internal_function_table; 
    2528    HashTable internal_class_table; 
Note: See TracChangeset for help on using the changeset viewer.