зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
506a9821ce
Коммит
31c561f66a
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
Wed Jul 22 22:23:24 2009 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Wed Jul 22 22:16:48 2009 URABE Shyouhei <shyouhei@ruby-lang.org>
|
Wed Jul 22 22:16:48 2009 URABE Shyouhei <shyouhei@ruby-lang.org>
|
||||||
|
|
||||||
* method.h : Commas at end of enum list not allowed as of C89
|
* method.h : Commas at end of enum list not allowed as of C89
|
||||||
|
|
43
compile.c
43
compile.c
|
@ -168,14 +168,11 @@ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
||||||
#define iseq_filename(iseq) \
|
#define iseq_filename(iseq) \
|
||||||
(((rb_iseq_t*)DATA_PTR(iseq))->filename)
|
(((rb_iseq_t*)DATA_PTR(iseq))->filename)
|
||||||
|
|
||||||
#define NEW_ISEQVAL(node, name, type) \
|
#define NEW_ISEQVAL(node, name, type, line_no) \
|
||||||
new_child_iseq(iseq, node, name, 0, type)
|
new_child_iseq(iseq, node, name, 0, type, line_no)
|
||||||
|
|
||||||
#define NEW_CHILD_ISEQVAL(node, name, type) \
|
#define NEW_CHILD_ISEQVAL(node, name, type, line_no) \
|
||||||
new_child_iseq(iseq, node, name, iseq->self, type)
|
new_child_iseq(iseq, node, name, iseq->self, type, line_no)
|
||||||
|
|
||||||
#define NEW_SPECIAQL_BLOCK_ISEQVAL(iseq, sym) \
|
|
||||||
new_child_iseq(iseq, iseq->node, iseq->name, iseq->parent_iseq, iseq->type, sym)
|
|
||||||
|
|
||||||
/* add instructions */
|
/* add instructions */
|
||||||
#define ADD_SEQ(seq1, seq2) \
|
#define ADD_SEQ(seq1, seq2) \
|
||||||
|
@ -449,13 +446,13 @@ rb_iseq_compile_node(VALUE self, NODE *node)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISEQ_TYPE_CLASS: {
|
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);
|
COMPILE(ret, "scoped node", node->nd_body);
|
||||||
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END);
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISEQ_TYPE_METHOD: {
|
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);
|
COMPILE(ret, "scoped node", node->nd_body);
|
||||||
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
|
||||||
break;
|
break;
|
||||||
|
@ -911,12 +908,12 @@ new_insn_send(rb_iseq_t *iseq, int line_no,
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
new_child_iseq(rb_iseq_t *iseq, NODE *node,
|
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;
|
VALUE ret;
|
||||||
|
|
||||||
debugs("[new_child_iseq]> ---------------------------------------\n");
|
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);
|
parent, type, iseq->compile_data->option);
|
||||||
debugs("[new_child_iseq]< ---------------------------------------\n");
|
debugs("[new_child_iseq]< ---------------------------------------\n");
|
||||||
iseq_add_mark_object(iseq, ret);
|
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
|
rb_str_concat(rb_str_new2
|
||||||
("defined guard in "),
|
("defined guard in "),
|
||||||
iseq->name),
|
iseq->name),
|
||||||
ISEQ_TYPE_DEFINED_GUARD);
|
ISEQ_TYPE_DEFINED_GUARD, 0);
|
||||||
|
|
||||||
defined_expr(iseq, ret, node->nd_recv, lfinish, Qfalse);
|
defined_expr(iseq, ret, node->nd_recv, lfinish, Qfalse);
|
||||||
ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
|
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 =
|
iseq->compile_data->current_block =
|
||||||
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
|
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
|
||||||
ISEQ_TYPE_BLOCK);
|
ISEQ_TYPE_BLOCK, nd_line(node));
|
||||||
|
|
||||||
mid = idEach;
|
mid = idEach;
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0),
|
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 {
|
else {
|
||||||
iseq->compile_data->current_block =
|
iseq->compile_data->current_block =
|
||||||
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
|
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);
|
COMPILE(ret, "iter caller", node->nd_iter);
|
||||||
}
|
}
|
||||||
ADD_LABEL(ret, retry_end_l);
|
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(
|
VALUE rescue = NEW_CHILD_ISEQVAL(
|
||||||
node->nd_resq,
|
node->nd_resq,
|
||||||
rb_str_concat(rb_str_new2("rescue in "), iseq->name),
|
rb_str_concat(rb_str_new2("rescue in "), iseq->name),
|
||||||
ISEQ_TYPE_RESCUE);
|
ISEQ_TYPE_RESCUE, nd_line(node));
|
||||||
|
|
||||||
ADD_LABEL(ret, lstart);
|
ADD_LABEL(ret, lstart);
|
||||||
COMPILE(ret, "rescue head", node->nd_head);
|
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
|
rb_str_concat(rb_str_new2
|
||||||
("ensure in "),
|
("ensure in "),
|
||||||
iseq->name),
|
iseq->name),
|
||||||
ISEQ_TYPE_ENSURE);
|
ISEQ_TYPE_ENSURE, nd_line(node));
|
||||||
LABEL *lstart = NEW_LABEL(nd_line(node));
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
||||||
LABEL *lend = NEW_LABEL(nd_line(node));
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
||||||
LABEL *lcont = 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:{
|
case NODE_DEFN:{
|
||||||
VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
|
VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
|
||||||
rb_str_dup(rb_id2str(node->nd_mid)),
|
rb_str_dup(rb_id2str(node->nd_mid)),
|
||||||
ISEQ_TYPE_METHOD);
|
ISEQ_TYPE_METHOD, nd_line(node));
|
||||||
|
|
||||||
debugp_param("defn/iseq", iseqval);
|
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:{
|
case NODE_DEFS:{
|
||||||
VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
|
VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
|
||||||
rb_str_dup(rb_id2str(node->nd_mid)),
|
rb_str_dup(rb_id2str(node->nd_mid)),
|
||||||
ISEQ_TYPE_METHOD);
|
ISEQ_TYPE_METHOD, nd_line(node));
|
||||||
|
|
||||||
debugp_param("defs/iseq", iseqval);
|
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(
|
NEW_CHILD_ISEQVAL(
|
||||||
node->nd_body,
|
node->nd_body,
|
||||||
rb_sprintf("<class:%s>", rb_id2name(node->nd_cpath->nd_mid)),
|
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_cpath(ret, iseq, node->nd_cpath);
|
||||||
COMPILE(ret, "super", node->nd_super);
|
COMPILE(ret, "super", node->nd_super);
|
||||||
ADD_INSN3(ret, nd_line(node), defineclass,
|
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(
|
VALUE iseqval = NEW_CHILD_ISEQVAL(
|
||||||
node->nd_body,
|
node->nd_body,
|
||||||
rb_sprintf("<module:%s>", rb_id2name(node->nd_cpath->nd_mid)),
|
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);
|
compile_cpath(ret, iseq, node->nd_cpath);
|
||||||
ADD_INSN (ret, nd_line(node), putnil); /* dummy */
|
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;
|
ID singletonclass;
|
||||||
VALUE iseqval =
|
VALUE iseqval =
|
||||||
NEW_ISEQVAL(node->nd_body, rb_str_new2("singletonclass"),
|
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);
|
COMPILE(ret, "sclass#recv", node->nd_recv);
|
||||||
ADD_INSN (ret, nd_line(node), putnil);
|
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:{
|
case NODE_POSTEXE:{
|
||||||
LABEL *lstart = NEW_LABEL(nd_line(node));
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
||||||
LABEL *lend = 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_LABEL(ret, lstart);
|
||||||
ADD_INSN1(ret, nd_line(node), onceinlinecache, lend);
|
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:{
|
case NODE_LAMBDA:{
|
||||||
/* compile same as 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);
|
VALUE argc = INT2FIX(0);
|
||||||
ADD_CALL_RECEIVER(ret, nd_line(node));
|
ADD_CALL_RECEIVER(ret, nd_line(node));
|
||||||
ADD_CALL_WITH_BLOCK(ret, nd_line(node), ID2SYM(idLambda), argc, block);
|
ADD_CALL_WITH_BLOCK(ret, nd_line(node), ID2SYM(idLambda), argc, block);
|
||||||
|
|
43
iseq.c
43
iseq.c
|
@ -213,7 +213,7 @@ set_relation(rb_iseq_t *iseq, const VALUE parent)
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
prepare_iseq_build(rb_iseq_t *iseq,
|
prepare_iseq_build(rb_iseq_t *iseq,
|
||||||
VALUE name, VALUE filename,
|
VALUE name, VALUE filename, VALUE line_no,
|
||||||
VALUE parent, VALUE type, VALUE block_opt,
|
VALUE parent, VALUE type, VALUE block_opt,
|
||||||
const rb_compile_option_t *option)
|
const rb_compile_option_t *option)
|
||||||
{
|
{
|
||||||
|
@ -222,6 +222,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
|
||||||
|
|
||||||
iseq->name = name;
|
iseq->name = name;
|
||||||
iseq->filename = filename;
|
iseq->filename = filename;
|
||||||
|
iseq->line_no = line_no;
|
||||||
iseq->defined_method_id = 0;
|
iseq->defined_method_id = 0;
|
||||||
iseq->mark_ary = rb_ary_new();
|
iseq->mark_ary = rb_ary_new();
|
||||||
RBASIC(iseq->mark_ary)->klass = 0;
|
RBASIC(iseq->mark_ary)->klass = 0;
|
||||||
|
@ -365,14 +366,14 @@ VALUE
|
||||||
rb_iseq_new(NODE *node, VALUE name, VALUE filename,
|
rb_iseq_new(NODE *node, VALUE name, VALUE filename,
|
||||||
VALUE parent, VALUE type)
|
VALUE parent, VALUE type)
|
||||||
{
|
{
|
||||||
return rb_iseq_new_with_opt(node, name, filename, parent, type,
|
return rb_iseq_new_with_opt(node, name, filename, INT2FIX(0), parent, type,
|
||||||
&COMPILE_OPTION_DEFAULT);
|
&COMPILE_OPTION_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE parent)
|
rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE parent)
|
||||||
{
|
{
|
||||||
return rb_iseq_new_with_opt(node, name, filename, parent, ISEQ_TYPE_TOP,
|
return rb_iseq_new_with_opt(node, name, filename, INT2FIX(0), parent, ISEQ_TYPE_TOP,
|
||||||
&COMPILE_OPTION_DEFAULT);
|
&COMPILE_OPTION_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,12 +382,12 @@ rb_iseq_new_main(NODE *node, VALUE filename)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
VALUE parent = th->base_block->iseq->self;
|
VALUE parent = th->base_block->iseq->self;
|
||||||
return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), filename,
|
return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), filename, INT2FIX(0),
|
||||||
parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
|
parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename,
|
rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename, VALUE line_no,
|
||||||
VALUE parent, VALUE type, VALUE bopt,
|
VALUE parent, VALUE type, VALUE bopt,
|
||||||
const rb_compile_option_t *option)
|
const rb_compile_option_t *option)
|
||||||
{
|
{
|
||||||
|
@ -396,28 +397,28 @@ rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename,
|
||||||
GetISeqPtr(self, iseq);
|
GetISeqPtr(self, iseq);
|
||||||
iseq->self = self;
|
iseq->self = self;
|
||||||
|
|
||||||
prepare_iseq_build(iseq, name, filename, parent, type, bopt, option);
|
prepare_iseq_build(iseq, name, filename, line_no, parent, type, bopt, option);
|
||||||
rb_iseq_compile_node(self, node);
|
rb_iseq_compile_node(self, node);
|
||||||
cleanup_iseq_build(iseq);
|
cleanup_iseq_build(iseq);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_iseq_new_with_opt(NODE *node, VALUE name, VALUE filename,
|
rb_iseq_new_with_opt(NODE *node, VALUE name, VALUE filename, VALUE line_no,
|
||||||
VALUE parent, VALUE type,
|
VALUE parent, VALUE type,
|
||||||
const rb_compile_option_t *option)
|
const rb_compile_option_t *option)
|
||||||
{
|
{
|
||||||
/* TODO: argument check */
|
/* TODO: argument check */
|
||||||
return rb_iseq_new_with_bopt_and_opt(node, name, filename, parent, type,
|
return rb_iseq_new_with_bopt_and_opt(node, name, filename, line_no, parent, type,
|
||||||
Qfalse, option);
|
Qfalse, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE filename,
|
rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE filename, VALUE line_no,
|
||||||
VALUE parent, VALUE type, VALUE bopt)
|
VALUE parent, VALUE type, VALUE bopt)
|
||||||
{
|
{
|
||||||
/* TODO: argument check */
|
/* TODO: argument check */
|
||||||
return rb_iseq_new_with_bopt_and_opt(node, name, filename, parent, type,
|
return rb_iseq_new_with_bopt_and_opt(node, name, filename, line_no, parent, type,
|
||||||
bopt, &COMPILE_OPTION_DEFAULT);
|
bopt, &COMPILE_OPTION_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +432,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
|
||||||
VALUE iseqval = iseq_alloc(self);
|
VALUE iseqval = iseq_alloc(self);
|
||||||
|
|
||||||
VALUE magic, version1, version2, format_type, misc;
|
VALUE magic, version1, version2, format_type, misc;
|
||||||
VALUE name, filename;
|
VALUE name, filename, line_no;
|
||||||
VALUE type, body, locals, args, exception;
|
VALUE type, body, locals, args, exception;
|
||||||
|
|
||||||
VALUE iseq_type;
|
VALUE iseq_type;
|
||||||
|
@ -441,7 +442,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
/* [magic, major_version, minor_version, format_type, misc,
|
/* [magic, major_version, minor_version, format_type, misc,
|
||||||
* name, filename,
|
* name, filename, line_no,
|
||||||
* type, locals, args, exception_table, body]
|
* type, locals, args, exception_table, body]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -455,6 +456,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
|
||||||
|
|
||||||
name = CHECK_STRING(rb_ary_entry(data, i++));
|
name = CHECK_STRING(rb_ary_entry(data, i++));
|
||||||
filename = CHECK_STRING(rb_ary_entry(data, i++));
|
filename = CHECK_STRING(rb_ary_entry(data, i++));
|
||||||
|
line_no = CHECK_INTEGER(rb_ary_entry(data, i++));
|
||||||
|
|
||||||
type = CHECK_SYMBOL(rb_ary_entry(data, i++));
|
type = CHECK_SYMBOL(rb_ary_entry(data, i++));
|
||||||
locals = CHECK_ARRAY(rb_ary_entry(data, i++));
|
locals = CHECK_ARRAY(rb_ary_entry(data, i++));
|
||||||
|
@ -496,7 +498,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
make_compile_option(&option, opt);
|
make_compile_option(&option, opt);
|
||||||
prepare_iseq_build(iseq, name, filename,
|
prepare_iseq_build(iseq, name, filename, line_no,
|
||||||
parent, iseq_type, 0, &option);
|
parent, iseq_type, 0, &option);
|
||||||
|
|
||||||
rb_iseq_build_from_ary(iseq, locals, args, exception, body);
|
rb_iseq_build_from_ary(iseq, locals, args, exception, body);
|
||||||
|
@ -544,11 +546,11 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE line, VALUE opt)
|
||||||
|
|
||||||
if (th->base_block && th->base_block->iseq) {
|
if (th->base_block && th->base_block->iseq) {
|
||||||
return rb_iseq_new_with_opt(node, th->base_block->iseq->name,
|
return rb_iseq_new_with_opt(node, th->base_block->iseq->name,
|
||||||
file, th->base_block->iseq->self,
|
file, line, th->base_block->iseq->self,
|
||||||
ISEQ_TYPE_EVAL, &option);
|
ISEQ_TYPE_EVAL, &option);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return rb_iseq_new_with_opt(node, rb_str_new2("<compiled>"), file, Qfalse,
|
return rb_iseq_new_with_opt(node, rb_str_new2("<compiled>"), file, line, Qfalse,
|
||||||
ISEQ_TYPE_TOP, &option);
|
ISEQ_TYPE_TOP, &option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -593,7 +595,7 @@ iseq_s_compile_file(int argc, VALUE *argv, VALUE self)
|
||||||
parser = rb_parser_new();
|
parser = rb_parser_new();
|
||||||
node = rb_parser_compile_file(parser, fname, f, NUM2INT(line));
|
node = rb_parser_compile_file(parser, fname, f, NUM2INT(line));
|
||||||
make_compile_option(&option, opt);
|
make_compile_option(&option, opt);
|
||||||
return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), file, Qfalse,
|
return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), file, line, Qfalse,
|
||||||
ISEQ_TYPE_TOP, &option);
|
ISEQ_TYPE_TOP, &option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +661,7 @@ iseq_to_a(VALUE self)
|
||||||
int
|
int
|
||||||
rb_iseq_first_lineno(rb_iseq_t *iseq)
|
rb_iseq_first_lineno(rb_iseq_t *iseq)
|
||||||
{
|
{
|
||||||
return iseq->insn_info_table[0].line_no;
|
return FIX2INT(iseq->line_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: search algorithm is brute force.
|
/* TODO: search algorithm is brute force.
|
||||||
|
@ -1298,7 +1300,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* [:magic, :major_version, :minor_version, :format_type, :misc,
|
* [:magic, :major_version, :minor_version, :format_type, :misc,
|
||||||
* :name, :filename, :type, :locals, :args,
|
* :name, :filename, :line_no, :type, :locals, :args,
|
||||||
* :catch_table, :bytecode]
|
* :catch_table, :bytecode]
|
||||||
*/
|
*/
|
||||||
rb_ary_push(val, rb_str_new2("YARVInstructionSequence/SimpleDataFormat"));
|
rb_ary_push(val, rb_str_new2("YARVInstructionSequence/SimpleDataFormat"));
|
||||||
|
@ -1308,6 +1310,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
|
||||||
rb_ary_push(val, misc);
|
rb_ary_push(val, misc);
|
||||||
rb_ary_push(val, iseq->name);
|
rb_ary_push(val, iseq->name);
|
||||||
rb_ary_push(val, iseq->filename);
|
rb_ary_push(val, iseq->filename);
|
||||||
|
rb_ary_push(val, iseq->line_no);
|
||||||
rb_ary_push(val, type);
|
rb_ary_push(val, type);
|
||||||
rb_ary_push(val, locals);
|
rb_ary_push(val, locals);
|
||||||
rb_ary_push(val, args);
|
rb_ary_push(val, args);
|
||||||
|
@ -1414,7 +1417,8 @@ rb_iseq_build_for_ruby2cext(
|
||||||
const VALUE *arg_opt_table,
|
const VALUE *arg_opt_table,
|
||||||
const struct iseq_catch_table_entry *catch_table,
|
const struct iseq_catch_table_entry *catch_table,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *filename)
|
const char *filename,
|
||||||
|
const unsigned short line_no)
|
||||||
{
|
{
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
VALUE iseqval = iseq_alloc(rb_cISeq);
|
VALUE iseqval = iseq_alloc(rb_cISeq);
|
||||||
|
@ -1425,6 +1429,7 @@ rb_iseq_build_for_ruby2cext(
|
||||||
*iseq = *iseq_template;
|
*iseq = *iseq_template;
|
||||||
iseq->name = rb_str_new2(name);
|
iseq->name = rb_str_new2(name);
|
||||||
iseq->filename = rb_str_new2(filename);
|
iseq->filename = rb_str_new2(filename);
|
||||||
|
iseq->line_no = line_no;
|
||||||
iseq->mark_ary = rb_ary_tmp_new(3);
|
iseq->mark_ary = rb_ary_tmp_new(3);
|
||||||
iseq->self = iseqval;
|
iseq->self = iseqval;
|
||||||
|
|
||||||
|
|
4
parse.y
4
parse.y
|
@ -2896,7 +2896,6 @@ primary : literal
|
||||||
reduce_nodes(&body);
|
reduce_nodes(&body);
|
||||||
$$ = NEW_DEFN($2, $4, body, NOEX_PRIVATE);
|
$$ = NEW_DEFN($2, $4, body, NOEX_PRIVATE);
|
||||||
fixpos($$, $4);
|
fixpos($$, $4);
|
||||||
fixpos($$->nd_defn, $4);
|
|
||||||
local_pop();
|
local_pop();
|
||||||
/*%
|
/*%
|
||||||
$$ = dispatch3(def, $2, $4, $5);
|
$$ = dispatch3(def, $2, $4, $5);
|
||||||
|
@ -2922,7 +2921,6 @@ primary : literal
|
||||||
reduce_nodes(&body);
|
reduce_nodes(&body);
|
||||||
$$ = NEW_DEFS($2, $5, $7, body);
|
$$ = NEW_DEFS($2, $5, $7, body);
|
||||||
fixpos($$, $2);
|
fixpos($$, $2);
|
||||||
fixpos($$->nd_defn, $2);
|
|
||||||
local_pop();
|
local_pop();
|
||||||
/*%
|
/*%
|
||||||
$$ = dispatch5(defs, $2, $3, $5, $7, $8);
|
$$ = dispatch5(defs, $2, $3, $5, $7, $8);
|
||||||
|
@ -3636,8 +3634,6 @@ brace_block : '{'
|
||||||
/*%%%*/
|
/*%%%*/
|
||||||
$$ = NEW_ITER($3,$4);
|
$$ = NEW_ITER($3,$4);
|
||||||
nd_set_line($$, $<num>2);
|
nd_set_line($$, $<num>2);
|
||||||
nd_set_line($$->nd_body, $<num>2);
|
|
||||||
nd_set_line($$->nd_body->nd_body, $<num>2);
|
|
||||||
dyna_pop();
|
dyna_pop();
|
||||||
/*%
|
/*%
|
||||||
$$ = dispatch2(brace_block, escape_Qundef($3), $4);
|
$$ = dispatch2(brace_block, escape_Qundef($3), $4);
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["c-return", 5, :+, Fixnum],
|
assert_equal(["c-return", 5, :+, Fixnum],
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["return", 4, :add, self.class],
|
assert_equal(["return", 6, :add, self.class],
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["line", 8, __method__, self.class],
|
assert_equal(["line", 8, __method__, self.class],
|
||||||
events.shift)
|
events.shift)
|
||||||
|
@ -98,7 +98,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["c-return", 4, :inherited, Class],
|
assert_equal(["c-return", 4, :inherited, Class],
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["class", 7, nil, nil],
|
assert_equal(["class", 4, nil, nil],
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["line", 5, nil, nil],
|
assert_equal(["line", 5, nil, nil],
|
||||||
events.shift)
|
events.shift)
|
||||||
|
@ -120,7 +120,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["call", 5, :bar, Foo],
|
assert_equal(["call", 5, :bar, Foo],
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["return", 5, :bar, Foo],
|
assert_equal(["return", 6, :bar, Foo],
|
||||||
events.shift)
|
events.shift)
|
||||||
assert_equal(["line", 9, __method__, self.class],
|
assert_equal(["line", 9, __method__, self.class],
|
||||||
events.shift)
|
events.shift)
|
||||||
|
|
|
@ -143,6 +143,7 @@ struct rb_iseq_struct {
|
||||||
unsigned long iseq_size;
|
unsigned long iseq_size;
|
||||||
VALUE mark_ary; /* Array: includes operands which should be GC marked */
|
VALUE mark_ary; /* Array: includes operands which should be GC marked */
|
||||||
VALUE coverage; /* coverage array */
|
VALUE coverage; /* coverage array */
|
||||||
|
unsigned short line_no;
|
||||||
|
|
||||||
/* insn info, must be freed */
|
/* insn info, must be freed */
|
||||||
struct iseq_insn_info_entry *insn_info_table;
|
struct iseq_insn_info_entry *insn_info_table;
|
||||||
|
@ -444,8 +445,8 @@ typedef struct rb_thread_struct
|
||||||
VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE);
|
VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE);
|
||||||
VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE parent);
|
VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE parent);
|
||||||
VALUE rb_iseq_new_main(NODE *node, VALUE filename);
|
VALUE rb_iseq_new_main(NODE *node, VALUE filename);
|
||||||
VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE);
|
VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
||||||
VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, const rb_compile_option_t*);
|
VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, const rb_compile_option_t*);
|
||||||
VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
|
VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
|
||||||
VALUE rb_iseq_disasm(VALUE self);
|
VALUE rb_iseq_disasm(VALUE self);
|
||||||
VALUE rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, rb_iseq_t *iseq, VALUE child);
|
VALUE rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, rb_iseq_t *iseq, VALUE child);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче