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,21 @@
1
+ #ifndef RUBY_TIMEV_H
2
+ #define RUBY_TIMEV_H
3
+
4
+ struct vtm {
5
+ VALUE year; /* 2000 for example. Integer. */
6
+ int mon; /* 1..12 */
7
+ int mday; /* 1..31 */
8
+ int hour; /* 0..23 */
9
+ int min; /* 0..59 */
10
+ int sec; /* 0..60 */
11
+ VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
12
+ VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */
13
+ int wday; /* 0:Sunday, 1:Monday, ..., 6:Saturday */
14
+ int yday; /* 1..366 */
15
+ int isdst; /* 0:StandardTime 1:DayLightSavingTime */
16
+ const char *zone; /* "JST", "EST", "EDT", etc. */
17
+ };
18
+
19
+ #define TIME_SCALE 1000000000
20
+
21
+ #endif
@@ -0,0 +1,117 @@
1
+ /**********************************************************************
2
+
3
+ transcode_data.h -
4
+
5
+ $Author: nobu $
6
+ created at: Mon 10 Dec 2007 14:01:47 JST 2007
7
+
8
+ Copyright (C) 2007 Martin Duerst
9
+
10
+ **********************************************************************/
11
+
12
+ #include "ruby/ruby.h"
13
+
14
+ #ifndef RUBY_TRANSCODE_DATA_H
15
+ #define RUBY_TRANSCODE_DATA_H 1
16
+
17
+ #if defined __GNUC__ && __GNUC__ >= 4
18
+ #pragma GCC visibility push(default)
19
+ #endif
20
+
21
+ #define WORDINDEX_SHIFT_BITS 2
22
+ #define WORDINDEX2INFO(widx) ((widx) << WORDINDEX_SHIFT_BITS)
23
+ #define INFO2WORDINDEX(info) ((info) >> WORDINDEX_SHIFT_BITS)
24
+ #define BYTE_LOOKUP_BASE(bl) ((bl)[0])
25
+ #define BYTE_LOOKUP_INFO(bl) ((bl)[1])
26
+
27
+ #define PType (unsigned int)
28
+
29
+ #define NOMAP (PType 0x01) /* direct map */
30
+ #define ONEbt (0x02) /* one byte payload */
31
+ #define TWObt (0x03) /* two bytes payload */
32
+ #define THREEbt (0x05) /* three bytes payload */
33
+ #define FOURbt (0x06) /* four bytes payload, UTF-8 only, macros start at getBT0 */
34
+ #define INVALID (PType 0x07) /* invalid byte sequence */
35
+ #define UNDEF (PType 0x09) /* legal but undefined */
36
+ #define ZERObt (PType 0x0A) /* zero bytes of payload, i.e. remove */
37
+ #define FUNii (PType 0x0B) /* function from info to info */
38
+ #define FUNsi (PType 0x0D) /* function from start to info */
39
+ #define FUNio (PType 0x0E) /* function from info to output */
40
+ #define FUNso (PType 0x0F) /* function from start to output */
41
+ #define STR1 (PType 0x11) /* string 4 <= len <= 259 bytes: 1byte length + content */
42
+ #define GB4bt (PType 0x12) /* GB18030 four bytes payload */
43
+ #define FUNsio (PType 0x13) /* function from start and info to output */
44
+
45
+ #define STR1_LENGTH(byte_addr) (unsigned int)(*(byte_addr) + 4)
46
+ #define STR1_BYTEINDEX(w) ((w) >> 6)
47
+ #define makeSTR1(bi) (((bi) << 6) | STR1)
48
+ #define makeSTR1LEN(len) ((len)-4)
49
+
50
+ #define o1(b1) (PType((((unsigned char)(b1))<<8)|ONEbt))
51
+ #define o2(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|TWObt))
52
+ #define o3(b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned int)(unsigned char)(b3))<<24)|THREEbt)&0xffffffffU))
53
+ #define o4(b0,b1,b2,b3) (PType(((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|(((unsigned char)(b3))<<24)|((((unsigned char)(b0))&0x07)<<5)|FOURbt)&0xffffffffU))
54
+ #define g4(b0,b1,b2,b3) (PType(((((unsigned char)(b0))<<8)|(((unsigned char)(b2))<<16)|((((unsigned char)(b1))&0x0f)<<24)|((((unsigned int)(unsigned char)(b3))&0x0f)<<28)|GB4bt)&0xffffffffU))
55
+ #define funsio(diff) (PType((((unsigned int)(diff))<<8)|FUNsio))
56
+
57
+ #define getBT1(a) ((unsigned char)((a)>> 8))
58
+ #define getBT2(a) ((unsigned char)((a)>>16))
59
+ #define getBT3(a) ((unsigned char)((a)>>24))
60
+ #define getBT0(a) (((unsigned char)((a)>> 5)&0x07)|0xF0) /* for UTF-8 only!!! */
61
+
62
+ #define getGB4bt0(a) ((unsigned char)((a)>> 8))
63
+ #define getGB4bt1(a) (((unsigned char)((a)>>24)&0x0F)|0x30)
64
+ #define getGB4bt2(a) ((unsigned char)((a)>>16))
65
+ #define getGB4bt3(a) (((unsigned char)((a)>>28)&0x0F)|0x30)
66
+
67
+ #define o2FUNii(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|FUNii))
68
+
69
+ /* do we need these??? maybe not, can be done with simple tables */
70
+ #define ONETRAIL /* legal but undefined if one more trailing UTF-8 */
71
+ #define TWOTRAIL /* legal but undefined if two more trailing UTF-8 */
72
+ #define THREETRAIL /* legal but undefined if three more trailing UTF-8 */
73
+
74
+ typedef enum {
75
+ asciicompat_converter, /* ASCII-compatible -> ASCII-compatible */
76
+ asciicompat_decoder, /* ASCII-incompatible -> ASCII-compatible */
77
+ asciicompat_encoder /* ASCII-compatible -> ASCII-incompatible */
78
+ /* ASCII-incompatible -> ASCII-incompatible is intentionally omitted. */
79
+ } rb_transcoder_asciicompat_type_t;
80
+
81
+ typedef struct rb_transcoder rb_transcoder;
82
+
83
+ /* static structure, one per supported encoding pair */
84
+ struct rb_transcoder {
85
+ const char *src_encoding;
86
+ const char *dst_encoding;
87
+ unsigned int conv_tree_start;
88
+ const unsigned char *byte_array;
89
+ unsigned int byte_array_length;
90
+ const unsigned int *word_array;
91
+ unsigned int word_array_length;
92
+ int word_size;
93
+ int input_unit_length;
94
+ int max_input;
95
+ int max_output;
96
+ rb_transcoder_asciicompat_type_t asciicompat_type;
97
+ size_t state_size;
98
+ int (*state_init_func)(void*); /* ret==0:success ret!=0:failure(errno) */
99
+ int (*state_fini_func)(void*); /* ret==0:success ret!=0:failure(errno) */
100
+ VALUE (*func_ii)(void*, VALUE); /* info -> info */
101
+ VALUE (*func_si)(void*, const unsigned char*, size_t); /* start -> info */
102
+ ssize_t (*func_io)(void*, VALUE, const unsigned char*, size_t); /* info -> output */
103
+ ssize_t (*func_so)(void*, const unsigned char*, size_t, unsigned char*, size_t); /* start -> output */
104
+ ssize_t (*finish_func)(void*, unsigned char*, size_t); /* -> output */
105
+ ssize_t (*resetsize_func)(void*); /* -> len */
106
+ ssize_t (*resetstate_func)(void*, unsigned char*, size_t); /* -> output */
107
+ ssize_t (*func_sio)(void*, const unsigned char*, size_t, VALUE, unsigned char*, size_t); /* start -> output */
108
+ };
109
+
110
+ void rb_declare_transcoder(const char *enc1, const char *enc2, const char *lib);
111
+ void rb_register_transcoder(const rb_transcoder *);
112
+
113
+ #if defined __GNUC__ && __GNUC__ >= 4
114
+ #pragma GCC visibility pop
115
+ #endif
116
+
117
+ #endif /* RUBY_TRANSCODE_DATA_H */
@@ -0,0 +1,189 @@
1
+ rb_declare_transcoder("Big5", "UTF-8", "big5");
2
+ rb_declare_transcoder("UTF-8", "Big5", "big5");
3
+ rb_declare_transcoder("CP950", "UTF-8", "big5");
4
+ rb_declare_transcoder("UTF-8", "CP950", "big5");
5
+ rb_declare_transcoder("Big5-HKSCS", "UTF-8", "big5");
6
+ rb_declare_transcoder("UTF-8", "Big5-HKSCS", "big5");
7
+ rb_declare_transcoder("CP951", "UTF-8", "big5");
8
+ rb_declare_transcoder("UTF-8", "CP951", "big5");
9
+ rb_declare_transcoder("Big5-UAO", "UTF-8", "big5");
10
+ rb_declare_transcoder("UTF-8", "Big5-UAO", "big5");
11
+ rb_declare_transcoder("GB2312", "UTF-8", "chinese");
12
+ rb_declare_transcoder("GB12345", "UTF-8", "chinese");
13
+ rb_declare_transcoder("UTF-8", "GB2312", "chinese");
14
+ rb_declare_transcoder("UTF-8", "GB12345", "chinese");
15
+ rb_declare_transcoder("UTF8-DoCoMo", "UTF8-KDDI", "emoji");
16
+ rb_declare_transcoder("UTF8-DoCoMo", "UTF8-SoftBank", "emoji");
17
+ rb_declare_transcoder("UTF8-DoCoMo", "UTF-8", "emoji");
18
+ rb_declare_transcoder("UTF8-KDDI", "UTF8-DoCoMo", "emoji");
19
+ rb_declare_transcoder("UTF8-KDDI", "UTF8-SoftBank", "emoji");
20
+ rb_declare_transcoder("UTF8-KDDI", "UTF-8", "emoji");
21
+ rb_declare_transcoder("UTF8-SoftBank", "UTF8-DoCoMo", "emoji");
22
+ rb_declare_transcoder("UTF8-SoftBank", "UTF8-KDDI", "emoji");
23
+ rb_declare_transcoder("UTF8-SoftBank", "UTF-8", "emoji");
24
+ rb_declare_transcoder("UTF-8", "UTF8-DoCoMo", "emoji");
25
+ rb_declare_transcoder("UTF-8", "UTF8-KDDI", "emoji");
26
+ rb_declare_transcoder("UTF-8", "UTF8-SoftBank", "emoji");
27
+ rb_declare_transcoder("stateless-ISO-2022-JP-KDDI", "UTF8-KDDI", "emoji_iso2022_kddi");
28
+ rb_declare_transcoder("UTF8-KDDI", "stateless-ISO-2022-JP-KDDI", "emoji_iso2022_kddi");
29
+ rb_declare_transcoder("ISO-2022-JP-KDDI", "stateless-ISO-2022-JP-KDDI", "emoji_iso2022_kddi");
30
+ rb_declare_transcoder("stateless-ISO-2022-JP-KDDI", "ISO-2022-JP-KDDI", "emoji_iso2022_kddi");
31
+ rb_declare_transcoder("SJIS-DOCOMO", "UTF8-DOCOMO", "emoji_sjis_docomo");
32
+ rb_declare_transcoder("UTF8-DOCOMO", "SJIS-DOCOMO", "emoji_sjis_docomo");
33
+ rb_declare_transcoder("SJIS-KDDI", "UTF8-KDDI", "emoji_sjis_kddi");
34
+ rb_declare_transcoder("UTF8-KDDI", "SJIS-KDDI", "emoji_sjis_kddi");
35
+ rb_declare_transcoder("SJIS-SoftBank", "UTF8-SoftBank", "emoji_sjis_softbank");
36
+ rb_declare_transcoder("UTF8-SoftBank", "SJIS-SoftBank", "emoji_sjis_softbank");
37
+ rb_declare_transcoder("", "amp_escape", "escape");
38
+ rb_declare_transcoder("", "xml_text_escape", "escape");
39
+ rb_declare_transcoder("", "xml_attr_content_escape", "escape");
40
+ rb_declare_transcoder("", "xml_attr_quote", "escape");
41
+ rb_declare_transcoder("GB18030", "UTF-8", "gb18030");
42
+ rb_declare_transcoder("UTF-8", "GB18030", "gb18030");
43
+ rb_declare_transcoder("GBK", "UTF-8", "gbk");
44
+ rb_declare_transcoder("UTF-8", "GBK", "gbk");
45
+ rb_declare_transcoder("ISO-2022-JP", "stateless-ISO-2022-JP", "iso2022");
46
+ rb_declare_transcoder("stateless-ISO-2022-JP", "ISO-2022-JP", "iso2022");
47
+ rb_declare_transcoder("stateless-ISO-2022-JP", "EUC-JP", "iso2022");
48
+ rb_declare_transcoder("EUC-JP", "stateless-ISO-2022-JP", "iso2022");
49
+ rb_declare_transcoder("CP50220", "cp51932", "iso2022");
50
+ rb_declare_transcoder("CP50221", "cp51932", "iso2022");
51
+ rb_declare_transcoder("CP51932", "CP50221", "iso2022");
52
+ rb_declare_transcoder("CP51932", "CP50220", "iso2022");
53
+ rb_declare_transcoder("EUC-JP", "Shift_JIS", "japanese");
54
+ rb_declare_transcoder("Shift_JIS", "EUC-JP", "japanese");
55
+ rb_declare_transcoder("EUC-JP", "UTF-8", "japanese_euc");
56
+ rb_declare_transcoder("eucJP-ms", "UTF-8", "japanese_euc");
57
+ rb_declare_transcoder("CP51932", "UTF-8", "japanese_euc");
58
+ rb_declare_transcoder("UTF-8", "EUC-JP", "japanese_euc");
59
+ rb_declare_transcoder("UTF-8", "eucJP-ms", "japanese_euc");
60
+ rb_declare_transcoder("UTF-8", "CP51932", "japanese_euc");
61
+ rb_declare_transcoder("Shift_JIS", "UTF-8", "japanese_sjis");
62
+ rb_declare_transcoder("Windows-31J", "UTF-8", "japanese_sjis");
63
+ rb_declare_transcoder("UTF-8", "Shift_JIS", "japanese_sjis");
64
+ rb_declare_transcoder("UTF-8", "Windows-31J", "japanese_sjis");
65
+ rb_declare_transcoder("UTF-8", "EUC-KR", "korean");
66
+ rb_declare_transcoder("EUC-KR", "UTF-8", "korean");
67
+ rb_declare_transcoder("UTF-8", "CP949", "korean");
68
+ rb_declare_transcoder("CP949", "UTF-8", "korean");
69
+ rb_declare_transcoder("", "universal_newline", "newline");
70
+ rb_declare_transcoder("", "crlf_newline", "newline");
71
+ rb_declare_transcoder("", "cr_newline", "newline");
72
+ rb_declare_transcoder("US-ASCII", "UTF-8", "single_byte");
73
+ rb_declare_transcoder("UTF-8", "US-ASCII", "single_byte");
74
+ rb_declare_transcoder("ASCII-8BIT", "UTF-8", "single_byte");
75
+ rb_declare_transcoder("UTF-8", "ASCII-8BIT", "single_byte");
76
+ rb_declare_transcoder("ISO-8859-1", "UTF-8", "single_byte");
77
+ rb_declare_transcoder("UTF-8", "ISO-8859-1", "single_byte");
78
+ rb_declare_transcoder("ISO-8859-2", "UTF-8", "single_byte");
79
+ rb_declare_transcoder("UTF-8", "ISO-8859-2", "single_byte");
80
+ rb_declare_transcoder("ISO-8859-3", "UTF-8", "single_byte");
81
+ rb_declare_transcoder("UTF-8", "ISO-8859-3", "single_byte");
82
+ rb_declare_transcoder("ISO-8859-4", "UTF-8", "single_byte");
83
+ rb_declare_transcoder("UTF-8", "ISO-8859-4", "single_byte");
84
+ rb_declare_transcoder("ISO-8859-5", "UTF-8", "single_byte");
85
+ rb_declare_transcoder("UTF-8", "ISO-8859-5", "single_byte");
86
+ rb_declare_transcoder("ISO-8859-6", "UTF-8", "single_byte");
87
+ rb_declare_transcoder("UTF-8", "ISO-8859-6", "single_byte");
88
+ rb_declare_transcoder("ISO-8859-7", "UTF-8", "single_byte");
89
+ rb_declare_transcoder("UTF-8", "ISO-8859-7", "single_byte");
90
+ rb_declare_transcoder("ISO-8859-8", "UTF-8", "single_byte");
91
+ rb_declare_transcoder("UTF-8", "ISO-8859-8", "single_byte");
92
+ rb_declare_transcoder("ISO-8859-9", "UTF-8", "single_byte");
93
+ rb_declare_transcoder("UTF-8", "ISO-8859-9", "single_byte");
94
+ rb_declare_transcoder("ISO-8859-10", "UTF-8", "single_byte");
95
+ rb_declare_transcoder("UTF-8", "ISO-8859-10", "single_byte");
96
+ rb_declare_transcoder("ISO-8859-11", "UTF-8", "single_byte");
97
+ rb_declare_transcoder("UTF-8", "ISO-8859-11", "single_byte");
98
+ rb_declare_transcoder("ISO-8859-13", "UTF-8", "single_byte");
99
+ rb_declare_transcoder("UTF-8", "ISO-8859-13", "single_byte");
100
+ rb_declare_transcoder("ISO-8859-14", "UTF-8", "single_byte");
101
+ rb_declare_transcoder("UTF-8", "ISO-8859-14", "single_byte");
102
+ rb_declare_transcoder("ISO-8859-15", "UTF-8", "single_byte");
103
+ rb_declare_transcoder("UTF-8", "ISO-8859-15", "single_byte");
104
+ rb_declare_transcoder("WINDOWS-874", "UTF-8", "single_byte");
105
+ rb_declare_transcoder("UTF-8", "WINDOWS-874", "single_byte");
106
+ rb_declare_transcoder("WINDOWS-1250", "UTF-8", "single_byte");
107
+ rb_declare_transcoder("UTF-8", "WINDOWS-1250", "single_byte");
108
+ rb_declare_transcoder("WINDOWS-1251", "UTF-8", "single_byte");
109
+ rb_declare_transcoder("UTF-8", "WINDOWS-1251", "single_byte");
110
+ rb_declare_transcoder("WINDOWS-1252", "UTF-8", "single_byte");
111
+ rb_declare_transcoder("UTF-8", "WINDOWS-1252", "single_byte");
112
+ rb_declare_transcoder("WINDOWS-1253", "UTF-8", "single_byte");
113
+ rb_declare_transcoder("UTF-8", "WINDOWS-1253", "single_byte");
114
+ rb_declare_transcoder("WINDOWS-1254", "UTF-8", "single_byte");
115
+ rb_declare_transcoder("UTF-8", "WINDOWS-1254", "single_byte");
116
+ rb_declare_transcoder("WINDOWS-1255", "UTF-8", "single_byte");
117
+ rb_declare_transcoder("UTF-8", "WINDOWS-1255", "single_byte");
118
+ rb_declare_transcoder("WINDOWS-1256", "UTF-8", "single_byte");
119
+ rb_declare_transcoder("UTF-8", "WINDOWS-1256", "single_byte");
120
+ rb_declare_transcoder("WINDOWS-1257", "UTF-8", "single_byte");
121
+ rb_declare_transcoder("UTF-8", "WINDOWS-1257", "single_byte");
122
+ rb_declare_transcoder("IBM437", "UTF-8", "single_byte");
123
+ rb_declare_transcoder("UTF-8", "IBM437", "single_byte");
124
+ rb_declare_transcoder("IBM775", "UTF-8", "single_byte");
125
+ rb_declare_transcoder("UTF-8", "IBM775", "single_byte");
126
+ rb_declare_transcoder("IBM737", "UTF-8", "single_byte");
127
+ rb_declare_transcoder("UTF-8", "IBM737", "single_byte");
128
+ rb_declare_transcoder("IBM852", "UTF-8", "single_byte");
129
+ rb_declare_transcoder("UTF-8", "IBM852", "single_byte");
130
+ rb_declare_transcoder("IBM855", "UTF-8", "single_byte");
131
+ rb_declare_transcoder("UTF-8", "IBM855", "single_byte");
132
+ rb_declare_transcoder("IBM857", "UTF-8", "single_byte");
133
+ rb_declare_transcoder("UTF-8", "IBM857", "single_byte");
134
+ rb_declare_transcoder("IBM860", "UTF-8", "single_byte");
135
+ rb_declare_transcoder("UTF-8", "IBM860", "single_byte");
136
+ rb_declare_transcoder("IBM861", "UTF-8", "single_byte");
137
+ rb_declare_transcoder("UTF-8", "IBM861", "single_byte");
138
+ rb_declare_transcoder("IBM862", "UTF-8", "single_byte");
139
+ rb_declare_transcoder("UTF-8", "IBM862", "single_byte");
140
+ rb_declare_transcoder("IBM863", "UTF-8", "single_byte");
141
+ rb_declare_transcoder("UTF-8", "IBM863", "single_byte");
142
+ rb_declare_transcoder("IBM865", "UTF-8", "single_byte");
143
+ rb_declare_transcoder("UTF-8", "IBM865", "single_byte");
144
+ rb_declare_transcoder("IBM866", "UTF-8", "single_byte");
145
+ rb_declare_transcoder("UTF-8", "IBM866", "single_byte");
146
+ rb_declare_transcoder("IBM869", "UTF-8", "single_byte");
147
+ rb_declare_transcoder("UTF-8", "IBM869", "single_byte");
148
+ rb_declare_transcoder("MACCROATIAN", "UTF-8", "single_byte");
149
+ rb_declare_transcoder("UTF-8", "MACCROATIAN", "single_byte");
150
+ rb_declare_transcoder("MACCYRILLIC", "UTF-8", "single_byte");
151
+ rb_declare_transcoder("UTF-8", "MACCYRILLIC", "single_byte");
152
+ rb_declare_transcoder("MACGREEK", "UTF-8", "single_byte");
153
+ rb_declare_transcoder("UTF-8", "MACGREEK", "single_byte");
154
+ rb_declare_transcoder("MACICELAND", "UTF-8", "single_byte");
155
+ rb_declare_transcoder("UTF-8", "MACICELAND", "single_byte");
156
+ rb_declare_transcoder("MACROMAN", "UTF-8", "single_byte");
157
+ rb_declare_transcoder("UTF-8", "MACROMAN", "single_byte");
158
+ rb_declare_transcoder("MACROMANIA", "UTF-8", "single_byte");
159
+ rb_declare_transcoder("UTF-8", "MACROMANIA", "single_byte");
160
+ rb_declare_transcoder("MACTURKISH", "UTF-8", "single_byte");
161
+ rb_declare_transcoder("UTF-8", "MACTURKISH", "single_byte");
162
+ rb_declare_transcoder("MACUKRAINE", "UTF-8", "single_byte");
163
+ rb_declare_transcoder("UTF-8", "MACUKRAINE", "single_byte");
164
+ rb_declare_transcoder("KOI8-U", "UTF-8", "single_byte");
165
+ rb_declare_transcoder("UTF-8", "KOI8-U", "single_byte");
166
+ rb_declare_transcoder("KOI8-R", "UTF-8", "single_byte");
167
+ rb_declare_transcoder("UTF-8", "KOI8-R", "single_byte");
168
+ rb_declare_transcoder("TIS-620", "UTF-8", "single_byte");
169
+ rb_declare_transcoder("UTF-8", "TIS-620", "single_byte");
170
+ rb_declare_transcoder("CP850", "UTF-8", "single_byte");
171
+ rb_declare_transcoder("UTF-8", "CP850", "single_byte");
172
+ rb_declare_transcoder("CP852", "UTF-8", "single_byte");
173
+ rb_declare_transcoder("UTF-8", "CP852", "single_byte");
174
+ rb_declare_transcoder("CP855", "UTF-8", "single_byte");
175
+ rb_declare_transcoder("UTF-8", "CP855", "single_byte");
176
+ rb_declare_transcoder("UTF-8", "UTF8-MAC", "utf8_mac");
177
+ rb_declare_transcoder("UTF8-MAC", "UTF-8", "utf8_mac");
178
+ rb_declare_transcoder("UTF-16BE", "UTF-8", "utf_16_32");
179
+ rb_declare_transcoder("UTF-8", "UTF-16BE", "utf_16_32");
180
+ rb_declare_transcoder("UTF-16LE", "UTF-8", "utf_16_32");
181
+ rb_declare_transcoder("UTF-8", "UTF-16LE", "utf_16_32");
182
+ rb_declare_transcoder("UTF-32BE", "UTF-8", "utf_16_32");
183
+ rb_declare_transcoder("UTF-8", "UTF-32BE", "utf_16_32");
184
+ rb_declare_transcoder("UTF-32LE", "UTF-8", "utf_16_32");
185
+ rb_declare_transcoder("UTF-8", "UTF-32LE", "utf_16_32");
186
+ rb_declare_transcoder("UTF-16", "UTF-8", "utf_16_32");
187
+ rb_declare_transcoder("UTF-32", "UTF-8", "utf_16_32");
188
+ rb_declare_transcoder("UTF-8", "UTF-16", "utf_16_32");
189
+ rb_declare_transcoder("UTF-8", "UTF-32", "utf_16_32");
@@ -0,0 +1,52 @@
1
+ #define RUBY_VERSION "1.9.3"
2
+ #define RUBY_PATCHLEVEL 194
3
+
4
+ #define RUBY_RELEASE_DATE "2012-04-20"
5
+ #define RUBY_RELEASE_YEAR 2012
6
+ #define RUBY_RELEASE_MONTH 4
7
+ #define RUBY_RELEASE_DAY 20
8
+
9
+ #include "ruby/version.h"
10
+
11
+ #if !defined RUBY_LIB_VERSION && defined RUBY_LIB_VERSION_STYLE
12
+ # if RUBY_LIB_VERSION_STYLE == 3
13
+ # define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR)"."STRINGIZE(RUBY_API_VERSION_TEENY)
14
+ # elif RUBY_LIB_VERSION_STYLE == 2
15
+ # define RUBY_LIB_VERSION STRINGIZE(RUBY_API_VERSION_MAJOR)"."STRINGIZE(RUBY_API_VERSION_MINOR)
16
+ # endif
17
+ #endif
18
+
19
+ #if RUBY_PATCHLEVEL == -1
20
+ #define RUBY_PATCHLEVEL_STR "dev"
21
+ #else
22
+ #define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL)
23
+ #endif
24
+
25
+ #ifndef RUBY_REVISION
26
+ # include "revision.h"
27
+ #endif
28
+ # ifndef RUBY_REVISION
29
+ # define RUBY_REVISION 0
30
+ #endif
31
+
32
+ #if RUBY_REVISION
33
+ # ifdef RUBY_BRANCH_NAME
34
+ # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION)
35
+ # else
36
+ # define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION)
37
+ # endif
38
+ #else
39
+ # define RUBY_REVISION_STR ""
40
+ #endif
41
+
42
+ # define RUBY_DESCRIPTION \
43
+ "ruby "RUBY_VERSION \
44
+ RUBY_PATCHLEVEL_STR \
45
+ " ("RUBY_RELEASE_DATE \
46
+ RUBY_REVISION_STR") " \
47
+ "["RUBY_PLATFORM"]"
48
+ # define RUBY_COPYRIGHT \
49
+ "ruby - Copyright (C) " \
50
+ STRINGIZE(RUBY_BIRTH_YEAR)"-" \
51
+ STRINGIZE(RUBY_RELEASE_YEAR)" " \
52
+ RUBY_AUTHOR
@@ -0,0 +1,756 @@
1
+ /**********************************************************************
2
+
3
+ vm_core.h -
4
+
5
+ $Author: marcandre $
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/st.h"
19
+
20
+ #include "node.h"
21
+ #include "debug.h"
22
+ #include "vm_opts.h"
23
+ #include "id.h"
24
+ #include "method.h"
25
+ #include "atomic.h"
26
+
27
+ #if defined(_WIN32)
28
+ #include "thread_win32.h"
29
+ #elif defined(HAVE_PTHREAD_H)
30
+ #include "thread_pthread.h"
31
+ #else
32
+ #error "unsupported thread type"
33
+ #endif
34
+
35
+ #ifndef ENABLE_VM_OBJSPACE
36
+ #ifdef _WIN32
37
+ /*
38
+ * TODO: object space independent st_table.
39
+ * socklist needs st_table in rb_w32_sysinit(), before object space
40
+ * initialization.
41
+ * It is too early now to change st_hash_type, since it breaks binary
42
+ * compatibility.
43
+ */
44
+ #define ENABLE_VM_OBJSPACE 0
45
+ #else
46
+ #define ENABLE_VM_OBJSPACE 1
47
+ #endif
48
+ #endif
49
+
50
+ #include <setjmp.h>
51
+ #include <signal.h>
52
+
53
+ #ifndef NSIG
54
+ # define NSIG (_SIGMAX + 1) /* For QNX */
55
+ #endif
56
+
57
+ #define RUBY_NSIG NSIG
58
+
59
+ #ifdef HAVE_STDARG_PROTOTYPES
60
+ #include <stdarg.h>
61
+ #define va_init_list(a,b) va_start((a),(b))
62
+ #else
63
+ #include <varargs.h>
64
+ #define va_init_list(a,b) va_start((a))
65
+ #endif
66
+
67
+ #if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
68
+ #define USE_SIGALTSTACK
69
+ #endif
70
+
71
+ /*****************/
72
+ /* configuration */
73
+ /*****************/
74
+
75
+ /* gcc ver. check */
76
+ #if defined(__GNUC__) && __GNUC__ >= 2
77
+
78
+ #if OPT_TOKEN_THREADED_CODE
79
+ #if OPT_DIRECT_THREADED_CODE
80
+ #undef OPT_DIRECT_THREADED_CODE
81
+ #endif
82
+ #endif
83
+
84
+ #else /* defined(__GNUC__) && __GNUC__ >= 2 */
85
+
86
+ /* disable threaded code options */
87
+ #if OPT_DIRECT_THREADED_CODE
88
+ #undef OPT_DIRECT_THREADED_CODE
89
+ #endif
90
+ #if OPT_TOKEN_THREADED_CODE
91
+ #undef OPT_TOKEN_THREADED_CODE
92
+ #endif
93
+ #endif
94
+
95
+ /* call threaded code */
96
+ #if OPT_CALL_THREADED_CODE
97
+ #if OPT_DIRECT_THREADED_CODE
98
+ #undef OPT_DIRECT_THREADED_CODE
99
+ #endif /* OPT_DIRECT_THREADED_CODE */
100
+ #if OPT_STACK_CACHING
101
+ #undef OPT_STACK_CACHING
102
+ #endif /* OPT_STACK_CACHING */
103
+ #endif /* OPT_CALL_THREADED_CODE */
104
+
105
+ /* likely */
106
+ #if __GNUC__ >= 3
107
+ #define LIKELY(x) (__builtin_expect((x), 1))
108
+ #define UNLIKELY(x) (__builtin_expect((x), 0))
109
+ #else /* __GNUC__ >= 3 */
110
+ #define LIKELY(x) (x)
111
+ #define UNLIKELY(x) (x)
112
+ #endif /* __GNUC__ >= 3 */
113
+
114
+ #if __GNUC__ >= 3
115
+ #define UNINITIALIZED_VAR(x) x = x
116
+ #else
117
+ #define UNINITIALIZED_VAR(x) x
118
+ #endif
119
+
120
+ typedef unsigned long rb_num_t;
121
+
122
+ /* iseq data type */
123
+
124
+ struct iseq_compile_data_ensure_node_stack;
125
+
126
+ typedef struct rb_compile_option_struct rb_compile_option_t;
127
+
128
+ struct iseq_inline_cache_entry {
129
+ VALUE ic_vmstat;
130
+ VALUE ic_class;
131
+ union {
132
+ VALUE value;
133
+ rb_method_entry_t *method;
134
+ long index;
135
+ } ic_value;
136
+ };
137
+
138
+ #if 1
139
+ #define GetCoreDataFromValue(obj, type, ptr) do { \
140
+ (ptr) = (type*)DATA_PTR(obj); \
141
+ } while (0)
142
+ #else
143
+ #define GetCoreDataFromValue(obj, type, ptr) Data_Get_Struct((obj), type, (ptr))
144
+ #endif
145
+
146
+ #define GetISeqPtr(obj, ptr) \
147
+ GetCoreDataFromValue((obj), rb_iseq_t, (ptr))
148
+
149
+ struct rb_iseq_struct;
150
+
151
+ struct rb_iseq_struct {
152
+ /***************/
153
+ /* static data */
154
+ /***************/
155
+
156
+ enum iseq_type {
157
+ ISEQ_TYPE_TOP,
158
+ ISEQ_TYPE_METHOD,
159
+ ISEQ_TYPE_BLOCK,
160
+ ISEQ_TYPE_CLASS,
161
+ ISEQ_TYPE_RESCUE,
162
+ ISEQ_TYPE_ENSURE,
163
+ ISEQ_TYPE_EVAL,
164
+ ISEQ_TYPE_MAIN,
165
+ ISEQ_TYPE_DEFINED_GUARD
166
+ } type; /* instruction sequence type */
167
+
168
+ VALUE name; /* String: iseq name */
169
+ VALUE filename; /* file information where this sequence from */
170
+ VALUE filepath; /* real file path or nil */
171
+ VALUE *iseq; /* iseq (insn number and operands) */
172
+ VALUE *iseq_encoded; /* encoded iseq */
173
+ unsigned long iseq_size;
174
+ VALUE mark_ary; /* Array: includes operands which should be GC marked */
175
+ VALUE coverage; /* coverage array */
176
+ unsigned short line_no;
177
+
178
+ /* insn info, must be freed */
179
+ struct iseq_insn_info_entry *insn_info_table;
180
+ size_t insn_info_size;
181
+
182
+ ID *local_table; /* must free */
183
+ int local_table_size;
184
+
185
+ /* method, class frame: sizeof(vars) + 1, block frame: sizeof(vars) */
186
+ int local_size;
187
+
188
+ struct iseq_inline_cache_entry *ic_entries;
189
+ int ic_size;
190
+
191
+ /**
192
+ * argument information
193
+ *
194
+ * def m(a1, a2, ..., aM, # mandatory
195
+ * b1=(...), b2=(...), ..., bN=(...), # optional
196
+ * *c, # rest
197
+ * d1, d2, ..., dO, # post
198
+ * &e) # block
199
+ * =>
200
+ *
201
+ * argc = M
202
+ * arg_rest = M+N+1 // or -1 if no rest arg
203
+ * arg_opts = N+1 // or 0 if no optional arg
204
+ * arg_opt_table = [ (arg_opts entries) ]
205
+ * arg_post_len = O // 0 if no post arguments
206
+ * arg_post_start = M+N+2
207
+ * arg_block = M+N + 1 + O + 1 // -1 if no block arg
208
+ * arg_simple = 0 if not simple arguments.
209
+ * = 1 if no opt, rest, post, block.
210
+ * = 2 if ambiguous block parameter ({|a|}).
211
+ * arg_size = argument size.
212
+ */
213
+
214
+ int argc;
215
+ int arg_simple;
216
+ int arg_rest;
217
+ int arg_block;
218
+ int arg_opts;
219
+ int arg_post_len;
220
+ int arg_post_start;
221
+ int arg_size;
222
+ VALUE *arg_opt_table;
223
+
224
+ size_t stack_max; /* for stack overflow check */
225
+
226
+ /* catch table */
227
+ struct iseq_catch_table_entry *catch_table;
228
+ int catch_table_size;
229
+
230
+ /* for child iseq */
231
+ struct rb_iseq_struct *parent_iseq;
232
+ struct rb_iseq_struct *local_iseq;
233
+
234
+ /****************/
235
+ /* dynamic data */
236
+ /****************/
237
+
238
+ VALUE self;
239
+ VALUE orig; /* non-NULL if its data have origin */
240
+
241
+ /* block inlining */
242
+ /*
243
+ * NODE *node;
244
+ * void *special_block_builder;
245
+ * void *cached_special_block_builder;
246
+ * VALUE cached_special_block;
247
+ */
248
+
249
+ /* klass/module nest information stack (cref) */
250
+ NODE *cref_stack;
251
+ VALUE klass;
252
+
253
+ /* misc */
254
+ ID defined_method_id; /* for define_method */
255
+
256
+ /* used at compile time */
257
+ struct iseq_compile_data *compile_data;
258
+ };
259
+
260
+ enum ruby_special_exceptions {
261
+ ruby_error_reenter,
262
+ ruby_error_nomemory,
263
+ ruby_error_sysstack,
264
+ ruby_error_closed_stream,
265
+ ruby_special_error_count
266
+ };
267
+
268
+ #define GetVMPtr(obj, ptr) \
269
+ GetCoreDataFromValue((obj), rb_vm_t, (ptr))
270
+
271
+ #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
272
+ struct rb_objspace;
273
+ void rb_objspace_free(struct rb_objspace *);
274
+ #endif
275
+
276
+ typedef struct rb_vm_struct {
277
+ VALUE self;
278
+
279
+ rb_global_vm_lock_t gvl;
280
+
281
+ struct rb_thread_struct *main_thread;
282
+ struct rb_thread_struct *running_thread;
283
+
284
+ st_table *living_threads;
285
+ VALUE thgroup_default;
286
+
287
+ int running;
288
+ int inhibit_thread_creation;
289
+ int thread_abort_on_exception;
290
+ unsigned long trace_flag;
291
+ volatile int sleeper;
292
+
293
+ /* object management */
294
+ VALUE mark_object_ary;
295
+
296
+ VALUE special_exceptions[ruby_special_error_count];
297
+
298
+ /* load */
299
+ VALUE top_self;
300
+ VALUE load_path;
301
+ VALUE loaded_features;
302
+ struct st_table *loading_table;
303
+
304
+ /* signal */
305
+ struct {
306
+ VALUE cmd;
307
+ int safe;
308
+ } trap_list[RUBY_NSIG];
309
+
310
+ /* hook */
311
+ rb_event_hook_t *event_hooks;
312
+
313
+ int src_encoding_index;
314
+
315
+ VALUE verbose, debug, progname;
316
+ VALUE coverages;
317
+
318
+ struct unlinked_method_entry_list_entry *unlinked_method_entry_list;
319
+
320
+ #if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
321
+ struct rb_objspace *objspace;
322
+ #endif
323
+
324
+ /*
325
+ * @shyouhei notes that this is not for storing normal Ruby
326
+ * objects so do *NOT* mark this when you GC.
327
+ */
328
+ struct RArray at_exit;
329
+ } rb_vm_t;
330
+
331
+ typedef struct {
332
+ VALUE *pc; /* cfp[0] */
333
+ VALUE *sp; /* cfp[1] */
334
+ VALUE *bp; /* cfp[2] */
335
+ rb_iseq_t *iseq; /* cfp[3] */
336
+ VALUE flag; /* cfp[4] */
337
+ VALUE self; /* cfp[5] / block[0] */
338
+ VALUE *lfp; /* cfp[6] / block[1] */
339
+ VALUE *dfp; /* cfp[7] / block[2] */
340
+ rb_iseq_t *block_iseq; /* cfp[8] / block[3] */
341
+ VALUE proc; /* cfp[9] / block[4] */
342
+ const rb_method_entry_t *me;/* cfp[10] */
343
+ } rb_control_frame_t;
344
+
345
+ typedef struct rb_block_struct {
346
+ VALUE self; /* share with method frame if it's only block */
347
+ VALUE *lfp; /* share with method frame if it's only block */
348
+ VALUE *dfp; /* share with method frame if it's only block */
349
+ rb_iseq_t *iseq;
350
+ VALUE proc;
351
+ } rb_block_t;
352
+
353
+ extern const rb_data_type_t ruby_threadptr_data_type;
354
+
355
+ #define GetThreadPtr(obj, ptr) \
356
+ TypedData_Get_Struct((obj), rb_thread_t, &ruby_threadptr_data_type, (ptr))
357
+
358
+ enum rb_thread_status {
359
+ THREAD_TO_KILL,
360
+ THREAD_RUNNABLE,
361
+ THREAD_STOPPED,
362
+ THREAD_STOPPED_FOREVER,
363
+ THREAD_KILLED
364
+ };
365
+
366
+ typedef RUBY_JMP_BUF rb_jmpbuf_t;
367
+
368
+ struct rb_vm_tag {
369
+ rb_jmpbuf_t buf;
370
+ VALUE tag;
371
+ VALUE retval;
372
+ struct rb_vm_tag *prev;
373
+ };
374
+
375
+ struct rb_vm_protect_tag {
376
+ struct rb_vm_protect_tag *prev;
377
+ };
378
+
379
+ struct rb_unblock_callback {
380
+ rb_unblock_function_t *func;
381
+ void *arg;
382
+ };
383
+
384
+ struct rb_mutex_struct;
385
+
386
+ #ifdef SIGSTKSZ
387
+ #define ALT_STACK_SIZE (SIGSTKSZ*2)
388
+ #else
389
+ #define ALT_STACK_SIZE (4*1024)
390
+ #endif
391
+
392
+ typedef struct rb_thread_struct {
393
+ VALUE self;
394
+ rb_vm_t *vm;
395
+
396
+ /* execution information */
397
+ VALUE *stack; /* must free, must mark */
398
+ unsigned long stack_size;
399
+ rb_control_frame_t *cfp;
400
+ int safe_level;
401
+ int raised_flag;
402
+ VALUE last_status; /* $? */
403
+
404
+ /* passing state */
405
+ int state;
406
+
407
+ int waiting_fd;
408
+
409
+ /* for rb_iterate */
410
+ const rb_block_t *passed_block;
411
+
412
+ /* for bmethod */
413
+ const rb_method_entry_t *passed_me;
414
+
415
+ /* for load(true) */
416
+ VALUE top_self;
417
+ VALUE top_wrapper;
418
+
419
+ /* eval env */
420
+ rb_block_t *base_block;
421
+
422
+ VALUE *local_lfp;
423
+ VALUE local_svar;
424
+
425
+ /* thread control */
426
+ rb_thread_id_t thread_id;
427
+ enum rb_thread_status status;
428
+ int priority;
429
+
430
+ native_thread_data_t native_thread_data;
431
+ void *blocking_region_buffer;
432
+
433
+ VALUE thgroup;
434
+ VALUE value;
435
+
436
+ VALUE errinfo;
437
+ VALUE thrown_errinfo;
438
+
439
+ rb_atomic_t interrupt_flag;
440
+ rb_thread_lock_t interrupt_lock;
441
+ struct rb_unblock_callback unblock;
442
+ VALUE locking_mutex;
443
+ struct rb_mutex_struct *keeping_mutexes;
444
+
445
+ struct rb_vm_tag *tag;
446
+ struct rb_vm_protect_tag *protect_tag;
447
+
448
+ int parse_in_eval;
449
+ int mild_compile_error;
450
+
451
+ /* storage */
452
+ st_table *local_storage;
453
+
454
+ struct rb_thread_struct *join_list_next;
455
+ struct rb_thread_struct *join_list_head;
456
+
457
+ VALUE first_proc;
458
+ VALUE first_args;
459
+ VALUE (*first_func)(ANYARGS);
460
+
461
+ /* for GC */
462
+ VALUE *machine_stack_start;
463
+ VALUE *machine_stack_end;
464
+ size_t machine_stack_maxsize;
465
+ #ifdef __ia64
466
+ VALUE *machine_register_stack_start;
467
+ VALUE *machine_register_stack_end;
468
+ size_t machine_register_stack_maxsize;
469
+ #endif
470
+ jmp_buf machine_regs;
471
+ int mark_stack_len;
472
+
473
+ /* statistics data for profiler */
474
+ VALUE stat_insn_usage;
475
+
476
+ /* tracer */
477
+ rb_event_hook_t *event_hooks;
478
+ rb_event_flag_t event_flags;
479
+ int tracing;
480
+
481
+ /* fiber */
482
+ VALUE fiber;
483
+ VALUE root_fiber;
484
+ rb_jmpbuf_t root_jmpbuf;
485
+
486
+ /* misc */
487
+ int method_missing_reason;
488
+ int abort_on_exception;
489
+ #ifdef USE_SIGALTSTACK
490
+ void *altstack;
491
+ #endif
492
+ unsigned long running_time_us;
493
+ } rb_thread_t;
494
+
495
+ /* iseq.c */
496
+ #if defined __GNUC__ && __GNUC__ >= 4
497
+ #pragma GCC visibility push(default)
498
+ #endif
499
+ VALUE rb_iseq_new(NODE*, VALUE, VALUE, VALUE, VALUE, enum iseq_type);
500
+ VALUE rb_iseq_new_top(NODE *node, VALUE name, VALUE filename, VALUE filepath, VALUE parent);
501
+ VALUE rb_iseq_new_main(NODE *node, VALUE filename, VALUE filepath);
502
+ VALUE rb_iseq_new_with_bopt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, VALUE);
503
+ VALUE rb_iseq_new_with_opt(NODE*, VALUE, VALUE, VALUE, VALUE, VALUE, enum iseq_type, const rb_compile_option_t*);
504
+ VALUE rb_iseq_compile(VALUE src, VALUE file, VALUE line);
505
+ VALUE rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE filepath, VALUE line, VALUE opt);
506
+ VALUE rb_iseq_disasm(VALUE self);
507
+ int rb_iseq_disasm_insn(VALUE str, VALUE *iseqval, size_t pos, rb_iseq_t *iseq, VALUE child);
508
+ const char *ruby_node_name(int node);
509
+ int rb_iseq_first_lineno(rb_iseq_t *iseq);
510
+
511
+ RUBY_EXTERN VALUE rb_cISeq;
512
+ RUBY_EXTERN VALUE rb_cRubyVM;
513
+ RUBY_EXTERN VALUE rb_cEnv;
514
+ RUBY_EXTERN VALUE rb_mRubyVMFrozenCore;
515
+ #if defined __GNUC__ && __GNUC__ >= 4
516
+ #pragma GCC visibility pop
517
+ #endif
518
+
519
+ /* each thread has this size stack : 128KB */
520
+ #define RUBY_VM_THREAD_STACK_SIZE (128 * 1024)
521
+
522
+ #define GetProcPtr(obj, ptr) \
523
+ GetCoreDataFromValue((obj), rb_proc_t, (ptr))
524
+
525
+ typedef struct {
526
+ rb_block_t block;
527
+
528
+ VALUE envval; /* for GC mark */
529
+ VALUE blockprocval;
530
+ int safe_level;
531
+ int is_from_method;
532
+ int is_lambda;
533
+ } rb_proc_t;
534
+
535
+ #define GetEnvPtr(obj, ptr) \
536
+ GetCoreDataFromValue((obj), rb_env_t, (ptr))
537
+
538
+ typedef struct {
539
+ VALUE *env;
540
+ int env_size;
541
+ int local_size;
542
+ VALUE prev_envval; /* for GC mark */
543
+ rb_block_t block;
544
+ } rb_env_t;
545
+
546
+ #define GetBindingPtr(obj, ptr) \
547
+ GetCoreDataFromValue((obj), rb_binding_t, (ptr))
548
+
549
+ typedef struct {
550
+ VALUE env;
551
+ VALUE filename;
552
+ unsigned short line_no;
553
+ } rb_binding_t;
554
+
555
+ /* used by compile time and send insn */
556
+ #define VM_CALL_ARGS_SPLAT_BIT (0x01 << 1)
557
+ #define VM_CALL_ARGS_BLOCKARG_BIT (0x01 << 2)
558
+ #define VM_CALL_FCALL_BIT (0x01 << 3)
559
+ #define VM_CALL_VCALL_BIT (0x01 << 4)
560
+ #define VM_CALL_TAILCALL_BIT (0x01 << 5)
561
+ #define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
562
+ #define VM_CALL_SUPER_BIT (0x01 << 7)
563
+ #define VM_CALL_OPT_SEND_BIT (0x01 << 8)
564
+
565
+ enum vm_special_object_type {
566
+ VM_SPECIAL_OBJECT_VMCORE = 1,
567
+ VM_SPECIAL_OBJECT_CBASE,
568
+ VM_SPECIAL_OBJECT_CONST_BASE
569
+ };
570
+
571
+ #define VM_FRAME_MAGIC_METHOD 0x11
572
+ #define VM_FRAME_MAGIC_BLOCK 0x21
573
+ #define VM_FRAME_MAGIC_CLASS 0x31
574
+ #define VM_FRAME_MAGIC_TOP 0x41
575
+ #define VM_FRAME_MAGIC_FINISH 0x51
576
+ #define VM_FRAME_MAGIC_CFUNC 0x61
577
+ #define VM_FRAME_MAGIC_PROC 0x71
578
+ #define VM_FRAME_MAGIC_IFUNC 0x81
579
+ #define VM_FRAME_MAGIC_EVAL 0x91
580
+ #define VM_FRAME_MAGIC_LAMBDA 0xa1
581
+ #define VM_FRAME_MAGIC_MASK_BITS 8
582
+ #define VM_FRAME_MAGIC_MASK (~(~0<<VM_FRAME_MAGIC_MASK_BITS))
583
+
584
+ #define VM_FRAME_TYPE(cfp) ((cfp)->flag & VM_FRAME_MAGIC_MASK)
585
+
586
+ /* other frame flag */
587
+ #define VM_FRAME_FLAG_PASSED 0x0100
588
+
589
+ #define RUBYVM_CFUNC_FRAME_P(cfp) \
590
+ (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)
591
+
592
+ /* inline cache */
593
+ typedef struct iseq_inline_cache_entry *IC;
594
+
595
+ void rb_vm_change_state(void);
596
+
597
+ typedef VALUE CDHASH;
598
+
599
+ #ifndef FUNC_FASTCALL
600
+ #define FUNC_FASTCALL(x) x
601
+ #endif
602
+
603
+ typedef rb_control_frame_t *
604
+ (FUNC_FASTCALL(*rb_insn_func_t))(rb_thread_t *, rb_control_frame_t *);
605
+
606
+ #define GC_GUARDED_PTR(p) ((VALUE)((VALUE)(p) | 0x01))
607
+ #define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)(p)) & ~0x03))
608
+ #define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)
609
+
610
+ #define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
611
+ #define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
612
+ #define RUBY_VM_END_CONTROL_FRAME(th) \
613
+ ((rb_control_frame_t *)((th)->stack + (th)->stack_size))
614
+ #define RUBY_VM_VALID_CONTROL_FRAME_P(cfp, ecfp) \
615
+ ((void *)(ecfp) > (void *)(cfp))
616
+ #define RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp) \
617
+ (!RUBY_VM_VALID_CONTROL_FRAME_P((cfp), RUBY_VM_END_CONTROL_FRAME(th)))
618
+
619
+ #define RUBY_VM_IFUNC_P(ptr) (BUILTIN_TYPE(ptr) == T_NODE)
620
+ #define RUBY_VM_NORMAL_ISEQ_P(ptr) \
621
+ ((ptr) && !RUBY_VM_IFUNC_P(ptr))
622
+
623
+ #define RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp) ((rb_block_t *)(&(cfp)->self))
624
+ #define RUBY_VM_GET_CFP_FROM_BLOCK_PTR(b) \
625
+ ((rb_control_frame_t *)((VALUE *)(b) - 5))
626
+
627
+ /* VM related object allocate functions */
628
+ VALUE rb_thread_alloc(VALUE klass);
629
+ VALUE rb_proc_alloc(VALUE klass);
630
+
631
+ /* for debug */
632
+ extern void rb_vmdebug_stack_dump_raw(rb_thread_t *, rb_control_frame_t *);
633
+ #define SDR() rb_vmdebug_stack_dump_raw(GET_THREAD(), GET_THREAD()->cfp)
634
+ #define SDR2(cfp) rb_vmdebug_stack_dump_raw(GET_THREAD(), (cfp))
635
+ void rb_vm_bugreport(void);
636
+
637
+ /* functions about thread/vm execution */
638
+ #if defined __GNUC__ && __GNUC__ >= 4
639
+ #pragma GCC visibility push(default)
640
+ #endif
641
+ VALUE rb_iseq_eval(VALUE iseqval);
642
+ VALUE rb_iseq_eval_main(VALUE iseqval);
643
+ void rb_enable_interrupt(void);
644
+ void rb_disable_interrupt(void);
645
+ #if defined __GNUC__ && __GNUC__ >= 4
646
+ #pragma GCC visibility pop
647
+ #endif
648
+ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
649
+
650
+ VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
651
+ int argc, const VALUE *argv, const rb_block_t *blockptr);
652
+ VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass);
653
+ VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
654
+ void rb_vm_rewrite_dfp_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp);
655
+ void rb_vm_inc_const_missing_count(void);
656
+ void rb_vm_gvl_destroy(rb_vm_t *vm);
657
+ VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc,
658
+ const VALUE *argv, const rb_method_entry_t *me);
659
+ void rb_unlink_method_entry(rb_method_entry_t *me);
660
+ void rb_gc_mark_unlinked_live_method_entries(void *pvm);
661
+
662
+ void rb_thread_start_timer_thread(void);
663
+ void rb_thread_stop_timer_thread(int);
664
+ void rb_thread_reset_timer_thread(void);
665
+ void rb_thread_wakeup_timer_thread(void);
666
+
667
+ int ruby_thread_has_gvl_p(void);
668
+ VALUE rb_make_backtrace(void);
669
+ typedef int rb_backtrace_iter_func(void *, VALUE, int, VALUE);
670
+ int rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg);
671
+ rb_control_frame_t *rb_vm_get_ruby_level_next_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
672
+ int rb_vm_get_sourceline(const rb_control_frame_t *);
673
+ VALUE rb_name_err_mesg_new(VALUE obj, VALUE mesg, VALUE recv, VALUE method);
674
+ void rb_vm_stack_to_heap(rb_thread_t *th);
675
+ void ruby_thread_init_stack(rb_thread_t *th);
676
+
677
+ NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
678
+ void rb_gc_mark_machine_stack(rb_thread_t *th);
679
+
680
+ #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
681
+
682
+ /* for thread */
683
+
684
+ #if RUBY_VM_THREAD_MODEL == 2
685
+ RUBY_EXTERN rb_thread_t *ruby_current_thread;
686
+ extern rb_vm_t *ruby_current_vm;
687
+
688
+ #define GET_VM() ruby_current_vm
689
+ #define GET_THREAD() ruby_current_thread
690
+ #define rb_thread_set_current_raw(th) (void)(ruby_current_thread = (th))
691
+ #define rb_thread_set_current(th) do { \
692
+ if ((th)->vm->running_thread != (th)) { \
693
+ (th)->vm->running_thread->running_time_us = 0; \
694
+ } \
695
+ rb_thread_set_current_raw(th); \
696
+ (th)->vm->running_thread = (th); \
697
+ } while (0)
698
+
699
+ #else
700
+ #error "unsupported thread model"
701
+ #endif
702
+
703
+ #define RUBY_VM_SET_TIMER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x01)
704
+ #define RUBY_VM_SET_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x02)
705
+ #define RUBY_VM_SET_FINALIZER_INTERRUPT(th) ATOMIC_OR((th)->interrupt_flag, 0x04)
706
+ #define RUBY_VM_INTERRUPTED(th) ((th)->interrupt_flag & 0x02)
707
+
708
+ int rb_signal_buff_size(void);
709
+ void rb_signal_exec(rb_thread_t *th, int sig);
710
+ void rb_threadptr_check_signal(rb_thread_t *mth);
711
+ void rb_threadptr_signal_raise(rb_thread_t *th, int sig);
712
+ void rb_threadptr_signal_exit(rb_thread_t *th);
713
+ void rb_threadptr_execute_interrupts(rb_thread_t *);
714
+ void rb_threadptr_interrupt(rb_thread_t *th);
715
+ void rb_threadptr_unlock_all_locking_mutexes(rb_thread_t *th);
716
+
717
+ void rb_thread_lock_unlock(rb_thread_lock_t *);
718
+ void rb_thread_lock_destroy(rb_thread_lock_t *);
719
+
720
+ #define RUBY_VM_CHECK_INTS_TH(th) do { \
721
+ if (UNLIKELY((th)->interrupt_flag)) { \
722
+ rb_threadptr_execute_interrupts(th); \
723
+ } \
724
+ } while (0)
725
+
726
+ #define RUBY_VM_CHECK_INTS() \
727
+ RUBY_VM_CHECK_INTS_TH(GET_THREAD())
728
+
729
+ /* tracer */
730
+ void
731
+ rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass);
732
+
733
+ #define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \
734
+ rb_event_flag_t wait_event__ = (th)->event_flags; \
735
+ if (UNLIKELY(wait_event__)) { \
736
+ if (wait_event__ & ((flag) | RUBY_EVENT_VM)) { \
737
+ rb_threadptr_exec_event_hooks((th), (flag), (self), (id), (klass)); \
738
+ } \
739
+ } \
740
+ } while (0)
741
+
742
+ #if defined __GNUC__ && __GNUC__ >= 4
743
+ #pragma GCC visibility push(default)
744
+ #endif
745
+
746
+ int rb_thread_check_trap_pending(void);
747
+
748
+ extern VALUE rb_get_coverages(void);
749
+ extern void rb_set_coverages(VALUE);
750
+ extern void rb_reset_coverages(void);
751
+
752
+ #if defined __GNUC__ && __GNUC__ >= 4
753
+ #pragma GCC visibility pop
754
+ #endif
755
+
756
+ #endif /* RUBY_VM_CORE_H */