cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_globals.h zend_language_parser.y zend_language_scanner.l
| From: | Andrei Zmievski | Date: | Wed, 02 Apr 2003 16:51:49 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_globals.h zend_language_parser.y zend_language_scanner.l | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1101@lists.php.net to get a copy of this message | ||
andrei Wed Apr 2 11:51:49 2003 EDT
Modified files:
/ZendEngine2 zend_compile.c zend_compile.h zend_globals.h
zend_language_parser.y zend_language_scanner.l
Log:
Implement a different way to catch documentation comments.
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.406 ZendEngine2/zend_compile.c:1.407
--- ZendEngine2/zend_compile.c:1.406 Wed Apr 2 11:13:11 2003
+++ ZendEngine2/zend_compile.c Wed Apr 2 11:51:49 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.406 2003/04/02 16:13:11 andrei Exp $ */
+/* $Id: zend_compile.c,v 1.407 2003/04/02 16:51:49 andrei Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -1068,6 +1068,12 @@
}
function_token->throw_list = CG(throw_list);
CG(throw_list) = NULL;
+
+ if (CG(doc_comment)) {
+ CG(active_op_array)->doc_comment = estrndup(CG(doc_comment), CG(doc_comment_len));
+ CG(active_op_array)->doc_comment_len = CG(doc_comment_len);
+ RESET_DOC_COMMENT();
+ }
}
@@ -1077,12 +1083,6 @@
zend_do_return(NULL, 0 TSRMLS_CC);
pass_two(CG(active_op_array) TSRMLS_CC);
CG(active_op_array)->line_end = zend_get_compiled_lineno(TSRMLS_C);
-#if 0
- if (doc_comment && doc_comment->op_type != IS_UNUSED) {
- CG(active_op_array)->doc_comment = doc_comment->u.constant.value.str.val;
- CG(active_op_array)->doc_comment_len = doc_comment->u.constant.value.str.len;
- }
-#endif
CG(active_op_array) = function_token->u.op_array;
/* Pop the switch and foreach seperators */
@@ -2241,6 +2241,12 @@
opline->result.u.var = get_temporary_variable(CG(active_op_array));
opline->result.op_type = IS_CONST;
CG(implementing_class) = opline->result;
+
+ if (CG(doc_comment)) {
+ CG(active_class_entry)->doc_comment = estrndup(CG(doc_comment), CG(doc_comment_len));
+ CG(active_class_entry)->doc_comment_len = CG(doc_comment_len);
+ RESET_DOC_COMMENT();
+ }
}
@@ -2259,13 +2265,6 @@
CG(active_class_entry)->line_end = zend_get_compiled_lineno(TSRMLS_C);
-#if 0
- if (doc_comment && doc_comment->op_type != IS_UNUSED) {
- CG(active_class_entry)->doc_comment = doc_comment->u.constant.value.str.val;
- CG(active_class_entry)->doc_comment_len = doc_comment->u.constant.value.str.len;
- }
-#endif
-
if (CG(active_class_entry)->num_interfaces > 0) {
CG(active_class_entry)->interfaces = (zend_class_entry **) emalloc(sizeof(zend_class_entry
*)*CG(active_class_entry)->num_interfaces);
}
@@ -3250,7 +3249,6 @@
}
}
-
void zend_auto_global_dtor(zend_auto_global *auto_global)
{
free(auto_global->name);
@@ -3403,6 +3401,18 @@
ns_token->u.previously_active_namespace = CG(active_namespace);
CG(active_namespace) = ns;
+ if (CG(doc_comment)) {
+ /*
+ * Do not overwrite previously declared doc comment in case the namespace is
+ * split over several parts.
+ */
+ if (CG(active_namespace)->doc_comment == NULL) {
+ CG(active_namespace)->doc_comment = estrndup(CG(doc_comment), CG(doc_comment_len));
+ CG(active_namespace)->doc_comment_len = CG(doc_comment_len);
+ }
+ RESET_DOC_COMMENT();
+ }
+
/* new symbol tables */
CG(class_table) = &ns->class_table;
CG(function_table) = &ns->function_table;
@@ -3422,21 +3432,6 @@
CG(active_namespace)->filename = zend_get_compiled_filename(TSRMLS_C);
CG(active_namespace)->line_end = zend_get_compiled_lineno(TSRMLS_C);
}
-
-#if 0
- if (doc_comment && doc_comment->op_type != IS_UNUSED) {
- /*
- * Do not overwrite previously declared doc comment in case the namespace is
- * split over several parts.
- */
- if (CG(active_namespace)->doc_comment == NULL) {
- CG(active_namespace)->doc_comment = doc_comment->u.constant.value.str.val;
- CG(active_namespace)->doc_comment_len = doc_comment->u.constant.value.str.len;
- } else {
- zval_dtor(&doc_comment->u.constant);
- }
- }
-#endif
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.232 ZendEngine2/zend_compile.h:1.233
--- ZendEngine2/zend_compile.h:1.232 Wed Apr 2 11:13:11 2003
+++ ZendEngine2/zend_compile.h Wed Apr 2 11:51:49 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.232 2003/04/02 16:13:11 andrei Exp $ */
+/* $Id: zend_compile.h,v 1.233 2003/04/02 16:51:49 andrei Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -40,6 +40,12 @@
#define INC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count++); }
#define DEC_BPC(op_array) if (CG(interactive)) { ((op_array)->backpatch_count--); }
#define HANDLE_INTERACTIVE() if (CG(interactive)) { execute_new_code(TSRMLS_C); }
+
+#define RESET_DOC_COMMENT() \
+ do { \
+ CG(doc_comment) = NULL; \
+ CG(doc_comment_len) = 0; \
+ } while (0)
typedef struct _zend_op_array zend_op_array;
typedef struct _zend_op zend_op;
Index: ZendEngine2/zend_globals.h
diff -u ZendEngine2/zend_globals.h:1.122 ZendEngine2/zend_globals.h:1.123
--- ZendEngine2/zend_globals.h:1.122 Mon Mar 31 15:42:01 2003
+++ ZendEngine2/zend_globals.h Wed Apr 2 11:51:49 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_globals.h,v 1.122 2003/03/31 20:42:01 andrei Exp $ */
+/* $Id: zend_globals.h,v 1.123 2003/04/02 16:51:49 andrei Exp $ */
#ifndef ZEND_GLOBALS_H
#define ZEND_GLOBALS_H
@@ -130,6 +130,9 @@
znode implementing_class;
zend_uint access_type;
+
+ char *doc_comment;
+ zend_uint doc_comment_len;
};
Index: ZendEngine2/zend_language_parser.y
diff -u ZendEngine2/zend_language_parser.y:1.109 ZendEngine2/zend_language_parser.y:1.110
--- ZendEngine2/zend_language_parser.y:1.109 Wed Apr 2 11:13:11 2003
+++ ZendEngine2/zend_language_parser.y Wed Apr 2 11:51:49 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_language_parser.y,v 1.109 2003/04/02 16:13:11 andrei Exp $ */
+/* $Id: zend_language_parser.y,v 1.110 2003/04/02 16:51:49 andrei Exp $ */
/*
* LALR shift/reduce conflicts and how they are resolved:
@@ -179,7 +179,7 @@
statement:
- unticked_statement { zend_do_ticks(TSRMLS_C); }
+ unticked_statement { zend_do_ticks(TSRMLS_C); RESET_DOC_COMMENT(); }
;
unticked_statement:
Index: ZendEngine2/zend_language_scanner.l
diff -u ZendEngine2/zend_language_scanner.l:1.85 ZendEngine2/zend_language_scanner.l:1.86
--- ZendEngine2/zend_language_scanner.l:1.85 Wed Apr 2 11:13:12 2003
+++ ZendEngine2/zend_language_scanner.l Wed Apr 2 11:51:49 2003
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_language_scanner.l,v 1.85 2003/04/02 16:13:12 andrei Exp $ */
+/* $Id: zend_language_scanner.l,v 1.86 2003/04/02 16:51:49 andrei Exp $ */
#define yyleng SCNG(yy_leng)
#define yytext SCNG(yy_text)
@@ -124,6 +124,7 @@
{
CG(heredoc) = NULL;
CG(heredoc_len)=0;
+ RESET_DOC_COMMENT();
SCNG(yy_start_stack_ptr) = 0;
SCNG(yy_start_stack_depth) = 0;
}
@@ -135,6 +136,7 @@
efree(CG(heredoc));
CG(heredoc_len)=0;
}
+ RESET_DOC_COMMENT();
}
END_EXTERN_C()
@@ -1201,6 +1203,8 @@
}
<ST_DOC_COMMENT>"*/" {
+ CG(doc_comment) = yytext; /* no copying - intentional */
+ CG(doc_comment_len) = yyleng;
HANDLE_NEWLINES(yytext, yyleng);
BEGIN(ST_IN_SCRIPTING);
return T_DOC_COMMENT;