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

ruby-changes:34790

From: nobu <ko1@a...>
Date: Sat, 19 Jul 2014 12:41:02 +0900 (JST)
Subject: [ruby-changes:34790] nobu:r46873 (trunk): compile.c: private reader in op_assign

nobu	2014-07-19 12:40:52 +0900 (Sat, 19 Jul 2014)

  New Revision: 46873

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

  Log:
    compile.c: private reader in op_assign
    
    * compile.c (iseq_compile_each): allow to access private attribute
      reader in op_assign.  [ruby-core:63817] [Bug #10060]

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/test/ruby/test_assignment.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46872)
+++ ChangeLog	(revision 46873)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jul 19 12:40:50 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (iseq_compile_each): allow to access private attribute
+	  reader in op_assign.  [ruby-core:63817] [Bug #10060]
+
 Sat Jul 19 11:56:36 2014  Grey Baker  <greysteil@g...>
 
 	* lib/time.rb (Time#apply_offset): Guards against a `nil` return
Index: compile.c
===================================================================
--- compile.c	(revision 46872)
+++ compile.c	(revision 46873)
@@ -4178,8 +4178,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L4178
 
 	asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node);
 	ADD_INSN(ret, line, dup);
-	ADD_SEND(ret, line, ID2SYM(node->nd_next->nd_vid),
-		 INT2FIX(0));
+	ADD_SEND_R(ret, line, ID2SYM(node->nd_next->nd_vid),
+		   INT2FIX(0), Qfalse, INT2FIX(asgnflag));
 
 	if (atype == 0 || atype == 1) {	/* 0: OR or 1: AND */
 	    ADD_INSN(ret, line, dup);
@@ -5331,6 +5331,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5331
 	DECL_ANCHOR(args);
 	VALUE flag = 0;
 	VALUE argc;
+	int asgnflag;
 
 	/* optimization shortcut
 	 *   obj["literal"] = value -> opt_aset_with(obj, "literal", value)
@@ -5358,7 +5359,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5359
 	INIT_ANCHOR(args);
 	argc = setup_args(iseq, args, node->nd_args, &flag);
 
-	flag |= COMPILE_RECV(recv, "recv", node);
+	flag |= (asgnflag = COMPILE_RECV(recv, "recv", node));
 
 	debugp_param("argc", argc);
 	debugp_param("nd_mid", ID2SYM(node->nd_mid));
@@ -5372,7 +5373,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5373
 		ADD_INSN1(ret, line, topn, INT2FIX(1));
 		if (flag & VM_CALL_ARGS_SPLAT) {
 		    ADD_INSN1(ret, line, putobject, INT2FIX(-1));
-		    ADD_SEND(ret, line, ID2SYM(idAREF), INT2FIX(1));
+		    ADD_SEND_R(ret, line, ID2SYM(idAREF), INT2FIX(1), Qfalse, INT2FIX(asgnflag));
 		}
 		ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 3));
 		ADD_INSN (ret, line, pop);
@@ -5380,7 +5381,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5381
 	    else if (flag & VM_CALL_ARGS_SPLAT) {
 		ADD_INSN(ret, line, dup);
 		ADD_INSN1(ret, line, putobject, INT2FIX(-1));
-		ADD_SEND(ret, line, ID2SYM(idAREF), INT2FIX(1));
+		ADD_SEND_R(ret, line, ID2SYM(idAREF), INT2FIX(1), Qfalse, INT2FIX(asgnflag));
 		ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2));
 		ADD_INSN (ret, line, pop);
 	    }
Index: test/ruby/test_assignment.rb
===================================================================
--- test/ruby/test_assignment.rb	(revision 46872)
+++ test/ruby/test_assignment.rb	(revision 46873)
@@ -106,9 +106,9 @@ class TestAssignment < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_assignment.rb#L106
 
     o = Object.new
     class << o
+      private
       def foo; 42; end
       def [](i); 42; end
-      private
       def foo=(a); 42; end
       def []=(i, a); 42; end
     end

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

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