summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-13 16:07:52 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-13 16:07:52 +0000
commitf5090e2f5ca5d5e0353659bdcba3c0a09e908178 (patch)
tree110fe3bd3f99c5102d1579c9e900ca9ce5ae72f8
parent186732f46ffa6b07d6b6e8e610f42308ae0ec5b5 (diff)
iseq.c: dump type of branchiftype on disasm
This makes easier to debug scripts related to r59950. * before $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype 5, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave * after $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype T_STRING, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--internal.h1
-rw-r--r--iseq.c10
-rw-r--r--vm_eval.c2
3 files changed, 11 insertions, 2 deletions
diff --git a/internal.h b/internal.h
index 229a555533..d0257a8d8b 100644
--- a/internal.h
+++ b/internal.h
@@ -1842,6 +1842,7 @@ VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, V
typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
rb_check_funcall_hook *hook, VALUE arg);
+const char *rb_type_str(enum ruby_value_type type);
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_yield_1(VALUE val);
VALUE rb_yield_force_blockarg(VALUE values);
diff --git a/iseq.c b/iseq.c
index f8fb90e7a9..186f8622e7 100644
--- a/iseq.c
+++ b/iseq.c
@@ -1344,7 +1344,15 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
break;
case TS_NUM: /* ULONG */
- ret = rb_sprintf("%"PRIuVALUE, op);
+ {
+ const char *type_str;
+ if (insn == BIN(branchiftype) && (type_str = rb_type_str((enum ruby_value_type)op)) != NULL) {
+ ret = rb_str_new_cstr(type_str);
+ }
+ else {
+ ret = rb_sprintf("%"PRIuVALUE, op);
+ }
+ }
break;
case TS_LINDEX:{
diff --git a/vm_eval.c b/vm_eval.c
index 0198f3f5d4..a62e2a7a62 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -440,7 +440,7 @@ rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
return vm_call0(ec, recv, mid, argc, argv, me);
}
-static const char *
+const char *
rb_type_str(enum ruby_value_type type)
{
#define type_case(t) case t: return #t;