summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-02 04:55:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-02 04:55:07 +0000
commitab9319d886da3c2e60ff2e642b48a4c376a5cd45 (patch)
treefcc418c8c0c37f4a8be141260c8fc922727e1c81 /compile.c
parenta81979ec5502187c6c7504afded5e6bc3f6eb6ed (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/compile.c b/compile.c
index b505fbe..860d5ad 100644
--- a/compile.c
+++ b/compile.c
@@ -1240,14 +1240,21 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
++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_ANCHOR *ret, NODE * node, int poped)
/* 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 {