summaryrefslogtreecommitdiff
path: root/ext/objspace
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-31 00:46:30 (GMT)
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-31 00:46:30 (GMT)
commita09e1750682ee19b21c5785f34f3db39e15a2f2e (patch)
treee4a888d5da822653a45addc4a319684c9d46e543 /ext/objspace
parentbb88b1aab8ce5aad01e11f1dbd574ab46ac44648 (diff)
Use NODE_CASE2 if case expressions don't exist
When NODE_WHEN is compiled by iseq_compile_each0, the node passed to compile_when is NODE_WHEN (not NODE_CASE). So we can not handle the location of NODE_CASE of case statements which don't have case expressions. e.g. : ``` case; when 1; foo; when 2; bar; else baz; end ``` This commit adds NODE_CASE2, and compiles it by iseq_compile_each0. * compile.c (compile_case): Does not call COMPILE_ when NODE_CASE does not have case expressions. * compile.c (compile_case2): Compile NODE_CASE2 by compile_case2. * compile.c (compile_when): Delete an obsoleted function. * compile.c (iseq_compile_each0): Compile NODE_CASE2. * ext/objspace/objspace.c (count_nodes): Add NODE_CASE2 case. * node.c (dump_node, rb_gc_mark_node): Add NODE_CASE2 case. * node.h (node_type): Add NODE_CASE2. * node.h (NEW_CASE2): Add a macro which generates NODE_CASE2. * parse.y: Generate NODE_CASE2 if case expressions don't exist. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/objspace')
-rw-r--r--ext/objspace/objspace.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index 38995d4..acc6231 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -376,6 +376,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_IF);
COUNT_NODE(NODE_UNLESS);
COUNT_NODE(NODE_CASE);
+ COUNT_NODE(NODE_CASE2);
COUNT_NODE(NODE_WHEN);
COUNT_NODE(NODE_WHILE);
COUNT_NODE(NODE_UNTIL);