mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
iseq.c: preserve encoding at disassembling
* iseq.c (rb_insn_operand_intern): preserve encoding of method name in CALL_INFO at disassembling. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
31aed95862
commit
b58802a3c1
3 changed files with 13 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Nov 24 02:03:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* io.c (must_respond_to): preserve encodings of variable name and
|
||||
|
|
2
iseq.c
2
iseq.c
|
@ -1230,7 +1230,7 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
|
|||
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));
|
||||
|
|
|
@ -52,13 +52,14 @@ class TestISeq < Test::Unit::TestCase
|
|||
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__
|
||||
|
|
Loading…
Reference in a new issue