ruby-internal 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. data/bin/ruby-internal-node-dump +1 -1
  2. data/bin/ruby-internal-obfuscate +1 -1
  3. data/ext/cached/ruby-1.8.4/internal/method/{method.h → internal_method.h} +12 -0
  4. data/ext/cached/ruby-1.8.4/internal/module/getcfp.h +13 -0
  5. data/ext/cached/ruby-1.8.4/internal/node/global_entry.h +94 -0
  6. data/ext/cached/ruby-1.8.4/internal/node/node_type_descrip.c +41 -41
  7. data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.c +288 -273
  8. data/ext/cached/ruby-1.8.4/internal/vm/instruction/insns_info.c +3 -0
  9. data/ext/cached/ruby-1.8.4/internal/vm/iseq/iseq_load.inc +21 -2
  10. data/ext/cached/{ruby-1.8.3/internal/method/method.h → ruby-1.8.5/internal/method/internal_method.h} +12 -0
  11. data/ext/cached/ruby-1.8.5/internal/module/getcfp.h +13 -0
  12. data/ext/cached/ruby-1.8.5/internal/node/global_entry.h +94 -0
  13. data/ext/cached/ruby-1.8.5/internal/node/node_type_descrip.c +45 -45
  14. data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.c +310 -295
  15. data/ext/cached/ruby-1.8.5/internal/vm/instruction/insns_info.c +3 -0
  16. data/ext/cached/ruby-1.8.5/internal/vm/iseq/iseq_load.inc +21 -2
  17. data/ext/cached/{ruby-1.8.5/internal/method/method.h → ruby-1.8.6/internal/method/internal_method.h} +12 -0
  18. data/ext/cached/ruby-1.8.6/internal/module/getcfp.h +13 -0
  19. data/ext/cached/ruby-1.8.6/internal/node/global_entry.h +94 -0
  20. data/ext/cached/ruby-1.8.6/internal/node/node_type_descrip.c +48 -48
  21. data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.c +323 -308
  22. data/ext/cached/ruby-1.8.6/internal/vm/instruction/insns_info.c +3 -0
  23. data/ext/cached/ruby-1.8.6/internal/vm/iseq/iseq_load.inc +21 -2
  24. data/ext/cached/{ruby-1.8.6/internal/method/method.h → ruby-1.8.7/internal/method/internal_method.h} +12 -0
  25. data/ext/cached/ruby-1.8.7/internal/module/getcfp.h +13 -0
  26. data/ext/cached/ruby-1.8.7/internal/node/global_entry.h +98 -0
  27. data/ext/cached/ruby-1.8.7/internal/node/node_type_descrip.c +42 -42
  28. data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.c +276 -261
  29. data/ext/cached/ruby-1.8.7/internal/vm/instruction/insns_info.c +3 -0
  30. data/ext/cached/ruby-1.8.7/internal/vm/iseq/iseq_load.inc +21 -2
  31. data/ext/cached/{ruby-1.9.0/internal/method/method.h → ruby-1.9.1/internal/method/internal_method.h} +12 -0
  32. data/ext/cached/ruby-1.9.1/internal/module/classpath.c +12 -14
  33. data/ext/cached/ruby-1.9.1/internal/module/getcfp.h +25 -0
  34. data/ext/cached/ruby-1.9.1/internal/node/global_entry.h +86 -0
  35. data/ext/cached/ruby-1.9.1/internal/node/node_type_descrip.c +46 -48
  36. data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.c +311 -412
  37. data/ext/cached/ruby-1.9.1/internal/vm/instruction/insns_info.c +3 -0
  38. data/ext/cached/ruby-1.9.1/internal/vm/iseq/iseq_load.inc +28 -6
  39. data/ext/cached/ruby-1.9.1/internal/yarv-headers/iseq.h +1 -0
  40. data/ext/cached/ruby-1.9.1/internal/yarv-headers/parse.h +6 -6
  41. data/ext/cached/ruby-1.9.1/internal/yarv-headers/revision.h +1 -1
  42. data/ext/cached/ruby-1.9.1/internal/yarv-headers/version.h +6 -5
  43. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_core.h +3 -2
  44. data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_insnhelper.h +1 -0
  45. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/binding/block.h +0 -0
  46. data/ext/cached/{ruby-1.9.1/internal/method/method.h → ruby-1.9.2/internal/method/internal_method.h} +16 -5
  47. data/ext/cached/ruby-1.9.2/internal/module/classpath.c +40 -0
  48. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/module/classpath.h +0 -0
  49. data/ext/cached/ruby-1.9.2/internal/module/getcfp.h +25 -0
  50. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/block.h +0 -0
  51. data/ext/cached/ruby-1.9.2/internal/node/global_entry.h +93 -0
  52. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/node_type_descrip.c +44 -48
  53. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/nodeinfo.c +291 -439
  54. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/nodeinfo.h +0 -0
  55. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/proc/block.h +0 -0
  56. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/tag/tag.h +0 -0
  57. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/vm/instruction/insns_info.c +141 -64
  58. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/vm/instruction/insns_info.h +88 -80
  59. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/vm/iseq/insns_info.inc +77 -70
  60. data/ext/cached/ruby-1.9.2/internal/vm/iseq/iseq_load.inc +426 -0
  61. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/debug.h +1 -1
  62. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/dln.h +3 -3
  63. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/encdb.h +18 -2
  64. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/eval_intern.h +39 -28
  65. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/gc.h +7 -5
  66. data/ext/cached/ruby-1.9.2/internal/yarv-headers/id.h +170 -0
  67. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/iseq.h +20 -10
  68. data/ext/cached/ruby-1.9.2/internal/yarv-headers/method.h +103 -0
  69. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/node.h +14 -47
  70. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/parse.h +31 -148
  71. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/regenc.h +7 -3
  72. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/regint.h +16 -17
  73. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/regparse.h +4 -1
  74. data/ext/cached/ruby-1.9.2/internal/yarv-headers/revision.h +1 -0
  75. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/thread_pthread.h +4 -1
  76. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/thread_win32.h +1 -1
  77. data/ext/cached/ruby-1.9.2/internal/yarv-headers/timev.h +21 -0
  78. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/transcode_data.h +20 -10
  79. data/ext/cached/ruby-1.9.2/internal/yarv-headers/transdb.h +179 -0
  80. data/ext/cached/ruby-1.9.2/internal/yarv-headers/version.h +55 -0
  81. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_core.h +127 -84
  82. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_exec.h +4 -7
  83. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_insnhelper.h +53 -36
  84. data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_opts.h +1 -1
  85. data/ext/cached/ruby-1.9.3/internal/binding/block.h +12 -0
  86. data/ext/cached/ruby-1.9.3/internal/method/internal_method.h +32 -0
  87. data/ext/cached/ruby-1.9.3/internal/module/classpath.c +40 -0
  88. data/ext/cached/{ruby-1.8.0 → ruby-1.9.3}/internal/module/classpath.h +5 -2
  89. data/ext/cached/ruby-1.9.3/internal/module/getcfp.h +25 -0
  90. data/ext/cached/ruby-1.9.3/internal/node/block.h +12 -0
  91. data/ext/cached/ruby-1.9.3/internal/node/global_entry.h +93 -0
  92. data/ext/cached/{ruby-1.8.3 → ruby-1.9.3}/internal/node/node_type_descrip.c +48 -57
  93. data/ext/cached/{ruby-1.6.8 → ruby-1.9.3}/internal/node/nodeinfo.c +589 -740
  94. data/ext/cached/{ruby-1.8.0 → ruby-1.9.3}/internal/node/nodeinfo.h +4 -3
  95. data/ext/cached/ruby-1.9.3/internal/proc/block.h +12 -0
  96. data/ext/cached/ruby-1.9.3/internal/tag/tag.h +6 -0
  97. data/ext/cached/ruby-1.9.3/internal/vm/instruction/insns_info.c +6013 -0
  98. data/ext/cached/ruby-1.9.3/internal/vm/instruction/insns_info.h +899 -0
  99. data/ext/cached/ruby-1.9.3/internal/vm/iseq/insns_info.inc +707 -0
  100. data/ext/cached/ruby-1.9.3/internal/vm/iseq/iseq_load.inc +423 -0
  101. data/ext/cached/ruby-1.9.3/internal/yarv-headers/addr2line.h +21 -0
  102. data/ext/cached/ruby-1.9.3/internal/yarv-headers/atomic.h +56 -0
  103. data/ext/cached/ruby-1.9.3/internal/yarv-headers/constant.h +34 -0
  104. data/ext/cached/ruby-1.9.3/internal/yarv-headers/debug.h +41 -0
  105. data/ext/cached/ruby-1.9.3/internal/yarv-headers/dln.h +50 -0
  106. data/ext/cached/ruby-1.9.3/internal/yarv-headers/encdb.h +167 -0
  107. data/ext/cached/ruby-1.9.3/internal/yarv-headers/eval_intern.h +234 -0
  108. data/ext/cached/ruby-1.9.3/internal/yarv-headers/gc.h +98 -0
  109. data/ext/cached/ruby-1.9.3/internal/yarv-headers/id.h +175 -0
  110. data/ext/cached/ruby-1.9.3/internal/yarv-headers/internal.h +232 -0
  111. data/ext/cached/ruby-1.9.3/internal/yarv-headers/iseq.h +125 -0
  112. data/ext/cached/ruby-1.9.3/internal/yarv-headers/method.h +105 -0
  113. data/ext/cached/ruby-1.9.3/internal/yarv-headers/node.h +503 -0
  114. data/ext/cached/ruby-1.9.3/internal/yarv-headers/parse.h +186 -0
  115. data/ext/cached/ruby-1.9.3/internal/yarv-headers/regenc.h +219 -0
  116. data/ext/cached/ruby-1.9.3/internal/yarv-headers/regint.h +850 -0
  117. data/ext/cached/ruby-1.9.3/internal/yarv-headers/regparse.h +362 -0
  118. data/ext/cached/ruby-1.9.3/internal/yarv-headers/revision.h +1 -0
  119. data/ext/cached/ruby-1.9.3/internal/yarv-headers/thread_pthread.h +51 -0
  120. data/ext/cached/ruby-1.9.3/internal/yarv-headers/thread_win32.h +40 -0
  121. data/ext/cached/ruby-1.9.3/internal/yarv-headers/timev.h +21 -0
  122. data/ext/cached/ruby-1.9.3/internal/yarv-headers/transcode_data.h +117 -0
  123. data/ext/cached/ruby-1.9.3/internal/yarv-headers/transdb.h +189 -0
  124. data/ext/cached/ruby-1.9.3/internal/yarv-headers/version.h +52 -0
  125. data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_core.h +756 -0
  126. data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_exec.h +184 -0
  127. data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_insnhelper.h +220 -0
  128. data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_opts.h +51 -0
  129. data/ext/internal/binding/block.h +20 -0
  130. data/ext/internal/method/internal_method.h +5 -38
  131. data/ext/internal/method/internal_method.h.rpp +0 -7
  132. data/ext/internal/method/method.c +52 -32
  133. data/ext/internal/module/classpath.c +18 -13
  134. data/ext/internal/module/classpath.h +3 -3
  135. data/ext/internal/module/extconf.rb +3 -2
  136. data/ext/internal/module/getcfp.h +13 -0
  137. data/ext/internal/module/getcfp.h.rpp +44 -0
  138. data/ext/internal/module/module.c +58 -21
  139. data/ext/internal/node/block.h +20 -0
  140. data/ext/internal/node/extconf.rb +2 -0
  141. data/ext/internal/node/global_entry.h +69 -13
  142. data/ext/internal/node/global_entry.h.rpp +11 -2
  143. data/ext/internal/node/node.c +30 -3
  144. data/ext/internal/node/node_type_descrip.c +47 -38
  145. data/ext/internal/node/nodeinfo.c +622 -306
  146. data/ext/internal/node/nodeinfo.h +1 -4
  147. data/ext/internal/proc/block.h +20 -0
  148. data/ext/internal/tag/tag.h +10 -0
  149. data/ext/internal/thread/thread.c +9 -3
  150. data/ext/internal/vm/extconf.rb +1 -0
  151. data/ext/internal/vm/instruction/insns_info.c +3 -5974
  152. data/ext/internal/vm/instruction/insns_info.h +0 -878
  153. data/ext/internal/vm/iseq/extconf.rb +1 -0
  154. data/ext/internal/vm/iseq/iseq.c +38 -4
  155. data/ext/internal/vm/iseq/iseq_load.inc.rpp +23 -5
  156. data/ext/internal/vm/vm.c +28 -0
  157. data/lib/internal/classtree.rb +28 -0
  158. data/lib/internal/debug.rb +10 -2
  159. data/lib/internal/method/as_code.rb +25 -0
  160. data/lib/internal/method/as_expression.rb +2 -3
  161. data/lib/internal/method/origin.rb +29 -0
  162. data/lib/internal/method/signature.rb +5 -300
  163. data/lib/internal/method/signature/argument.rb +102 -0
  164. data/lib/internal/method/signature/iseq.rb +52 -0
  165. data/lib/internal/method/signature/node.rb +160 -0
  166. data/lib/internal/method/signature/signature.rb +23 -0
  167. data/lib/internal/proc/as_code.rb +2 -0
  168. data/lib/internal/proc/as_expression.rb +2 -0
  169. data/lib/internal/vm/bytedecoder.rb +5 -5
  170. data/lib/internal/vm/iseq/as_code.rb +2 -2
  171. data/lib/internal/vm/iseq/as_expression.rb +2 -2
  172. data/test/test_dump_method.rb +1 -1
  173. data/test/test_method.rb +21 -3
  174. data/test/test_node.rb +20 -4
  175. metadata +152 -155
  176. data/ext/cached/ruby-1.6.8/internal/binding/block.h +0 -35
  177. data/ext/cached/ruby-1.6.8/internal/method/method.h +0 -19
  178. data/ext/cached/ruby-1.6.8/internal/module/classpath.c +0 -3
  179. data/ext/cached/ruby-1.6.8/internal/module/classpath.h +0 -8
  180. data/ext/cached/ruby-1.6.8/internal/node/block.h +0 -35
  181. data/ext/cached/ruby-1.6.8/internal/node/global_entry.h +0 -15
  182. data/ext/cached/ruby-1.6.8/internal/node/node_type_descrip.c +0 -149
  183. data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.h +0 -69
  184. data/ext/cached/ruby-1.6.8/internal/proc/block.h +0 -35
  185. data/ext/cached/ruby-1.6.8/internal/tag/tag.h +0 -15
  186. data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.c +0 -39
  187. data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.h +0 -21
  188. data/ext/cached/ruby-1.6.8/internal/vm/iseq/insns_info.inc +0 -12
  189. data/ext/cached/ruby-1.6.8/internal/vm/iseq/iseq_load.inc +0 -9
  190. data/ext/cached/ruby-1.8.0/internal/binding/block.h +0 -37
  191. data/ext/cached/ruby-1.8.0/internal/method/method.h +0 -19
  192. data/ext/cached/ruby-1.8.0/internal/module/classpath.c +0 -27
  193. data/ext/cached/ruby-1.8.0/internal/node/block.h +0 -37
  194. data/ext/cached/ruby-1.8.0/internal/node/global_entry.h +0 -10
  195. data/ext/cached/ruby-1.8.0/internal/node/node_type_descrip.c +0 -155
  196. data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.c +0 -5744
  197. data/ext/cached/ruby-1.8.0/internal/proc/block.h +0 -37
  198. data/ext/cached/ruby-1.8.0/internal/tag/tag.h +0 -15
  199. data/ext/cached/ruby-1.8.0/internal/vm/instruction/insns_info.c +0 -39
  200. data/ext/cached/ruby-1.8.0/internal/vm/instruction/insns_info.h +0 -21
  201. data/ext/cached/ruby-1.8.0/internal/vm/iseq/insns_info.inc +0 -12
  202. data/ext/cached/ruby-1.8.0/internal/vm/iseq/iseq_load.inc +0 -9
  203. data/ext/cached/ruby-1.8.1/internal/binding/block.h +0 -31
  204. data/ext/cached/ruby-1.8.1/internal/method/method.h +0 -19
  205. data/ext/cached/ruby-1.8.1/internal/module/classpath.c +0 -27
  206. data/ext/cached/ruby-1.8.1/internal/module/classpath.h +0 -14
  207. data/ext/cached/ruby-1.8.1/internal/node/block.h +0 -31
  208. data/ext/cached/ruby-1.8.1/internal/node/global_entry.h +0 -10
  209. data/ext/cached/ruby-1.8.1/internal/node/node_type_descrip.c +0 -154
  210. data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.c +0 -5736
  211. data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.h +0 -69
  212. data/ext/cached/ruby-1.8.1/internal/proc/block.h +0 -31
  213. data/ext/cached/ruby-1.8.1/internal/tag/tag.h +0 -16
  214. data/ext/cached/ruby-1.8.1/internal/vm/instruction/insns_info.c +0 -39
  215. data/ext/cached/ruby-1.8.1/internal/vm/instruction/insns_info.h +0 -21
  216. data/ext/cached/ruby-1.8.1/internal/vm/iseq/insns_info.inc +0 -12
  217. data/ext/cached/ruby-1.8.1/internal/vm/iseq/iseq_load.inc +0 -9
  218. data/ext/cached/ruby-1.8.2/internal/binding/block.h +0 -32
  219. data/ext/cached/ruby-1.8.2/internal/method/method.h +0 -19
  220. data/ext/cached/ruby-1.8.2/internal/module/classpath.c +0 -45
  221. data/ext/cached/ruby-1.8.2/internal/module/classpath.h +0 -17
  222. data/ext/cached/ruby-1.8.2/internal/node/block.h +0 -32
  223. data/ext/cached/ruby-1.8.2/internal/node/global_entry.h +0 -10
  224. data/ext/cached/ruby-1.8.2/internal/node/node_type_descrip.c +0 -154
  225. data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.c +0 -5736
  226. data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.h +0 -69
  227. data/ext/cached/ruby-1.8.2/internal/proc/block.h +0 -32
  228. data/ext/cached/ruby-1.8.2/internal/tag/tag.h +0 -16
  229. data/ext/cached/ruby-1.8.2/internal/vm/instruction/insns_info.c +0 -39
  230. data/ext/cached/ruby-1.8.2/internal/vm/instruction/insns_info.h +0 -21
  231. data/ext/cached/ruby-1.8.2/internal/vm/iseq/insns_info.inc +0 -12
  232. data/ext/cached/ruby-1.8.2/internal/vm/iseq/iseq_load.inc +0 -9
  233. data/ext/cached/ruby-1.8.3/internal/binding/block.h +0 -32
  234. data/ext/cached/ruby-1.8.3/internal/module/classpath.c +0 -45
  235. data/ext/cached/ruby-1.8.3/internal/module/classpath.h +0 -17
  236. data/ext/cached/ruby-1.8.3/internal/node/block.h +0 -32
  237. data/ext/cached/ruby-1.8.3/internal/node/global_entry.h +0 -10
  238. data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.c +0 -5736
  239. data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.h +0 -69
  240. data/ext/cached/ruby-1.8.3/internal/proc/block.h +0 -32
  241. data/ext/cached/ruby-1.8.3/internal/tag/tag.h +0 -16
  242. data/ext/cached/ruby-1.8.3/internal/vm/instruction/insns_info.c +0 -39
  243. data/ext/cached/ruby-1.8.3/internal/vm/instruction/insns_info.h +0 -21
  244. data/ext/cached/ruby-1.8.3/internal/vm/iseq/insns_info.inc +0 -12
  245. data/ext/cached/ruby-1.8.3/internal/vm/iseq/iseq_load.inc +0 -9
  246. data/ext/cached/ruby-1.8.7/internal/method/method.h +0 -20
  247. data/ext/cached/ruby-1.9.0/internal/module/classpath.c +0 -42
  248. data/ext/cached/ruby-1.9.0/internal/node/global_entry.h +0 -10
  249. data/ext/cached/ruby-1.9.0/internal/vm/iseq/iseq_load.inc +0 -13
  250. data/ext/cached/ruby-1.9.0/internal/yarv-headers/id.h +0 -83
  251. data/ext/cached/ruby-1.9.0/internal/yarv-headers/revision.h +0 -1
  252. data/ext/cached/ruby-1.9.0/internal/yarv-headers/transdb.h +0 -67
  253. data/ext/cached/ruby-1.9.0/internal/yarv-headers/version.h +0 -57
  254. data/ext/internal/module/cfp.h +0 -13
@@ -3,5 +3,6 @@ require 'mkmf-ruby-internal'
3
3
 
4
4
  have_header('iseq.h')
5
5
  have_header('ruby/node.h') or have_header('node.h')
6
+ have_type('struct RTypedData')
6
7
 
7
8
  create_ruby_internal_makefile 'internal/vm/iseq/iseq'
@@ -11,13 +11,41 @@
11
11
  #ifdef RUBY_VM
12
12
 
13
13
  #include "vm_core.h"
14
-
15
- #include "iseq_load.inc"
14
+ #include "gc.h"
15
+ #include "internal/method/internal_method.h"
16
16
 
17
17
  #ifdef HAVE_ISEQ_H
18
18
  #include "iseq.h"
19
19
  #endif
20
20
 
21
+ #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA
22
+
23
+ # undef GET_THREAD
24
+ # undef GetThreadPtr
25
+ # define GetThreadPtr(obj, ptr) \
26
+ TypedData_Get_Struct((obj), rb_thread_t, p_ruby_threadptr_data_type, (ptr))
27
+
28
+ static rb_data_type_t const * p_ruby_threadptr_data_type;
29
+
30
+ static rb_thread_t * GET_THREAD()
31
+ {
32
+ VALUE thread = rb_thread_current();
33
+ rb_thread_t * th;
34
+ ID * local_tbl;
35
+ GetThreadPtr(thread, th);
36
+ return th;
37
+ }
38
+
39
+ static void init_ruby_threadptr_data_type()
40
+ {
41
+ VALUE thread = rb_thread_current();
42
+ p_ruby_threadptr_data_type = RTYPEDDATA_TYPE(thread);
43
+ }
44
+
45
+ #endif
46
+
47
+ #include "iseq_load.inc"
48
+
21
49
  #ifndef RARRAY_LEN
