[前][次][番号順一覧][スレッド一覧]

ruby-changes:49493

From: mame <ko1@a...>
Date: Fri, 5 Jan 2018 17:59:26 +0900 (JST)
Subject: [ruby-changes:49493] mame:r61608 (trunk): node.h: define rb_ast_body_t and restructure rb_ast_t

mame	2018-01-05 17:59:20 +0900 (Fri, 05 Jan 2018)

  New Revision: 61608

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61608

  Log:
    node.h: define rb_ast_body_t and restructure rb_ast_t

  Modified files:
    trunk/iseq.c
    trunk/load.c
    trunk/node.c
    trunk/node.h
    trunk/parse.y
    trunk/ruby.c
    trunk/template/prelude.c.tmpl
    trunk/vm_eval.c
Index: iseq.c
===================================================================
--- iseq.c	(revision 61607)
+++ iseq.c	(revision 61608)
@@ -708,7 +708,7 @@ rb_iseq_compile_with_option(VALUE src, V https://github.com/ruby/ruby/blob/trunk/iseq.c#L708
 	ast = (*parse)(parser, file, src, ln);
     }
 
-    if (!ast->root) {
+    if (!ast->body.root) {
 	rb_ast_dispose(ast);
 	rb_exc_raise(GET_EC()->errinfo);
     }
@@ -716,7 +716,7 @@ rb_iseq_compile_with_option(VALUE src, V https://github.com/ruby/ruby/blob/trunk/iseq.c#L716
 	INITIALIZED VALUE label = parent ?
 	    parent->body->location.label :
 	    rb_fstring_cstr("<compiled>");
-	iseq = rb_iseq_new_with_opt(ast->root, label, file, realpath, line,
+	iseq = rb_iseq_new_with_opt(ast->body.root, label, file, realpath, line,
 				    parent, type, &option);
 	rb_ast_dispose(ast);
     }
@@ -927,17 +927,17 @@ iseqw_s_compile_file(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/iseq.c#L927
     parser = rb_parser_new();
     rb_parser_set_context(parser, NULL, FALSE);
     ast = rb_parser_compile_file_path(parser, file, f, NUM2INT(line));
-    if (!ast->root) exc = GET_EC()->errinfo;
+    if (!ast->body.root) exc = GET_EC()->errinfo;
 
     rb_io_close(f);
-    if (!ast->root) {
+    if (!ast->body.root) {
 	rb_ast_dispose(ast);
 	rb_exc_raise(exc);
     }
 
     make_compile_option(&option, opt);
 
-    ret = iseqw_new(rb_iseq_new_with_opt(ast->root, rb_fstring_cstr("<main>"),
+    ret = iseqw_new(rb_iseq_new_with_opt(ast->body.root, rb_fstring_cstr("<main>"),
 					 file,
 					 rb_realpath_internal(Qnil, file, 1),
 					 line, NULL, ISEQ_TYPE_TOP, &option));
Index: load.c
===================================================================
--- load.c	(revision 61607)
+++ load.c	(revision 61608)
@@ -604,7 +604,7 @@ rb_load_internal0(rb_execution_context_t https://github.com/ruby/ruby/blob/trunk/load.c#L604
 	    VALUE parser = rb_parser_new();
 	    rb_parser_set_context(parser, NULL, FALSE);
 	    ast = (rb_ast_t *)rb_parser_load_file(parser, fname);
-	    iseq = rb_iseq_new_top(ast->root, rb_fstring_cstr("<top (required)>"),
+	    iseq = rb_iseq_new_top(ast->body.root, rb_fstring_cstr("<top (required)>"),
 			    fname, rb_realpath_internal(Qnil, fname, 1), NULL);
 	    rb_ast_dispose(ast);
 	}
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 61607)
+++ vm_eval.c	(revision 61608)
@@ -1272,8 +1272,8 @@ eval_make_iseq(VALUE src, VALUE fname, i https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1272
 
     rb_parser_set_context(parser, base_block, FALSE);
     ast = rb_parser_compile_string_path(parser, fname, src, line);
-    if (ast->root) {
-	iseq = rb_iseq_new_with_opt(ast->root,
+    if (ast->body.root) {
+	iseq = rb_iseq_new_with_opt(ast->body.root,
 				    parent->body->location.label,
 				    fname, realpath, INT2FIX(line),
 				    parent, ISEQ_TYPE_EVAL, NULL);
Index: template/prelude.c.tmpl
===================================================================
--- template/prelude.c.tmpl	(revision 61607)
+++ template/prelude.c.tmpl	(revision 61608)
@@ -161,11 +161,11 @@ prelude_eval(VALUE code, VALUE name, int https://github.com/ruby/ruby/blob/trunk/template/prelude.c.tmpl#L161
     };
 
     rb_ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
-    if (!ast->root) {
+    if (!ast->body.root) {
 	rb_ast_dispose(ast);
 	rb_exc_raise(rb_errinfo());
     }
-    rb_iseq_eval(rb_iseq_new_with_opt(ast->root, name, name, Qnil, INT2FIX(line),
+    rb_iseq_eval(rb_iseq_new_with_opt(ast->body.root, name, name, Qnil, INT2FIX(line),
 				      NULL, ISEQ_TYPE_TOP, &optimization));
     rb_ast_dispose(ast);
 }
Index: ruby.c
===================================================================
--- ruby.c	(revision 61607)
+++ ruby.c	(revision 61608)
@@ -1704,7 +1704,7 @@ process_options(int argc, char **argv, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1704
 	rb_enc_set_default_internal(Qnil);
     rb_stdio_set_default_encoding();
 
-    if (!ast->root) {
+    if (!ast->body.root) {
 	rb_ast_dispose(ast);
 	return Qfalse;
     }
@@ -1726,7 +1726,7 @@ process_options(int argc, char **argv, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1726
     }
 
     if (dump & (DUMP_BIT(parsetree)|DUMP_BIT(parsetree_with_comment))) {
-	rb_io_write(rb_stdout, rb_parser_dump_tree(ast->root, dump & DUMP_BIT(parsetree_with_comment)));
+	rb_io_write(rb_stdout, rb_parser_dump_tree(ast->body.root, dump & DUMP_BIT(parsetree_with_comment)));
 	rb_io_flush(rb_stdout);
 	dump &= ~DUMP_BIT(parsetree)&~DUMP_BIT(parsetree_with_comment);
 	if (!dump) {
@@ -1749,7 +1749,7 @@ process_options(int argc, char **argv, r https://github.com/ruby/ruby/blob/trunk/ruby.c#L1749
 	    }
 	}
 	base_block = toplevel_context(toplevel_binding);
-	iseq = rb_iseq_new_main(ast->root, opt->script_name, path, vm_block_iseq(base_block));
+	iseq = rb_iseq_new_main(ast->body.root, opt->script_name, path, vm_block_iseq(base_block));
 	rb_ast_dispose(ast);
     }
 
Index: parse.y
===================================================================
--- parse.y	(revision 61607)
+++ parse.y	(revision 61608)
@@ -5675,7 +5675,7 @@ yycompile(VALUE vparser, struct parser_p https://github.com/ruby/ruby/blob/trunk/parse.y#L5675
     ruby_sourceline = line - 1;
 
     parser->ast = ast = rb_ast_new();
-    ast->root = (NODE *)rb_suppress_tracing(yycompile0, (VALUE)parser);
+    ast->body.root = (NODE *)rb_suppress_tracing(yycompile0, (VALUE)parser);
     parser->ast = 0;
     RB_GC_GUARD(vparser); /* prohibit tail call optimization */
 
Index: node.c
===================================================================
--- node.c	(revision 61607)
+++ node.c	(revision 61608)
@@ -1150,7 +1150,7 @@ rb_ast_delete_node(rb_ast_t *ast, NODE * https://github.com/ruby/ruby/blob/trunk/node.c#L1150
 rb_ast_t *
 rb_ast_new(void)
 {
-    return (rb_ast_t *)rb_imemo_new(imemo_ast, 0, (VALUE)rb_node_buffer_new(), rb_ary_tmp_new(0), 0);
+    return (rb_ast_t *)rb_imemo_new(imemo_ast, rb_ary_tmp_new(0), 0, 0, (VALUE)rb_node_buffer_new());
 }
 
 void
Index: node.h
===================================================================
--- node.h	(revision 61607)
+++ node.h	(revision 61608)
@@ -467,12 +467,15 @@ RUBY_SYMBOL_EXPORT_BEGIN https://github.com/ruby/ruby/blob/trunk/node.h#L467
 
 typedef struct node_buffer_struct node_buffer_t;
 /* T_IMEMO/ast */
+typedef struct rb_ast_body_struct {
+    const NODE *root;
+    VALUE reserved;
+} rb_ast_body_t;
 typedef struct rb_ast_struct {
     VALUE flags;
-    VALUE reserved1;
-    const NODE *root;
     node_buffer_t *node_buffer;
     VALUE mark_ary;
+    rb_ast_body_t body;
 } rb_ast_t;
 rb_ast_t *rb_ast_new();
 void rb_ast_mark(rb_ast_t*);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]