ruby-changes:9844
From: shyouhei <ko1@a...>
Date: Thu, 8 Jan 2009 13:25:52 +0900 (JST)
Subject: [ruby-changes:9844] Ruby:r21385 (ruby_1_8_7): merge revision(s) 18356:
shyouhei 2009-01-08 13:25:36 +0900 (Thu, 08 Jan 2009) New Revision: 21385 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21385 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_7/ChangeLog branches/ruby_1_8_7/parse.y branches/ruby_1_8_7/version.h Index: ruby_1_8_7/parse.y =================================================================== --- ruby_1_8_7/parse.y (revision 21384) +++ ruby_1_8_7/parse.y (revision 21385) @@ -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 */ @@ -394,6 +398,7 @@ compstmt : stmts opt_terms { void_stmts($1); + fixup_nodes(&deferred_nodes); $$ = $1; } ; @@ -1080,27 +1085,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 { @@ -2689,6 +2688,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; @@ -2700,6 +2700,7 @@ in_single = 0; in_def = 0; cur_mid = 0; + deferred_nodes = 0; vp = ruby_dyna_vars; ruby_dyna_vars = vars; @@ -5376,6 +5377,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* @@ -5384,21 +5415,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 @@ -5919,6 +5948,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_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 21384) +++ ruby_1_8_7/ChangeLog (revision 21385) @@ -1,3 +1,9 @@ +Thu Jan 8 13:24:23 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:09:46 2009 Nobuyoshi Nakada <nobu@r...> * eval.c (timeofday): use monotonic clock. based on a patch Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 21384) +++ ruby_1_8_7/version.h (revision 21385) @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2009-01-07" +#define RUBY_RELEASE_DATE "2009-01-08" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20090107 -#define RUBY_PATCHLEVEL 79 +#define RUBY_RELEASE_CODE 20090108 +#define RUBY_PATCHLEVEL 80 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 7 #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/