├── .cvsignore ├── .gitignore ├── COPYING ├── LGPL ├── LICENSE ├── README.rdoc ├── Rakefile ├── TODO ├── bin ├── ruby-internal-node-dump └── ruby-internal-obfuscate ├── example ├── README ├── simple_client.rb ├── simple_server.rb ├── triangle_client.rb └── triangle_server.rb ├── ext ├── .gitignore ├── cached │ ├── ruby-1.8.4 │ │ └── internal │ │ │ ├── binding │ │ │ └── block.h │ │ │ ├── method │ │ │ └── internal_method.h │ │ │ ├── module │ │ │ ├── classpath.c │ │ │ ├── classpath.h │ │ │ └── getcfp.h │ │ │ ├── node │ │ │ ├── block.h │ │ │ ├── global_entry.h │ │ │ ├── node_type_descrip.c │ │ │ ├── nodeinfo.c │ │ │ └── nodeinfo.h │ │ │ ├── proc │ │ │ └── block.h │ │ │ ├── tag │ │ │ └── tag.h │ │ │ └── vm │ │ │ ├── instruction │ │ │ ├── insns_info.c │ │ │ └── insns_info.h │ │ │ └── iseq │ │ │ ├── insns_info.inc │ │ │ └── iseq_load.inc │ ├── ruby-1.8.5 │ │ └── internal │ │ │ ├── binding │ │ │ └── block.h │ │ │ ├── method │ │ │ └── internal_method.h │ │ │ ├── module │ │ │ ├── classpath.c │ │ │ ├── classpath.h │ │ │ └── getcfp.h │ │ │ ├── node │ │ │ ├── block.h │ │ │ ├── global_entry.h │ │ │ ├── node_type_descrip.c │ │ │ ├── nodeinfo.c │ │ │ └── nodeinfo.h │ │ │ ├── proc │ │ │ └── block.h │ │ │ ├── tag │ │ │ └── tag.h │ │ │ └── vm │ │ │ ├── instruction │ │ │ ├── insns_info.c │ │ │ └── insns_info.h │ │ │ └── iseq │ │ │ ├── insns_info.inc │ │ │ └── iseq_load.inc │ ├── ruby-1.8.6 │ │ └── internal │ │ │ ├── binding │ │ │ └── block.h │ │ │ ├── method │ │ │ └── internal_method.h │ │ │ ├── module │ │ │ ├── classpath.c │ │ │ ├── classpath.h │ │ │ └── getcfp.h │ │ │ ├── node │ │ │ ├── block.h │ │ │ ├── global_entry.h │ │ │ ├── node_type_descrip.c │ │ │ ├── nodeinfo.c │ │ │ └── nodeinfo.h │ │ │ ├── proc │ │ │ └── block.h │ │ │ ├── tag │ │ │ └── tag.h │ │ │ └── vm │ │ │ ├── instruction │ │ │ ├── insns_info.c │ │ │ └── insns_info.h │ │ │ └── iseq │ │ │ ├── insns_info.inc │ │ │ └── iseq_load.inc │ ├── ruby-1.8.7 │ │ └── internal │ │ │ ├── binding │ │ │ └── block.h │ │ │ ├── method │ │ │ └── internal_method.h │ │ │ ├── module │ │ │ ├── classpath.c │ │ │ ├── classpath.h │ │ │ └── getcfp.h │ │ │ ├── node │ │ │ ├── block.h │ │ │ ├── global_entry.h │ │ │ ├── node_type_descrip.c │ │ │ ├── nodeinfo.c │ │ │ └── nodeinfo.h │ │ │ ├── proc │ │ │ └── block.h │ │ │ ├── tag │ │ │ └── tag.h │ │ │ └── vm │ │ │ ├── instruction │ │ │ ├── insns_info.c │ │ │ └── insns_info.h │ │ │ └── iseq │ │ │ ├── insns_info.inc │ │ │ └── iseq_load.inc │ ├── ruby-1.9.1 │ │ └── internal │ │ │ ├── binding │ │ │ └── block.h │ │ │ ├── method │ │ │ └── internal_method.h │ │ │ ├── module │ │ │ ├── classpath.c │ │ │ ├── classpath.h │ │ │ └── getcfp.h │ │ │ ├── node │ │ │ ├── block.h │ │ │ ├── global_entry.h │ │ │ ├── node_type_descrip.c │ │ │ ├── nodeinfo.c │ │ │ └── nodeinfo.h │ │ │ ├── proc │ │ │ └── block.h │ │ │ ├── tag │ │ │ └── tag.h │ │ │ ├── vm │ │ │ ├── instruction │ │ │ │ ├── insns_info.c │ │ │ │ └── insns_info.h │ │ │ └── iseq │ │ │ │ ├── insns_info.inc │ │ │ │ └── iseq_load.inc │ │ │ └── yarv-headers │ │ │ ├── debug.h │ │ │ ├── dln.h │ │ │ ├── encdb.h │ │ │ ├── eval_intern.h │ │ │ ├── gc.h │ │ │ ├── id.h │ │ │ ├── iseq.h │ │ │ ├── node.h │ │ │ ├── parse.h │ │ │ ├── regenc.h │ │ │ ├── regint.h │ │ │ ├── regparse.h │ │ │ ├── revision.h │ │ │ ├── thread_pthread.h │ │ │ ├── thread_win32.h │ │ │ ├── transcode_data.h │ │ │ ├── transdb.h │ │ │ ├── version.h │ │ │ ├── vm_core.h │ │ │ ├── vm_exec.h │ │ │ ├── vm_insnhelper.h │ │ │ └── vm_opts.h │ ├── ruby-1.9.2 │ │ └── internal │ │ │ ├── binding │ │ │ └── block.h │ │ │ ├── method │ │ │ └── internal_method.h │ │ │ ├── module │ │ │ ├── classpath.c │ │ │ ├── classpath.h │ │ │ └── getcfp.h │ │ │ ├── node │ │ │ ├── block.h │ │ │ ├── global_entry.h │ │ │ ├── node_type_descrip.c │ │ │ ├── nodeinfo.c │ │ │ └── nodeinfo.h │ │ │ ├── proc │ │ │ └── block.h │ │ │ ├── tag │ │ │ └── tag.h │ │ │ ├── vm │ │ │ ├── instruction │ │ │ │ ├── insns_info.c │ │ │ │ └── insns_info.h │ │ │ └── iseq │ │ │ │ ├── insns_info.inc │ │ │ │ └── iseq_load.inc │ │ │ └── yarv-headers │ │ │ ├── debug.h │ │ │ ├── dln.h │ │ │ ├── encdb.h │ │ │ ├── eval_intern.h │ │ │ ├── gc.h │ │ │ ├── id.h │ │ │ ├── iseq.h │ │ │ ├── method.h │ │ │ ├── node.h │ │ │ ├── parse.h │ │ │ ├── regenc.h │ │ │ ├── regint.h │ │ │ ├── regparse.h │ │ │ ├── revision.h │ │ │ ├── thread_pthread.h │ │ │ ├── thread_win32.h │ │ │ ├── timev.h │ │ │ ├── transcode_data.h │ │ │ ├── transdb.h │ │ │ ├── version.h │ │ │ ├── vm_core.h │ │ │ ├── vm_exec.h │ │ │ ├── vm_insnhelper.h │ │ │ └── vm_opts.h │ └── ruby-1.9.3 │ │ └── internal │ │ ├── binding │ │ └── block.h │ │ ├── method │ │ └── internal_method.h │ │ ├── module │ │ ├── classpath.c │ │ ├── classpath.h │ │ └── getcfp.h │ │ ├── node │ │ ├── block.h │ │ ├── global_entry.h │ │ ├── node_type_descrip.c │ │ ├── nodeinfo.c │ │ └── nodeinfo.h │ │ ├── proc │ │ └── block.h │ │ ├── tag │ │ └── tag.h │ │ ├── vm │ │ ├── instruction │ │ │ ├── insns_info.c │ │ │ └── insns_info.h │ │ └── iseq │ │ │ ├── insns_info.inc │ │ │ └── iseq_load.inc │ │ └── yarv-headers │ │ ├── addr2line.h │ │ ├── atomic.h │ │ ├── constant.h │ │ ├── debug.h │ │ ├── dln.h │ │ ├── encdb.h │ │ ├── eval_intern.h │ │ ├── gc.h │ │ ├── id.h │ │ ├── internal.h │ │ ├── iseq.h │ │ ├── method.h │ │ ├── node.h │ │ ├── parse.h │ │ ├── regenc.h │ │ ├── regint.h │ │ ├── regparse.h │ │ ├── revision.h │ │ ├── thread_pthread.h │ │ ├── thread_win32.h │ │ ├── timev.h │ │ ├── transcode_data.h │ │ ├── transdb.h │ │ ├── version.h │ │ ├── vm_core.h │ │ ├── vm_exec.h │ │ ├── vm_insnhelper.h │ │ └── vm_opts.h ├── generate_cached.rb ├── generate_cached.sh ├── internal │ ├── .gitignore │ ├── binding │ │ ├── .gitignore │ │ ├── binding.c │ │ ├── block.h.rpp │ │ └── extconf.rb │ ├── method │ │ ├── .gitignore │ │ ├── extconf.rb │ │ ├── internal_method.h.rpp │ │ └── method.c │ ├── module │ │ ├── .gitignore │ │ ├── classpath.c.rpp │ │ ├── classpath.h.rpp │ │ ├── extconf.rb │ │ ├── getcfp.h.rpp │ │ ├── module.c │ │ └── module.h │ ├── node │ │ ├── .gitignore │ │ ├── block.h.rpp │ │ ├── builtins.h │ │ ├── extconf.rb │ │ ├── global_entry.h.rpp │ │ ├── node.c │ │ ├── node_type_descrip.c.rpp │ │ ├── node_type_descrip.h │ │ ├── node_type_descrip.rb │ │ ├── nodeinfo.c.rpp │ │ ├── nodeinfo.h.rpp │ │ ├── nodes.rb │ │ ├── nodes.yaml │ │ ├── read_node_h.rb │ │ └── ruby_internal_node.h │ ├── noex │ │ ├── extconf.rb │ │ └── noex.c │ ├── object │ │ ├── extconf.rb │ │ └── object.c │ ├── proc │ │ ├── .gitignore │ │ ├── block.h.rpp │ │ ├── extconf.rb │ │ └── proc.c │ ├── tag │ │ ├── .gitignore │ │ ├── extconf.rb │ │ ├── tag.c │ │ └── tag.h.rpp │ ├── thread │ │ ├── extconf.rb │ │ └── thread.c │ └── vm │ │ ├── constants │ │ ├── constants.c │ │ └── extconf.rb │ │ ├── control_frame │ │ ├── control_frame.c │ │ ├── control_frame.h │ │ └── extconf.rb │ │ ├── extconf.rb │ │ ├── inline_cache │ │ ├── extconf.rb │ │ └── inline_cache.c │ │ ├── instruction │ │ ├── .gitignore │ │ ├── extconf.rb │ │ ├── insns_info.c.rpp │ │ ├── insns_info.h.rpp │ │ ├── instruction.c │ │ └── instruction.h │ │ ├── iseq │ │ ├── .gitignore │ │ ├── extconf.rb │ │ ├── insns_info.inc.rpp │ │ ├── internal_iseq.h │ │ ├── iseq.c │ │ └── iseq_load.inc.rpp │ │ └── vm.c ├── mkmf-ruby-internal.rb └── ruby_source_dir.rb ├── generate_rdoc.rb ├── lib └── internal │ ├── binding.rb │ ├── classtree.rb │ ├── debug.rb │ ├── method.rb │ ├── module.rb │ ├── node.rb │ ├── node │ ├── dump.rb │ ├── obfusc.rb │ ├── pp.rb │ └── to_a.rb │ ├── noex.rb │ ├── obfusc.rb │ ├── object.rb │ ├── proc.rb │ ├── tag.rb │ ├── thread.rb │ ├── vm.rb │ └── vm │ ├── constants.rb │ ├── control_frame.rb │ ├── inline_cache.rb │ ├── instruction.rb │ └── iseq.rb ├── metaconfig ├── post-config.rb ├── post-install.rb ├── post-setup.rb ├── pre-config.rb ├── pre-install.rb ├── pre-setup.rb ├── publish_rdoc.rb ├── ruby-internal.gemspec ├── ruby.supp ├── run_tests.rb ├── sample ├── dump_class.rb └── irbrc ├── setup.rb └── test ├── node_samples.rb ├── test_dump_class.rb ├── test_dump_method.rb ├── test_dump_proc.rb ├── test_helpers.rb ├── test_method.rb ├── test_module.rb ├── test_node.rb ├── test_proc.rb └── test_thread.rb /.cvsignore: -------------------------------------------------------------------------------- 1 | doc 2 | config.save 3 | InstalledFiles 4 | nodewrap-*.gem 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *~ 3 | .config 4 | InstalledFiles 5 | config.log 6 | ruby-internal-*.gem 7 | doc 8 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | The Ruby License (http://www.ruby-lang.org/en/LICENSE.txt) 2 | ---------------------------------------------------------- 3 | 4 | You may redistribute this software and/or modify it under either the terms of 5 | the GPL (see the file GPL), or the conditions below: 6 | 7 | 1. You may make and give away verbatim copies of the source form of the 8 | software without restriction, provided that you duplicate all of the 9 | original copyright notices and associated disclaimers. 10 | 11 | 2. You may modify your copy of the software in any way, provided that 12 | you do at least ONE of the following: 13 | 14 | a) place your modifications in the Public Domain or otherwise 15 | make them Freely Available, such as by posting said 16 | modifications to Usenet or an equivalent medium, or by allowing 17 | the author to include your modifications in the software. 18 | 19 | b) use the modified software only within your corporation or 20 | organization. 21 | 22 | c) rename any non-standard executables so the names do not conflict 23 | with standard executables, which must also be provided. 24 | 25 | d) make other distribution arrangements with the author. 26 | 27 | 3. You may distribute the software in object code or executable 28 | form, provided that you do at least ONE of the following: 29 | 30 | a) distribute the executables and library files of the software, 31 | together with instructions (in the manual page or equivalent) 32 | on where to get the original distribution. 33 | 34 | b) accompany the distribution with the machine-readable source of 35 | the software. 36 | 37 | c) give non-standard executables non-standard names, with 38 | instructions on where to get the original software distribution. 39 | 40 | d) make other distribution arrangements with the author. 41 | 42 | 4. You may modify and include the part of the software into any other 43 | software (possibly commercial). But some files in the distribution 44 | are not written by the author, so that they are not under these terms. 45 | 46 | For the list of those files and their copying conditions, see the 47 | file LEGAL. 48 | 49 | 5. The scripts and library files supplied as input to or produced as 50 | output from the software do not automatically fall under the 51 | copyright of the software, but belong to whomever generated them, 52 | and may be sold commercially, and may be aggregated with this 53 | software. 54 | 55 | 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR 56 | IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 57 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 58 | PURPOSE. 59 | 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Ruby/Internal 0.5 2 | Copyright (C) 2008 Paul Brannan 3 | 4 | You may distribute this software under the same terms as Ruby (see the file 5 | COPYING that was distributed with this library). 6 | 7 | All the files in this distribution are covered under Ruby's license, 8 | except install.rb, which is covered under the LGPL. 9 | 10 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | 3 | task :clean do 4 | ruby "setup.rb clean" 5 | end 6 | 7 | task :config do 8 | ruby "setup.rb config --without-tests" 9 | end 10 | 11 | task :setup do 12 | ruby "setup.rb setup" 13 | end 14 | 15 | task :install do 16 | ruby "setup.rb install" 17 | end 18 | 19 | task :default => [ :config, :setup ] 20 | 21 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * Clean up the code 2 | - Refactor module_load; code to create a subclass and code to attach 3 | an arbitrary class as a metaclass should be factored out 4 | - Split up unrelated code into separate source files 5 | * Write more test cases 6 | * Shouldn't be able to dump classes with non-default allocation 7 | functions; write a test for this 8 | * Test for dumping a metaclass that has a metaclass 9 | * Should real_superclass use rb_class_real() when including modules? 10 | -------------------------------------------------------------------------------- /bin/ruby-internal-node-dump: -------------------------------------------------------------------------------- 1 | #! /home/cout/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 2 | 3 | require 'pp' 4 | require 'internal/node/pp' 5 | require 'optparse' 6 | 7 | dash_e = [] 8 | 9 | args = ARGV 10 | 11 | opts = OptionParser.new do |opts| 12 | opts.banner = "Usage: #{$0} [switches] [--] [programfile] [arguments]" 13 | opts.summary_width = 15 14 | opts.summary_indent = ' ' 15 | 16 | opts.on( 17 | "-e line", 18 | "one line of script. Several -e's allowed. Omit [programfile]") do |line| 19 | dash_e << line 20 | end 21 | 22 | opts.order!(args) do |arg| 23 | args.unshift arg 24 | opts.terminate 25 | end 26 | end 27 | 28 | if dash_e.size > 0 then 29 | str = dash_e.join("\n") 30 | else 31 | filename = ARGV[0] 32 | str = File.read(filename) 33 | end 34 | 35 | node = Node.compile_string(str) 36 | 37 | pp node 38 | 39 | -------------------------------------------------------------------------------- /bin/ruby-internal-obfuscate: -------------------------------------------------------------------------------- 1 | #! /home/cout/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 2 | 3 | require 'internal/node/obfusc' 4 | 5 | filename = ARGV[0] 6 | 7 | if not filename then 8 | puts "Usage: #{$0} " 9 | exit 1 10 | fi 11 | 12 | str = File.read(filename) 13 | 14 | node = Node.compile_string(str) 15 | 16 | # TODO: Should the whole program be obfuscated or just this module? 17 | str = node.obfusc() 18 | 19 | puts str 20 | 21 | -------------------------------------------------------------------------------- /example/README: -------------------------------------------------------------------------------- 1 | To use these programs, install nodewrap, then: 2 | 3 | ruby simple_server.rb | ruby simple_client.rb 4 | ruby triangle_server.rb | ruby triangle_client.rb 5 | 6 | -------------------------------------------------------------------------------- /example/simple_client.rb: -------------------------------------------------------------------------------- 1 | require 'nodewrap' 2 | 3 | n = Marshal.load($stdin) 4 | 5 | Foo = Class.new(Object) 6 | Foo.instance_eval do 7 | add_method(:foo, n, 0) 8 | end 9 | 10 | f = Foo.new 11 | f.foo 12 | 13 | -------------------------------------------------------------------------------- /example/simple_server.rb: -------------------------------------------------------------------------------- 1 | require 'nodewrap' 2 | 3 | def foo 4 | puts 'foo!' 5 | end 6 | 7 | m = Object.method(:foo) 8 | n = m.body 9 | Marshal.dump(n, $stdout) 10 | $stdout.flush 11 | 12 | -------------------------------------------------------------------------------- /example/triangle_client.rb: -------------------------------------------------------------------------------- 1 | require 'nodewrap' 2 | 3 | Marshal.load($stdin) 4 | 5 | t = M::Triangle.new(3, 4, 5) 6 | puts "The area of #{t} is: #{t.area}" 7 | 8 | -------------------------------------------------------------------------------- /example/triangle_server.rb: -------------------------------------------------------------------------------- 1 | require 'nodewrap' 2 | 3 | module M 4 | class Triangle 5 | def initialize(a, b, c) 6 | @a = a 7 | @b = b 8 | @c = c 9 | end 10 | 11 | def area 12 | s = (@a + @b + @c) / 2.0 13 | return Math.sqrt(s*(s-@a)*(s-@b)*(s-@c)) 14 | end 15 | 16 | def to_s 17 | return "a #{@a}-#{@b}-#{@c} triangle" 18 | end 19 | end 20 | end 21 | 22 | Marshal.dump(M, $stdout) 23 | $stdout.flush 24 | 25 | -------------------------------------------------------------------------------- /ext/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | mkmf.log 3 | *.o 4 | *.so 5 | core 6 | .*.swp 7 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/binding/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/method/internal_method.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_method__h_ 2 | #define ruby_internal_method__h_ 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | struct METHOD { 21 | VALUE klass, rklass; 22 | VALUE recv; 23 | ID id, oid; 24 | int safe_level; 25 | NODE *body; 26 | }; 27 | 28 | #define METHOD_OCLASS(m) m->klass 29 | #define METHOD_RCLASS(m) m->rklass 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/module/classpath.c: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | VALUE 4 | class2path(klass) 5 | VALUE klass; 6 | { 7 | VALUE path = rb_class_path(klass); 8 | char *n = RSTRING(path)->ptr; 9 | 10 | if (n[0] == '#') { 11 | rb_raise(rb_eTypeError, "can't dump anonymous %s %s", 12 | (TYPE(klass) == T_CLASS ? "class" : "module"), 13 | n); 14 | } 15 | if (rb_path2class(n) != rb_class_real(klass)) { 16 | rb_raise(rb_eTypeError, "%s can't be referred", n); 17 | } 18 | return path; 19 | } 20 | 21 | VALUE 22 | path2class(path) 23 | char *path; 24 | { 25 | VALUE v = rb_path2class(path); 26 | 27 | if (TYPE(v) != T_CLASS) { 28 | rb_raise(rb_eArgError, "%s does not refer class", path); 29 | } 30 | return v; 31 | } 32 | 33 | VALUE 34 | path2module(path) 35 | char *path; 36 | { 37 | VALUE v = rb_path2class(path); 38 | 39 | if (TYPE(v) != T_MODULE) { 40 | rb_raise(rb_eArgError, "%s does not refer module", path); 41 | } 42 | return v; 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/module/classpath.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSPATH_H 2 | #define CLASSPATH_H 3 | 4 | #include "ruby.h" 5 | 6 | VALUE class2path( 7 | VALUE klass 8 | ); 9 | VALUE path2class( 10 | char *path 11 | ); 12 | VALUE path2module( 13 | char *path 14 | ); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/module/getcfp.h: -------------------------------------------------------------------------------- 1 | #ifndef getcfp__h 2 | #define getcfp__h 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/node/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/node/global_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | struct trace_var { 7 | int removed; 8 | void (*func)(); 9 | VALUE data; 10 | struct trace_var *next; 11 | }; 12 | struct global_variable { 13 | int counter; 14 | void *data; 15 | VALUE (*getter)(); 16 | void (*setter)(); 17 | void (*marker)(); 18 | int block_trace; 19 | struct trace_var *trace; 20 | }; 21 | struct global_entry { 22 | struct global_variable *var; 23 | ID id; 24 | }; 25 | static VALUE undef_getter(); 26 | static void undef_setter(); 27 | static void undef_marker(); 28 | static VALUE val_getter(); 29 | static void val_setter(); 30 | static void val_marker(); 31 | struct global_entry* 32 | rb_global_entry(id) 33 | ID id; 34 | { 35 | struct global_entry *entry; 36 | 37 | if (!st_lookup(rb_global_tbl, id, (st_data_t *)&entry)) { 38 | struct global_variable *var; 39 | entry = ALLOC(struct global_entry); 40 | var = ALLOC(struct global_variable); 41 | entry->id = id; 42 | entry->var = var; 43 | var->counter = 1; 44 | var->data = 0; 45 | var->getter = undef_getter; 46 | var->setter = undef_setter; 47 | var->marker = undef_marker; 48 | 49 | var->block_trace = 0; 50 | var->trace = 0; 51 | st_add_direct(rb_global_tbl, id, (st_data_t)entry); 52 | } 53 | return entry; 54 | } 55 | static VALUE 56 | undef_getter(id) 57 | ID id; 58 | { 59 | rb_warning("global variable `%s' not initialized", rb_id2name(id)); 60 | 61 | return Qnil; 62 | } 63 | static void 64 | undef_setter(val, id, data, var) 65 | VALUE val; 66 | ID id; 67 | void *data; 68 | struct global_variable *var; 69 | { 70 | var->getter = val_getter; 71 | var->setter = val_setter; 72 | var->marker = val_marker; 73 | 74 | var->data = (void*)val; 75 | } 76 | static void 77 | undef_marker() 78 | { 79 | } 80 | static VALUE 81 | val_getter(id, val) 82 | ID id; 83 | VALUE val; 84 | { 85 | return val; 86 | } 87 | static void 88 | val_setter(val, id, data, var) 89 | VALUE val; 90 | ID id; 91 | void *data; 92 | struct global_variable *var; 93 | { 94 | var->data = (void*)val; 95 | } 96 | static void 97 | val_marker(data) 98 | VALUE data; 99 | { 100 | if (data) rb_gc_mark_maybe(data); 101 | } 102 | 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/node/nodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | NEN_1ST, 12 | NEN_2ND, 13 | NEN_AID, 14 | NEN_ALEN, 15 | NEN_ARGC, 16 | NEN_ARGS, 17 | NEN_BEG, 18 | NEN_BODY, 19 | NEN_CFLAG, 20 | NEN_CFNC, 21 | NEN_CLSS, 22 | NEN_CNT, 23 | NEN_COND, 24 | NEN_CPATH, 25 | NEN_CVAL, 26 | NEN_DEFN, 27 | NEN_ELSE, 28 | NEN_END, 29 | NEN_ENSR, 30 | NEN_ENTRY, 31 | NEN_FRML, 32 | NEN_HEAD, 33 | NEN_IBDY, 34 | NEN_ITER, 35 | NEN_LIT, 36 | NEN_MID, 37 | NEN_MODL, 38 | NEN_NEW, 39 | NEN_NEXT, 40 | NEN_NOEX, 41 | NEN_NTH, 42 | NEN_OLD, 43 | NEN_OPT, 44 | NEN_ORIG, 45 | NEN_RECV, 46 | NEN_RESQ, 47 | NEN_REST, 48 | NEN_RVAL, 49 | NEN_STATE, 50 | NEN_STTS, 51 | NEN_SUPER, 52 | NEN_TAG, 53 | NEN_TBL, 54 | NEN_TVAL, 55 | NEN_VALUE, 56 | NEN_VAR, 57 | NEN_VID, 58 | }; 59 | 60 | VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash); 61 | void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash); 62 | VALUE node_s_members(VALUE klass); 63 | void define_node_subclass_methods(); 64 | 65 | #define NODE_OP_ASGN2_ARG NODE_LAST + 1 66 | #define NUM_NODE_TYPE_DESCRIPS NODE_OP_ASGN2_ARG + 1 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/proc/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/tag/tag.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | #define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq) 8 | #define TAG_RETURN 0x1 9 | #define TAG_BREAK 0x2 10 | #define TAG_NEXT 0x3 11 | #define TAG_RETRY 0x4 12 | #define TAG_REDO 0x5 13 | #define TAG_RAISE 0x6 14 | #define TAG_THROW 0x7 15 | #define TAG_FATAL 0x8 16 | #define TAG_MASK 0xf 17 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/vm/instruction/insns_info.c: -------------------------------------------------------------------------------- 1 | #include "insns_info.h" 2 | 3 | #ifdef RUBY_VM 4 | 5 | #include "iseq.h" 6 | #include "vm_core.h" 7 | 8 | 9 | VALUE instruction_class[VM_INSTRUCTION_SIZE]; 10 | 11 | static ID operand_type_name_of(int operand_type) 12 | { 13 | char const * retval = "????"; 14 | 15 | switch(operand_type) 16 | { 17 | case TS_ISEQ: retval = "iseq"; break; 18 | case TS_GENTRY: retval = "gentry"; break; 19 | case TS_OFFSET: retval = "operand"; break; 20 | case TS_DINDEX: retval = "dindex"; break; 21 | case TS_VARIABLE: retval = "variable"; break; 22 | case TS_CDHASH: retval = "cdhash"; break; 23 | case TS_IC: retval = "ic"; break; 24 | case TS_ID: retval = "id"; break; 25 | case TS_VALUE: retval = "value"; break; 26 | case TS_LINDEX: retval = "lindex"; break; 27 | case TS_NUM: retval = "num"; break; 28 | } 29 | 30 | return rb_intern(retval); 31 | } 32 | 33 | 34 | void define_instruction_subclasses(VALUE rb_cInstruction) 35 | { 36 | /* For rdoc: rb_cVM = rb_define_class("VM", rb_cObject); */ 37 | /* For rdoc: rb_cInstruction = rb_define_class_under(rb_cVM, "Instruction", rb_cObject); */ 38 | 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/vm/instruction/insns_info.h: -------------------------------------------------------------------------------- 1 | #ifndef insns_info__h_ 2 | #define insns_info__h_ 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | #ifdef HAVE_VM_H 11 | #include "vm.h" 12 | #endif 13 | 14 | 15 | extern VALUE instruction_class[VM_INSTRUCTION_SIZE]; 16 | void define_instruction_subclasses(VALUE rb_cInstruction); 17 | 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/vm/iseq/insns_info.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_insns_info__inc_ 2 | #define ruby_internal_insns_info__inc_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.4/internal/vm/iseq/iseq_load.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_iseq_load__inc_ 2 | #define ruby_internal_iseq_load__inc_ 3 | 4 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 5 | 6 | static rb_data_type_t const * p_iseq_data_type; 7 | 8 | static void init_iseq_data_type() 9 | { 10 | rb_proc_t * p; 11 | VALUE body; 12 | 13 | VALUE binding = rb_binding_new(); 14 | VALUE new_proc = rb_funcall( 15 | rb_cObject, rb_intern("eval"), 2, rb_str_new2("proc { }"), binding); 16 | GetProcPtr(new_proc, p); 17 | body = p->block.iseq->self; 18 | 19 | p_iseq_data_type = RTYPEDDATA_TYPE(body); 20 | } 21 | 22 | #else 23 | 24 | #endif 25 | # 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/binding/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/method/internal_method.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_method__h_ 2 | #define ruby_internal_method__h_ 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | struct METHOD { 21 | VALUE klass, rklass; 22 | VALUE recv; 23 | ID id, oid; 24 | int safe_level; 25 | NODE *body; 26 | }; 27 | 28 | #define METHOD_OCLASS(m) m->klass 29 | #define METHOD_RCLASS(m) m->rklass 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/module/classpath.c: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | VALUE 4 | class2path(klass) 5 | VALUE klass; 6 | { 7 | VALUE path = rb_class_path(klass); 8 | char *n = RSTRING(path)->ptr; 9 | 10 | if (n[0] == '#') { 11 | rb_raise(rb_eTypeError, "can't dump anonymous %s %s", 12 | (TYPE(klass) == T_CLASS ? "class" : "module"), 13 | n); 14 | } 15 | if (rb_path2class(n) != rb_class_real(klass)) { 16 | rb_raise(rb_eTypeError, "%s can't be referred", n); 17 | } 18 | return path; 19 | } 20 | 21 | VALUE 22 | path2class(path) 23 | char *path; 24 | { 25 | VALUE v = rb_path2class(path); 26 | 27 | if (TYPE(v) != T_CLASS) { 28 | rb_raise(rb_eArgError, "%s does not refer class", path); 29 | } 30 | return v; 31 | } 32 | 33 | VALUE 34 | path2module(path) 35 | char *path; 36 | { 37 | VALUE v = rb_path2class(path); 38 | 39 | if (TYPE(v) != T_MODULE) { 40 | rb_raise(rb_eArgError, "%s does not refer module", path); 41 | } 42 | return v; 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/module/classpath.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSPATH_H 2 | #define CLASSPATH_H 3 | 4 | #include "ruby.h" 5 | 6 | VALUE class2path( 7 | VALUE klass 8 | ); 9 | VALUE path2class( 10 | char *path 11 | ); 12 | VALUE path2module( 13 | char *path 14 | ); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/module/getcfp.h: -------------------------------------------------------------------------------- 1 | #ifndef getcfp__h 2 | #define getcfp__h 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/node/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/node/global_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | struct trace_var { 7 | int removed; 8 | void (*func)(); 9 | VALUE data; 10 | struct trace_var *next; 11 | }; 12 | struct global_variable { 13 | int counter; 14 | void *data; 15 | VALUE (*getter)(); 16 | void (*setter)(); 17 | void (*marker)(); 18 | int block_trace; 19 | struct trace_var *trace; 20 | }; 21 | struct global_entry { 22 | struct global_variable *var; 23 | ID id; 24 | }; 25 | static VALUE undef_getter(); 26 | static void undef_setter(); 27 | static void undef_marker(); 28 | static VALUE val_getter(); 29 | static void val_setter(); 30 | static void val_marker(); 31 | struct global_entry* 32 | rb_global_entry(id) 33 | ID id; 34 | { 35 | struct global_entry *entry; 36 | 37 | if (!st_lookup(rb_global_tbl, id, (st_data_t *)&entry)) { 38 | struct global_variable *var; 39 | entry = ALLOC(struct global_entry); 40 | var = ALLOC(struct global_variable); 41 | entry->id = id; 42 | entry->var = var; 43 | var->counter = 1; 44 | var->data = 0; 45 | var->getter = undef_getter; 46 | var->setter = undef_setter; 47 | var->marker = undef_marker; 48 | 49 | var->block_trace = 0; 50 | var->trace = 0; 51 | st_add_direct(rb_global_tbl, id, (st_data_t)entry); 52 | } 53 | return entry; 54 | } 55 | static VALUE 56 | undef_getter(id) 57 | ID id; 58 | { 59 | rb_warning("global variable `%s' not initialized", rb_id2name(id)); 60 | 61 | return Qnil; 62 | } 63 | static void 64 | undef_setter(val, id, data, var) 65 | VALUE val; 66 | ID id; 67 | void *data; 68 | struct global_variable *var; 69 | { 70 | var->getter = val_getter; 71 | var->setter = val_setter; 72 | var->marker = val_marker; 73 | 74 | var->data = (void*)val; 75 | } 76 | static void 77 | undef_marker() 78 | { 79 | } 80 | static VALUE 81 | val_getter(id, val) 82 | ID id; 83 | VALUE val; 84 | { 85 | return val; 86 | } 87 | static void 88 | val_setter(val, id, data, var) 89 | VALUE val; 90 | ID id; 91 | void *data; 92 | struct global_variable *var; 93 | { 94 | var->data = (void*)val; 95 | } 96 | static void 97 | val_marker(data) 98 | VALUE data; 99 | { 100 | if (data) rb_gc_mark_maybe(data); 101 | } 102 | 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/node/nodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | NEN_1ST, 12 | NEN_2ND, 13 | NEN_AID, 14 | NEN_ALEN, 15 | NEN_ARGC, 16 | NEN_ARGS, 17 | NEN_BEG, 18 | NEN_BODY, 19 | NEN_CFLAG, 20 | NEN_CFNC, 21 | NEN_CLSS, 22 | NEN_CNT, 23 | NEN_COND, 24 | NEN_CPATH, 25 | NEN_CVAL, 26 | NEN_DEFN, 27 | NEN_ELSE, 28 | NEN_END, 29 | NEN_ENSR, 30 | NEN_ENTRY, 31 | NEN_FRML, 32 | NEN_HEAD, 33 | NEN_IBDY, 34 | NEN_ITER, 35 | NEN_LIT, 36 | NEN_MID, 37 | NEN_MODL, 38 | NEN_NEXT, 39 | NEN_NOEX, 40 | NEN_NTH, 41 | NEN_OPT, 42 | NEN_ORIG, 43 | NEN_RECV, 44 | NEN_RESQ, 45 | NEN_REST, 46 | NEN_RVAL, 47 | NEN_STATE, 48 | NEN_STTS, 49 | NEN_SUPER, 50 | NEN_TAG, 51 | NEN_TBL, 52 | NEN_TVAL, 53 | NEN_VALUE, 54 | NEN_VAR, 55 | NEN_VID, 56 | }; 57 | 58 | VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash); 59 | void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash); 60 | VALUE node_s_members(VALUE klass); 61 | void define_node_subclass_methods(); 62 | 63 | #define NODE_OP_ASGN2_ARG NODE_LAST + 1 64 | #define NUM_NODE_TYPE_DESCRIPS NODE_OP_ASGN2_ARG + 1 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/proc/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/tag/tag.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | #define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq) 8 | #define TAG_RETURN 0x1 9 | #define TAG_BREAK 0x2 10 | #define TAG_NEXT 0x3 11 | #define TAG_RETRY 0x4 12 | #define TAG_REDO 0x5 13 | #define TAG_RAISE 0x6 14 | #define TAG_THROW 0x7 15 | #define TAG_FATAL 0x8 16 | #define TAG_MASK 0xf 17 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/vm/instruction/insns_info.c: -------------------------------------------------------------------------------- 1 | #include "insns_info.h" 2 | 3 | #ifdef RUBY_VM 4 | 5 | #include "iseq.h" 6 | #include "vm_core.h" 7 | 8 | 9 | VALUE instruction_class[VM_INSTRUCTION_SIZE]; 10 | 11 | static ID operand_type_name_of(int operand_type) 12 | { 13 | char const * retval = "????"; 14 | 15 | switch(operand_type) 16 | { 17 | case TS_ISEQ: retval = "iseq"; break; 18 | case TS_GENTRY: retval = "gentry"; break; 19 | case TS_OFFSET: retval = "operand"; break; 20 | case TS_DINDEX: retval = "dindex"; break; 21 | case TS_VARIABLE: retval = "variable"; break; 22 | case TS_CDHASH: retval = "cdhash"; break; 23 | case TS_IC: retval = "ic"; break; 24 | case TS_ID: retval = "id"; break; 25 | case TS_VALUE: retval = "value"; break; 26 | case TS_LINDEX: retval = "lindex"; break; 27 | case TS_NUM: retval = "num"; break; 28 | } 29 | 30 | return rb_intern(retval); 31 | } 32 | 33 | 34 | void define_instruction_subclasses(VALUE rb_cInstruction) 35 | { 36 | /* For rdoc: rb_cVM = rb_define_class("VM", rb_cObject); */ 37 | /* For rdoc: rb_cInstruction = rb_define_class_under(rb_cVM, "Instruction", rb_cObject); */ 38 | 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/vm/instruction/insns_info.h: -------------------------------------------------------------------------------- 1 | #ifndef insns_info__h_ 2 | #define insns_info__h_ 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | #ifdef HAVE_VM_H 11 | #include "vm.h" 12 | #endif 13 | 14 | 15 | extern VALUE instruction_class[VM_INSTRUCTION_SIZE]; 16 | void define_instruction_subclasses(VALUE rb_cInstruction); 17 | 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/vm/iseq/insns_info.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_insns_info__inc_ 2 | #define ruby_internal_insns_info__inc_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.5/internal/vm/iseq/iseq_load.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_iseq_load__inc_ 2 | #define ruby_internal_iseq_load__inc_ 3 | 4 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 5 | 6 | static rb_data_type_t const * p_iseq_data_type; 7 | 8 | static void init_iseq_data_type() 9 | { 10 | rb_proc_t * p; 11 | VALUE body; 12 | 13 | VALUE binding = rb_binding_new(); 14 | VALUE new_proc = rb_funcall( 15 | rb_cObject, rb_intern("eval"), 2, rb_str_new2("proc { }"), binding); 16 | GetProcPtr(new_proc, p); 17 | body = p->block.iseq->self; 18 | 19 | p_iseq_data_type = RTYPEDDATA_TYPE(body); 20 | } 21 | 22 | #else 23 | 24 | #endif 25 | # 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/binding/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/method/internal_method.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_method__h_ 2 | #define ruby_internal_method__h_ 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | struct METHOD { 21 | VALUE klass, rklass; 22 | VALUE recv; 23 | ID id, oid; 24 | int safe_level; 25 | NODE *body; 26 | }; 27 | 28 | #define METHOD_OCLASS(m) m->klass 29 | #define METHOD_RCLASS(m) m->rklass 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/module/classpath.c: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | VALUE 4 | class2path(klass) 5 | VALUE klass; 6 | { 7 | VALUE path = rb_class_path(klass); 8 | char *n = RSTRING(path)->ptr; 9 | 10 | if (n[0] == '#') { 11 | rb_raise(rb_eTypeError, "can't dump anonymous %s %s", 12 | (TYPE(klass) == T_CLASS ? "class" : "module"), 13 | n); 14 | } 15 | if (rb_path2class(n) != rb_class_real(klass)) { 16 | rb_raise(rb_eTypeError, "%s can't be referred", n); 17 | } 18 | return path; 19 | } 20 | 21 | VALUE 22 | path2class(path) 23 | char *path; 24 | { 25 | VALUE v = rb_path2class(path); 26 | 27 | if (TYPE(v) != T_CLASS) { 28 | rb_raise(rb_eArgError, "%s does not refer class", path); 29 | } 30 | return v; 31 | } 32 | 33 | VALUE 34 | path2module(path) 35 | char *path; 36 | { 37 | VALUE v = rb_path2class(path); 38 | 39 | if (TYPE(v) != T_MODULE) { 40 | rb_raise(rb_eArgError, "%s does not refer module", path); 41 | } 42 | return v; 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/module/classpath.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSPATH_H 2 | #define CLASSPATH_H 3 | 4 | #include "ruby.h" 5 | 6 | VALUE class2path( 7 | VALUE klass 8 | ); 9 | VALUE path2class( 10 | char *path 11 | ); 12 | VALUE path2module( 13 | char *path 14 | ); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/module/getcfp.h: -------------------------------------------------------------------------------- 1 | #ifndef getcfp__h 2 | #define getcfp__h 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/node/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/node/global_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | struct trace_var { 7 | int removed; 8 | void (*func)(); 9 | VALUE data; 10 | struct trace_var *next; 11 | }; 12 | struct global_variable { 13 | int counter; 14 | void *data; 15 | VALUE (*getter)(); 16 | void (*setter)(); 17 | void (*marker)(); 18 | int block_trace; 19 | struct trace_var *trace; 20 | }; 21 | struct global_entry { 22 | struct global_variable *var; 23 | ID id; 24 | }; 25 | static VALUE undef_getter(); 26 | static void undef_setter(); 27 | static void undef_marker(); 28 | static VALUE val_getter(); 29 | static void val_setter(); 30 | static void val_marker(); 31 | struct global_entry* 32 | rb_global_entry(id) 33 | ID id; 34 | { 35 | struct global_entry *entry; 36 | 37 | if (!st_lookup(rb_global_tbl, id, (st_data_t *)&entry)) { 38 | struct global_variable *var; 39 | entry = ALLOC(struct global_entry); 40 | var = ALLOC(struct global_variable); 41 | entry->id = id; 42 | entry->var = var; 43 | var->counter = 1; 44 | var->data = 0; 45 | var->getter = undef_getter; 46 | var->setter = undef_setter; 47 | var->marker = undef_marker; 48 | 49 | var->block_trace = 0; 50 | var->trace = 0; 51 | st_add_direct(rb_global_tbl, id, (st_data_t)entry); 52 | } 53 | return entry; 54 | } 55 | static VALUE 56 | undef_getter(id) 57 | ID id; 58 | { 59 | rb_warning("global variable `%s' not initialized", rb_id2name(id)); 60 | 61 | return Qnil; 62 | } 63 | static void 64 | undef_setter(val, id, data, var) 65 | VALUE val; 66 | ID id; 67 | void *data; 68 | struct global_variable *var; 69 | { 70 | var->getter = val_getter; 71 | var->setter = val_setter; 72 | var->marker = val_marker; 73 | 74 | var->data = (void*)val; 75 | } 76 | static void 77 | undef_marker() 78 | { 79 | } 80 | static VALUE 81 | val_getter(id, val) 82 | ID id; 83 | VALUE val; 84 | { 85 | return val; 86 | } 87 | static void 88 | val_setter(val, id, data, var) 89 | VALUE val; 90 | ID id; 91 | void *data; 92 | struct global_variable *var; 93 | { 94 | var->data = (void*)val; 95 | } 96 | static void 97 | val_marker(data) 98 | VALUE data; 99 | { 100 | if (data) rb_gc_mark_maybe(data); 101 | } 102 | 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/node/nodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | NEN_1ST, 12 | NEN_2ND, 13 | NEN_AID, 14 | NEN_ALEN, 15 | NEN_ARGC, 16 | NEN_ARGS, 17 | NEN_BEG, 18 | NEN_BODY, 19 | NEN_CFLAG, 20 | NEN_CFNC, 21 | NEN_CLSS, 22 | NEN_CNT, 23 | NEN_COND, 24 | NEN_CPATH, 25 | NEN_CVAL, 26 | NEN_DEFN, 27 | NEN_ELSE, 28 | NEN_END, 29 | NEN_ENSR, 30 | NEN_ENTRY, 31 | NEN_FRML, 32 | NEN_HEAD, 33 | NEN_IBDY, 34 | NEN_ITER, 35 | NEN_LIT, 36 | NEN_MID, 37 | NEN_MODL, 38 | NEN_NEXT, 39 | NEN_NOEX, 40 | NEN_NTH, 41 | NEN_OPT, 42 | NEN_ORIG, 43 | NEN_RECV, 44 | NEN_RESQ, 45 | NEN_REST, 46 | NEN_RVAL, 47 | NEN_STATE, 48 | NEN_STTS, 49 | NEN_SUPER, 50 | NEN_TAG, 51 | NEN_TBL, 52 | NEN_TVAL, 53 | NEN_VALUE, 54 | NEN_VAR, 55 | NEN_VID, 56 | }; 57 | 58 | VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash); 59 | void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash); 60 | VALUE node_s_members(VALUE klass); 61 | void define_node_subclass_methods(); 62 | 63 | #define NODE_OP_ASGN2_ARG NODE_LAST + 1 64 | #define NUM_NODE_TYPE_DESCRIPS NODE_OP_ASGN2_ARG + 1 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/proc/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/tag/tag.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | #define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq) 8 | #define TAG_RETURN 0x1 9 | #define TAG_BREAK 0x2 10 | #define TAG_NEXT 0x3 11 | #define TAG_RETRY 0x4 12 | #define TAG_REDO 0x5 13 | #define TAG_RAISE 0x6 14 | #define TAG_THROW 0x7 15 | #define TAG_FATAL 0x8 16 | #define TAG_MASK 0xf 17 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/vm/instruction/insns_info.c: -------------------------------------------------------------------------------- 1 | #include "insns_info.h" 2 | 3 | #ifdef RUBY_VM 4 | 5 | #include "iseq.h" 6 | #include "vm_core.h" 7 | 8 | 9 | VALUE instruction_class[VM_INSTRUCTION_SIZE]; 10 | 11 | static ID operand_type_name_of(int operand_type) 12 | { 13 | char const * retval = "????"; 14 | 15 | switch(operand_type) 16 | { 17 | case TS_ISEQ: retval = "iseq"; break; 18 | case TS_GENTRY: retval = "gentry"; break; 19 | case TS_OFFSET: retval = "operand"; break; 20 | case TS_DINDEX: retval = "dindex"; break; 21 | case TS_VARIABLE: retval = "variable"; break; 22 | case TS_CDHASH: retval = "cdhash"; break; 23 | case TS_IC: retval = "ic"; break; 24 | case TS_ID: retval = "id"; break; 25 | case TS_VALUE: retval = "value"; break; 26 | case TS_LINDEX: retval = "lindex"; break; 27 | case TS_NUM: retval = "num"; break; 28 | } 29 | 30 | return rb_intern(retval); 31 | } 32 | 33 | 34 | void define_instruction_subclasses(VALUE rb_cInstruction) 35 | { 36 | /* For rdoc: rb_cVM = rb_define_class("VM", rb_cObject); */ 37 | /* For rdoc: rb_cInstruction = rb_define_class_under(rb_cVM, "Instruction", rb_cObject); */ 38 | 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/vm/instruction/insns_info.h: -------------------------------------------------------------------------------- 1 | #ifndef insns_info__h_ 2 | #define insns_info__h_ 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | #ifdef HAVE_VM_H 11 | #include "vm.h" 12 | #endif 13 | 14 | 15 | extern VALUE instruction_class[VM_INSTRUCTION_SIZE]; 16 | void define_instruction_subclasses(VALUE rb_cInstruction); 17 | 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/vm/iseq/insns_info.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_insns_info__inc_ 2 | #define ruby_internal_insns_info__inc_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.6/internal/vm/iseq/iseq_load.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_iseq_load__inc_ 2 | #define ruby_internal_iseq_load__inc_ 3 | 4 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 5 | 6 | static rb_data_type_t const * p_iseq_data_type; 7 | 8 | static void init_iseq_data_type() 9 | { 10 | rb_proc_t * p; 11 | VALUE body; 12 | 13 | VALUE binding = rb_binding_new(); 14 | VALUE new_proc = rb_funcall( 15 | rb_cObject, rb_intern("eval"), 2, rb_str_new2("proc { }"), binding); 16 | GetProcPtr(new_proc, p); 17 | body = p->block.iseq->self; 18 | 19 | p_iseq_data_type = RTYPEDDATA_TYPE(body); 20 | } 21 | 22 | #else 23 | 24 | #endif 25 | # 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/binding/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/method/internal_method.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_method__h_ 2 | #define ruby_internal_method__h_ 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | struct METHOD { 21 | VALUE klass, rklass; 22 | VALUE recv; 23 | ID id, oid; 24 | int safe_level; 25 | NODE *body; 26 | }; 27 | 28 | #define METHOD_OCLASS(m) m->klass 29 | #define METHOD_RCLASS(m) m->rklass 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/module/classpath.c: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | VALUE 4 | class2path(klass) 5 | VALUE klass; 6 | { 7 | VALUE path = rb_class_path(klass); 8 | char *n = RSTRING(path)->ptr; 9 | 10 | if (n[0] == '#') { 11 | rb_raise(rb_eTypeError, "can't dump anonymous %s %s", 12 | (TYPE(klass) == T_CLASS ? "class" : "module"), 13 | n); 14 | } 15 | if (rb_path2class(n) != rb_class_real(klass)) { 16 | rb_raise(rb_eTypeError, "%s can't be referred", n); 17 | } 18 | return path; 19 | } 20 | 21 | VALUE 22 | path2class(path) 23 | const char *path; 24 | { 25 | VALUE v = rb_path2class(path); 26 | 27 | if (TYPE(v) != T_CLASS) { 28 | rb_raise(rb_eArgError, "%s does not refer class", path); 29 | } 30 | return v; 31 | } 32 | 33 | VALUE 34 | path2module(path) 35 | const char *path; 36 | { 37 | VALUE v = rb_path2class(path); 38 | 39 | if (TYPE(v) != T_MODULE) { 40 | rb_raise(rb_eArgError, "%s does not refer module", path); 41 | } 42 | return v; 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/module/classpath.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSPATH_H 2 | #define CLASSPATH_H 3 | 4 | #include "ruby.h" 5 | 6 | VALUE class2path( 7 | VALUE klass 8 | ); 9 | VALUE path2class( 10 | const char *path 11 | ); 12 | VALUE path2module( 13 | const char *path 14 | ); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/module/getcfp.h: -------------------------------------------------------------------------------- 1 | #ifndef getcfp__h 2 | #define getcfp__h 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/node/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/node/global_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | struct trace_var { 7 | int removed; 8 | void (*func)(); 9 | VALUE data; 10 | struct trace_var *next; 11 | }; 12 | struct global_variable { 13 | int counter; 14 | void *data; 15 | VALUE (*getter)(); 16 | void (*setter)(); 17 | void (*marker)(); 18 | int block_trace; 19 | struct trace_var *trace; 20 | }; 21 | struct global_entry { 22 | struct global_variable *var; 23 | ID id; 24 | }; 25 | static VALUE undef_getter(); 26 | static void undef_setter(); 27 | static void undef_marker(); 28 | static VALUE val_getter(); 29 | static void val_setter(); 30 | static void val_marker(); 31 | struct global_entry* 32 | rb_global_entry(id) 33 | ID id; 34 | { 35 | struct global_entry *entry; 36 | st_data_t data; 37 | 38 | if (!st_lookup(rb_global_tbl, id, &data)) { 39 | struct global_variable *var; 40 | entry = ALLOC(struct global_entry); 41 | var = ALLOC(struct global_variable); 42 | entry->id = id; 43 | entry->var = var; 44 | var->counter = 1; 45 | var->data = 0; 46 | var->getter = undef_getter; 47 | var->setter = undef_setter; 48 | var->marker = undef_marker; 49 | 50 | var->block_trace = 0; 51 | var->trace = 0; 52 | st_add_direct(rb_global_tbl, id, (st_data_t)entry); 53 | } 54 | else { 55 | entry = (struct global_entry *)data; 56 | } 57 | return entry; 58 | } 59 | static VALUE 60 | undef_getter(id) 61 | ID id; 62 | { 63 | rb_warning("global variable `%s' not initialized", rb_id2name(id)); 64 | 65 | return Qnil; 66 | } 67 | static void 68 | undef_setter(val, id, data, var) 69 | VALUE val; 70 | ID id; 71 | void *data; 72 | struct global_variable *var; 73 | { 74 | var->getter = val_getter; 75 | var->setter = val_setter; 76 | var->marker = val_marker; 77 | 78 | var->data = (void*)val; 79 | } 80 | static void 81 | undef_marker() 82 | { 83 | } 84 | static VALUE 85 | val_getter(id, val) 86 | ID id; 87 | VALUE val; 88 | { 89 | return val; 90 | } 91 | static void 92 | val_setter(val, id, data, var) 93 | VALUE val; 94 | ID id; 95 | void *data; 96 | struct global_variable *var; 97 | { 98 | var->data = (void*)val; 99 | } 100 | static void 101 | val_marker(data) 102 | VALUE data; 103 | { 104 | if (data) rb_gc_mark_maybe(data); 105 | } 106 | 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/node/nodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | NEN_1ST, 12 | NEN_2ND, 13 | NEN_AID, 14 | NEN_ALEN, 15 | NEN_ARGC, 16 | NEN_ARGS, 17 | NEN_BEG, 18 | NEN_BODY, 19 | NEN_CFLAG, 20 | NEN_CFNC, 21 | NEN_CLSS, 22 | NEN_CNT, 23 | NEN_COND, 24 | NEN_CPATH, 25 | NEN_CVAL, 26 | NEN_DEFN, 27 | NEN_ELSE, 28 | NEN_END, 29 | NEN_ENSR, 30 | NEN_ENTRY, 31 | NEN_FRML, 32 | NEN_HEAD, 33 | NEN_IBDY, 34 | NEN_ITER, 35 | NEN_LIT, 36 | NEN_MID, 37 | NEN_MODL, 38 | NEN_NEXT, 39 | NEN_NOEX, 40 | NEN_NTH, 41 | NEN_OPT, 42 | NEN_ORIG, 43 | NEN_RECV, 44 | NEN_RESQ, 45 | NEN_REST, 46 | NEN_RVAL, 47 | NEN_STATE, 48 | NEN_STTS, 49 | NEN_SUPER, 50 | NEN_TAG, 51 | NEN_TBL, 52 | NEN_TVAL, 53 | NEN_VALUE, 54 | NEN_VAR, 55 | NEN_VID, 56 | }; 57 | 58 | VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash); 59 | void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash); 60 | VALUE node_s_members(VALUE klass); 61 | void define_node_subclass_methods(); 62 | 63 | #define NODE_OP_ASGN2_ARG NODE_LAST + 1 64 | #define NUM_NODE_TYPE_DESCRIPS NODE_OP_ASGN2_ARG + 1 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/proc/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | struct BLOCK { 11 | NODE *var; 12 | NODE *body; 13 | VALUE self; 14 | struct FRAME frame; 15 | struct SCOPE *scope; 16 | VALUE klass; 17 | NODE *cref; 18 | int iter; 19 | int vmode; 20 | int flags; 21 | int uniq; 22 | struct RVarmap *dyna_vars; 23 | VALUE orig_thread; 24 | VALUE wrapper; 25 | VALUE block_obj; 26 | struct BLOCK *outer; 27 | struct BLOCK *prev; 28 | }; 29 | 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/tag/tag.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | #define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq) 8 | #define TAG_RETURN 0x1 9 | #define TAG_BREAK 0x2 10 | #define TAG_NEXT 0x3 11 | #define TAG_RETRY 0x4 12 | #define TAG_REDO 0x5 13 | #define TAG_RAISE 0x6 14 | #define TAG_THROW 0x7 15 | #define TAG_FATAL 0x8 16 | #define TAG_MASK 0xf 17 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/vm/instruction/insns_info.c: -------------------------------------------------------------------------------- 1 | #include "insns_info.h" 2 | 3 | #ifdef RUBY_VM 4 | 5 | #include "iseq.h" 6 | #include "vm_core.h" 7 | 8 | 9 | VALUE instruction_class[VM_INSTRUCTION_SIZE]; 10 | 11 | static ID operand_type_name_of(int operand_type) 12 | { 13 | char const * retval = "????"; 14 | 15 | switch(operand_type) 16 | { 17 | case TS_ISEQ: retval = "iseq"; break; 18 | case TS_GENTRY: retval = "gentry"; break; 19 | case TS_OFFSET: retval = "operand"; break; 20 | case TS_DINDEX: retval = "dindex"; break; 21 | case TS_VARIABLE: retval = "variable"; break; 22 | case TS_CDHASH: retval = "cdhash"; break; 23 | case TS_IC: retval = "ic"; break; 24 | case TS_ID: retval = "id"; break; 25 | case TS_VALUE: retval = "value"; break; 26 | case TS_LINDEX: retval = "lindex"; break; 27 | case TS_NUM: retval = "num"; break; 28 | } 29 | 30 | return rb_intern(retval); 31 | } 32 | 33 | 34 | void define_instruction_subclasses(VALUE rb_cInstruction) 35 | { 36 | /* For rdoc: rb_cVM = rb_define_class("VM", rb_cObject); */ 37 | /* For rdoc: rb_cInstruction = rb_define_class_under(rb_cVM, "Instruction", rb_cObject); */ 38 | 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/vm/instruction/insns_info.h: -------------------------------------------------------------------------------- 1 | #ifndef insns_info__h_ 2 | #define insns_info__h_ 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | #ifdef HAVE_VM_H 11 | #include "vm.h" 12 | #endif 13 | 14 | 15 | extern VALUE instruction_class[VM_INSTRUCTION_SIZE]; 16 | void define_instruction_subclasses(VALUE rb_cInstruction); 17 | 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/vm/iseq/insns_info.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_insns_info__inc_ 2 | #define ruby_internal_insns_info__inc_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.8.7/internal/vm/iseq/iseq_load.inc: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_iseq_load__inc_ 2 | #define ruby_internal_iseq_load__inc_ 3 | 4 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 5 | 6 | static rb_data_type_t const * p_iseq_data_type; 7 | 8 | static void init_iseq_data_type() 9 | { 10 | rb_proc_t * p; 11 | VALUE body; 12 | 13 | VALUE binding = rb_binding_new(); 14 | VALUE new_proc = rb_funcall( 15 | rb_cObject, rb_intern("eval"), 2, rb_str_new2("proc { }"), binding); 16 | GetProcPtr(new_proc, p); 17 | body = p->block.iseq->self; 18 | 19 | p_iseq_data_type = RTYPEDDATA_TYPE(body); 20 | } 21 | 22 | #else 23 | 24 | #endif 25 | # 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/binding/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/method/internal_method.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_method__h_ 2 | #define ruby_internal_method__h_ 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | struct METHOD { 21 | VALUE oclass; /* class that holds the method */ 22 | VALUE rclass; /* class of the receiver */ 23 | VALUE recv; 24 | ID id, oid; 25 | NODE *body; 26 | }; 27 | 28 | #define METHOD_OCLASS(m) m->oclass 29 | #define METHOD_RCLASS(m) m->rclass 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/module/classpath.c: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | VALUE 4 | class2path(VALUE klass) 5 | { 6 | VALUE path = rb_class_path(klass); 7 | const char *n; 8 | 9 | n = must_not_be_anonymous((TYPE(klass) == T_CLASS ? "class" : "module"), path); 10 | if (rb_path_to_class(path) != rb_class_real(klass)) { 11 | rb_raise(rb_eTypeError, "%s can't be referred to", n); 12 | } 13 | return path; 14 | } 15 | 16 | VALUE 17 | path2class(VALUE path) 18 | { 19 | VALUE v = rb_path_to_class(path); 20 | 21 | if (TYPE(v) != T_CLASS) { 22 | rb_raise(rb_eArgError, "%.*s does not refer to class", 23 | (int)RSTRING_LEN(path), RSTRING_PTR(path)); 24 | } 25 | return v; 26 | } 27 | 28 | VALUE 29 | path2module(VALUE path) 30 | { 31 | VALUE v = rb_path_to_class(path); 32 | 33 | if (TYPE(v) != T_MODULE) { 34 | rb_raise(rb_eArgError, "%.*s does not refer to module", 35 | (int)RSTRING_LEN(path), RSTRING_PTR(path)); 36 | } 37 | return v; 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/module/classpath.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSPATH_H 2 | #define CLASSPATH_H 3 | 4 | #include "ruby.h" 5 | 6 | VALUE class2path( 7 | 8 | ); 9 | VALUE path2class( 10 | 11 | ); 12 | VALUE path2module( 13 | 14 | ); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/module/getcfp.h: -------------------------------------------------------------------------------- 1 | #ifndef getcfp__h 2 | #define getcfp__h 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | static rb_control_frame_t * 11 | getcfp(rb_thread_t *th, rb_control_frame_t *cfp) 12 | { 13 | while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) { 14 | if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { 15 | return cfp; 16 | } 17 | cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); 18 | } 19 | return 0; 20 | } 21 | 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/node/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/node/global_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | #define global_variable rb_global_variable 7 | #define gvar_getter_t rb_gvar_getter_t 8 | #define gvar_setter_t rb_gvar_setter_t 9 | #define gvar_marker_t rb_gvar_marker_t 10 | struct trace_var { 11 | int removed; 12 | void (*func)(VALUE arg, VALUE val); 13 | VALUE data; 14 | struct trace_var *next; 15 | }; 16 | struct global_variable { 17 | int counter; 18 | void *data; 19 | gvar_getter_t *getter; 20 | gvar_setter_t *setter; 21 | gvar_marker_t *marker; 22 | int block_trace; 23 | struct trace_var *trace; 24 | }; 25 | struct global_entry { 26 | struct global_variable *var; 27 | ID id; 28 | }; 29 | #define undef_getter rb_gvar_undef_getter 30 | #define undef_setter rb_gvar_undef_setter 31 | #define undef_marker rb_gvar_undef_marker 32 | #define val_getter rb_gvar_val_getter 33 | #define val_setter rb_gvar_val_setter 34 | #define val_marker rb_gvar_val_marker 35 | struct global_entry* 36 | rb_global_entry(ID id) 37 | { 38 | struct global_entry *entry; 39 | st_data_t data; 40 | 41 | if (!st_lookup(rb_global_tbl, id, &data)) { 42 | struct global_variable *var; 43 | entry = ALLOC(struct global_entry); 44 | var = ALLOC(struct global_variable); 45 | entry->id = id; 46 | entry->var = var; 47 | var->counter = 1; 48 | var->data = 0; 49 | var->getter = undef_getter; 50 | var->setter = undef_setter; 51 | var->marker = undef_marker; 52 | 53 | var->block_trace = 0; 54 | var->trace = 0; 55 | st_add_direct(rb_global_tbl, id, (st_data_t)entry); 56 | } 57 | else { 58 | entry = (struct global_entry *)data; 59 | } 60 | return entry; 61 | } 62 | VALUE 63 | undef_getter(ID id, void *data, struct global_variable *var) 64 | { 65 | rb_warning("global variable `%s' not initialized", rb_id2name(id)); 66 | 67 | return Qnil; 68 | } 69 | void 70 | undef_setter(VALUE val, ID id, void *data, struct global_variable *var) 71 | { 72 | var->getter = val_getter; 73 | var->setter = val_setter; 74 | var->marker = val_marker; 75 | 76 | var->data = (void*)val; 77 | } 78 | void 79 | undef_marker(VALUE *var) 80 | { 81 | } 82 | VALUE 83 | val_getter(ID id, void *data, struct global_variable *var) 84 | { 85 | return (VALUE)data; 86 | } 87 | void 88 | val_setter(VALUE val, ID id, void *data, struct global_variable *var) 89 | { 90 | var->data = (void*)val; 91 | } 92 | void 93 | val_marker(VALUE *var) 94 | { 95 | VALUE data = (VALUE)var; 96 | if (data) rb_gc_mark_maybe(data); 97 | } 98 | 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/node/nodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | NEN_1ST, 12 | NEN_2ND, 13 | NEN_AID, 14 | NEN_ALEN, 15 | NEN_ARGC, 16 | NEN_ARGS, 17 | NEN_BEG, 18 | NEN_BODY, 19 | NEN_CFLAG, 20 | NEN_CFNC, 21 | NEN_CLSS, 22 | NEN_CNT, 23 | NEN_COND, 24 | NEN_CPATH, 25 | NEN_CVAL, 26 | NEN_DEFN, 27 | NEN_ELSE, 28 | NEN_END, 29 | NEN_ENSR, 30 | NEN_ENTRY, 31 | NEN_FRML, 32 | NEN_HEAD, 33 | NEN_ITER, 34 | NEN_LIT, 35 | NEN_MID, 36 | NEN_MODL, 37 | NEN_NEXT, 38 | NEN_NOEX, 39 | NEN_NTH, 40 | NEN_OID, 41 | NEN_OPT, 42 | NEN_ORIG, 43 | NEN_PID, 44 | NEN_PLEN, 45 | NEN_RECV, 46 | NEN_RESQ, 47 | NEN_REST, 48 | NEN_RVAL, 49 | NEN_STATE, 50 | NEN_STTS, 51 | NEN_SUPER, 52 | NEN_TAG, 53 | NEN_TBL, 54 | NEN_TVAL, 55 | NEN_VALUE, 56 | NEN_VAR, 57 | NEN_VID, 58 | NEN_VISI, 59 | }; 60 | 61 | VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash); 62 | void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash); 63 | VALUE node_s_members(VALUE klass); 64 | void define_node_subclass_methods(); 65 | 66 | #define NODE_OP_ASGN2_ARG NODE_LAST + 1 67 | #define NUM_NODE_TYPE_DESCRIPS NODE_OP_ASGN2_ARG + 1 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/proc/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/tag/tag.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/debug.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | debug.h - YARV Debug function interface 4 | 5 | $Author: ko1 $ 6 | created at: 04/08/25 02:33:49 JST 7 | 8 | Copyright (C) 2004-2007 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef RUBY_DEBUG_H 13 | #define RUBY_DEBUG_H 14 | 15 | #include "ruby/ruby.h" 16 | #include "node.h" 17 | 18 | #define dpv(h,v) ruby_debug_print_value(-1, 0, h, v) 19 | #define dp(v) ruby_debug_print_value(-1, 0, "", v) 20 | #define dpi(i) ruby_debug_print_id(-1, 0, "", i) 21 | #define dpn(n) ruby_debug_print_node(-1, 0, "", n) 22 | 23 | #define bp() ruby_debug_breakpoint() 24 | 25 | VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v); 26 | ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id); 27 | NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node); 28 | int ruby_debug_print_indent(int level, int debug_level, int indent_level); 29 | void ruby_debug_breakpoint(void); 30 | void ruby_debug_gc_check_func(void); 31 | 32 | #ifdef RUBY_DEBUG_ENV 33 | void ruby_set_debug_option(const char *str); 34 | #endif 35 | 36 | #endif /* RUBY_DEBUG_H */ 37 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/dln.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | dln.h - 4 | 5 | $Author: nobu $ 6 | created at: Wed Jan 19 16:53:09 JST 1994 7 | 8 | Copyright (C) 1993-2007 Yukihiro Matsumoto 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef DLN_H 13 | #define DLN_H 14 | 15 | #ifdef __cplusplus 16 | # ifndef HAVE_PROTOTYPES 17 | # define HAVE_PROTOTYPES 1 18 | # endif 19 | # ifndef HAVE_STDARG_PROTOTYPES 20 | # define HAVE_STDARG_PROTOTYPES 1 21 | # endif 22 | #endif 23 | 24 | #undef _ 25 | #ifdef HAVE_PROTOTYPES 26 | # define _(args) args 27 | #else 28 | # define _(args) () 29 | #endif 30 | 31 | DEPRECATED(char *dln_find_exe(const char*,const char*)); 32 | DEPRECATED(char *dln_find_file(const char*,const char*)); 33 | char *dln_find_exe_r(const char*,const char*,char*,int); 34 | char *dln_find_file_r(const char*,const char*,char*,int); 35 | 36 | #ifdef USE_DLN_A_OUT 37 | extern char *dln_argv0; 38 | #endif 39 | 40 | void *dln_load(const char*); 41 | #endif 42 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/gc.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef RUBY_GC_H 3 | #define RUBY_GC_H 1 4 | 5 | #if defined(__i386) && defined(__GNUC__) 6 | #define SET_MACHINE_STACK_END(p) __asm__("mov %%esp, %0" : "=r" (*p)) 7 | #else 8 | NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p)); 9 | #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p) 10 | #define USE_CONSERVATIVE_STACK_END 11 | #endif 12 | 13 | /* for GC debug */ 14 | 15 | #ifndef RUBY_MARK_FREE_DEBUG 16 | #define RUBY_MARK_FREE_DEBUG 0 17 | #endif 18 | 19 | #if RUBY_MARK_FREE_DEBUG 20 | extern int ruby_gc_debug_indent; 21 | 22 | static void 23 | rb_gc_debug_indent(void) 24 | { 25 | printf("%*s", ruby_gc_debug_indent, ""); 26 | } 27 | 28 | static void 29 | rb_gc_debug_body(char *mode, char *msg, int st, void *ptr) 30 | { 31 | if (st == 0) { 32 | ruby_gc_debug_indent--; 33 | } 34 | rb_gc_debug_indent(); 35 | printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr); 36 | 37 | if (st) { 38 | ruby_gc_debug_indent++; 39 | } 40 | 41 | fflush(stdout); 42 | } 43 | 44 | #define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr) 45 | #define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr) 46 | #define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr) 47 | #define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr) 48 | #define RUBY_GC_INFO rb_gc_debug_indent(); printf 49 | 50 | #else 51 | #define RUBY_MARK_ENTER(msg) 52 | #define RUBY_MARK_LEAVE(msg) 53 | #define RUBY_FREE_ENTER(msg) 54 | #define RUBY_FREE_LEAVE(msg) 55 | #define RUBY_GC_INFO if(0)printf 56 | #endif 57 | 58 | #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);} 59 | #define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);} 60 | 61 | #if STACK_GROW_DIRECTION > 0 62 | # define STACK_UPPER(x, a, b) a 63 | #elif STACK_GROW_DIRECTION < 0 64 | # define STACK_UPPER(x, a, b) b 65 | #else 66 | RUBY_EXTERN int ruby_stack_grow_direction; 67 | int ruby_get_stack_grow_direction(VALUE *addr); 68 | # define stack_growup_p(x) ( \ 69 | (ruby_stack_grow_direction ? \ 70 | ruby_stack_grow_direction : \ 71 | ruby_get_stack_grow_direction(x)) > 0) 72 | # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b) 73 | #endif 74 | 75 | #endif /* RUBY_GC_H */ 76 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/iseq.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | iseq.h - 4 | 5 | $Author: yugui $ 6 | created at: 04/01/01 23:36:57 JST 7 | 8 | Copyright (C) 2004-2008 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef RUBY_COMPILE_H 13 | #define RUBY_COMPILE_H 14 | 15 | /* compile.c */ 16 | VALUE rb_iseq_compile_node(VALUE self, NODE *node); 17 | int rb_iseq_translate_threaded_code(rb_iseq_t *iseq); 18 | VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, 19 | VALUE exception, VALUE body); 20 | 21 | /* iseq.c */ 22 | VALUE ruby_iseq_load(VALUE data, VALUE parent, VALUE opt); 23 | struct st_table *ruby_insn_make_insn_table(void); 24 | 25 | #define ISEQ_TYPE_TOP INT2FIX(1) 26 | #define ISEQ_TYPE_METHOD INT2FIX(2) 27 | #define ISEQ_TYPE_BLOCK INT2FIX(3) 28 | #define ISEQ_TYPE_CLASS INT2FIX(4) 29 | #define ISEQ_TYPE_RESCUE INT2FIX(5) 30 | #define ISEQ_TYPE_ENSURE INT2FIX(6) 31 | #define ISEQ_TYPE_EVAL INT2FIX(7) 32 | #define ISEQ_TYPE_MAIN INT2FIX(8) 33 | #define ISEQ_TYPE_DEFINED_GUARD INT2FIX(9) 34 | 35 | #define CATCH_TYPE_RESCUE INT2FIX(1) 36 | #define CATCH_TYPE_ENSURE INT2FIX(2) 37 | #define CATCH_TYPE_RETRY INT2FIX(3) 38 | #define CATCH_TYPE_BREAK INT2FIX(4) 39 | #define CATCH_TYPE_REDO INT2FIX(5) 40 | #define CATCH_TYPE_NEXT INT2FIX(6) 41 | 42 | struct iseq_insn_info_entry { 43 | unsigned short position; 44 | unsigned short line_no; 45 | unsigned short sp; 46 | }; 47 | 48 | struct iseq_catch_table_entry { 49 | VALUE type; 50 | VALUE iseq; 51 | unsigned long start; 52 | unsigned long end; 53 | unsigned long cont; 54 | unsigned long sp; 55 | }; 56 | 57 | #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512) 58 | 59 | struct iseq_compile_data_storage { 60 | struct iseq_compile_data_storage *next; 61 | unsigned long pos; 62 | unsigned long size; 63 | char *buff; 64 | }; 65 | 66 | struct iseq_compile_data { 67 | /* GC is needed */ 68 | VALUE err_info; 69 | VALUE mark_ary; 70 | VALUE catch_table_ary; /* Array */ 71 | 72 | /* GC is not needed */ 73 | struct iseq_label_data *start_label; 74 | struct iseq_label_data *end_label; 75 | struct iseq_label_data *redo_label; 76 | VALUE current_block; 77 | VALUE loopval_popped; /* used by NODE_BREAK */ 78 | VALUE ensure_node; 79 | VALUE for_iseq; 80 | struct iseq_compile_data_ensure_node_stack *ensure_node_stack; 81 | int cached_const; 82 | struct iseq_compile_data_storage *storage_head; 83 | struct iseq_compile_data_storage *storage_current; 84 | int last_line; 85 | int last_coverable_line; 86 | int flip_cnt; 87 | int label_no; 88 | int node_level; 89 | const rb_compile_option_t *option; 90 | }; 91 | 92 | /* defined? */ 93 | #define DEFINED_IVAR INT2FIX(1) 94 | #define DEFINED_IVAR2 INT2FIX(2) 95 | #define DEFINED_GVAR INT2FIX(3) 96 | #define DEFINED_CVAR INT2FIX(4) 97 | #define DEFINED_CONST INT2FIX(5) 98 | #define DEFINED_METHOD INT2FIX(6) 99 | #define DEFINED_YIELD INT2FIX(7) 100 | #define DEFINED_REF INT2FIX(8) 101 | #define DEFINED_ZSUPER INT2FIX(9) 102 | #define DEFINED_FUNC INT2FIX(10) 103 | 104 | #endif /* RUBY_COMPILE_H */ 105 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/revision.h: -------------------------------------------------------------------------------- 1 | #define RUBY_REVISION 30908 2 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/thread_pthread.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | thread_pthread.h - 4 | 5 | $Author: nobu $ 6 | 7 | Copyright (C) 2004-2007 Koichi Sasada 8 | 9 | **********************************************************************/ 10 | 11 | #ifndef RUBY_THREAD_PTHREAD_H 12 | #define RUBY_THREAD_PTHREAD_H 13 | 14 | #include 15 | typedef pthread_t rb_thread_id_t; 16 | typedef pthread_mutex_t rb_thread_lock_t; 17 | typedef pthread_cond_t rb_thread_cond_t; 18 | 19 | typedef struct native_thread_data_struct { 20 | void *signal_thread_list; 21 | pthread_cond_t sleep_cond; 22 | } native_thread_data_t; 23 | 24 | #endif /* RUBY_THREAD_PTHREAD_H */ 25 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/thread_win32.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | thread_win32.h - 4 | 5 | $Author: usa $ 6 | 7 | Copyright (C) 2004-2007 Koichi Sasada 8 | 9 | **********************************************************************/ 10 | 11 | /* interface */ 12 | #ifndef RUBY_THREAD_WIN32_H 13 | #define RUBY_THREAD_WIN32_H 14 | 15 | #include 16 | 17 | # ifdef __CYGWIN__ 18 | # undef _WIN32 19 | # endif 20 | 21 | WINBASEAPI BOOL WINAPI 22 | TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection); 23 | 24 | typedef HANDLE rb_thread_id_t; 25 | typedef CRITICAL_SECTION rb_thread_lock_t; 26 | typedef struct rb_thread_cond_struct rb_thread_cond_t; 27 | 28 | typedef struct native_thread_data_struct { 29 | HANDLE interrupt_event; 30 | } native_thread_data_t; 31 | 32 | #endif /* RUBY_THREAD_WIN32_H */ 33 | 34 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/version.h: -------------------------------------------------------------------------------- 1 | #define RUBY_VERSION "1.9.1" 2 | #define RUBY_PATCHLEVEL 431 3 | #define RUBY_VERSION_MAJOR 1 4 | #define RUBY_VERSION_MINOR 9 5 | #define RUBY_VERSION_TEENY 1 6 | 7 | #define RUBY_RELEASE_YEAR 2011 8 | #define RUBY_RELEASE_MONTH 2 9 | #define RUBY_RELEASE_DAY 18 10 | #define RUBY_RELEASE_DATE "2011-02-18" 11 | 12 | #ifdef RUBY_EXTERN 13 | RUBY_EXTERN const char ruby_version[]; 14 | RUBY_EXTERN const char ruby_release_date[]; 15 | RUBY_EXTERN const char ruby_platform[]; 16 | RUBY_EXTERN const int ruby_patchlevel; 17 | RUBY_EXTERN const char ruby_description[]; 18 | RUBY_EXTERN const char ruby_copyright[]; 19 | #endif 20 | 21 | #define RUBY_AUTHOR "Yukihiro Matsumoto" 22 | #define RUBY_BIRTH_YEAR 1993 23 | #define RUBY_BIRTH_MONTH 2 24 | #define RUBY_BIRTH_DAY 24 25 | 26 | #define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL) 27 | 28 | #ifndef RUBY_REVISION 29 | # include "revision.h" 30 | #endif 31 | # ifndef RUBY_REVISION 32 | # define RUBY_REVISION 0 33 | #endif 34 | 35 | #if RUBY_REVISION 36 | # ifdef RUBY_BRANCH_NAME 37 | # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION) 38 | # else 39 | # define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION) 40 | # endif 41 | #else 42 | # define RUBY_REVISION_STR "" 43 | #endif 44 | 45 | # define RUBY_DESCRIPTION \ 46 | "ruby "RUBY_VERSION \ 47 | RUBY_PATCHLEVEL_STR \ 48 | " ("RUBY_RELEASE_DATE \ 49 | RUBY_REVISION_STR") " \ 50 | "["RUBY_PLATFORM"]" 51 | # define RUBY_COPYRIGHT \ 52 | "ruby - Copyright (C) " \ 53 | STRINGIZE(RUBY_BIRTH_YEAR)"-" \ 54 | STRINGIZE(RUBY_RELEASE_YEAR)" " \ 55 | RUBY_AUTHOR 56 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.1/internal/yarv-headers/vm_opts.h: -------------------------------------------------------------------------------- 1 | /*-*-c-*-*/ 2 | /********************************************************************** 3 | 4 | vm_opts.h - VM optimize option 5 | 6 | $Author: ko1 $ 7 | 8 | Copyright (C) 2004-2007 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | 13 | #ifndef RUBY_VM_OPTS_H 14 | #define RUBY_VM_OPTS_H 15 | 16 | /* Compile options. 17 | * You can change these options at runtime by VM::CompileOption. 18 | * Following definitions are default values. 19 | */ 20 | 21 | #define OPT_TRACE_INSTRUCTION 1 22 | #define OPT_TAILCALL_OPTIMIZATION 0 23 | #define OPT_PEEPHOLE_OPTIMIZATION 1 24 | #define OPT_SPECIALISED_INSTRUCTION 1 25 | #define OPT_INLINE_CONST_CACHE 1 26 | 27 | 28 | /* Build Options. 29 | * You can't change these options at runtime. 30 | */ 31 | 32 | /* C compiler depend */ 33 | #define OPT_DIRECT_THREADED_CODE 1 34 | #define OPT_TOKEN_THREADED_CODE 0 35 | #define OPT_CALL_THREADED_CODE 0 36 | 37 | /* VM running option */ 38 | #define OPT_CHECKED_RUN 1 39 | #define OPT_INLINE_METHOD_CACHE 1 40 | #define OPT_BLOCKINLINING 0 41 | 42 | /* architecture independent, affects generated code */ 43 | #define OPT_OPERANDS_UNIFICATION 0 44 | #define OPT_INSTRUCTIONS_UNIFICATION 0 45 | #define OPT_UNIFY_ALL_COMBINATION 0 46 | #define OPT_STACK_CACHING 0 47 | 48 | /* misc */ 49 | #define SUPPORT_JOKE 0 50 | 51 | #endif /* RUBY_VM_OPTS_H */ 52 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/binding/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/method/internal_method.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_method__h_ 2 | #define ruby_internal_method__h_ 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | struct METHOD { 21 | VALUE recv; 22 | VALUE rclass; 23 | ID id; 24 | rb_method_entry_t me; 25 | }; 26 | 27 | #define METHOD_OCLASS(m) m->klass 28 | #define METHOD_RCLASS(m) m->rclass 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/module/classpath.c: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | VALUE 4 | class2path(VALUE klass) 5 | { 6 | VALUE path = rb_class_path(klass); 7 | const char *n; 8 | 9 | n = must_not_be_anonymous((TYPE(klass) == T_CLASS ? "class" : "module"), path); 10 | if (rb_path_to_class(path) != rb_class_real(klass)) { 11 | rb_raise(rb_eTypeError, "%s can't be referred to", n); 12 | } 13 | return path; 14 | } 15 | 16 | VALUE 17 | path2class(VALUE path) 18 | { 19 | VALUE v = rb_path_to_class(path); 20 | 21 | if (TYPE(v) != T_CLASS) { 22 | rb_raise(rb_eArgError, "%.*s does not refer to class", 23 | (int)RSTRING_LEN(path), RSTRING_PTR(path)); 24 | } 25 | return v; 26 | } 27 | 28 | VALUE 29 | path2module(VALUE path) 30 | { 31 | VALUE v = rb_path_to_class(path); 32 | 33 | if (TYPE(v) != T_MODULE) { 34 | rb_raise(rb_eArgError, "%.*s does not refer to module", 35 | (int)RSTRING_LEN(path), RSTRING_PTR(path)); 36 | } 37 | return v; 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/module/classpath.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSPATH_H 2 | #define CLASSPATH_H 3 | 4 | #include "ruby.h" 5 | 6 | VALUE class2path( 7 | 8 | ); 9 | VALUE path2class( 10 | 11 | ); 12 | VALUE path2module( 13 | 14 | ); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/module/getcfp.h: -------------------------------------------------------------------------------- 1 | #ifndef getcfp__h 2 | #define getcfp__h 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | static rb_control_frame_t * 11 | getcfp(rb_thread_t *th, rb_control_frame_t *cfp) 12 | { 13 | while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) { 14 | if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { 15 | return cfp; 16 | } 17 | cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); 18 | } 19 | return 0; 20 | } 21 | 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/node/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/node/global_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | #define global_variable rb_global_variable 7 | #define global_entry rb_global_entry 8 | #define gvar_getter_t rb_gvar_getter_t 9 | #define gvar_setter_t rb_gvar_setter_t 10 | #define gvar_marker_t rb_gvar_marker_t 11 | struct trace_var { 12 | int removed; 13 | void (*func)(VALUE arg, VALUE val); 14 | VALUE data; 15 | struct trace_var *next; 16 | }; 17 | struct global_variable { 18 | int counter; 19 | void *data; 20 | gvar_getter_t *getter; 21 | gvar_setter_t *setter; 22 | gvar_marker_t *marker; 23 | int block_trace; 24 | struct trace_var *trace; 25 | }; 26 | #define undef_getter rb_gvar_undef_getter 27 | #define undef_setter rb_gvar_undef_setter 28 | #define undef_marker rb_gvar_undef_marker 29 | #define val_getter rb_gvar_val_getter 30 | #define val_setter rb_gvar_val_setter 31 | #define val_marker rb_gvar_val_marker 32 | struct global_entry* 33 | rb_global_entry(ID id) 34 | { 35 | struct global_entry *entry; 36 | st_data_t data; 37 | 38 | if (!st_lookup(rb_global_tbl, (st_data_t)id, &data)) { 39 | struct global_variable *var; 40 | entry = ALLOC(struct global_entry); 41 | var = ALLOC(struct global_variable); 42 | entry->id = id; 43 | entry->var = var; 44 | var->counter = 1; 45 | var->data = 0; 46 | var->getter = undef_getter; 47 | var->setter = undef_setter; 48 | var->marker = undef_marker; 49 | 50 | var->block_trace = 0; 51 | var->trace = 0; 52 | st_add_direct(rb_global_tbl, id, (st_data_t)entry); 53 | } 54 | else { 55 | entry = (struct global_entry *)data; 56 | } 57 | return entry; 58 | } 59 | VALUE 60 | undef_getter(ID id, void *data, struct global_variable *var) 61 | { 62 | rb_warning("global variable `%s' not initialized", rb_id2name(id)); 63 | 64 | return Qnil; 65 | } 66 | void 67 | undef_setter(VALUE val, ID id, void *data, struct global_variable *var) 68 | { 69 | var->getter = val_getter; 70 | var->setter = val_setter; 71 | var->marker = val_marker; 72 | 73 | var->data = (void*)val; 74 | } 75 | void 76 | undef_marker(VALUE *var) 77 | { 78 | } 79 | VALUE 80 | val_getter(ID id, void *data, struct global_variable *var) 81 | { 82 | return (VALUE)data; 83 | } 84 | void 85 | val_setter(VALUE val, ID id, void *data, struct global_variable *var) 86 | { 87 | var->data = (void*)val; 88 | } 89 | void 90 | val_marker(VALUE *var) 91 | { 92 | VALUE data = (VALUE)var; 93 | if (data) rb_gc_mark_maybe(data); 94 | } 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/node/nodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | NEN_1ST, 12 | NEN_2ND, 13 | NEN_AID, 14 | NEN_ALEN, 15 | NEN_ARGC, 16 | NEN_ARGS, 17 | NEN_BEG, 18 | NEN_BODY, 19 | NEN_CFLAG, 20 | NEN_CFNC, 21 | NEN_CLSS, 22 | NEN_CNT, 23 | NEN_COND, 24 | NEN_CPATH, 25 | NEN_CVAL, 26 | NEN_DEFN, 27 | NEN_ELSE, 28 | NEN_END, 29 | NEN_ENSR, 30 | NEN_ENTRY, 31 | NEN_FRML, 32 | NEN_HEAD, 33 | NEN_ITER, 34 | NEN_LIT, 35 | NEN_MID, 36 | NEN_MODL, 37 | NEN_NEXT, 38 | NEN_NOEX, 39 | NEN_NTH, 40 | NEN_OID, 41 | NEN_OPT, 42 | NEN_ORIG, 43 | NEN_PID, 44 | NEN_PLEN, 45 | NEN_RECV, 46 | NEN_RESQ, 47 | NEN_REST, 48 | NEN_RVAL, 49 | NEN_STATE, 50 | NEN_STTS, 51 | NEN_SUPER, 52 | NEN_TAG, 53 | NEN_TBL, 54 | NEN_TVAL, 55 | NEN_VALUE, 56 | NEN_VAR, 57 | NEN_VID, 58 | NEN_VISI, 59 | }; 60 | 61 | VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash); 62 | void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash); 63 | VALUE node_s_members(VALUE klass); 64 | void define_node_subclass_methods(); 65 | 66 | #define NODE_OP_ASGN2_ARG NODE_LAST + 1 67 | #define NUM_NODE_TYPE_DESCRIPS NODE_OP_ASGN2_ARG + 1 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/proc/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/tag/tag.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/debug.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | debug.h - YARV Debug function interface 4 | 5 | $Author: akr $ 6 | created at: 04/08/25 02:33:49 JST 7 | 8 | Copyright (C) 2004-2007 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef RUBY_DEBUG_H 13 | #define RUBY_DEBUG_H 14 | 15 | #include "ruby/ruby.h" 16 | #include "node.h" 17 | 18 | #define dpv(h,v) ruby_debug_print_value(-1, 0, h, v) 19 | #define dp(v) ruby_debug_print_value(-1, 0, "", v) 20 | #define dpi(i) ruby_debug_print_id(-1, 0, "", i) 21 | #define dpn(n) ruby_debug_print_node(-1, 0, "", n) 22 | 23 | #define bp() ruby_debug_breakpoint() 24 | 25 | VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v); 26 | ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id); 27 | NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node); 28 | int ruby_debug_print_indent(int level, int debug_level, int indent_level); 29 | void ruby_debug_breakpoint(void); 30 | void ruby_debug_gc_check_func(void); 31 | 32 | #ifdef RUBY_DEBUG_ENV 33 | void ruby_set_debug_option(const char *str); 34 | #endif 35 | 36 | #endif /* RUBY_DEBUG_H */ 37 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/dln.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | dln.h - 4 | 5 | $Author: akr $ 6 | created at: Wed Jan 19 16:53:09 JST 1994 7 | 8 | Copyright (C) 1993-2007 Yukihiro Matsumoto 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef DLN_H 13 | #define DLN_H 14 | 15 | #ifdef __cplusplus 16 | # ifndef HAVE_PROTOTYPES 17 | # define HAVE_PROTOTYPES 1 18 | # endif 19 | # ifndef HAVE_STDARG_PROTOTYPES 20 | # define HAVE_STDARG_PROTOTYPES 1 21 | # endif 22 | #endif 23 | 24 | #undef _ 25 | #ifdef HAVE_PROTOTYPES 26 | # define _(args) args 27 | #else 28 | # define _(args) () 29 | #endif 30 | 31 | DEPRECATED(char *dln_find_exe(const char*,const char*)); 32 | DEPRECATED(char *dln_find_file(const char*,const char*)); 33 | char *dln_find_exe_r(const char*,const char*,char*,size_t); 34 | char *dln_find_file_r(const char*,const char*,char*,size_t); 35 | 36 | #ifdef USE_DLN_A_OUT 37 | extern char *dln_argv0; 38 | #endif 39 | 40 | void *dln_load(const char*); 41 | #endif 42 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/gc.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef RUBY_GC_H 3 | #define RUBY_GC_H 1 4 | 5 | #if defined(__x86_64__) && defined(__GNUC__) 6 | #define SET_MACHINE_STACK_END(p) __asm__("movq\t%%rsp, %0" : "=r" (*p)) 7 | #elif defined(__i386) && defined(__GNUC__) 8 | #define SET_MACHINE_STACK_END(p) __asm__("movl\t%%esp, %0" : "=r" (*p)) 9 | #else 10 | NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p)); 11 | #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p) 12 | #define USE_CONSERVATIVE_STACK_END 13 | #endif 14 | 15 | /* for GC debug */ 16 | 17 | #ifndef RUBY_MARK_FREE_DEBUG 18 | #define RUBY_MARK_FREE_DEBUG 0 19 | #endif 20 | 21 | #if RUBY_MARK_FREE_DEBUG 22 | extern int ruby_gc_debug_indent; 23 | 24 | static void 25 | rb_gc_debug_indent(void) 26 | { 27 | printf("%*s", ruby_gc_debug_indent, ""); 28 | } 29 | 30 | static void 31 | rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr) 32 | { 33 | if (st == 0) { 34 | ruby_gc_debug_indent--; 35 | } 36 | rb_gc_debug_indent(); 37 | printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr); 38 | 39 | if (st) { 40 | ruby_gc_debug_indent++; 41 | } 42 | 43 | fflush(stdout); 44 | } 45 | 46 | #define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", msg, 1, ptr) 47 | #define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", msg, 0, ptr) 48 | #define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", msg, 1, ptr) 49 | #define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", msg, 0, ptr) 50 | #define RUBY_GC_INFO rb_gc_debug_indent(); printf 51 | 52 | #else 53 | #define RUBY_MARK_ENTER(msg) 54 | #define RUBY_MARK_LEAVE(msg) 55 | #define RUBY_FREE_ENTER(msg) 56 | #define RUBY_FREE_LEAVE(msg) 57 | #define RUBY_GC_INFO if(0)printf 58 | #endif 59 | 60 | #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);} 61 | #define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;} 62 | 63 | #if STACK_GROW_DIRECTION > 0 64 | # define STACK_UPPER(x, a, b) a 65 | #elif STACK_GROW_DIRECTION < 0 66 | # define STACK_UPPER(x, a, b) b 67 | #else 68 | RUBY_EXTERN int ruby_stack_grow_direction; 69 | int ruby_get_stack_grow_direction(volatile VALUE *addr); 70 | # define stack_growup_p(x) ( \ 71 | (ruby_stack_grow_direction ? \ 72 | ruby_stack_grow_direction : \ 73 | ruby_get_stack_grow_direction(x)) > 0) 74 | # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? a : b) 75 | #endif 76 | 77 | #endif /* RUBY_GC_H */ 78 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/iseq.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | iseq.h - 4 | 5 | $Author: mame $ 6 | created at: 04/01/01 23:36:57 JST 7 | 8 | Copyright (C) 2004-2008 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef RUBY_COMPILE_H 13 | #define RUBY_COMPILE_H 14 | 15 | /* compile.c */ 16 | VALUE rb_iseq_compile_node(VALUE self, NODE *node); 17 | int rb_iseq_translate_threaded_code(rb_iseq_t *iseq); 18 | VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, 19 | VALUE exception, VALUE body); 20 | 21 | /* iseq.c */ 22 | VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt); 23 | struct st_table *ruby_insn_make_insn_table(void); 24 | 25 | #define ISEQ_TYPE_TOP INT2FIX(1) 26 | #define ISEQ_TYPE_METHOD INT2FIX(2) 27 | #define ISEQ_TYPE_BLOCK INT2FIX(3) 28 | #define ISEQ_TYPE_CLASS INT2FIX(4) 29 | #define ISEQ_TYPE_RESCUE INT2FIX(5) 30 | #define ISEQ_TYPE_ENSURE INT2FIX(6) 31 | #define ISEQ_TYPE_EVAL INT2FIX(7) 32 | #define ISEQ_TYPE_MAIN INT2FIX(8) 33 | #define ISEQ_TYPE_DEFINED_GUARD INT2FIX(9) 34 | 35 | #define CATCH_TYPE_RESCUE ((int)INT2FIX(1)) 36 | #define CATCH_TYPE_ENSURE ((int)INT2FIX(2)) 37 | #define CATCH_TYPE_RETRY ((int)INT2FIX(3)) 38 | #define CATCH_TYPE_BREAK ((int)INT2FIX(4)) 39 | #define CATCH_TYPE_REDO ((int)INT2FIX(5)) 40 | #define CATCH_TYPE_NEXT ((int)INT2FIX(6)) 41 | 42 | struct iseq_insn_info_entry { 43 | unsigned short position; 44 | unsigned short line_no; 45 | unsigned short sp; 46 | }; 47 | 48 | struct iseq_catch_table_entry { 49 | VALUE type; 50 | VALUE iseq; 51 | unsigned long start; 52 | unsigned long end; 53 | unsigned long cont; 54 | unsigned long sp; 55 | }; 56 | 57 | #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512) 58 | 59 | struct iseq_compile_data_storage { 60 | struct iseq_compile_data_storage *next; 61 | unsigned long pos; 62 | unsigned long size; 63 | char *buff; 64 | }; 65 | 66 | struct iseq_compile_data { 67 | /* GC is needed */ 68 | VALUE err_info; 69 | VALUE mark_ary; 70 | VALUE catch_table_ary; /* Array */ 71 | 72 | /* GC is not needed */ 73 | struct iseq_label_data *start_label; 74 | struct iseq_label_data *end_label; 75 | struct iseq_label_data *redo_label; 76 | VALUE current_block; 77 | VALUE ensure_node; 78 | VALUE for_iseq; 79 | struct iseq_compile_data_ensure_node_stack *ensure_node_stack; 80 | int loopval_popped; /* used by NODE_BREAK */ 81 | int cached_const; 82 | struct iseq_compile_data_storage *storage_head; 83 | struct iseq_compile_data_storage *storage_current; 84 | int last_line; 85 | int last_coverable_line; 86 | int flip_cnt; 87 | int label_no; 88 | int node_level; 89 | const rb_compile_option_t *option; 90 | }; 91 | 92 | /* defined? */ 93 | #define DEFINED_IVAR INT2FIX(1) 94 | #define DEFINED_IVAR2 INT2FIX(2) 95 | #define DEFINED_GVAR INT2FIX(3) 96 | #define DEFINED_CVAR INT2FIX(4) 97 | #define DEFINED_CONST INT2FIX(5) 98 | #define DEFINED_METHOD INT2FIX(6) 99 | #define DEFINED_YIELD INT2FIX(7) 100 | #define DEFINED_REF INT2FIX(8) 101 | #define DEFINED_ZSUPER INT2FIX(9) 102 | #define DEFINED_FUNC INT2FIX(10) 103 | 104 | #endif /* RUBY_COMPILE_H */ 105 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/method.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | method.h - 4 | 5 | $Author: ko1 $ 6 | created at: Wed Jul 15 20:02:33 2009 7 | 8 | Copyright (C) 2009 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | #ifndef METHOD_H 12 | #define METHOD_H 13 | 14 | typedef enum { 15 | NOEX_PUBLIC = 0x00, 16 | NOEX_NOSUPER = 0x01, 17 | NOEX_PRIVATE = 0x02, 18 | NOEX_PROTECTED = 0x04, 19 | NOEX_MASK = 0x06, 20 | NOEX_BASIC = 0x08, 21 | NOEX_UNDEF = NOEX_NOSUPER, 22 | NOEX_MODFUNC = 0x12, 23 | NOEX_SUPER = 0x20, 24 | NOEX_VCALL = 0x40, 25 | NOEX_RESPONDS = 0x80 26 | } rb_method_flag_t; 27 | 28 | #define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F) 29 | #define NOEX_WITH(n, s) ((s << 8) | (n) | (ruby_running ? 0 : NOEX_BASIC)) 30 | #define NOEX_WITH_SAFE(n) NOEX_WITH(n, rb_safe_level()) 31 | 32 | /* method data type */ 33 | 34 | typedef enum { 35 | VM_METHOD_TYPE_ISEQ, 36 | VM_METHOD_TYPE_CFUNC, 37 | VM_METHOD_TYPE_ATTRSET, 38 | VM_METHOD_TYPE_IVAR, 39 | VM_METHOD_TYPE_BMETHOD, 40 | VM_METHOD_TYPE_ZSUPER, 41 | VM_METHOD_TYPE_UNDEF, 42 | VM_METHOD_TYPE_NOTIMPLEMENTED, 43 | VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */ 44 | VM_METHOD_TYPE_MISSING /* wrapper for method_missing(id) */ 45 | } rb_method_type_t; 46 | 47 | typedef struct rb_method_cfunc_struct { 48 | VALUE (*func)(ANYARGS); 49 | int argc; 50 | } rb_method_cfunc_t; 51 | 52 | typedef struct rb_method_attr_struct { 53 | ID id; 54 | VALUE location; 55 | } rb_method_attr_t; 56 | 57 | typedef struct rb_iseq_struct rb_iseq_t; 58 | 59 | typedef struct rb_method_definition_struct { 60 | rb_method_type_t type; /* method type */ 61 | ID original_id; 62 | union { 63 | rb_iseq_t *iseq; /* should be mark */ 64 | rb_method_cfunc_t cfunc; 65 | rb_method_attr_t attr; 66 | VALUE proc; /* should be mark */ 67 | enum method_optimized_type { 68 | OPTIMIZED_METHOD_TYPE_SEND, 69 | OPTIMIZED_METHOD_TYPE_CALL 70 | } optimize_type; 71 | } body; 72 | int alias_count; 73 | } rb_method_definition_t; 74 | 75 | typedef struct rb_method_entry_struct { 76 | rb_method_flag_t flag; 77 | char mark; 78 | rb_method_definition_t *def; 79 | ID called_id; 80 | VALUE klass; /* should be mark */ 81 | } rb_method_entry_t; 82 | 83 | struct unlinked_method_entry_list_entry { 84 | struct unlinked_method_entry_list_entry *next; 85 | rb_method_entry_t *me; 86 | }; 87 | 88 | #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF) 89 | 90 | void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex); 91 | rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex); 92 | rb_method_entry_t *rb_method_entry(VALUE klass, ID id); 93 | 94 | rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id); 95 | rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex); 96 | 97 | int rb_method_entry_arity(const rb_method_entry_t *me); 98 | 99 | void rb_mark_method_entry(const rb_method_entry_t *me); 100 | void rb_free_method_entry(rb_method_entry_t *me); 101 | void rb_sweep_method_entry(void *vm); 102 | 103 | #endif /* METHOD_H */ 104 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/revision.h: -------------------------------------------------------------------------------- 1 | #define RUBY_REVISION 34678 2 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/thread_pthread.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | thread_pthread.h - 4 | 5 | $Author: naruse $ 6 | 7 | Copyright (C) 2004-2007 Koichi Sasada 8 | 9 | **********************************************************************/ 10 | 11 | #ifndef RUBY_THREAD_PTHREAD_H 12 | #define RUBY_THREAD_PTHREAD_H 13 | 14 | #include 15 | #ifdef HAVE_PTHREAD_NP_H 16 | #include 17 | #endif 18 | typedef pthread_t rb_thread_id_t; 19 | typedef pthread_mutex_t rb_thread_lock_t; 20 | typedef pthread_cond_t rb_thread_cond_t; 21 | 22 | typedef struct native_thread_data_struct { 23 | void *signal_thread_list; 24 | pthread_cond_t sleep_cond; 25 | } native_thread_data_t; 26 | 27 | #endif /* RUBY_THREAD_PTHREAD_H */ 28 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/thread_win32.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | thread_win32.h - 4 | 5 | $Author: akr $ 6 | 7 | Copyright (C) 2004-2007 Koichi Sasada 8 | 9 | **********************************************************************/ 10 | 11 | /* interface */ 12 | #ifndef RUBY_THREAD_WIN32_H 13 | #define RUBY_THREAD_WIN32_H 14 | 15 | #include 16 | 17 | # ifdef __CYGWIN__ 18 | # undef _WIN32 19 | # endif 20 | 21 | WINBASEAPI BOOL WINAPI 22 | TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection); 23 | 24 | typedef HANDLE rb_thread_id_t; 25 | typedef CRITICAL_SECTION rb_thread_lock_t; 26 | typedef struct rb_thread_cond_struct rb_thread_cond_t; 27 | 28 | typedef struct native_thread_data_struct { 29 | HANDLE interrupt_event; 30 | } native_thread_data_t; 31 | 32 | #endif /* RUBY_THREAD_WIN32_H */ 33 | 34 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/timev.h: -------------------------------------------------------------------------------- 1 | #ifndef RUBY_TIMEV_H 2 | #define RUBY_TIMEV_H 3 | 4 | struct vtm { 5 | VALUE year; /* 2000 for example. Integer. */ 6 | int mon; /* 1..12 */ 7 | int mday; /* 1..31 */ 8 | int hour; /* 0..23 */ 9 | int min; /* 0..59 */ 10 | int sec; /* 0..60 */ 11 | VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */ 12 | VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */ 13 | int wday; /* 0:Sunday, 1:Monday, ..., 6:Saturday */ 14 | int yday; /* 1..366 */ 15 | int isdst; /* 0:StandardTime 1:DayLightSavingTime */ 16 | const char *zone; /* "JST", "EST", "EDT", etc. */ 17 | }; 18 | 19 | #define TIME_SCALE 1000000000 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/version.h: -------------------------------------------------------------------------------- 1 | #define RUBY_VERSION "1.9.2" 2 | #define RUBY_PATCHLEVEL 318 3 | #define RUBY_VERSION_MAJOR 1 4 | #define RUBY_VERSION_MINOR 9 5 | #define RUBY_VERSION_TEENY 1 6 | 7 | #define RUBY_RELEASE_YEAR 2012 8 | #define RUBY_RELEASE_MONTH 2 9 | #define RUBY_RELEASE_DAY 14 10 | #define RUBY_RELEASE_DATE "2012-02-14" 11 | 12 | #include "ruby/version.h" 13 | 14 | #if !defined RUBY_LIB_VERSION && defined RUBY_LIB_VERSION_STYLE 15 | # if RUBY_LIB_VERSION_STYLE == 3 16 | # define RUBY_LIB_VERSION STRINGIZE(RUBY_VERSION_MAJOR)"."STRINGIZE(RUBY_VERSION_MINOR)"."STRINGIZE(RUBY_VERSION_TEENY) 17 | # elif RUBY_LIB_VERSION_STYLE == 2 18 | # define RUBY_LIB_VERSION STRINGIZE(RUBY_VERSION_MAJOR)"."STRINGIZE(RUBY_VERSION_MINOR) 19 | # endif 20 | #endif 21 | 22 | #if RUBY_PATCHLEVEL == -1 23 | #define RUBY_PATCHLEVEL_STR "dev" 24 | #else 25 | #define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL) 26 | #endif 27 | 28 | #ifndef RUBY_REVISION 29 | # include "revision.h" 30 | #endif 31 | # ifndef RUBY_REVISION 32 | # define RUBY_REVISION 0 33 | #endif 34 | 35 | #if RUBY_REVISION 36 | # ifdef RUBY_BRANCH_NAME 37 | # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION) 38 | # else 39 | # define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION) 40 | # endif 41 | #else 42 | # define RUBY_REVISION_STR "" 43 | #endif 44 | 45 | # define RUBY_DESCRIPTION \ 46 | "ruby "RUBY_VERSION \ 47 | RUBY_PATCHLEVEL_STR \ 48 | " ("RUBY_RELEASE_DATE \ 49 | RUBY_REVISION_STR") " \ 50 | "["RUBY_PLATFORM"]" 51 | # define RUBY_COPYRIGHT \ 52 | "ruby - Copyright (C) " \ 53 | STRINGIZE(RUBY_BIRTH_YEAR)"-" \ 54 | STRINGIZE(RUBY_RELEASE_YEAR)" " \ 55 | RUBY_AUTHOR 56 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.2/internal/yarv-headers/vm_opts.h: -------------------------------------------------------------------------------- 1 | /*-*-c-*-*/ 2 | /********************************************************************** 3 | 4 | vm_opts.h - VM optimize option 5 | 6 | $Author: akr $ 7 | 8 | Copyright (C) 2004-2007 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | 13 | #ifndef RUBY_VM_OPTS_H 14 | #define RUBY_VM_OPTS_H 15 | 16 | /* Compile options. 17 | * You can change these options at runtime by VM::CompileOption. 18 | * Following definitions are default values. 19 | */ 20 | 21 | #define OPT_TRACE_INSTRUCTION 1 22 | #define OPT_TAILCALL_OPTIMIZATION 0 23 | #define OPT_PEEPHOLE_OPTIMIZATION 1 24 | #define OPT_SPECIALISED_INSTRUCTION 1 25 | #define OPT_INLINE_CONST_CACHE 1 26 | 27 | 28 | /* Build Options. 29 | * You can't change these options at runtime. 30 | */ 31 | 32 | /* C compiler depend */ 33 | #define OPT_DIRECT_THREADED_CODE 1 34 | #define OPT_TOKEN_THREADED_CODE 0 35 | #define OPT_CALL_THREADED_CODE 0 36 | 37 | /* VM running option */ 38 | #define OPT_CHECKED_RUN 1 39 | #define OPT_INLINE_METHOD_CACHE 1 40 | #define OPT_BLOCKINLINING 0 41 | 42 | /* architecture independent, affects generated code */ 43 | #define OPT_OPERANDS_UNIFICATION 0 44 | #define OPT_INSTRUCTIONS_UNIFICATION 0 45 | #define OPT_UNIFY_ALL_COMBINATION 0 46 | #define OPT_STACK_CACHING 0 47 | 48 | /* misc */ 49 | #define SUPPORT_JOKE 0 50 | 51 | #endif /* RUBY_VM_OPTS_H */ 52 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/binding/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/method/internal_method.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_method__h_ 2 | #define ruby_internal_method__h_ 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | struct METHOD { 21 | VALUE recv; 22 | VALUE rclass; 23 | ID id; 24 | rb_method_entry_t *me; 25 | struct unlinked_method_entry_list_entry *ume; 26 | }; 27 | 28 | #define METHOD_OCLASS(m) m->klass 29 | #define METHOD_RCLASS(m) m->rclass 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/module/classpath.c: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | VALUE 4 | class2path(VALUE klass) 5 | { 6 | VALUE path = rb_class_path(klass); 7 | const char *n; 8 | 9 | n = must_not_be_anonymous((TYPE(klass) == T_CLASS ? "class" : "module"), path); 10 | if (rb_path_to_class(path) != rb_class_real(klass)) { 11 | rb_raise(rb_eTypeError, "%s can't be referred to", n); 12 | } 13 | return path; 14 | } 15 | 16 | VALUE 17 | path2class(VALUE path) 18 | { 19 | VALUE v = rb_path_to_class(path); 20 | 21 | if (TYPE(v) != T_CLASS) { 22 | rb_raise(rb_eArgError, "%.*s does not refer to class", 23 | (int)RSTRING_LEN(path), RSTRING_PTR(path)); 24 | } 25 | return v; 26 | } 27 | 28 | VALUE 29 | path2module(VALUE path) 30 | { 31 | VALUE v = rb_path_to_class(path); 32 | 33 | if (TYPE(v) != T_MODULE) { 34 | rb_raise(rb_eArgError, "%.*s does not refer to module", 35 | (int)RSTRING_LEN(path), RSTRING_PTR(path)); 36 | } 37 | return v; 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/module/classpath.h: -------------------------------------------------------------------------------- 1 | #ifndef CLASSPATH_H 2 | #define CLASSPATH_H 3 | 4 | #include "ruby.h" 5 | 6 | VALUE class2path( 7 | 8 | ); 9 | VALUE path2class( 10 | 11 | ); 12 | VALUE path2module( 13 | 14 | ); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/module/getcfp.h: -------------------------------------------------------------------------------- 1 | #ifndef getcfp__h 2 | #define getcfp__h 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | static rb_control_frame_t * 11 | getcfp(rb_thread_t *th, rb_control_frame_t *cfp) 12 | { 13 | while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) { 14 | if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { 15 | return cfp; 16 | } 17 | cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); 18 | } 19 | return 0; 20 | } 21 | 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/node/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/node/global_entry.h: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | #define global_variable rb_global_variable 7 | #define global_entry rb_global_entry 8 | #define gvar_getter_t rb_gvar_getter_t 9 | #define gvar_setter_t rb_gvar_setter_t 10 | #define gvar_marker_t rb_gvar_marker_t 11 | struct trace_var { 12 | int removed; 13 | void (*func)(VALUE arg, VALUE val); 14 | VALUE data; 15 | struct trace_var *next; 16 | }; 17 | struct global_variable { 18 | int counter; 19 | void *data; 20 | gvar_getter_t *getter; 21 | gvar_setter_t *setter; 22 | gvar_marker_t *marker; 23 | int block_trace; 24 | struct trace_var *trace; 25 | }; 26 | #define undef_getter rb_gvar_undef_getter 27 | #define undef_setter rb_gvar_undef_setter 28 | #define undef_marker rb_gvar_undef_marker 29 | #define val_getter rb_gvar_val_getter 30 | #define val_setter rb_gvar_val_setter 31 | #define val_marker rb_gvar_val_marker 32 | struct global_entry* 33 | rb_global_entry(ID id) 34 | { 35 | struct global_entry *entry; 36 | st_data_t data; 37 | 38 | if (!st_lookup(rb_global_tbl, (st_data_t)id, &data)) { 39 | struct global_variable *var; 40 | entry = ALLOC(struct global_entry); 41 | var = ALLOC(struct global_variable); 42 | entry->id = id; 43 | entry->var = var; 44 | var->counter = 1; 45 | var->data = 0; 46 | var->getter = undef_getter; 47 | var->setter = undef_setter; 48 | var->marker = undef_marker; 49 | 50 | var->block_trace = 0; 51 | var->trace = 0; 52 | st_add_direct(rb_global_tbl, id, (st_data_t)entry); 53 | } 54 | else { 55 | entry = (struct global_entry *)data; 56 | } 57 | return entry; 58 | } 59 | VALUE 60 | undef_getter(ID id, void *data, struct global_variable *var) 61 | { 62 | rb_warning("global variable `%s' not initialized", rb_id2name(id)); 63 | 64 | return Qnil; 65 | } 66 | void 67 | undef_setter(VALUE val, ID id, void *data, struct global_variable *var) 68 | { 69 | var->getter = val_getter; 70 | var->setter = val_setter; 71 | var->marker = val_marker; 72 | 73 | var->data = (void*)val; 74 | } 75 | void 76 | undef_marker(VALUE *var) 77 | { 78 | } 79 | VALUE 80 | val_getter(ID id, void *data, struct global_variable *var) 81 | { 82 | return (VALUE)data; 83 | } 84 | void 85 | val_setter(VALUE val, ID id, void *data, struct global_variable *var) 86 | { 87 | var->data = (void*)val; 88 | } 89 | void 90 | val_marker(VALUE *var) 91 | { 92 | VALUE data = (VALUE)var; 93 | if (data) rb_gc_mark_maybe(data); 94 | } 95 | 96 | #endif 97 | 98 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/node/nodeinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | NEN_1ST, 12 | NEN_2ND, 13 | NEN_AID, 14 | NEN_ALEN, 15 | NEN_ARGC, 16 | NEN_ARGS, 17 | NEN_BEG, 18 | NEN_BODY, 19 | NEN_CFLAG, 20 | NEN_CFNC, 21 | NEN_CLSS, 22 | NEN_CNT, 23 | NEN_COND, 24 | NEN_CPATH, 25 | NEN_CVAL, 26 | NEN_DEFN, 27 | NEN_ELSE, 28 | NEN_END, 29 | NEN_ENSR, 30 | NEN_ENTRY, 31 | NEN_FRML, 32 | NEN_HEAD, 33 | NEN_ITER, 34 | NEN_LIT, 35 | NEN_MID, 36 | NEN_MODL, 37 | NEN_NEXT, 38 | NEN_NOEX, 39 | NEN_NTH, 40 | NEN_OID, 41 | NEN_OPT, 42 | NEN_ORIG, 43 | NEN_PID, 44 | NEN_PLEN, 45 | NEN_RECV, 46 | NEN_RESQ, 47 | NEN_REST, 48 | NEN_RVAL, 49 | NEN_STATE, 50 | NEN_STTS, 51 | NEN_SUPER, 52 | NEN_TAG, 53 | NEN_TBL, 54 | NEN_TVAL, 55 | NEN_VALUE, 56 | NEN_VAR, 57 | NEN_VID, 58 | NEN_VISI, 59 | }; 60 | 61 | VALUE dump_node_elem(enum Node_Elem_Name nen, NODE * n, VALUE node_hash); 62 | void load_node_elem(enum Node_Elem_Name nen, VALUE v, NODE * n, VALUE node_hash, VALUE id_hash); 63 | VALUE node_s_members(VALUE klass); 64 | void define_node_subclass_methods(); 65 | 66 | #define NODE_OP_ASGN2_ARG NODE_LAST + 1 67 | #define NUM_NODE_TYPE_DESCRIPS NODE_OP_ASGN2_ARG + 1 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/proc/block.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/tag/tag.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/addr2line.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | addr2line.h - 4 | 5 | $Author$ 6 | 7 | Copyright (C) 2010 Shinichiro Hamaji 8 | 9 | **********************************************************************/ 10 | 11 | #ifndef RUBY_ADDR2LINE_H 12 | #define RUBY_ADDR2LINE_H 13 | 14 | #ifdef USE_ELF 15 | 16 | void 17 | rb_dump_backtrace_with_lines(int num_traces, void **traces, char **syms); 18 | 19 | #endif /* USE_ELF */ 20 | 21 | #endif /* RUBY_ADDR2LINE_H */ 22 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/atomic.h: -------------------------------------------------------------------------------- 1 | #ifndef RUBY_ATOMIC_H 2 | #define RUBY_ATOMIC_H 3 | 4 | #ifdef _WIN32 5 | #if defined _MSC_VER && _MSC_VER > 1200 6 | #pragma intrinsic(_InterlockedOr) 7 | #endif 8 | typedef LONG rb_atomic_t; 9 | 10 | # define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val)) 11 | # define ATOMIC_INC(var) InterlockedIncrement(&(var)) 12 | # define ATOMIC_DEC(var) InterlockedDecrement(&(var)) 13 | #if defined __GNUC__ 14 | # define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val)) 15 | #elif defined _MSC_VER && _MSC_VER <= 1200 16 | # define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val)) 17 | static inline void 18 | rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val) 19 | { 20 | #ifdef _M_IX86 21 | __asm mov eax, var; 22 | __asm mov ecx, val; 23 | __asm lock or [eax], ecx; 24 | #else 25 | #error unsupported architecture 26 | #endif 27 | } 28 | #else 29 | # define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val)) 30 | #endif 31 | # define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val)) 32 | 33 | #elif defined HAVE_GCC_ATOMIC_BUILTINS 34 | /* @shyouhei hack to support atomic operations in case of gcc. Gcc 35 | * has its own pseudo-insns to support them. See info, or 36 | * http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */ 37 | 38 | typedef unsigned int rb_atomic_t; /* Anything OK */ 39 | # define ATOMIC_SET(var, val) __sync_lock_test_and_set(&(var), (val)) 40 | # define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1) 41 | # define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1) 42 | # define ATOMIC_OR(var, val) __sync_or_and_fetch(&(var), (val)) 43 | # define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) 44 | 45 | #else 46 | typedef int rb_atomic_t; 47 | extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val); 48 | 49 | # define ATOMIC_SET(var, val) ((var) = (val)) 50 | # define ATOMIC_INC(var) (++(var)) 51 | # define ATOMIC_DEC(var) (--(var)) 52 | # define ATOMIC_OR(var, val) ((var) |= (val)) 53 | # define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val)) 54 | #endif 55 | 56 | #endif /* RUBY_ATOMIC_H */ 57 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/constant.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | constant.h - 4 | 5 | $Author$ 6 | created at: Sun Nov 15 00:09:33 2009 7 | 8 | Copyright (C) 2009 Yusuke Endoh 9 | 10 | **********************************************************************/ 11 | #ifndef CONSTANT_H 12 | #define CONSTANT_H 13 | 14 | typedef enum { 15 | CONST_PUBLIC = 0x00, 16 | CONST_PRIVATE = 0x01 17 | } rb_const_flag_t; 18 | 19 | typedef struct rb_const_entry_struct { 20 | rb_const_flag_t flag; 21 | VALUE value; /* should be mark */ 22 | } rb_const_entry_t; 23 | 24 | VALUE rb_mod_private_constant(int argc, VALUE *argv, VALUE obj); 25 | VALUE rb_mod_public_constant(int argc, VALUE *argv, VALUE obj); 26 | void rb_free_const_table(st_table *tbl); 27 | VALUE rb_public_const_get(VALUE klass, ID id); 28 | VALUE rb_public_const_get_at(VALUE klass, ID id); 29 | VALUE rb_public_const_get_from(VALUE klass, ID id); 30 | int rb_public_const_defined(VALUE klass, ID id); 31 | int rb_public_const_defined_at(VALUE klass, ID id); 32 | int rb_public_const_defined_from(VALUE klass, ID id); 33 | 34 | #endif /* CONSTANT_H */ 35 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/debug.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | debug.h - YARV Debug function interface 4 | 5 | $Author: akr $ 6 | created at: 04/08/25 02:33:49 JST 7 | 8 | Copyright (C) 2004-2007 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef RUBY_DEBUG_H 13 | #define RUBY_DEBUG_H 14 | 15 | #include "ruby/ruby.h" 16 | #include "node.h" 17 | 18 | #if defined __GNUC__ && __GNUC__ >= 4 19 | #pragma GCC visibility push(default) 20 | #endif 21 | 22 | #define dpv(h,v) ruby_debug_print_value(-1, 0, (h), (v)) 23 | #define dp(v) ruby_debug_print_value(-1, 0, "", (v)) 24 | #define dpi(i) ruby_debug_print_id(-1, 0, "", (i)) 25 | #define dpn(n) ruby_debug_print_node(-1, 0, "", (n)) 26 | 27 | #define bp() ruby_debug_breakpoint() 28 | 29 | VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v); 30 | ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id); 31 | NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node); 32 | int ruby_debug_print_indent(int level, int debug_level, int indent_level); 33 | void ruby_debug_breakpoint(void); 34 | void ruby_debug_gc_check_func(void); 35 | void ruby_set_debug_option(const char *str); 36 | 37 | #if defined __GNUC__ && __GNUC__ >= 4 38 | #pragma GCC visibility pop 39 | #endif 40 | 41 | #endif /* RUBY_DEBUG_H */ 42 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/dln.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | dln.h - 4 | 5 | $Author: nobu $ 6 | created at: Wed Jan 19 16:53:09 JST 1994 7 | 8 | Copyright (C) 1993-2007 Yukihiro Matsumoto 9 | 10 | **********************************************************************/ 11 | 12 | #ifndef DLN_H 13 | #define DLN_H 14 | 15 | #ifdef __cplusplus 16 | # ifndef HAVE_PROTOTYPES 17 | # define HAVE_PROTOTYPES 1 18 | # endif 19 | # ifndef HAVE_STDARG_PROTOTYPES 20 | # define HAVE_STDARG_PROTOTYPES 1 21 | # endif 22 | #endif 23 | 24 | #undef _ 25 | #ifdef HAVE_PROTOTYPES 26 | # define _(args) args 27 | #else 28 | # define _(args) () 29 | #endif 30 | 31 | #if defined __GNUC__ && __GNUC__ >= 4 32 | #pragma GCC visibility push(default) 33 | #endif 34 | 35 | DEPRECATED(char *dln_find_exe(const char*,const char*)); 36 | DEPRECATED(char *dln_find_file(const char*,const char*)); 37 | char *dln_find_exe_r(const char*,const char*,char*,size_t); 38 | char *dln_find_file_r(const char*,const char*,char*,size_t); 39 | 40 | #ifdef USE_DLN_A_OUT 41 | extern char *dln_argv0; 42 | #endif 43 | 44 | void *dln_load(const char*); 45 | 46 | #if defined __GNUC__ && __GNUC__ >= 4 47 | #pragma GCC visibility pop 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/gc.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef RUBY_GC_H 3 | #define RUBY_GC_H 1 4 | 5 | #if defined(__x86_64__) && defined(__GNUC__) 6 | #define SET_MACHINE_STACK_END(p) __asm__("movq\t%%rsp, %0" : "=r" (*(p))) 7 | #elif defined(__i386) && defined(__GNUC__) 8 | #define SET_MACHINE_STACK_END(p) __asm__("movl\t%%esp, %0" : "=r" (*(p))) 9 | #else 10 | NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p)); 11 | #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p) 12 | #define USE_CONSERVATIVE_STACK_END 13 | #endif 14 | 15 | /* for GC debug */ 16 | 17 | #ifndef RUBY_MARK_FREE_DEBUG 18 | #define RUBY_MARK_FREE_DEBUG 0 19 | #endif 20 | 21 | #if RUBY_MARK_FREE_DEBUG 22 | extern int ruby_gc_debug_indent; 23 | 24 | static inline void 25 | rb_gc_debug_indent(void) 26 | { 27 | printf("%*s", ruby_gc_debug_indent, ""); 28 | } 29 | 30 | static inline void 31 | rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr) 32 | { 33 | if (st == 0) { 34 | ruby_gc_debug_indent--; 35 | } 36 | rb_gc_debug_indent(); 37 | printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr); 38 | 39 | if (st) { 40 | ruby_gc_debug_indent++; 41 | } 42 | 43 | fflush(stdout); 44 | } 45 | 46 | #define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", (msg), 1, ptr) 47 | #define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr) 48 | #define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr) 49 | #define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr) 50 | #define RUBY_GC_INFO rb_gc_debug_indent(); printf 51 | 52 | #else 53 | #define RUBY_MARK_ENTER(msg) 54 | #define RUBY_MARK_LEAVE(msg) 55 | #define RUBY_FREE_ENTER(msg) 56 | #define RUBY_FREE_LEAVE(msg) 57 | #define RUBY_GC_INFO if(0)printf 58 | #endif 59 | 60 | #define RUBY_MARK_UNLESS_NULL(ptr) if(RTEST(ptr)){rb_gc_mark(ptr);} 61 | #define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;} 62 | 63 | #if STACK_GROW_DIRECTION > 0 64 | # define STACK_UPPER(x, a, b) (a) 65 | #elif STACK_GROW_DIRECTION < 0 66 | # define STACK_UPPER(x, a, b) (b) 67 | #else 68 | RUBY_EXTERN int ruby_stack_grow_direction; 69 | int ruby_get_stack_grow_direction(volatile VALUE *addr); 70 | # define stack_growup_p(x) ( \ 71 | (ruby_stack_grow_direction ? \ 72 | ruby_stack_grow_direction : \ 73 | ruby_get_stack_grow_direction(x)) > 0) 74 | # define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b)) 75 | #endif 76 | 77 | #if STACK_GROW_DIRECTION 78 | #define STACK_GROW_DIR_DETECTION 79 | #define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b)) 80 | #else 81 | #define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection 82 | #define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b)) 83 | #endif 84 | 85 | #if defined __GNUC__ && __GNUC__ >= 4 86 | #pragma GCC visibility push(default) 87 | #endif 88 | 89 | size_t rb_objspace_data_type_memsize(VALUE obj); 90 | void rb_objspace_each_objects( 91 | int (*callback)(void *start, void *end, size_t stride, void *data), 92 | void *data); 93 | 94 | #if defined __GNUC__ && __GNUC__ >= 4 95 | #pragma GCC visibility pop 96 | #endif 97 | 98 | #endif /* RUBY_GC_H */ 99 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/revision.h: -------------------------------------------------------------------------------- 1 | #define RUBY_REVISION 35410 2 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/thread_pthread.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | thread_pthread.h - 4 | 5 | $Author: kosaki $ 6 | 7 | Copyright (C) 2004-2007 Koichi Sasada 8 | 9 | **********************************************************************/ 10 | 11 | #ifndef RUBY_THREAD_PTHREAD_H 12 | #define RUBY_THREAD_PTHREAD_H 13 | 14 | #include 15 | #ifdef HAVE_PTHREAD_NP_H 16 | #include 17 | #endif 18 | typedef pthread_t rb_thread_id_t; 19 | typedef pthread_mutex_t rb_thread_lock_t; 20 | 21 | typedef struct rb_thread_cond_struct { 22 | pthread_cond_t cond; 23 | #ifdef HAVE_CLOCKID_T 24 | clockid_t clockid; 25 | #endif 26 | } rb_thread_cond_t; 27 | 28 | typedef struct native_thread_data_struct { 29 | void *signal_thread_list; 30 | rb_thread_cond_t sleep_cond; 31 | } native_thread_data_t; 32 | 33 | #include 34 | 35 | typedef struct rb_global_vm_lock_struct { 36 | /* fast path */ 37 | unsigned long acquired; 38 | pthread_mutex_t lock; 39 | 40 | /* slow path */ 41 | volatile unsigned long waiting; 42 | rb_thread_cond_t cond; 43 | 44 | /* yield */ 45 | rb_thread_cond_t switch_cond; 46 | rb_thread_cond_t switch_wait_cond; 47 | int need_yield; 48 | int wait_yield; 49 | } rb_global_vm_lock_t; 50 | 51 | #endif /* RUBY_THREAD_PTHREAD_H */ 52 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/thread_win32.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | 3 | thread_win32.h - 4 | 5 | $Author: kosaki $ 6 | 7 | Copyright (C) 2004-2007 Koichi Sasada 8 | 9 | **********************************************************************/ 10 | 11 | /* interface */ 12 | #ifndef RUBY_THREAD_WIN32_H 13 | #define RUBY_THREAD_WIN32_H 14 | 15 | #include 16 | 17 | # ifdef __CYGWIN__ 18 | # undef _WIN32 19 | # endif 20 | 21 | WINBASEAPI BOOL WINAPI 22 | TryEnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection); 23 | 24 | typedef HANDLE rb_thread_id_t; 25 | typedef CRITICAL_SECTION rb_thread_lock_t; 26 | typedef struct rb_thread_cond_struct { 27 | struct cond_event_entry *next; 28 | struct cond_event_entry *prev; 29 | } rb_thread_cond_t; 30 | 31 | typedef struct native_thread_data_struct { 32 | HANDLE interrupt_event; 33 | } native_thread_data_t; 34 | 35 | typedef struct rb_global_vm_lock_struct { 36 | HANDLE lock; 37 | } rb_global_vm_lock_t; 38 | 39 | #endif /* RUBY_THREAD_WIN32_H */ 40 | 41 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/timev.h: -------------------------------------------------------------------------------- 1 | #ifndef RUBY_TIMEV_H 2 | #define RUBY_TIMEV_H 3 | 4 | struct vtm { 5 | VALUE year; /* 2000 for example. Integer. */ 6 | int mon; /* 1..12 */ 7 | int mday; /* 1..31 */ 8 | int hour; /* 0..23 */ 9 | int min; /* 0..59 */ 10 | int sec; /* 0..60 */ 11 | VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */ 12 | VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */ 13 | int wday; /* 0:Sunday, 1:Monday, ..., 6:Saturday */ 14 | int yday; /* 1..366 */ 15 | int isdst; /* 0:StandardTime 1:DayLightSavingTime */ 16 | const char *zone; /* "JST", "EST", "EDT", etc. */ 17 | }; 18 | 19 | #define TIME_SCALE 1000000000 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/version.h: -------------------------------------------------------------------------------- 1 | #define RUBY_VERSION "1.9.3" 2 | #define RUBY_PATCHLEVEL 194 3 | 4 | #define RUBY_RELEASE_DATE "2012-04-20" 5 | #define RUBY_RELEASE_YEAR 2012 6 | #define RUBY_RELEASE_MONTH 4 7 | #define RUBY_RELEASE_DAY 20 8 | 9 | #include "ruby/version.h" 10 | 11 | #if !defined RUBY_LIB_VERSION && defined RUBY_LIB_VERSION_STYLE 12 | # if RUBY_LIB_VERSION_STYLE == 3 13 | # define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR)"."STRINGIZE(RUBY_API_VERSION_TEENY) 14 | # elif RUBY_LIB_VERSION_STYLE == 2 15 | # define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR) 16 | # endif 17 | #endif 18 | 19 | #if RUBY_PATCHLEVEL == -1 20 | #define RUBY_PATCHLEVEL_STR "dev" 21 | #else 22 | #define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL) 23 | #endif 24 | 25 | #ifndef RUBY_REVISION 26 | # include "revision.h" 27 | #endif 28 | # ifndef RUBY_REVISION 29 | # define RUBY_REVISION 0 30 | #endif 31 | 32 | #if RUBY_REVISION 33 | # ifdef RUBY_BRANCH_NAME 34 | # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION) 35 | # else 36 | # define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION) 37 | # endif 38 | #else 39 | # define RUBY_REVISION_STR "" 40 | #endif 41 | 42 | # define RUBY_DESCRIPTION \ 43 | "ruby "RUBY_VERSION \ 44 | RUBY_PATCHLEVEL_STR \ 45 | " ("RUBY_RELEASE_DATE \ 46 | RUBY_REVISION_STR") " \ 47 | "["RUBY_PLATFORM"]" 48 | # define RUBY_COPYRIGHT \ 49 | "ruby - Copyright (C) " \ 50 | STRINGIZE(RUBY_BIRTH_YEAR)"-" \ 51 | STRINGIZE(RUBY_RELEASE_YEAR)" " \ 52 | RUBY_AUTHOR 53 | -------------------------------------------------------------------------------- /ext/cached/ruby-1.9.3/internal/yarv-headers/vm_opts.h: -------------------------------------------------------------------------------- 1 | /*-*-c-*-*/ 2 | /********************************************************************** 3 | 4 | vm_opts.h - VM optimize option 5 | 6 | $Author: akr $ 7 | 8 | Copyright (C) 2004-2007 Koichi Sasada 9 | 10 | **********************************************************************/ 11 | 12 | 13 | #ifndef RUBY_VM_OPTS_H 14 | #define RUBY_VM_OPTS_H 15 | 16 | /* Compile options. 17 | * You can change these options at runtime by VM::CompileOption. 18 | * Following definitions are default values. 19 | */ 20 | 21 | #define OPT_TRACE_INSTRUCTION 1 22 | #define OPT_TAILCALL_OPTIMIZATION 0 23 | #define OPT_PEEPHOLE_OPTIMIZATION 1 24 | #define OPT_SPECIALISED_INSTRUCTION 1 25 | #define OPT_INLINE_CONST_CACHE 1 26 | 27 | 28 | /* Build Options. 29 | * You can't change these options at runtime. 30 | */ 31 | 32 | /* C compiler depend */ 33 | #define OPT_DIRECT_THREADED_CODE 1 34 | #define OPT_TOKEN_THREADED_CODE 0 35 | #define OPT_CALL_THREADED_CODE 0 36 | 37 | /* VM running option */ 38 | #define OPT_CHECKED_RUN 1 39 | #define OPT_INLINE_METHOD_CACHE 1 40 | #define OPT_BLOCKINLINING 0 41 | 42 | /* architecture independent, affects generated code */ 43 | #define OPT_OPERANDS_UNIFICATION 0 44 | #define OPT_INSTRUCTIONS_UNIFICATION 0 45 | #define OPT_UNIFY_ALL_COMBINATION 0 46 | #define OPT_STACK_CACHING 0 47 | 48 | /* misc */ 49 | #define SUPPORT_JOKE 0 50 | 51 | #endif /* RUBY_VM_OPTS_H */ 52 | -------------------------------------------------------------------------------- /ext/generate_cached.rb: -------------------------------------------------------------------------------- 1 | require 'rubypp' 2 | require 'fileutils' 3 | 4 | dir = ARGV[0] 5 | $:.unshift(dir) 6 | 7 | # Unset RUBY_VERSION 8 | class Object 9 | remove_const :RUBY_VERSION 10 | end 11 | 12 | # Figure out the Ruby version and set RUBY_VERSION to fool the scripts 13 | # we'll be calling 14 | File.open(File.join(dir, 'version.h')) do |version_h| 15 | version_h.each_line do |line| 16 | # #define RUBY_VERSION "1.6.4" 17 | if line =~ /#define RUBY_VERSION \"(.*?)\"/ then 18 | RUBY_VERSION = $1 19 | end 20 | end 21 | end 22 | 23 | # Set RUBY_SORUCE_DIR to the directory specified on the command line 24 | RUBY_SOURCE_DIR = dir 25 | $".push('ruby_source_dir.rb') 26 | 27 | ruby_include_path = File.join(RUBY_SOURCE_DIR, 'include') 28 | if not File.exist?(ruby_include_path) or \ 29 | not File.directory?(ruby_include_path) then 30 | # pre-YARV 31 | ruby_include_path = RUBY_SOURCE_DIR 32 | end 33 | RUBY_INCLUDE_DIR = ruby_include_path 34 | 35 | # Figure out where we're going to spit output 36 | output_dir = File.expand_path("cached/ruby-#{RUBY_VERSION}") 37 | basedir = File.expand_path(File.dirname(__FILE__)) 38 | 39 | def generate_cached_rpp(input_rpp, output_dir) 40 | FileUtils.mkdir_p(output_dir) 41 | input_dir = File.dirname(input_rpp) 42 | base = File.basename(input_rpp.gsub(/(.*)\..*/, "\\1")) 43 | out = File.join(output_dir, base) 44 | orig_dir = Dir.pwd 45 | begin 46 | Dir.chdir(input_dir) 47 | rubypp(input_rpp, out) 48 | ensure 49 | Dir.chdir(orig_dir) 50 | end 51 | end 52 | 53 | def recursively_generate_cached_rpps(input_dir, output_dir) 54 | Dir[File.join(input_dir, '*')].each do |file| 55 | next if file == '.' or file == '..' 56 | if File.directory?(file) then 57 | recursively_generate_cached_rpps( 58 | file, 59 | File.join(output_dir, File.basename(file))) 60 | end 61 | end 62 | 63 | Dir[File.join(input_dir, '*.rpp')].each do |rpp| 64 | generate_cached_rpp(rpp, output_dir) 65 | end 66 | end 67 | 68 | $stdout.puts "Generating cached files for ruby-#{RUBY_VERSION}" 69 | 70 | recursively_generate_cached_rpps( 71 | File.join(basedir, 'internal'), 72 | File.join(output_dir, 'internal')) 73 | 74 | ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i 75 | if ruby_version_code >= 190 then 76 | yarv_header_output_dir = 77 | File.join(output_dir, 'internal', 'yarv-headers') 78 | FileUtils.mkdir_p(yarv_header_output_dir) 79 | FileUtils.cp(Dir["#{RUBY_SOURCE_DIR}/*.h"], yarv_header_output_dir) 80 | end 81 | 82 | -------------------------------------------------------------------------------- /ext/generate_cached.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dir="$1" 4 | 5 | if [ -z "$dir" ]; then 6 | dir=~/.rvm/src 7 | fi 8 | 9 | if [ ! -d "$dir" ]; then 10 | echo "$dir not found" 11 | echo "Usage: $0 " 12 | echo "where is the directory where the untarred ruby source archives can be found." 13 | exit 1 14 | fi 15 | 16 | dirs=`ls -1 -d "$dir"/ruby-?.?.? "$dir"/ruby-?.?.?-p*` 17 | dirs=`echo $dirs | sort` 18 | 19 | for dir in $dirs; do 20 | ruby generate_cached.rb "$dir" 21 | done 22 | 23 | -------------------------------------------------------------------------------- /ext/internal/.gitignore: -------------------------------------------------------------------------------- 1 | yarv-headers 2 | -------------------------------------------------------------------------------- /ext/internal/binding/.gitignore: -------------------------------------------------------------------------------- 1 | block.h 2 | -------------------------------------------------------------------------------- /ext/internal/binding/binding.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "internal/node/ruby_internal_node.h" 3 | #include "block.h" 4 | 5 | #ifdef RUBY_VM 6 | #include "vm_core.h" 7 | #endif 8 | 9 | /* 10 | * call-seq: 11 | * binding.body => Binding 12 | * 13 | * Given a Binding, returns the Node for that Binding's body. 14 | * 15 | * On YARV, this will returning the Binding's instruction sequence. 16 | */ 17 | static VALUE binding_body(VALUE self) 18 | { 19 | #ifdef RUBY_VM 20 | rb_binding_t * binding; 21 | rb_env_t * env; 22 | GetBindingPtr(self, binding); 23 | GetEnvPtr(binding->env, env); 24 | return env->block.iseq->self; 25 | #else 26 | struct BLOCK * b; 27 | if(rb_safe_level() >= 4) 28 | { 29 | /* no access to potentially sensitive data from the sandbox */ 30 | rb_raise(rb_eSecurityError, "Insecure: can't get binding body"); 31 | } 32 | Data_Get_Struct(self, struct BLOCK, b); 33 | return wrap_node(b->body); 34 | #endif 35 | } 36 | 37 | void Init_binding(void) 38 | { 39 | rb_require("internal/node"); 40 | 41 | /* For rdoc: rb_cBinding = rb_define_class("Binding", rb_cObject) */ 42 | VALUE rb_cBinding = rb_const_get(rb_cObject, rb_intern("Binding")); 43 | rb_define_method(rb_cBinding, "body", binding_body, 0); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /ext/internal/binding/block.h.rpp: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | #ruby < 5 | 6 | #ifdef RUBY_VM 7 | #include "method.h" 8 | #endif 9 | 10 | #include "internal/node/ruby_internal_node.h" 11 | 12 | #ifndef FALSE 13 | #define FALSE 0 14 | #endif 15 | 16 | #ifndef TRUE 17 | #define TRUE (!FALSE) 18 | #endif 19 | 20 | #ruby <#{oclass_member} 65 | #define METHOD_RCLASS(m) m->#{rclass_member} 66 | END 67 | 68 | nil 69 | END 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /ext/internal/module/.gitignore: -------------------------------------------------------------------------------- 1 | classpath.c 2 | classpath.h 3 | getcfp.h 4 | -------------------------------------------------------------------------------- /ext/internal/module/classpath.c.rpp: -------------------------------------------------------------------------------- 1 | #include "classpath.h" 2 | 3 | #ruby < 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | #ruby <len 10 | #endif 11 | 12 | #ifndef RARRAY_PTR 13 | #define RARRAY_PTR(a) RARRAY(a)->ptr 14 | #endif 15 | 16 | #ifndef RSTRING_LEN 17 | #define RSTRING_LEN(a) RSTRING(a)->len 18 | #endif 19 | 20 | #ifndef RSTRING_PTR 21 | #define RSTRING_PTR(a) RSTRING(a)->ptr 22 | #endif 23 | 24 | #ifndef RCLASS_SUPER 25 | #define RCLASS_SUPER(c) RCLASS(c)->super 26 | #endif 27 | 28 | #ifndef RCLASS_IV_TBL 29 | #define RCLASS_IV_TBL(c) RCLASS(c)->iv_tbl 30 | #endif 31 | 32 | #ifndef RCLASS_M_TBL 33 | #define RCLASS_M_TBL(c) RCLASS(c)->m_tbl 34 | #endif 35 | 36 | #ifndef NEW_NODE 37 | #define NEW_NODE(t,a0,a1,a2) \ 38 | rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2)) 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ext/internal/node/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../..' 2 | require 'mkmf-ruby-internal' 3 | 4 | have_type('st_data_t', [ 'ruby.h', 'st.h' ]) or 5 | have_type('st_data_t', [ 'ruby.h', 'ruby/st.h']) 6 | 7 | have_const('NODE_ALLOCA', [ 'ruby.h', 'node.h' ]) or 8 | have_const('NODE_ALLOCA', [ 'ruby.h', 'ruby/node.h' ]) 9 | 10 | have_func('rb_protect_inspect', 'ruby.h') 11 | have_func('rb_obj_respond_to', 'ruby.h') 12 | have_func('rb_define_alloc_func', 'ruby.h') 13 | have_func('rb_is_local_id', 'ruby.h') 14 | have_func('rb_source_filename', 'ruby.h') 15 | 16 | checking_for("ruby_top_cref") do 17 | if try_link(<<-END) then 18 | #include 19 | extern void * ruby_top_cref; 20 | int main() { printf("%p\\n", ruby_top_cref); return 0; } 21 | END 22 | $defs.push "-DHAVE_RUBY_TOP_CREF" 23 | end 24 | end 25 | 26 | checking_for("ruby_cref") do 27 | if try_link(<<-END) then 28 | #include 29 | extern void * ruby_cref; 30 | int main() { printf("%p\\n", ruby_cref); return 0; } 31 | END 32 | $defs.push "-DHAVE_RUBY_CREF" 33 | end 34 | end 35 | 36 | have_header('iseq.h') 37 | 38 | ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i 39 | $CPPFLAGS << " -DRUBY_VERSION_CODE=#{ruby_version_code}" 40 | 41 | have_header('ruby/node.h') or have_header('node.h') 42 | 43 | have_type('struct RTypedData') 44 | 45 | create_ruby_internal_makefile 'internal/node/node' 46 | 47 | -------------------------------------------------------------------------------- /ext/internal/node/global_entry.h.rpp: -------------------------------------------------------------------------------- 1 | #ifndef global_entry__h_ 2 | #define global_entry__h_ 3 | 4 | st_table * rb_global_tbl; 5 | 6 | #ruby <nt != NODE_LAST; 45 | ++descrip) 46 | { 47 | if(node_type_descrips[descrip->nt]) 48 | { 49 | rb_raise(rb_eRuntimeError, "duplicate entry for node type %d (%s is also %s)\n", descrip->nt, descrip->name, node_type_descrips[descrip->nt]->name); 50 | } 51 | else 52 | { 53 | node_type_descrips[descrip->nt] = descrip; 54 | } 55 | } 56 | node_type_descrips_initialized = 1; 57 | } 58 | } 59 | 60 | /* Given a node, find out the types of the three elements it contains */ 61 | Node_Type_Descrip const * node_type_descrip(enum node_type nt) 62 | { 63 | init_node_type_descrips(); 64 | if(node_type_descrips[nt]) 65 | { 66 | return node_type_descrips[nt]; 67 | } 68 | else 69 | { 70 | rb_raise(rb_eArgError, "Unknown node type %d", nt); 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /ext/internal/node/node_type_descrip.h: -------------------------------------------------------------------------------- 1 | #ifndef node_type_descrip__h 2 | #define node_type_descrip__h 3 | 4 | #include "nodeinfo.h" 5 | 6 | typedef struct { 7 | enum node_type nt; 8 | enum Node_Elem_Name n1; 9 | enum Node_Elem_Name n2; 10 | enum Node_Elem_Name n3; 11 | char const * name; 12 | } Node_Type_Descrip; 13 | 14 | Node_Type_Descrip const * node_type_descrip(enum node_type nt); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /ext/internal/node/node_type_descrip.rb: -------------------------------------------------------------------------------- 1 | $: << '../..' 2 | require 'ruby_source_dir' 3 | require 'nodes' 4 | 5 | NODE_TYPE_DESCRIPS = [] 6 | 7 | ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i 8 | 9 | nodes = Nodes.new 10 | nodes.each do |name, node| 11 | members = node['members'] || {} 12 | version_range = node['version_range'] 13 | if version_range.includes?(ruby_version_code) then 14 | node_name = node['name'].upcase 15 | member_names = [ 16 | (members.keys[0] || 'NONE').upcase, 17 | (members.keys[1] || 'NONE').upcase, 18 | (members.keys[2] || 'NONE').upcase, 19 | ] 20 | NODE_TYPE_DESCRIPS << [ node_name, *member_names ] 21 | end 22 | end 23 | 24 | NODE_TYPE_DESCRIPS.concat [ 25 | [ 'LAST' , 'NONE' , 'NONE' , 'NONE' ], 26 | ] 27 | 28 | Node_Type_Descrip = Struct.new(:name, :node1, :node2, :node3) 29 | 30 | NODE_TYPE_DESCRIPS.map! { |x| Node_Type_Descrip.new(*x) } 31 | 32 | NEN_TO_NODE_TYPE = {} 33 | NODE_TYPE_DESCRIPS.each do |descrip| 34 | [descrip.node1, descrip.node2, descrip.node3].each do |nen| 35 | NEN_TO_NODE_TYPE[nen] ||= [] 36 | NEN_TO_NODE_TYPE[nen] << descrip.name 37 | end 38 | end 39 | 40 | -------------------------------------------------------------------------------- /ext/internal/node/nodeinfo.h.rpp: -------------------------------------------------------------------------------- 1 | #ifndef nodeinfo_h 2 | #define nodeinfo_h 3 | 4 | #include "ruby_internal_node.h" 5 | 6 | #include "ruby.h" 7 | 8 | enum Node_Elem_Name 9 | { 10 | NEN_NONE, 11 | #ruby < @range_end 29 | else 30 | return false if version_code >= @range_end 31 | end 32 | 33 | return true 34 | end 35 | end 36 | 37 | class Nodes 38 | NodeInfo = Struct.new(:name, :doc, :members, :version_range) 39 | MemberInfo = Struct.new(:doc, :type) 40 | 41 | def initialize(filename = nil) 42 | if not filename then 43 | dir = File.dirname(__FILE__) 44 | filename = File.join(dir, 'nodes.yaml') 45 | end 46 | nodes = File.open(filename) { |io| YAML.load(io) } 47 | 48 | @nodes = {} 49 | nodes.each do |name, node| 50 | members = {} 51 | # TODO: is there any way to enforce order here? 52 | (node['members'] || {}).each do |member_name, member| 53 | member ||= {} 54 | members[member_name] = MemberInfo.new( 55 | member['doc'], 56 | member['type']) 57 | end 58 | version_range = NodeVersionRange.new(node['version']) 59 | @nodes[name] = NodeInfo.new( 60 | name.gsub(/\(.*\)/, ''), 61 | node['doc'], 62 | members, 63 | version_range) 64 | end 65 | end 66 | 67 | def each(&block) 68 | @nodes.sort.each(&block) 69 | end 70 | 71 | def [](name) 72 | @nodes[name] 73 | end 74 | 75 | def include?(name) 76 | @nodes.include?(name) 77 | end 78 | end 79 | 80 | -------------------------------------------------------------------------------- /ext/internal/node/read_node_h.rb: -------------------------------------------------------------------------------- 1 | $: << '../..' 2 | require 'ruby_source_dir' 3 | 4 | NODE_H_LOCATION = "#{RUBY_INCLUDE_DIR}/node.h" 5 | NODE_H_ALT_LOCATION = "#{RUBY_SOURCE_DIR}/node.h" 6 | 7 | def open_alt(*files, &block) 8 | last_exc = nil 9 | files.each do |file| 10 | begin 11 | File.open(file, &block) 12 | return 13 | rescue Errno::ENOENT 14 | last_exc = $! 15 | end 16 | end 17 | raise last_exc 18 | end 19 | 20 | NODEINFO = Hash.new 21 | open_alt(NODE_H_LOCATION, NODE_H_ALT_LOCATION) do |node_h| 22 | while line = node_h.gets do 23 | case line 24 | when /^#define\s+nd_(\w+)\s+(.*)/ 25 | NODEINFO[$1] = $2 26 | end 27 | end 28 | end 29 | 30 | if __FILE__ == $0 then 31 | require 'pp' 32 | pp NODEINFO 33 | end 34 | 35 | -------------------------------------------------------------------------------- /ext/internal/node/ruby_internal_node.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_node__h_ 2 | #define ruby_internal_node__h_ 3 | 4 | #include 5 | 6 | #if defined(HAVE_NODE_H) 7 | #include "node.h" 8 | #elif defined(HAVE_RUBY_NODE_H) 9 | #include "ruby/node.h" 10 | #endif 11 | 12 | VALUE wrap_node(NODE * n); 13 | VALUE wrap_node_as(NODE * n, VALUE klass); 14 | 15 | NODE * unwrap_node(VALUE r); 16 | 17 | VALUE node_id(NODE * n); 18 | NODE * id_to_node(VALUE id); 19 | 20 | VALUE eval_ruby_node(NODE * node, VALUE self, VALUE cref); 21 | 22 | void dump_node_or_iseq_to_hash(VALUE n, int node_type, VALUE node_hash); 23 | VALUE load_node_or_iseq_from_hash(VALUE node_id, VALUE node_hash, VALUE id_hash); 24 | 25 | void dump_node_to_hash(NODE * n, int node_type, VALUE node_hash); 26 | NODE * load_node_from_hash(VALUE arr, VALUE orig_node_id, VALUE node_hash, VALUE id_hash); 27 | 28 | extern VALUE rb_cNodeSubclass[NODE_LAST]; 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /ext/internal/noex/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../..' 2 | require 'mkmf-ruby-internal' 3 | 4 | have_header('ruby/node.h') or have_header('node.h') 5 | 6 | create_ruby_internal_makefile 'internal/noex/noex' 7 | -------------------------------------------------------------------------------- /ext/internal/noex/noex.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "internal/node/ruby_internal_node.h" 4 | 5 | #ifdef RUBY_VM 6 | #include "method.h" 7 | #endif 8 | 9 | void Init_noex(void) 10 | { 11 | /* 12 | * Document-module: Noex 13 | * 14 | * The Noex module contains all the Noex constants from node.h. These 15 | * constants can be passed to Module#add_method as modifiers to the 16 | * method being added. 17 | * 18 | * [+PUBLIC+] Method is public. 19 | * [+UNDEF+] Method is undefined. 20 | * [+PRIVATE+] Method is private. 21 | * [+PROTECTED+] Method is protected. 22 | * 23 | * The following are available in Ruby 1.8 and below: 24 | * [+CFUNC+] Method is a C function. 25 | * 26 | * And these are available in Ruby 1.9 and above: 27 | * [+NOSUPER+] ??? 28 | * [+MASK+] ??? 29 | */ 30 | VALUE rb_mNoex = rb_define_module("Noex"); 31 | rb_define_const(rb_mNoex, "PUBLIC", INT2NUM(NOEX_PUBLIC)); 32 | rb_define_const(rb_mNoex, "UNDEF", INT2NUM(NOEX_UNDEF)); 33 | rb_define_const(rb_mNoex, "PRIVATE", INT2NUM(NOEX_PRIVATE)); 34 | rb_define_const(rb_mNoex, "PROTECTED", INT2NUM(NOEX_PROTECTED)); 35 | 36 | #ifdef NOEX_CFUNC 37 | rb_define_const(rb_mNoex, "CFUNC", INT2NUM(NOEX_CFUNC)); 38 | #endif 39 | 40 | #ifdef NOEX_NOSUPER 41 | rb_define_const(rb_mNoex, "NOSUPER", INT2NUM(NOEX_NOSUPER)); 42 | #endif 43 | 44 | #ifdef NOEX_MASK 45 | rb_define_const(rb_mNoex, "MASK", INT2NUM(NOEX_MASK)); 46 | #endif 47 | } 48 | 49 | -------------------------------------------------------------------------------- /ext/internal/object/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../..' 2 | require 'mkmf-ruby-internal' 3 | 4 | create_ruby_internal_makefile 'internal/object/object' 5 | -------------------------------------------------------------------------------- /ext/internal/object/object.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * call-seq: 5 | * class.real_class => Class 6 | * 7 | * Return the object's first immediate ancestor; this may be the 8 | * object's class, its singleton class, or a module singleton. 9 | */ 10 | static VALUE real_class(VALUE self) 11 | { 12 | if(IMMEDIATE_P(self)) 13 | { 14 | return CLASS_OF(self); 15 | } 16 | else 17 | { 18 | return RBASIC(self)->klass; 19 | } 20 | } 21 | 22 | /* 23 | * call-seq: 24 | * class.singleton? => true or false 25 | * 26 | * Return true if this object is a singleton (that is, it has the 27 | * FL_SINGLETON flag set). 28 | */ 29 | static VALUE is_singleton(VALUE self) 30 | { 31 | return FL_TEST(self, FL_SINGLETON) ? Qtrue : Qfalse; 32 | } 33 | 34 | /* 35 | * call-seq: 36 | * class.has_singleton? => true or false 37 | * 38 | * Return true if this object has a singleton class. 39 | */ 40 | static VALUE has_singleton(VALUE self) 41 | { 42 | if(FIXNUM_P(self) || SYMBOL_P(self)) 43 | { 44 | return Qfalse; 45 | } 46 | else if(rb_special_const_p(self)) 47 | { 48 | return Qtrue; 49 | } 50 | else 51 | { 52 | return FL_TEST(RBASIC(self)->klass, FL_SINGLETON) ? Qtrue : Qfalse; 53 | } 54 | } 55 | 56 | /* 57 | * call-seq: 58 | * class.singleton_class => Class 59 | * 60 | * Return the object's singleton class. Creats a new singleton class 61 | * for the object if it does not have one. See RCR#231. 62 | */ 63 | static VALUE singleton_class(VALUE self) 64 | { 65 | return rb_singleton_class(self); 66 | } 67 | 68 | void Init_object(void) 69 | { 70 | rb_define_method(rb_mKernel, "real_class", real_class, 0); 71 | rb_define_method(rb_mKernel, "singleton?", is_singleton, 0); 72 | rb_define_method(rb_mKernel, "has_singleton?", has_singleton, 0); 73 | rb_define_method(rb_mKernel, "singleton_class", singleton_class, 0); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /ext/internal/proc/.gitignore: -------------------------------------------------------------------------------- 1 | block.h 2 | -------------------------------------------------------------------------------- /ext/internal/proc/block.h.rpp: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_block__h_ 2 | #define ruby_internal_block__h_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | #ruby < 2 | #include "tag.h" 3 | 4 | void Init_tag() 5 | { 6 | VALUE rb_mTag = rb_define_module("Tag"); 7 | rb_define_const(rb_mTag, "RETURN", INT2NUM(TAG_RETURN)); 8 | rb_define_const(rb_mTag, "BREAK", INT2NUM(TAG_BREAK)); 9 | rb_define_const(rb_mTag, "NEXT", INT2NUM(TAG_NEXT)); 10 | rb_define_const(rb_mTag, "RETRY", INT2NUM(TAG_RETRY)); 11 | rb_define_const(rb_mTag, "REDO", INT2NUM(TAG_REDO)); 12 | rb_define_const(rb_mTag, "RAISE", INT2NUM(TAG_RAISE)); 13 | rb_define_const(rb_mTag, "THROW", INT2NUM(TAG_THROW)); 14 | rb_define_const(rb_mTag, "FATAL", INT2NUM(TAG_FATAL)); 15 | rb_define_const(rb_mTag, "MASK", INT2NUM(TAG_MASK)); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /ext/internal/tag/tag.h.rpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "eval_intern.h" 5 | #endif 6 | 7 | #ruby < 2 | 3 | #ifdef RUBY_VM 4 | #include "vm_core.h" 5 | #include "eval_intern.h" 6 | #include "internal/vm/control_frame/control_frame.h" 7 | #endif 8 | 9 | #ifdef RUBY_VM 10 | 11 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 12 | 13 | # undef GetThreadPtr 14 | # define GetThreadPtr(obj, ptr) \ 15 | TypedData_Get_Struct((obj), rb_thread_t, p_ruby_threadptr_data_type, (ptr)) 16 | 17 | static rb_data_type_t const * p_ruby_threadptr_data_type; 18 | 19 | static void init_ruby_threadptr_data_type() 20 | { 21 | VALUE thread = rb_thread_current(); 22 | p_ruby_threadptr_data_type = RTYPEDDATA_TYPE(thread); 23 | } 24 | 25 | #endif 26 | 27 | static VALUE rb_cVmControlFrame; 28 | 29 | /* TODO: also defined in control_frame.c */ 30 | void mark_ruby_internal_control_frame( 31 | struct RubyInternalControlFrame * cfp) 32 | { 33 | rb_gc_mark(cfp->thread); 34 | } 35 | 36 | /* 37 | * call-seq: 38 | * thread.cfp = RubyVM::ControlFrame 39 | * 40 | * Returns the thread's control frame. 41 | */ 42 | static VALUE thread_cfp(VALUE self) 43 | { 44 | rb_thread_t * th; 45 | rb_control_frame_t * prev_cfp; 46 | 47 | GetThreadPtr(self, th); 48 | 49 | /* TODO: Not sure how many control frames back to go to get the one we 50 | * want */ 51 | prev_cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); 52 | if((void *)(th->stack + th->stack_size) == (void *)prev_cfp) 53 | { 54 | return Qnil; 55 | } 56 | else 57 | { 58 | struct RubyInternalControlFrame * cfp; 59 | VALUE cfp_v; 60 | 61 | cfp_v = Data_Make_Struct( 62 | rb_cVmControlFrame, 63 | struct RubyInternalControlFrame, 64 | mark_ruby_internal_control_frame, 65 | free, 66 | cfp); 67 | 68 | cfp->control_frame = prev_cfp; 69 | cfp->thread = self; 70 | 71 | return cfp_v; 72 | } 73 | } 74 | 75 | /* For Ludicrous */ 76 | void * ruby_current_thread_jmp_buf() 77 | { 78 | /* jmp_buf is guaranteed to be an array type that can decay to a 79 | * pointer */ 80 | VALUE thread = rb_thread_current(); 81 | rb_thread_t * th; 82 | GetThreadPtr(thread, th); 83 | return th->tag->buf; 84 | } 85 | 86 | /* For Ludicrous */ 87 | void * ruby_current_thread_tag(void * tag) 88 | { 89 | VALUE thread = rb_thread_current(); 90 | rb_thread_t * th; 91 | GetThreadPtr(thread, th); 92 | return th->tag; 93 | } 94 | 95 | /* For Ludicrous */ 96 | void ruby_set_current_thread_tag(void * tag) 97 | { 98 | VALUE thread = rb_thread_current(); 99 | rb_thread_t * th; 100 | GetThreadPtr(thread, th); 101 | th->tag = tag; 102 | } 103 | 104 | #endif 105 | 106 | void Init_thread(void) 107 | { 108 | /* For rdoc: rb_cThread = rb_define_class("Thread", rb_cObject); */ 109 | 110 | #ifdef RUBY_VM 111 | VALUE rb_cRubyVM; 112 | 113 | rb_require("internal/vm/control_frame"); 114 | 115 | if(!rb_const_defined(rb_cObject, rb_intern("RubyVM"))) 116 | { 117 | rb_define_const( 118 | rb_cObject, 119 | "RubyVM", 120 | rb_const_get(rb_cObject, rb_intern("VM"))); 121 | } 122 | 123 | rb_cRubyVM = rb_define_class("RubyVM", rb_cObject); 124 | rb_cVmControlFrame = rb_const_get(rb_cRubyVM, rb_intern("ControlFrame")); 125 | 126 | rb_define_method(rb_cThread, "cfp", thread_cfp, 0); 127 | #endif 128 | 129 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 130 | init_ruby_threadptr_data_type(); 131 | #endif 132 | } 133 | 134 | -------------------------------------------------------------------------------- /ext/internal/vm/constants/constants.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | #include "vm_core.h" 5 | #endif 6 | 7 | void Init_constants(void) 8 | { 9 | #ifdef RUBY_VM 10 | VALUE rb_cRubyVM; 11 | 12 | if(!rb_const_defined(rb_cObject, rb_intern("RubyVM"))) 13 | { 14 | rb_define_const( 15 | rb_cObject, 16 | "RubyVM", 17 | rb_const_get(rb_cObject, rb_intern("VM"))); 18 | } 19 | 20 | rb_cRubyVM = rb_define_class("RubyVM", rb_cObject); 21 | rb_define_const(rb_cRubyVM, "CALL_ARGS_SPLAT_BIT", INT2NUM(VM_CALL_ARGS_SPLAT_BIT)); 22 | rb_define_const(rb_cRubyVM, "CALL_ARGS_BLOCKARG_BIT", INT2NUM(VM_CALL_ARGS_BLOCKARG_BIT)); 23 | rb_define_const(rb_cRubyVM, "CALL_FCALL_BIT", INT2NUM(VM_CALL_FCALL_BIT)); 24 | rb_define_const(rb_cRubyVM, "CALL_VCALL_BIT", INT2NUM(VM_CALL_VCALL_BIT)); 25 | rb_define_const(rb_cRubyVM, "CALL_TAILCALL_BIT", INT2NUM(VM_CALL_TAILCALL_BIT)); 26 | rb_define_const(rb_cRubyVM, "CALL_TAILRECURSION_BIT", INT2NUM(VM_CALL_TAILRECURSION_BIT)); 27 | rb_define_const(rb_cRubyVM, "CALL_SUPER_BIT", INT2NUM(VM_CALL_SUPER_BIT)); 28 | #ifdef HAVE_RUBY_CALL_SEND_BIT 29 | rb_define_const(rb_cRubyVM, "CALL_SEND_BIT", INT2NUM(VM_CALL_SEND_BIT)); 30 | #endif 31 | rb_define_const(rb_cRubyVM, "SPECIAL_OBJECT_VMCORE", INT2NUM(VM_SPECIAL_OBJECT_VMCORE)); 32 | rb_define_const(rb_cRubyVM, "SPECIAL_OBJECT_CBASE", INT2NUM(VM_SPECIAL_OBJECT_CBASE)); 33 | #endif 34 | } 35 | 36 | -------------------------------------------------------------------------------- /ext/internal/vm/constants/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../../..' 2 | require 'mkmf-ruby-internal' 3 | create_ruby_internal_makefile 'internal/vm/constants/constants' 4 | 5 | have_const('VM_CALL_SEND_BIT', [ 'ruby.h', 'vm_core.h' ]) 6 | -------------------------------------------------------------------------------- /ext/internal/vm/control_frame/control_frame.h: -------------------------------------------------------------------------------- 1 | #ifndef RUBY_INTERNAL__VM__CONTROL_FRAME__CONTROL_FRAME_H 2 | #define RUBY_INTERNAL__VM__CONTROL_FRAME__CONTROL_FRAME_H 3 | 4 | #include 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | struct RubyInternalControlFrame 11 | { 12 | rb_control_frame_t * control_frame; 13 | VALUE thread; 14 | }; 15 | 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /ext/internal/vm/control_frame/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../../..' 2 | require 'mkmf-ruby-internal' 3 | 4 | ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i 5 | $CPPFLAGS << " -DRUBY_VERSION_CODE=#{ruby_version_code}" 6 | 7 | have_type('struct RTypedData') 8 | 9 | create_ruby_internal_makefile 'internal/vm/control_frame/control_frame' 10 | -------------------------------------------------------------------------------- /ext/internal/vm/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../..' 2 | require 'mkmf-ruby-internal' 3 | have_type('struct RTypedData') 4 | create_ruby_internal_makefile 'internal/vm/vm' 5 | -------------------------------------------------------------------------------- /ext/internal/vm/inline_cache/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../../..' 2 | require 'mkmf-ruby-internal' 3 | 4 | have_header('ruby/node.h') or have_header('node.h') 5 | 6 | create_ruby_internal_makefile 'internal/vm/inline_cache/inline_cache' 7 | -------------------------------------------------------------------------------- /ext/internal/vm/inline_cache/inline_cache.c: -------------------------------------------------------------------------------- 1 | #include "internal/node/ruby_internal_node.h" 2 | #include "internal/node/nodeinfo.h" 3 | #include 4 | 5 | #ifdef RUBY_VM 6 | 7 | #include "vm_core.h" 8 | 9 | /* 10 | * call-seq: 11 | * inline_cache.class => nil 12 | * 13 | * Currently returns nil, because returning the real class can cause the 14 | * interpreter to crash. 15 | */ 16 | static VALUE inline_cache_klass(VALUE self) 17 | { 18 | IC inline_cache = (IC)unwrap_node(self); 19 | if (inline_cache->ic_class == Qundef) 20 | { 21 | return Qnil; 22 | } 23 | else 24 | { 25 | return inline_cache->ic_class; 26 | } 27 | } 28 | 29 | /* 30 | * call-seq: 31 | * inline_cache.value => Object 32 | * 33 | * Returns the ic_cache member of the inline cache. 34 | */ 35 | static VALUE inline_cache_value(VALUE self) 36 | { 37 | /* TODO: Wrap the LABEL object (from compile.c) */ 38 | return Qnil; 39 | } 40 | 41 | /* 42 | * call-seq: 43 | * inline_cache.vmstat => object 44 | * 45 | * Returns the ic_vmstat member of the inline cache. 46 | */ 47 | static VALUE inline_cache_vmstat(VALUE self) 48 | { 49 | IC inline_cache = (IC)unwrap_node(self); 50 | return INT2NUM(inline_cache->ic_vmstat); 51 | } 52 | 53 | #endif 54 | 55 | void Init_inline_cache(void) 56 | { 57 | #ifdef RUBY_VM 58 | VALUE rb_cNode; 59 | VALUE rb_cRubyVM; 60 | 61 | rb_require("internal/node/node"); 62 | 63 | rb_cNode = rb_define_class("Node", rb_cObject); 64 | 65 | if(!rb_const_defined(rb_cObject, rb_intern("RubyVM"))) 66 | { 67 | rb_define_const( 68 | rb_cObject, 69 | "RubyVM", 70 | rb_const_get(rb_cObject, rb_intern("VM"))); 71 | } 72 | 73 | rb_cRubyVM = rb_define_class("RubyVM", rb_cObject); 74 | VALUE rb_cInlineCache = rb_define_class_under(rb_cRubyVM, "InlineCache", rb_cNode); 75 | rb_define_method(rb_cInlineCache, "klass", inline_cache_klass, 0); 76 | rb_define_method(rb_cInlineCache, "value", inline_cache_value, 0); 77 | rb_define_method(rb_cInlineCache, "vmstat", inline_cache_vmstat, 0); 78 | VALUE inline_cache_members = rb_ary_new(); 79 | rb_ary_push(inline_cache_members, rb_str_new2("klass")); 80 | rb_ary_push(inline_cache_members, rb_str_new2("value")); 81 | rb_ary_push(inline_cache_members, rb_str_new2("vmstat")); 82 | rb_iv_set(rb_cInlineCache, "__member__", inline_cache_members); 83 | rb_define_singleton_method(rb_cInlineCache, "members", node_s_members, 0); 84 | #endif 85 | } 86 | 87 | -------------------------------------------------------------------------------- /ext/internal/vm/instruction/.gitignore: -------------------------------------------------------------------------------- 1 | insns_info.c 2 | insns_info.h 3 | -------------------------------------------------------------------------------- /ext/internal/vm/instruction/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../../..' 2 | require 'mkmf-ruby-internal' 3 | 4 | have_header('vm.h') 5 | 6 | create_ruby_internal_makefile 'internal/vm/instruction/instruction' 7 | -------------------------------------------------------------------------------- /ext/internal/vm/instruction/insns_info.h.rpp: -------------------------------------------------------------------------------- 1 | #ifndef insns_info__h_ 2 | #define insns_info__h_ 3 | 4 | #include "ruby.h" 5 | 6 | #ifdef RUBY_VM 7 | 8 | #include "vm_core.h" 9 | 10 | #ifdef HAVE_VM_H 11 | #include "vm.h" 12 | #endif 13 | 14 | #ruby < 4 | 5 | #ifndef RARRAY_LEN 6 | #define RARRAY_LEN(a) RARRAY(a)->len 7 | #endif 8 | 9 | #ifndef RARRAY_PTR 10 | #define RARRAY_PTR(a) RARRAY(a)->ptr 11 | #endif 12 | 13 | #ifdef RUBY_VM 14 | 15 | /* 16 | * call-seq: 17 | * Instruction.new(*operands) => Instruction 18 | * 19 | * Create a new instruction with the given operands. 20 | */ 21 | static VALUE instruction_initialize(int argc, VALUE * argv, VALUE self) 22 | { 23 | VALUE operands = rb_ary_new4(argc, argv); 24 | rb_iv_set(self, "@operands", operands); 25 | return Qnil; 26 | } 27 | 28 | /* 29 | * call-seq: 30 | * instruction.operands => Array 31 | * 32 | * Returns the instructions operands. 33 | */ 34 | static VALUE instruction_operands(VALUE self) 35 | { 36 | return rb_iv_get(self, "@operands"); 37 | } 38 | 39 | VALUE allocate_instruction(int instruction, VALUE args) 40 | { 41 | return rb_class_new_instance( 42 | RARRAY_LEN(args), 43 | RARRAY_PTR(args), 44 | instruction_class[instruction]); 45 | } 46 | 47 | #endif 48 | 49 | void Init_instruction(void) 50 | { 51 | #ifdef RUBY_VM 52 | VALUE rb_cRubyVM; 53 | VALUE rb_cInstruction; 54 | 55 | if(!rb_const_defined(rb_cObject, rb_intern("RubyVM"))) 56 | { 57 | rb_define_const( 58 | rb_cObject, 59 | "RubyVM", 60 | rb_const_get(rb_cObject, rb_intern("VM"))); 61 | } 62 | 63 | rb_cRubyVM = rb_define_class("RubyVM", rb_cObject); 64 | 65 | rb_cInstruction = rb_define_class_under(rb_cRubyVM, "Instruction", rb_cObject); 66 | rb_define_method(rb_cInstruction, "initialize", instruction_initialize, -1); 67 | rb_define_method(rb_cInstruction, "operands", instruction_operands, 0); 68 | rb_undef_method(rb_cInstruction, "new"); 69 | 70 | define_instruction_subclasses(rb_cInstruction); 71 | 72 | /* Silence compiler warnings about unused static functions */ 73 | insn_name(0); 74 | insn_op_type(0, 0); 75 | insn_op_types(0); 76 | #endif 77 | } 78 | 79 | -------------------------------------------------------------------------------- /ext/internal/vm/instruction/instruction.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_vm__instruction__h_ 2 | #define ruby_internal_vm__instruction__h_ 3 | 4 | #ifdef RUBY_VM 5 | 6 | VALUE allocate_instruction(int instruction, VALUE args); 7 | 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /ext/internal/vm/iseq/.gitignore: -------------------------------------------------------------------------------- 1 | insns_info.inc 2 | iseq_load.inc 3 | -------------------------------------------------------------------------------- /ext/internal/vm/iseq/extconf.rb: -------------------------------------------------------------------------------- 1 | $: << '../../..' 2 | require 'mkmf-ruby-internal' 3 | 4 | have_header('iseq.h') 5 | have_header('ruby/node.h') or have_header('node.h') 6 | have_type('struct RTypedData') 7 | 8 | create_ruby_internal_makefile 'internal/vm/iseq/iseq' 9 | -------------------------------------------------------------------------------- /ext/internal/vm/iseq/insns_info.inc.rpp: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_insns_info__inc_ 2 | #define ruby_internal_insns_info__inc_ 3 | 4 | #include 5 | 6 | #ifndef RUBY_VM 7 | #include "env.h" 8 | #endif 9 | 10 | #ruby <= 190 then 14 | 15 | $: << '../../..' 16 | require 'ruby_source_dir' 17 | insns_info_location = "#{RUBY_SOURCE_DIR}/insns_info.inc" 18 | 19 | File.open(insns_info_location) do |input| 20 | input.each_line do |line| 21 | puts line 22 | end 23 | end 24 | end 25 | 26 | nil 27 | END 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /ext/internal/vm/iseq/internal_iseq.h: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_vm__internal_iseq_h_ 2 | #define ruby_internal_vm__internal_iseq_h_ 3 | 4 | #include 5 | 6 | void dump_iseq_to_hash(VALUE iseq, VALUE node_hash); 7 | VALUE load_iseq_from_hash(VALUE iseq, VALUE orig_node_id, VALUE node_hash, VALUE id_hash); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /ext/internal/vm/iseq/iseq_load.inc.rpp: -------------------------------------------------------------------------------- 1 | #ifndef ruby_internal_iseq_load__inc_ 2 | #define ruby_internal_iseq_load__inc_ 3 | 4 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 5 | 6 | static rb_data_type_t const * p_iseq_data_type; 7 | 8 | static void init_iseq_data_type() 9 | { 10 | rb_proc_t * p; 11 | VALUE body; 12 | 13 | VALUE binding = rb_binding_new(); 14 | VALUE new_proc = rb_funcall( 15 | rb_cObject, rb_intern("eval"), 2, rb_str_new2("proc { }"), binding); 16 | GetProcPtr(new_proc, p); 17 | body = p->block.iseq->self; 18 | 19 | p_iseq_data_type = RTYPEDDATA_TYPE(body); 20 | } 21 | 22 | #else 23 | 24 | #endif 25 | # 26 | #ruby <= 191 then 30 | 31 | $: << '../../..' 32 | require 'ruby_source_dir' 33 | iseq_c_location = "#{RUBY_SOURCE_DIR}/iseq.c" 34 | 35 | write = false 36 | stopwrite = false 37 | prev_line = nil 38 | File.open(iseq_c_location) do |input| 39 | input.each_line do |line| 40 | case line 41 | when /^(iseq_load|iseq_alloc|iseq_mark|iseq_free|compile_data_free|make_compile_option|make_compile_option_value|prepare_iseq_build|cleanup_iseq_build|set_relation|iseq_memsize)/ 42 | write = true 43 | puts prev_line 44 | when /^static.*COMPILE_OPTION_DEFAULT.*=/ 45 | write = true 46 | when /^static.*COMPILE_OPTION_FALSE.*=/ 47 | write = true 48 | stopwrite = true 49 | when /TypedData_Make_Struct.*\&iseq_data_type/ 50 | line.gsub!(/\&iseq_data_type/, 'p_iseq_data_type') 51 | when /^#define CHECK_/, 52 | /^static inline VALUE CHECK_/ 53 | write = true 54 | stopwrite = true 55 | when /^\}/ 56 | stopwrite = true 57 | end 58 | puts line if write 59 | if stopwrite then 60 | write = false 61 | stopwrite = false 62 | end 63 | prev_line = line 64 | end 65 | end 66 | 67 | elsif ruby_version_code >= 190 then 68 | 69 | puts <<-END 70 | 71 | /* Defined but not declared by ruby */ 72 | VALUE iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt); 73 | 74 | END 75 | 76 | end 77 | 78 | nil 79 | END 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /ext/internal/vm/vm.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef RUBY_VM 4 | 5 | #include "vm_core.h" 6 | 7 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 8 | 9 | # undef GetThreadPtr 10 | # define GetThreadPtr(obj, ptr) \ 11 | TypedData_Get_Struct((obj), rb_thread_t, p_ruby_threadptr_data_type, (ptr)) 12 | 13 | static rb_data_type_t const * p_ruby_threadptr_data_type; 14 | 15 | static void init_ruby_threadptr_data_type() 16 | { 17 | VALUE thread = rb_thread_current(); 18 | p_ruby_threadptr_data_type = RTYPEDDATA_TYPE(thread); 19 | } 20 | 21 | #endif 22 | 23 | extern rb_vm_t * ruby_current_vm; 24 | 25 | /* 26 | * call-seq: 27 | * RubyVM.current => RubyVM 28 | * 29 | * Returns the current ruby VM. 30 | */ 31 | static VALUE vm_current(VALUE klass) 32 | { 33 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 34 | VALUE thread = rb_thread_current(); 35 | rb_thread_t * th; 36 | ID * local_tbl; 37 | GetThreadPtr(thread, th); 38 | return th->vm->self; 39 | #else 40 | return ruby_current_vm->self; 41 | #endif 42 | } 43 | 44 | /* 45 | * call-seq: 46 | * ruby_vm.top_self 47 | * 48 | * Returns the VM's "top self". 49 | */ 50 | static VALUE vm_top_self(VALUE self) 51 | { 52 | rb_vm_t * vm; 53 | 54 | Data_Get_Struct(self, rb_vm_t, vm); 55 | 56 | return vm->top_self; 57 | } 58 | 59 | #endif 60 | 61 | void Init_vm(void) 62 | { 63 | #ifdef RUBY_VM 64 | VALUE rb_cRubyVM; 65 | 66 | if(!rb_const_defined(rb_cObject, rb_intern("RubyVM"))) 67 | { 68 | rb_define_const( 69 | rb_cObject, 70 | "RubyVM", 71 | rb_const_get(rb_cObject, rb_intern("VM"))); 72 | } 73 | 74 | rb_cRubyVM = rb_define_class("RubyVM", rb_cObject); 75 | rb_define_singleton_method(rb_cRubyVM, "current", vm_current, 0); 76 | rb_define_method(rb_cRubyVM, "top_self", vm_top_self, 0); 77 | #endif 78 | 79 | #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA 80 | init_ruby_threadptr_data_type(); 81 | #endif 82 | } 83 | 84 | -------------------------------------------------------------------------------- /ext/ruby_source_dir.rb: -------------------------------------------------------------------------------- 1 | wd = Dir.pwd() 2 | metaconfig_dir = File.join(File.dirname(__FILE__), '..') 3 | Dir.chdir metaconfig_dir 4 | begin 5 | $: << '.' # TODO: hack 6 | require 'setup' 7 | require 'rbconfig' 8 | if not defined?(RbConfig) then 9 | RbConfig = Config 10 | end 11 | config = ConfigTable.new(RbConfig::CONFIG) 12 | config.load_standard_entries 13 | config.load_script 'metaconfig' 14 | config.load_savefile 15 | ensure 16 | Dir.chdir(wd) 17 | end 18 | 19 | RUBY_SOURCE_DIR = config['ruby-source-path'] 20 | RUBY_INCLUDE_DIR = config['ruby-include-path'] 21 | USING_CACHED_FILES = config['cached-files'] == 'yes' 22 | 23 | if __FILE__ == $0 then 24 | puts "Using cached files: #{USING_CACHED_FILES}" 25 | puts "Ruby source dir: #{RUBY_SOURCE_DIR}" 26 | puts "Ruby include dir: #{RUBY_INCLUDE_DIR}" 27 | end 28 | 29 | -------------------------------------------------------------------------------- /generate_rdoc.rb: -------------------------------------------------------------------------------- 1 | require 'find' 2 | 3 | def list_files(dir, pattern) 4 | arr = [] 5 | Find.find(dir) do |filename| 6 | if filename =~ pattern then 7 | arr.push(filename) 8 | end 9 | end 10 | return arr 11 | end 12 | 13 | def generate_rdoc(*options) 14 | begin 15 | require 'rdoc/rdoc' 16 | rescue LoadError 17 | puts "WARNING: RDoc not installed; skipping generation of docs" 18 | return 19 | end 20 | 21 | r = RDoc::RDoc.new 22 | rdoc_files = [] 23 | rdoc_files.concat [ 'README' ] 24 | rdoc_files.concat list_files('lib', /\.rb$/) if File.exist?('lib') 25 | rdoc_files.concat list_files('ext', /\.c$/) if File.exist?('ext') 26 | rdoc_files.reject! { |file| file =~ %r{^ext/cached/} } 27 | r.document(options + rdoc_files) 28 | end 29 | 30 | if __FILE__ == $0 then 31 | generate_rdoc(*ARGV) 32 | end 33 | 34 | -------------------------------------------------------------------------------- /lib/internal/binding.rb: -------------------------------------------------------------------------------- 1 | require 'internal/binding/binding' 2 | -------------------------------------------------------------------------------- /lib/internal/classtree.rb: -------------------------------------------------------------------------------- 1 | require 'internal/object' 2 | require 'internal/module' 3 | 4 | class Object 5 | # Returns an ASCII representation of a class hierarchy, e.g.: 6 | # 7 | # irb(main):004:0> puts Object.new.classtree 8 | # # 9 | # +-class = Object 10 | # |-class = # 11 | # | |-class = Class 12 | # | | |-class = # 13 | # | | | |-class = # (*) 14 | # | | | +-super = # 15 | # | | | |-class = Class (*) 16 | # | | | +-super = # (*) 17 | # | | +-super = Module 18 | # | | |-class = # (*) 19 | # | | +-super = Object (*) 20 | # | +-super = Class (*) 21 | # +-super = # 22 | # +-class = PP::ObjectMixin? 23 | # |-class = Module (*) 24 | # +-super = # 25 | # +-class = Kernel 26 | # => nil 27 | # 28 | # An asterisk (*) indicates that the class has previously been 29 | # printed. 30 | # 31 | # The notation # indicates a singleton class. 32 | # 33 | def classtree(s = '', prefix = '', obj=self, graphed={}) 34 | # if Module == obj.class.class then 35 | # s << "included module " 36 | # elsif obj.singleton? then 37 | # s << "singleton class " 38 | # elsif Class === obj then 39 | # s << "class " 40 | # end 41 | s << "#{obj}" 42 | if graphed[obj] then 43 | s << " (*)\n" 44 | return s 45 | end 46 | s << "\n" 47 | graphed[obj] = true 48 | return if Kernel == obj 49 | subtree = (Module === obj) && (obj.real_superclass) 50 | s << "#{prefix}#{subtree ? '|-' : '+-'}class = " 51 | classtree(s, prefix + (subtree ? '| ' : ' '), obj.real_class, graphed) 52 | if subtree then 53 | s << "#{prefix}+-super = " 54 | classtree(s, prefix + ' ', obj.real_superclass, graphed) 55 | end 56 | return s 57 | end 58 | end 59 | 60 | if __FILE__ == $0 then 61 | module M 62 | end 63 | 64 | class Foo 65 | class << self; end 66 | include M 67 | end 68 | 69 | class Bar < Foo 70 | end 71 | 72 | class Baz 73 | class << self; @foo = 1; end 74 | def self.foo; end 75 | end 76 | 77 | b = Bar.new 78 | b.classtree($stderr) 79 | 80 | b = Baz.new 81 | b.classtree($stderr) 82 | end 83 | 84 | -------------------------------------------------------------------------------- /lib/internal/debug.rb: -------------------------------------------------------------------------------- 1 | require 'internal/node' 2 | require 'internal/node/as_expression' 3 | require 'internal/node/pp' 4 | 5 | module Internal 6 | # Print an expression and its result, e.g.: 7 | # 8 | # printdebug { 1 + 1 } 9 | # 10 | # will print: 11 | # 12 | # test.rb:42: 1 + 1 => 2 13 | # 14 | def printdebug(&block) 15 | puts "#{caller[0]}: #{block.body.as_expression} => #{block.call}" 16 | end 17 | end 18 | 19 | if __FILE__ == $0 then 20 | include Internal 21 | a = 41 22 | printdebug { a + 1 } 23 | end 24 | 25 | -------------------------------------------------------------------------------- /lib/internal/method.rb: -------------------------------------------------------------------------------- 1 | require 'internal/method/method' 2 | -------------------------------------------------------------------------------- /lib/internal/module.rb: -------------------------------------------------------------------------------- 1 | require 'internal/module/module' 2 | -------------------------------------------------------------------------------- /lib/internal/node.rb: -------------------------------------------------------------------------------- 1 | require 'internal/node/node' 2 | require 'internal/node/to_a' 3 | require 'internal/node/pp' 4 | -------------------------------------------------------------------------------- /lib/internal/node/dump.rb: -------------------------------------------------------------------------------- 1 | # This is a script similar to the Pragmatic Programmers' NodeDump.so. 2 | # You can use it similarly, e.g.: 3 | # 4 | # $ cat test.rb 5 | # def foo 6 | # 1+1 7 | # end 8 | # 9 | # $ ruby -rinternal/node/dump test.rb 10 | # NODE_NEWLINE at test.rb:1 11 | # |-nth = 1 12 | # +-next = NODE_DEFN at test.rb:1 13 | # |-defn = NODE_SCOPE at test.rb:3 14 | # | |-rval = false 15 | # | |-tbl = nil 16 | # | +-next = NODE_BLOCK at test.rb:1 17 | # | |-next = NODE_BLOCK at test.rb:3 18 | # | | |-next = false 19 | # | | +-head = NODE_NEWLINE at test.rb:2 20 | # | | |-nth = 2 21 | # | | +-next = NODE_CALL at test.rb:2 22 | # | | |-recv = NODE_LIT at test.rb:2 23 | # | | | +-lit = 1 24 | # | | |-args = NODE_ARRAY at test.rb:2 25 | # | | | |-alen = 1 26 | # | | | |-head = NODE_LIT at test.rb:2 27 | # | | | | +-lit = 1 28 | # | | | +-next = false 29 | # | | +-mid = :+ 30 | # | +-head = NODE_ARGS at test.rb:1 31 | # | |-cnt = 0 32 | # | |-rest = -1 33 | # | +-opt = false 34 | # |-mid = :foo 35 | # +-noex = PRIVATE 36 | 37 | require 'internal/node/pp' 38 | 39 | set_trace_func proc { 40 | begin 41 | n = $ruby_eval_tree 42 | if defined?($ruby_eval_tree_begin) and $ruby_eval_tree_begin then 43 | pp $ruby_eval_tree_begin, $stderr 44 | end 45 | if n then 46 | PP.pp n, $stderr 47 | exit! 48 | end 49 | rescue Exception 50 | p $!, $!.backtrace 51 | end 52 | } 53 | 54 | -------------------------------------------------------------------------------- /lib/internal/node/obfusc.rb: -------------------------------------------------------------------------------- 1 | require 'internal/node' 2 | 3 | class Node 4 | def obfusc(begin_nodes=[]) 5 | n = self 6 | 7 | # The outputted code must do the following: 8 | # 1. Evaluate each of the begin nodes (BEGIN {...}). 9 | # 2. Evaluate the main node. 10 | return <<-END 11 | require 'internal/node' 12 | if RUBY_VERSION != "#{RUBY_VERSION}" then 13 | $stderr.puts "Wrong Ruby version; please use #{RUBY_VERSION}" 14 | exit 1 15 | end 16 | begin_nodes = Marshal.load(#{Marshal.dump(begin_nodes).inspect}) 17 | n = Marshal.load(#{Marshal.dump(n).inspect}) 18 | begin_nodes.each do |node| 19 | node.eval(self) 20 | end 21 | n.eval(self) 22 | END 23 | end 24 | end 25 | 26 | -------------------------------------------------------------------------------- /lib/internal/node/pp.rb: -------------------------------------------------------------------------------- 1 | # Require this file to get a node pretty-printer. 2 | # 3 | 4 | require 'internal/node' 5 | require 'internal/vm' 6 | require 'pp' 7 | 8 | module Noex 9 | # Return a string representing the given integer as a noex value. 10 | # 11 | def stringify(noex) 12 | Noex.constants.each do |constant| 13 | return constant.to_s if const_get(constant) == noex 14 | end 15 | return noex.to_s 16 | end 17 | module_function :stringify 18 | end 19 | 20 | class Node 21 | # Return a string containing an ascii-art tree of the node's 22 | # structure. 23 | # 24 | def tree(s = '', prefix = '') 25 | s << "NODE_#{self.nd_type.to_s} at #{self.nd_file}:#{self.nd_line}\n" 26 | self.members.each_with_index do |member, idx| 27 | last = (idx == self.members.size-1) 28 | s << "#{prefix}#{(last ? '+-' : '|-')}#{member} = " 29 | value = self[member] 30 | if Node === value then 31 | value.tree(s, prefix + (last ? ' ' : '| ')) 32 | elsif defined?(RubyVM) and 33 | defined?(RubyVM::InstructionSequence) and 34 | RubyVM::InstructionSequence === value then 35 | s << "\n" 36 | d = value.disasm 37 | lines = d.split("\n") 38 | lines.each_with_index do |line, line_idx| 39 | if line =~ /^== disasm: (.*?)=/ then line = $1; end 40 | if line =~ /(.*)\s+\(\s*\d+\)/ then line = $1; end 41 | next if line =~ /^\|-----/ 42 | last_line = (line_idx == lines.size-1) 43 | s << "#{prefix}#{last ? ' ' : '| '}#{(last_line ? '+-' : '|-')}#{line}\n" 44 | end 45 | # p value.local_table 46 | elsif member == 'noex' then 47 | s << Noex.stringify(value) + "\n" 48 | else 49 | s << value.inspect + "\n" 50 | end 51 | end 52 | return s 53 | end 54 | 55 | # Pretty-print node using Node#tree onto s, which can be a String or 56 | # IO. 57 | # 58 | def pretty_print(pp) 59 | pp.text(tree()) 60 | end 61 | end 62 | 63 | if __FILE__ == $0 then 64 | def foo # :nodoc: 65 | 1 + 1 66 | end 67 | 68 | m = method(:foo) 69 | n = m.body 70 | puts n.pretty_print 71 | end 72 | 73 | -------------------------------------------------------------------------------- /lib/internal/node/to_a.rb: -------------------------------------------------------------------------------- 1 | class Node 2 | 3 | class ARRAY < Node 4 | def to_a 5 | a = [] 6 | e = self 7 | while e do 8 | a << e.head 9 | e = e.next 10 | end 11 | a 12 | end 13 | end 14 | 15 | class ZARRAY < Node 16 | def to_a 17 | [] 18 | end 19 | end 20 | 21 | class BLOCK < Node 22 | def to_a 23 | a = [] 24 | e = self 25 | while e do 26 | a << e.head 27 | e = e.next 28 | end 29 | a 30 | end 31 | end 32 | 33 | class LIT < Node 34 | def to_a 35 | return [ self ] 36 | end 37 | end 38 | 39 | if defined?(TO_ARY) then 40 | class TO_ARY < Node 41 | def to_a 42 | return [ self.head ] 43 | end 44 | end 45 | end 46 | 47 | def to_a 48 | raise NotImplementedError, "#to_a not defined for #{self.class}" 49 | end 50 | 51 | end 52 | 53 | -------------------------------------------------------------------------------- /lib/internal/noex.rb: -------------------------------------------------------------------------------- 1 | require 'internal/noex/noex' 2 | -------------------------------------------------------------------------------- /lib/internal/obfusc.rb: -------------------------------------------------------------------------------- 1 | # A code obfuscator for Ruby. It works by getting a dump of the node 2 | # tree, then wrapping it with a lightweight loader. 3 | # 4 | # NOTE: This code is for demonstration purposes only! It has not been 5 | # extensively tested, and I cannot guarantee that it works in all cases 6 | # (I don't even know what the corner cases are). If you wish to use 7 | # this in a commercial product, please verify that the code is correctly 8 | # loaded. 9 | # 10 | # Usage: 11 | # 12 | # $ cat test.rb 13 | # def foo 14 | # 1+1 15 | # end 16 | # 17 | # puts foo() 18 | # 19 | # $ ruby -rinternal/obfusc test.rb > test2.rb 20 | # $ ruby test2.rb 21 | # 2 22 | 23 | require 'internal/node/obfusc' 24 | 25 | begin_nodes = [] 26 | set_trace_func proc { 27 | n = $ruby_eval_tree 28 | if defined?($ruby_eval_tree_begin) and $ruby_eval_tree_begin then 29 | n.pretty_print($stderr) 30 | begin_nodes << $ruby_eval_tree_begin 31 | end 32 | if n then 33 | # TODO: Do I need to include ruby_dyna_vars? 34 | str = n.obfusc(begin_nodes) 35 | puts str 36 | exit 37 | end 38 | } 39 | 40 | -------------------------------------------------------------------------------- /lib/internal/object.rb: -------------------------------------------------------------------------------- 1 | require 'internal/object/object' 2 | -------------------------------------------------------------------------------- /lib/internal/proc.rb: -------------------------------------------------------------------------------- 1 | require 'internal/proc/proc' 2 | -------------------------------------------------------------------------------- /lib/internal/tag.rb: -------------------------------------------------------------------------------- 1 | require 'internal/tag/tag' 2 | -------------------------------------------------------------------------------- /lib/internal/thread.rb: -------------------------------------------------------------------------------- 1 | require 'internal/thread/thread' 2 | -------------------------------------------------------------------------------- /lib/internal/vm.rb: -------------------------------------------------------------------------------- 1 | require 'internal/vm/vm' 2 | -------------------------------------------------------------------------------- /lib/internal/vm/constants.rb: -------------------------------------------------------------------------------- 1 | require 'internal/vm/constants/constants' 2 | -------------------------------------------------------------------------------- /lib/internal/vm/control_frame.rb: -------------------------------------------------------------------------------- 1 | require 'internal/vm/control_frame/control_frame' 2 | -------------------------------------------------------------------------------- /lib/internal/vm/inline_cache.rb: -------------------------------------------------------------------------------- 1 | require 'internal/vm/inline_cache/inline_cache' 2 | -------------------------------------------------------------------------------- /lib/internal/vm/instruction.rb: -------------------------------------------------------------------------------- 1 | require 'internal/vm/instruction/instruction' 2 | -------------------------------------------------------------------------------- /lib/internal/vm/iseq.rb: -------------------------------------------------------------------------------- 1 | require 'internal/vm/iseq/iseq' 2 | -------------------------------------------------------------------------------- /metaconfig: -------------------------------------------------------------------------------- 1 | add_path_config( 2 | 'ruby-source-path', 3 | '', 4 | 'path to the ruby source code') 5 | 6 | add_path_config( 7 | 'ruby-include-path', 8 | '', 9 | 'path to the ruby header files') 10 | 11 | add_bool_config( 12 | 'without-tests', 13 | false, 14 | 'does not run tests') 15 | 16 | add_bool_config( 17 | 'cached-files', 18 | false, 19 | 'does not run tests') 20 | -------------------------------------------------------------------------------- /post-config.rb: -------------------------------------------------------------------------------- 1 | exec_task_traverse 'clean' 2 | -------------------------------------------------------------------------------- /post-install.rb: -------------------------------------------------------------------------------- 1 | require 'generate_rdoc' 2 | 3 | generate_rdoc('--ri-site') 4 | 5 | -------------------------------------------------------------------------------- /post-setup.rb: -------------------------------------------------------------------------------- 1 | $: << '.' # TODO: hack 2 | require 'run_tests' 3 | require 'generate_rdoc' 4 | 5 | if config('without-tests') != 'yes' then 6 | run_tests() 7 | end 8 | 9 | -------------------------------------------------------------------------------- /pre-install.rb: -------------------------------------------------------------------------------- 1 | class ::Installer 2 | remove_method :install_dir_ext 3 | 4 | # Hook to install shared objects in the right directory (the default 5 | # is to strip off the subdirectory) 6 | def install_dir_ext(rel) 7 | return unless extdir?(curr_srcdir()) 8 | install_files rubyextentions('.'), 9 | "#{config('sodir')}/#{rel}", 10 | 0555 11 | end 12 | end 13 | 14 | -------------------------------------------------------------------------------- /pre-setup.rb: -------------------------------------------------------------------------------- 1 | alias generate_files_dir_lib noop 2 | alias generate_files_dir_bin noop 3 | 4 | def generate_files_dir_ext(rel) 5 | return unless extdir?(curr_srcdir()) 6 | make 'generated_files' if File.file?('Makefile') 7 | end 8 | 9 | exec_task_traverse 'generate_files' 10 | -------------------------------------------------------------------------------- /publish_rdoc.rb: -------------------------------------------------------------------------------- 1 | require 'generate_rdoc' 2 | 3 | generate_rdoc 4 | system("rsync -r -P doc/* cout@rubyforge.org:/var/www/gforge-projects/ruby-internal") 5 | -------------------------------------------------------------------------------- /ruby-internal.gemspec: -------------------------------------------------------------------------------- 1 | spec = Gem::Specification.new do |s| 2 | s.name = 'ruby-internal' 3 | s.version = '0.8.5' 4 | s.summary = 'A library that provides acccess to the ' + \ 5 | 'internals of the ruby interpreter' 6 | s.homepage = 'http://rubystuff.org/nodewrap/' 7 | s.rubyforge_project = 'nodewrap' 8 | s.author = 'Paul Brannan' 9 | s.email = 'curlypaul924@gmail.com' 10 | 11 | s.add_dependency 'rubypp', '>= 0.0.1' 12 | 13 | s.description = <<-END 14 | Ruby-Internal is Ruby module that provides direct access to Ruby's 15 | internal data structures. 16 | END 17 | 18 | patterns = [ 19 | 'lib/**/*.rb', 20 | 'ext/mkmf-ruby-internal.rb', 21 | 'ext/ruby_source_dir.rb', 22 | 'ext/internal/**/*.rpp', 23 | 'ext/internal/**/*.c', 24 | 'ext/internal/**/*.h', 25 | 'ext/internal/**/*.rb', 26 | 'ext/cached/ruby-*/**/*', 27 | 'example/*.rb', 28 | 'example/README', 29 | 'test/*.rb', 30 | '*.rb', 31 | 'COPYING', 32 | 'LEGAL', 33 | 'LGPL', 34 | 'LICENSE', 35 | 'README.rdoc', 36 | 'TODO', 37 | 'metaconfig', 38 | 'setup.rb', 39 | 'Rakefile', 40 | 'bin/ruby-internal-node-dump', 41 | 'bin/ruby-internal-obfuscate', 42 | 'sample/dump_class.rb', 43 | 'sample/irbrc', 44 | ] 45 | s.files = patterns.collect { |p| Dir.glob(p) }.flatten 46 | 47 | s.executables = [ 48 | 'ruby-internal-node-dump', 49 | 'ruby-internal-obfuscate', 50 | ] 51 | 52 | s.extensions = 'Rakefile' 53 | s.test_files = Dir.glob('test/test_*.rb') 54 | 55 | s.extra_rdoc_files = [ 'README.rdoc' ] 56 | 57 | s.require_paths << 'ext' 58 | end 59 | 60 | -------------------------------------------------------------------------------- /ruby.supp: -------------------------------------------------------------------------------- 1 | 2 | { 3 | memcpy/rb_thread_save_context(Value1) 4 | Memcheck:Addr1 5 | fun:memcpy 6 | fun:rb_thread_save_context 7 | } 8 | 9 | { 10 | memcpy/rb_thread_restore_context(Value1) 11 | Memcheck:Addr1 12 | fun:memcpy 13 | fun:rb_thread_restore_context 14 | } 15 | 16 | { 17 | strchr/_dl_catch_error(Cond) 18 | Memcheck:Cond 19 | fun:strchr 20 | obj:/lib/libc-2.2.5.so 21 | fun:_dl_catch_error 22 | } 23 | 24 | { 25 | gc_mark(Cond) 26 | Memcheck:Cond 27 | fun:gc_mark 28 | } 29 | 30 | { 31 | gc_mark(Value4) 32 | Memcheck:Value4 33 | fun:gc_mark 34 | } 35 | 36 | { 37 | gc_mark_children(Cond) 38 | Memcheck:Cond 39 | fun:gc_mark_children 40 | } 41 | 42 | { 43 | gc_mark_children(Value4) 44 | Memcheck:Value4 45 | fun:gc_mark_children 46 | } 47 | 48 | { 49 | mark_locations_array(Cond) 50 | Memcheck:Cond 51 | fun:mark_locations_array 52 | } 53 | 54 | { 55 | mark_locations_array(Value4) 56 | Memcheck:Value4 57 | fun:mark_locations_array 58 | } 59 | 60 | { 61 | mark_locations_array(Addr4) 62 | Memcheck:Addr4 63 | fun:mark_locations_array 64 | } 65 | 66 | { 67 | mark_locations_array(Value8) 68 | Memcheck:Value8 69 | fun:mark_locations_array 70 | } 71 | 72 | { 73 | mark_locations_array(Addr8) 74 | Memcheck:Addr8 75 | fun:mark_locations_array 76 | } 77 | 78 | { 79 | rb_gc_mark(Cond) 80 | Memcheck:Cond 81 | fun:rb_gc_mark 82 | } 83 | 84 | { 85 | rb_gc_mark(Value4) 86 | Memcheck:Value4 87 | fun:rb_gc_mark 88 | } 89 | 90 | { 91 | rb_gc_mark_children(Value4) 92 | Memcheck:Value4 93 | fun:rb_gc_mark_children 94 | } 95 | 96 | { 97 | rb_gc_mark_children(Cond) 98 | Memcheck:Cond 99 | fun:rb_gc_mark_children 100 | } 101 | 102 | { 103 | rb_thread_save_context(Addr4) 104 | Memcheck:Addr4 105 | fun:rb_thread_save_context 106 | } 107 | 108 | # TODO: I'm not sure if this rule is good or not 109 | { 110 | rb_yield_0(Addr4) 111 | Memcheck:Addr4 112 | fun:rb_yield_0 113 | } 114 | 115 | { 116 | is_pointer_to_heap(Cond) 117 | Memcheck:Cond 118 | fun:is_pointer_to_heap 119 | } 120 | 121 | { 122 | rb_special_const_p(Cond) 123 | Memcheck:Cond 124 | fun:rb_special_const_p 125 | } 126 | 127 | { 128 | gc_sweep(Cond) 129 | Memcheck:Cond 130 | fun:gc_sweep 131 | } 132 | 133 | { 134 | th_make_env_each(Cond) 135 | Memcheck:Cond 136 | fun:th_make_env_each 137 | } 138 | 139 | { 140 | gc_marks(Value8) 141 | Memcheck:Value8 142 | fun:gc_marks 143 | } 144 | 145 | { 146 | gc_marks(Cond) 147 | Memcheck:Cond 148 | fun:gc_marks 149 | } 150 | 151 | { 152 | mark_current_machine_context(Cond) 153 | Memcheck:Cond 154 | fun:mark_current_machine_context 155 | } 156 | 157 | -------------------------------------------------------------------------------- /run_tests.rb: -------------------------------------------------------------------------------- 1 | $: << '.' # TODO: hack 2 | require 'test/test_helpers' 3 | 4 | def run_tests 5 | begin 6 | require 'test/unit' 7 | rescue LoadError 8 | puts "WARNING: Test::Unit not installed; skipping tests" 9 | return 10 | end 11 | 12 | $:.unshift('ext') 13 | $:.unshift('lib') 14 | tests = Dir['test/test_*.rb'] 15 | tests.each do |test| 16 | load test 17 | end 18 | 19 | run_all_tests() 20 | end 21 | 22 | if __FILE__ == $0 then 23 | require 'timeout' 24 | result = nil 25 | timeout(600) { run_tests() } 26 | end 27 | 28 | -------------------------------------------------------------------------------- /sample/dump_class.rb: -------------------------------------------------------------------------------- 1 | require 'internal/node' 2 | 3 | class Foo 4 | def foo; puts "this is a test..."; end 5 | end 6 | 7 | s = Marshal.dump(Foo) 8 | p Marshal.load(s) #=> Foo 9 | 10 | -------------------------------------------------------------------------------- /sample/irbrc: -------------------------------------------------------------------------------- 1 | require 'pp' 2 | require 'internal/node/pp' 3 | require 'internal/classtree' 4 | require 'internal/method/signature' 5 | -------------------------------------------------------------------------------- /test/test_dump_proc.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | require 'rbconfig' 3 | 4 | dir = File.dirname(__FILE__) 5 | $:.unshift(dir) if not $:.include?(dir) 6 | $:.unshift("#{dir}/../lib") if not $:.include?("#{dir}/../lib") 7 | $:.unshift("#{dir}/../ext") if not $:.include?("#{dir}/../ext") 8 | 9 | require 'internal/proc' 10 | 11 | require 'node_samples' 12 | 13 | $stdout.sync = true 14 | $stderr.sync = true 15 | 16 | class TC_Dump_Proc < Test::Unit::TestCase 17 | module Foo 18 | def foo(n=1) 19 | # A fancy way to return 42 20 | if false then 21 | answer = 0 22 | else 23 | answer = 0 24 | (1..42).each do |i| 25 | answer += (i / i) 26 | end 27 | end 28 | return n * answer 29 | end 30 | end 31 | 32 | include Foo 33 | 34 | Tmp_Foo = nil 35 | 36 | # For the cvar proc test 37 | @@a = 42 38 | 39 | class TestClassBase 40 | # for testing super() 41 | def foo 42 | return 42 43 | end 44 | end 45 | 46 | class TestClass < TestClassBase 47 | include Foo 48 | FOO = 1 49 | @foo = 2 50 | @@foo = 3 51 | 52 | # Make sure we have enough instance variables to exceed 53 | # ROBJECT_EMBED_LEN_MAX 54 | @bar1 = 1 55 | @bar2 = 2 56 | @bar3 = 3 57 | 58 | class << self 59 | FOO = 4 60 | @foo = 5 61 | end 62 | 63 | # for testing cvar 64 | # (can't be in base class due to change in 1.9 of class var lookup) 65 | @@a = 42 66 | end 67 | 68 | @@test_class = TestClass 69 | 70 | def initialize(test_method_name) 71 | # TODO: This seems to be the only way to get tests defined with # 72 | # define_method to run on 1.8.1 and earlier. 73 | catch(:invalid_test) { super(test_method_name) } 74 | end 75 | 76 | extend Test::Unit::Assertions 77 | 78 | Proc_Node_Samples.each do |node_name, sample_code| 79 | p = proc { 80 | p_orig = eval <<-END_DEF 81 | proc { 82 | #{sample_code} 83 | } 84 | END_DEF 85 | 86 | #puts "dumping" 87 | d = Marshal.dump(p_orig) 88 | #puts "loading" 89 | u = Marshal.load(d) 90 | p_new = u.bind(binding) 91 | 92 | orig_result = nil 93 | orig_exc = nil 94 | begin 95 | orig_result = p_orig.call 96 | rescue Exception => exc 97 | orig_exc = exc 98 | end 99 | 100 | dup_result = nil 101 | dup_exc = nil 102 | begin 103 | dup_result = p_new.call 104 | rescue Exception => exc 105 | dup_exc = exc 106 | end 107 | 108 | assert_equal orig_exc, dup_exc 109 | assert_equal orig_result, dup_result 110 | } 111 | define_method "test_dump_proc_#{node_name}", p 112 | end 113 | end 114 | 115 | if __FILE__ == $0 then 116 | exit Test::Unit::AutoRunner.run 117 | end 118 | 119 | -------------------------------------------------------------------------------- /test/test_helpers.rb: -------------------------------------------------------------------------------- 1 | $mini_unit_exit_code = 0 2 | 3 | def disable_mini_unit_auto_run 4 | MiniTest::Unit.class_eval do 5 | alias :run_ :run 6 | def run(*args) 7 | return $mini_unit_exit_code 8 | end 9 | end 10 | end 11 | 12 | def run_all_tests_with_mini_unit 13 | begin 14 | test = MiniTest::Unit.new 15 | args = ARGV.dup 16 | args << '-v' 17 | $mini_unit_exit_code = test.run(args) 18 | exit($mini_unit_exit_code) 19 | ensure 20 | disable_mini_unit_auto_run 21 | end 22 | end 23 | 24 | def run_all_tests_with_test_unit 25 | tests = [] 26 | ObjectSpace.each_object(Class) do |o| 27 | if o < Test::Unit::TestCase then 28 | tests << o 29 | end 30 | end 31 | 32 | suite = Test::Unit::TestSuite.new("RubyInternal") 33 | tests.each do |test| 34 | test.suite.tests.each do |testcase| 35 | suite << testcase 36 | end 37 | end 38 | 39 | require 'test/unit/ui/console/testrunner' 40 | 41 | verbose = nil 42 | begin 43 | verbose = Test::Unit::UI.const_get(:VERBOSE) 44 | rescue NameError 45 | verbose = Test::Unit::UI::Console::TestRunner.const_get(:VERBOSE) 46 | end 47 | 48 | result = Test::Unit::UI::Console::TestRunner.run( 49 | suite, 50 | verbose) 51 | exit(result.error_count + result.failure_count) 52 | end 53 | 54 | def run_all_tests 55 | if defined?(MiniTest) then 56 | run_all_tests_with_mini_unit 57 | else 58 | run_all_tests_with_test_unit 59 | end 60 | end 61 | 62 | -------------------------------------------------------------------------------- /test/test_method.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | require 'rbconfig' 3 | 4 | dir = File.dirname(__FILE__) 5 | $:.unshift(dir) if not $:.include?(dir) 6 | $:.unshift("#{dir}/../lib") if not $:.include?("#{dir}/../lib") 7 | $:.unshift("#{dir}/../ext") if not $:.include?("#{dir}/../ext") 8 | 9 | require 'internal/method' 10 | 11 | require "node_samples" 12 | 13 | $stdout.sync = true 14 | $stderr.sync = true 15 | 16 | class TC_Method < Test::Unit::TestCase 17 | module Foo 18 | def foo(n=1) 19 | # A fancy way to return 42 20 | if false then 21 | answer = 0 22 | else 23 | answer = 0 24 | (1..42).each do |i| 25 | answer += (i / i) 26 | end 27 | end 28 | return n * answer 29 | end 30 | end 31 | 32 | class MarshalMethodHelper 33 | include Foo 34 | end 35 | 36 | include Foo 37 | 38 | def test_method_node 39 | m = method(:foo) 40 | n = m.body 41 | if defined?(RubyVM::InstructionSequence) then 42 | # YARV 43 | assert n.class == RubyVM::InstructionSequence || # 1.9.2 and later 44 | n.class == Node::METHOD # 1.9.1 and earlier 45 | else 46 | # pre-YARV 47 | assert_equal Node::SCOPE, n.class 48 | end 49 | end 50 | 51 | def test_dump_method 52 | o = MarshalMethodHelper.new 53 | m = o.method(:foo) 54 | d = Marshal.dump(m) 55 | end 56 | 57 | def test_load_method 58 | o = MarshalMethodHelper.new 59 | m = o.method(:foo) 60 | d = Marshal.dump(m) 61 | m2 = Marshal.load(d) 62 | assert_equal m.call, m2.call 63 | end 64 | 65 | def test_dump_unbound_method 66 | o = MarshalMethodHelper.new 67 | u = o.method(:foo).unbind 68 | d = Marshal.dump(u) 69 | end 70 | 71 | def test_load_unbound_method 72 | o = MarshalMethodHelper.new 73 | u = o.method(:foo).unbind 74 | d = Marshal.dump(u) 75 | u2 = Marshal.load(d) 76 | m = u.bind(o) 77 | m2 = u.bind(o) 78 | assert_equal m.call, m2.call 79 | end 80 | 81 | def test_method_oid 82 | m = method(:foo) 83 | oid = m.method_oid 84 | end 85 | end 86 | 87 | if __FILE__ == $0 then 88 | # exit Test::Unit::AutoRunner.run 89 | end 90 | 91 | -------------------------------------------------------------------------------- /test/test_module.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | require 'rbconfig' 3 | 4 | dir = File.dirname(__FILE__) 5 | $:.unshift(dir) if not $:.include?(dir) 6 | $:.unshift("#{dir}/../lib") if not $:.include?("#{dir}/../lib") 7 | $:.unshift("#{dir}/../ext") if not $:.include?("#{dir}/../ext") 8 | 9 | require 'internal/module' 10 | require 'internal/method' 11 | require 'internal/noex' 12 | 13 | $stdout.sync = true 14 | $stderr.sync = true 15 | 16 | class TC_Module < Test::Unit::TestCase 17 | module Foo 18 | def foo(n=1) 19 | # A fancy way to return 42 20 | if false then 21 | answer = 0 22 | else 23 | answer = 0 24 | (1..42).each do |i| 25 | answer += (i / i) 26 | end 27 | end 28 | return n * answer 29 | end 30 | end 31 | 32 | include Foo 33 | 34 | def test_add_method 35 | m = method(:foo) 36 | n = m.body 37 | klass = Class.new 38 | klass.class_eval do 39 | add_method(:foo, n, Noex::PUBLIC) 40 | end 41 | obj = klass.new 42 | assert_equal 42, obj.foo 43 | end 44 | end 45 | 46 | if __FILE__ == $0 then 47 | # exit Test::Unit::AutoRunner.run 48 | end 49 | 50 | -------------------------------------------------------------------------------- /test/test_node.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | require 'rbconfig' 3 | 4 | dir = File.dirname(__FILE__) 5 | $:.unshift(dir) if not $:.include?(dir) 6 | $:.unshift("#{dir}/../lib") if not $:.include?("#{dir}/../lib") 7 | $:.unshift("#{dir}/../ext") if not $:.include?("#{dir}/../ext") 8 | 9 | require 'internal/node' 10 | require 'internal/method' 11 | require 'internal/module' 12 | require 'internal/noex' 13 | 14 | $stdout.sync = true 15 | $stderr.sync = true 16 | 17 | class TC_Node < Test::Unit::TestCase 18 | module Foo 19 | def foo(n=1) 20 | # A fancy way to return 42 21 | if false then 22 | answer = 0 23 | else 24 | answer = 0 25 | (1..42).each do |i| 26 | answer += (i / i) 27 | end 28 | end 29 | return n * answer 30 | end 31 | end 32 | 33 | include Foo 34 | 35 | def test_node_eval 36 | node = Node.compile_string('1 + 1') 37 | assert_equal 2, node.eval(self) 38 | end 39 | 40 | def test_marshal_node 41 | m = method(:foo) 42 | n = m.body 43 | d = Marshal.dump(n) 44 | n2 = Marshal.load(d) 45 | case n2 46 | when Node 47 | # 1.9.1 and earlier 48 | assert_equal n.nd_file, n2.nd_file 49 | assert_equal n.nd_type, n2.nd_type 50 | assert_equal n.flags, n2.flags 51 | when RubyVM::InstructionSequence 52 | # 1.9.2 and later 53 | assert_equal n.name, n2.name 54 | assert_equal n.filename, n2.filename 55 | assert_equal n.argc, n2.argc 56 | assert_equal n.arg_simple, n2.arg_simple 57 | assert_equal n.arg_rest, n2.arg_rest 58 | assert_equal n.arg_block, n2.arg_block 59 | else 60 | fail "Unexpeced type #{n2.class}" 61 | end 62 | klass = Class.new; 63 | klass.class_eval do 64 | add_method(:foo, n2, Noex::PUBLIC) 65 | end 66 | obj = klass.new 67 | assert_equal 42, obj.foo 68 | end 69 | 70 | MAJOR = Config::CONFIG['MAJOR'].to_i 71 | MINOR = Config::CONFIG['MINOR'].to_i 72 | TEENY = Config::CONFIG['TEENY'].to_i 73 | RUBY_VERSION_CODE = MAJOR * 100 + MINOR * 10 + TEENY 74 | 75 | def test_ruby_eval_tree 76 | if RUBY_VERSION_CODE < 190 then 77 | assert Node === $ruby_eval_tree 78 | end 79 | end 80 | 81 | def test_ruby_eval_tree_begin 82 | if RUBY_VERSION_CODE < 190 then 83 | assert_equal nil, $ruby_eval_tree_begin 84 | end 85 | end 86 | end 87 | 88 | if __FILE__ == $0 then 89 | $: << '.' # TODO: hack 90 | require 'test_helpers' 91 | run_all_tests 92 | end 93 | 94 | -------------------------------------------------------------------------------- /test/test_proc.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | require 'rbconfig' 3 | 4 | dir = File.dirname(__FILE__) 5 | $:.unshift(dir) if not $:.include?(dir) 6 | $:.unshift("#{dir}/../lib") if not $:.include?("#{dir}/../lib") 7 | $:.unshift("#{dir}/../ext") if not $:.include?("#{dir}/../ext") 8 | 9 | require 'internal/proc' 10 | 11 | $stdout.sync = true 12 | $stderr.sync = true 13 | 14 | class TC_Node < Test::Unit::TestCase 15 | def initialize(test_method_name) 16 | # TODO: This seems to be the only way to get tests defined with # 17 | # define_method to run on 1.8.1 and earlier. 18 | catch(:invalid_test) { super(test_method_name) } 19 | end 20 | 21 | def test_marshal_proc 22 | p = proc { 1 + 1 } 23 | d = Marshal.dump(p) 24 | u = Marshal.load(d) 25 | p2 = u.bind(binding) 26 | assert_equal(p.call, p2.call) 27 | end 28 | 29 | def test_proc_unbind 30 | p = proc { 1 + 1 } 31 | u = p.unbind 32 | p2 = u.bind(binding) 33 | assert_equal(p.call, p2.call) 34 | end 35 | 36 | if not defined?(RubyVM) then 37 | define_method(:test_proc_body) do 38 | p = proc { 1 + 1 } 39 | assert_equal p.call, p.body.eval(self) 40 | end 41 | end 42 | end 43 | 44 | if __FILE__ == $0 then 45 | exit Test::Unit::AutoRunner.run 46 | end 47 | 48 | -------------------------------------------------------------------------------- /test/test_thread.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | require 'rbconfig' 3 | 4 | dir = File.dirname(__FILE__) 5 | $:.unshift(dir) if not $:.include?(dir) 6 | $:.unshift("#{dir}/../lib") if not $:.include?("#{dir}/../lib") 7 | $:.unshift("#{dir}/../ext") if not $:.include?("#{dir}/../ext") 8 | 9 | require 'internal/thread' 10 | 11 | $stdout.sync = true 12 | $stderr.sync = true 13 | 14 | class TC_Thread < Test::Unit::TestCase 15 | def test_thread_cfp 16 | return if not defined?(RubyVM) 17 | 18 | cfp = Thread.current.cfp 19 | end 20 | end 21 | 22 | if __FILE__ == $0 then 23 | exit Test::Unit::AutoRunner.run 24 | end 25 | 26 | --------------------------------------------------------------------------------