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,67 @@
1
+ rb_declare_transcoder("", "amp_escape", "escape");
2
+ rb_declare_transcoder("", "xml_text_escape", "escape");
3
+ rb_declare_transcoder("", "xml_attr_content_escape", "escape");
4
+ rb_declare_transcoder("", "xml_attr_quote", "escape");
5
+ rb_declare_transcoder("ISO-2022-JP", "stateless-ISO-2022-JP", "iso2022");
6
+ rb_declare_transcoder("stateless-ISO-2022-JP", "ISO-2022-JP", "iso2022");
7
+ rb_declare_transcoder("stateless-ISO-2022-JP", "EUC-JP", "iso2022");
8
+ rb_declare_transcoder("EUC-JP", "stateless-ISO-2022-JP", "iso2022");
9
+ rb_declare_transcoder("EUC-JP", "Shift_JIS", "japanese");
10
+ rb_declare_transcoder("Shift_JIS", "EUC-JP", "japanese");
11
+ rb_declare_transcoder("EUC-JP", "UTF-8", "japanese_euc");
12
+ rb_declare_transcoder("eucJP-ms", "UTF-8", "japanese_euc");
13
+ rb_declare_transcoder("CP51932", "UTF-8", "japanese_euc");
14
+ rb_declare_transcoder("UTF-8", "EUC-JP", "japanese_euc");
15
+ rb_declare_transcoder("UTF-8", "eucJP-ms", "japanese_euc");
16
+ rb_declare_transcoder("UTF-8", "CP51932", "japanese_euc");
17
+ rb_declare_transcoder("Shift_JIS", "UTF-8", "japanese_sjis");
18
+ rb_declare_transcoder("Windows-31J", "UTF-8", "japanese_sjis");
19
+ rb_declare_transcoder("UTF-8", "Shift_JIS", "japanese_sjis");
20
+ rb_declare_transcoder("UTF-8", "Windows-31J", "japanese_sjis");
21
+ rb_declare_transcoder("UTF-8", "EUC-KR", "korean");
22
+ rb_declare_transcoder("EUC-KR", "UTF-8", "korean");
23
+ rb_declare_transcoder("UTF-8", "CP949", "korean");
24
+ rb_declare_transcoder("CP949", "UTF-8", "korean");
25
+ rb_declare_transcoder("", "universal_newline", "newline");
26
+ rb_declare_transcoder("", "crlf_newline", "newline");
27
+ rb_declare_transcoder("", "cr_newline", "newline");
28
+ rb_declare_transcoder("US-ASCII", "UTF-8", "single_byte");
29
+ rb_declare_transcoder("UTF-8", "US-ASCII", "single_byte");
30
+ rb_declare_transcoder("ASCII-8BIT", "UTF-8", "single_byte");
31
+ rb_declare_transcoder("UTF-8", "ASCII-8BIT", "single_byte");
32
+ rb_declare_transcoder("ISO-8859-1", "UTF-8", "single_byte");
33
+ rb_declare_transcoder("UTF-8", "ISO-8859-1", "single_byte");
34
+ rb_declare_transcoder("ISO-8859-2", "UTF-8", "single_byte");
35
+ rb_declare_transcoder("UTF-8", "ISO-8859-2", "single_byte");
36
+ rb_declare_transcoder("ISO-8859-3", "UTF-8", "single_byte");
37
+ rb_declare_transcoder("UTF-8", "ISO-8859-3", "single_byte");
38
+ rb_declare_transcoder("ISO-8859-4", "UTF-8", "single_byte");
39
+ rb_declare_transcoder("UTF-8", "ISO-8859-4", "single_byte");
40
+ rb_declare_transcoder("ISO-8859-5", "UTF-8", "single_byte");
41
+ rb_declare_transcoder("UTF-8", "ISO-8859-5", "single_byte");
42
+ rb_declare_transcoder("ISO-8859-6", "UTF-8", "single_byte");
43
+ rb_declare_transcoder("UTF-8", "ISO-8859-6", "single_byte");
44
+ rb_declare_transcoder("ISO-8859-7", "UTF-8", "single_byte");
45
+ rb_declare_transcoder("UTF-8", "ISO-8859-7", "single_byte");
46
+ rb_declare_transcoder("ISO-8859-8", "UTF-8", "single_byte");
47
+ rb_declare_transcoder("UTF-8", "ISO-8859-8", "single_byte");
48
+ rb_declare_transcoder("ISO-8859-9", "UTF-8", "single_byte");
49
+ rb_declare_transcoder("UTF-8", "ISO-8859-9", "single_byte");
50
+ rb_declare_transcoder("ISO-8859-10", "UTF-8", "single_byte");
51
+ rb_declare_transcoder("UTF-8", "ISO-8859-10", "single_byte");
52
+ rb_declare_transcoder("ISO-8859-11", "UTF-8", "single_byte");
53
+ rb_declare_transcoder("UTF-8", "ISO-8859-11", "single_byte");
54
+ rb_declare_transcoder("ISO-8859-13", "UTF-8", "single_byte");
55
+ rb_declare_transcoder("UTF-8", "ISO-8859-13", "single_byte");
56
+ rb_declare_transcoder("ISO-8859-14", "UTF-8", "single_byte");
57
+ rb_declare_transcoder("UTF-8", "ISO-8859-14", "single_byte");
58
+ rb_declare_transcoder("ISO-8859-15", "UTF-8", "single_byte");
59
+ rb_declare_transcoder("UTF-8", "ISO-8859-15", "single_byte");
60
+ rb_declare_transcoder("UTF-16BE", "UTF-8", "utf_16_32");
61
+ rb_declare_transcoder("UTF-8", "UTF-16BE", "utf_16_32");
62
+ rb_declare_transcoder("UTF-16LE", "UTF-8", "utf_16_32");
63
+ rb_declare_transcoder("UTF-8", "UTF-16LE", "utf_16_32");
64
+ rb_declare_transcoder("UTF-32BE", "UTF-8", "utf_16_32");
65
+ rb_declare_transcoder("UTF-8", "UTF-32BE", "utf_16_32");
66
+ rb_declare_transcoder("UTF-32LE", "UTF-8", "utf_16_32");
67
+ rb_declare_transcoder("UTF-8", "UTF-32LE", "utf_16_32");
@@ -0,0 +1,57 @@
1
+ #define RUBY_VERSION "1.9.0"
2
+ #define RUBY_RELEASE_DATE "2008-10-04"
3
+ #define RUBY_VERSION_CODE 190
4
+ #define RUBY_RELEASE_CODE 20081004
5
+ #define RUBY_PATCHLEVEL 0
6
+
7
+ #define RUBY_VERSION_MAJOR 1
8
+ #define RUBY_VERSION_MINOR 9
9
+ #define RUBY_VERSION_TEENY 0
10
+ #define RUBY_RELEASE_YEAR 2008
11
+ #define RUBY_RELEASE_MONTH 10
12
+ #define RUBY_RELEASE_DAY 4
13
+
14
+ #ifdef RUBY_EXTERN
15
+ RUBY_EXTERN const char ruby_version[];
16
+ RUBY_EXTERN const char ruby_release_date[];
17
+ RUBY_EXTERN const char ruby_platform[];
18
+ RUBY_EXTERN const int ruby_patchlevel;
19
+ RUBY_EXTERN const char ruby_description[];
20
+ RUBY_EXTERN const char ruby_copyright[];
21
+ #endif
22
+
23
+ #define RUBY_AUTHOR "Yukihiro Matsumoto"
24
+ #define RUBY_BIRTH_YEAR 1993
25
+ #define RUBY_BIRTH_MONTH 2
26
+ #define RUBY_BIRTH_DAY 24
27
+
28
+ #ifndef RUBY_REVISION
29
+ #include "revision.h"
30
+ #endif
31
+ #ifndef RUBY_REVISION
32
+ #define RUBY_REVISION 0
33
+ #endif
34
+
35
+ #if RUBY_VERSION_TEENY > 0 && RUBY_PATCHLEVEL < 5000 && !RUBY_REVISION
36
+ #define RUBY_RELEASE_STR "patchlevel"
37
+ #define RUBY_RELEASE_NUM RUBY_PATCHLEVEL
38
+ #else
39
+ #ifdef RUBY_BRANCH_NAME
40
+ #define RUBY_RELEASE_STR RUBY_BRANCH_NAME
41
+ #else
42
+ #define RUBY_RELEASE_STR "revision"
43
+ #endif
44
+ #define RUBY_RELEASE_NUM RUBY_REVISION
45
+ #endif
46
+
47
+ # define RUBY_DESCRIPTION \
48
+ "ruby "RUBY_VERSION \
49
+ " ("RUBY_RELEASE_DATE" " \
50
+ RUBY_RELEASE_STR" " \
51
+ STRINGIZE(RUBY_RELEASE_NUM)") " \
52
+ "["RUBY_PLATFORM"]"
53
+ # define RUBY_COPYRIGHT \
54
+ "ruby - Copyright (C) " \
55
+ STRINGIZE(RUBY_BIRTH_YEAR)"-" \
56
+ STRINGIZE(RUBY_RELEASE_YEAR)" " \
57
+ RUBY_AUTHOR
@@ -0,0 +1,663 @@
1
+ /**********************************************************************
2
+
3
+ vm_core.h -
4
+
5
+ $Author: ko1 $
6
+ created at: 04/01/01 19:41:38 JST
7
+
8
+ Copyright (C) 2004-2007 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_VM_CORE_H
13
+ #define RUBY_VM_CORE_H
14
+
15
+ #define RUBY_VM_THREAD_MODEL 2
16
+
17
+ #include "ruby/ruby.h"
18
+ #include "ruby/vm.h"
19
+ #include "ruby/st.h"
20
+
21
+ #include "node.h"
22
+ #include "debug.h"
23
+ #include "vm_opts.h"
24
+ #include "id.h"
25
+
26
+ #if defined(_WIN32)
27
+ #include "thread_win32.h"
28
+ #elif defined(HAVE_PTHREAD_H)
29
+ #include "thread_pthread.h"
30
+ #else
31
+ #error "unsupported thread type"
32
+ #endif
33
+
34
+ #include <setjmp.h>
35
+ #include <signal.h>
36
+
37
+ #ifndef NSIG
38
+ # ifdef DJGPP
39
+ # define NSIG SIGMAX
40
+ # elif defined MACOS_UNUSE_SIGNAL
41
+ # define NSIG 1
42
+ # else
43
+ # define NSIG (_SIGMAX + 1) /* For QNX */
44
+ # endif
45
+ #endif
46
+
47
+ #define RUBY_NSIG NSIG
48
+
49
+ #ifdef HAVE_STDARG_PROTOTYPES
50
+ #include <stdarg.h>
51
+ #define va_init_list(a,b) va_start(a,b)
52
+ #else
53
+ #include <varargs.h>
54
+ #define va_init_list(a,b) va_start(a)
55
+ #endif
56
+
57
+ /*****************/
58
+ /* configuration */
59
+ /*****************/
60
+
61
+ /* gcc ver. check */
62
+ #if defined(__GNUC__) && __GNUC__ >= 2
63
+
64
+ #if OPT_TOKEN_THREADED_CODE
65
+ #if OPT_DIRECT_THREADED_CODE
66
+ #undef OPT_DIRECT_THREADED_CODE
67
+ #endif
68
+ #endif
69
+
70
+ #else /* defined(__GNUC__) && __GNUC__ >= 2 */
71
+
72
+ /* disable threaded code options */
73
+ #if OPT_DIRECT_THREADED_CODE
74
+ #undef OPT_DIRECT_THREADED_CODE
75
+ #endif
76
+ #if OPT_TOKEN_THREADED_CODE
77
+ #undef OPT_TOKEN_THREADED_CODE
78
+ #endif
79
+ #endif
80
+
81
+ /* call threaded code */
82
+ #if OPT_CALL_THREADED_CODE
83
+ #if OPT_DIRECT_THREADED_CODE
84
+ #undef OPT_DIRECT_THREADED_CODE
85
+ #endif /* OPT_DIRECT_THREADED_CODE */
86
+ #if OPT_STACK_CACHING
87
+ #undef OPT_STACK_CACHING
88
+ #endif /* OPT_STACK_CACHING */
89
+ #endif /* OPT_CALL_THREADED_CODE */
90
+
91
+ /* likely */
92
+ #if __GNUC__ >= 3
93
+ #define LIKELY(x) (__builtin_expect((x), 1))
94
+ #define UNLIKELY(x) (__builtin_expect((x), 0))
95
+ #else /* __GNUC__ >= 3 */
96
+ #define LIKELY(x) (x)
97
+ #define UNLIKELY(x) (x)
98
+ #endif /* __GNUC__ >= 3 */
99
+
100
+ typedef unsigned long rb_num_t;
101
+
102
+ struct iseq_compile_data_ensure_node_stack;
103
+
104
+ typedef struct rb_compile_option_struct {
105
+ int inline_const_cache;
106
+ int peephole_optimization;
107
+ int tailcall_optimization;
108
+ int specialized_instruction;
109
+ int operands_unification;
110
+ int instructions_unification;
111
+ int stack_caching;
112
+ int trace_instruction;
113
+ int debug_level;
114
+ } rb_compile_option_t;
115
+
116
+ #if 1
117
+ #define GetCoreDataFromValue(obj, type, ptr) do { \
118
+ ptr = (type*)DATA_PTR(obj); \
119
+ } while (0)
120
+ #else
121
+ #define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct(obj, type, ptr)
122
+ #endif
123
+
124
+ #define GetISeqPtr(obj, ptr) \
125
+ GetCoreDataFromValue(obj, rb_iseq_t, ptr)
126
+
127
+ struct rb_iseq_struct;
128
+
129
+ struct rb_iseq_struct {
130
+ /***************/
131
+ /* static data */
132
+ /***************/
133
+
134
+ VALUE type; /* instruction sequence type */
135
+ VALUE name; /* String: iseq name */
136
+ VALUE filename; /* file information where this sequence from */
137
+ VALUE *iseq; /* iseq (insn number and openrads) */
138
+ VALUE *iseq_encoded; /* encoded iseq */
139
+ unsigned long iseq_size;
140
+ VALUE mark_ary; /* Array: includes operands which should be GC marked */
141
+ VALUE coverage; /* coverage array */
142
+
143
+ /* insn info, must be freed */
144
+ struct iseq_insn_info_entry *insn_info_table;
145
+ unsigned long insn_info_size;
146
+
147
+ ID *local_table; /* must free */
148
+ int local_table_size;
149
+
150
+ /* method, class frame: sizeof(vars) + 1, block frame: sizeof(vars) */
151
+ int local_size;
152
+
153
+ /**
154
+ * argument information
155
+ *
156
+ * def m(a1, a2, ..., aM, # mandatory
157
+ * b1=(...), b2=(...), ..., bN=(...), # optinal
158
+ * *c, # rest
159
+ * d1, d2, ..., dO, # post
160
+ * &e) # block
161
+ * =>
162
+ *
163
+ * argc = M
164
+ * arg_rest = M+N+1 // or -1 if no rest arg
165
+ * arg_opts = N
166
+ * arg_opts_tbl = [ (N entries) ]
167
+ * arg_post_len = O // 0 if no post arguments
168
+ * arg_post_start = M+N+2
169
+ * arg_block = M+N + 1 + O + 1 // -1 if no block arg
170
+ * arg_simple = 0 if not simple arguments.
171
+ * = 1 if no opt, rest, post, block.
172
+ * = 2 if ambiguos block parameter ({|a|}).
173
+ * arg_size = argument size.
174
+ */
175
+
176
+ int argc;
177
+ int arg_simple;
178
+ int arg_rest;
179
+ int arg_block;
180
+ int arg_opts;
181
+ int arg_post_len;
182
+ int arg_post_start;
183
+ int arg_size;
184
+ VALUE *arg_opt_table;
185
+
186
+ int stack_max; /* for stack overflow check */
187
+
188
+ /* catch table */
189
+ struct iseq_catch_table_entry *catch_table;
190
+ int catch_table_size;
191
+
192
+ /* for child iseq */
193
+ struct rb_iseq_struct *parent_iseq;
194
+ struct rb_iseq_struct *local_iseq;
195
+
196
+ /****************/
197
+ /* dynamic data */
198
+ /****************/
199
+
200
+ VALUE self;
201
+ VALUE orig; /* non-NULL if its data have origin */
202
+
203
+ /* block inlining */
204
+ /*
205
+ * NODE *node;
206
+ * void *special_block_builder;
207
+ * void *cached_special_block_builder;
208
+ * VALUE cached_special_block;
209
+ */
210
+
211
+ /* klass/module nest information stack (cref) */
212
+ NODE *cref_stack;
213
+ VALUE klass;
214
+
215
+ /* misc */
216
+ ID defined_method_id; /* for define_method */
217
+
218
+ /* used at compile time */
219
+ struct iseq_compile_data *compile_data;
220
+ };
221
+
222
+ enum ruby_special_exceptions {
223
+ ruby_error_reenter,
224
+ ruby_error_nomemory,
225
+ ruby_error_sysstack,
226
+ ruby_special_error_count
227
+ };
228
+
229
+ typedef struct rb_iseq_struct rb_iseq_t;
230
+
231
+ #define GetVMPtr(obj, ptr) \
232
+ GetCoreDataFromValue(obj, rb_vm_t, ptr)
233
+
234
+ struct rb_vm_struct
235
+ {
236
+ VALUE self;
237
+
238
+ rb_thread_lock_t global_vm_lock;
239
+
240
+ struct rb_thread_struct *main_thread;
241
+ struct rb_thread_struct *running_thread;
242
+
243
+ st_table *living_threads;
244
+ VALUE thgroup_default;
245
+
246
+ int running;
247
+ int thread_abort_on_exception;
248
+ unsigned long trace_flag;
249
+ volatile int sleeper;
250
+
251
+ /* object management */
252
+ VALUE mark_object_ary;
253
+
254
+ VALUE special_exceptions[ruby_special_error_count];
255
+
256
+ /* load */
257
+ VALUE top_self;
258
+ VALUE load_path;
259
+ VALUE loaded_features;
260
+ struct st_table *loading_table;
261
+
262
+ /* signal */
263
+ struct {
264
+ VALUE cmd;
265
+ int safe;
266
+ } trap_list[RUBY_NSIG];
267
+
268
+ /* hook */
269
+ rb_event_hook_t *event_hooks;
270
+
271
+ int src_encoding_index;
272
+
273
+ VALUE verbose, debug, progname;
274
+ VALUE coverages;
275
+
276
+ #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
277
+ struct rb_objspace *objspace;
278
+ #endif
279
+ };
280
+
281
+ typedef struct {
282
+ VALUE *pc; /* cfp[0] */
283
+ VALUE *sp; /* cfp[1] */
284
+ VALUE *bp; /* cfp[2] */
285
+ rb_iseq_t *iseq; /* cfp[3] */
286
+ VALUE flag; /* cfp[4] */
287
+ VALUE self; /* cfp[5] / block[0] */
288
+ VALUE *lfp; /* cfp[6] / block[1] */
289
+ VALUE *dfp; /* cfp[7] / block[2] */
290
+ rb_iseq_t *block_iseq; /* cfp[8] / block[3] */
291
+ VALUE proc; /* cfp[9] / block[4] */
292
+ ID method_id; /* cfp[10] saved in special case */
293
+ VALUE method_class; /* cfp[11] saved in special case */
294
+ } rb_control_frame_t;
295
+
296
+ typedef struct rb_block_struct {
297
+ VALUE self; /* share with method frame if it's only block */
298
+ VALUE *lfp; /* share with method frame if it's only block */
299
+ VALUE *dfp; /* share with method frame if it's only block */
300
+ rb_iseq_t *iseq;
301
+ VALUE proc;
302
+ } rb_block_t;
303
+
304
+ #define GetThreadPtr(obj, ptr) \
305
+ GetCoreDataFromValue(obj, rb_thread_t, ptr)
306
+
307
+ enum rb_thread_status {
308
+ THREAD_TO_KILL,
309
+ THREAD_RUNNABLE,
310
+ THREAD_STOPPED,
311
+ THREAD_STOPPED_FOREVER,
312
+ THREAD_KILLED
313
+ };
314
+
315
+ typedef RUBY_JMP_BUF rb_jmpbuf_t;
316
+
317
+ struct rb_vm_tag {
318
+ rb_jmpbuf_t buf;
319
+ VALUE tag;
320
+ VALUE retval;
321
+ struct rb_vm_tag *prev;
322
+ };
323
+
324
+ struct rb_vm_trap_tag {
325
+ struct rb_vm_trap_tag *prev;
326
+ };
327
+
328
+ #define RUBY_VM_VALUE_CACHE_SIZE 0x1000
329
+ #define USE_VALUE_CACHE 0
330
+
331
+ struct rb_unblock_callback {
332
+ rb_unblock_function_t *func;
333
+ void *arg;
334
+ };
335
+
336
+ struct rb_mutex_struct;
337
+
338
+ typedef struct rb_thread_struct
339
+ {
340
+ VALUE self;
341
+ rb_vm_t *vm;
342
+
343
+ /* execution information */
344
+ VALUE *stack; /* must free, must mark */
345
+ unsigned long stack_size;
346
+ rb_control_frame_t *cfp;
347
+ int safe_level;
348
+ int raised_flag;
349
+ VALUE last_status; /* $? */
350
+
351
+ /* passing state */
352
+ int state;
353
+
354
+ /* for rb_iterate */
355
+ rb_block_t *passed_block;
356
+
357
+ /* for load(true) */
358
+ VALUE top_self;
359
+ VALUE top_wrapper;
360
+
361
+ /* eval env */
362
+ rb_block_t *base_block;
363
+
364
+ VALUE *local_lfp;
365
+ VALUE local_svar;
366
+
367
+ /* thread control */
368
+ rb_thread_id_t thread_id;
369
+ enum rb_thread_status status;
370
+ int priority;
371
+ int slice;
372
+
373
+ native_thread_data_t native_thread_data;
374
+
375
+ VALUE thgroup;
376
+ VALUE value;
377
+
378
+ VALUE errinfo;
379
+ VALUE thrown_errinfo;
380
+ int exec_signal;
381
+
382
+ int interrupt_flag;
383
+ rb_thread_lock_t interrupt_lock;
384
+ struct rb_unblock_callback unblock;
385
+ VALUE locking_mutex;
386
+ struct rb_mutex_struct *keeping_mutexes;
387
+ int transition_for_lock;
388
+
389
+ struct rb_vm_tag *tag;
390
+ struct rb_vm_trap_tag *trap_tag;
391
+
392
+ int parse_in_eval;
393
+ int mild_compile_error;
394
+
395
+ /* storage */
396
+ st_table *local_storage;
397
+ #if USE_VALUE_CACHE
398
+ VALUE value_cache[RUBY_VM_VALUE_CACHE_SIZE + 1];
399
+ VALUE *value_cache_ptr;
400
+ #endif
401
+
402
+ struct rb_thread_struct *join_list_next;
403
+ struct rb_thread_struct *join_list_head;
404
+
405
+ VALUE first_proc;
406
+ VALUE first_args;
407
+ VALUE (*first_func)(ANYARGS);
408
+
409
+ /* for GC */
410
+ VALUE *machine_stack_start;
411
+ VALUE *machine_stack_end;
412
+ size_t machine_stack_maxsize;
413
+ #ifdef __ia64
414
+ VALUE *machine_register_stack_start;
415
+ VALUE *machine_register_stack_end;
416
+ size_t machine_register_stack_maxsize;
417
+ #endif
418
+ jmp_buf machine_regs;
419
+ int mark_stack_len;
420
+
421
+ /* statistics data for profiler */
422
+ VALUE stat_insn_usage;
423
+
424
+ /* tracer */
425
+ rb_event_hook_t *event_hooks;
426
+ rb_event_flag_t event_flags;
427
+ int tracing;
428
+
429
+ /* fiber */
430
+ VALUE fiber;
431
+ VALUE root_fiber;
432
+ rb_jmpbuf_t root_jmpbuf;
433
+
434
+ /* misc */
435
+ int method_missing_reason;
436
+ int abort_on_exception;
437
+ } rb_thread_t;
438
+
439
+ /* iseq.c */
440
+ VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE);
441
+ VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE parent);
442
+ VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE);
443
+ VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, const rb_compile_option_t*);
444
+ VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
445
+ VALUE ruby_iseq_disasm(VALUE self);
446
+ VALUE ruby_iseq_disasm_insn(VALUE str, VALUE *iseqval, int pos, rb_iseq_t *iseq, VALUE child);
447
+ const char *ruby_node_name(int node);
448
+ int rb_iseq_first_lineno(rb_iseq_t *iseq);
449
+
450
+ RUBY_EXTERN VALUE rb_cISeq;
451
+ RUBY_EXTERN VALUE rb_cRubyVM;
452
+ RUBY_EXTERN VALUE rb_cEnv;
453
+ RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
454
+
455
+ /* each thread has this size stack : 128KB */
456
+ #define RUBY_VM_THREAD_STACK_SIZE (128 * 1024)
457
+
458
+ struct global_entry {
459
+ struct global_variable *var;
460
+ ID id;
461
+ };
462
+
463
+ #define GetProcPtr(obj, ptr) \
464
+ GetCoreDataFromValue(obj, rb_proc_t, ptr)
465
+
466
+ typedef struct {
467
+ rb_block_t block;
468
+
469
+ VALUE envval; /* for GC mark */
470
+ VALUE blockprocval;
471
+ int safe_level;
472
+ int is_from_method;
473
+ int is_lambda;
474
+ } rb_proc_t;
475
+
476
+ #define GetEnvPtr(obj, ptr) \
477
+ GetCoreDataFromValue(obj, rb_env_t, ptr)
478
+
479
+ typedef struct {
480
+ VALUE *env;
481
+ int env_size;
482
+ int local_size;
483
+ VALUE prev_envval; /* for GC mark */
484
+ rb_block_t block;
485
+ } rb_env_t;
486
+
487
+ #define GetBindingPtr(obj, ptr) \
488
+ GetCoreDataFromValue(obj, rb_binding_t, ptr)
489
+
490
+ typedef struct {
491
+ VALUE env;
492
+ } rb_binding_t;
493
+
494
+
495
+ /* used by compile time and send insn */
496
+ #define VM_CALL_ARGS_SPLAT_BIT (0x01 << 1)
497
+ #define VM_CALL_ARGS_BLOCKARG_BIT (0x01 << 2)
498
+ #define VM_CALL_FCALL_BIT (0x01 << 3)
499
+ #define VM_CALL_VCALL_BIT (0x01 << 4)
500
+ #define VM_CALL_TAILCALL_BIT (0x01 << 5)
501
+ #define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
502
+ #define VM_CALL_SUPER_BIT (0x01 << 7)
503
+ #define VM_CALL_SEND_BIT (0x01 << 8)
504
+
505
+ #define VM_SPECIAL_OBJECT_VMCORE 0x01
506
+ #define VM_SPECIAL_OBJECT_CBASE 0x02
507
+
508
+ #define VM_FRAME_MAGIC_METHOD 0x11
509
+ #define VM_FRAME_MAGIC_BLOCK 0x21
510
+ #define VM_FRAME_MAGIC_CLASS 0x31
511
+ #define VM_FRAME_MAGIC_TOP 0x41
512
+ #define VM_FRAME_MAGIC_FINISH 0x51
513
+ #define VM_FRAME_MAGIC_CFUNC 0x61
514
+ #define VM_FRAME_MAGIC_PROC 0x71
515
+ #define VM_FRAME_MAGIC_IFUNC 0x81
516
+ #define VM_FRAME_MAGIC_EVAL 0x91
517
+ #define VM_FRAME_MAGIC_LAMBDA 0xa1
518
+ #define VM_FRAME_MAGIC_MASK_BITS 8
519
+ #define VM_FRAME_MAGIC_MASK (~(~0<<VM_FRAME_MAGIC_MASK_BITS))
520
+
521
+ #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
522
+
523
+ /* other frame flag */
524
+ #define VM_FRAME_FLAG_PASSED 0x0100
525
+
526
+
527
+ #define RUBYVM_CFUNC_FRAME_P(cfp) \
528
+ (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
529
+
530
+
531
+ /* inline (method|const) cache */
532
+ #define NEW_INLINE_CACHE_ENTRY() NEW_WHILE(Qundef, 0, 0)
533
+ #define ic_class u1.value
534
+ #define ic_method u2.node
535
+ #define ic_value u2.value
536
+ #define ic_vmstat u3.cnt
537
+ typedef NODE *IC;
538
+
539
+ void rb_vm_change_state(void);
540
+
541
+ typedef VALUE CDHASH;
542
+
543
+ #ifndef FUNC_FASTCALL
544
+ #define FUNC_FASTCALL(x) x
545
+ #endif
546
+
547
+ typedef rb_control_frame_t *
548
+ (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
549
+
550
+ #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
551
+ #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)p) & ~0x03))
552
+ #define GC_GUARDED_PTR_P(p) (((VALUE)p) & 0x01)
553
+
554
+ #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) (cfp+1)
555
+ #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) (cfp-1)
556
+ #define RUBY_VM_END_CONTROL_FRAME(th) \
557
+ ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
558
+ #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
559
+ ((void *)(ecfp) > (void *)(cfp))
560
+ #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
561
+ (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
562
+
563
+ #define RUBY_VM_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE)
564
+ #define RUBY_VM_NORMAL_ISEQ_P(ptr) \
565
+ (ptr && !RUBY_VM_IFUNC_P(ptr))
566
+
567
+ #define RUBY_VM_CLASS_SPECIAL_P(ptr) (((VALUE)(ptr)) & 0x02)
568
+
569
+ #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
570
+ #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
571
+ ((rb_control_frame_t *)((VALUE *)(b) - 5))
572
+
573
+ /* VM related object allocate functions */
574
+ VALUE rb_thread_alloc(VALUE klass);
575
+ VALUE rb_proc_alloc(VALUE klass);
576
+
577
+ /* for debug */
578
+ extern void vm_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
579
+ #define SDR() vm_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
580
+ #define SDR2(cfp) vm_stack_dump_raw(GET_THREAD(), (cfp))
581
+ void rb_vm_bugreport(void);
582
+
583
+
584
+ /* functions about thread/vm execution */
585
+
586
+ VALUE rb_iseq_eval(VALUE iseqval);
587
+ void rb_enable_interrupt(void);
588
+ void rb_disable_interrupt(void);
589
+ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
590
+
591
+ VALUE vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
592
+ int argc, const VALUE *argv, rb_block_t *blockptr);
593
+ VALUE vm_make_proc(rb_thread_t *th, rb_control_frame_t *cfp, const rb_block_t *block, VALUE klass);
594
+ VALUE vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
595
+
596
+ NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
597
+
598
+ #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
599
+
600
+ /* for thread */
601
+
602
+ #if RUBY_VM_THREAD_MODEL == 2
603
+ RUBY_EXTERN rb_thread_t *ruby_current_thread;
604
+ extern rb_vm_t *ruby_current_vm;
605
+
606
+ #define GET_VM() ruby_current_vm
607
+ #define GET_THREAD() ruby_current_thread
608
+ #define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
609
+ #define rb_thread_set_current(th) do { \
610
+ rb_thread_set_current_raw(th); \
611
+ th->vm->running_thread = th; \
612
+ } while (0)
613
+
614
+ #else
615
+ #error "unsupported thread model"
616
+ #endif
617
+
618
+ #define RUBY_VM_SET_INTERRUPT(th) ((th)->interrupt_flag |= 0x02)
619
+ #define RUBY_VM_SET_TIMER_INTERRUPT(th) ((th)->interrupt_flag |= 0x01)
620
+ #define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ((th)->interrupt_flag |= 0x04)
621
+ #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02)
622
+
623
+ void rb_thread_execute_interrupts(rb_thread_t *);
624
+
625
+ #define RUBY_VM_CHECK_INTS_TH(th) do { \
626
+ if (UNLIKELY(th->interrupt_flag)) { \
627
+ rb_thread_execute_interrupts(th); \
628
+ } \
629
+ } while (0)
630
+
631
+ #define RUBY_VM_CHECK_INTS() \
632
+ RUBY_VM_CHECK_INTS_TH(GET_THREAD())
633
+
634
+ /* tracer */
635
+ static inline void
636
+ exec_event_hooks(rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass)
637
+ {
638
+ if (self == rb_mRubyVMFrozenCore) return;
639
+ while (hook) {
640
+ if (flag & hook->flag) {
641
+ (*hook->func)(flag, hook->data, self, id, klass);
642
+ }
643
+ hook = hook->next;
644
+ }
645
+ }
646
+
647
+ #define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \
648
+ rb_event_flag_t wait_event__ = th->event_flags; \
649
+ if (UNLIKELY(wait_event__)) { \
650
+ if (wait_event__ & (flag | RUBY_EVENT_VM)) { \
651
+ VALUE self__ = (self), klass__ = (klass); \
652
+ ID id__ = (id); \
653
+ if (wait_event__ & flag) { \
654
+ exec_event_hooks(th->event_hooks, flag, self__, id__, klass__); \
655
+ } \
656
+ if (wait_event__ & RUBY_EVENT_VM) { \
657
+ exec_event_hooks(th->vm->event_hooks, flag, self__, id__, klass__); \
658
+ } \
659
+ } \
660
+ } \
661
+ } while (0)
662
+
663
+ #endif /* RUBY_VM_CORE_H */