mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
- Support constants. The following works now:
<? class foo { const GC = "foo constant\n"; } define("GC", "Global constant\n"); namespace; print GC; namespace foo; print GC; namespace; print foo::GC; ?>
This commit is contained in:
parent
250aded265
commit
055709538c
@ -2042,7 +2042,14 @@ send_by_ref:
|
||||
}
|
||||
NEXT_OPCODE();
|
||||
case ZEND_FETCH_CONSTANT:
|
||||
{
|
||||
zend_class_entry *ce;
|
||||
zval **value;
|
||||
|
||||
if (EX(opline)->op1.op_type == IS_UNUSED) {
|
||||
if (EG(namespace)) {
|
||||
ce = EG(namespace);
|
||||
} else {
|
||||
if (!zend_get_constant(EX(opline)->op2.u.constant.value.str.val, EX(opline)->op2.u.constant.value.str.len, &EX(Ts)[EX(opline)->result.u.var].tmp_var TSRMLS_CC)) {
|
||||
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
|
||||
EX(opline)->op2.u.constant.value.str.val,
|
||||
@ -2050,9 +2057,11 @@ send_by_ref:
|
||||
EX(Ts)[EX(opline)->result.u.var].tmp_var = EX(opline)->op2.u.constant;
|
||||
zval_copy_ctor(&EX(Ts)[EX(opline)->result.u.var].tmp_var);
|
||||
}
|
||||
NEXT_OPCODE();
|
||||
}
|
||||
} else {
|
||||
zend_class_entry *ce = EX(Ts)[EX(opline)->op1.u.var].EA.class_entry;
|
||||
zval **value;
|
||||
ce = EX(Ts)[EX(opline)->op1.u.var].EA.class_entry;
|
||||
}
|
||||
|
||||
if (zend_hash_find(&ce->constants, EX(opline)->op2.u.constant.value.str.val, EX(opline)->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) {
|
||||
zval_update_constant(value, (void *) 1 TSRMLS_CC);
|
||||
|
Loading…
Reference in New Issue
Block a user