diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-22 13:37:26 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-22 13:37:26 +0000 |
commit | 31c561f66a4fc727f24a1010bf1dfff6f6c85ffc (patch) | |
tree | 8531808ccda96f0f65d1f12d544e953df0ca6014 /compile.c | |
parent | 506a9821ce44db2b02bf3da99bef8b2e55f46562 (diff) | |
download | ruby-31c561f66a4fc727f24a1010bf1dfff6f6c85ffc.tar.gz |
* vm_core.h (struct rb_iseq_t): add a new field line_no. This field
represents line number from which the original code of the iseq
starts. [ruby-dev:38698]
* iseq.c, compile.c: ditto.
* parse.y: line number hack (for Proc#source_location) is no longer
needed.
* test/ruby/test_settracefunc.rb: line number of set_trace_func is now
compatible with 1.8's.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 43 |
1 files changed, 20 insertions, 23 deletions
@@ -168,14 +168,11 @@ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2); #define iseq_filename(iseq) \ (((rb_iseq_t*)DATA_PTR(iseq))->filename) -#define NEW_ISEQVAL(node, name, type) \ - new_child_iseq(iseq, node, name, 0, type) +#define NEW_ISEQVAL(node, name, type, line_no) \ + new_child_iseq(iseq, node, name, 0, type, line_no) -#define NEW_CHILD_ISEQVAL(node, name, type) \ - new_child_iseq(iseq, node, name, iseq->self, type) - -#define NEW_SPECIAQL_BLOCK_ISEQVAL(iseq, sym) \ - new_child_iseq(iseq, iseq->node, iseq->name, iseq->parent_iseq, iseq->type, sym) +#define NEW_CHILD_ISEQVAL(node, name, type, line_no) \ + new_child_iseq(iseq, node, name, iseq->self, type, line_no) /* add instructions */ #define ADD_SEQ(seq1, seq2) \ @@ -449,13 +446,13 @@ rb_iseq_compile_node(VALUE self, NODE *node) break; } case ISEQ_TYPE_CLASS: { - ADD_TRACE(ret, nd_line(node), RUBY_EVENT_CLASS); + ADD_TRACE(ret, FIX2INT(iseq->line_no), RUBY_EVENT_CLASS); COMPILE(ret, "scoped node", node->nd_body); ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END); break; } case ISEQ_TYPE_METHOD: { - ADD_TRACE(ret, nd_line(node), RUBY_EVENT_CALL); + ADD_TRACE(ret, FIX2INT(iseq->line_no), RUBY_EVENT_CALL); COMPILE(ret, "scoped node", node->nd_body); ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN); break; @@ -911,12 +908,12 @@ new_insn_send(rb_iseq_t *iseq, int line_no, static VALUE new_child_iseq(rb_iseq_t *iseq, NODE *node, - VALUE name, VALUE parent, VALUE type) + VALUE name, VALUE parent, VALUE type, int line_no) { VALUE ret; debugs("[new_child_iseq]> ---------------------------------------\n"); - ret = rb_iseq_new_with_opt(node, name, iseq_filename(iseq->self), + ret = rb_iseq_new_with_opt(node, name, iseq_filename(iseq->self), INT2FIX(line_no), parent, type, iseq->compile_data->option); debugs("[new_child_iseq]< ---------------------------------------\n"); iseq_add_mark_object(iseq, ret); @@ -2678,7 +2675,7 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret, rb_str_concat(rb_str_new2 ("defined guard in "), iseq->name), - ISEQ_TYPE_DEFINED_GUARD); + ISEQ_TYPE_DEFINED_GUARD, 0); defined_expr(iseq, ret, node->nd_recv, lfinish, Qfalse); ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]); @@ -3256,7 +3253,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) iseq->compile_data->current_block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), - ISEQ_TYPE_BLOCK); + ISEQ_TYPE_BLOCK, nd_line(node)); mid = idEach; ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0), @@ -3265,7 +3262,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) else { iseq->compile_data->current_block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), - ISEQ_TYPE_BLOCK); + ISEQ_TYPE_BLOCK, nd_line(node)); COMPILE(ret, "iter caller", node->nd_iter); } ADD_LABEL(ret, retry_end_l); @@ -3499,7 +3496,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) VALUE rescue = NEW_CHILD_ISEQVAL( node->nd_resq, rb_str_concat(rb_str_new2("rescue in "), iseq->name), - ISEQ_TYPE_RESCUE); + ISEQ_TYPE_RESCUE, nd_line(node)); ADD_LABEL(ret, lstart); COMPILE(ret, "rescue head", node->nd_head); @@ -3581,7 +3578,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) rb_str_concat(rb_str_new2 ("ensure in "), iseq->name), - ISEQ_TYPE_ENSURE); + ISEQ_TYPE_ENSURE, nd_line(node)); LABEL *lstart = NEW_LABEL(nd_line(node)); LABEL *lend = NEW_LABEL(nd_line(node)); LABEL *lcont = NEW_LABEL(nd_line(node)); @@ -4495,7 +4492,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_DEFN:{ VALUE iseqval = NEW_ISEQVAL(node->nd_defn, rb_str_dup(rb_id2str(node->nd_mid)), - ISEQ_TYPE_METHOD); + ISEQ_TYPE_METHOD, nd_line(node)); debugp_param("defn/iseq", iseqval); @@ -4515,7 +4512,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_DEFS:{ VALUE iseqval = NEW_ISEQVAL(node->nd_defn, rb_str_dup(rb_id2str(node->nd_mid)), - ISEQ_TYPE_METHOD); + ISEQ_TYPE_METHOD, nd_line(node)); debugp_param("defs/iseq", iseqval); @@ -4569,7 +4566,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) NEW_CHILD_ISEQVAL( node->nd_body, rb_sprintf("<class:%s>", rb_id2name(node->nd_cpath->nd_mid)), - ISEQ_TYPE_CLASS); + ISEQ_TYPE_CLASS, nd_line(node)); compile_cpath(ret, iseq, node->nd_cpath); COMPILE(ret, "super", node->nd_super); ADD_INSN3(ret, nd_line(node), defineclass, @@ -4584,7 +4581,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) VALUE iseqval = NEW_CHILD_ISEQVAL( node->nd_body, rb_sprintf("<module:%s>", rb_id2name(node->nd_cpath->nd_mid)), - ISEQ_TYPE_CLASS); + ISEQ_TYPE_CLASS, nd_line(node)); compile_cpath(ret, iseq, node->nd_cpath); ADD_INSN (ret, nd_line(node), putnil); /* dummy */ @@ -4599,7 +4596,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) ID singletonclass; VALUE iseqval = NEW_ISEQVAL(node->nd_body, rb_str_new2("singletonclass"), - ISEQ_TYPE_CLASS); + ISEQ_TYPE_CLASS, nd_line(node)); COMPILE(ret, "sclass#recv", node->nd_recv); ADD_INSN (ret, nd_line(node), putnil); @@ -4802,7 +4799,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_POSTEXE:{ LABEL *lstart = NEW_LABEL(nd_line(node)); LABEL *lend = NEW_LABEL(nd_line(node)); - VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK); + VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(node)); ADD_LABEL(ret, lstart); ADD_INSN1(ret, nd_line(node), onceinlinecache, lend); @@ -4895,7 +4892,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) } case NODE_LAMBDA:{ /* compile same as lambda{...} */ - VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK); + VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(node)); VALUE argc = INT2FIX(0); ADD_CALL_RECEIVER(ret, nd_line(node)); ADD_CALL_WITH_BLOCK(ret, nd_line(node), ID2SYM(idLambda), argc, block); |