From 606e855622c2694c6bf1a5cec59373bef0d0877e Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 25 Nov 2014 18:44:22 +0000 Subject: [PATCH] rb_id2str over rb_id2name git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- class.c | 8 ++++---- compile.c | 24 ++++++++++++++---------- debug.c | 2 +- error.c | 4 ++-- eval_error.c | 10 +++++----- gc.c | 2 +- vm.c | 11 +++++------ 7 files changed, 32 insertions(+), 29 deletions(-) diff --git a/class.c b/class.c index d9ce5b5604..2869bf36b0 100644 --- a/class.c +++ b/class.c @@ -699,16 +699,16 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super) if (rb_const_defined_at(outer, id)) { klass = rb_const_get_at(outer, id); if (!RB_TYPE_P(klass, T_CLASS)) { - rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id)); + rb_raise(rb_eTypeError, "%"PRIsVALUE" is not a class", rb_id2str(id)); } if (rb_class_real(RCLASS_SUPER(klass)) != super) { - rb_name_error(id, "%s is already defined", rb_id2name(id)); + rb_name_error(id, "%"PRIsVALUE" is already defined", rb_id2str(id)); } return klass; } if (!super) { - rb_warn("no super class for `%s::%s', Object assumed", - rb_class2name(outer), rb_id2name(id)); + rb_warn("no super class for `%"PRIsVALUE"::%"PRIsVALUE"', Object assumed", + rb_class_path(outer), rb_id2str(id)); } klass = rb_define_class_id(id, super); rb_set_class_path_string(klass, outer, rb_id2str(id)); diff --git a/compile.c b/compile.c index be59c2cd76..7a73ddfcd9 100644 --- a/compile.c +++ b/compile.c @@ -444,7 +444,8 @@ validate_label(st_data_t name, st_data_t label, st_data_t arg) do { int ret; COMPILE_ERROR((ruby_sourcefile, lobj->position, - "%s: undefined label", rb_id2name((ID)name))); + "%"PRIsVALUE": undefined label", + rb_id2str((ID)name))); if (ret) break; } while (0); } @@ -3960,7 +3961,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) ID id = node->nd_vid; int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id); - debugs("lvar: %s idx: %d\n", rb_id2name(id), idx); + debugs("lvar: %"PRIsVALUE" idx: %d\n", rb_id2str(id), idx); COMPILE(ret, "rvalue", node->nd_value); if (!poped) { @@ -3974,7 +3975,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_DASGN_CURR:{ int idx, lv, ls; COMPILE(ret, "dvalue", node->nd_value); - debugp_param("dassn id", rb_str_new2(rb_id2name(node->nd_vid) ? rb_id2name(node->nd_vid) : "*")); + debugi("dassn id", rb_id2str(node->nd_vid) ? node->nd_vid : '*'); if (!poped) { ADD_INSN(ret, line, dup); @@ -3983,7 +3984,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls); if (idx < 0) { - rb_bug("NODE_DASGN(_CURR): unknown id (%s)", rb_id2name(node->nd_vid)); + rb_bug("NODE_DASGN(_CURR): unknown id (%"PRIsVALUE")", rb_id2str(node->nd_vid)); } ADD_INSN2(ret, line, setlocal, INT2FIX(ls - idx), INT2FIX(lv)); @@ -4758,7 +4759,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) ID id = node->nd_vid; int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id); - debugs("id: %s idx: %d\n", rb_id2name(id), idx); + debugs("id: %"PRIsVALUE" idx: %d\n", rb_id2str(id), idx); ADD_INSN2(ret, line, getlocal, INT2FIX(idx), INT2FIX(get_lvar_level(iseq))); } break; @@ -4769,7 +4770,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) if (!poped) { idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls); if (idx < 0) { - rb_bug("unknown dvar (%s)", rb_id2name(node->nd_vid)); + rb_bug("unknown dvar (%"PRIsVALUE")", rb_id2str(node->nd_vid)); } ADD_INSN2(ret, line, getlocal, INT2FIX(ls - idx), INT2FIX(lv)); } @@ -5076,7 +5077,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) VALUE iseqval = NEW_CHILD_ISEQVAL( node->nd_body, - rb_sprintf("", rb_id2name(node->nd_cpath->nd_mid)), + rb_sprintf("", rb_id2str(node->nd_cpath->nd_mid)), ISEQ_TYPE_CLASS, line); VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath); int flags = VM_DEFINECLASS_TYPE_CLASS; @@ -5094,7 +5095,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_MODULE:{ VALUE iseqval = NEW_CHILD_ISEQVAL( node->nd_body, - rb_sprintf("", rb_id2name(node->nd_cpath->nd_mid)), + rb_sprintf("", rb_id2str(node->nd_cpath->nd_mid)), ISEQ_TYPE_CLASS, line); VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath); @@ -5558,7 +5559,7 @@ insn_data_to_s_detail(INSN *iobj) { struct rb_global_entry *entry = (struct rb_global_entry *) (OPERAND_AT(iobj, j) & (~1)); - rb_str_cat2(str, rb_id2name(entry->id)); + rb_str_append(str, rb_id2str(entry->id)); break; } case TS_IC: /* inline cache */ @@ -5567,7 +5568,10 @@ insn_data_to_s_detail(INSN *iobj) case TS_CALLINFO: /* call info */ { rb_call_info_t *ci = (rb_call_info_t *)OPERAND_AT(iobj, j); - rb_str_catf(str, "", ci->mid ? rb_id2name(ci->mid) : "", ci->orig_argc); + rb_str_cat2(str, "mid) + rb_str_catf(str, "%"PRIsVALUE, rb_id2str(ci->mid)); + rb_str_catf(str, ", %d>", ci->orig_argc); break; } case TS_CDHASH: /* case/when condition cache */ diff --git a/debug.c b/debug.c index a5ae6a7467..b526ab9523 100644 --- a/debug.c +++ b/debug.c @@ -115,7 +115,7 @@ ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id) { if (level < debug_level) { - fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id)); + fprintf(stderr, "DBG> %s: %"PRIsVALUE"\n", header, rb_id2str(id)); fflush(stderr); } return id; diff --git a/error.c b/error.c index 7aa939f829..241413c738 100644 --- a/error.c +++ b/error.c @@ -1952,8 +1952,8 @@ void rb_notimplement(void) { rb_raise(rb_eNotImpError, - "%s() function is unimplemented on this machine", - rb_id2name(rb_frame_this_func())); + "%"PRIsVALUE"() function is unimplemented on this machine", + rb_id2str(rb_frame_this_func())); } void diff --git a/eval_error.c b/eval_error.c index 0c323c21c7..6d43fe3c7c 100644 --- a/eval_error.c +++ b/eval_error.c @@ -22,20 +22,20 @@ warn_printf(const char *fmt, ...) static void error_pos(void) { - const char *sourcefile = rb_sourcefile(); + VALUE sourcefile = rb_sourcefilename(); int sourceline = rb_sourceline(); if (sourcefile) { ID caller_name; if (sourceline == 0) { - warn_printf("%s", sourcefile); + warn_printf("%"PRIsVALUE, sourcefile); } else if ((caller_name = rb_frame_callee()) != 0) { - warn_printf("%s:%d:in `%s'", sourcefile, sourceline, - rb_id2name(caller_name)); + warn_printf("%"PRIsVALUE":%d:in `%"PRIsVALUE"'", sourcefile, sourceline, + rb_id2str(caller_name)); } else { - warn_printf("%s:%d", sourcefile, sourceline); + warn_printf("%"PRIsVALUE":%d", sourcefile, sourceline); } } } diff --git a/gc.c b/gc.c index 9c0dbeffcf..8cde90cc1b 100644 --- a/gc.c +++ b/gc.c @@ -2717,7 +2717,7 @@ id2ref(VALUE obj, VALUE objid) if ((ptr % sizeof(RVALUE)) == (4 << 2)) { ID symid = ptr / sizeof(RVALUE); - if (rb_id2name(symid) == 0) + if (rb_id2str(symid) == 0) rb_raise(rb_eRangeError, "%p is not symbol id value", p0); return ID2SYM(symid); } diff --git a/vm.c b/vm.c index a495da01b9..ddb93f6034 100644 --- a/vm.c +++ b/vm.c @@ -1729,15 +1729,14 @@ rb_thread_current_status(const rb_thread_t *th) if (cfp->pc != 0) { rb_iseq_t *iseq = cfp->iseq; int line_no = rb_vm_get_sourceline(cfp); - char *file = RSTRING_PTR(iseq->location.path); - str = rb_sprintf("%s:%d:in `%s'", - file, line_no, RSTRING_PTR(iseq->location.label)); + str = rb_sprintf("%"PRIsVALUE":%d:in `%"PRIsVALUE"'", + iseq->location.path, line_no, iseq->location.label); } } else if (cfp->me->def->original_id) { - str = rb_sprintf("`%s#%s' (cfunc)", - rb_class2name(cfp->me->klass), - rb_id2name(cfp->me->def->original_id)); + str = rb_sprintf("`%"PRIsVALUE"#%"PRIsVALUE"' (cfunc)", + rb_class_path(cfp->me->klass), + rb_id2str(cfp->me->def->original_id)); } return str;