ruby-changes:23848
From: ko1 <ko1@a...>
Date: Mon, 4 Jun 2012 11:49:49 +0900 (JST)
Subject: [ruby-changes:23848] ko1:r35899 (trunk): * vm_core.h (rb_location_t): fix type and field name.
ko1 2012-06-04 11:49:37 +0900 (Mon, 04 Jun 2012) New Revision: 35899 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35899 Log: * 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. Modified files: trunk/ChangeLog trunk/compile.c trunk/iseq.c trunk/proc.c trunk/vm.c trunk/vm_backtrace.c trunk/vm_core.h trunk/vm_dump.c trunk/vm_eval.c trunk/vm_insnhelper.c trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 35898) +++ ChangeLog (revision 35899) @@ -1,3 +1,26 @@ +Mon Jun 4 11:42:39 2012 Koichi Sasada <ko1@a...> + + * 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@r...> * marshal.c (r_object0): also load TYPE_USRMARSHAL, TYPE_DATA using Index: vm_core.h =================================================================== --- vm_core.h (revision 35898) +++ vm_core.h (revision 35899) @@ -150,13 +150,13 @@ #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 @@ 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 @@ #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 { VALUE env; - VALUE filename; - unsigned short line_no; + VALUE path; + unsigned short first_lineno; } rb_binding_t; /* used by compile time and send insn */ Index: iseq.c =================================================================== --- iseq.c (revision 35898) +++ iseq.c (revision 35899) @@ -69,8 +69,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ ((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 @@ } 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 @@ } 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 @@ 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 @@ { 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 @@ { 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ /* 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; Index: compile.c =================================================================== --- compile.c (revision 35898) +++ compile.c (revision 35899) @@ -165,11 +165,11 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ } 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 @@ 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 @@ 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 @@ } 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 clau (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/