mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rb_id2str over rb_id2name
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d0ac6d5879
commit
606e855622
7 changed files with 32 additions and 29 deletions
8
class.c
8
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));
|
||||
|
|
24
compile.c
24
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("<class:%s>", rb_id2name(node->nd_cpath->nd_mid)),
|
||||
rb_sprintf("<class:%"PRIsVALUE">", 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("<module:%s>", rb_id2name(node->nd_cpath->nd_mid)),
|
||||
rb_sprintf("<module:%"PRIsVALUE">", 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, "<callinfo:%s, %d>", ci->mid ? rb_id2name(ci->mid) : "", ci->orig_argc);
|
||||
rb_str_cat2(str, "<callinfo:");
|
||||
if (ci->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 */
|
||||
|
|
2
debug.c
2
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;
|
||||
|
|
4
error.c
4
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
|
||||
|
|
10
eval_error.c
10
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
gc.c
2
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);
|
||||
}
|
||||
|
|
11
vm.c
11
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;
|
||||
|
|
Loading…
Reference in a new issue