From 6b6bf4dd481f744faf54b5efcda5f32e4565bd7d Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 12 Jul 2007 04:25:46 +0000 Subject: * blockinlining.c: remove "yarv" prefix. * array.c, numeric.c: ditto. * insnhelper.ci, insns.def, vm_evalbody.ci: ditto. * yarvcore.c: removed. * yarvcore.h: renamed to core.h. * cont.c, debug.c, error.c, process.c, signal.c : ditto. * ext/probeprofiler/probeprofiler.c: ditto. * id.c, id.h: added. * inits.c: ditto. * compile.c: rename internal functions. * compile.h: fix debug flag. * eval.c, object.c, vm.c: remove ruby_top_self. use rb_vm_top_self() instead. * eval_intern.h, eval_load: ditto. * gc.c: rename yarv_machine_stack_mark() to rb_gc_mark_machine_stack(). * insnhelper.h: remove unused macros. * iseq.c: add iseq_compile() to create iseq object from source string. * proc.c: rename a internal function. * template/insns.inc.tmpl: remove YARV prefix. * thread.c: * vm.c (rb_iseq_eval): added. * vm.c: move some functions from yarvcore.c. * vm_dump.c: fix to remove compiler warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 72 +++++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 29 deletions(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index 55ff9952b3..c50a6d443d 100644 --- a/iseq.c +++ b/iseq.c @@ -13,12 +13,16 @@ #include "ruby/ruby.h" #include "ruby/node.h" -#include "yarvcore.h" +/* #define MARK_FREE_DEBUG 1 */ +#include "gc.h" +#include "vm_core.h" + #include "insns.inc" #include "insns_info.inc" -/* #define MARK_FREE_DEBUG 1 */ -#include "gc.h" +/* compile.c */ +void iseq_compile(VALUE self, NODE *node); +int iseq_translate_threaded_code(rb_iseq_t *iseq); VALUE rb_cISeq; @@ -289,7 +293,7 @@ rb_iseq_new_with_bopt_and_opt(NODE *node, VALUE name, VALUE filename, iseq->self = self; prepare_iseq_build(iseq, name, filename, parent, type, bopt, option); - rb_iseq_compile(self, node); + iseq_compile(self, node); cleanup_iseq_build(iseq); return self; } @@ -418,22 +422,41 @@ compile_string(VALUE str, VALUE file, VALUE line) return node; } -static VALUE -iseq_s_compile(int argc, VALUE *argv, VALUE self) +VALUE +rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE line, VALUE opt) { - VALUE str, file = Qnil, line = INT2FIX(1), opt = Qnil; - NODE *node; rb_compile_option_t option; + NODE *node = compile_string(src, file, line); + rb_thread_t *th = GET_THREAD(); + make_compile_option(&option, opt); + + if (th->base_block) { + return rb_iseq_new_with_opt(node, th->base_block->iseq->name, + file, th->base_block->iseq->self, + ISEQ_TYPE_EVAL, &option); + } + else { + return rb_iseq_new_with_opt(node, rb_str_new2(""), file, Qfalse, + ISEQ_TYPE_TOP, &option); + } +} + +VALUE +rb_iseq_compile(VALUE src, VALUE file, VALUE line) +{ + return rb_iseq_compile_with_option(src, file, line, Qnil); +} - rb_scan_args(argc, argv, "13", &str, &file, &line, &opt); +static VALUE +iseq_s_compile(int argc, VALUE *argv, VALUE self) +{ + VALUE src, file = Qnil, line = INT2FIX(1), opt = Qnil; + rb_scan_args(argc, argv, "13", &src, &file, &line, &opt); file = file == Qnil ? rb_str_new2("") : file; line = line == Qnil ? INT2FIX(1) : line; - node = compile_string(str, file, line); - make_compile_option(&option, opt); - return rb_iseq_new_with_opt(node, rb_str_new2("
"), file, Qfalse, - ISEQ_TYPE_TOP, &option); + return rb_iseq_compile_with_option(src, file, line, opt); } static VALUE @@ -481,7 +504,7 @@ iseq_check(VALUE val) static VALUE iseq_eval(VALUE self) { - return rb_thread_eval(GET_THREAD(), self); + return rb_iseq_eval(self); } static VALUE @@ -1066,15 +1089,6 @@ end } } -int -debug_node(NODE *node) -{ - printf("node type: %d\n", nd_type(node)); - printf("node name: %s\n", ruby_node_name(nd_type(node))); - printf("node filename: %s\n", node->nd_file); - return 0; -} - #define DECL_SYMBOL(name) \ static VALUE sym_##name @@ -1121,7 +1135,7 @@ cdhash_each(VALUE key, VALUE value, VALUE ary) VALUE iseq_data_to_ary(rb_iseq_t *iseq) { - int i, pos, line = 0, insn_pos = 0; + int i, pos, line = 0; VALUE *seq; VALUE val = rb_ary_new(); @@ -1133,7 +1147,7 @@ iseq_data_to_ary(rb_iseq_t *iseq) VALUE exception = rb_ary_new(); /* [[....]] */ VALUE misc = rb_hash_new(); - static VALUE insn_syms[YARV_MAX_INSTRUCTION_SIZE]; + static VALUE insn_syms[VM_INSTRUCTION_SIZE]; struct st_table *labels_table = st_init_numtable(); DECL_SYMBOL(top); @@ -1146,7 +1160,7 @@ iseq_data_to_ary(rb_iseq_t *iseq) if (sym_top == 0) { int i; - for (i=0; i