ruby-internal 0.6.0

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