[前][次][番号順一覧][スレッド一覧]

ruby-changes:45763

From: nobu <ko1@a...>
Date: Sat, 11 Mar 2017 21:26:07 +0900 (JST)
Subject: [ruby-changes:45763] nobu:r57836 (trunk): compile.c: constify flags

nobu	2017-03-11 21:26:00 +0900 (Sat, 11 Mar 2017)

  New Revision: 57836

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57836

  Log:
    compile.c: constify flags
    
    * compile.c (compile_cpath): return `noscoped` bit flag, instead
      of boolean flag.
    
    * compile.c (iseq_compile_each): constify flags.

  Modified files:
    trunk/compile.c
Index: compile.c
===================================================================
--- compile.c	(revision 57835)
+++ compile.c	(revision 57836)
@@ -3492,24 +3492,24 @@ compile_colon2(rb_iseq_t *iseq, NODE *no https://github.com/ruby/ruby/blob/trunk/compile.c#L3492
     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_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5950
 	const rb_iseq_t *class_iseq = NEW_CHILD_ISEQ(node->nd_body,
 						     rb_sprintf("<class:%"PRIsVALUE">", 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_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5966
         const rb_iseq_t *module_iseq = NEW_CHILD_ISEQ(node->nd_body,
 						      rb_sprintf("<module:%"PRIsVALUE">", 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));
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]