22
50
  #define RARRAY_LEN(a) RARRAY(a)->len
23
51
  #endif
@@ -368,7 +396,7 @@ static VALUE iseq_insn_line(VALUE self, VALUE n)
368
396
  static VALUE iseq_catch_table(VALUE self)
369
397
  {
370
398
  rb_iseq_t *iseqdat = iseq_check(self);
371
- unsigned long j;
399
+ long j;
372
400
 
373
401
  VALUE catch_table = rb_ary_new();
374
402
 
@@ -475,7 +503,7 @@ static VALUE iseq_marshal_load(VALUE klass, VALUE str)
475
503
  arr = marshal_load(str);
476
504
  convert_placeholders_to_modules(arr);
477
505
 
478
- VALUE iseq = iseq_load(Qnil, arr, 0, Qnil);
506
+ VALUE iseq = iseq_load(rb_cISeq, arr, 0, Qnil);
479
507
  return iseq;
480
508
  }
481
509
 
@@ -504,6 +532,7 @@ void Init_iseq(void)
504
532
 
505
533
  rb_require("internal/node");
506
534
  rb_require("internal/module");
535
+ rb_require("internal/method");
507
536
  rb_require("internal/vm/instruction");
508
537
  rb_require("internal/vm/inline_cache");
509
538
 
