Permalink
Browse files

- Support parent:: again

  • Loading branch information...
andigutmans committed Dec 27, 2001
1 parent a5f7a38 commit b3fd2faac06a6f9f216070b00ad46c13309fa6b3
Showing with 18 additions and 12 deletions.
  1. +5 −10 Zend/zend_compile.c
  2. +3 −1 Zend/zend_compile.h
  3. +10 −1 Zend/zend_execute.c
View
@@ -961,6 +961,11 @@ void do_fetch_class(znode *result, znode *class_entry, znode *class_name TSRMLS_
SET_UNUSED(opline->op2);
opline->extended_value = ZEND_FETCH_CLASS_SELF;
zval_dtor(&class_name->u.constant);
+ } else if ((class_name->u.constant.value.str.len == (sizeof("parent") - 1)) &&
+ !memcmp(class_name->u.constant.value.str.val, "parent", sizeof("parent"))) {
+ SET_UNUSED(opline->op2);
+ opline->extended_value = ZEND_FETCH_CLASS_PARENT;
+ zval_dtor(&class_name->u.constant);
} else if ((class_name->u.constant.value.str.len == (sizeof("main") - 1)) &&
!memcmp(class_name->u.constant.value.str.val, "main", sizeof("main"))) {
SET_UNUSED(opline->op2);
@@ -999,16 +1004,6 @@ void zend_do_begin_class_member_function_call(znode *class_name, znode *function
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_INIT_FCALL_BY_NAME;
- zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len);
- if ((class_name->u.constant.value.str.len == sizeof("parent")-1)
- && !memcmp(class_name->u.constant.value.str.val, "parent", sizeof("parent")-1)) {
- if (!CG(active_ce_parent_class_name).value.str.val) {
- zend_error(E_COMPILE_ERROR, "No parent class available");
- }
- efree(class_name->u.constant.value.str.val);
- class_name->u.constant.value.str.len = CG(active_ce_parent_class_name).value.str.len;
- class_name->u.constant.value.str.val = estrndup(CG(active_ce_parent_class_name).value.str.val, class_name->u.constant.value.str.len);
- }
opline->op1 = *class_name;
opline->op2 = *function_name;
opline->extended_value = ZEND_MEMBER_FUNC_CALL;
View
@@ -558,7 +558,9 @@ int zendlex(znode *zendlval TSRMLS_DC);
/* class fetches */
#define ZEND_FETCH_CLASS_DEFAULT 0
#define ZEND_FETCH_CLASS_SELF 1
-#define ZEND_FETCH_CLASS_MAIN 2
+#define ZEND_FETCH_CLASS_PARENT 2
+#define ZEND_FETCH_CLASS_MAIN 3
+
/* variable parsing type (compile-time) */
#define ZEND_PARSED_MEMBER (1<<0)
View
@@ -1503,7 +1503,16 @@ binary_assign_op_addr: {
} else if (EX(opline)->extended_value == ZEND_FETCH_CLASS_MAIN) {
EX(Ts)[EX(opline)->result.u.var].EA.class_entry = EG(main_class_ptr);
NEXT_OPCODE();
- }
+ } else if (EX(opline)->extended_value == ZEND_FETCH_CLASS_PARENT) {
+ if (!EG(namespace)) {
+ zend_error(E_ERROR, "Cannot fetch parent:: when no class scope is active");
+ }
+ if (!EG(namespace)->parent) {
+ zend_error(E_ERROR, "Cannot fetch parent:: as current class scope has no parent");
+ }
+ EX(Ts)[EX(opline)->result.u.var].EA.class_entry = EG(namespace)->parent;
+ NEXT_OPCODE();
+ }
class_name = get_zval_ptr(&EX(opline)->op2, EX(Ts), &EG(free_op2), BP_VAR_R);

0 comments on commit b3fd2fa

Please sign in to comment.