com php-src: Add zend_do_suspend_if_generator calls : Zend/zend_compile.c Zend/zend_compile.h Zend/ zend_language_parser.y

From: Date: Sat, 19 May 2012 18:19:45 +0000
Subject: com php-src: Add zend_do_suspend_if_generator calls : Zend/zend_compile.c Zend/zend_compile.h Zend/ zend_language_parser.y
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-70087@lists.php.net to get a copy of this message
Commit: e14cfafcbfbe58e0fc3f7b814698a908b0dffca5 Author: Nikita Popov <nikic@php.net> Sat, 19 May 2012 20:19:45 +0200 Parents: fd2a109f86d18b93d29153c2ddfa605651c7df05 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e14cfafcbfbe58e0fc3f7b814698a908b0dffca5 Log: Add zend_do_suspend_if_generator calls The execution of generator functions will be suspended right after the arguments were RECVed. This will be done in zend_do_suspend_if_generator.. Changed paths: M Zend/zend_compile.c M Zend/zend_compile.h M Zend/zend_language_parser.y Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index d2b3536..831f9f9 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2668,6 +2668,17 @@ void zend_do_yield(znode *expr TSRMLS_DC) /* {{{ */ } /* }}} */ +void zend_do_suspend_if_generator(TSRMLS_D) /* {{{ */ +{ + // we only suspend execution if the current function is a generator + if ((CG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) == 0) { + return; + } + + /* do nothing for now */ +} +/* }}} */ + static int zend_add_try_element(zend_uint try_op TSRMLS_DC) /* {{{ */ { int try_catch_offset = CG(active_op_array)->last_try_catch++; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 375f953..5365f96 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -491,6 +491,7 @@ int zend_do_begin_class_member_function_call(znode *class_name, znode *method_na void zend_do_end_function_call(znode *function_name, znode *result, const znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC); void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC); void zend_do_yield(znode *expr TSRMLS_DC); +void zend_do_suspend_if_generator(TSRMLS_D); void zend_do_handle_exception(TSRMLS_D); void zend_do_begin_lambda_function_declaration(znode *result, znode *function_token, int is_generator, int return_reference, int is_static TSRMLS_DC); diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 2fcf674..2045a5e 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -372,7 +372,8 @@ is_reference: unticked_function_declaration_statement: function is_generator is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$4, 0, $2.op_type, $3.op_type, NULL TSRMLS_CC); } - '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } + '(' parameter_list ')' { zend_do_suspend_if_generator(TSRMLS_C); } + '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); } ; unticked_class_declaration_statement: @@ -583,7 +584,8 @@ class_statement: | class_constant_declaration ';' | trait_use_statement | method_modifiers function is_generator is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$5, 1, $3.op_type, $4.op_type, &$1 TSRMLS_CC); } - '(' parameter_list ')' method_body { zend_do_abstract_method(&$5, &$1, &$10 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); } + '(' parameter_list ')' { zend_do_suspend_if_generator(TSRMLS_C); } + method_body { zend_do_abstract_method(&$5, &$1, &$11 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); } ; trait_use_statement: @@ -800,9 +802,11 @@ expr_without_variable: | '' backticks_expr '' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); } | T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); } | function is_generator is_reference { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, $3.op_type, 0 TSRMLS_CC); } - '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $4; } + '(' parameter_list ')' lexical_vars { zend_do_suspend_if_generator(TSRMLS_C); } + '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $4; } | T_STATIC function is_generator is_reference { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, $4.op_type, 1 TSRMLS_CC); } - '(' parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $5; } + '(' parameter_list ')' lexical_vars { zend_do_suspend_if_generator(TSRMLS_C); } + '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $5; } ; combined_scalar_offset:

« previous php.cvs (#70087) next »