* insnhelper.ci (vm_search_normal_superclass): rename function.
* insnhelper.ci (vm_search_superclass): ditto. * proc.c (struct METHOD): rename rklass -> rclass. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c79ab68d37
commit
c227d3feb3
@ -21,6 +21,14 @@ Wed Nov 21 14:55:13 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* array.c (rb_ary_permutation): add gc guard codes.
|
||||
|
||||
Wed Nov 21 11:16:37 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* insnhelper.ci (vm_search_normal_superclass): rename function.
|
||||
|
||||
* insnhelper.ci (vm_search_superclass): ditto.
|
||||
|
||||
* proc.c (struct METHOD): rename rklass -> rclass.
|
||||
|
||||
Wed Nov 21 03:12:50 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* process.c (rb_f_system): returns nil on execution failure.
|
||||
|
@ -359,7 +359,7 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, int num,
|
||||
recv, (VALUE) blockptr, 0, reg_cfp->sp, 0, 1);
|
||||
|
||||
cfp->method_id = id;
|
||||
cfp->method_klass = klass;
|
||||
cfp->method_class = klass;
|
||||
|
||||
reg_cfp->sp -= num + 1;
|
||||
|
||||
@ -393,7 +393,7 @@ vm_call_bmethod(rb_thread_t *th, ID id, VALUE procval, VALUE recv,
|
||||
|
||||
/* control block frame */
|
||||
(cfp-2)->method_id = id;
|
||||
(cfp-2)->method_klass = klass;
|
||||
(cfp-2)->method_class = klass;
|
||||
|
||||
GetProcPtr(procval, proc);
|
||||
val = vm_invoke_proc(th, proc, recv, argc, argv);
|
||||
@ -1107,13 +1107,13 @@ vm_method_search(VALUE id, VALUE klass, IC ic)
|
||||
|
||||
#if OPT_INLINE_METHOD_CACHE
|
||||
{
|
||||
if (LIKELY(klass == ic->ic_klass) &&
|
||||
if (LIKELY(klass == ic->ic_class) &&
|
||||
LIKELY(GET_VM_STATE_VERSION() == ic->ic_vmstat)) {
|
||||
mn = ic->ic_method;
|
||||
}
|
||||
else {
|
||||
mn = rb_method_node(klass, id);
|
||||
ic->ic_klass = klass;
|
||||
ic->ic_class = klass;
|
||||
ic->ic_method = mn;
|
||||
ic->ic_vmstat = GET_VM_STATE_VERSION();
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ vm_method_search(VALUE id, VALUE klass, IC ic)
|
||||
}
|
||||
|
||||
static inline VALUE
|
||||
vm_search_normal_super_klass(VALUE klass, VALUE recv)
|
||||
vm_search_normal_superclass(VALUE klass, VALUE recv)
|
||||
{
|
||||
if (BUILTIN_TYPE(klass) == T_CLASS) {
|
||||
klass = RCLASS_SUPER(klass);
|
||||
@ -1144,7 +1144,7 @@ vm_search_normal_super_klass(VALUE klass, VALUE recv)
|
||||
}
|
||||
|
||||
static void
|
||||
vm_search_super_klass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, VALUE recv, VALUE sigval, ID *idp, VALUE *klassp)
|
||||
vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, VALUE recv, VALUE sigval, ID *idp, VALUE *klassp)
|
||||
{
|
||||
ID id;
|
||||
VALUE klass;
|
||||
@ -1174,7 +1174,7 @@ vm_search_super_klass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, VALUE recv, VA
|
||||
}
|
||||
|
||||
id = lcfp->method_id;
|
||||
klass = vm_search_normal_super_klass(lcfp->method_klass, recv);
|
||||
klass = vm_search_normal_superclass(lcfp->method_class, recv);
|
||||
|
||||
if (sigval == Qfalse) {
|
||||
/* zsuper */
|
||||
@ -1182,7 +1182,7 @@ vm_search_super_klass(rb_control_frame_t *reg_cfp, rb_iseq_t *ip, VALUE recv, VA
|
||||
}
|
||||
}
|
||||
else {
|
||||
klass = vm_search_normal_super_klass(ip->klass, recv);
|
||||
klass = vm_search_normal_superclass(ip->klass, recv);
|
||||
}
|
||||
|
||||
*idp = id;
|
||||
|
14
insns.def
14
insns.def
@ -861,7 +861,7 @@ defined
|
||||
ip = ip->parent_iseq;
|
||||
}
|
||||
if (ip) {
|
||||
VALUE klass = vm_search_normal_super_klass(ip->klass, GET_SELF());
|
||||
VALUE klass = vm_search_normal_superclass(ip->klass, GET_SELF());
|
||||
if (rb_method_boundp(klass, ip->defined_method_id, 0)) {
|
||||
expr_type = "super";
|
||||
}
|
||||
@ -944,7 +944,7 @@ trace
|
||||
*/
|
||||
DEFINE_INSN
|
||||
defineclass
|
||||
(ID id, ISEQ klass_iseq, rb_num_t define_type)
|
||||
(ID id, ISEQ class_iseq, rb_num_t define_type)
|
||||
(VALUE cbase, VALUE super)
|
||||
(VALUE val)
|
||||
{
|
||||
@ -1019,13 +1019,13 @@ defineclass
|
||||
rb_bug("unknown defineclass type: %d", (int)define_type);
|
||||
}
|
||||
|
||||
COPY_CREF(klass_iseq->cref_stack, vm_cref_push(th, klass, NOEX_PUBLIC));
|
||||
COPY_CREF(class_iseq->cref_stack, vm_cref_push(th, klass, NOEX_PUBLIC));
|
||||
|
||||
/* enter scope */
|
||||
vm_push_frame(th, klass_iseq,
|
||||
vm_push_frame(th, class_iseq,
|
||||
FRAME_MAGIC_CLASS, klass, (VALUE) GET_DFP() | 0x02,
|
||||
klass_iseq->iseq_encoded, GET_SP(), 0,
|
||||
klass_iseq->local_size);
|
||||
class_iseq->iseq_encoded, GET_SP(), 0,
|
||||
class_iseq->local_size);
|
||||
RESTORE_REGS();
|
||||
|
||||
INC_VM_STATE_VERSION();
|
||||
@ -1096,7 +1096,7 @@ invokesuper
|
||||
const VALUE flag = VM_CALL_SUPER_BIT | VM_CALL_FCALL_BIT;
|
||||
|
||||
recv = GET_SELF();
|
||||
vm_search_super_klass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass);
|
||||
vm_search_superclass(GET_CFP(), GET_ISEQ(), recv, TOPN(num), &id, &klass);
|
||||
mn = rb_method_node(klass, id);
|
||||
|
||||
CALL_METHOD(num, blockptr, flag, id, mn, recv, klass);
|
||||
|
@ -444,13 +444,13 @@ w_class(char type, VALUE obj, struct dump_arg *arg, int check)
|
||||
}
|
||||
|
||||
static void
|
||||
w_uclass(VALUE obj, VALUE base_klass, struct dump_arg *arg)
|
||||
w_uclass(VALUE obj, VALUE super, struct dump_arg *arg)
|
||||
{
|
||||
VALUE klass = CLASS_OF(obj);
|
||||
|
||||
w_extended(klass, arg, Qtrue);
|
||||
klass = rb_class_real(klass);
|
||||
if (klass != base_klass) {
|
||||
if (klass != super) {
|
||||
w_byte(TYPE_UCLASS, arg);
|
||||
w_unique(RSTRING_PTR(class2path(klass)), arg);
|
||||
}
|
||||
|
2
prec.c
2
prec.c
@ -19,7 +19,7 @@ static ID prc_pr, prc_if;
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* num.prec(klass) => a_klass
|
||||
* num.prec(klass) => a_class
|
||||
*
|
||||
* Converts _self_ into an instance of _klass_. By default,
|
||||
* +prec+ invokes
|
||||
|
73
proc.c
73
proc.c
@ -14,7 +14,8 @@
|
||||
#include "gc.h"
|
||||
|
||||
struct METHOD {
|
||||
VALUE klass, rklass;
|
||||
VALUE oclass; /* class that holds the method */
|
||||
VALUE rclass; /* class of the recevier */
|
||||
VALUE recv;
|
||||
ID id, oid;
|
||||
NODE *body;
|
||||
@ -349,7 +350,7 @@ proc_lambda(void)
|
||||
}
|
||||
|
||||
VALUE
|
||||
proc_invoke(VALUE self, VALUE args, VALUE alt_self, VALUE alt_klass)
|
||||
proc_invoke(VALUE self, VALUE args, VALUE alt_self, VALUE alt_class)
|
||||
{
|
||||
rb_proc_t *proc;
|
||||
GetProcPtr(self, proc);
|
||||
@ -595,8 +596,8 @@ proc_to_proc(VALUE self)
|
||||
void
|
||||
bm_mark(struct METHOD *data)
|
||||
{
|
||||
rb_gc_mark(data->rklass);
|
||||
rb_gc_mark(data->klass);
|
||||
rb_gc_mark(data->rclass);
|
||||
rb_gc_mark(data->oclass);
|
||||
rb_gc_mark(data->recv);
|
||||
rb_gc_mark((VALUE)data->body);
|
||||
}
|
||||
@ -604,17 +605,17 @@ bm_mark(struct METHOD *data)
|
||||
NODE *rb_get_method_body(VALUE klass, ID id, ID *idp);
|
||||
|
||||
static VALUE
|
||||
mnew(VALUE klass, VALUE obj, ID id, VALUE mklass)
|
||||
mnew(VALUE klass, VALUE obj, ID id, VALUE mclass)
|
||||
{
|
||||
VALUE method;
|
||||
NODE *body;
|
||||
struct METHOD *data;
|
||||
VALUE rklass = klass;
|
||||
VALUE rclass = klass;
|
||||
ID oid = id;
|
||||
|
||||
again:
|
||||
if ((body = rb_get_method_body(klass, id, 0)) == 0) {
|
||||
print_undef(rklass, oid);
|
||||
print_undef(rclass, oid);
|
||||
}
|
||||
|
||||
klass = body->nd_clss;
|
||||
@ -625,19 +626,19 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mklass)
|
||||
goto again;
|
||||
}
|
||||
|
||||
while (rklass != klass &&
|
||||
(FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) {
|
||||
rklass = RCLASS_SUPER(rklass);
|
||||
while (rclass != klass &&
|
||||
(FL_TEST(rclass, FL_SINGLETON) || TYPE(rclass) == T_ICLASS)) {
|
||||
rclass = RCLASS_SUPER(rclass);
|
||||
}
|
||||
if (TYPE(klass) == T_ICLASS)
|
||||
klass = RBASIC(klass)->klass;
|
||||
method = Data_Make_Struct(mklass, struct METHOD, bm_mark, -1, data);
|
||||
data->klass = klass;
|
||||
method = Data_Make_Struct(mclass, struct METHOD, bm_mark, -1, data);
|
||||
data->oclass = klass;
|
||||
data->recv = obj;
|
||||
|
||||
data->id = id;
|
||||
data->body = body;
|
||||
data->rklass = rklass;
|
||||
data->rclass = rclass;
|
||||
data->oid = oid;
|
||||
OBJ_INFECT(method, klass);
|
||||
|
||||
@ -692,7 +693,7 @@ method_eq(VALUE method, VALUE other)
|
||||
Data_Get_Struct(method, struct METHOD, m1);
|
||||
Data_Get_Struct(other, struct METHOD, m2);
|
||||
|
||||
if (m1->klass != m2->klass || m1->rklass != m2->rklass ||
|
||||
if (m1->oclass != m2->oclass || m1->rclass != m2->rclass ||
|
||||
m1->recv != m2->recv || m1->body != m2->body)
|
||||
return Qfalse;
|
||||
|
||||
@ -713,8 +714,8 @@ method_hash(VALUE method)
|
||||
long hash;
|
||||
|
||||
Data_Get_Struct(method, struct METHOD, m);
|
||||
hash = (long)m->klass;
|
||||
hash ^= (long)m->rklass;
|
||||
hash = (long)m->oclass;
|
||||
hash ^= (long)m->rclass;
|
||||
hash ^= (long)m->recv;
|
||||
hash ^= (long)m->body;
|
||||
|
||||
@ -740,11 +741,11 @@ method_unbind(VALUE obj)
|
||||
method =
|
||||
Data_Make_Struct(rb_cUnboundMethod, struct METHOD, bm_mark, free,
|
||||
data);
|
||||
data->klass = orig->klass;
|
||||
data->oclass = orig->oclass;
|
||||
data->recv = Qundef;
|
||||
data->id = orig->id;
|
||||
data->body = orig->body;
|
||||
data->rklass = orig->rklass;
|
||||
data->rclass = orig->rclass;
|
||||
data->oid = orig->oid;
|
||||
OBJ_INFECT(method, obj);
|
||||
|
||||
@ -796,7 +797,7 @@ method_owner(VALUE obj)
|
||||
struct METHOD *data;
|
||||
|
||||
Data_Get_Struct(obj, struct METHOD, data);
|
||||
return data->klass;
|
||||
return data->oclass;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -935,16 +936,16 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
|
||||
|
||||
if (RDATA(body)->dmark == (RUBY_DATA_FUNC) bm_mark) {
|
||||
struct METHOD *method = (struct METHOD *)DATA_PTR(body);
|
||||
VALUE rklass = method->rklass;
|
||||
if (rklass != mod) {
|
||||
if (FL_TEST(rklass, FL_SINGLETON)) {
|
||||
VALUE rclass = method->rclass;
|
||||
if (rclass != mod) {
|
||||
if (FL_TEST(rclass, FL_SINGLETON)) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"can't bind singleton method to a different class");
|
||||
}
|
||||
if (!RTEST(rb_class_inherited_p(mod, rklass))) {
|
||||
if (!RTEST(rb_class_inherited_p(mod, rclass))) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"bind argument must be a subclass of %s",
|
||||
rb_class2name(rklass));
|
||||
rb_class2name(rclass));
|
||||
}
|
||||
}
|
||||
node = method->body;
|
||||
@ -1035,7 +1036,7 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
PASS_PASSED_BLOCK();
|
||||
result = vm_call0(GET_THREAD(),
|
||||
data->klass, data->recv, data->id, data->oid,
|
||||
data->oclass, data->recv, data->id, data->oid,
|
||||
argc, argv, data->body, 0);
|
||||
}
|
||||
POP_TAG();
|
||||
@ -1143,21 +1144,21 @@ umethod_bind(VALUE method, VALUE recv)
|
||||
struct METHOD *data, *bound;
|
||||
|
||||
Data_Get_Struct(method, struct METHOD, data);
|
||||
if (data->rklass != CLASS_OF(recv)) {
|
||||
if (FL_TEST(data->rklass, FL_SINGLETON)) {
|
||||
if (data->rclass != CLASS_OF(recv)) {
|
||||
if (FL_TEST(data->rclass, FL_SINGLETON)) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"singleton method called for a different object");
|
||||
}
|
||||
if (!rb_obj_is_kind_of(recv, data->rklass)) {
|
||||
if (!rb_obj_is_kind_of(recv, data->rclass)) {
|
||||
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
||||
rb_class2name(data->rklass));
|
||||
rb_class2name(data->rclass));
|
||||
}
|
||||
}
|
||||
|
||||
method = Data_Make_Struct(rb_cMethod, struct METHOD, bm_mark, free, bound);
|
||||
*bound = *data;
|
||||
bound->recv = recv;
|
||||
bound->rklass = CLASS_OF(recv);
|
||||
bound->rclass = CLASS_OF(recv);
|
||||
|
||||
return method;
|
||||
}
|
||||
@ -1280,11 +1281,11 @@ method_inspect(VALUE method)
|
||||
rb_str_buf_cat2(str, s);
|
||||
rb_str_buf_cat2(str, ": ");
|
||||
|
||||
if (FL_TEST(data->klass, FL_SINGLETON)) {
|
||||
VALUE v = rb_iv_get(data->klass, "__attached__");
|
||||
if (FL_TEST(data->oclass, FL_SINGLETON)) {
|
||||
VALUE v = rb_iv_get(data->oclass, "__attached__");
|
||||
|
||||
if (data->recv == Qundef) {
|
||||
rb_str_buf_append(str, rb_inspect(data->klass));
|
||||
rb_str_buf_append(str, rb_inspect(data->oclass));
|
||||
}
|
||||
else if (data->recv == v) {
|
||||
rb_str_buf_append(str, rb_inspect(v));
|
||||
@ -1299,10 +1300,10 @@ method_inspect(VALUE method)
|
||||
}
|
||||
}
|
||||
else {
|
||||
rb_str_buf_cat2(str, rb_class2name(data->rklass));
|
||||
if (data->rklass != data->klass) {
|
||||
rb_str_buf_cat2(str, rb_class2name(data->rclass));
|
||||
if (data->rclass != data->oclass) {
|
||||
rb_str_buf_cat2(str, "(");
|
||||
rb_str_buf_cat2(str, rb_class2name(data->klass));
|
||||
rb_str_buf_cat2(str, rb_class2name(data->oclass));
|
||||
rb_str_buf_cat2(str, ")");
|
||||
}
|
||||
}
|
||||
|
2
thread.c
2
thread.c
@ -2906,7 +2906,7 @@ call_trace_proc(VALUE args)
|
||||
klass = p->klass;
|
||||
}
|
||||
else {
|
||||
rb_thread_method_id_and_klass(GET_THREAD(), &id, &klass);
|
||||
rb_thread_method_id_and_class(GET_THREAD(), &id, &klass);
|
||||
}
|
||||
if (id == ID_ALLOCATOR)
|
||||
return Qnil;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2007-11-21"
|
||||
#define RUBY_RELEASE_DATE "2007-11-22"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20071121
|
||||
#define RUBY_RELEASE_CODE 20071122
|
||||
#define RUBY_PATCHLEVEL 0
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
@ -9,7 +9,7 @@
|
||||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2007
|
||||
#define RUBY_RELEASE_MONTH 11
|
||||
#define RUBY_RELEASE_DAY 21
|
||||
#define RUBY_RELEASE_DAY 22
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
12
vm.c
12
vm.c
@ -448,7 +448,7 @@ vm_call0(rb_thread_t *th, VALUE klass, VALUE recv,
|
||||
recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1);
|
||||
|
||||
cfp->method_id = id;
|
||||
cfp->method_klass = klass;
|
||||
cfp->method_class = klass;
|
||||
|
||||
val = call_cfunc(body->nd_cfnc, recv, body->nd_argc, argc, argv);
|
||||
|
||||
@ -502,11 +502,11 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv)
|
||||
rb_control_frame_t *cfp = th->cfp;
|
||||
|
||||
if (!cfp->iseq) {
|
||||
klass = cfp->method_klass;
|
||||
klass = cfp->method_class;
|
||||
klass = RCLASS_SUPER(klass);
|
||||
|
||||
if (klass == 0) {
|
||||
klass = vm_search_normal_super_klass(cfp->method_klass, recv);
|
||||
klass = vm_search_normal_superclass(cfp->method_class, recv);
|
||||
}
|
||||
|
||||
id = cfp->method_id;
|
||||
@ -1375,13 +1375,13 @@ rb_iseq_eval(VALUE iseqval)
|
||||
}
|
||||
|
||||
int
|
||||
rb_thread_method_id_and_klass(rb_thread_t *th, ID *idp, VALUE *klassp)
|
||||
rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp)
|
||||
{
|
||||
rb_control_frame_t *cfp = th->cfp;
|
||||
rb_iseq_t *iseq = cfp->iseq;
|
||||
if (!iseq) {
|
||||
if (idp) *idp = cfp->method_id;
|
||||
if (klassp) *klassp = cfp->method_klass;
|
||||
if (klassp) *klassp = cfp->method_class;
|
||||
return 1;
|
||||
}
|
||||
while (iseq) {
|
||||
@ -1420,7 +1420,7 @@ rb_thread_current_status(rb_thread_t *th)
|
||||
}
|
||||
else if (cfp->method_id) {
|
||||
str = rb_sprintf("`%s#%s' (cfunc)",
|
||||
RSTRING_PTR(rb_class_name(cfp->method_klass)),
|
||||
RSTRING_PTR(rb_class_name(cfp->method_class)),
|
||||
rb_id2name(cfp->method_id));
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ typedef struct {
|
||||
rb_iseq_t *block_iseq; /* cfp[8] / block[3] */
|
||||
VALUE proc; /* cfp[9] / block[4] */
|
||||
ID method_id; /* cfp[10] saved in special case */
|
||||
VALUE method_klass; /* cfp[11] saved in special case */
|
||||
VALUE method_class; /* cfp[11] saved in special case */
|
||||
VALUE prof_time_self; /* cfp[12] */
|
||||
VALUE prof_time_chld; /* cfp[13] */
|
||||
} rb_control_frame_t;
|
||||
@ -522,7 +522,7 @@ typedef struct {
|
||||
|
||||
/* inline (method|const) cache */
|
||||
#define NEW_INLINE_CACHE_ENTRY() NEW_WHILE(Qundef, 0, 0)
|
||||
#define ic_klass u1.value
|
||||
#define ic_class u1.value
|
||||
#define ic_method u2.node
|
||||
#define ic_value u2.value
|
||||
#define ic_vmstat u3.cnt
|
||||
@ -593,7 +593,7 @@ void rb_vm_bugreport(void);
|
||||
VALUE rb_iseq_eval(VALUE iseqval);
|
||||
void rb_enable_interrupt(void);
|
||||
void rb_disable_interrupt(void);
|
||||
int rb_thread_method_id_and_klass(rb_thread_t *th, ID *idp, VALUE *klassp);
|
||||
int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
|
||||
|
||||
VALUE vm_eval_body(rb_thread_t *th);
|
||||
VALUE vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, int argc, VALUE *argv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user