From 103731a25d18a005046af04c3040f35f674cfc6a Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 11 Mar 2017 12:26:00 +0000 Subject: compile.c: constify flags * compile.c (compile_cpath): return `noscoped` bit flag, instead of boolean flag. * compile.c (iseq_compile_each): constify flags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/compile.c b/compile.c index be38c63dea..70b7278af0 100644 --- a/compile.c +++ b/compile.c @@ -3492,24 +3492,24 @@ compile_colon2(rb_iseq_t *iseq, NODE *node, return COMPILE_OK; } -static VALUE +static int compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, NODE *cpath) { if (nd_type(cpath) == NODE_COLON3) { /* toplevel class ::Foo */ ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject); - return Qfalse; + return VM_DEFINECLASS_FLAG_SCOPED; } else if (cpath->nd_head) { /* Bar::Foo */ COMPILE(ret, "nd_else->nd_head", cpath->nd_head); - return Qfalse; + return VM_DEFINECLASS_FLAG_SCOPED; } else { /* class at cbase Foo */ ADD_INSN1(ret, nd_line(cpath), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE)); - return Qtrue; + return 0; } } @@ -5950,11 +5950,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe const rb_iseq_t *class_iseq = NEW_CHILD_ISEQ(node->nd_body, rb_sprintf("", rb_id2str(node->nd_cpath->nd_mid)), ISEQ_TYPE_CLASS, line); - VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath); - int flags = VM_DEFINECLASS_TYPE_CLASS; + const int flags = VM_DEFINECLASS_TYPE_CLASS | + (node->nd_super ? VM_DEFINECLASS_FLAG_HAS_SUPERCLASS : 0) | + compile_cpath(ret, iseq, node->nd_cpath); - if (!noscope) flags |= VM_DEFINECLASS_FLAG_SCOPED; - if (node->nd_super) flags |= VM_DEFINECLASS_FLAG_HAS_SUPERCLASS; CHECK(COMPILE(ret, "super", node->nd_super)); ADD_INSN3(ret, line, defineclass, ID2SYM(node->nd_cpath->nd_mid), class_iseq, INT2FIX(flags)); @@ -5967,10 +5966,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe const rb_iseq_t *module_iseq = NEW_CHILD_ISEQ(node->nd_body, rb_sprintf("", rb_id2str(node->nd_cpath->nd_mid)), ISEQ_TYPE_CLASS, line); - VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath); - int flags = VM_DEFINECLASS_TYPE_MODULE; + const int flags = VM_DEFINECLASS_TYPE_MODULE | + compile_cpath(ret, iseq, node->nd_cpath); - if (!noscope) flags |= VM_DEFINECLASS_FLAG_SCOPED; ADD_INSN (ret, line, putnil); /* dummy */ ADD_INSN3(ret, line, defineclass, ID2SYM(node->nd_cpath->nd_mid), module_iseq, INT2FIX(flags)); -- cgit v1.2.3