* iseq.c (rb_insn_operand_intern): improve operands of defined
  instruction.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-12-22 00:29:38 +00:00
Родитель 93dcc40bb7
Коммит b4dc51ce10
1 изменённых файлов: 35 добавлений и 13 удалений

48
iseq.c
Просмотреть файл

@ -1419,6 +1419,12 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
if (insn == BIN(branchiftype) && (type_str = rb_type_str((enum ruby_value_type)op)) != NULL) { if (insn == BIN(branchiftype) && (type_str = rb_type_str((enum ruby_value_type)op)) != NULL) {
ret = rb_str_new_cstr(type_str); ret = rb_str_new_cstr(type_str);
} }
else if (insn == BIN(defined) && op_no == 0 &&
(enum defined_type)op == DEFINED_FUNC ? (ret = rb_fstring_cstr("func"), 1) :
(enum defined_type)op == DEFINED_REF ? (ret = rb_fstring_cstr("ref"), 1) :
(ret = rb_iseq_defined_string((enum defined_type)op)) != 0) {
/* ok */
}
else { else {
ret = rb_sprintf("%"PRIuVALUE, op); ret = rb_sprintf("%"PRIuVALUE, op);
} }
@ -1445,10 +1451,24 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
break; break;
} }
case TS_ID: /* ID (symbol) */ case TS_ID: /* ID (symbol) */
op = ID2SYM(op); ret = rb_inspect(ID2SYM(op));
break;
case TS_VALUE: /* VALUE */ case TS_VALUE: /* VALUE */
op = obj_resurrect(op); op = obj_resurrect(op);
if (insn == BIN(defined) && op_no == 1 && FIXNUM_P(op)) {
/* should be DEFINED_REF */
int type = NUM2INT(op);
if (type) {
if (type & 1) {
ret = rb_sprintf(":$%c", (type >> 1));
}
else {
ret = rb_sprintf(":$%d", (type >> 1));
}
break;
}
}
ret = rb_inspect(op); ret = rb_inspect(op);
if (CLASS_OF(op) == rb_cISeq) { if (CLASS_OF(op) == rb_cISeq) {
if (child) { if (child) {
@ -1501,18 +1521,20 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
if (ci->flag) { if (ci->flag) {
VALUE flags = rb_ary_new(); VALUE flags = rb_ary_new();
if (ci->flag & VM_CALL_ARGS_SPLAT) rb_ary_push(flags, rb_str_new2("ARGS_SPLAT")); # define CALL_FLAG(n) if (ci->flag & VM_CALL_##n) rb_ary_push(flags, rb_str_new2(#n))
if (ci->flag & VM_CALL_ARGS_BLOCKARG) rb_ary_push(flags, rb_str_new2("ARGS_BLOCKARG")); # define CALL_OPT_FLAG(n) if (ci->flag & VM_CALL_OPT_##n) rb_ary_push(flags, rb_str_new2(#n))
if (ci->flag & VM_CALL_ARGS_BLOCKARG_BLOCKPARAM) rb_ary_push(flags, rb_str_new2("ARGS_BLOCKARG_BLOCKPARAM")); CALL_FLAG(ARGS_SPLAT);
if (ci->flag & VM_CALL_FCALL) rb_ary_push(flags, rb_str_new2("FCALL")); CALL_FLAG(ARGS_BLOCKARG);
if (ci->flag & VM_CALL_VCALL) rb_ary_push(flags, rb_str_new2("VCALL")); CALL_FLAG(ARGS_BLOCKARG_BLOCKPARAM);
if (ci->flag & VM_CALL_ARGS_SIMPLE) rb_ary_push(flags, rb_str_new2("ARGS_SIMPLE")); CALL_FLAG(FCALL);
if (ci->flag & VM_CALL_BLOCKISEQ) rb_ary_push(flags, rb_str_new2("BLOCKISEQ")); CALL_FLAG(VCALL);
if (ci->flag & VM_CALL_TAILCALL) rb_ary_push(flags, rb_str_new2("TAILCALL")); CALL_FLAG(ARGS_SIMPLE);
if (ci->flag & VM_CALL_SUPER) rb_ary_push(flags, rb_str_new2("SUPER")); CALL_FLAG(BLOCKISEQ);
if (ci->flag & VM_CALL_KWARG) rb_ary_push(flags, rb_str_new2("KWARG")); CALL_FLAG(TAILCALL);
if (ci->flag & VM_CALL_KW_SPLAT) rb_ary_push(flags, rb_str_new2("KW_SPLAT")); CALL_FLAG(SUPER);
if (ci->flag & VM_CALL_OPT_SEND) rb_ary_push(flags, rb_str_new2("SEND")); /* maybe not reachable */ CALL_FLAG(KWARG);
CALL_FLAG(KW_SPLAT);
CALL_FLAG(OPT_SEND); /* maybe not reachable */
rb_ary_push(ary, rb_ary_join(flags, rb_str_new2("|"))); rb_ary_push(ary, rb_ary_join(flags, rb_str_new2("|")));
} }
ret = rb_sprintf("<callinfo!%"PRIsVALUE">", rb_ary_join(ary, rb_str_new2(", "))); ret = rb_sprintf("<callinfo!%"PRIsVALUE">", rb_ary_join(ary, rb_str_new2(", ")));