ruby-internal 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +59 -0
- data/LGPL +515 -0
- data/LICENSE +9 -0
- data/README +31 -0
- data/Rakefile +20 -0
- data/TODO +9 -0
- data/example/README +5 -0
- data/example/simple_client.rb +12 -0
- data/example/simple_server.rb +11 -0
- data/example/triangle_client.rb +7 -0
- data/example/triangle_server.rb +24 -0
- data/ext/cached/ruby-1.8.0/internal/binding/block.h +37 -0
- data/ext/cached/ruby-1.8.0/internal/method/method.h +19 -0
- data/ext/cached/ruby-1.8.0/internal/module/classpath.c +27 -0
- data/ext/cached/ruby-1.8.0/internal/module/classpath.h +14 -0
- data/ext/cached/ruby-1.8.0/internal/node/block.h +37 -0
- data/ext/cached/ruby-1.8.0/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.0/internal/node/node_type_descrip.c +155 -0
- data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.c +5741 -0
- data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.h +69 -0
- data/ext/cached/ruby-1.8.0/internal/proc/block.h +37 -0
- data/ext/cached/ruby-1.8.0/internal/tag/tag.h +15 -0
- data/ext/cached/ruby-1.8.0/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.0/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.0/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.8.1/internal/binding/block.h +31 -0
- data/ext/cached/ruby-1.8.1/internal/method/method.h +19 -0
- data/ext/cached/ruby-1.8.1/internal/module/classpath.c +27 -0
- data/ext/cached/ruby-1.8.1/internal/module/classpath.h +14 -0
- data/ext/cached/ruby-1.8.1/internal/node/block.h +31 -0
- data/ext/cached/ruby-1.8.1/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.1/internal/node/node_type_descrip.c +154 -0
- data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.c +5733 -0
- data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.h +69 -0
- data/ext/cached/ruby-1.8.1/internal/proc/block.h +31 -0
- data/ext/cached/ruby-1.8.1/internal/tag/tag.h +16 -0
- data/ext/cached/ruby-1.8.1/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.1/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.1/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.8.2/internal/binding/block.h +32 -0
- data/ext/cached/ruby-1.8.2/internal/method/method.h +19 -0
- data/ext/cached/ruby-1.8.2/internal/module/classpath.c +45 -0
- data/ext/cached/ruby-1.8.2/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.8.2/internal/node/block.h +32 -0
- data/ext/cached/ruby-1.8.2/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.2/internal/node/node_type_descrip.c +154 -0
- data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.c +5733 -0
- data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.h +69 -0
- data/ext/cached/ruby-1.8.2/internal/proc/block.h +32 -0
- data/ext/cached/ruby-1.8.2/internal/tag/tag.h +16 -0
- data/ext/cached/ruby-1.8.2/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.2/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.2/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.8.3/internal/binding/block.h +32 -0
- data/ext/cached/ruby-1.8.3/internal/method/method.h +20 -0
- data/ext/cached/ruby-1.8.3/internal/module/classpath.c +45 -0
- data/ext/cached/ruby-1.8.3/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.8.3/internal/node/block.h +32 -0
- data/ext/cached/ruby-1.8.3/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.3/internal/node/node_type_descrip.c +154 -0
- data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.c +5733 -0
- data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.h +69 -0
- data/ext/cached/ruby-1.8.3/internal/proc/block.h +32 -0
- data/ext/cached/ruby-1.8.3/internal/tag/tag.h +16 -0
- data/ext/cached/ruby-1.8.3/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.3/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.3/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.8.4/internal/binding/block.h +32 -0
- data/ext/cached/ruby-1.8.4/internal/method/method.h +20 -0
- data/ext/cached/ruby-1.8.4/internal/module/classpath.c +45 -0
- data/ext/cached/ruby-1.8.4/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.8.4/internal/node/block.h +32 -0
- data/ext/cached/ruby-1.8.4/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.4/internal/node/node_type_descrip.c +154 -0
- data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.c +5733 -0
- data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.h +69 -0
- data/ext/cached/ruby-1.8.4/internal/proc/block.h +32 -0
- data/ext/cached/ruby-1.8.4/internal/tag/tag.h +16 -0
- data/ext/cached/ruby-1.8.4/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.4/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.4/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.8.5/internal/binding/block.h +32 -0
- data/ext/cached/ruby-1.8.5/internal/method/method.h +20 -0
- data/ext/cached/ruby-1.8.5/internal/module/classpath.c +45 -0
- data/ext/cached/ruby-1.8.5/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.8.5/internal/node/block.h +32 -0
- data/ext/cached/ruby-1.8.5/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.5/internal/node/node_type_descrip.c +154 -0
- data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.c +5732 -0
- data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.h +67 -0
- data/ext/cached/ruby-1.8.5/internal/proc/block.h +32 -0
- data/ext/cached/ruby-1.8.5/internal/tag/tag.h +16 -0
- data/ext/cached/ruby-1.8.5/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.5/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.5/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.8.6/internal/binding/block.h +32 -0
- data/ext/cached/ruby-1.8.6/internal/method/method.h +20 -0
- data/ext/cached/ruby-1.8.6/internal/module/classpath.c +45 -0
- data/ext/cached/ruby-1.8.6/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.8.6/internal/node/block.h +32 -0
- data/ext/cached/ruby-1.8.6/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.6/internal/node/node_type_descrip.c +154 -0
- data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.c +5732 -0
- data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.h +67 -0
- data/ext/cached/ruby-1.8.6/internal/proc/block.h +32 -0
- data/ext/cached/ruby-1.8.6/internal/tag/tag.h +16 -0
- data/ext/cached/ruby-1.8.6/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.6/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.6/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.8.7/internal/binding/block.h +32 -0
- data/ext/cached/ruby-1.8.7/internal/method/method.h +20 -0
- data/ext/cached/ruby-1.8.7/internal/module/classpath.c +45 -0
- data/ext/cached/ruby-1.8.7/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.8.7/internal/node/block.h +32 -0
- data/ext/cached/ruby-1.8.7/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.8.7/internal/node/node_type_descrip.c +154 -0
- data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.c +5732 -0
- data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.h +67 -0
- data/ext/cached/ruby-1.8.7/internal/proc/block.h +32 -0
- data/ext/cached/ruby-1.8.7/internal/tag/tag.h +16 -0
- data/ext/cached/ruby-1.8.7/internal/vm/instruction/insns_info.c +39 -0
- data/ext/cached/ruby-1.8.7/internal/vm/instruction/insns_info.h +21 -0
- data/ext/cached/ruby-1.8.7/internal/vm/iseq/insns_info.inc +12 -0
- data/ext/cached/ruby-1.9.0/internal/binding/block.h +12 -0
- data/ext/cached/ruby-1.9.0/internal/method/method.h +20 -0
- data/ext/cached/ruby-1.9.0/internal/module/classpath.c +42 -0
- data/ext/cached/ruby-1.9.0/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.9.0/internal/node/block.h +12 -0
- data/ext/cached/ruby-1.9.0/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.9.0/internal/node/node_type_descrip.c +149 -0
- data/ext/cached/ruby-1.9.0/internal/node/nodeinfo.c +5579 -0
- data/ext/cached/ruby-1.9.0/internal/node/nodeinfo.h +70 -0
- data/ext/cached/ruby-1.9.0/internal/proc/block.h +12 -0
- data/ext/cached/ruby-1.9.0/internal/tag/tag.h +6 -0
- data/ext/cached/ruby-1.9.0/internal/vm/instruction/insns_info.c +5936 -0
- data/ext/cached/ruby-1.9.0/internal/vm/instruction/insns_info.h +891 -0
- data/ext/cached/ruby-1.9.0/internal/vm/iseq/insns_info.inc +700 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/debug.h +36 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/dln.h +41 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/encdb.h +147 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/eval_intern.h +221 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/gc.h +75 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/id.h +83 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/iseq.h +94 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/node.h +516 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/parse.h +303 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/regenc.h +207 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/regint.h +842 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/regparse.h +351 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/revision.h +1 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/thread_pthread.h +24 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/thread_win32.h +33 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/transcode_data.h +99 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/transdb.h +67 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/version.h +57 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/vm_core.h +663 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/vm_exec.h +187 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/vm_insnhelper.h +191 -0
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/vm_opts.h +51 -0
- data/ext/cached/ruby-1.9.1/internal/binding/block.h +12 -0
- data/ext/cached/ruby-1.9.1/internal/method/method.h +20 -0
- data/ext/cached/ruby-1.9.1/internal/module/classpath.c +42 -0
- data/ext/cached/ruby-1.9.1/internal/module/classpath.h +17 -0
- data/ext/cached/ruby-1.9.1/internal/node/block.h +12 -0
- data/ext/cached/ruby-1.9.1/internal/node/global_entry.h +10 -0
- data/ext/cached/ruby-1.9.1/internal/node/node_type_descrip.c +149 -0
- data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.c +5579 -0
- data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.h +70 -0
- data/ext/cached/ruby-1.9.1/internal/proc/block.h +12 -0
- data/ext/cached/ruby-1.9.1/internal/tag/tag.h +6 -0
- data/ext/cached/ruby-1.9.1/internal/vm/instruction/insns_info.c +5936 -0
- data/ext/cached/ruby-1.9.1/internal/vm/instruction/insns_info.h +891 -0
- data/ext/cached/ruby-1.9.1/internal/vm/iseq/insns_info.inc +700 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/debug.h +36 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/dln.h +41 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/encdb.h +147 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/eval_intern.h +209 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/gc.h +75 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/id.h +184 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/iseq.h +94 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/node.h +516 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/parse.h +303 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/regenc.h +207 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/regint.h +842 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/regparse.h +351 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/revision.h +1 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/thread_pthread.h +24 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/thread_win32.h +33 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/transcode_data.h +99 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/transdb.h +85 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/version.h +60 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_core.h +655 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_exec.h +187 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_insnhelper.h +194 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_opts.h +51 -0
- data/ext/internal/binding/binding.c +45 -0
- data/ext/internal/binding/block.h.rpp +44 -0
- data/ext/internal/binding/extconf.rb +6 -0
- data/ext/internal/method/extconf.rb +8 -0
- data/ext/internal/method/method.c +269 -0
- data/ext/internal/method/method.h.rpp +58 -0
- data/ext/internal/module/classpath.c.rpp +29 -0
- data/ext/internal/module/classpath.h.rpp +36 -0
- data/ext/internal/module/extconf.rb +11 -0
- data/ext/internal/module/module.c +797 -0
- data/ext/internal/module/module.h +7 -0
- data/ext/internal/node/block.h.rpp +44 -0
- data/ext/internal/node/builtins.h +41 -0
- data/ext/internal/node/extconf.rb +66 -0
- data/ext/internal/node/global_entry.h.rpp +26 -0
- data/ext/internal/node/node.c +1147 -0
- data/ext/internal/node/node_type_descrip.c.rpp +72 -0
- data/ext/internal/node/node_type_descrip.h +17 -0
- data/ext/internal/node/node_type_descrip.rb +39 -0
- data/ext/internal/node/nodeinfo.c.rpp +587 -0
- data/ext/internal/node/nodeinfo.h.rpp +30 -0
- data/ext/internal/node/nodes.rb +78 -0
- data/ext/internal/node/read_node_h.rb +34 -0
- data/ext/internal/node/ruby_internal_node.h +31 -0
- data/ext/internal/noex/extconf.rb +6 -0
- data/ext/internal/noex/noex.c +44 -0
- data/ext/internal/object/extconf.rb +4 -0
- data/ext/internal/object/object.c +75 -0
- data/ext/internal/proc/block.h.rpp +44 -0
- data/ext/internal/proc/extconf.rb +9 -0
- data/ext/internal/proc/proc.c +331 -0
- data/ext/internal/tag/extconf.rb +3 -0
- data/ext/internal/tag/tag.c +17 -0
- data/ext/internal/tag/tag.h.rpp +22 -0
- data/ext/internal/thread/extconf.rb +3 -0
- data/ext/internal/thread/thread.c +107 -0
- data/ext/internal/vm/constants/constants.c +33 -0
- data/ext/internal/vm/constants/extconf.rb +3 -0
- data/ext/internal/vm/control_frame/control_frame.c +185 -0
- data/ext/internal/vm/control_frame/control_frame.h +18 -0
- data/ext/internal/vm/control_frame/extconf.rb +3 -0
- data/ext/internal/vm/extconf.rb +3 -0
- data/ext/internal/vm/inline_cache/extconf.rb +6 -0
- data/ext/internal/vm/inline_cache/inline_cache.c +79 -0
- data/ext/internal/vm/instruction/extconf.rb +6 -0
- data/ext/internal/vm/instruction/insns_info.c.rpp +213 -0
- data/ext/internal/vm/instruction/insns_info.h.rpp +53 -0
- data/ext/internal/vm/instruction/instruction.c +78 -0
- data/ext/internal/vm/instruction/instruction.h +10 -0
- data/ext/internal/vm/iseq/extconf.rb +7 -0
- data/ext/internal/vm/iseq/insns_info.inc.rpp +30 -0
- data/ext/internal/vm/iseq/internal_iseq.h +9 -0
- data/ext/internal/vm/iseq/iseq.c +555 -0
- data/ext/internal/vm/vm.c +55 -0
- data/ext/mkmf-ruby-internal.rb +111 -0
- data/ext/ruby_source_dir.rb +24 -0
- data/ext/rubypp.rb +97 -0
- data/generate_rdoc.rb +33 -0
- data/lib/internal/binding.rb +1 -0
- data/lib/internal/classtree.rb +55 -0
- data/lib/internal/debug.rb +16 -0
- data/lib/internal/method.rb +1 -0
- data/lib/internal/method/as_code.rb +33 -0
- data/lib/internal/method/as_expression.rb +34 -0
- data/lib/internal/method/signature.rb +442 -0
- data/lib/internal/module.rb +1 -0
- data/lib/internal/module/as_code.rb +45 -0
- data/lib/internal/node.rb +3 -0
- data/lib/internal/node/as_code.rb +233 -0
- data/lib/internal/node/as_expression.rb +619 -0
- data/lib/internal/node/dump.rb +53 -0
- data/lib/internal/node/pp.rb +72 -0
- data/lib/internal/node/to_a.rb +52 -0
- data/lib/internal/noex.rb +1 -0
- data/lib/internal/obfusc.rb +57 -0
- data/lib/internal/object.rb +1 -0
- data/lib/internal/object/as_code.rb +10 -0
- data/lib/internal/proc.rb +1 -0
- data/lib/internal/proc/as_code.rb +21 -0
- data/lib/internal/proc/as_expression.rb +14 -0
- data/lib/internal/proc/signature.rb +184 -0
- data/lib/internal/tag.rb +1 -0
- data/lib/internal/thread.rb +1 -0
- data/lib/internal/vm.rb +1 -0
- data/lib/internal/vm/bytedecoder.rb +866 -0
- data/lib/internal/vm/constants.rb +1 -0
- data/lib/internal/vm/control_frame.rb +1 -0
- data/lib/internal/vm/inline_cache.rb +1 -0
- data/lib/internal/vm/instruction.rb +1 -0
- data/lib/internal/vm/iseq.rb +1 -0
- data/lib/internal/vm/iseq/as_code.rb +27 -0
- data/lib/internal/vm/iseq/as_expression.rb +26 -0
- data/metaconfig +19 -0
- data/post-config.rb +1 -0
- data/post-install.rb +4 -0
- data/post-setup.rb +7 -0
- data/pre-config.rb +96 -0
- data/pre-install.rb +13 -0
- data/pre-setup.rb +8 -0
- data/run_tests.rb +26 -0
- data/setup.rb +1599 -0
- data/test/expression_samples.rb +160 -0
- data/test/node_samples.rb +122 -0
- data/test/test_as_code.rb +261 -0
- data/test/test_as_expression.rb +229 -0
- data/test/test_dump_class.rb +187 -0
- data/test/test_dump_method.rb +144 -0
- data/test/test_dump_proc.rb +118 -0
- data/test/test_helpers.rb +61 -0
- data/test/test_method.rb +72 -0
- data/test/test_methodsig.rb +267 -0
- data/test/test_module.rb +49 -0
- data/test/test_node.rb +77 -0
- data/test/test_proc.rb +47 -0
- metadata +377 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
#ifndef ruby_internal_block__h_
|
2
|
+
#define ruby_internal_block__h_
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
|
6
|
+
#ifndef RUBY_VM
|
7
|
+
#include "env.h"
|
8
|
+
#endif
|
9
|
+
|
10
|
+
#ruby <<END
|
11
|
+
$: << '../..'
|
12
|
+
require 'ruby_source_dir'
|
13
|
+
vm_c_location = "#{RUBY_SOURCE_DIR}/vm.c"
|
14
|
+
eval_c_location = "#{RUBY_SOURCE_DIR}/eval.c"
|
15
|
+
|
16
|
+
[ vm_c_location, eval_c_location ].each do |file|
|
17
|
+
next if not File.exist?(file)
|
18
|
+
|
19
|
+
File.open(file) do |eval_c|
|
20
|
+
write = false
|
21
|
+
stopwrite = false
|
22
|
+
while (line = eval_c.gets) != nil do
|
23
|
+
case line
|
24
|
+
when /^struct (BLOCK)/
|
25
|
+
write = true
|
26
|
+
stopwrite = false
|
27
|
+
when /^\}/
|
28
|
+
stopwrite = true
|
29
|
+
end
|
30
|
+
puts line if write
|
31
|
+
if write and stopwrite then
|
32
|
+
stopwrite = false
|
33
|
+
write = false
|
34
|
+
puts ''
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
nil
|
41
|
+
END
|
42
|
+
|
43
|
+
#endif
|
44
|
+
|
@@ -0,0 +1,269 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include "internal/node/ruby_internal_node.h"
|
3
|
+
#include "method.h"
|
4
|
+
|
5
|
+
#ifdef RUBY_VM
|
6
|
+
#include "vm_core.h"
|
7
|
+
#endif
|
8
|
+
|
9
|
+
#ifndef HAVE_RB_CMETHOD
|
10
|
+
static VALUE rb_cMethod = Qnil;
|
11
|
+
#endif
|
12
|
+
|
13
|
+
#ifndef HAVE_RB_CUNBOUNDMETHOD
|
14
|
+
static VALUE rb_cUnboundMethod = Qnil;
|
15
|
+
#endif
|
16
|
+
|
17
|
+
#ifndef RARRAY_LEN
|
18
|
+
#define RARRAY_LEN(a) RARRAY(a)->len
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#ifndef RARRAY_PTR
|
22
|
+
#define RARRAY_PTR(a) RARRAY(a)->ptr
|
23
|
+
#endif
|
24
|
+
|
25
|
+
static VALUE rb_mMarshal;
|
26
|
+
|
27
|
+
static VALUE marshal_dump(VALUE obj, VALUE limit)
|
28
|
+
{
|
29
|
+
return rb_funcall(rb_mMarshal, rb_intern("dump"), 2, obj, limit);
|
30
|
+
}
|
31
|
+
|
32
|
+
static VALUE marshal_load(VALUE obj)
|
33
|
+
{
|
34
|
+
return rb_funcall(rb_mMarshal, rb_intern("load"), 1, obj);
|
35
|
+
}
|
36
|
+
|
37
|
+
static char const * lookup_module_str =
|
38
|
+
"proc { |name|\n"
|
39
|
+
" o = Object\n"
|
40
|
+
" name.to_s.split('::').each do |subname|\n"
|
41
|
+
" if subname == '<Singleton>' then\n"
|
42
|
+
" o = o.singleton_class\n"
|
43
|
+
" else\n"
|
44
|
+
" o = o.const_get(subname)\n"
|
45
|
+
" end\n"
|
46
|
+
" end\n"
|
47
|
+
" o\n"
|
48
|
+
"}\n";
|
49
|
+
|
50
|
+
static VALUE lookup_module_proc = Qnil;
|
51
|
+
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* method.receiver => Object
|
55
|
+
*
|
56
|
+
* Given a Method, returns the Object to which it is bound.
|
57
|
+
*/
|
58
|
+
static VALUE method_receiver(VALUE method)
|
59
|
+
{
|
60
|
+
struct METHOD * m;
|
61
|
+
Data_Get_Struct(method, struct METHOD, m);
|
62
|
+
return m->recv;
|
63
|
+
}
|
64
|
+
|
65
|
+
/*
|
66
|
+
* call-seq:
|
67
|
+
* method.method_id => Symbol
|
68
|
+
*
|
69
|
+
* Given a Method, returns the Symbol of the method it represents. If
|
70
|
+
* the method is an alias for another method, returns the Symbol of the
|
71
|
+
* new method, not the original. If the method changes name, returns
|
72
|
+
* the original name, not the new name.
|
73
|
+
*/
|
74
|
+
static VALUE method_id(VALUE method)
|
75
|
+
{
|
76
|
+
struct METHOD * m;
|
77
|
+
Data_Get_Struct(method, struct METHOD, m);
|
78
|
+
return ID2SYM(m->id);
|
79
|
+
}
|
80
|
+
|
81
|
+
/*
|
82
|
+
* call-seq:
|
83
|
+
* method.method_oid => Symbol
|
84
|
+
*
|
85
|
+
* Given a Method, returns the Symbol of the method it represents. If
|
86
|
+
* the method is an alias for another method, returns the Symbol of the
|
87
|
+
* original method, not the alias. If the original method changes name,
|
88
|
+
* returns the original name.
|
89
|
+
*/
|
90
|
+
static VALUE method_oid(VALUE method)
|
91
|
+
{
|
92
|
+
struct METHOD * m;
|
93
|
+
Data_Get_Struct(method, struct METHOD, m);
|
94
|
+
return ID2SYM(m->oid);
|
95
|
+
}
|
96
|
+
|
97
|
+
/*
|
98
|
+
* call-seq:
|
99
|
+
* method.origin_class => Class
|
100
|
+
*
|
101
|
+
* Given a Method, returns the Class in which the method it represents
|
102
|
+
* was defined. If the method was defined in a base class and
|
103
|
+
* Object#method is called on a derived instance of that base class,
|
104
|
+
* this method returns the base class.
|
105
|
+
*/
|
106
|
+
static VALUE method_origin_class(VALUE method)
|
107
|
+
{
|
108
|
+
struct METHOD * m;
|
109
|
+
Data_Get_Struct(method, struct METHOD, m);
|
110
|
+
return METHOD_OCLASS(m);
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
* call-seq:
|
115
|
+
* method.attached_class => Class
|
116
|
+
*
|
117
|
+
* Given a Method, returns the Class it is attached to.
|
118
|
+
*/
|
119
|
+
static VALUE method_attached_class(VALUE method)
|
120
|
+
{
|
121
|
+
struct METHOD * m;
|
122
|
+
Data_Get_Struct(method, struct METHOD, m);
|
123
|
+
return CLASS_OF(m->recv);
|
124
|
+
}
|
125
|
+
|
126
|
+
/*
|
127
|
+
* call-seq:
|
128
|
+
* method.body => Node
|
129
|
+
*
|
130
|
+
* Given a Method, returns the Node for that Method's body. This can be
|
131
|
+
* used to directly copy one class's method to another (using
|
132
|
+
* add_method).
|
133
|
+
*/
|
134
|
+
static VALUE method_body(VALUE method)
|
135
|
+
{
|
136
|
+
struct METHOD * m;
|
137
|
+
if(rb_safe_level() >= 4)
|
138
|
+
{
|
139
|
+
/* no access to potentially sensitive data from the sandbox */
|
140
|
+
rb_raise(rb_eSecurityError, "Insecure: can't get method body");
|
141
|
+
}
|
142
|
+
Data_Get_Struct(method, struct METHOD, m);
|
143
|
+
return wrap_node(m->body);
|
144
|
+
}
|
145
|
+
|
146
|
+
/*
|
147
|
+
* call-seq:
|
148
|
+
* method.dump(limit) => String
|
149
|
+
*
|
150
|
+
* Dump a Method and the object to which it is bound to a String. The
|
151
|
+
* Method's class will not be dumped, only the name of the class.
|
152
|
+
*
|
153
|
+
* Unfortunately, this means that methods for anonymous classes can be
|
154
|
+
* dumped but cannot be loaded.
|
155
|
+
*/
|
156
|
+
static VALUE method_dump(VALUE self, VALUE limit)
|
157
|
+
{
|
158
|
+
struct METHOD * method;
|
159
|
+
VALUE arr;
|
160
|
+
|
161
|
+
if(rb_safe_level() >= 4)
|
162
|
+
{
|
163
|
+
/* no access to potentially sensitive data from the sandbox */
|
164
|
+
rb_raise(rb_eSecurityError, "Insecure: can't dump method");
|
165
|
+
}
|
166
|
+
|
167
|
+
arr = rb_ary_new();
|
168
|
+
Data_Get_Struct(self, struct METHOD, method);
|
169
|
+
rb_ary_push(arr, rb_mod_name(METHOD_OCLASS(method)));
|
170
|
+
rb_ary_push(arr, rb_mod_name(METHOD_RCLASS(method)));
|
171
|
+
if(rb_class_of(self) == rb_cUnboundMethod)
|
172
|
+
{
|
173
|
+
rb_ary_push(arr, Qnil);
|
174
|
+
}
|
175
|
+
else
|
176
|
+
{
|
177
|
+
rb_ary_push(arr, method->recv);
|
178
|
+
}
|
179
|
+
rb_ary_push(arr, ID2SYM(method->id));
|
180
|
+
rb_ary_push(arr, ID2SYM(method->oid));
|
181
|
+
rb_ary_push(arr, method_body(self));
|
182
|
+
|
183
|
+
return marshal_dump(arr, limit);
|
184
|
+
}
|
185
|
+
|
186
|
+
/*
|
187
|
+
* call-seq:
|
188
|
+
* Method.load(String) => Method
|
189
|
+
*
|
190
|
+
* Load a Method from a String.
|
191
|
+
*/
|
192
|
+
static VALUE method_load(VALUE klass, VALUE str)
|
193
|
+
{
|
194
|
+
struct METHOD * method;
|
195
|
+
VALUE rarr = marshal_load(str);
|
196
|
+
VALUE * arr;
|
197
|
+
NODE * n;
|
198
|
+
VALUE retval;
|
199
|
+
|
200
|
+
if( rb_safe_level() >= 4
|
201
|
+
|| (rb_safe_level() >= 1 && OBJ_TAINTED(str)))
|
202
|
+
{
|
203
|
+
/* no playing with knives in the sandbox */
|
204
|
+
rb_raise(rb_eSecurityError, "Insecure: can't load method");
|
205
|
+
}
|
206
|
+
|
207
|
+
Check_Type(rarr, T_ARRAY);
|
208
|
+
if(RARRAY_LEN(rarr) != 6)
|
209
|
+
{
|
210
|
+
rb_raise(rb_eArgError, "corrupt data");
|
211
|
+
}
|
212
|
+
|
213
|
+
/* Create a METHOD object -- doesn't matter which method we use */
|
214
|
+
retval = rb_funcall(
|
215
|
+
rb_cObject, rb_intern("method"), 1, ID2SYM(rb_intern("__id__")));
|
216
|
+
Data_Get_Struct(retval, struct METHOD, method);
|
217
|
+
arr = RARRAY_PTR(rarr);
|
218
|
+
METHOD_OCLASS(method) =
|
219
|
+
rb_funcall(lookup_module_proc, rb_intern("call"), 1, arr[0]);
|
220
|
+
METHOD_RCLASS(method) =
|
221
|
+
rb_funcall(lookup_module_proc, rb_intern("call"), 1, arr[1]);
|
222
|
+
method->recv = arr[2];
|
223
|
+
method->id = SYM2ID(arr[3]);
|
224
|
+
method->oid = SYM2ID(arr[4]);
|
225
|
+
Data_Get_Struct(arr[5], NODE, n);
|
226
|
+
method->body = n;
|
227
|
+
|
228
|
+
if(klass == rb_cUnboundMethod)
|
229
|
+
{
|
230
|
+
retval = rb_funcall(retval, rb_intern("unbind"), 0);
|
231
|
+
}
|
232
|
+
|
233
|
+
return retval;
|
234
|
+
}
|
235
|
+
|
236
|
+
void Init_method(void)
|
237
|
+
{
|
238
|
+
rb_require("internal/node");
|
239
|
+
|
240
|
+
rb_mMarshal = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
241
|
+
|
242
|
+
/* For rdoc: rb_cMethod = rb_define_class("Method", rb_cObject) */
|
243
|
+
#ifndef HAVE_RB_CMETHOD
|
244
|
+
rb_cMethod = rb_const_get(rb_cObject, rb_intern("Method"));
|
245
|
+
#endif
|
246
|
+
rb_define_method(rb_cMethod, "receiver", method_receiver, 0);
|
247
|
+
|
248
|
+
/* For rdoc: rb_cUnboundMethod = rb_define_class("UnboundMethod", rb_cObject) */
|
249
|
+
#ifndef HAVE_RB_CUNBOUNDMETHOD
|
250
|
+
rb_cUnboundMethod = rb_const_get(rb_cObject, rb_intern("UnboundMethod"));
|
251
|
+
#endif
|
252
|
+
rb_define_method(rb_cMethod, "origin_class", method_origin_class, 0);
|
253
|
+
rb_define_method(rb_cUnboundMethod, "origin_class", method_origin_class, 0);
|
254
|
+
rb_define_method(rb_cMethod, "attached_class", method_attached_class, 0);
|
255
|
+
rb_define_method(rb_cMethod, "method_id", method_id, 0);
|
256
|
+
rb_define_method(rb_cUnboundMethod, "method_id", method_id, 0);
|
257
|
+
rb_define_method(rb_cMethod, "method_oid", method_oid, 0);
|
258
|
+
rb_define_method(rb_cUnboundMethod, "method_oid", method_oid, 0);
|
259
|
+
rb_define_method(rb_cMethod, "body", method_body, 0);
|
260
|
+
rb_define_method(rb_cUnboundMethod, "body", method_body, 0);
|
261
|
+
rb_define_method(rb_cMethod, "_dump", method_dump, 1);
|
262
|
+
rb_define_method(rb_cUnboundMethod, "_dump", method_dump, 1);
|
263
|
+
rb_define_singleton_method(rb_cMethod, "_load", method_load, 1);
|
264
|
+
rb_define_singleton_method(rb_cUnboundMethod, "_load", method_load, 1);
|
265
|
+
|
266
|
+
lookup_module_proc = rb_eval_string(lookup_module_str);
|
267
|
+
rb_global_variable(&lookup_module_proc);
|
268
|
+
}
|
269
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#ifndef ruby_internal_method__h_
|
2
|
+
#define ruby_internal_method__h_
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
|
6
|
+
#include "internal/node/ruby_internal_node.h"
|
7
|
+
|
8
|
+
#ruby <<END
|
9
|
+
$: << '../..'
|
10
|
+
require 'ruby_source_dir'
|
11
|
+
proc_c_location = "#{RUBY_SOURCE_DIR}/proc.c"
|
12
|
+
eval_c_location = "#{RUBY_SOURCE_DIR}/eval.c"
|
13
|
+
|
14
|
+
oclass_member = "klass"
|
15
|
+
rclass_member = "klass"
|
16
|
+
|
17
|
+
[ proc_c_location, eval_c_location ].each do |file|
|
18
|
+
next if not File.exist?(file)
|
19
|
+
|
20
|
+
File.open(file) do |eval_c|
|
21
|
+
write = false
|
22
|
+
stopwrite = false
|
23
|
+
while (line = eval_c.gets) != nil do
|
24
|
+
case line
|
25
|
+
when /^struct (METHOD)/
|
26
|
+
write = true
|
27
|
+
stopwrite = false
|
28
|
+
when /^\}/
|
29
|
+
stopwrite = true
|
30
|
+
when /VALUE oclass/
|
31
|
+
oclass_member = "oclass"
|
32
|
+
when /VALUE oklass/
|
33
|
+
oklass_member = "oklass"
|
34
|
+
when /VALUE (klass, )?rclass/
|
35
|
+
rclass_member = "rclass"
|
36
|
+
when /VALUE (klass, )?rklass/
|
37
|
+
rclass_member = "rklass"
|
38
|
+
end
|
39
|
+
puts line if write
|
40
|
+
if write and stopwrite then
|
41
|
+
stopwrite = false
|
42
|
+
write = false
|
43
|
+
puts ''
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
puts <<-END
|
50
|
+
#define METHOD_OCLASS(m) m->#{oclass_member}
|
51
|
+
#define METHOD_RCLASS(m) m->#{rclass_member}
|
52
|
+
END
|
53
|
+
|
54
|
+
nil
|
55
|
+
END
|
56
|
+
|
57
|
+
#endif
|
58
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#include "classpath.h"
|
2
|
+
|
3
|
+
#ruby <<END
|
4
|
+
$: << '../..'
|
5
|
+
require 'ruby_source_dir'
|
6
|
+
|
7
|
+
marshal_c_location = "#{RUBY_SOURCE_DIR}/marshal.c"
|
8
|
+
File.open(marshal_c_location) do |marshal_c|
|
9
|
+
write = false
|
10
|
+
stopwrite = false
|
11
|
+
while (line = marshal_c.gets) != nil do
|
12
|
+
case line
|
13
|
+
when /^(path2class|path2module|class2path)/
|
14
|
+
puts "VALUE" if not write
|
15
|
+
write = true
|
16
|
+
stopwrite = false
|
17
|
+
when /^\}/
|
18
|
+
stopwrite = true if write
|
19
|
+
end
|
20
|
+
puts line if write
|
21
|
+
if stopwrite then
|
22
|
+
stopwrite = false
|
23
|
+
write = false
|
24
|
+
puts ''
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
END
|
29
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#ifndef CLASSPATH_H
|
2
|
+
#define CLASSPATH_H
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
|
6
|
+
#ruby <<END
|
7
|
+
$: << '../..'
|
8
|
+
require 'ruby_source_dir'
|
9
|
+
|
10
|
+
defn = nil
|
11
|
+
marshal_c_location = "#{RUBY_SOURCE_DIR}/marshal.c"
|
12
|
+
File.open(marshal_c_location) do |marshal_c|
|
13
|
+
write = false
|
14
|
+
while (line = marshal_c.gets) != nil do
|
15
|
+
case line
|
16
|
+
when /^(path2class|path2module|class2path)/
|
17
|
+
record_defn = true
|
18
|
+
defn = []
|
19
|
+
when /^\{/
|
20
|
+
if record_defn then
|
21
|
+
record_defn = false
|
22
|
+
puts "VALUE #{defn[0].sub(/\(.*/, '')}("
|
23
|
+
vars = defn[1..-1].map { |d| d.sub(/;.*/, '') }
|
24
|
+
puts vars.join(",\n")
|
25
|
+
puts ");"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
if record_defn then
|
29
|
+
defn << line.chomp
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
END
|
34
|
+
|
35
|
+
#endif
|
36
|
+
|