Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_execute.c zend_language_parser.y zend_language_scanner.l

From: Date: Thu, 21 Nov 2002 12:41:06 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_execute.c zend_language_parser.y zend_language_scanner.l
References: 1  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-646@lists.php.net to get a copy of this message
In zend_compile.h it must be void zend_do_abstract_method(TSRMLS_D); instead of TSRMLS_C. marcus At 19:00 20.11.2002, Andi Gutmans wrote:
andi            Wed Nov 20 13:00:24 2002 EDT
Modified files:
    /ZendEngine2        zend_compile.c zend_compile.h zend_execute.c
                        zend_language_parser.y zend_language_scanner.l
Log: - Fix build (thanks Marcus) - Implement abstract methods, syntax:
  -    abstract function foo($vars);
- I don't see any reason why modifiers such as static/public need to be - used with abstract. PHP is weakly typed and there would be no meaning to - this anyway. People who want a strictly typed compiled language are - looking in the wrong place. Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.323 ZendEngine2/zend_compile.c:1.324
--- ZendEngine2/zend_compile.c:1.323    Sun Nov 10 17:02:28 2002
+++ ZendEngine2/zend_compile.c Wed Nov 20 13:00:21 2002 @@ -378,6 +378,15 @@
        SET_UNUSED(opline->op2);
} +void zend_do_abstract_method(TSRMLS_D) +{
+       zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
+
+       opline->opcode = ZEND_RAISE_ABSTRACT_ERROR;
+       SET_UNUSED(opline->op1);
+       SET_UNUSED(opline->op2);
+} + void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC) { Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.192 ZendEngine2/zend_compile.h:1.193
--- ZendEngine2/zend_compile.h:1.192    Sun Nov 10 12:50:27 2002
+++ ZendEngine2/zend_compile.h Wed Nov 20 13:00:21 2002 @@ -393,6 +393,8 @@ void zend_do_import(int type, znode *what TSRMLS_DC); void zend_do_end_import(znode *import_from TSRMLS_DC); +void zend_do_abstract_method(TSRMLS_C); + ZEND_API void function_add_ref(zend_function *function); #define INITIAL_OP_ARRAY_SIZE 64 @@ -607,6 +609,8 @@
 #define ZEND_DECLARE_CLASS                             139
#define ZEND_DECLARE_INHERITED_CLASS 140
 #define ZEND_DECLARE_FUNCTION                  141
+
+#define ZEND_RAISE_ABSTRACT_ERROR      142
/* end of block */ Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.394 ZendEngine2/zend_execute.c:1.395
--- ZendEngine2/zend_execute.c:1.394    Tue Nov 19 12:51:30 2002
+++ ZendEngine2/zend_execute.c Wed Nov 20 13:00:22 2002 @@ -3567,21 +3567,28 @@ int zend_begin_silence_handler(ZEND_OPCODE_HANDLER_ARGS) {
-       EX(Ts)[EX(opline)->result.u.var].tmp_var.value.lval = EG(error_reporting);
-       EX(Ts)[EX(opline)->result.u.var].tmp_var.type = IS_LONG;  /* shouldn't be necessary */
+       EX_T(EX(opline)->result.u.var).tmp_var.value.lval = EG(error_reporting);
+       EX_T(EX(opline)->result.u.var).tmp_var.type = IS_LONG;  /* shouldn't be necessary */
        zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
        NEXT_OPCODE();
} +int zend_raise_abstract_error_handler(ZEND_OPCODE_HANDLER_ARGS) +{
+       zend_error(E_ERROR, "Cannot call abstract method");
+       NEXT_OPCODE(); /* Never reached */
+} + int zend_end_silence_handler(ZEND_OPCODE_HANDLER_ARGS) {
        zval restored_error_reporting;
        restored_error_reporting.type = IS_LONG;
-       restored_error_reporting.value.lval = EX(Ts)[EX(opline)->op1.u.var].tmp_var.value.lval;
+       restored_error_reporting.value.lval = EX_T(EX(opline)->op1.u.var).tmp_var.value.lval;
        convert_to_string(&restored_error_reporting);
        zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
        zendi_zval_dtor(restored_error_reporting);
+       NEXT_OPCODE();
} int zend_qm_assign_handler(ZEND_OPCODE_HANDLER_ARGS) @@ -3839,4 +3846,6 @@
        zend_opcode_handlers[ZEND_DECLARE_CLASS] = zend_declare_class_handler;
        zend_opcode_handlers[ZEND_DECLARE_INHERITED_CLASS] = zend_declare_inherited_class_handler;
        zend_opcode_handlers[ZEND_DECLARE_FUNCTION] = zend_declare_function_handler;
+
+       zend_opcode_handlers[ZEND_RAISE_ABSTRACT_ERROR] = zend_raise_abstract_error_handler;
} Index: ZendEngine2/zend_language_parser.y diff -u ZendEngine2/zend_language_parser.y:1.76 ZendEngine2/zend_language_parser.y:1.77
--- ZendEngine2/zend_language_parser.y:1.76     Sun Nov 10 12:50:27 2002
+++ ZendEngine2/zend_language_parser.y Wed Nov 20 13:00:23 2002 @@ -111,6 +111,7 @@ %token T_USE %token T_GLOBAL %token T_STATIC +%token T_ABSTRACT %token T_PRIVATE %token T_PROTECTED %token T_VAR @@ -441,6 +442,8 @@
        |       is_static T_FUNCTION { $2.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$5, 1, $4.op_type, $1.u.constant.value.lval TSRMLS_CC); } '('
                        parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); }
        |       T_CLASS T_STRING extends_from '{' { zend_do_begin_class_declaration(&$1, &$2, &$3 TSRMLS_CC); } class_statement_list '}' { zend_do_end_class_declaration(&$1 TSRMLS_CC); }
+       |       T_ABSTRACT T_FUNCTION { $2.u.opline_num = CG(zend_lineno); } is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$5, 1, $4.op_type, $1.u.constant.value.lval TSRMLS_CC); } '('
+                       parameter_list ')' { zend_do_abstract_method(TSRMLS_C); zend_do_end_function_declaration(&$2 TSRMLS_CC); }
; is_static: Index: ZendEngine2/zend_language_scanner.l diff -u ZendEngine2/zend_language_scanner.l:1.65 ZendEngine2/zend_language_scanner.l:1.66
--- ZendEngine2/zend_language_scanner.l:1.65    Mon Nov 18 00:27:46 2002
+++ ZendEngine2/zend_language_scanner.l Wed Nov 20 13:00:23 2002 @@ -726,6 +726,10 @@
        return T_STATIC;
} +<ST_IN_SCRIPTING>"abstract" {
+       return T_ABSTRACT;
+} + <ST_IN_SCRIPTING>"private" {
        return T_PRIVATE;
} @@ -737,7 +741,6 @@ <ST_IN_SCRIPTING>"public" {
        return T_VAR;
} - <ST_IN_SCRIPTING>"unset" {
        return T_UNSET;
-- Zend Engine CVS Mailing List (http://cvs.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.zend-engine.cvs (#646) next »