@@ -563,5 +592,10 @@ void Init_iseq(void)
563
592
  insn_name(0);
564
593
  insn_op_types(0);
565
594
  #endif
595
+
596
+ #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA
597
+ init_iseq_data_type();
598
+ init_ruby_threadptr_data_type();
599
+ #endif
566
600
  }
567
601
 
@@ -1,10 +1,28 @@
1
1
  #ifndef ruby_internal_iseq_load__inc_
2
2
  #define ruby_internal_iseq_load__inc_
3
3
 
4
- #include "gc.h"
5
- #include "iseq.h"
6
- #include "vm_core.h"
4
+ #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA
7
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
+ #
8
26
  #ruby <<END
9
27
  ruby_version_code = RUBY_VERSION.gsub(/\./, '').to_i
10
28
 
@@ -23,13 +41,13 @@
23
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)/
24
42
  write = true
25
43
  puts prev_line
26
- when /^static.*iseq_data_type.*=/
27
- write = true
28
44
  when /^static.*COMPILE_OPTION_DEFAULT.*=/
29
45
  write = true
30
46
  when /^static.*COMPILE_OPTION_FALSE.*=/
31
47
  write = true
32
48
  stopwrite = true
49
+ when /TypedData_Make_Struct.*\&iseq_data_type/
50
+ line.gsub!(/\&iseq_data_type/, 'p_iseq_data_type')
33
51
  when /^#define CHECK_/,
