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

ruby-changes:36466

From: nobu <ko1@a...>
Date: Mon, 24 Nov 2014 02:03:53 +0900 (JST)
Subject: [ruby-changes:36466] nobu:r48548 (trunk): iseq.c: preserve encoding at disassembling

nobu	2014-11-24 02:03:32 +0900 (Mon, 24 Nov 2014)

  New Revision: 48548

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

  Log:
    iseq.c: preserve encoding at disassembling
    
    * iseq.c (rb_insn_operand_intern): preserve encoding of method
      name in CALL_INFO at disassembling.

  Modified files:
    trunk/ChangeLog
    trunk/iseq.c
    trunk/test/ruby/test_iseq.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48547)
+++ ChangeLog	(revision 48548)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Nov 24 02:03:30 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* iseq.c (rb_insn_operand_intern): preserve encoding of method
+	  name in CALL_INFO at disassembling.
+
 Mon Nov 24 02:02:59 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* io.c (must_respond_to): preserve encodings of variable name and
Index: iseq.c
===================================================================
--- iseq.c	(revision 48547)
+++ iseq.c	(revision 48548)
@@ -1230,7 +1230,7 @@ rb_insn_operand_intern(const rb_iseq_t * https://github.com/ruby/ruby/blob/trunk/iseq.c#L1230
 	    VALUE ary = rb_ary_new();
 
 	    if (ci->mid) {
-		rb_ary_push(ary, rb_sprintf("mid:%s", rb_id2name(ci->mid)));
+		rb_ary_push(ary, rb_sprintf("mid:%"PRIsVALUE, rb_id2str(ci->mid)));
 	    }
 
 	    rb_ary_push(ary, rb_sprintf("argc:%d", ci->orig_argc));
Index: test/ruby/test_iseq.rb
===================================================================
--- test/ruby/test_iseq.rb	(revision 48547)
+++ test/ruby/test_iseq.rb	(revision 48548)
@@ -52,13 +52,14 @@ class TestISeq < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_iseq.rb#L52
   end if defined?(RubyVM::InstructionSequence.load)
 
   def test_disasm_encoding
-    src = "\u{3042} = 1; \u{3042}"
-    enc, Encoding.default_internal = Encoding.default_internal, src.encoding
-    assert_equal(src.encoding, RubyVM::InstructionSequence.compile(src).disasm.encoding)
+    src = "\u{3042} = 1; \u{3042}; \u{3043}"
+    asm = RubyVM::InstructionSequence.compile(src).disasm
+    assert_equal(src.encoding, asm.encoding)
+    assert_predicate(asm, :valid_encoding?)
     src.encode!(Encoding::Shift_JIS)
-    assert_equal(true, RubyVM::InstructionSequence.compile(src).disasm.ascii_only?)
-  ensure
-    Encoding.default_internal = enc
+    asm = RubyVM::InstructionSequence.compile(src).disasm
+    assert_equal(src.encoding, asm.encoding)
+    assert_predicate(asm, :valid_encoding?)
   end
 
   LINE_BEFORE_METHOD = __LINE__

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

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