ruby-changes:36770
From: nobu <ko1@a...>
Date: Tue, 16 Dec 2014 04:13:20 +0900 (JST)
Subject: [ruby-changes:36770] nobu:r48851 (trunk): iseq.c: use caller location
nobu 2014-12-16 04:13:15 +0900 (Tue, 16 Dec 2014) New Revision: 48851 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48851 Log: iseq.c: use caller location * iseq.c (rb_method_for_self_aref, rb_method_for_self_aset): set same location as the caller. Modified files: trunk/iseq.c Index: iseq.c =================================================================== --- iseq.c (revision 48850) +++ iseq.c (revision 48851) @@ -548,13 +548,28 @@ iseq_load(VALUE self, VALUE data, VALUE https://github.com/ruby/ruby/blob/trunk/iseq.c#L548 return iseqval; } +static VALUE +caller_location(VALUE *path) +{ + rb_thread_t *th = GET_THREAD(); + rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); + if (cfp) { + int line = rb_vm_get_sourceline(cfp); + *path = cfp->iseq->location.path; + return INT2FIX(line); + } + else { + *path = rb_str_new2("<compiled>"); + return INT2FIX(1); + } +} + VALUE rb_method_for_self_aref(VALUE name, VALUE arg) { VALUE iseqval = iseq_alloc(rb_cISeq); rb_iseq_t *iseq; - VALUE path = rb_str_new2("<compiled>"); - VALUE lineno = INT2FIX(1); + VALUE path, lineno = caller_location(&path); VALUE parent = 0; VALUE misc, locals, params, exception, body, send_arg; int flag = VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE; @@ -603,8 +618,7 @@ rb_method_for_self_aset(VALUE name, VALU https://github.com/ruby/ruby/blob/trunk/iseq.c#L618 { VALUE iseqval = iseq_alloc(rb_cISeq); rb_iseq_t *iseq; - VALUE path = rb_str_new2("<compiled>"); - VALUE lineno = INT2FIX(1); + VALUE path, lineno = caller_location(&path); VALUE parent = 0; VALUE misc, locals, params, exception, body, send_arg; int flag = VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/