ruby-changes:36599
From: nobu <ko1@a...>
Date: Tue, 2 Dec 2014 13:55:17 +0900 (JST)
Subject: [ruby-changes:36599] nobu:r48680 (trunk): compile.c: set true and false directly
nobu 2014-12-02 13:55:07 +0900 (Tue, 02 Dec 2014) New Revision: 48680 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48680 Log: compile.c: set true and false directly * compile.c (iseq_set_arguments): directly set true and false default values not only nil to keyword arguments. Modified files: trunk/compile.c Index: compile.c =================================================================== --- compile.c (revision 48679) +++ compile.c (revision 48680) @@ -1240,14 +1240,21 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L1240 ++rkw; } else { - if (nd_type(val_node) == NODE_LIT) { + switch (nd_type(val_node)) { + case NODE_LIT: dv = val_node->nd_lit; iseq_add_mark_object(iseq, dv); - } - else if (nd_type(val_node) == NODE_NIL) { + break; + case NODE_NIL: dv = Qnil; - } - else { + break; + case NODE_TRUE: + dv = Qtrue; + break; + case NODE_FALSE: + dv = Qfalse; + break; + default: COMPILE_POPED(optargs, "kwarg", node); /* nd_type(node) == NODE_KW_ARG */ dv = complex_mark; } @@ -5358,7 +5365,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5365 /* required argument. do nothing */ rb_bug("unreachable"); } - else if (nd_type(default_value) == NODE_LIT) { + else if (nd_type(default_value) == NODE_LIT || + nd_type(default_value) == NODE_NIL || + nd_type(default_value) == NODE_TRUE || + nd_type(default_value) == NODE_FALSE) { rb_bug("unreachable"); } else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/