From: nobu.nokada@... Date: 2004-05-25T18:15:17+09:00 Subject: Re: RCR? change Proc#inspect to show start..end lines Hi, At Tue, 25 May 2004 05:39:16 +0900, Joel VanderWerf wrote in [ruby-talk:101253]: > It would be easier to extract the entire code block without doing > parsing if Proc#inspect returned a _range_ of lines: > > # Unfortunately, there's no more room for it. > I thought that eval-ing __LINE__ against the proc's binding might give > the last line of the proc's definition, but actually the results are > surprisingly inconsistent: I think this has no bad side effects. Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.665 diff -u -2 -p -r1.665 eval.c --- eval.c 25 May 2004 02:54:21 -0000 1.665 +++ eval.c 25 May 2004 08:49:56 -0000 @@ -2932,4 +2932,5 @@ rb_eval(self, n) PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { + ruby_frame->node = node; result = rb_eval(self, node->nd_iter); } @@ -6043,8 +6044,8 @@ eval(self, src, scope, file, line) old_wrapper = ruby_wrapper; ruby_wrapper = data->wrapper; - if ((file == 0 || (line == 1 && strcmp(file, "(eval)") == 0)) && data->body) { - file = data->body->nd_file; + if (file == 0 || (line == 1 && strcmp(file, "(eval)") == 0)) { + file = data->frame.node->nd_file; if (!file) file = "__builtin__"; - line = nd_line(data->body); + line = nd_line(data->frame.node); } -- Nobu Nakada