summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-08 10:52:38 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-08 10:52:38 +0000
commitb6a98140d57e7e298046dae1f0f09b068c423e57 (patch)
tree708e41d16b3fdf724e9f81add842f32c5375bee3 /iseq.c
parent62cc5d4e01b2443cd48fc011affddf331d89301b (diff)
merges r24243 from trunk into ruby_1_9_1.
-- * 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/branches/ruby_1_9_1@24446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/iseq.c b/iseq.c
index 69cdd7fe1d..159da22ed5 100644
--- a/iseq.c
+++ b/iseq.c
@@ -148,7 +148,7 @@ set_relation(rb_iseq_t *iseq, const VALUE parent)
static VALUE
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,
const rb_compile_option_t *option)
{
@@ -157,6 +157,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
iseq->name = name;
iseq->filename = filename;
+ iseq->line_no = line_no;
iseq->defined_method_id = 0;
iseq->mark_ary = rb_ary_new();
RBASIC(iseq->mark_ary)->klass = 0;
@@ -301,14 +302,14 @@ VALUE
rb_iseq_new(NODE *node, VALUE name, VALUE filename,
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);
}
VALUE
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);
}
@@ -317,12 +318,12 @@ rb_iseq_new_main(NODE *node, VALUE filename)
{
rb_thread_t *th = GET_THREAD();
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);
}
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,
const rb_compile_option_t *option)
{
@@ -332,26 +333,26 @@ rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename,
GetISeqPtr(self, iseq);
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);
cleanup_iseq_build(iseq);
return self;
}
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,
const rb_compile_option_t *option)
{
- return rb_iseq_new_with_bopt_and_opt(node, name, filename, parent, type,
- Qfalse, option);
+ return rb_iseq_new_with_bopt_and_opt(node, name, filename, line_no, parent, type,
+ Qfalse, option);
}
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)
{
- 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);
}
@@ -365,7 +366,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
VALUE iseqval = iseq_alloc(self);
VALUE magic, version1, version2, format_type, misc;
- VALUE name, filename;
+ VALUE name, filename, line_no;
VALUE type, body, locals, args, exception;
VALUE iseq_type;
@@ -375,7 +376,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
int i = 0;
/* [magic, major_version, minor_version, format_type, misc,
- * name, filename,
+ * name, filename, line_no,
* type, locals, args, exception_table, body]
*/
@@ -389,6 +390,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
name = 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++));
locals = CHECK_ARRAY(rb_ary_entry(data, i++));
@@ -430,7 +432,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE 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);
rb_iseq_build_from_ary(iseq, locals, args, exception, body);
@@ -477,11 +479,11 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE line, VALUE opt)
if (th->base_block && th->base_block->iseq) {
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);
}
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);
}
}
@@ -526,7 +528,7 @@ iseq_s_compile_file(int argc, VALUE *argv, VALUE self)
parser = rb_parser_new();
node = rb_parser_compile_file(parser, fname, f, NUM2INT(line));
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);
}
@@ -592,7 +594,7 @@ iseq_to_a(VALUE self)
int
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.
@@ -1243,7 +1245,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
/*
* [:magic, :major_version, :minor_version, :format_type, :misc,
- * :name, :filename, :type, :locals, :args,
+ * :name, :filename, :line_no, :type, :locals, :args,
* :catch_table, :bytecode]
*/
rb_ary_push(val, rb_str_new2("YARVInstructionSequence/SimpleDataFormat"));
@@ -1253,6 +1255,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
rb_ary_push(val, misc);
rb_ary_push(val, iseq->name);
rb_ary_push(val, iseq->filename);
+ rb_ary_push(val, iseq->line_no);
rb_ary_push(val, type);
rb_ary_push(val, locals);
rb_ary_push(val, args);
@@ -1296,7 +1299,8 @@ rb_iseq_build_for_ruby2cext(
const VALUE *arg_opt_table,
const struct iseq_catch_table_entry *catch_table,
const char *name,
- const char *filename)
+ const char *filename,
+ const unsigned short line_no)
{
int i;
VALUE iseqval = iseq_alloc(rb_cISeq);
@@ -1308,6 +1312,7 @@ rb_iseq_build_for_ruby2cext(
iseq->name = rb_str_new2(name);
iseq->filename = rb_str_new2(filename);
iseq->mark_ary = rb_ary_new();
+ iseq->line_no = line_no;
iseq->self = iseqval;
iseq->iseq = ALLOC_N(VALUE, iseq->iseq_size);