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
@@ -0,0 +1,102 @@
1
+
2
+ module MethodSig
3
+ class Argument
4
+ attr_reader :name
5
+
6
+ def required?
7
+ return !optional?
8
+ end
9
+
10
+ def optional?
11
+ return rest? || block?
12
+ end
13
+
14
+ def rest?
15
+ return @is_rest
16
+ end
17
+
18
+ def block?
19
+ return @is_block
20
+ end
21
+
22
+ def default
23
+ return nil
24
+ end
25
+
26
+ def initialize(name, is_rest, is_block)
27
+ @name = name
28
+ @is_rest = is_rest
29
+ @is_block = is_block
30
+ end
31
+
32
+ def to_s
33
+ if @is_rest then
34
+ prefix = "*"
35
+ elsif @is_block then
36
+ prefix = "&"
37
+ end
38
+
39
+ if self.default then
40
+ suffix = "=#{default()}"
41
+ end
42
+
43
+ return "#{prefix}#{@name}#{suffix}"
44
+ end
45
+ end
46
+
47
+ class OptionalArgument < Argument
48
+ def optional?
49
+ return true
50
+ end
51
+ end
52
+
53
+ class NodeOptionalArgument < OptionalArgument
54
+ attr_reader :node_for_default
55
+ attr_reader :default
56
+
57
+ def initialize(name, default, node_for_default, is_rest, is_block)
58
+ super(name, is_rest, is_block)
59
+ @default = default
60
+ @node_for_default = node_for_default
61
+ end
62
+ end
63
+
64
+ class YarvOptionalArgument < OptionalArgument
65
+ attr_reader :iseq
66
+ attr_reader :pc_start
67
+ attr_reader :local_idx
68
+
69
+ def initialize(name, iseq, pc_start, local_idx, is_rest, is_block)
70
+ super(name, is_rest, is_block)
71
+ @iseq = iseq
72
+ @pc_start = pc_start
73
+ @local_idx = local_idx
74
+ @default = nil
75
+ end
76
+
77
+ def inspect
78
+ default()
79
+ super
80
+ end
81
+
82
+ def default
83
+ return @default if @default
84
+
85
+ env = Internal::ByteDecoder::Environment.new(@iseq.local_table())
86
+ local_table_idx = local_table_idx()
87
+ @iseq.bytedecode(env, @pc_start) do |instr|
88
+ RubyVM::Instruction::SETLOCAL === instr &&
89
+ instr.operands[0] == local_table_idx
90
+ end
91
+ expressions = env.expressions + env.stack
92
+
93
+ @default = expressions[0].rhs.to_s
94
+ return @default
95
+ end
96
+
97
+ def local_table_idx
98
+ return @iseq.local_table.size - @local_idx + 1
99
+ end
100
+ end
101
+ end
102
+
@@ -0,0 +1,52 @@
1
+ class RubyVM
2
+ # YARV 1.9.2 and later
3
+ class InstructionSequence
4
+ include MethodSig
5
+
6
+ def local_vars
7
+ local_vars = self.local_table
8
+ return local_vars
9
+ end
10
+
11
+ def argument_names
12
+ local_vars = self.local_vars
13
+ opt_args = self.arg_opt_table
14
+ opt_args.pop # last arg is a pointer to the start of the code
15
+ num_args = \
16
+ self.argc + \
17
+ opt_args.size + \
18
+ (rest_arg ? 1 : 0) + \
19
+ (block_arg ? 1 : 0)
20
+ return local_vars[0...num_args]
21
+ end
22
+
23
+ def args_node
24
+ return nil
25
+ end
26
+
27
+ def rest_arg
28
+ arg_rest = self.arg_rest
29
+ return arg_rest >= 0 ? arg_rest : nil
30
+ end
31
+
32
+ def block_arg
33
+ arg_block = self.arg_block
34
+ return arg_block >= 0 ? arg_block : nil
35
+ end
36
+
37
+ def set_optional_args(args, args_node, names)
38
+ opt_table = self.arg_opt_table
39
+ opt_table.pop
40
+ first_opt_idx =
41
+ names.size -
42
+ opt_table.size -
43
+ (self.rest_arg ? 1 : 0) -
44
+ (self.block_arg ? 1 : 0)
45
+ opt_table.each_with_index do |pc, idx|
46
+ name = names[first_opt_idx + idx]
47
+ args[name] = YarvOptionalArgument.new(name, self, pc, idx, false, false)
48
+ end
49
+ end
50
+ end
51
+ end
52
+
@@ -0,0 +1,160 @@
1
+ class Node
2
+ # pre-YARV
3
+ class SCOPE
4
+ include MethodSig
5
+
6
+ def local_vars
7
+ return self.tbl || []
8
+ end
9
+
10
+ def argument_names
11
+ local_vars = self.local_vars
12
+ args = self.args_node
13
+ num_required_args = args.cnt
14
+ num_optional_args = 0
15
+ opt = args.opt
16
+ while opt do
17
+ num_optional_args += 1
18
+ opt = opt.next
19
+ end
20
+ num_args = \
21
+ num_required_args + \
22
+ num_optional_args + \
23
+ (rest_arg ? 1 : 0) + \
24
+ (block_arg ? 1 : 0)
25
+ return local_vars[0...num_args]
26
+ end
27
+
28
+ def args_node
29
+ if self.next.class == Node::ARGS then
30
+ return self.next
31
+ elsif self.next.head.class == Node::ARGS then
32
+ return self.next.head
33
+ else
34
+ raise "Could not find method arguments"
35
+ end
36
+ end
37
+
38
+ def rest_arg
39
+ args_node = args_node()
40
+ rest = args_node.rest()
41
+ if rest.class == Node::LASGN then
42
+ # subtract 2 to account for implicit vars
43
+ return rest.cnt - 2
44
+ elsif not rest
45
+ return nil
46
+ else
47
+ return rest > 0 ? rest - 2 : nil
48
+ end
49
+ end
50
+
51
+ def block_arg
52
+ block = self.next
53
+ if block.class == Node::BLOCK and
54
+ block.next.head.class == Node::BLOCK_ARG then
55
+ # subtract 2 to account for implicit vars
56
+ return block.next.head.cnt - 2
57
+ else
58
+ return nil
59
+ end
60
+ end
61
+
62
+ def set_optional_args(args, args_node, names)
63
+ opt = args_node.opt
64
+ while opt do
65
+ head = opt.head
66
+ if head.class == Node::LASGN then
67
+ args[head.vid] = NodeOptionalArgument.new(
68
+ head.vid, head.value.as_expression, head.value, false, false)
69
+ else
70
+ raise "Unexpected node type: #{opt.class}"
71
+ end
72
+ opt = opt.next
73
+ end
74
+ end
75
+ end
76
+
77
+ # Pre-YARV, I think
78
+ class BMETHOD
79
+ def local_vars
80
+ raise "TODO: Not implemented yet"
81
+ end
82
+
83
+ def argument_names
84
+ return self.cval.arguments.names
85
+ end
86
+
87
+ def arguments
88
+ return self.cval.arguments
89
+ end
90
+
91
+ def args_node
92
+ raise "TODO: Not implemented yet"
93
+ end
94
+
95
+ def rest_arg
96
+ raise "TODO: Not implemented yet"
97
+ end
98
+
99
+ def block_arg
100
+ raise "TODO: Not implemented yet"
101
+ end
102
+
103
+ def set_optional_args(args, args_node, names)
104
+ raise "TODO: Not implemented yet"
105
+ end
106
+ end
107
+
108
+ # YARV up to 1.9.1
109
+ class METHOD
110
+ include MethodSig
111
+
112
+ def local_vars
113
+ iseq = self.body
114
+ local_vars = iseq.local_table
115
+ return local_vars
116
+ end
117
+
118
+ def argument_names
119
+ local_vars = self.local_vars
120
+ iseq = self.body
121
+ opt_args = iseq.arg_opt_table
122
+ opt_args.pop # last arg is a pointer to the start of the code
123
+ num_args = \
124
+ iseq.argc + \
125
+ opt_args.size + \
126
+ (rest_arg ? 1 : 0) + \
127
+ (block_arg ? 1 : 0)
128
+ return local_vars[0...num_args]
129
+ end
130
+
131
+ def args_node
132
+ return nil
133
+ end
134
+
135
+ def rest_arg
136
+ arg_rest = self.body.arg_rest
137
+ return arg_rest >= 0 ? arg_rest : nil
138
+ end
139
+
140
+ def block_arg
141
+ arg_block = self.body.arg_block
142
+ return arg_block >= 0 ? arg_block : nil
143
+ end
144
+
145
+ def set_optional_args(args, args_node, names)
146
+ opt_table = self.body.arg_opt_table
147
+ opt_table.pop
148
+ first_opt_idx =
149
+ names.size -
150
+ opt_table.size -
151
+ (self.rest_arg ? 1 : 0) -
152
+ (self.block_arg ? 1 : 0)
153
+ opt_table.each_with_index do |pc, idx|
154
+ name = names[first_opt_idx + idx]
155
+ args[name] = YarvOptionalArgument.new(name, self.body, pc, idx, false, false)
156
+ end
157
+ end
158
+ end
159
+ end
160
+
@@ -0,0 +1,23 @@
1
+ module MethodSig
2
+ # An abstraction for a method signature.
3
+ class Signature
4
+ attr_reader :origin_class, :name, :arg_names, :args
5
+
6
+ def initialize(origin_class, name, arg_names, args)
7
+ @origin_class = origin_class
8
+ @name = name
9
+ @arg_names = arg_names
10
+ @args = args
11
+ end
12
+
13
+ def to_s
14
+ return "#{@origin_class}\##{@name}(#{param_list})"
15
+ end
16
+
17
+ def param_list
18
+ params = @arg_names.map{ |n| args[n].to_s }
19
+ return params.join(', ')
20
+ end
21
+ end
22
+ end
23
+
@@ -3,6 +3,8 @@ require 'internal/proc'
3
3
  require 'internal/proc/signature'
