From 893ee3097885c83df17273d7de5ed54438de5d20 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 8 Jan 2008 04:05:59 +0000 Subject: [PATCH] * compile.c (iseq_build_from_ary), iseq.c (iseq_load): fix for format change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ compile.c | 9 +++++---- iseq.c | 32 ++++++++++++++++---------------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 008905a89f..67c3213b9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Jan 8 13:05:57 2008 Nobuyoshi Nakada + + * compile.c (iseq_build_from_ary), iseq.c (iseq_load): fix for format change. + Tue Jan 8 07:56:11 2008 Tanaka Akira * string.c (rb_str_buf_append): fix append itself. diff --git a/compile.c b/compile.c index 371e5a90b3..e1219e4b93 100644 --- a/compile.c +++ b/compile.c @@ -4831,7 +4831,7 @@ iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor, #define CHECK_ARRAY(v) rb_convert_type(v, T_ARRAY, "Array", "to_ary") #define CHECK_STRING(v) rb_convert_type(v, T_STRING, "String", "to_str") #define CHECK_SYMBOL(v) rb_convert_type(v, T_SYMBOL, "Symbol", "to_sym") -#define CHECK_INTEGER(v) (NUM2LONG(v), v) +static inline VALUE CHECK_INTEGER(VALUE v) {NUM2LONG(v); return v;} VALUE iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, @@ -4868,20 +4868,19 @@ iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, else { int i = 0; VALUE argc = CHECK_INTEGER(rb_ary_entry(args, i++)); - VALUE arg_opts = CHECK_INTEGER(rb_ary_entry(args, i++)); VALUE arg_opt_labels = CHECK_ARRAY(rb_ary_entry(args, i++)); VALUE arg_post_len = CHECK_INTEGER(rb_ary_entry(args, i++)); VALUE arg_post_start = CHECK_INTEGER(rb_ary_entry(args, i++)); VALUE arg_rest = CHECK_INTEGER(rb_ary_entry(args, i++)); VALUE arg_block = CHECK_INTEGER(rb_ary_entry(args, i++)); + VALUE arg_simple = CHECK_INTEGER(rb_ary_entry(args, i++)); iseq->argc = FIX2INT(argc); - iseq->arg_opts = FIX2INT(arg_opts); iseq->arg_rest = FIX2INT(arg_rest); iseq->arg_post_len = FIX2INT(arg_post_len); iseq->arg_post_start = FIX2INT(arg_post_start); iseq->arg_block = FIX2INT(arg_block); - iseq->arg_opt_table = (VALUE *)ALLOC_N(VALUE, iseq->arg_opts); + iseq->arg_opt_table = (VALUE *)ALLOC_N(VALUE, RARRAY_LEN(arg_opt_labels)); if (iseq->arg_block != -1) { iseq->arg_size = iseq->arg_block + 1; @@ -4901,6 +4900,8 @@ iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, (VALUE)register_label(iseq, labels_table, rb_ary_entry(arg_opt_labels, i)); } + + iseq->arg_simple = NUM2INT(arg_simple); } /* exception */ diff --git a/iseq.c b/iseq.c index cde2c9988c..2b2b855e9a 100644 --- a/iseq.c +++ b/iseq.c @@ -323,48 +323,48 @@ VALUE iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, #define CHECK_ARRAY(v) rb_convert_type(v, T_ARRAY, "Array", "to_ary") #define CHECK_STRING(v) rb_convert_type(v, T_STRING, "String", "to_str") #define CHECK_SYMBOL(v) rb_convert_type(v, T_SYMBOL, "Symbol", "to_sym") -#define CHECK_INTEGER(v) (NUM2LONG(v), v) +static inline VALUE CHECK_INTEGER(VALUE v) {NUM2LONG(v); return v;} VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt) { VALUE iseqval = iseq_alloc(rb_cISeq); VALUE magic, version1, version2, format_type, misc; - VALUE name, filename, line; + VALUE name, filename; VALUE type, body, locals, args, exception; VALUE iseq_type; struct st_table *type_map = 0; rb_iseq_t *iseq; rb_compile_option_t option; + int i = 0; /* [magic, major_version, minor_version, format_type, misc, - * name, filename, line, + * name, filename, * type, locals, args, exception_table, body] */ data = CHECK_ARRAY(data); - magic = CHECK_STRING(rb_ary_entry(data, 0)); - version1 = CHECK_INTEGER(rb_ary_entry(data, 1)); - version2 = CHECK_INTEGER(rb_ary_entry(data, 2)); - format_type = CHECK_INTEGER(rb_ary_entry(data, 3)); - misc = rb_ary_entry(data, 4); /* TODO */ + magic = CHECK_STRING(rb_ary_entry(data, i++)); + version1 = CHECK_INTEGER(rb_ary_entry(data, i++)); + version2 = CHECK_INTEGER(rb_ary_entry(data, i++)); + format_type = CHECK_INTEGER(rb_ary_entry(data, i++)); + misc = rb_ary_entry(data, i++); /* TODO */ - name = CHECK_STRING(rb_ary_entry(data, 5)); - filename = CHECK_STRING(rb_ary_entry(data, 6)); - line = CHECK_ARRAY(rb_ary_entry(data, 7)); + name = CHECK_STRING(rb_ary_entry(data, i++)); + filename = CHECK_STRING(rb_ary_entry(data, i++)); - type = CHECK_SYMBOL(rb_ary_entry(data, 8)); - locals = CHECK_ARRAY(rb_ary_entry(data, 9)); + type = CHECK_SYMBOL(rb_ary_entry(data, i++)); + locals = CHECK_ARRAY(rb_ary_entry(data, i++)); - args = rb_ary_entry(data, 10); + args = rb_ary_entry(data, i++); if (FIXNUM_P(args) || (args = CHECK_ARRAY(args))) { /* */ } - exception = CHECK_ARRAY(rb_ary_entry(data, 11)); - body = CHECK_ARRAY(rb_ary_entry(data, 12)); + exception = CHECK_ARRAY(rb_ary_entry(data, i++)); + body = CHECK_ARRAY(rb_ary_entry(data, i++)); GetISeqPtr(iseqval, iseq); iseq->self = iseqval;