ruby-changes:9842
From: shyouhei <ko1@a...>
Date: Thu, 8 Jan 2009 13:23:57 +0900 (JST)
Subject: [ruby-changes:9842] Ruby:r21383 (ruby_1_8_6): merge revision(s) 18356:
shyouhei 2009-01-08 13:23:42 +0900 (Thu, 08 Jan 2009) New Revision: 21383 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21383 Log: merge revision(s) 18356: * parse.y (deferred_nodes, compstmt, arg, fixup_nodes, range_op): fix up fixnum range literal in conditional as automagical line number comparison. [ruby-core:12124], [ruby-dev:35731] Modified files: branches/ruby_1_8_6/ChangeLog branches/ruby_1_8_6/parse.y branches/ruby_1_8_6/version.h Index: ruby_1_8_6/parse.y =================================================================== --- ruby_1_8_6/parse.y (revision 21382) +++ ruby_1_8_6/parse.y (revision 21383) @@ -124,6 +124,8 @@ static ID cur_mid = 0; static int command_start = Qtrue; +static NODE *deferred_nodes; + static NODE *cond(); static NODE *logop(); static int cond_negative(); @@ -181,6 +183,8 @@ static void top_local_init(); static void top_local_setup(); +static void fixup_nodes(); + #define RE_OPTION_ONCE 0x80 #define NODE_STRTERM NODE_ZARRAY /* nothing to gc */ @@ -391,6 +395,7 @@ compstmt : stmts opt_terms { void_stmts($1); + fixup_nodes(&deferred_nodes); $$ = $1; } ; @@ -1077,27 +1082,21 @@ { value_expr($1); value_expr($3); + $$ = NEW_DOT2($1, $3); if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { - $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qfalse); - $$ = $1; + deferred_nodes = list_append(deferred_nodes, $$); } - else { - $$ = NEW_DOT2($1, $3); - } } | arg tDOT3 arg { value_expr($1); value_expr($3); + $$ = NEW_DOT3($1, $3); if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { - $1->nd_lit = rb_range_new($1->nd_lit, $3->nd_lit, Qtrue); - $$ = $1; + deferred_nodes = list_append(deferred_nodes, $$); } - else { - $$ = NEW_DOT3($1, $3); - } } | arg '+' arg { @@ -2621,6 +2620,7 @@ lex_strterm = 0; ruby_current_node = 0; ruby_sourcefile = rb_source_filename(f); + deferred_nodes = 0; n = yyparse(); ruby_debug_lines = 0; compile_for_eval = 0; @@ -2632,6 +2632,7 @@ in_single = 0; in_def = 0; cur_mid = 0; + deferred_nodes = 0; vp = ruby_dyna_vars; ruby_dyna_vars = vars; @@ -5308,6 +5309,36 @@ if (!e_option_supplied()) parser_warning(node, str); } +static void +fixup_nodes(rootnode) + NODE **rootnode; +{ + NODE *node, *next, *head; + + for (node = *rootnode; node; node = next) { + enum node_type type; + VALUE val; + + next = node->nd_next; + head = node->nd_head; + rb_gc_force_recycle((VALUE)node); + *rootnode = next; + switch (type = nd_type(head)) { + case NODE_DOT2: + case NODE_DOT3: + val = rb_range_new(head->nd_beg->nd_lit, head->nd_end->nd_lit, + type == NODE_DOT3 ? Qtrue : Qfalse); + rb_gc_force_recycle((VALUE)head->nd_beg); + rb_gc_force_recycle((VALUE)head->nd_end); + nd_set_type(head, NODE_LIT); + head->nd_lit = val; + break; + default: + break; + } + } +} + static NODE *cond0(); static NODE* @@ -5316,21 +5347,19 @@ { enum node_type type; - if (!e_option_supplied()) return node; if (node == 0) return 0; - value_expr(node); - node = cond0(node); type = nd_type(node); if (type == NODE_NEWLINE) { node = node->nd_next; type = nd_type(node); } + value_expr(node); if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) { warn_unless_e_option(node, "integer literal in conditional range"); return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$."))); } - return node; + return cond0(node); } static int @@ -5847,6 +5876,7 @@ rb_gc_mark(lex_lastline); rb_gc_mark(lex_input); rb_gc_mark((VALUE)lex_strterm); + rb_gc_mark((VALUE)deferred_nodes); } void Index: ruby_1_8_6/ChangeLog =================================================================== --- ruby_1_8_6/ChangeLog (revision 21382) +++ ruby_1_8_6/ChangeLog (revision 21383) @@ -1,3 +1,9 @@ +Thu Jan 8 13:20:15 2009 Nobuyoshi Nakada <nobu@r...> + + * parse.y (deferred_nodes, compstmt, arg, fixup_nodes, range_op): fix + up fixnum range literal in conditional as automagical line number + comparison. [ruby-core:12124], [ruby-dev:35731] + Wed Jan 7 10:06:12 2009 Nobuyoshi Nakada <nobu@r...> * eval.c (timeofday): use monotonic clock. based on a patch Index: ruby_1_8_6/version.h =================================================================== --- ruby_1_8_6/version.h (revision 21382) +++ ruby_1_8_6/version.h (revision 21383) @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.6" -#define RUBY_RELEASE_DATE "2009-01-07" +#define RUBY_RELEASE_DATE "2009-01-08" #define RUBY_VERSION_CODE 186 -#define RUBY_RELEASE_CODE 20090107 -#define RUBY_PATCHLEVEL 292 +#define RUBY_RELEASE_CODE 20090108 +#define RUBY_PATCHLEVEL 293 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 6 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 7 +#define RUBY_RELEASE_DAY 8 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/