From 9c708baa2de1db5eb3541459385967c9b6a8dbd4 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 1 Jul 2007 23:57:04 +0000 Subject: [PATCH] * eval_intern.h, yarvcore.h: move declaration of sysstack_error to yarvcore.h. * iseq.c: fix symbol name (:toplevel -> :top). * lib/vm/instruction.rb, template/vm.inc.tmpl: replacable current file name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ eval_intern.h | 1 - iseq.c | 34 +++++++++++++++++----------------- lib/vm/instruction.rb | 2 +- template/vm.inc.tmpl | 18 +++++++++--------- yarvcore.h | 2 ++ 6 files changed, 39 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2b2fda01e6ceb..f8f5411071e464 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Jul 2 08:53:47 2007 Koichi Sasada + + * eval_intern.h, yarvcore.h: move declaration of sysstack_error + to yarvcore.h. + + * iseq.c: fix symbol name (:toplevel -> :top). + + * lib/vm/instruction.rb, template/vm.inc.tmpl: replacable + current file name. + Mon Jul 2 05:29:07 2007 Koichi Sasada * compile.c, iseq.c: fix iseq some of load/store process. diff --git a/eval_intern.h b/eval_intern.h index 45e26817635a9f..9e03d789a85bf8 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -178,7 +178,6 @@ char *strrchr _((const char *, const char)); } extern VALUE exception_error; -extern VALUE sysstack_error; void rb_thread_cleanup _((void)); void rb_thread_wait_other_threads _((void)); diff --git a/iseq.c b/iseq.c index 2eeef7cb7f6481..2647dd15215a70 100644 --- a/iseq.c +++ b/iseq.c @@ -358,13 +358,13 @@ iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) if (type_map == 0) { type_map = st_init_numtable(); - st_insert(type_map, ID2SYM(rb_intern("toplevel")), ISEQ_TYPE_TOP); - st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD); - st_insert(type_map, ID2SYM(rb_intern("block")), ISEQ_TYPE_BLOCK); - st_insert(type_map, ID2SYM(rb_intern("class")), ISEQ_TYPE_CLASS); - st_insert(type_map, ID2SYM(rb_intern("rescue")), ISEQ_TYPE_RESCUE); - st_insert(type_map, ID2SYM(rb_intern("ensure")), ISEQ_TYPE_ENSURE); - st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL); + st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP); + st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD); + st_insert(type_map, ID2SYM(rb_intern("block")), ISEQ_TYPE_BLOCK); + st_insert(type_map, ID2SYM(rb_intern("class")), ISEQ_TYPE_CLASS); + st_insert(type_map, ID2SYM(rb_intern("rescue")), ISEQ_TYPE_RESCUE); + st_insert(type_map, ID2SYM(rb_intern("ensure")), ISEQ_TYPE_ENSURE); + st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL); } if (st_lookup(type_map, type, &iseq_type) == 0) { @@ -1125,7 +1125,7 @@ iseq_data_to_ary(rb_iseq_t *iseq) static VALUE insn_syms[YARV_MAX_INSTRUCTION_SIZE]; struct st_table *labels_table = st_init_numtable(); - DECL_SYMBOL(toplevel); + DECL_SYMBOL(top); DECL_SYMBOL(method); DECL_SYMBOL(block); DECL_SYMBOL(class); @@ -1133,12 +1133,12 @@ iseq_data_to_ary(rb_iseq_t *iseq) DECL_SYMBOL(ensure); DECL_SYMBOL(eval); - if (sym_toplevel == 0) { + if (sym_top == 0) { int i; for (i=0; itype) { - case ISEQ_TYPE_TOP: type = sym_toplevel; break; - case ISEQ_TYPE_METHOD: type = sym_method; break; - case ISEQ_TYPE_BLOCK: type = sym_block; break; - case ISEQ_TYPE_CLASS: type = sym_class; break; - case ISEQ_TYPE_RESCUE: type = sym_rescue; break; - case ISEQ_TYPE_ENSURE: type = sym_ensure; break; - case ISEQ_TYPE_EVAL: type = sym_eval; break; + case ISEQ_TYPE_TOP: type = sym_top; break; + case ISEQ_TYPE_METHOD: type = sym_method; break; + case ISEQ_TYPE_BLOCK: type = sym_block; break; + case ISEQ_TYPE_CLASS: type = sym_class; break; + case ISEQ_TYPE_RESCUE: type = sym_rescue; break; + case ISEQ_TYPE_ENSURE: type = sym_ensure; break; + case ISEQ_TYPE_EVAL: type = sym_eval; break; default: rb_bug("unsupported iseq type"); }; diff --git a/lib/vm/instruction.rb b/lib/vm/instruction.rb index 250bfcd422bbe7..20c0fb41da40ba 100644 --- a/lib/vm/instruction.rb +++ b/lib/vm/instruction.rb @@ -839,7 +839,7 @@ def make_insn_def insn file = insn.body.instance_variable_get(:@file) ret << "#line #{line+1} \"#{file}\"" << "\n" ret << insn.body - ret << '#line __CURRENT_LINE__ "vm.inc"' << "\n" + ret << '#line __CURRENT_LINE__ "__CURRENT_FILE__"' << "\n" else ret << insn.body end diff --git a/template/vm.inc.tmpl b/template/vm.inc.tmpl index 8b49beb1140e58..f79de9785a5495 100644 --- a/template/vm.inc.tmpl +++ b/template/vm.inc.tmpl @@ -12,17 +12,17 @@ */ <%= -ret = '' -offset = 15 -line_no = 0 -vm_body.each_line{|line| - if line =~ /^\#line __CURRENT_LINE__/ - ret << line.sub(/__CURRENT_LINE__/, "#{line_no+offset}") +line = 15 +vm_body.gsub(/\n|__CURRENT_LINE__|__CURRENT_FILE__/){|e| + case e + when '__CURRENT_LINE__' + line.to_s + when '__CURRENT_FILE__' + "vm.inc" else - ret < diff --git a/yarvcore.h b/yarvcore.h index 34de53b8b9511f..3fdb7417ff37db 100644 --- a/yarvcore.h +++ b/yarvcore.h @@ -687,6 +687,8 @@ int vm_get_sourceline(rb_control_frame_t *); VALUE yarvcore_eval_parsed(NODE *node, VALUE file); VALUE yarvcore_eval(VALUE self, VALUE str, VALUE file, VALUE line); +RUBY_EXTERN VALUE sysstack_error; + /* for thread */ #if RUBY_VM_THREAD_MODEL == 2