From ab664381aa170064d378e2c9912f043cc1c14b81 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 6 Aug 2007 04:34:11 +0000 Subject: [PATCH] * iseq.c (iseq_s_compile_option_get, Init_ISeq): added a new method VM::InstructionSequence::compile_option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++-- iseq.c | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c410189e9f..3cbcd31089 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Mon Aug 6 13:09:55 2007 Nobuyoshi Nakada +Mon Aug 6 13:34:09 2007 Nobuyoshi Nakada * common.mk (INSNS): not chdir to srcdir. @@ -6,10 +6,13 @@ Mon Aug 6 13:09:55 2007 Nobuyoshi Nakada * iseq.c (ruby_node_name): ditto. + * iseq.c (iseq_s_compile_option_get, Init_ISeq): added a new + method VM::InstructionSequence::compile_option. + * lib/vm/instruction.rb (RubyVM::SourceCodeGenerator): --destdir option. - * tool/node_name.rb: ditto. + * tool/node_name.rb: to auto-generate node name list. Sun Aug 5 11:51:39 2007 Kouhei Sutou diff --git a/iseq.c b/iseq.c index 7e652492cb..94e8eeff22 100644 --- a/iseq.c +++ b/iseq.c @@ -487,7 +487,13 @@ iseq_s_compile_option_set(VALUE self, VALUE opt) rb_compile_option_t option; make_compile_option(&option, opt); COMPILE_OPTION_DEFAULT = option; - return make_compile_option_value(&option); + return opt; +} + +static VALUE +iseq_s_compile_option_get(VALUE self) +{ + return make_compile_option_value(&COMPILE_OPTION_DEFAULT); } static rb_iseq_t * @@ -671,7 +677,7 @@ insn_operand_intern(rb_iseq_t *iseq, */ VALUE ruby_iseq_disasm_insn(VALUE ret, VALUE *iseq, int pos, - rb_iseq_t *iseqdat, VALUE child) + rb_iseq_t *iseqdat, VALUE child) { int insn = iseq[pos]; int len = insn_len(insn); @@ -757,6 +763,7 @@ ruby_iseq_disasm(VALUE self) int i; ID *tbl; char buff[0x200]; + enum {header_minlen = 72}; iseq = iseqdat->iseq; size = iseqdat->iseq_size; @@ -764,8 +771,9 @@ ruby_iseq_disasm(VALUE self) rb_str_cat2(str, "== disasm: "); rb_str_concat(str, iseq_inspect(iseqdat->self)); - for (i = RSTRING_LEN(str); i < 72; i++) { - rb_str_cat2(str, "="); + if ((i = RSTRING_LEN(str)) < header_minlen) { + rb_str_resize(str, header_minlen); + memset(RSTRING_PTR(str) + i, '=', header_minlen - i); } rb_str_cat2(str, "\n"); @@ -1225,6 +1233,8 @@ Init_ISeq(void) rb_define_singleton_method(rb_cISeq, "compile", iseq_s_compile, -1); rb_define_singleton_method(rb_cISeq, "new", iseq_s_compile, -1); rb_define_singleton_method(rb_cISeq, "compile_file", iseq_s_compile_file, -1); + rb_define_singleton_method(rb_cISeq, "compile_option", + iseq_s_compile_option_get, 0); rb_define_singleton_method(rb_cISeq, "compile_option=", iseq_s_compile_option_set, 1); }