ruby-changes:9206
From: nobu <ko1@a...>
Date: Mon, 15 Dec 2008 14:20:11 +0900 (JST)
Subject: [ruby-changes:9206] Ruby:r20743 (trunk): * vm_eval.c (vm_call_super): uses method_missing().
nobu 2008-12-15 14:15:26 +0900 (Mon, 15 Dec 2008) New Revision: 20743 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20743 Log: * vm_eval.c (vm_call_super): uses method_missing(). * vm_eval.c (method_missing): get rid of too large alloca. * vm_eval.c (rb_call0, method_missing): uses idMethodMissing. * vm_method.c (rb_add_method, remove_method, rb_undef): uses id__send__. * vm_method.c (Init_eval_method): removed IDs which are defined as immediate values. Modified files: trunk/ChangeLog trunk/vm_eval.c trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 20742) +++ ChangeLog (revision 20743) @@ -1,3 +1,17 @@ +Mon Dec 15 14:15:23 2008 Nobuyoshi Nakada <nobu@r...> + + * vm_eval.c (vm_call_super): uses method_missing(). + + * vm_eval.c (method_missing): get rid of too large alloca. + + * vm_eval.c (rb_call0, method_missing): uses idMethodMissing. + + * vm_method.c (rb_add_method, remove_method, rb_undef): uses + id__send__. + + * vm_method.c (Init_eval_method): removed IDs which are defined as + immediate values. + Mon Dec 15 11:35:27 2008 Nobuyoshi Nakada <nobu@r...> * vm.c (vm_backtrace): defaults to script name for C functions. Index: vm_eval.c =================================================================== --- vm_eval.c (revision 20742) +++ vm_eval.c (revision 20743) @@ -137,28 +137,11 @@ } body = rb_method_node(klass, id); /* this returns NODE_METHOD */ - - if (body) { - body = body->nd_body; + if (!body) { + return method_missing(recv, id, argc, argv, 0); } - else { - VALUE *argv_m, result, argv_ary = 0; - if (argc < 0x100) { - argv_m = ALLOCA_N(VALUE, argc+1); - } - else { - argv_ary = rb_ary_tmp_new(argc+1); - argv_m = RARRAY_PTR(argv_ary); - } - MEMCPY(argv_m + 1, argv, VALUE, argc); - argv_m[0] = ID2SYM(id); - th->method_missing_reason = 0; - th->passed_block = 0; - result = rb_funcall2(recv, idMethodMissing, argc + 1, argv_m); - if (argv_ary) rb_ary_clear(argv_ary); - return result; - } + body = body->nd_body; return vm_call0(th, klass, recv, id, id, argc, argv, body, CALL_SUPER); } @@ -221,7 +204,7 @@ } - if (mid != missing) { + if (mid != idMethodMissing) { /* receiver specified form for private method */ if (UNLIKELY(noex)) { if (((noex & NOEX_MASK) & NOEX_PRIVATE) && scope == 0) { @@ -347,10 +330,13 @@ static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status) { - VALUE *nargv; - GET_THREAD()->method_missing_reason = call_status; + VALUE *nargv, result, argv_ary = 0; + rb_thread_t *th = GET_THREAD(); - if (id == missing) { + th->method_missing_reason = call_status; + th->passed_block = 0; + + if (id == idMethodMissing) { rb_method_missing(argc, argv, obj); } else if (id == ID_ALLOCATOR) { @@ -358,11 +344,19 @@ rb_class2name(obj)); } - nargv = ALLOCA_N(VALUE, argc + 1); + if (argc < 0x100) { + nargv = ALLOCA_N(VALUE, argc + 1); + } + else { + argv_ary = rb_ary_tmp_new(argc + 1); + nargv = RARRAY_PTR(argv_ary); + } nargv[0] = ID2SYM(id); MEMCPY(nargv + 1, argv, VALUE, argc); - return rb_funcall2(obj, missing, argc + 1, nargv); + result = rb_funcall2(obj, idMethodMissing, argc + 1, nargv); + if (argv_ary) rb_ary_clear(argv_ary); + return result; } VALUE Index: vm_method.c =================================================================== --- vm_method.c (revision 20742) +++ vm_method.c (revision 20743) @@ -8,9 +8,8 @@ static void rb_vm_check_redefinition_opt_method(const NODE *node); -static ID __send__, object_id; +static ID object_id; static ID removed, singleton_removed, undefined, singleton_undefined; -static ID eqq, each, aref, aset, match, missing; static ID added, singleton_added; struct cache_entry { /* method hash table. */ @@ -166,7 +165,7 @@ rb_warn("redefining Object#initialize may cause infinite loop"); } - if (mid == object_id || mid == __send__) { + if (mid == object_id || mid == id__send__) { if (node && nd_type(node) == RUBY_VM_METHOD_NODE) { rb_warn("redefining `%s' may cause serious problem", rb_id2name(mid)); @@ -313,7 +312,7 @@ } if (OBJ_FROZEN(klass)) rb_error_frozen("class/module"); - if (mid == object_id || mid == __send__ || mid == idInitialize) { + if (mid == object_id || mid == id__send__ || mid == idInitialize) { rb_warn("removing `%s' may cause serious problem", rb_id2name(mid)); } if (st_lookup(RCLASS_M_TBL(klass), mid, &data)) { @@ -480,7 +479,7 @@ rb_id2name(id)); } rb_frozen_class_p(klass); - if (id == object_id || id == __send__ || id == idInitialize) { + if (id == object_id || id == id__send__ || id == idInitialize) { rb_warn("undefining `%s' may cause serious problem", rb_id2name(id)); } body = search_method(klass, id, &origin); @@ -1128,13 +1127,6 @@ rb_define_singleton_method(rb_vm_top_self(), "private", top_private, -1); object_id = rb_intern("object_id"); - __send__ = rb_intern("__send__"); - eqq = rb_intern("==="); - each = rb_intern("each"); - aref = rb_intern("[]"); - aset = rb_intern("[]="); - match = rb_intern("=~"); - missing = rb_intern("method_missing"); added = rb_intern("method_added"); singleton_added = rb_intern("singleton_method_added"); removed = rb_intern("method_removed"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/