4
4
 
5
5
  class Proc
6
+ # Return a string representation of a proc's definition/body,
7
+ # similarly to +Method#as_code+.
6
8
  def as_code(indent=0)
7
9
  sig = self.signature
8
10
  body_expression = self.body ? self.body.as_code(indent+1) : nil
@@ -3,6 +3,8 @@ require 'internal/proc/signature'
3
3
  require 'internal/proc'
4
4
 
5
5
  class Proc
6
+ # Return a single-line string representation of a proc's
7
+ # definition/body, similarly to +Method#as_expression+.
6
8
  def as_expression
7
9
  sig = self.signature
8
10
  body_expression = self.body ? self.body.as_expression : nil
@@ -3,7 +3,7 @@ require 'internal/vm/instruction'
3
3
  require 'internal/vm/inline_cache'
4
4
  require 'internal/vm/constants'
5
5
 
6
- module Nodewrap
6
+ module Internal
7
7
 
8
8
  # A module for decoding YARV bytecode.
9
9
  #
@@ -13,7 +13,7 @@ module Nodewrap
13
13
  # could use this as a base for building one.
14
14
  #
15
15
  # Example usage:
16
- # env = Nodewrap::ByteDecoder::Environment.new(is.local_table)
16
+ # env = Internal::ByteDecoder::Environment.new(is.local_table)
17
17
  # is = RubyVM::InstructionSequence.new('1 + 1')