34
52
  /^static inline VALUE CHECK_/
35
53
  write = true
data/ext/internal/vm/vm.c CHANGED
@@ -4,6 +4,22 @@
4
4
 
5
5
  #include "vm_core.h"
6
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
+
7
23
  extern rb_vm_t * ruby_current_vm;
8
24
 
9
25
  /*
@@ -14,7 +30,15 @@ extern rb_vm_t * ruby_current_vm;
14
30
  */
15
31
  static VALUE vm_current(VALUE klass)
16
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
17
40
  return ruby_current_vm->self;
41
+ #endif
18
42
  }
19
43
 
20
44
  /*
@@ -51,5 +75,9 @@ void Init_vm(void)
51
75
  rb_define_singleton_method(rb_cRubyVM, "current", vm_current, 0);
52
76
  rb_define_method(rb_cRubyVM, "top_self", vm_top_self, 0);
53
77
  #endif
78
+
79
+ #ifdef HAVE_TYPE_STRUCT_RTYPEDDATA
80
+ init_ruby_threadptr_data_type();
81
+ #endif
54
82
  }
55
83
 
@@ -2,6 +2,34 @@ require 'internal/object'
2
2
  require 'internal/module'
3
3
 
4
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
+ # #<Object:0x40330ce8>
9
+ # +-class = Object
10
+ # |-class = #<Class:Object>
11
+ # | |-class = Class
12
+ # | | |-class = #<Class:Class>
13
+ # | | | |-class = #<Class:Class> (*)
14
+ # | | | +-super = #<Class:Module>
15
+ # | | | |-class = Class (*)
16
+ # | | | +-super = #<Class:Object> (*)
17
+ # | | +-super = Module
18
+ # | | |-class = #<Class:Module> (*)
19
+ # | | +-super = Object (*)
20
+ # | +-super = Class (*)
21
+ # +-super = #<PP::ObjectMixin?:0x40349568>
22
+ # +-class = PP::ObjectMixin?
23
+ # |-class = Module (*)
24
+ # +-super = #<Kernel:0x4033507c>
25
+ # +-class = Kernel
26
+ # => nil
27
+ #
28
+ # An asterisk (*) indicates that the class has previously been
29
+ # printed.
30
+ #
31
+ # The notation #<Class:XXXX> indicates a singleton class.
32
+ #
5
33
  def classtree(s = '', prefix = '', obj=self, graphed={})
6
34
  # if Module == obj.class.class then
7
35
  # s << "included module "
@@ -2,14 +2,22 @@ require 'internal/node'
2
2
  require 'internal/node/as_expression'
3
3
  require 'internal/node/pp'
4
4
 
5
- module Nodewrap
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
+ #
6
14
  def printdebug(&block)
7
15
  puts "#{caller[0]}: #{block.body.as_expression} => #{block.call}"
8
16
  end
9
17
  end
10
18
 
11
19
  if __FILE__ == $0 then
12
- include Nodewrap
20
+ include Internal
13
21
  a = 41
14
22
  printdebug { a + 1 }
15
23
  end
@@ -4,6 +4,31 @@ require 'internal/method'
4
4
  require 'internal/method/signature'
5
5
 
6
6
  module MethodAsCode
7
+ # Returns a string representation of the method definition/body.
8
+ #
9
+ # irb(main):001:0> def foo(a, b, *rest, &block)
10
+ # irb(main):002:1> begin
11
+ # irb(main):003:2* if not a and not b then
12
+ # irb(main):004:3* raise "Need more input!"
13
+ # irb(main):005:3> end
14
+ # irb(main):006:2> return a + b
15
+ # irb(main):007:2> ensure
16
+ # irb(main):008:2* puts "In ensure block"
17
+ # irb(main):009:2> end
18
+ # irb(main):010:1> end
19
+ # => nil
20
+ # irb(main):011:0> m = method(:foo)
21
+ # => #<Method: Object#foo>
22
+ # irb(main):012:0> puts m.as_code
23
+ # def foo(a, b, *rest, &block)
24
+ # begin
25
+ # (raise("Need more input!")) if (not a and not b)
26
+ # return a + b
27
+ # ensure
28
+ # puts("In ensure block")
29
+ # end
30
+ # end
31
+ #
7
32
  def as_code(indent=0, name=nil)
8
33
  sig = self.signature
9
34
  if self.body.respond_to?(:body) then
@@ -4,9 +4,8 @@ require 'internal/method/signature'
4
4
  require 'internal/method'
5
5
 
6
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.
7
+ # Return a single-line string representation of a method
8
+ # TODO: this method would be more aptly named "as_expression_string".
10
9
  def as_expression
11
10
  sig = self.signature
12
11
  if self.body.respond_to?(:body) then
@@ -0,0 +1,29 @@
1
+ module MethodOrigin
2
+ # An abstraction for a method origin.
3
+ class Origin
4
+ attr_reader :file, :line
5
+
6
+ def initialize(file, line)
7
+ @file = file
8
+ @line = line
9
+ end
10
+
11
+ def to_s
12
+ return "#{file}:#{line}"
13
+ end
14
+ end
15
+
16
+ # Return a Method::Origin representing where the method was defined.
17
+ def origin
18
+ block = body().next
19
+ return Origin.new(block.nd_file, block.nd_line)
20
+ end
21
+ end
22
+
23
+ class Method
24
+ include MethodOrigin
25
+ end
26
+
27
+ class UnboundMethod
28
+ include MethodOrigin
29
+ end
@@ -1,111 +1,17 @@
1
1
  require 'internal/method'
2
2
  require 'internal/node'
3
3
  require 'internal/node/as_expression'
4
+ require 'internal/method/signature/argument'
5
+ require 'internal/method/signature/node'
6
+ require 'internal/method/signature/signature'
4
7
 
5
8
  if defined?(RubyVM) then
6
9
  require 'internal/vm/bytedecoder'
10
+ require 'internal/method/signature/iseq'
7
11
  end
8
12
 
9
13
  module MethodSig
10
- class Argument
11
- attr_reader :name
12
-
13
- def required?
14
- return !optional?
15
- end
16
-
17
- def optional?
18
- return rest? || block?
19
- end
20
-
21
- def rest?
22
- return @is_rest
23
- end
24
-
25
- def block?
26
- return @is_block
27
- end
28
-
29
- def default
30
- return nil
31
- end
32
-
33
- def initialize(name, is_rest, is_block)
34
- @name = name
35
- @is_rest = is_rest
36
- @is_block = is_block
37
- end
38
-
39
- def to_s
40
- if @is_rest then
41
- prefix = "*"
42
- elsif @is_block then
43
- prefix = "&"
44
- end
45
-
46
- if self.default then
47
- suffix = "=#{default()}"
48
- end
49
-
50
- return "#{prefix}#{@name}#{suffix}"
51
- end
52
- end
53
-
54
- class OptionalArgument < Argument
55
- def optional?
56
- return true
57
- end
58
- end
59
-
60
- class NodeOptionalArgument < OptionalArgument
61
- attr_reader :node_for_default
62
- attr_reader :default
63
-
64
- def initialize(name, default, node_for_default, is_rest, is_block)
65
- super(name, is_rest, is_block)
66
- @default = default
67
- @node_for_default = node_for_default
68
- end
69
- end
70
-
71
- class YarvOptionalArgument < OptionalArgument
72
- attr_reader :iseq
73
- attr_reader :pc_start
74
- attr_reader :local_idx
75
-
76
- def initialize(name, iseq, pc_start, local_idx, is_rest, is_block)
77
- super(name, is_rest, is_block)
78
- @iseq = iseq
79
- @pc_start = pc_start
80
- @local_idx = local_idx
81
- @default = nil
82
- end
83
-
84
- def inspect
85
- default()
86
- super
87
- end
88
-
89
- def default
90
- return @default if @default
91
-
92
- env = Nodewrap::ByteDecoder::Environment.new(@iseq.local_table())
93
- local_table_idx = local_table_idx()
94
- @iseq.bytedecode(env, @pc_start) do |instr|
95
- RubyVM::Instruction::SETLOCAL === instr &&
96
- instr.operands[0] == local_table_idx
97
- end
98
- expressions = env.expressions + env.stack
99
-
100
- @default = expressions[0].rhs.to_s
101
- return @default
102
- end
103
-
104
- def local_table_idx
105
- return @iseq.local_table.size - @local_idx + 1
106
- end
107
- end
108
-
14
+ # Return the names of the local variables of this method.
109
15
  def local_vars
110
16
  return self.body.local_vars
111
17
  end
@@ -169,47 +75,6 @@ module MethodSig
169
75
 
170
76
  return args
171
77
  end
172
-
173
- # An abstraction for a method signature.
174
- class Signature
175
- attr_reader :origin_class, :name, :arg_names, :args
176
-
177
- def initialize(origin_class, name, arg_names, args)
178
- @origin_class = origin_class
179
- @name = name
180
- @arg_names = arg_names
181
- @args = args
182
- end
183
-
184
- def to_s
185
- return "#{@origin_class}\##{@name}(#{param_list})"
186
- end
187
-
188
- def param_list
189
- params = @arg_names.map{ |n| args[n].to_s }
190
- return params.join(', ')
191
- end
192
- end
193
-
194
- # An abstraction for a method origin.
195
- class Origin
196
- attr_reader :file, :line
197
-
198
- def initialize(file, line)
199
- @file = file
200
- @line = line
201
- end
202
-
203
- def to_s
204
- return "#{file}:#{line}"
205
- end
206
- end
207
-
208
- # Return a Method::Origin representing where the method was defined.
209
- def origin
210
- block = body().next
211
- return Origin.new(block.nd_file, block.nd_line)
212
- end
213
78
  end
214
79
 
215
80
  class Method
@@ -238,166 +103,6 @@ class UnboundMethod
238
103
  end
239
104
  end
240
105
 
241
- class Node
242
- # pre-YARV
243
- class SCOPE
244
- include MethodSig
245
-
246
- def local_vars
247
- return self.tbl || []
248
- end
249
-
250
- def argument_names
251
- local_vars = self.local_vars
252
- args = self.args_node
253
- num_required_args = args.cnt
254
- num_optional_args = 0
255
- opt = args.opt
256
- while opt do
257
- num_optional_args += 1
258
- opt = opt.next
259
- end
260
- num_args = \
261
- num_required_args + \
262
- num_optional_args + \
263
- (rest_arg ? 1 : 0) + \
264
- (block_arg ? 1 : 0)
265
- return local_vars[0...num_args]
266
- end
267
-
268
- def args_node
269
- if self.next.class == Node::ARGS then
270
- return self.next
271
- elsif self.next.head.class == Node::ARGS then
272
- return self.next.head
273
- else
274
- raise "Could not find method arguments"
275
- end
276
- end
277
-
278
- def rest_arg
279
- args_node = args_node()
280
- rest = args_node.rest()
281
- if rest.class == Node::LASGN then
282
- # subtract 2 to account for implicit vars
283
- return rest.cnt - 2
284
- elsif not rest
285
- return nil
286
- else
287
- return rest > 0 ? rest - 2 : nil
288
- end
289
- end
290
-
291
- def block_arg
292
- block = self.next
293
- if block.class == Node::BLOCK and
294
- block.next.head.class == Node::BLOCK_ARG then
295
- # subtract 2 to account for implicit vars
296
- return block.next.head.cnt - 2
297
- else
298
- return nil
299
- end
300
- end
301
-
302
- def set_optional_args(args, args_node, names)
303
- opt = args_node.opt
304
- while opt do
305
- head = opt.head
306
- if head.class == Node::LASGN then
307
- args[head.vid] = NodeOptionalArgument.new(
308
- head.vid, head.value.as_expression, head.value, false, false)
309
- else
310
- raise "Unexpected node type: #{opt.class}"
311
- end
312
- opt = opt.next
313
- end
314
- end
315
- end
316
-
317
- # Pre-YARV, I think
318
- class BMETHOD
319
- def local_vars
320
- raise "TODO: Not implemented yet"
321
- end
322
-
323
- def argument_names
324
- return self.cval.arguments.names
325
- end
326
-
327
- def arguments
328
- return self.cval.arguments
329
- end
330
-
331
- def args_node
332
- raise "TODO: Not implemented yet"
333
- end
334
-
335
- def rest_arg
336
- raise "TODO: Not implemented yet"
337
- end
338
-
339
- def block_arg
340
- raise "TODO: Not implemented yet"
341
- end
342
-
343
- def set_optional_args(args, args_node, names)
344
- raise "TODO: Not implemented yet"
345
- end
346
- end
347
-
348
- # YARV
349
- class METHOD
350
- include MethodSig
351
-
352
- def local_vars
353
- iseq = self.body
354
- local_vars = iseq.local_table
355
- return local_vars
356
- end
357
-
358
- def argument_names
359
- local_vars = self.local_vars
360
- iseq = self.body
361
- opt_args = iseq.arg_opt_table
362
- opt_args.pop # last arg is a pointer to the start of the code
363
- num_args = \
364
- iseq.argc + \
365
- opt_args.size + \
366
- (rest_arg ? 1 : 0) + \
367
- (block_arg ? 1 : 0)
368
- return local_vars[0...num_args]
369
- end
370
-
371
- def args_node
372
- return nil
373
- end
374
-
375
- def rest_arg
376
- arg_rest = self.body.arg_rest
377
- return arg_rest >= 0 ? arg_rest : nil
378
- end
379
-
380
- def block_arg
381
- arg_block = self.body.arg_block
382
- return arg_block >= 0 ? arg_block : nil
383
- end
384
-
385
- def set_optional_args(args, args_node, names)
386
- opt_table = self.body.arg_opt_table
387
- opt_table.pop
388
- first_opt_idx =
389
- names.size -
390
- opt_table.size -
391
- (self.rest_arg ? 1 : 0) -
392
- (self.block_arg ? 1 : 0)
393
- opt_table.each_with_index do |pc, idx|
394
- name = names[first_opt_idx + idx]
395
- args[name] = YarvOptionalArgument.new(name, self.body, pc, idx, false, false)
396
- end
397
- end
398
- end
399
- end
400
-
401
106
  if __FILE__ == $0 then
402
107
  def foo(); end
403
108
  puts method(:foo).signature