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,55 @@
1
+ #include <ruby.h>
2
+
3
+ #ifdef RUBY_VM
4
+
5
+ #include "vm_core.h"
6
+
7
+ extern rb_vm_t * ruby_current_vm;
8
+
9
+ /*
10
+ * call-seq:
11
+ * RubyVM.current => RubyVM
12
+ *
13
+ * Returns the current ruby VM.
14
+ */
15
+ static VALUE vm_current(VALUE klass)
16
+ {
17
+ return ruby_current_vm->self;
18
+ }
19
+
20
+ /*
21
+ * call-seq:
22
+ * ruby_vm.top_self
23
+ *
24
+ * Returns the VM's "top self".
25
+ */
26
+ static VALUE vm_top_self(VALUE self)
27
+ {
28
+ rb_vm_t * vm;
29
+
30
+ Data_Get_Struct(self, rb_vm_t, vm);
31
+
32
+ return vm->top_self;
33
+ }
34
+
35
+ #endif
36
+
37
+ void Init_vm(void)
38
+ {
39
+ #ifdef RUBY_VM
40
+ VALUE rb_cRubyVM;
41
+
42
+ if(!rb_const_defined(rb_cObject, rb_intern("RubyVM")))
43
+ {
44
+ rb_define_const(
45
+ rb_cObject,
46
+ "RubyVM",
47
+ rb_const_get(rb_cObject, rb_intern("VM")));
48
+ }
49
+
50
+ rb_cRubyVM = rb_define_class("RubyVM", rb_cObject);
51
+ rb_define_singleton_method(rb_cRubyVM, "current", vm_current, 0);
52
+ rb_define_method(rb_cRubyVM, "top_self", vm_top_self, 0);
53
+ #endif
54
+ }
55
+
@@ -0,0 +1,111 @@
1
+ require 'mkmf'
2
+
3
+ using_cached_files = enable_config('cached-files')
4
+ if using_cached_files then
5
+ # if --enable-cached-files was specified on the command line, then use cached
6
+ # files
7
+ USING_CACHED_FILES = true
8
+ else
9
+ ruby_source_path = arg_config('--ruby-source-path')
10
+ if ruby_source_path.nil? then
11
+ class SetupError < StandardError; end
12
+
13
+ # if the user did not specify the source dir, then see if we have one
14
+ # configured
15
+ begin
16
+ require 'ruby_source_dir'
17
+ # if we got here, then we successfuly loaded the configuration
18
+ rescue SetupError
19
+ # otherwise, assume we are using cached files
20
+ USING_CACHED_FILES = true
21
+ end
22
+ else
23
+ # the user did specify the source path
24
+ USING_CACHED_FILES = false
25
+ RUBY_SOURCE_DIR = ruby_source_path
26
+ end
27
+ end
28
+
29
+ def create_ruby_internal_makefile(name)
30
+ rb_files = Dir['*.rb']
31
+ rpp_files = Dir['*.rpp']
32
+ generated_files = rpp_files.map { |f| f.sub(/\.rpp$/, '') }
33
+
34
+ # Append the generated C files to the list of source files
35
+ srcs = Dir['*.c']
36
+ generated_files.each do |f|
37
+ if f =~ /\.c$/ then
38
+ srcs << f
39
+ end
40
+ end
41
+ srcs.uniq!
42
+ $objs = srcs.map { |f| f.sub(/\.c$/, ".#{$OBJEXT}") }
43
+
44
+ # Turn on warnings and debugging by default on gcc
45
+ if CONFIG['CC'] == 'gcc' then
46
+ $CFLAGS << ' -Wall -g'
47
+ end
48
+
49
+ create_makefile(name)
50
+
51
+ append_to_makefile = ''
52
+
53
+ base_dir = File.dirname(__FILE__)
54
+
55
+ if USING_CACHED_FILES then
56
+
57
+ subdir = File.expand_path(File.dirname($0))
58
+ subdir = subdir.gsub(File.expand_path(base_dir), '')
59
+ cached_dir = File.join('cached', "ruby-#{RUBY_VERSION}")
60
+
61
+ # -- Using cached files --
62
+ rpp_files.each do |rpp_file|
63
+ dest_file = rpp_file.sub(/\.rpp$/, '')
64
+ src_file = File.join(base_dir, cached_dir, subdir, File.basename(dest_file))
65
+ append_to_makefile << <<END
66
+ #{dest_file}: #{src_file}
67
+ \t@$(RUBY) -e 'begin; require "fileutils"; rescue LoadError; require "ftools"; FileUtils = File end; FileUtils.copy("#{src_file}", ".", :verbose => true)'
68
+ END
69
+ end
70
+ else
71
+ # -- Generating files --
72
+ rpp_files.each do |rpp_file|
73
+ dest_file = rpp_file.sub(/\.rpp$/, '')
74
+ append_to_makefile << <<END
75
+ #{dest_file}: #{rpp_file} #{rb_files.join(' ')}
76
+ \t$(RUBY) #{base_dir}/rubypp.rb #{rpp_file} #{dest_file}
77
+ END
78
+ end
79
+
80
+ end
81
+
82
+ # Dependencies
83
+ # TODO: we could be smarter about this
84
+ generated_headers = generated_files.select { |x| x =~ /\.h$/ }
85
+ generated_incs = generated_files.select { |x| x =~ /\.inc$/ }
86
+ append_to_makefile << <<END
87
+ $(OBJS): #{generated_headers.join(' ')} #{generated_incs.join(' ')}
88
+ clean: clean_generated_files
89
+ clean_generated_files:
90
+ \t@$(RM) #{generated_files.join(' ')}
91
+ generated_files: #{generated_files.join(' ')}
92
+ END
93
+
94
+ # Append it all to the makefile
95
+ File.open('Makefile', 'a') do |makefile|
96
+ makefile.puts(append_to_makefile)
97
+ end
98
+ end
99
+
100
+ base_dir = File.dirname(__FILE__)
101
+ $CPPFLAGS << " -I#{base_dir}"
102
+
103
+ ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i
104
+ if ruby_version_code >= 190 then
105
+ if USING_CACHED_FILES then
106
+ $CPPFLAGS << " -I#{base_dir}/internal/yarv-headers"
107
+ else
108
+ $CPPFLAGS << " -I#{RUBY_SOURCE_DIR}"
109
+ end
110
+ end
111
+
@@ -0,0 +1,24 @@
1
+ wd = Dir.pwd()
2
+ metaconfig_dir = File.join(File.dirname(__FILE__), '..')
3
+ Dir.chdir metaconfig_dir
4
+ begin
5
+ require 'setup.rb'
6
+ require 'rbconfig'
7
+ config = ConfigTable.new(Config::CONFIG)
8
+ config.load_standard_entries
9
+ config.load_script 'metaconfig'
10
+ config.load_savefile
11
+ ensure
12
+ Dir.chdir(wd)
13
+ end
14
+
15
+ RUBY_SOURCE_DIR = config['ruby-source-path']
16
+ RUBY_INCLUDE_DIR = config['ruby-include-path']
17
+ USING_CACHED_FILES = config['cached-files'] == 'yes'
18
+
19
+ if __FILE__ == $0 then
20
+ puts "Using cached files: #{USING_CACHED_FILES}"
21
+ puts "Ruby source dir: #{RUBY_SOURCE_DIR}"
22
+ puts "Ruby include dir: #{RUBY_INCLUDE_DIR}"
23
+ end
24
+
data/ext/rubypp.rb ADDED
@@ -0,0 +1,97 @@
1
+ class Preprocessor
2
+ def initialize(input, output, filename)
3
+ @input = input
4
+ @output = output
5
+ @filename = filename
6
+ @linenum = 1
7
+ end
8
+
9
+ def getline
10
+ line = @input.gets
11
+ @linenum += 1 if not line.nil?
12
+ return line
13
+ end
14
+
15
+ def preprocess
16
+ success = false
17
+ begin
18
+ loop do
19
+ line = getline
20
+ break if line.nil?
21
+ case line
22
+ when /(.*[^\\]|^)\#\{(.*?)\}(.*)/
23
+ puts "#{$1}#{evaluate($2, @linenum)}#{$3}"
24
+ when /^\#ruby\s+<<(.*)/
25
+ marker = $1
26
+ str = ''
27
+ evalstart = @linenum
28
+ loop do
29
+ line = getline
30
+ if line.nil? then
31
+ raise "End of input without #{marker}"
32
+ end
33
+ break if line.chomp == marker
34
+ str << line
35
+ end
36
+ result = evaluate(str, evalstart)
37
+ puts result if not result.nil?
38
+ when /^\#ruby\s+(.*)/
39
+ str = line = $1
40
+ while line[-1] == ?\\
41
+ str.chop!
42
+ line = getline
43
+ break if line.nil?
44
+ line.chomp!
45
+ str << line
46
+ end
47
+ result = evaluate(str, @linenum)
48
+ puts result if not result.nil?
49
+ else
50
+ puts line
51
+ end
52
+ end
53
+ success = true
54
+ ensure
55
+ if not success then
56
+ $stderr.puts "Error on line #{@linenum}:"
57
+ end
58
+ end
59
+ end
60
+
61
+ def evaluate(str, linenum)
62
+ result = eval(str, TOPLEVEL_BINDING, @filename, linenum)
63
+ success = true
64
+ return result
65
+ end
66
+
67
+ def puts(line)
68
+ @output.puts(line)
69
+ end
70
+ end
71
+
72
+ def puts(line)
73
+ $preprocessor.puts(line)
74
+ end
75
+
76
+ def rubypp(input_file, output_file)
77
+ input = input_file ? File.open(input_file) : $stdin
78
+ output = output_file ? File.open(output_file, 'w') : $stdout
79
+
80
+ success = false
81
+ begin
82
+ $preprocessor = Preprocessor.new(input, output, input_file || "(stdin)")
83
+ $preprocessor.preprocess()
84
+ success = true
85
+ ensure
86
+ if not success then
87
+ File.unlink(output_file) rescue Errno::ENOENT
88
+ end
89
+ end
90
+ end
91
+
92
+ if __FILE__ == $0 then
93
+ input_file = ARGV[0]
94
+ output_file = ARGV[1]
95
+ rubypp(input_file, output_file)
96
+ end
97
+
data/generate_rdoc.rb ADDED
@@ -0,0 +1,33 @@
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
+
@@ -0,0 +1 @@
1
+ require 'internal/binding/binding'
@@ -0,0 +1,55 @@
1
+ require 'internal/object'
2
+ require 'internal/module'
3
+
4
+ class Object
5
+ def classtree(s = '', prefix = '', obj=self, graphed={})
6
+ # if Module == obj.class.class then
7
+ # s << "included module "
8
+ # elsif obj.singleton? then
9
+ # s << "singleton class "
10
+ # elsif Class === obj then
11
+ # s << "class "
12
+ # end
13
+ s << "#{obj}"
14
+ if graphed[obj] then
15
+ s << " (*)\n"
16
+ return s
17
+ end
18
+ s << "\n"
19
+ graphed[obj] = true
20
+ return if Kernel == obj
21
+ subtree = (Module === obj) && (obj.real_superclass)
22
+ s << "#{prefix}#{subtree ? '|-' : '+-'}class = "
23
+ classtree(s, prefix + (subtree ? '| ' : ' '), obj.real_class, graphed)
24
+ if subtree then
25
+ s << "#{prefix}+-super = "
26
+ classtree(s, prefix + ' ', obj.real_superclass, graphed)
27
+ end
28
+ return s
29
+ end
30
+ end
31
+
32
+ if __FILE__ == $0 then
33
+ module M
34
+ end
35
+
36
+ class Foo
37
+ class << self; end
38
+ include M
39
+ end
40
+
41
+ class Bar < Foo
42
+ end
43
+
44
+ class Baz
45
+ class << self; @foo = 1; end
46
+ def self.foo; end
47
+ end
48
+
49
+ b = Bar.new
50
+ b.classtree($stderr)
51
+
52
+ b = Baz.new
53
+ b.classtree($stderr)
54
+ end
55
+
@@ -0,0 +1,16 @@
1
+ require 'internal/node'
2
+ require 'internal/node/as_expression'
3
+ require 'internal/node/pp'
4
+
5
+ module Nodewrap
6
+ def printdebug(&block)
7
+ puts "#{caller[0]}: #{block.body.as_expression} => #{block.call}"
8
+ end
9
+ end
10
+
11
+ if __FILE__ == $0 then
12
+ include Nodewrap
13
+ a = 41
14
+ printdebug { a + 1 }
15
+ end
16
+
@@ -0,0 +1 @@
1
+ require 'internal/method/method'
@@ -0,0 +1,33 @@
1
+ require 'internal/node/as_code'
2
+ require 'internal/vm/iseq/as_code'
3
+ require 'internal/method'
4
+ require 'internal/method/signature'
5
+
6
+ module MethodAsCode
7
+ def as_code(indent=0, name=nil)
8
+ sig = self.signature
9
+ if self.body.respond_to?(:body) then
10
+ # YARV
11
+ body_expression = self.body.body.as_code(indent+1)
12
+ else
13
+ # pre-YARV
14
+ body_expression = self.body ? self.body.as_code(indent+1) : ''
15
+ end
16
+ name ||= sig.name
17
+ s = "#{' '*indent}def #{name}(#{sig.param_list})\n"
18
+ if body_expression then
19
+ s += "#{body_expression}\n"
20
+ end
21
+ s += "#{' '*indent}end"
22
+ return s
23
+ end
24
+ end
25
+
26
+ class Method
27
+ include MethodAsCode
28
+ end
29
+
30
+ class UnboundMethod
31
+ include MethodAsCode
32
+ end
33
+
@@ -0,0 +1,34 @@
1
+ require 'internal/node/as_expression'
2
+ require 'internal/vm/iseq/as_expression'
3
+ require 'internal/method/signature'
4
+ require 'internal/method'
5
+
6
+ module MethodAsExpression
7
+ # It doesn't entirely make sense to have Method#as_expression, because
8
+ # a method definition isn't an expression. We have one anyway, to be
9
+ # consistent with Proc.
10
+ def as_expression
11
+ sig = self.signature
12
+ if self.body.respond_to?(:body) then
13
+ # YARV
14
+ body_expression = self.body.body.as_expression
15
+ else
16
+ # pre-YARV
17
+ body_expression = self.body.as_expression
18
+ end
19
+ if body_expression then
20
+ return "def #{sig.name}(#{sig.param_list}); #{body_expression}; end"
21
+ else
22
+ return "def #{sig.name}(#{sig.param_list}); end"
23
+ end
24
+ end
25
+ end
26
+
27
+ class Method
28
+ include MethodAsExpression
29
+ end
30
+
31
+ class UnboundMethod
32
+ include MethodAsExpression
33
+ end
34
+