18
18
  # is.bytedecode(env)
19
19
  # env.expressions.each do |expr|
@@ -450,11 +450,11 @@ end
450
450
 
451
451
  end # ByteDecoder
452
452
 
453
- end # Nodewrap
453
+ end # Internal
454
454
 
455
455
  class RubyVM
456
456
  class Instruction
457
- include Nodewrap::ByteDecoder
457
+ include Internal::ByteDecoder
458
458
 
459
459
  class PUTOBJECT
460
460
  def bytedecode(env)
@@ -839,7 +839,7 @@ if __FILE__ == $0 then
839
839
  is = n.body
840
840
  puts is.disasm
841
841
 
842
- env = Nodewrap::ByteDecoder::Environment.new(is.local_table)
842
+ env = Internal::ByteDecoder::Environment.new(is.local_table)
843
843
  s = ''
844
844
  # puts "local_table = #{is.local_table.inspect}"
845
845
  is.each do |i|
@@ -6,14 +6,14 @@ if defined?(RubyVM::InstructionSequence) then
6
6
  class RubyVM
7
7
  class InstructionSequence
8
8
  def as_code(indent=0)
9
- env = Nodewrap::ByteDecoder::Environment.new(local_table())
9
+ env = Internal::ByteDecoder::Environment.new(local_table())
10
10
  opt_pc = self.opt_pc
11
11
  self.bytedecode(env, opt_pc)
12
12
  expressions = env.expressions + env.stack
13
13
  if expressions.length == 0 then
14
14
  return nil
15
15
  elsif expressions.length == 1 and
16
- expressions[0].is_a?(Nodewrap::ByteDecoder::Expression::Literal) and
16
+ expressions[0].is_a?(Internal::ByteDecoder::Expression::Literal) and
17
17
  expressions[0].value == nil then
18
18
  return nil
19
19
  else
@@ -6,14 +6,14 @@ if defined?(RubyVM::InstructionSequence) then
6
6
  class RubyVM
7
7
  class InstructionSequence
8
8
  def as_expression
9
- env = Nodewrap::ByteDecoder::Environment.new(local_table())
9
+ env = Internal::ByteDecoder::Environment.new(local_table())
10
10
  opt_pc = self.opt_pc
11
11
  self.bytedecode(env, opt_pc)
12
12
  expressions = env.expressions + env.stack
13
13
  if expressions.length == 0 then
14
14
  return nil
15
15
  elsif expressions.length == 1 and
16
- expressions[0].is_a?(Nodewrap::ByteDecoder::Expression::Literal) and
16
+ expressions[0].is_a?(Internal::ByteDecoder::Expression::Literal) and
17
17
  expressions[0].value == nil then
18
18
  return nil
19
19
  else
@@ -139,6 +139,6 @@ class TC_Dump_Module < Test::Unit::TestCase
139
139
  end
140
140
 
141
141
  if __FILE__ == $0 then
142
- exit Test::Unit::AutoRunner.run
142
+ # exit Test::Unit::AutoRunner.run
143
143
  end
144
144