Use `mrb_funcall_id()` extensively.

Except for support files e.g. `mruby-test/driver.c`, which are not
target of symbol collection via `rake gensym`.
parent dcd3e590
......@@ -149,10 +149,10 @@ mrb_ary_slice_bang(mrb_state *mrb, mrb_value self)
return mrb_nil_value();
}
case MRB_TT_FIXNUM:
val = mrb_funcall(mrb, self, "delete_at", 1, index);
val = mrb_funcall_id(mrb, self, MRB_SYM(delete_at), 1, index);
return val;
default:
val = mrb_funcall(mrb, self, "delete_at", 1, index);
val = mrb_funcall_id(mrb, self, MRB_SYM(delete_at), 1, index);
return val;
}
}
......
......@@ -67,7 +67,7 @@ mrb_debug_eval(mrb_state *mrb, mrb_debug_context *dbg, const char *expr, size_t
recv = dbg->regs[0];
v = mrb_funcall(mrb, recv, "instance_eval", 1, ruby_code);
v = mrb_funcall_id(mrb, recv, MRB_SYM(instance_eval), 1, ruby_code);
}
if (exc) {
......
......@@ -104,13 +104,13 @@ p(mrb_state *mrb, mrb_value obj, int prompt)
mrb_value val;
char* msg;
val = mrb_funcall(mrb, obj, "inspect", 0);
val = mrb_funcall_id(mrb, obj, MRB_SYM(inspect), 0);
if (prompt) {
if (!mrb->exc) {
fputs(" => ", stdout);
}
else {
val = mrb_funcall(mrb, mrb_obj_value(mrb->exc), "inspect", 0);
val = mrb_funcall_id(mrb, mrb_obj_value(mrb->exc), MRB_SYM(inspect), 0);
}
}
if (!mrb_string_p(val)) {
......
......@@ -1603,7 +1603,7 @@ codegen(codegen_scope *s, node *tree, int val)
{
node *n = tree->car->cdr;
mrb_sym mid = nsym(n->cdr->car);
mrb_sym mnil = mrb_intern_lit(s->mrb, "nil?");
mrb_sym mnil = MRB_QSYM(nil_p);
if (mid == mnil && n->cdr->cdr->car == NULL) {
nil_p = TRUE;
codegen(s, n->car, VAL);
......
......@@ -109,7 +109,7 @@ io_set_process_status(mrb_state *mrb, pid_t pid, int status)
}
}
if (c_status != NULL) {
v = mrb_funcall(mrb, mrb_obj_value(c_status), "new", 2, mrb_fixnum_value(pid), mrb_fixnum_value(status));
v = mrb_funcall_id(mrb, mrb_obj_value(c_status), MRB_SYM(new), 2, mrb_fixnum_value(pid), mrb_fixnum_value(status));
} else {
v = mrb_fixnum_value(WEXITSTATUS(status));
}
......
......@@ -57,7 +57,7 @@ mrb_f_caller(mrb_state *mrb, mrb_value self)
return mrb_ary_new(mrb);
}
return mrb_funcall(mrb, bt, "[]", 2, mrb_fixnum_value(lev), mrb_fixnum_value(n));
return mrb_funcall_id(mrb, bt, MRB_QSYM(aref), 2, mrb_fixnum_value(lev), mrb_fixnum_value(n));
}
/*
......
......@@ -622,7 +622,7 @@ remove_method(mrb_state *mrb, mrb_value mod, mrb_sym mid)
k = kh_get(mt, mrb, h, mid);
if (k != kh_end(h)) {
kh_del(mt, mrb, h, k);
mrb_funcall(mrb, mod, "method_removed", 1, mrb_symbol_value(mid));
mrb_funcall_id(mrb, mod, MRB_SYM(method_removed), 1, mrb_symbol_value(mid));
return;
}
}
......
......@@ -256,7 +256,7 @@ method_source_location(mrb_state *mrb, mrb_value self)
rproc = mrb_proc_ptr(proc);
orig = rproc->c;
rproc->c = mrb->proc_class;
ret = mrb_funcall(mrb, proc, "source_location", 0);
ret = mrb_funcall_id(mrb, proc, MRB_SYM(source_location), 0);
rproc->c = orig;
return ret;
}
......@@ -278,7 +278,7 @@ method_parameters(mrb_state *mrb, mrb_value self)
rproc = mrb_proc_ptr(proc);
orig = rproc->c;
rproc->c = mrb->proc_class;
ret = mrb_funcall(mrb, proc, "parameters", 0);
ret = mrb_funcall_id(mrb, proc, MRB_SYM(parameters), 0);
rproc->c = orig;
return ret;
}
......@@ -325,7 +325,7 @@ mrb_search_method_owner(mrb_state *mrb, struct RClass *c, mrb_value obj, mrb_sym
if (!mrb_respond_to(mrb, obj, MRB_QSYM(respond_to_missing_p))) {
goto name_error;
}
ret = mrb_funcall(mrb, obj, "respond_to_missing?", 2, mrb_symbol_value(name), mrb_true_value());
ret = mrb_funcall_id(mrb, obj, MRB_QSYM(respond_to_missing_p), 2, mrb_symbol_value(name), mrb_true_value());
if (!mrb_test(ret)) {
goto name_error;
}
......
......@@ -81,8 +81,8 @@ range_last(mrb_state *mrb, mrb_value range)
return mrb_range_end(mrb, range);
}
array = mrb_funcall(mrb, range, "to_a", 0);
return mrb_funcall(mrb, array, "last", 1, mrb_to_int(mrb, num));
array = mrb_funcall_id(mrb, range, MRB_SYM(to_a), 0);
return mrb_funcall_id(mrb, array, MRB_SYM(last), 1, mrb_to_int(mrb, num));
}
/*
......
......@@ -177,7 +177,7 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
for (res = res0; res != NULL; res = res->ai_next) {
sa = mrb_str_new(mrb, (char*)res->ai_addr, res->ai_addrlen);
ai = mrb_funcall(mrb, klass, "new", 4, sa, mrb_fixnum_value(res->ai_family), mrb_fixnum_value(res->ai_socktype), mrb_fixnum_value(res->ai_protocol));
ai = mrb_funcall_id(mrb, klass, MRB_SYM(new), 4, sa, mrb_fixnum_value(res->ai_family), mrb_fixnum_value(res->ai_socktype), mrb_fixnum_value(res->ai_protocol));
mrb_ary_push(mrb, ary, ai);
mrb_gc_arena_restore(mrb, arena_idx);
}
......@@ -200,7 +200,7 @@ mrb_addrinfo_getnameinfo(mrb_state *mrb, mrb_value self)
host = mrb_str_buf_new(mrb, NI_MAXHOST);
serv = mrb_str_buf_new(mrb, NI_MAXSERV);
sastr = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@sockaddr"));
sastr = mrb_iv_get(mrb, self, MRB_QSYM(a_sockaddr));
if (!mrb_string_p(sastr)) {
mrb_raise(mrb, E_SOCKET_ERROR, "invalid sockaddr");
}
......@@ -222,7 +222,7 @@ mrb_addrinfo_unix_path(mrb_state *mrb, mrb_value self)
{
mrb_value sastr;
sastr = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@sockaddr"));
sastr = mrb_iv_get(mrb, self, MRB_QSYM(a_sockaddr));
if (((struct sockaddr *)RSTRING_PTR(sastr))->sa_family != AF_UNIX)
mrb_raise(mrb, E_SOCKET_ERROR, "need AF_UNIX address");
if (RSTRING_LEN(sastr) < (mrb_int)offsetof(struct sockaddr_un, sun_path) + 1) {
......@@ -269,7 +269,7 @@ sa2addrlist(mrb_state *mrb, const struct sockaddr *sa, socklen_t salen)
static int
socket_fd(mrb_state *mrb, mrb_value sock)
{
return (int)mrb_fixnum(mrb_funcall(mrb, sock, "fileno", 0));
return (int)mrb_fixnum(mrb_funcall_id(mrb, sock, MRB_SYM(fileno), 0));
}
static int
......@@ -350,7 +350,7 @@ mrb_basicsocket_getsockopt(mrb_state *mrb, mrb_value self)
c = mrb_const_get(mrb, mrb_obj_value(mrb_class_get(mrb, "Socket")), MRB_SYM(Option));
family = socket_family(s);
data = mrb_str_new(mrb, opt, optlen);
return mrb_funcall(mrb, c, "new", 4, mrb_fixnum_value(family), mrb_fixnum_value(level), mrb_fixnum_value(optname), data);
return mrb_funcall_id(mrb, c, MRB_SYM(new), 4, mrb_fixnum_value(family), mrb_fixnum_value(level), mrb_fixnum_value(optname), data);
}
static mrb_value
......@@ -472,9 +472,9 @@ mrb_basicsocket_setsockopt(mrb_state *mrb, mrb_value self)
} else if (argc == 1) {
if (strcmp(mrb_obj_classname(mrb, so), "Socket::Option") != 0)
mrb_raise(mrb, E_ARGUMENT_ERROR, "not an instance of Socket::Option");
level = mrb_fixnum(mrb_funcall(mrb, so, "level", 0));
optname = mrb_fixnum(mrb_funcall(mrb, so, "optname", 0));
optval = mrb_funcall(mrb, so, "data", 0);
level = mrb_fixnum(mrb_funcall_id(mrb, so, MRB_SYM(level), 0));
optname = mrb_fixnum(mrb_funcall_id(mrb, so, MRB_SYM(optname), 0));
optval = mrb_funcall_id(mrb, so, MRB_SYM(data), 0);
} else {
mrb_argnum_error(mrb, argc, 3, 3);
}
......
......@@ -763,7 +763,7 @@ retry:
tmp = mrb_str_new(mrb, buf, 1);
}
else {
tmp = mrb_funcall(mrb, val, "chr", 0);
tmp = mrb_funcall_id(mrb, val, MRB_SYM(chr), 0);
mrb_check_type(mrb, tmp, MRB_TT_STRING);
}
#endif
......
......@@ -1090,7 +1090,7 @@ mrb_ary_splat(mrb_state *mrb, mrb_value v)
return mrb_ary_new_from_values(mrb, 1, &v);
}
ary = mrb_funcall(mrb, v, "to_a", 0);
ary = mrb_funcall_id(mrb, v, MRB_SYM(to_a), 0);
if (mrb_nil_p(ary)) {
return mrb_ary_new_from_values(mrb, 1, &v);
}
......
......@@ -114,7 +114,7 @@ exc_to_s(mrb_state *mrb, mrb_value exc)
static mrb_value
exc_message(mrb_state *mrb, mrb_value exc)
{
return mrb_funcall(mrb, exc, "to_s", 0);
return mrb_funcall_id(mrb, exc, MRB_SYM(to_s), 0);
}
/*
......
......@@ -72,7 +72,7 @@ ht_hash_func(mrb_state *mrb, htable *t, mrb_value key)
break;
default:
hv = mrb_funcall(mrb, key, "hash", 0);
hv = mrb_funcall_id(mrb, key, MRB_SYM(hash), 0);
h = (size_t)tt ^ (size_t)mrb_fixnum(hv);
break;
}
......@@ -856,7 +856,7 @@ hash_default(mrb_state *mrb, mrb_value hash, mrb_value key)
{
if (MRB_RHASH_DEFAULT_P(hash)) {
if (MRB_RHASH_PROCDEFAULT_P(hash)) {
return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, key);
return mrb_funcall_id(mrb, RHASH_PROCDEFAULT(hash), MRB_SYM(call), 2, hash, key);
}
else {
return RHASH_IFNONE(hash);
......@@ -897,7 +897,7 @@ mrb_hash_default(mrb_state *mrb, mrb_value hash)
if (MRB_RHASH_DEFAULT_P(hash)) {
if (MRB_RHASH_PROCDEFAULT_P(hash)) {
if (!given) return mrb_nil_value();
return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, key);
return mrb_funcall_id(mrb, RHASH_PROCDEFAULT(hash), MRB_SYM(call), 2, hash, key);
}
else {
return RHASH_IFNONE(hash);
......@@ -1083,7 +1083,7 @@ mrb_hash_shift(mrb_state *mrb, mrb_value hash)
if (MRB_RHASH_DEFAULT_P(hash)) {
if (MRB_RHASH_PROCDEFAULT_P(hash)) {
return mrb_funcall(mrb, RHASH_PROCDEFAULT(hash), "call", 2, hash, mrb_nil_value());
return mrb_funcall_id(mrb, RHASH_PROCDEFAULT(hash), MRB_SYM(call), 2, hash, mrb_nil_value());
}
else {
return RHASH_IFNONE(hash);
......
......@@ -310,7 +310,7 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
default:
break;
}
mrb_funcall(mrb, dest, "initialize_copy", 1, obj);
mrb_funcall_id(mrb, dest, MRB_SYM(initialize_copy), 1, obj);
}
/* 15.3.1.3.8 */
......@@ -411,8 +411,8 @@ mrb_obj_extend(mrb_state *mrb, mrb_int argc, mrb_value *argv, mrb_value obj)
mrb_check_type(mrb, argv[i], MRB_TT_MODULE);
}
while (argc--) {
mrb_funcall(mrb, argv[argc], "extend_object", 1, obj);
mrb_funcall(mrb, argv[argc], "extended", 1, obj);
mrb_funcall_id(mrb, argv[argc], MRB_SYM(extend_object), 1, obj);
mrb_funcall_id(mrb, argv[argc], MRB_SYM(extended), 1, obj);
}
return obj;
}
......@@ -749,7 +749,7 @@ obj_respond_to(mrb_state *mrb, mrb_value self)
mrb_get_args(mrb, "n|b", &id, &priv);
respond_to_p = basic_obj_respond_to(mrb, self, id, !priv);
if (!respond_to_p) {
rtm_id = mrb_intern_lit(mrb, "respond_to_missing?");
rtm_id = MRB_QSYM(respond_to_missing_p);
if (basic_obj_respond_to(mrb, self, rtm_id, !priv)) {
mrb_value args[2], v;
args[0] = mrb_symbol_value(id);
......
......@@ -1558,7 +1558,7 @@ mrb_cmp(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
return -2;
return mrb_str_cmp(mrb, obj1, obj2);
default:
v = mrb_funcall(mrb, obj1, "<=>", 1, obj2);
v = mrb_funcall_id(mrb, obj1, MRB_SYM(cmp), 1, obj2);
if (mrb_nil_p(v) || !mrb_fixnum_p(v))
return -2;
return mrb_fixnum(v);
......
......@@ -58,7 +58,7 @@ mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
return TRUE;
}
#endif
result = mrb_funcall(mrb, obj1, "==", 1, obj2);
result = mrb_funcall_id(mrb, obj1, MRB_QSYM(eq), 1, obj2);
if (mrb_test(result)) return TRUE;
return FALSE;
}
......@@ -648,12 +648,12 @@ mrb_check_hash_type(mrb_state *mrb, mrb_value hash)
MRB_API mrb_value
mrb_inspect(mrb_state *mrb, mrb_value obj)
{
return mrb_obj_as_string(mrb, mrb_funcall(mrb, obj, "inspect", 0));
return mrb_obj_as_string(mrb, mrb_funcall_id(mrb, obj, MRB_SYM(inspect), 0));
}
MRB_API mrb_bool
mrb_eql(mrb_state *mrb, mrb_value obj1, mrb_value obj2)
{
if (mrb_obj_eq(mrb, obj1, obj2)) return TRUE;
return mrb_test(mrb_funcall(mrb, obj1, "eql?", 1, obj2));
return mrb_test(mrb_funcall_id(mrb, obj1, MRB_QSYM(eql_p), 1, obj2));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment