summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 09:09:21 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 09:09:21 +0000
commite2e23e688fd655c55112872b10a7bd6840314653 (patch)
tree1be14c402bfd9c6b51b1e674b5e2df8ec1ccd3ab /iseq.c
parentc332266ee0d026340e369c9b67d01837ba2ed2e4 (diff)
* iseq.c (Init_ISeq): disable ISeq.load() because there is no verifier.
* iseq.c, proc.c: add ISeq.disasm(method). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/iseq.c b/iseq.c
index f316eda..c478062 100644
--- a/iseq.c
+++ b/iseq.c
@@ -881,6 +881,23 @@ ruby_iseq_disasm(VALUE self)
return str;
}
+static VALUE
+iseq_s_disasm(VALUE klass, VALUE body)
+{
+ extern NODE *rb_method_body(VALUE body);
+ NODE *node;
+ VALUE ret = Qnil;
+
+ if ((node = rb_method_body(body)) != 0) {
+ if (nd_type(node) == RUBY_VM_METHOD_NODE) {
+ VALUE iseqval = (VALUE)node->nd_body;
+ ret = ruby_iseq_disasm(iseqval);
+ }
+ }
+
+ return ret;
+}
+
const char *
ruby_node_name(int node)
{
@@ -1250,16 +1267,19 @@ Init_ISeq(void)
rb_define_alloc_func(rb_cISeq, iseq_alloc);
rb_define_method(rb_cISeq, "inspect", iseq_inspect, 0);
rb_define_method(rb_cISeq, "disasm", ruby_iseq_disasm, 0);
+ rb_define_method(rb_cISeq, "disassemble", ruby_iseq_disasm, 0);
rb_define_method(rb_cISeq, "to_a", iseq_to_a, 0);
rb_define_method(rb_cISeq, "eval", iseq_eval, 0);
- rb_define_singleton_method(rb_cISeq, "load", iseq_s_load, -1);
+ /* disable this feature because there is no verifier. */
+ /* rb_define_singleton_method(rb_cISeq, "load", iseq_s_load, -1); */
+
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);
+ 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);
+ rb_define_singleton_method(rb_cISeq, "disasm", iseq_s_disasm, 1);
+ rb_define_singleton_method(rb_cISeq, "disassemble", iseq_s_disasm, 1);
}