From b76fd8283aa28794c082c61615b57bc0e80acdc7 Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 31 Oct 2010 01:42:54 +0000 Subject: * vm_core.h: some refactoring. - move decl. of rb_compile_option_struct to iseq.h. - define enum iseq_type. - define enum vm_special_object_type. * compile.c: some refactoring. - apply above changes. - (struct iseq_link_element): change value of type. - remove unused decl. - fix comment. - rename iseq_build_body and iseq_build_exception to iseq_build_from_ary_body and iseq_build_from_ary_exception. * iseq.h: define enum catch_type and enum defined_type. * insns.def: apply above changes. * iseq.c: define ISEQ_MAJOR_VERSION and ISEQ_MINOR_VERSION. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 4ee20d458b..c852b2c234 100644 --- a/compile.c +++ b/compile.c @@ -24,10 +24,10 @@ typedef struct iseq_link_element { enum { - ISEQ_ELEMENT_NONE = INT2FIX(0x00), - ISEQ_ELEMENT_LABEL = INT2FIX(0x01), - ISEQ_ELEMENT_INSN = INT2FIX(0x02), - ISEQ_ELEMENT_ADJUST = INT2FIX(0x03) + ISEQ_ELEMENT_NONE, + ISEQ_ELEMENT_LABEL, + ISEQ_ELEMENT_INSN, + ISEQ_ELEMENT_ADJUST, } type; struct iseq_link_element *next; struct iseq_link_element *prev; @@ -329,8 +329,6 @@ static int insn_data_length(INSN *iobj); static int insn_data_line_no(INSN *iobj); static int calc_sp_depth(int depth, INSN *iobj); -static void ADD_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor, LINK_ELEMENT *elem); - static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...); static LABEL *new_label_body(rb_iseq_t *iseq, long line); static ADJUST *new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line); @@ -1252,7 +1250,7 @@ static const struct st_hash_type cdhash_type = { }; /** - ruby insn object array -> raw instruction sequence + ruby insn object list -> raw instruction sequence */ static int iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor) @@ -2859,7 +2857,7 @@ add_ensure_iseq(LINK_ANCHOR *ret, rb_iseq_t *iseq, int is_return) } static VALUE -setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned long *flag) +setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag) { VALUE argc = INT2FIX(0); int nsplat = 0; @@ -3743,7 +3741,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_OP_ASGN1: { DECL_ANCHOR(args); VALUE argc; - unsigned long flag = 0; + VALUE flag = 0; ID id = node->nd_mid; int boff = 0; @@ -4024,7 +4022,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) DECL_ANCHOR(args); ID mid = node->nd_mid; VALUE argc; - unsigned long flag = 0; + VALUE flag = 0; VALUE parent_block = iseq->compile_data->current_block; iseq->compile_data->current_block = Qfalse; @@ -4121,7 +4119,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_ZSUPER:{ DECL_ANCHOR(args); VALUE argc; - unsigned long flag = 0; + VALUE flag = 0; VALUE parent_block = iseq->compile_data->current_block; INIT_ANCHOR(args); @@ -4292,7 +4290,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_YIELD:{ DECL_ANCHOR(args); VALUE argc; - unsigned long flag = 0; + VALUE flag = 0; INIT_ANCHOR(args); if (iseq->type == ISEQ_TYPE_TOP) { @@ -4907,7 +4905,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) case NODE_ATTRASGN:{ DECL_ANCHOR(recv); DECL_ANCHOR(args); - unsigned long flag = 0; + VALUE flag = 0; VALUE argc; INIT_ANCHOR(recv); @@ -5170,7 +5168,7 @@ get_exception_sym2type(VALUE sym) if (sym == symEnsure) return CATCH_TYPE_ENSURE; if (sym == symRetry) return CATCH_TYPE_RETRY; if (sym == symBreak) return CATCH_TYPE_BREAK; - if (sym == symRedo) return CATCH_TYPE_REDO; + if (sym == symRedo) return CATCH_TYPE_REDO; if (sym == symNext) return CATCH_TYPE_NEXT; rb_raise(rb_eSyntaxError, "invalid exception symbol: %s", RSTRING_PTR(rb_inspect(sym))); @@ -5178,7 +5176,7 @@ get_exception_sym2type(VALUE sym) } static int -iseq_build_exception(rb_iseq_t *iseq, struct st_table *labels_table, +iseq_build_from_ary_exception(rb_iseq_t *iseq, struct st_table *labels_table, VALUE exception) { int i; @@ -5227,7 +5225,7 @@ insn_make_insn_table(void) } static int -iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, +iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, VALUE body, struct st_table *labels_table) { /* TODO: body should be frozen */ @@ -5370,9 +5368,7 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, int i; ID *tbl; struct st_table *labels_table = st_init_numtable(); - DECL_ANCHOR(anchor); - INIT_ANCHOR(anchor); iseq->local_table_size = RARRAY_LENINT(locals); @@ -5430,10 +5426,10 @@ rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, } /* exception */ - iseq_build_exception(iseq, labels_table, exception); + iseq_build_from_ary_exception(iseq, labels_table, exception); /* body */ - iseq_build_body(iseq, anchor, body, labels_table); + iseq_build_from_ary_body(iseq, anchor, body, labels_table); return iseq->self; } -- cgit v1.2.3