summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--compile.c49
-rw-r--r--iseq.c117
-rw-r--r--proc.c28
-rw-r--r--vm.c10
-rw-r--r--vm_backtrace.c24
-rw-r--r--vm_core.h26
-rw-r--r--vm_dump.c8
-rw-r--r--vm_eval.c8
-rw-r--r--vm_insnhelper.c4
-rw-r--r--vm_method.c6
11 files changed, 164 insertions, 139 deletions
diff --git a/ChangeLog b/ChangeLog
index cfdd9f643e..3b4818d434 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+Mon Jun 4 11:42:39 2012 Koichi Sasada <ko1@atdot.net>
+
+ * vm_core.h (rb_location_t): fix type and field name.
+ (1) rename rb_location_t to rb_iseq_location_t.
+ (2) rename field names of rb_iseq_location_t to adjust
+ RubyVM::Backtrace::Location methods.
+ (2-1) filename -> path
+ (2-2) filepath -> absolute_path
+ (2-3) basename -> base_label
+ (2-4) name -> label
+ (3) rename filed name rb_iseq_location_t#line_no to
+ rb_iseq_location_t#first_lineno to clear purpose of this field.
+ (4) The field names rb_binding_t#(filename|line_no) are also renamed
+ to rb_binding_t#(path|first_lineno).
+
+ * compile.c: apply above changes.
+
+ * iseq.c: ditto.
+
+ * proc.c: ditto.
+
+ * vm*.c: ditto.
+
Mon Jun 4 11:40:28 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (r_object0): also load TYPE_USRMARSHAL, TYPE_DATA using
diff --git a/compile.c b/compile.c
index 4c6c4fb0ae..6c1e218b0f 100644
--- a/compile.c
+++ b/compile.c
@@ -165,11 +165,11 @@ r_value(VALUE value)
/* create new label */
#define NEW_LABEL(l) new_label_body(iseq, (l))
-#define iseq_filename(iseq) \
- (((rb_iseq_t*)DATA_PTR(iseq))->location.filename)
+#define iseq_path(iseq) \
+ (((rb_iseq_t*)DATA_PTR(iseq))->location.path)
-#define iseq_filepath(iseq) \
- (((rb_iseq_t*)DATA_PTR(iseq))->location.filepath)
+#define iseq_absolute_path(iseq) \
+ (((rb_iseq_t*)DATA_PTR(iseq))->location.absolute_path)
#define NEW_ISEQVAL(node, name, type, line_no) \
new_child_iseq(iseq, (node), (name), 0, (type), (line_no))
@@ -423,7 +423,7 @@ iseq_add_mark_object(rb_iseq_t *iseq, VALUE v)
return COMPILE_OK;
}
-#define ruby_sourcefile RSTRING_PTR(iseq->location.filename)
+#define ruby_sourcefile RSTRING_PTR(iseq->location.path)
static int
iseq_add_mark_object_compile_time(rb_iseq_t *iseq, VALUE v)
@@ -491,13 +491,13 @@ rb_iseq_compile_node(VALUE self, NODE *node)
break;
}
case ISEQ_TYPE_CLASS: {
- ADD_TRACE(ret, FIX2INT(iseq->location.line_no), RUBY_EVENT_CLASS);
+ ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), 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, FIX2INT(iseq->location.line_no), RUBY_EVENT_CALL);
+ ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_CALL);
COMPILE(ret, "scoped node", node->nd_body);
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
break;
@@ -960,8 +960,9 @@ new_child_iseq(rb_iseq_t *iseq, NODE *node,
VALUE ret;
debugs("[new_child_iseq]> ---------------------------------------\n");
- ret = rb_iseq_new_with_opt(node, name, iseq_filename(iseq->self), iseq_filepath(iseq->self), INT2FIX(line_no),
- parent, type, iseq->compile_data->option);
+ ret = rb_iseq_new_with_opt(node, name,
+ iseq_path(iseq->self), iseq_absolute_path(iseq->self),
+ INT2FIX(line_no), parent, type, iseq->compile_data->option);
debugs("[new_child_iseq]< ---------------------------------------\n");
iseq_add_mark_object(iseq, ret);
return ret;
@@ -1376,7 +1377,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
default:
dump_disasm_list(FIRST_ELEMENT(anchor));
dump_disasm_list(list);
- rb_compile_error(RSTRING_PTR(iseq->location.filename), line,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), line,
"error: set_sequence");
break;
}
@@ -1419,7 +1420,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
if (iobj->operand_size != len - 1) {
/* printf("operand size miss! (%d, %d)\n", iobj->operand_size, len); */
dump_disasm_list(list);
- rb_compile_error(RSTRING_PTR(iseq->location.filename), iobj->line_no,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
"operand size miss! (%d for %d)",
iobj->operand_size, len - 1);
xfree(generated_iseq);
@@ -1436,7 +1437,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
/* label(destination position) */
lobj = (LABEL *)operands[j];
if (!lobj->set) {
- rb_compile_error(RSTRING_PTR(iseq->location.filename), iobj->line_no,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
"unknown label");
}
if (lobj->sp == -1) {
@@ -1502,7 +1503,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
}
break;
default:
- rb_compile_error(RSTRING_PTR(iseq->location.filename), iobj->line_no,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
"unknown operand type: %c", type);
xfree(generated_iseq);
xfree(line_info_table);
@@ -2045,7 +2046,7 @@ insn_set_sc_state(rb_iseq_t *iseq, INSN *iobj, int state)
dump_disasm_list((LINK_ELEMENT *)iobj);
dump_disasm_list((LINK_ELEMENT *)lobj);
printf("\n-- %d, %d\n", lobj->sc_state, nstate);
- rb_compile_error(RSTRING_PTR(iseq->location.filename), iobj->line_no,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
"insn_set_sc_state error\n");
return 0;
}
@@ -2147,7 +2148,7 @@ iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
case SCS_XX:
goto normal_insn;
default:
- rb_compile_error(RSTRING_PTR(iseq->location.filename), iobj->line_no,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
"unreachable");
}
/* remove useless pop */
@@ -2449,7 +2450,7 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, int onl
}
else {
if (rb_hash_lookup(literals, lit) != Qnil) {
- rb_compile_warning(RSTRING_PTR(iseq->location.filename), nd_line(val), "duplicated when clause is ignored");
+ rb_compile_warning(RSTRING_PTR(iseq->location.path), nd_line(val), "duplicated when clause is ignored");
}
else {
rb_hash_aset(literals, lit, (VALUE)(l1) | 1);
@@ -2897,7 +2898,7 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
VALUE rescue = NEW_CHILD_ISEQVAL(NEW_NIL(),
rb_str_concat(rb_str_new2
("defined guard in "),
- iseq->location.name),
+ iseq->location.label),
ISEQ_TYPE_DEFINED_GUARD, 0);
APPEND_LABEL(ret, lcur, lstart);
ADD_LABEL(ret, lend);
@@ -2924,10 +2925,10 @@ make_name_for_block(rb_iseq_t *iseq)
}
if (level == 1) {
- return rb_sprintf("block in %s", RSTRING_PTR(ip->location.name));
+ return rb_sprintf("block in %s", RSTRING_PTR(ip->location.label));
}
else {
- return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->location.name));
+ return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->location.label));
}
}
@@ -3649,7 +3650,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
LABEL *lcont = NEW_LABEL(nd_line(node));
VALUE rescue = NEW_CHILD_ISEQVAL(
node->nd_resq,
- rb_str_concat(rb_str_new2("rescue in "), iseq->location.name),
+ rb_str_concat(rb_str_new2("rescue in "), iseq->location.label),
ISEQ_TYPE_RESCUE, nd_line(node));
ADD_LABEL(ret, lstart);
@@ -3731,7 +3732,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
VALUE ensure = NEW_CHILD_ISEQVAL(node->nd_ensr,
rb_str_concat(rb_str_new2
("ensure in "),
- iseq->location.name),
+ iseq->location.label),
ISEQ_TYPE_ENSURE, nd_line(node));
LABEL *lstart = NEW_LABEL(nd_line(node));
LABEL *lend = NEW_LABEL(nd_line(node));
@@ -4917,7 +4918,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
LABEL *lfin = NEW_LABEL(nd_line(node));
LABEL *ltrue = NEW_LABEL(nd_line(node));
VALUE key = rb_sprintf("flipflag/%s-%p-%d",
- RSTRING_PTR(iseq->location.name), (void *)iseq,
+ RSTRING_PTR(iseq->location.label), (void *)iseq,
iseq->compile_data->flip_cnt++);
hide_obj(key);
@@ -5454,12 +5455,12 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
if (st_lookup(insn_table, (st_data_t)insn, &insn_id) == 0) {
/* TODO: exception */
RB_GC_GUARD(insn) = rb_inspect(insn);
- rb_compile_error(RSTRING_PTR(iseq->location.filename), line_no,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), line_no,
"unknown instruction: %s", RSTRING_PTR(insn));
}
if (argc != insn_len((VALUE)insn_id)-1) {
- rb_compile_error(RSTRING_PTR(iseq->location.filename), line_no,
+ rb_compile_error(RSTRING_PTR(iseq->location.path), line_no,
"operand size mismatch");
}
diff --git a/iseq.c b/iseq.c
index e5cb7c11ae..f75911cab0 100644
--- a/iseq.c
+++ b/iseq.c
@@ -69,8 +69,8 @@ iseq_free(void *ptr)
if (!iseq->orig) {
/* It's possible that strings are freed */
if (0) {
- RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->location.name),
- RSTRING_PTR(iseq->location.filename));
+ RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->location.label),
+ RSTRING_PTR(iseq->location.path));
}
if (iseq->iseq != iseq->iseq_encoded) {
@@ -99,13 +99,13 @@ iseq_mark(void *ptr)
if (ptr) {
rb_iseq_t *iseq = ptr;
- RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->location.name), RSTRING_PTR(iseq->location.filename));
+ RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->location.label), RSTRING_PTR(iseq->location.path));
RUBY_MARK_UNLESS_NULL(iseq->mark_ary);
- RUBY_MARK_UNLESS_NULL(iseq->location.name);
- RUBY_MARK_UNLESS_NULL(iseq->location.basename);
- RUBY_MARK_UNLESS_NULL(iseq->location.filename);
- RUBY_MARK_UNLESS_NULL(iseq->location.filepath);
+ RUBY_MARK_UNLESS_NULL(iseq->location.label);
+ RUBY_MARK_UNLESS_NULL(iseq->location.base_label);
+ RUBY_MARK_UNLESS_NULL(iseq->location.path);
+ RUBY_MARK_UNLESS_NULL(iseq->location.absolute_path);
RUBY_MARK_UNLESS_NULL((VALUE)iseq->cref_stack);
RUBY_MARK_UNLESS_NULL(iseq->klass);
@@ -178,14 +178,14 @@ iseq_alloc(VALUE klass)
return TypedData_Make_Struct(klass, rb_iseq_t, &iseq_data_type, iseq);
}
-static rb_location_t *
-iseq_location_setup(rb_iseq_t *iseq, VALUE filename, VALUE filepath, VALUE name, size_t line_no)
+static rb_iseq_location_t *
+iseq_location_setup(rb_iseq_t *iseq, VALUE path, VALUE absolute_path, VALUE name, size_t first_lineno)
{
- rb_location_t *loc = &iseq->location;
- loc->filename = filename;
- loc->filepath = filepath;
- loc->name = loc->basename = name;
- loc->line_no = line_no;
+ rb_iseq_location_t *loc = &iseq->location;
+ loc->path = path;
+ loc->absolute_path = absolute_path;
+ loc->label = loc->base_label = name;
+ loc->first_lineno = first_lineno;
return loc;
}
@@ -235,7 +235,7 @@ set_relation(rb_iseq_t *iseq, const VALUE parent)
static VALUE
prepare_iseq_build(rb_iseq_t *iseq,
- VALUE name, VALUE filename, VALUE filepath, VALUE line_no,
+ VALUE name, VALUE path, VALUE absolute_path, VALUE first_lineno,
VALUE parent, enum iseq_type type, VALUE block_opt,
const rb_compile_option_t *option)
{
@@ -247,11 +247,11 @@ prepare_iseq_build(rb_iseq_t *iseq,
set_relation(iseq, parent);
OBJ_FREEZE(name);
- OBJ_FREEZE(filename);
+ OBJ_FREEZE(path);
- iseq_location_setup(iseq, filename, filepath, name, line_no);
+ iseq_location_setup(iseq, path, absolute_path, name, first_lineno);
if (iseq != iseq->local_iseq) {
- iseq->location.basename = iseq->local_iseq->location.name;
+ iseq->location.base_label = iseq->local_iseq->location.label;
}
iseq->defined_method_id = 0;
@@ -290,7 +290,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
if (!GET_THREAD()->parse_in_eval) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages)) {
- iseq->coverage = rb_hash_lookup(coverages, filename);
+ iseq->coverage = rb_hash_lookup(coverages, path);
if (NIL_P(iseq->coverage)) iseq->coverage = Qfalse;
}
}
@@ -307,7 +307,7 @@ cleanup_iseq_build(rb_iseq_t *iseq)
compile_data_free(data);
if (RTEST(err)) {
- rb_funcall2(err, rb_intern("set_backtrace"), 1, &iseq->location.filename);
+ rb_funcall2(err, rb_intern("set_backtrace"), 1, &iseq->location.path);
rb_exc_raise(err);
}
return Qtrue;
@@ -390,31 +390,31 @@ make_compile_option_value(rb_compile_option_t *option)
}
VALUE
-rb_iseq_new(NODE *node, VALUE name, VALUE filename, VALUE filepath,
+rb_iseq_new(NODE *node, VALUE name, VALUE path, VALUE absolute_path,
VALUE parent, enum iseq_type type)
{
- return rb_iseq_new_with_opt(node, name, filename, filepath, INT2FIX(0), parent, type,
+ return rb_iseq_new_with_opt(node, name, path, absolute_path, INT2FIX(0), parent, type,
&COMPILE_OPTION_DEFAULT);
}
VALUE
-rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE filepath, VALUE parent)
+rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE absolute_path, VALUE parent)
{
- return rb_iseq_new_with_opt(node, name, filename, filepath, INT2FIX(0), parent, ISEQ_TYPE_TOP,
+ return rb_iseq_new_with_opt(node, name, path, absolute_path, INT2FIX(0), parent, ISEQ_TYPE_TOP,
&COMPILE_OPTION_DEFAULT);
}
VALUE
-rb_iseq_new_main(NODE *node, VALUE filename, VALUE filepath)
+rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path)
{
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, filepath, INT2FIX(0),
+ return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), path, absolute_path, INT2FIX(0),
parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
}
static VALUE
-rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename, VALUE filepath, VALUE line_no,
+rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE path, VALUE absolute_path, VALUE first_lineno,
VALUE parent, enum iseq_type type, VALUE bopt,
const rb_compile_option_t *option)
{
@@ -424,28 +424,28 @@ rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename, VALUE file
GetISeqPtr(self, iseq);
iseq->self = self;
- prepare_iseq_build(iseq, name, filename, filepath, line_no, parent, type, bopt, option);
+ prepare_iseq_build(iseq, name, path, absolute_path, first_lineno, 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, VALUE filepath, VALUE line_no,
+rb_iseq_new_with_opt(NODE *node, VALUE name, VALUE path, VALUE absolute_path, VALUE first_lineno,
VALUE parent, enum iseq_type type,
const rb_compile_option_t *option)
{
/* TODO: argument check */
- return rb_iseq_new_with_bopt_and_opt(node, name, filename, filepath, line_no, parent, type,
+ return rb_iseq_new_with_bopt_and_opt(node, name, path, absolute_path, first_lineno, parent, type,
Qfalse, option);
}
VALUE
-rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE filename, VALUE filepath, VALUE line_no,
+rb_iseq_new_with_bopt(NODE *node, VALUE name, VALUE path, VALUE absolute_path, VALUE first_lineno,
VALUE parent, enum iseq_type type, VALUE bopt)
{
/* TODO: argument check */
- return rb_iseq_new_with_bopt_and_opt(node, name, filename, filepath, line_no, parent, type,
+ return rb_iseq_new_with_bopt_and_opt(node, name, path, absolute_path, first_lineno, parent, type,
bopt, &COMPILE_OPTION_DEFAULT);
}
@@ -459,7 +459,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, filepath, line_no;
+ VALUE name, path, absolute_path, first_lineno;
VALUE type, body, locals, args, exception;
st_data_t iseq_type;
@@ -469,7 +469,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
int i = 0;
/* [magic, major_version, minor_version, format_type, misc,
- * name, filename, line_no,
+ * label, path, first_lineno,
* type, locals, args, exception_table, body]
*/
@@ -483,10 +483,10 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
((void)magic, (void)version1, (void)version2, (void)format_type, (void)misc);
name = CHECK_STRING(rb_ary_entry(data, i++));
- filename = CHECK_STRING(rb_ary_entry(data, i++));
- filepath = rb_ary_entry(data, i++);
- filepath = NIL_P(filepath) ? Qnil : CHECK_STRING(filepath);
- line_no = CHECK_INTEGER(rb_ary_entry(data, i++));
+ path = CHECK_STRING(rb_ary_entry(data, i++));
+ absolute_path = rb_ary_entry(data, i++);
+ absolute_path = NIL_P(absolute_path) ? Qnil : CHECK_STRING(absolute_path);
+ first_lineno = CHECK_INTEGER(rb_ary_entry(data, i++));
type = CHECK_SYMBOL(rb_ary_entry(data, i++));
locals = CHECK_ARRAY(rb_ary_entry(data, i++));
@@ -528,7 +528,7 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
}
make_compile_option(&option, opt);
- prepare_iseq_build(iseq, name, filename, filepath, line_no,
+ prepare_iseq_build(iseq, name, path, absolute_path, first_lineno,
parent, (enum iseq_type)iseq_type, 0, &option);
rb_iseq_build_from_ary(iseq, locals, args, exception, body);
@@ -565,7 +565,7 @@ parse_string(VALUE str, const char *file, int line)
}
VALUE
-rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE filepath, VALUE line, VALUE opt)
+rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE line, VALUE opt)
{
rb_compile_option_t option;
const char *fn = StringValueCStr(file);
@@ -575,12 +575,12 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE filepath, VALUE line, V
make_compile_option(&option, opt);
if (th->base_block && th->base_block->iseq) {
- return rb_iseq_new_with_opt(node, th->base_block->iseq->location.name,
- file, filepath, line, th->base_block->iseq->self,
+ return rb_iseq_new_with_opt(node, th->base_block->iseq->location.label,
+ file, absolute_path, line, th->base_block->iseq->self,
ISEQ_TYPE_EVAL, &option);
}
else {
- return rb_iseq_new_with_opt(node, rb_str_new2("<compiled>"), file, filepath, line, Qfalse,
+ return rb_iseq_new_with_opt(node, rb_str_new2("<compiled>"), file, absolute_path, line, Qfalse,
ISEQ_TYPE_TOP, &option);
}
}
@@ -651,7 +651,7 @@ iseq_check(VALUE val)
{
rb_iseq_t *iseq;
GetISeqPtr(val, iseq);
- if (!iseq->location.name) {
+ if (!iseq->location.label) {
rb_raise(rb_eTypeError, "uninitialized InstructionSequence");
}
return iseq;
@@ -669,13 +669,13 @@ iseq_inspect(VALUE self)
{
rb_iseq_t *iseq;
GetISeqPtr(self, iseq);
- if (!iseq->location.name) {
+ if (!iseq->location.label) {
return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self));
}
return rb_sprintf("<%s:%s@%s>",
rb_obj_classname(self),
- RSTRING_PTR(iseq->location.name), RSTRING_PTR(iseq->location.filename));
+ RSTRING_PTR(iseq->location.label), RSTRING_PTR(iseq->location.path));
}
static
@@ -692,7 +692,7 @@ iseq_to_a(VALUE self)
int
rb_iseq_first_lineno(const rb_iseq_t *iseq)
{
- return FIX2INT(iseq->location.line_no);
+ return FIX2INT(iseq->location.first_lineno);
}
/* TODO: search algorithm is brute force.
@@ -823,7 +823,7 @@ insn_operand_intern(rb_iseq_t *iseq,
{
rb_iseq_t *iseq = (rb_iseq_t *)op;
if (iseq) {
- ret = iseq->location.name;
+ ret = iseq->location.label;
if (child) {
rb_ary_push(child, iseq->self);
}
@@ -1347,9 +1347,10 @@ iseq_data_to_ary(rb_iseq_t *iseq)
rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq->local_size));
rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq->stack_max));
+ /* TODO: compatibility issue */
/*
* [:magic, :major_version, :minor_version, :format_type, :misc,
- * :name, :filename, :filepath, :line_no, :type, :locals, :args,
+ * :name, :path, :absolute_path, :start_lineno, :type, :locals, :args,
* :catch_table, :bytecode]
*/
rb_ary_push(val, rb_str_new2("YARVInstructionSequence/SimpleDataFormat"));
@@ -1357,10 +1358,10 @@ iseq_data_to_ary(rb_iseq_t *iseq)
rb_ary_push(val, INT2FIX(ISEQ_MINOR_VERSION)); /* minor */
rb_ary_push(val, INT2FIX(1));
rb_ary_push(val, misc);
- rb_ary_push(val, iseq->location.name);
- rb_ary_push(val, iseq->location.filename);
- rb_ary_push(val, iseq->location.filepath);
- rb_ary_push(val, iseq->location.line_no);
+ rb_ary_push(val, iseq->location.label);
+ rb_ary_push(val, iseq->location.path);
+ rb_ary_push(val, iseq->location.absolute_path);
+ rb_ary_push(val, iseq->location.first_lineno);
rb_ary_push(val, type);
rb_ary_push(val, locals);
rb_ary_push(val, args);
@@ -1487,8 +1488,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 unsigned short line_no)
+ const char *path,
+ const unsigned short first_lineno)
{
unsigned long i;
VALUE iseqval = iseq_alloc(rb_cISeq);
@@ -1497,9 +1498,9 @@ rb_iseq_build_for_ruby2cext(
/* copy iseq */
*iseq = *iseq_template;
- iseq->location.name = rb_str_new2(name);
- iseq->location.filename = rb_str_new2(filename);
- iseq->location.line_no = line_no;
+ iseq->location.label = rb_str_new2(name);
+ iseq->location.path = rb_str_new2(path);
+ iseq->location.first_lineno = first_lineno;
iseq->mark_ary = rb_ary_tmp_new(3);
OBJ_UNTRUST(iseq->mark_ary);
iseq->self = iseqval;
diff --git a/proc.c b/proc.c
index 3a354f0a00..b0437db9cd 100644
--- a/proc.c
+++ b/proc.c
@@ -256,7 +256,7 @@ binding_mark(void *ptr)
if (ptr) {
bind = ptr;
RUBY_MARK_UNLESS_NULL(bind->env);
- RUBY_MARK_UNLESS_NULL(bind->filename);
+ RUBY_MARK_UNLESS_NULL(bind->path);
}
RUBY_MARK_LEAVE("binding");
}
@@ -294,8 +294,8 @@ binding_dup(VALUE self)
GetBindingPtr(self, src);
GetBindingPtr(bindval, dst);
dst->env = src->env;
- dst->filename = src->filename;
- dst->line_no = src->line_no;
+ dst->path = src->path;
+ dst->first_lineno = src->first_lineno;
return bindval;
}
@@ -322,8 +322,8 @@ rb_binding_new(void)
GetBindingPtr(bindval, bind);
bind->env = rb_vm_make_env_object(th, cfp);
- bind->filename = cfp->iseq->location.filename;
- bind->line_no = rb_vm_get_sourceline(cfp);
+ bind->path = cfp->iseq->location.path;
+ bind->first_lineno = rb_vm_get_sourceline(cfp);
return bindval;
}
@@ -699,7 +699,7 @@ iseq_location(rb_iseq_t *iseq)
VALUE loc[2];
if (!iseq) return Qnil;
- loc[0] = iseq->location.filename;
+ loc[0] = iseq->location.path;
if (iseq->line_info_table) {
loc[1] = INT2FIX(rb_iseq_first_lineno(iseq));
}
@@ -843,14 +843,14 @@ proc_to_s(VALUE self)
is_lambda = proc->is_lambda ? " (lambda)" : "";
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
- int line_no = 0;
+ int first_lineno = 0;
if (iseq->line_info_table) {
- line_no = rb_iseq_first_lineno(iseq);
+ first_lineno = rb_iseq_first_lineno(iseq);
}
str = rb_sprintf("#<%s:%p@%s:%d%s>", cname, (void *)self,
- RSTRING_PTR(iseq->location.filename),
- line_no, is_lambda);
+ RSTRING_PTR(iseq->location.path),
+ first_lineno, is_lambda);
}
else {
str = rb_sprintf("#<%s:%p%s>", cname, (void *)proc->block.iseq,
@@ -1980,12 +1980,12 @@ proc_binding(VALUE self)
GetBindingPtr(bindval, bind);
bind->env = proc->envval;
if (RUBY_VM_NORMAL_ISEQ_P(proc->block.iseq)) {
- bind->filename = proc->block.iseq->location.filename;
- bind->line_no = rb_iseq_first_lineno(proc->block.iseq);
+ bind->path = proc->block.iseq->location.path;
+ bind->first_lineno = rb_iseq_first_lineno(proc->block.iseq);
}
else {
- bind->filename = Qnil;
- bind->line_no = 0;
+ bind->path = Qnil;
+ bind->first_lineno = 0;
}
return bindval;
}
diff --git a/vm.c b/vm.c
index 80e4949ebc..0f7f0923d4 100644
--- a/vm.c
+++ b/vm.c
@@ -736,7 +736,7 @@ rb_sourcefilename(void)
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (cfp) {
- return cfp->iseq->location.filename;
+ return cfp->iseq->location.path;
}
else {
return Qnil;
@@ -750,7 +750,7 @@ rb_sourcefile(void)
rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (cfp) {
- return RSTRING_PTR(cfp->iseq->location.filename);
+ return RSTRING_PTR(cfp->iseq->location.path);
}
else {
return 0;
@@ -1414,9 +1414,9 @@ rb_thread_current_status(const rb_thread_t *th)
if (cfp->pc != 0) {
rb_iseq_t *iseq = cfp->iseq;
int line_no = rb_vm_get_sourceline(cfp);
- char *file = RSTRING_PTR(iseq->location.filename);
+ char *file = RSTRING_PTR(iseq->location.path);
str = rb_sprintf("%s:%d:in `%s'",
- file, line_no, RSTRING_PTR(iseq->location.name));
+ file, line_no, RSTRING_PTR(iseq->location.label));
}
}
else if (cfp->me->def->original_id) {
@@ -2164,7 +2164,7 @@ rb_vm_set_progname(VALUE filename)
rb_thread_t *th = GET_VM()->main_thread;
rb_control_frame_t *cfp = (void *)(th->stack + th->stack_size);
--cfp;
- cfp->iseq->location.filename = filename;
+ cfp->iseq->location.path = filename;
}
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
diff --git a/vm_backtrace.c b/vm_backtrace.c
index d0e55557d0..59df7cc309 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -152,7 +152,7 @@ location_label(rb_backtrace_location_t *loc)
switch (loc->type) {
case LOCATION_TYPE_ISEQ:
case LOCATION_TYPE_ISEQ_CALCED:
- return loc->body.iseq.iseq->location.name;
+ return loc->body.iseq.iseq->location.label;
case LOCATION_TYPE_CFUNC:
return rb_id2str(loc->body.cfunc.mid);
case LOCATION_TYPE_IFUNC:
@@ -174,7 +174,7 @@ location_base_label(rb_backtrace_location_t *loc)
switch (loc->type) {
case LOCATION_TYPE_ISEQ:
case LOCATION_TYPE_ISEQ_CALCED:
- return loc->body.iseq.iseq->location.basename;
+ return loc->body.iseq.iseq->location.base_label;
case LOCATION_TYPE_CFUNC:
return rb_sym_to_s(ID2SYM(loc->body.cfunc.mid));
case LOCATION_TYPE_IFUNC:
@@ -196,7 +196,7 @@ location_path(rb_backtrace_location_t *loc)
switch (loc->type) {
case LOCATION_TYPE_ISEQ:
case LOCATION_TYPE_ISEQ_CALCED:
- return loc->body.iseq.iseq->location.filename;
+ return loc->body.iseq.iseq->location.path;
case LOCATION_TYPE_CFUNC:
if (loc->body.cfunc.prev_loc) {
return location_path(loc->body.cfunc.prev_loc);
@@ -221,7 +221,7 @@ location_absolute_path(rb_backtrace_location_t *loc)
switch (loc->type) {
case LOCATION_TYPE_ISEQ:
case LOCATION_TYPE_ISEQ_CALCED:
- return loc->body.iseq.iseq->location.filepath;
+ return loc->body.iseq.iseq->location.absolute_path;
case LOCATION_TYPE_CFUNC:
if (loc->body.cfunc.prev_loc) {
return location_absolute_path(loc->body.cfunc.prev_loc);
@@ -261,20 +261,20 @@ location_to_str(rb_backtrace_location_t *loc)
switch (loc->type) {
case LOCATION_TYPE_ISEQ:
- file = loc->body.iseq.iseq->location.filename;
- name = loc->body.iseq.iseq->location.name;
+ file = loc->body.iseq.iseq->location.path;
+ name = loc->body.iseq.iseq->location.label;
lineno = loc->body.iseq.lineno.lineno = calc_lineno(loc->body.iseq.iseq, loc->body.iseq.lineno.pc);
loc->type = LOCATION_TYPE_ISEQ_CALCED;
break;
case LOCATION_TYPE_ISEQ_CALCED:
- file = loc->body.iseq.iseq->location.filename;
+ file = loc->body.iseq.iseq->location.path;
lineno = loc->body.iseq.lineno.lineno;
- name = loc->body.iseq.iseq->location.name;
+ name = loc->body.iseq.iseq->location.label;
break;
case LOCATION_TYPE_CFUNC:
if (loc->body.cfunc.prev_loc) {
- file = loc->body.cfunc.prev_loc->body.iseq.iseq->location.filename;
+ file = loc->body.cfunc.prev_loc->body.iseq.iseq->location.path;
lineno = location_lineno(loc->body.cfunc.prev_loc);
}
else {
@@ -585,7 +585,7 @@ vm_backtrace_frame_ary(rb_thread_t *th, int lev, int n)
return backtrace_to_frame_ary(backtrace_object(th), lev, n);
}
-/* old style backtrace directly */
+/* make old style backtrace directly */
struct oldbt_arg {
VALUE filename;
@@ -608,8 +608,8 @@ static void
oldbt_iter_iseq(void *ptr, const rb_iseq_t *iseq, const VALUE *pc)
{
struct oldbt_arg *arg = (struct oldbt_arg *)ptr;
- VALUE file = arg->filename = iseq->location.filename;
- VALUE name = iseq->location.name;
+ VALUE file = arg->filename = iseq->location.path;
+ VALUE name = iseq->location.label;
int lineno = arg->lineno = calc_lineno(iseq, pc);
(arg->func)(arg->data, file, lineno, name);
diff --git a/vm_core.h b/vm_core.h
index 764f142884..c831d60e4a 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -150,13 +150,13 @@ struct iseq_inline_cache_entry {
#define GetISeqPtr(obj, ptr) \
GetCoreDataFromValue((obj), rb_iseq_t, (ptr))
-typedef struct rb_location_struct {
- VALUE filename;
- VALUE filepath;
- VALUE basename;
- VALUE name;
- size_t line_no;
-} rb_location_t;
+typedef struct rb_iseq_location_struct {
+ VALUE path;
+ VALUE absolute_path;
+ VALUE base_label;
+ VALUE label;
+ size_t first_lineno;
+} rb_iseq_location_t;
struct rb_iseq_struct;
@@ -177,7 +177,7 @@ struct rb_iseq_struct {
ISEQ_TYPE_DEFINED_GUARD
} type; /* instruction sequence type */
- rb_location_t location;
+ rb_iseq_location_t location;
VALUE *iseq; /* iseq (insn number and operands) */
VALUE *iseq_encoded; /* encoded iseq */
@@ -512,12 +512,12 @@ typedef struct rb_thread_struct {
#pragma GCC visibility push(default)
#endif
VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE, enum iseq_type);
-VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE filepath, VALUE parent);
-VALUE rb_iseq_new_main(NODE *node, VALUE filename, VALUE filepath);
+VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE path, VALUE absolute_path, VALUE parent);
+VALUE rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path);
VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, VALUE);
VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, const rb_compile_option_t*);
VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
-VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE filepath, VALUE line, VALUE opt);
+VALUE rb_iseq_compile_with_option(VALUE src, VALUE path, VALUE absolute_path, VALUE line, VALUE opt);
VALUE rb_iseq_disasm(VALUE self);
int rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, size_t pos, rb_iseq_t *iseq, VALUE child);
const char *ruby_node_name(int node);
@@ -563,8 +563,8 @@ typedef struct {
typedef struct {
VALUE env;
- VALUE filename;
- unsigned short line_no;
+ VALUE path;
+ unsigned short first_lineno;
} rb_binding_t;
/* used by compile time and send insn */
diff --git a/vm_dump.c b/vm_dump.c
index 185646d5aa..2766677cf3 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -39,7 +39,7 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
VALUE tmp;
if (cfp->block_iseq != 0 && BUILTIN_TYPE(cfp->block_iseq) != T_NODE) {
- biseq_name = ""; /* RSTRING(cfp->block_iseq->location.name)->ptr; */
+ biseq_name = ""; /* RSTRING(cfp->block_iseq->location.label)->ptr; */
}
if (lfp < 0 || (size_t)lfp > th->stack_size) {
@@ -111,10 +111,10 @@ control_frame_dump(rb_thread_t *th, rb_control_frame_t *cfp)
}
else {
pc = cfp->pc - cfp->iseq->iseq_encoded;
- iseq_name = RSTRING_PTR(cfp->iseq->location.name);
+ iseq_name = RSTRING_PTR(cfp->iseq->location.label);
line = rb_vm_get_sourceline(cfp);
if (line) {
- snprintf(posbuf, MAX_POSBUF, "%s:%d", RSTRING_PTR(cfp->iseq->location.filename), line);
+ snprintf(posbuf, MAX_POSBUF, "%s:%d", RSTRING_PTR(cfp->iseq->location.path), line);
}
}
}
@@ -272,7 +272,7 @@ vm_stack_dump_each(rb_thread_t *th, rb_control_frame_t *cfp)
else {
argc = iseq->argc;
local_size = iseq->local_size;
- name = RSTRING_PTR(iseq->location.name);
+ name = RSTRING_PTR(iseq->location.label);
}
/* stack trace header */
diff --git a/vm_eval.c b/vm_eval.c
index dee646cdc1..c1b79f5061 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1019,9 +1019,9 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char
if (rb_obj_is_kind_of(scope, rb_cBinding)) {
GetBindingPtr(scope, bind);
envval = bind->env;
- if (strcmp(file, "(eval)") == 0 && bind->filename != Qnil) {
- file = RSTRING_PTR(bind->filename);
- line = bind->line_no;
+ if (strcmp(file, "(eval)") == 0 && bind->path != Qnil) {
+ file = RSTRING_PTR(bind->path);
+ line = bind->first_lineno;
}
}
else {
@@ -1676,7 +1676,7 @@ rb_current_realfilepath(void)
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp = th->cfp;
cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
- if (cfp != 0) return cfp->iseq->location.filepath;
+ if (cfp != 0) return cfp->iseq->location.absolute_path;
return Qnil;
}
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 8a21f21ec0..a4b4b8fe78 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -133,8 +133,8 @@ argument_error(const rb_iseq_t *iseq, int miss_argc, int min_argc, int max_argc)
int line_no = rb_iseq_first_lineno(iseq);
err_line = rb_sprintf("%s:%d:in `%s'",
- RSTRING_PTR(iseq->location.filename),
- line_no, RSTRING_PTR(iseq->location.name));
+ RSTRING_PTR(iseq->location.path),
+ line_no, RSTRING_PTR(iseq->location.label));
rb_funcall(bt, rb_intern("unshift"), 1, err_line);
}
diff --git a/vm_method.c b/vm_method.c
index a22c917880..673113eaa8 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -224,9 +224,9 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
default:
break;
}
- if (iseq && !NIL_P(iseq->location.filename)) {
+ if (iseq && !NIL_P(iseq->location.path)) {
int line = iseq->line_info_table ? rb_iseq_first_lineno(iseq) : 0;
- rb_compile_warning(RSTRING_PTR(iseq->location.filename), line,
+ rb_compile_warning(RSTRING_PTR(iseq->location.path), line,
"previous definition of %s was here",
rb_id2name(old_def->original_id));
}
@@ -307,7 +307,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
th = GET_THREAD();
cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
if (cfp && (line = rb_vm_get_sourceline(cfp))) {
- VALUE location = rb_ary_new3(2, cfp->iseq->location.filename, INT2FIX(line));
+ VALUE location = rb_ary_new3(2, cfp->iseq->location.path, INT2FIX(line));
def->body.attr.location = rb_ary_freeze(location);
}
break;