diff options
author | Andi Gutmans <andi@php.net> | 2002-11-20 18:00:23 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2002-11-20 18:00:23 +0000 |
commit | 227f7838d6555b13a322829d786d8b38ac299e86 (patch) | |
tree | e24506a95c0bb02643ebca34cd5ce8a01cf6a07d /Zend | |
parent | a257d758a5b71a0513b63360e64c38220aeab4c3 (diff) | |
download | php-git-227f7838d6555b13a322829d786d8b38ac299e86.tar.gz |
- 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.
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/zend_compile.c | 9 | ||||
-rw-r--r-- | Zend/zend_compile.h | 4 | ||||
-rw-r--r-- | Zend/zend_execute.c | 15 | ||||
-rw-r--r-- | Zend/zend_language_parser.y | 3 | ||||
-rw-r--r-- | Zend/zend_language_scanner.l | 5 |
5 files changed, 32 insertions, 4 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index aa31534db4..d0b6d65e91 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -378,6 +378,15 @@ void zend_do_echo(znode *arg TSRMLS_DC) 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) { diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 14a5029c68..f793bb0688 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -393,6 +393,8 @@ void zend_do_begin_import(TSRMLS_D); 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 @@ -608,6 +610,8 @@ int zendlex(znode *zendlval TSRMLS_DC); #define ZEND_DECLARE_INHERITED_CLASS 140 #define ZEND_DECLARE_FUNCTION 141 +#define ZEND_RAISE_ABSTRACT_ERROR 142 + /* end of block */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index a50ce095a2..9b9ffd0d98 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -3567,21 +3567,28 @@ int zend_exit_handler(ZEND_OPCODE_HANDLER_ARGS) 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 @@ void zend_init_opcodes_handlers() 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; } diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 8609c16a71..89217ee7d4 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -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 @@ class_statement: | 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: diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index dd6d5637fe..57fe3fc8bf 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -726,6 +726,10 @@ NEWLINE ("\r"|"\n"|"\r\n") return T_STATIC; } +<ST_IN_SCRIPTING>"abstract" { + return T_ABSTRACT; +} + <ST_IN_SCRIPTING>"private" { return T_PRIVATE; } @@ -738,7 +742,6 @@ NEWLINE ("\r"|"\n"|"\r\n") return T_VAR; } - <ST_IN_SCRIPTING>"unset" { return T_UNSET; } |