johnson 2.0.0.pre1 → 2.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. data/CHANGELOG.rdoc +12 -0
  2. data/Manifest.txt +4 -285
  3. data/Rakefile +13 -20
  4. data/ext/tracemonkey/global.cc +4 -1
  5. data/ext/tracemonkey/js.cc +30 -33
  6. data/ext/tracemonkey/runtime.cc +96 -6
  7. data/ext/tracemonkey/split_global.cc +0 -5
  8. data/ext/tracemonkey/tracemonkey.h +2 -2
  9. data/lib/johnson.rb +2 -2
  10. data/lib/johnson/runtime.rb +25 -15
  11. data/lib/johnson/tracemonkey/runtime.rb +6 -3
  12. data/vendor/tracemonkey/config/system-headers +1 -3
  13. data/vendor/tracemonkey/jscntxt.h +5 -2
  14. data/vendor/tracemonkey/jsdbgapi.cpp +9 -1
  15. data/vendor/tracemonkey/jsdbgapi.h +4 -0
  16. data/vendor/tracemonkey/tests/ecma/NativeObjects/browser.js +0 -0
  17. data/vendor/tracemonkey/tests/ecma/NativeObjects/jstests.list +0 -0
  18. data/vendor/tracemonkey/tests/ecma_3_1/Object/jstests.list +1 -1
  19. data/vendor/tracemonkey/tests/js1_3/misc/browser.js +0 -0
  20. data/vendor/tracemonkey/tests/js1_3/misc/jstests.list +0 -0
  21. data/vendor/tracemonkey/tests/js1_5/Regress/jstests.list +4 -4
  22. data/vendor/tracemonkey/tests/js1_5/Scope/jstests.list +1 -1
  23. data/vendor/tracemonkey/tests/js1_5/decompilation/jstests.list +2 -2
  24. data/vendor/tracemonkey/tests/js1_7/decompilation/jstests.list +1 -1
  25. data/vendor/tracemonkey/tests/shell.js +2 -1
  26. metadata +51 -309
  27. data/ext/spidermonkey/context.c +0 -116
  28. data/ext/spidermonkey/context.h +0 -19
  29. data/ext/spidermonkey/conversions.c +0 -361
  30. data/ext/spidermonkey/conversions.h +0 -31
  31. data/ext/spidermonkey/debugger.c +0 -234
  32. data/ext/spidermonkey/debugger.h +0 -10
  33. data/ext/spidermonkey/extconf.rb +0 -32
  34. data/ext/spidermonkey/extensions.c +0 -37
  35. data/ext/spidermonkey/extensions.h +0 -12
  36. data/ext/spidermonkey/global.c +0 -40
  37. data/ext/spidermonkey/global.h +0 -11
  38. data/ext/spidermonkey/idhash.c +0 -16
  39. data/ext/spidermonkey/idhash.h +0 -8
  40. data/ext/spidermonkey/immutable_node.c +0 -1153
  41. data/ext/spidermonkey/immutable_node.c.erb +0 -523
  42. data/ext/spidermonkey/immutable_node.h +0 -22
  43. data/ext/spidermonkey/jroot.h +0 -197
  44. data/ext/spidermonkey/js_land_proxy.c +0 -620
  45. data/ext/spidermonkey/js_land_proxy.h +0 -20
  46. data/ext/spidermonkey/ruby_land_proxy.c +0 -618
  47. data/ext/spidermonkey/ruby_land_proxy.h +0 -38
  48. data/ext/spidermonkey/runtime.c +0 -396
  49. data/ext/spidermonkey/runtime.h +0 -27
  50. data/ext/spidermonkey/spidermonkey.c +0 -22
  51. data/ext/spidermonkey/spidermonkey.h +0 -29
  52. data/lib/johnson/spidermonkey.rb +0 -12
  53. data/lib/johnson/spidermonkey/context.rb +0 -10
  54. data/lib/johnson/spidermonkey/debugger.rb +0 -67
  55. data/lib/johnson/spidermonkey/immutable_node.rb +0 -282
  56. data/lib/johnson/spidermonkey/js_land_proxy.rb +0 -64
  57. data/lib/johnson/spidermonkey/mutable_tree_visitor.rb +0 -242
  58. data/lib/johnson/spidermonkey/ruby_land_proxy.rb +0 -17
  59. data/lib/johnson/spidermonkey/runtime.rb +0 -74
  60. data/test/johnson/spidermonkey/context_test.rb +0 -21
  61. data/test/johnson/spidermonkey/immutable_node_test.rb +0 -34
  62. data/test/johnson/spidermonkey/js_land_proxy_test.rb +0 -273
  63. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +0 -274
  64. data/test/johnson/spidermonkey/runtime_test.rb +0 -41
  65. data/vendor/spidermonkey/.cvsignore +0 -9
  66. data/vendor/spidermonkey/Makefile.in +0 -449
  67. data/vendor/spidermonkey/Makefile.ref +0 -365
  68. data/vendor/spidermonkey/README.html +0 -820
  69. data/vendor/spidermonkey/SpiderMonkey.rsp +0 -12
  70. data/vendor/spidermonkey/Y.js +0 -19
  71. data/vendor/spidermonkey/build.mk +0 -43
  72. data/vendor/spidermonkey/config.mk +0 -192
  73. data/vendor/spidermonkey/config/AIX4.1.mk +0 -65
  74. data/vendor/spidermonkey/config/AIX4.2.mk +0 -64
  75. data/vendor/spidermonkey/config/AIX4.3.mk +0 -65
  76. data/vendor/spidermonkey/config/Darwin.mk +0 -83
  77. data/vendor/spidermonkey/config/Darwin1.3.mk +0 -81
  78. data/vendor/spidermonkey/config/Darwin1.4.mk +0 -41
  79. data/vendor/spidermonkey/config/Darwin5.2.mk +0 -81
  80. data/vendor/spidermonkey/config/Darwin5.3.mk +0 -81
  81. data/vendor/spidermonkey/config/HP-UXB.10.10.mk +0 -77
  82. data/vendor/spidermonkey/config/HP-UXB.10.20.mk +0 -77
  83. data/vendor/spidermonkey/config/HP-UXB.11.00.mk +0 -80
  84. data/vendor/spidermonkey/config/IRIX.mk +0 -87
  85. data/vendor/spidermonkey/config/IRIX5.3.mk +0 -44
  86. data/vendor/spidermonkey/config/IRIX6.1.mk +0 -44
  87. data/vendor/spidermonkey/config/IRIX6.2.mk +0 -44
  88. data/vendor/spidermonkey/config/IRIX6.3.mk +0 -44
  89. data/vendor/spidermonkey/config/IRIX6.5.mk +0 -44
  90. data/vendor/spidermonkey/config/Linux_All.mk +0 -103
  91. data/vendor/spidermonkey/config/Mac_OS10.0.mk +0 -82
  92. data/vendor/spidermonkey/config/OSF1V4.0.mk +0 -72
  93. data/vendor/spidermonkey/config/OSF1V5.0.mk +0 -69
  94. data/vendor/spidermonkey/config/SunOS4.1.4.mk +0 -101
  95. data/vendor/spidermonkey/config/SunOS5.10.mk +0 -50
  96. data/vendor/spidermonkey/config/SunOS5.3.mk +0 -91
  97. data/vendor/spidermonkey/config/SunOS5.4.mk +0 -92
  98. data/vendor/spidermonkey/config/SunOS5.5.1.mk +0 -44
  99. data/vendor/spidermonkey/config/SunOS5.5.mk +0 -87
  100. data/vendor/spidermonkey/config/SunOS5.6.mk +0 -89
  101. data/vendor/spidermonkey/config/SunOS5.7.mk +0 -44
  102. data/vendor/spidermonkey/config/SunOS5.8.mk +0 -44
  103. data/vendor/spidermonkey/config/SunOS5.9.mk +0 -44
  104. data/vendor/spidermonkey/config/WINNT4.0.mk +0 -117
  105. data/vendor/spidermonkey/config/WINNT5.0.mk +0 -117
  106. data/vendor/spidermonkey/config/WINNT5.1.mk +0 -117
  107. data/vendor/spidermonkey/config/WINNT5.2.mk +0 -117
  108. data/vendor/spidermonkey/config/WINNT6.0.mk +0 -117
  109. data/vendor/spidermonkey/config/dgux.mk +0 -64
  110. data/vendor/spidermonkey/editline/Makefile.ref +0 -144
  111. data/vendor/spidermonkey/editline/README +0 -83
  112. data/vendor/spidermonkey/editline/editline.3 +0 -175
  113. data/vendor/spidermonkey/editline/editline.c +0 -1369
  114. data/vendor/spidermonkey/editline/editline.h +0 -135
  115. data/vendor/spidermonkey/editline/sysunix.c +0 -182
  116. data/vendor/spidermonkey/editline/unix.h +0 -82
  117. data/vendor/spidermonkey/fdlibm/.cvsignore +0 -7
  118. data/vendor/spidermonkey/fdlibm/Makefile.in +0 -127
  119. data/vendor/spidermonkey/fdlibm/Makefile.ref +0 -192
  120. data/vendor/spidermonkey/fdlibm/e_acos.c +0 -147
  121. data/vendor/spidermonkey/fdlibm/e_acosh.c +0 -105
  122. data/vendor/spidermonkey/fdlibm/e_asin.c +0 -156
  123. data/vendor/spidermonkey/fdlibm/e_atan2.c +0 -165
  124. data/vendor/spidermonkey/fdlibm/e_atanh.c +0 -110
  125. data/vendor/spidermonkey/fdlibm/e_cosh.c +0 -133
  126. data/vendor/spidermonkey/fdlibm/e_exp.c +0 -202
  127. data/vendor/spidermonkey/fdlibm/e_fmod.c +0 -184
  128. data/vendor/spidermonkey/fdlibm/e_gamma.c +0 -71
  129. data/vendor/spidermonkey/fdlibm/e_gamma_r.c +0 -70
  130. data/vendor/spidermonkey/fdlibm/e_hypot.c +0 -173
  131. data/vendor/spidermonkey/fdlibm/e_j0.c +0 -524
  132. data/vendor/spidermonkey/fdlibm/e_j1.c +0 -523
  133. data/vendor/spidermonkey/fdlibm/e_jn.c +0 -315
  134. data/vendor/spidermonkey/fdlibm/e_lgamma.c +0 -71
  135. data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +0 -347
  136. data/vendor/spidermonkey/fdlibm/e_log.c +0 -184
  137. data/vendor/spidermonkey/fdlibm/e_log10.c +0 -134
  138. data/vendor/spidermonkey/fdlibm/e_pow.c +0 -386
  139. data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +0 -222
  140. data/vendor/spidermonkey/fdlibm/e_remainder.c +0 -120
  141. data/vendor/spidermonkey/fdlibm/e_scalb.c +0 -89
  142. data/vendor/spidermonkey/fdlibm/e_sinh.c +0 -122
  143. data/vendor/spidermonkey/fdlibm/e_sqrt.c +0 -497
  144. data/vendor/spidermonkey/fdlibm/fdlibm.h +0 -273
  145. data/vendor/spidermonkey/fdlibm/fdlibm.mak +0 -1453
  146. data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
  147. data/vendor/spidermonkey/fdlibm/k_cos.c +0 -135
  148. data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +0 -354
  149. data/vendor/spidermonkey/fdlibm/k_sin.c +0 -114
  150. data/vendor/spidermonkey/fdlibm/k_standard.c +0 -785
  151. data/vendor/spidermonkey/fdlibm/k_tan.c +0 -170
  152. data/vendor/spidermonkey/fdlibm/s_asinh.c +0 -101
  153. data/vendor/spidermonkey/fdlibm/s_atan.c +0 -175
  154. data/vendor/spidermonkey/fdlibm/s_cbrt.c +0 -133
  155. data/vendor/spidermonkey/fdlibm/s_ceil.c +0 -120
  156. data/vendor/spidermonkey/fdlibm/s_copysign.c +0 -72
  157. data/vendor/spidermonkey/fdlibm/s_cos.c +0 -118
  158. data/vendor/spidermonkey/fdlibm/s_erf.c +0 -356
  159. data/vendor/spidermonkey/fdlibm/s_expm1.c +0 -267
  160. data/vendor/spidermonkey/fdlibm/s_fabs.c +0 -70
  161. data/vendor/spidermonkey/fdlibm/s_finite.c +0 -71
  162. data/vendor/spidermonkey/fdlibm/s_floor.c +0 -121
  163. data/vendor/spidermonkey/fdlibm/s_frexp.c +0 -99
  164. data/vendor/spidermonkey/fdlibm/s_ilogb.c +0 -85
  165. data/vendor/spidermonkey/fdlibm/s_isnan.c +0 -74
  166. data/vendor/spidermonkey/fdlibm/s_ldexp.c +0 -66
  167. data/vendor/spidermonkey/fdlibm/s_lib_version.c +0 -73
  168. data/vendor/spidermonkey/fdlibm/s_log1p.c +0 -211
  169. data/vendor/spidermonkey/fdlibm/s_logb.c +0 -79
  170. data/vendor/spidermonkey/fdlibm/s_matherr.c +0 -64
  171. data/vendor/spidermonkey/fdlibm/s_modf.c +0 -132
  172. data/vendor/spidermonkey/fdlibm/s_nextafter.c +0 -124
  173. data/vendor/spidermonkey/fdlibm/s_rint.c +0 -131
  174. data/vendor/spidermonkey/fdlibm/s_scalbn.c +0 -107
  175. data/vendor/spidermonkey/fdlibm/s_signgam.c +0 -40
  176. data/vendor/spidermonkey/fdlibm/s_significand.c +0 -68
  177. data/vendor/spidermonkey/fdlibm/s_sin.c +0 -118
  178. data/vendor/spidermonkey/fdlibm/s_tan.c +0 -112
  179. data/vendor/spidermonkey/fdlibm/s_tanh.c +0 -122
  180. data/vendor/spidermonkey/fdlibm/w_acos.c +0 -78
  181. data/vendor/spidermonkey/fdlibm/w_acosh.c +0 -78
  182. data/vendor/spidermonkey/fdlibm/w_asin.c +0 -80
  183. data/vendor/spidermonkey/fdlibm/w_atan2.c +0 -79
  184. data/vendor/spidermonkey/fdlibm/w_atanh.c +0 -81
  185. data/vendor/spidermonkey/fdlibm/w_cosh.c +0 -77
  186. data/vendor/spidermonkey/fdlibm/w_exp.c +0 -88
  187. data/vendor/spidermonkey/fdlibm/w_fmod.c +0 -78
  188. data/vendor/spidermonkey/fdlibm/w_gamma.c +0 -85
  189. data/vendor/spidermonkey/fdlibm/w_gamma_r.c +0 -81
  190. data/vendor/spidermonkey/fdlibm/w_hypot.c +0 -78
  191. data/vendor/spidermonkey/fdlibm/w_j0.c +0 -105
  192. data/vendor/spidermonkey/fdlibm/w_j1.c +0 -106
  193. data/vendor/spidermonkey/fdlibm/w_jn.c +0 -128
  194. data/vendor/spidermonkey/fdlibm/w_lgamma.c +0 -85
  195. data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +0 -81
  196. data/vendor/spidermonkey/fdlibm/w_log.c +0 -78
  197. data/vendor/spidermonkey/fdlibm/w_log10.c +0 -81
  198. data/vendor/spidermonkey/fdlibm/w_pow.c +0 -99
  199. data/vendor/spidermonkey/fdlibm/w_remainder.c +0 -77
  200. data/vendor/spidermonkey/fdlibm/w_scalb.c +0 -95
  201. data/vendor/spidermonkey/fdlibm/w_sinh.c +0 -77
  202. data/vendor/spidermonkey/fdlibm/w_sqrt.c +0 -77
  203. data/vendor/spidermonkey/javascript-trace.d +0 -73
  204. data/vendor/spidermonkey/js.c +0 -3951
  205. data/vendor/spidermonkey/js.mdp +0 -0
  206. data/vendor/spidermonkey/js.msg +0 -308
  207. data/vendor/spidermonkey/js.pkg +0 -2
  208. data/vendor/spidermonkey/js3240.rc +0 -79
  209. data/vendor/spidermonkey/jsOS240.def +0 -654
  210. data/vendor/spidermonkey/jsapi.c +0 -5836
  211. data/vendor/spidermonkey/jsapi.h +0 -2624
  212. data/vendor/spidermonkey/jsarena.c +0 -450
  213. data/vendor/spidermonkey/jsarena.h +0 -318
  214. data/vendor/spidermonkey/jsarray.c +0 -2996
  215. data/vendor/spidermonkey/jsarray.h +0 -127
  216. data/vendor/spidermonkey/jsatom.c +0 -1045
  217. data/vendor/spidermonkey/jsatom.h +0 -442
  218. data/vendor/spidermonkey/jsbit.h +0 -253
  219. data/vendor/spidermonkey/jsbool.c +0 -176
  220. data/vendor/spidermonkey/jsbool.h +0 -73
  221. data/vendor/spidermonkey/jsclist.h +0 -139
  222. data/vendor/spidermonkey/jscntxt.c +0 -1348
  223. data/vendor/spidermonkey/jscntxt.h +0 -1120
  224. data/vendor/spidermonkey/jscompat.h +0 -57
  225. data/vendor/spidermonkey/jsconfig.h +0 -248
  226. data/vendor/spidermonkey/jsconfig.mk +0 -181
  227. data/vendor/spidermonkey/jscpucfg.c +0 -396
  228. data/vendor/spidermonkey/jscpucfg.h +0 -212
  229. data/vendor/spidermonkey/jsdate.c +0 -2390
  230. data/vendor/spidermonkey/jsdate.h +0 -124
  231. data/vendor/spidermonkey/jsdbgapi.c +0 -1802
  232. data/vendor/spidermonkey/jsdbgapi.h +0 -464
  233. data/vendor/spidermonkey/jsdhash.c +0 -868
  234. data/vendor/spidermonkey/jsdhash.h +0 -592
  235. data/vendor/spidermonkey/jsdtoa.c +0 -3167
  236. data/vendor/spidermonkey/jsdtoa.h +0 -130
  237. data/vendor/spidermonkey/jsdtracef.c +0 -317
  238. data/vendor/spidermonkey/jsdtracef.h +0 -77
  239. data/vendor/spidermonkey/jsemit.c +0 -6909
  240. data/vendor/spidermonkey/jsemit.h +0 -741
  241. data/vendor/spidermonkey/jsexn.c +0 -1371
  242. data/vendor/spidermonkey/jsexn.h +0 -96
  243. data/vendor/spidermonkey/jsfile.c +0 -2736
  244. data/vendor/spidermonkey/jsfile.h +0 -56
  245. data/vendor/spidermonkey/jsfile.msg +0 -90
  246. data/vendor/spidermonkey/jsfun.c +0 -2634
  247. data/vendor/spidermonkey/jsfun.h +0 -254
  248. data/vendor/spidermonkey/jsgc.c +0 -3562
  249. data/vendor/spidermonkey/jsgc.h +0 -403
  250. data/vendor/spidermonkey/jshash.c +0 -476
  251. data/vendor/spidermonkey/jshash.h +0 -151
  252. data/vendor/spidermonkey/jsify.pl +0 -485
  253. data/vendor/spidermonkey/jsinterp.c +0 -7007
  254. data/vendor/spidermonkey/jsinterp.h +0 -525
  255. data/vendor/spidermonkey/jsinvoke.c +0 -43
  256. data/vendor/spidermonkey/jsiter.c +0 -1067
  257. data/vendor/spidermonkey/jsiter.h +0 -122
  258. data/vendor/spidermonkey/jskeyword.tbl +0 -124
  259. data/vendor/spidermonkey/jskwgen.c +0 -460
  260. data/vendor/spidermonkey/jslibmath.h +0 -266
  261. data/vendor/spidermonkey/jslock.c +0 -1309
  262. data/vendor/spidermonkey/jslock.h +0 -313
  263. data/vendor/spidermonkey/jslocko.asm +0 -60
  264. data/vendor/spidermonkey/jslog2.c +0 -94
  265. data/vendor/spidermonkey/jslong.c +0 -264
  266. data/vendor/spidermonkey/jslong.h +0 -412
  267. data/vendor/spidermonkey/jsmath.c +0 -567
  268. data/vendor/spidermonkey/jsmath.h +0 -57
  269. data/vendor/spidermonkey/jsnum.c +0 -1239
  270. data/vendor/spidermonkey/jsnum.h +0 -283
  271. data/vendor/spidermonkey/jsobj.c +0 -5282
  272. data/vendor/spidermonkey/jsobj.h +0 -709
  273. data/vendor/spidermonkey/jsopcode.c +0 -5245
  274. data/vendor/spidermonkey/jsopcode.h +0 -394
  275. data/vendor/spidermonkey/jsopcode.tbl +0 -523
  276. data/vendor/spidermonkey/jsotypes.h +0 -202
  277. data/vendor/spidermonkey/jsparse.c +0 -6704
  278. data/vendor/spidermonkey/jsparse.h +0 -511
  279. data/vendor/spidermonkey/jsprf.c +0 -1264
  280. data/vendor/spidermonkey/jsprf.h +0 -150
  281. data/vendor/spidermonkey/jsproto.tbl +0 -128
  282. data/vendor/spidermonkey/jsprvtd.h +0 -267
  283. data/vendor/spidermonkey/jspubtd.h +0 -744
  284. data/vendor/spidermonkey/jsregexp.c +0 -4364
  285. data/vendor/spidermonkey/jsregexp.h +0 -183
  286. data/vendor/spidermonkey/jsreops.tbl +0 -145
  287. data/vendor/spidermonkey/jsscan.c +0 -2012
  288. data/vendor/spidermonkey/jsscan.h +0 -387
  289. data/vendor/spidermonkey/jsscope.c +0 -1957
  290. data/vendor/spidermonkey/jsscope.h +0 -418
  291. data/vendor/spidermonkey/jsscript.c +0 -1832
  292. data/vendor/spidermonkey/jsscript.h +0 -287
  293. data/vendor/spidermonkey/jsshell.msg +0 -50
  294. data/vendor/spidermonkey/jsstddef.h +0 -83
  295. data/vendor/spidermonkey/jsstr.c +0 -5005
  296. data/vendor/spidermonkey/jsstr.h +0 -641
  297. data/vendor/spidermonkey/jstypes.h +0 -475
  298. data/vendor/spidermonkey/jsutil.c +0 -345
  299. data/vendor/spidermonkey/jsutil.h +0 -157
  300. data/vendor/spidermonkey/jsxdrapi.c +0 -800
  301. data/vendor/spidermonkey/jsxdrapi.h +0 -218
  302. data/vendor/spidermonkey/jsxml.c +0 -8476
  303. data/vendor/spidermonkey/jsxml.h +0 -349
  304. data/vendor/spidermonkey/lock_SunOS.s +0 -119
  305. data/vendor/spidermonkey/perfect.js +0 -39
  306. data/vendor/spidermonkey/plify_jsdhash.sed +0 -36
  307. data/vendor/spidermonkey/prmjtime.c +0 -846
  308. data/vendor/spidermonkey/prmjtime.h +0 -103
  309. data/vendor/spidermonkey/resource.h +0 -15
  310. data/vendor/spidermonkey/rules.mk +0 -197
  311. data/vendor/spidermonkey/win32.order +0 -384
@@ -1,31 +0,0 @@
1
- #ifndef JOHNSON_SPIDERMONKEY_CONVERSIONS_H
2
- #define JOHNSON_SPIDERMONKEY_CONVERSIONS_H
3
-
4
- #include "spidermonkey.h"
5
- #include "context.h"
6
- #include "runtime.h"
7
-
8
- DECLARE_RUBY_WRAPPER(convert_to_ruby, JohnsonRuntime* runtime; jsval js_value)
9
- #define CONVERT_TO_RUBY(runtime, js) CALL_RUBY_WRAPPER(convert_to_ruby, runtime, js)
10
-
11
- DECLARE_RUBY_WRAPPER(convert_js_string_to_ruby, JohnsonRuntime* runtime; JSString* str)
12
- #define CONVERT_JS_STRING_TO_RUBY(runtime, js) CALL_RUBY_WRAPPER(convert_js_string_to_ruby, runtime, js)
13
-
14
- DECLARE_RUBY_WRAPPER(rb_funcall_0, VALUE obj; ID sym; int argc)
15
- #define RB_FUNCALL_0(obj, sym) CALL_RUBY_WRAPPER(rb_funcall_0, obj, sym, 0)
16
- DECLARE_RUBY_WRAPPER(rb_funcall_1, VALUE obj; ID sym; int argc; VALUE a)
17
- #define RB_FUNCALL_1(obj, sym, a) CALL_RUBY_WRAPPER(rb_funcall_1, obj, sym, 1, a)
18
- DECLARE_RUBY_WRAPPER(rb_funcall_2, VALUE obj; ID sym; int argc; VALUE a; VALUE b)
19
- #define RB_FUNCALL_2(obj, sym, a, b) CALL_RUBY_WRAPPER(rb_funcall_2, obj, sym, 2, a, b)
20
-
21
- DECLARE_RUBY_WRAPPER(rb_intern, const char* name)
22
- #define RB_INTERN(name) CALL_RUBY_WRAPPER(rb_intern, name)
23
-
24
- JSBool convert_to_js(JohnsonRuntime* runtime, VALUE ruby, jsval* retval);
25
- VALUE convert_to_ruby(JohnsonRuntime* runtime, jsval js);
26
- VALUE convert_js_string_to_ruby(JohnsonRuntime* runtime, JSString* str);
27
-
28
- NORETURN(void raise_js_error_in_ruby(JohnsonRuntime* runtime));
29
- JSBool report_ruby_error_in_js(JohnsonRuntime* runtime, int state, VALUE old_errinfo);
30
-
31
- #endif
@@ -1,234 +0,0 @@
1
- #include "debugger.h"
2
- #include "context.h"
3
- #include "conversions.h"
4
- #include "immutable_node.h"
5
-
6
- static VALUE debugger_class = Qnil;
7
-
8
- bool ruby_value_is_debugger(VALUE maybe_debugger)
9
- {
10
- VALUE klass = CLASS_OF(maybe_debugger);
11
- return (klass == debugger_class);
12
- }
13
-
14
- /*
15
- * call-seq:
16
- * frame_pc(context, frame)
17
- *
18
- * Get the frame parse context
19
- */
20
- static VALUE frame_pc(VALUE UNUSED(self), VALUE context, VALUE frame)
21
- {
22
- JSContext * js = NULL;
23
- JSStackFrame * fp = NULL;
24
- Data_Get_Struct(context, JSContext, js);
25
- Data_Get_Struct(frame, JSStackFrame, fp);
26
- return Data_Wrap_Struct(rb_cObject, NULL, NULL, JS_GetFramePC(js, fp));
27
- }
28
-
29
- /*
30
- * call-seq:
31
- * line_number(context, script, bytecode)
32
- *
33
- * Get the line number of the +bytecode+ given +context+ and +script+
34
- */
35
- static VALUE line_number(VALUE UNUSED(self), VALUE context, VALUE script, VALUE bytecode)
36
- {
37
- JSContext * js = NULL;
38
- JSScript * js_script = NULL;
39
- jsbytecode * js_bytecode = NULL;
40
-
41
- Data_Get_Struct(context, JSContext, js);
42
- Data_Get_Struct(script, JSScript, js_script);
43
- Data_Get_Struct(bytecode, jsbytecode, js_bytecode);
44
-
45
- return INT2NUM((long)JS_PCToLineNumber(js, js_script, js_bytecode));
46
- }
47
-
48
- /*
49
- * call-seq:
50
- * file_name(context, script)
51
- *
52
- * Get the file name of the +script+ given +context+
53
- */
54
- static VALUE file_name(VALUE UNUSED(self), VALUE context, VALUE script)
55
- {
56
- JSContext * js = NULL;
57
- JSScript * js_script = NULL;
58
-
59
- Data_Get_Struct(context, JSContext, js);
60
- Data_Get_Struct(script, JSScript, js_script);
61
-
62
- return rb_str_new2(JS_GetScriptFilename(js, js_script));
63
- }
64
-
65
- static JSTrapStatus interrupt_handler(JSContext *js, JSScript *script,
66
- jsbytecode *pc, jsval *UNUSED(rval), void *rb)
67
- {
68
- assert(js);
69
- assert(rb);
70
- assert(pc);
71
-
72
- VALUE self = (VALUE)rb;
73
- VALUE rb_cx = Data_Wrap_Struct(rb_cObject, NULL, NULL, js);
74
- VALUE rb_script = Data_Wrap_Struct(rb_cObject, NULL, NULL, script);
75
- VALUE rb_pc = Data_Wrap_Struct(rb_cObject, NULL, NULL, pc);
76
-
77
- return NUM2INT(rb_funcall(self, rb_intern("interrupt_handler"), 3,
78
- rb_cx,
79
- rb_script,
80
- rb_pc
81
- ));
82
- }
83
-
84
- static void new_script_hook(JSContext *UNUSED(js),
85
- const char *filename,
86
- uintN lineno,
87
- JSScript *UNUSED(script),
88
- JSFunction *UNUSED(fun),
89
- void *rb)
90
- {
91
- VALUE self = (VALUE)rb;
92
- VALUE rb_filename = rb_str_new2(filename);
93
- VALUE rb_linenum = UINT2NUM((unsigned long)lineno);
94
-
95
- /* FIXME: Pass the rest of this crap to the debugger? */
96
- rb_funcall(self, rb_intern("new_script_hook"), 2, rb_filename, rb_linenum);
97
- }
98
-
99
- static void destroy_script_hook(JSContext *UNUSED(js),
100
- JSScript *UNUSED(script),
101
- void *rb)
102
- {
103
- VALUE self = (VALUE)rb;
104
- rb_funcall(self, rb_intern("destroy_script_hook"), 0);
105
- }
106
-
107
- static JSTrapStatus debugger_handler(JSContext *js, JSScript *script,
108
- jsbytecode *pc, jsval *UNUSED(rval), void *rb)
109
- {
110
- assert(js);
111
- assert(rb);
112
- assert(pc);
113
-
114
- VALUE self = (VALUE)rb;
115
- VALUE rb_cx = Data_Wrap_Struct(rb_cObject, NULL, NULL, js);
116
- VALUE rb_script = Data_Wrap_Struct(rb_cObject, NULL, NULL, script);
117
- VALUE rb_pc = Data_Wrap_Struct(rb_cObject, NULL, NULL, pc);
118
-
119
- return NUM2INT(rb_funcall(self, rb_intern("debugger_handler"), 3,
120
- rb_cx,
121
- rb_script,
122
- rb_pc
123
- ));
124
- }
125
-
126
- static void source_handler(const char *filename, uintN lineno,
127
- jschar *str, size_t length,
128
- void **UNUSED(listenerTSData), void *rb)
129
- {
130
- VALUE self = (VALUE)rb;
131
- VALUE rb_filename = rb_str_new2(filename);
132
- VALUE rb_lineno = ULONG2NUM((unsigned long)lineno);
133
- VALUE rb_str = rb_str_new((char *)str, (signed long)(length * sizeof(jschar)));
134
-
135
- rb_funcall(self, rb_intern("source_handler"), 3, rb_filename, rb_lineno, rb_str);
136
- }
137
-
138
- static void * execute_hook(JSContext *js, JSStackFrame *fp, JSBool before,
139
- JSBool *ok, void *rb)
140
- {
141
- VALUE self = (VALUE)rb;
142
- VALUE rb_before = JS_TRUE == before ? Qtrue : Qfalse;
143
- VALUE rb_ok = ok ? Qtrue : Qfalse;
144
- VALUE rb_js = Data_Wrap_Struct(rb_cObject, NULL, NULL, (void *)js);
145
- VALUE rb_fp = Data_Wrap_Struct(rb_cObject, NULL, NULL, (void *)fp);
146
-
147
- rb_funcall(self, rb_intern("execute_hook"), 4, rb_js,rb_fp,rb_before,rb_ok);
148
- return rb;
149
- }
150
-
151
- static void * call_hook(JSContext *UNUSED(js), JSStackFrame *UNUSED(fp), JSBool before,
152
- JSBool *ok, void *rb)
153
- {
154
- VALUE self = (VALUE)rb;
155
- VALUE rb_before = before ? Qtrue : Qfalse;
156
- VALUE rb_ok = ok ? Qtrue : Qfalse;
157
-
158
- rb_funcall(self, rb_intern("call_hook"), 2, rb_before, rb_ok);
159
- return rb;
160
- }
161
-
162
- static void object_hook(JSContext *js, JSObject *obj, JSBool isNew, void *rb)
163
- {
164
- assert(rb);
165
- assert(js);
166
- assert(obj);
167
- VALUE self = (VALUE)rb;
168
-
169
- VALUE rb_is_new = isNew ? Qtrue : Qfalse;
170
-
171
- rb_funcall(self, rb_intern("object_hook"), 1, rb_is_new);
172
- }
173
-
174
- static JSTrapStatus throw_hook(JSContext *UNUSED(js), JSScript *UNUSED(script),
175
- jsbytecode *pc, jsval *UNUSED(rval), void *rb)
176
- {
177
- VALUE self = (VALUE)rb;
178
- VALUE rb_bytecode = jsop_to_symbol(*pc);
179
- return NUM2INT(rb_funcall(self, rb_intern("throw_hook"), 1, rb_bytecode));
180
- }
181
-
182
- static JSBool debug_error_hook(JSContext *UNUSED(js), const char *message,
183
- JSErrorReport *UNUSED(report), void *rb)
184
- {
185
- VALUE self = (VALUE)rb;
186
- VALUE rb_message = rb_str_new2(message);
187
- rb_funcall(self, rb_intern("debug_error_hook"), 1, rb_message);
188
- return JS_TRUE;
189
- }
190
-
191
- static VALUE allocate(VALUE klass)
192
- {
193
- JSDebugHooks* debug = calloc(1L, sizeof(JSDebugHooks));
194
- VALUE self = Data_Wrap_Struct(klass, 0, 0, debug);
195
-
196
- debug->interruptHandler = interrupt_handler;
197
- debug->interruptHandlerData = (void *)self;
198
- debug->newScriptHook = new_script_hook;
199
- debug->newScriptHookData = (void *)self;
200
- debug->destroyScriptHook = destroy_script_hook;
201
- debug->destroyScriptHookData = (void *)self;
202
- debug->debuggerHandler = debugger_handler;
203
- debug->debuggerHandlerData = (void *)self;
204
- debug->sourceHandler = source_handler;
205
- debug->sourceHandlerData = (void *)self;
206
- debug->executeHook = execute_hook;
207
- debug->executeHookData = (void *)self;
208
- debug->callHook = call_hook;
209
- debug->callHookData = (void *)self;
210
- debug->objectHook = object_hook;
211
- debug->objectHookData = (void *)self;
212
- debug->throwHook = throw_hook;
213
- debug->throwHookData = (void *)self;
214
- debug->debugErrorHook = debug_error_hook;
215
- debug->debugErrorHookData = (void *)self;
216
-
217
- return self;
218
- }
219
-
220
- void init_Johnson_SpiderMonkey_Debugger(VALUE spidermonkey)
221
- {
222
- /* HACK: These comments are *only* to make RDoc happy.
223
- VALUE johnson = rb_define_module("Johnson");
224
- VALUE spidermonkey = rb_define_module_under(johnson, "SpiderMonkey");
225
- */
226
-
227
- /* This is the debugging hooks used with SpiderMonkey. */
228
- debugger_class = rb_define_class_under(spidermonkey, "Debugger", rb_cObject);
229
- rb_define_private_method(debugger_class, "frame_pc", frame_pc, 2);
230
- rb_define_private_method(debugger_class, "line_number", line_number, 3);
231
- rb_define_private_method(debugger_class, "file_name", file_name, 2);
232
-
233
- rb_define_alloc_func(debugger_class, allocate);
234
- }
@@ -1,10 +0,0 @@
1
- #ifndef JOHNSON_SPIDERMONKEY_DEBUGGER_H
2
- #define JOHNSON_SPIDERMONKEY_DEBUGGER_H
3
-
4
- #include "spidermonkey.h"
5
- #include "jsdbgapi.h"
6
-
7
- void init_Johnson_SpiderMonkey_Debugger(VALUE spidermonkey);
8
- bool ruby_value_is_debugger(VALUE maybe_debugger);
9
-
10
- #endif
@@ -1,32 +0,0 @@
1
- ENV["RC_ARCHS"] = "" if RUBY_PLATFORM =~ /darwin/
2
-
3
- require "find"
4
- require "mkmf"
5
-
6
- cflags = %w(g)
7
- defines = %w(XP_UNIX)
8
-
9
- warnings = %w(all extra cast-qual write-strings conversion missing-noreturn)
10
- warnings << "inline"
11
-
12
- cflags.concat warnings.collect { |w| "W#{w}" }
13
- cflags.concat defines.collect { |d| "D#{d}" }
14
-
15
- $CFLAGS << cflags.collect { |f| " -#{f}" }.join(" ")
16
-
17
- spidermonkey_dir = File.expand_path File.dirname(__FILE__) +
18
- "/../../vendor/spidermonkey"
19
-
20
- Dir.chdir spidermonkey_dir do
21
- system "make -f Makefile.ref" if Dir["**/libjs.a"].empty?
22
- end
23
-
24
- libjs = Dir[spidermonkey_dir + "/**/libjs.a"].first
25
- $LOCAL_LIBS << libjs
26
-
27
- dir_config "johnson/spidermonkey"
28
-
29
- find_header "jsautocfg.h", File.dirname(libjs)
30
- find_header "jsapi.h", spidermonkey_dir
31
-
32
- create_makefile "johnson/spidermonkey/spidermonkey"
@@ -1,37 +0,0 @@
1
- #include "extensions.h"
2
-
3
- static JSBool /* Object.defineProperty(target, name, value, flags) */
4
- define_property(JSContext *js_context, JSObject* UNUSED(obj), uintN argc, jsval *argv, jsval *retval) {
5
- assert(argc > 1);
6
- char *name = JS_GetStringBytes(JSVAL_TO_STRING(argv[1]));
7
-
8
- // READ_ONLY | ITERABLE | NON_DELETABLE
9
- jsuint flags = argc > 3 ? (unsigned) JSVAL_TO_INT(argv[3]) : 0;
10
-
11
- *retval = JSVAL_VOID;
12
- return JS_DefineProperty(js_context, JSVAL_TO_OBJECT(argv[0]), name, argc > 2 ? argv[2] : JSVAL_VOID, NULL, NULL, flags);
13
- }
14
-
15
- VALUE init_spidermonkey_extensions(JohnsonContext* context, VALUE self)
16
- {
17
- PREPARE_RUBY_JROOTS(context->js, 1);
18
-
19
- jsval Object;
20
- JSObject * global = JS_GetGlobalObject(context->js);
21
- JCHECK(JS_GetProperty(context->js, global, "Object", &Object));
22
- JROOT(Object);
23
-
24
- JCHECK(JS_DefineFunction(context->js, JSVAL_TO_OBJECT(Object),
25
- "defineProperty", define_property, 4, 0));
26
-
27
- JCHECK(JS_DefineProperty(context->js, JSVAL_TO_OBJECT(Object), "READ_ONLY",
28
- INT_TO_JSVAL(0x02), NULL, NULL, JSPROP_READONLY));
29
-
30
- JCHECK(JS_DefineProperty(context->js, JSVAL_TO_OBJECT(Object), "ITERABLE",
31
- INT_TO_JSVAL(0x01), NULL, NULL, JSPROP_READONLY));
32
-
33
- JCHECK(JS_DefineProperty(context->js, JSVAL_TO_OBJECT(Object), "NON_DELETABLE",
34
- INT_TO_JSVAL(0x04), NULL, NULL, JSPROP_READONLY));
35
-
36
- JRETURN_RUBY(self);
37
- }
@@ -1,12 +0,0 @@
1
- #ifndef JOHNSON_SPIDERMONKEY_EXTENSIONS_H
2
- #define JOHNSON_SPIDERMONKEY_EXTENSIONS_H
3
-
4
- #include "spidermonkey.h"
5
- #include "context.h"
6
- #include "conversions.h"
7
-
8
- // A context is passed here because there might not be a current context
9
- // for the runtime when the function is called.
10
- VALUE init_spidermonkey_extensions(JohnsonContext* context, VALUE self);
11
-
12
- #endif
@@ -1,40 +0,0 @@
1
- #include "global.h"
2
-
3
- static JSBool enumerate(JSContext *js_context, JSObject *obj)
4
- {
5
- return JS_EnumerateStandardClasses(js_context, obj);
6
- }
7
-
8
- static JSBool resolve(JSContext *js_context, JSObject *obj, jsval id, uintN flags, JSObject **objp)
9
- {
10
- if ((flags & JSRESOLVE_ASSIGNING) == 0)
11
- {
12
- JSBool resolved_p;
13
-
14
- if (!JS_ResolveStandardClass(js_context, obj, id, &resolved_p))
15
- return JS_FALSE;
16
-
17
- if (resolved_p)
18
- *objp = obj;
19
- }
20
-
21
- return JS_TRUE;
22
- }
23
-
24
- static JSClass OurGlobalClass = {
25
- "global", JSCLASS_NEW_RESOLVE | JSCLASS_GLOBAL_FLAGS,
26
- JS_PropertyStub, // addProperty
27
- JS_PropertyStub, // delProperty
28
- JS_PropertyStub, // getProperty
29
- JS_PropertyStub, // setProperty
30
- enumerate,
31
- (JSResolveOp) resolve,
32
- JS_ConvertStub,
33
- JS_FinalizeStub,
34
- JSCLASS_NO_OPTIONAL_MEMBERS
35
- };
36
-
37
- JSObject* johnson_create_global_object(JSContext* context)
38
- {
39
- return JS_NewObject(context, &OurGlobalClass, NULL, NULL);
40
- }
@@ -1,11 +0,0 @@
1
- #ifndef JOHNSON_SPIDERMONKEY_GLOBAL_H
2
- #define JOHNSON_SPIDERMONKEY_GLOBAL_H
3
-
4
- #include "spidermonkey.h"
5
- #include "context.h"
6
- #include "runtime.h"
7
-
8
- // NOTE: one of the FEW places a context should be passed around
9
- JSObject* johnson_create_global_object(JSContext* context);
10
-
11
- #endif
@@ -1,16 +0,0 @@
1
- #include "idhash.h"
2
-
3
- static JSHashNumber key_hash(const void *key)
4
- {
5
- return (JSHashNumber)key;
6
- }
7
-
8
- static intN comparator(const void *v1, const void *v2)
9
- {
10
- return v1 == v2;
11
- }
12
-
13
- JSHashTable* create_id_hash()
14
- {
15
- return JS_NewHashTable(0, key_hash, comparator, comparator, NULL, NULL);
16
- }
@@ -1,8 +0,0 @@
1
- #ifndef JOHNSON_SPIDERMONKEY_IDHASH_H
2
- #define JOHNSON_SPIDERMONKEY_IDHASH_H
3
-
4
- #include "spidermonkey.h"
5
-
6
- JSHashTable* create_id_hash();
7
-
8
- #endif
@@ -1,1153 +0,0 @@
1
- #include "immutable_node.h"
2
-
3
- static VALUE cNode;
4
-
5
- static void deallocate(ImmutableNodeContext* context)
6
- {
7
- if (context->pc)
8
- {
9
- js_FinishParseContext(context->js, context->pc);
10
- free(context->pc);
11
- }
12
-
13
- JS_DestroyContext(context->js);
14
- JS_DestroyRuntime(context->runtime);
15
- free(context);
16
- }
17
-
18
- static VALUE allocate(VALUE klass)
19
- {
20
- ImmutableNodeContext * context = calloc(1L, sizeof(ImmutableNodeContext));
21
-
22
- VALUE self = Data_Wrap_Struct(klass, 0, deallocate, context);
23
-
24
- assert(context->runtime = JS_NewRuntime(0x100000));
25
- assert(context->js = JS_NewContext(context->runtime, 8192L));
26
-
27
- return self;
28
- }
29
-
30
- /*
31
- * call-seq:
32
- * parse_io(stream, filename=nil, line_number=0)
33
- *
34
- * Parses an IO object, returning a native spidermonkey parse tree.
35
- */
36
- static VALUE parse_io(int argc, VALUE *argv, VALUE klass) {
37
- VALUE self = allocate(klass);
38
- VALUE stream, filename, linenum;
39
-
40
- ImmutableNodeContext* context;
41
- Data_Get_Struct(self, ImmutableNodeContext, context);
42
-
43
- assert(context->pc = calloc(1L, sizeof(JSParseContext)));
44
-
45
- rb_scan_args( argc, argv, "12", &stream, &filename, &linenum );
46
-
47
- VALUE file_contents = rb_funcall(stream, rb_intern("read"), 0);
48
- size_t length = NUM2INT(rb_funcall(file_contents, rb_intern("length"), 0));
49
-
50
- jschar* chars;
51
- assert(chars = js_InflateString(context->js, StringValuePtr(file_contents), &length));
52
-
53
- if(!filename && rb_respond_to(stream, rb_intern("path"))) {
54
- filename = rb_funcall(stream, rb_intern("path"), 0);
55
- }
56
- char* filenamez = RTEST(filename) ? StringValueCStr(filename) : NULL;
57
- int linenumi = RTEST(linenum) ? NUM2INT(linenum) : 1;
58
-
59
- assert(js_InitParseContext(context->js, context->pc,
60
- NULL,
61
- chars,
62
- length,
63
- NULL, filenamez, (unsigned)linenumi));
64
- JS_SetVersion(context->js, JSVERSION_LATEST);
65
-
66
- context->node = js_ParseScript(context->js,
67
- JS_NewObject(context->js, NULL, NULL, NULL),
68
- context->pc);
69
- if(JS_IsExceptionPending(context->js)) {
70
- jsval exception, message, file_name, line_number;
71
- JS_GetPendingException(context->js, &exception);
72
- JS_GetProperty(context->js, JSVAL_TO_OBJECT(exception), "message",&message);
73
- JS_GetProperty(context->js, JSVAL_TO_OBJECT(exception), "fileName",&file_name);
74
- JS_GetProperty(context->js, JSVAL_TO_OBJECT(exception), "lineNumber",&line_number);
75
- JS_ClearPendingException(context->js);
76
-
77
- rb_funcall( self,
78
- rb_intern("raise_parse_error"),
79
- 3,
80
- message == JSVAL_NULL ?
81
- Qnil :
82
- rb_str_new2(JS_GetStringBytes(JSVAL_TO_STRING(message))),
83
- rb_str_new2(JS_GetStringBytes(JSVAL_TO_STRING(file_name))),
84
- INT2NUM((long)JSVAL_TO_INT(line_number))
85
- );
86
-
87
- }
88
- return self;
89
- }
90
-
91
- /*
92
- * call-seq:
93
- * line
94
- *
95
- * Returns the line number of the node.
96
- */
97
- static VALUE line(VALUE self) {
98
- ImmutableNodeContext * ctx;
99
-
100
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
101
- return INT2NUM((long)(ctx->node->pn_pos.begin.lineno));
102
- }
103
-
104
- /*
105
- * call-seq:
106
- * index
107
- *
108
- * Returns the column number of the node.
109
- */
110
- static VALUE begin_index(VALUE self) {
111
- ImmutableNodeContext * ctx;
112
-
113
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
114
- return INT2NUM((long)(ctx->node->pn_pos.begin.index));
115
- }
116
-
117
- /*
118
- * call-seq:
119
- * pn_arity
120
- *
121
- * Returns the arity of the node as a symbol.
122
- */
123
- static VALUE pn_arity(VALUE self) {
124
- ImmutableNodeContext * ctx;
125
-
126
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
127
- switch(ctx->node->pn_arity) {
128
- case PN_FUNC:
129
- return ID2SYM(rb_intern("pn_func"));
130
- case PN_LIST:
131
- return ID2SYM(rb_intern("pn_list"));
132
- case PN_TERNARY:
133
- return ID2SYM(rb_intern("pn_ternary"));
134
- case PN_BINARY:
135
- return ID2SYM(rb_intern("pn_binary"));
136
- case PN_UNARY:
137
- return ID2SYM(rb_intern("pn_unary"));
138
- case PN_NAME:
139
- return ID2SYM(rb_intern("pn_name"));
140
- case PN_NULLARY:
141
- return ID2SYM(rb_intern("pn_nullary"));
142
- }
143
- return Qnil;
144
- }
145
-
146
- /*
147
- * call-seq:
148
- * pn_type
149
- *
150
- * Returns the type of the node as a symbol.
151
- */
152
- static VALUE pn_type(VALUE self) {
153
- ImmutableNodeContext * ctx;
154
-
155
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
156
- switch(ctx->node->pn_type) {
157
-
158
- case TOK_EOF: return ID2SYM(rb_intern("tok_eof"));
159
-
160
- case TOK_EOL: return ID2SYM(rb_intern("tok_eol"));
161
-
162
- case TOK_SEMI: return ID2SYM(rb_intern("tok_semi"));
163
-
164
- case TOK_COMMA: return ID2SYM(rb_intern("tok_comma"));
165
-
166
- case TOK_ASSIGN: return ID2SYM(rb_intern("tok_assign"));
167
-
168
- case TOK_HOOK: return ID2SYM(rb_intern("tok_hook"));
169
-
170
- case TOK_COLON: return ID2SYM(rb_intern("tok_colon"));
171
-
172
- case TOK_OR: return ID2SYM(rb_intern("tok_or"));
173
-
174
- case TOK_AND: return ID2SYM(rb_intern("tok_and"));
175
-
176
- case TOK_BITOR: return ID2SYM(rb_intern("tok_bitor"));
177
-
178
- case TOK_BITXOR: return ID2SYM(rb_intern("tok_bitxor"));
179
-
180
- case TOK_BITAND: return ID2SYM(rb_intern("tok_bitand"));
181
-
182
- case TOK_EQOP: return ID2SYM(rb_intern("tok_eqop"));
183
-
184
- case TOK_RELOP: return ID2SYM(rb_intern("tok_relop"));
185
-
186
- case TOK_SHOP: return ID2SYM(rb_intern("tok_shop"));
187
-
188
- case TOK_PLUS: return ID2SYM(rb_intern("tok_plus"));
189
-
190
- case TOK_MINUS: return ID2SYM(rb_intern("tok_minus"));
191
-
192
- case TOK_STAR: return ID2SYM(rb_intern("tok_star"));
193
-
194
- case TOK_DIVOP: return ID2SYM(rb_intern("tok_divop"));
195
-
196
- case TOK_UNARYOP: return ID2SYM(rb_intern("tok_unaryop"));
197
-
198
- case TOK_INC: return ID2SYM(rb_intern("tok_inc"));
199
-
200
- case TOK_DEC: return ID2SYM(rb_intern("tok_dec"));
201
-
202
- case TOK_DOT: return ID2SYM(rb_intern("tok_dot"));
203
-
204
- case TOK_LB: return ID2SYM(rb_intern("tok_lb"));
205
-
206
- case TOK_RB: return ID2SYM(rb_intern("tok_rb"));
207
-
208
- case TOK_LC: return ID2SYM(rb_intern("tok_lc"));
209
-
210
- case TOK_RC: return ID2SYM(rb_intern("tok_rc"));
211
-
212
- case TOK_LP: return ID2SYM(rb_intern("tok_lp"));
213
-
214
- case TOK_RP: return ID2SYM(rb_intern("tok_rp"));
215
-
216
- case TOK_NAME: return ID2SYM(rb_intern("tok_name"));
217
-
218
- case TOK_NUMBER: return ID2SYM(rb_intern("tok_number"));
219
-
220
- case TOK_STRING: return ID2SYM(rb_intern("tok_string"));
221
-
222
- case TOK_REGEXP: return ID2SYM(rb_intern("tok_regexp"));
223
-
224
- case TOK_PRIMARY: return ID2SYM(rb_intern("tok_primary"));
225
-
226
- case TOK_FUNCTION: return ID2SYM(rb_intern("tok_function"));
227
-
228
- case TOK_EXPORT: return ID2SYM(rb_intern("tok_export"));
229
-
230
- case TOK_IMPORT: return ID2SYM(rb_intern("tok_import"));
231
-
232
- case TOK_IF: return ID2SYM(rb_intern("tok_if"));
233
-
234
- case TOK_ELSE: return ID2SYM(rb_intern("tok_else"));
235
-
236
- case TOK_SWITCH: return ID2SYM(rb_intern("tok_switch"));
237
-
238
- case TOK_CASE: return ID2SYM(rb_intern("tok_case"));
239
-
240
- case TOK_DEFAULT: return ID2SYM(rb_intern("tok_default"));
241
-
242
- case TOK_WHILE: return ID2SYM(rb_intern("tok_while"));
243
-
244
- case TOK_DO: return ID2SYM(rb_intern("tok_do"));
245
-
246
- case TOK_FOR: return ID2SYM(rb_intern("tok_for"));
247
-
248
- case TOK_BREAK: return ID2SYM(rb_intern("tok_break"));
249
-
250
- case TOK_CONTINUE: return ID2SYM(rb_intern("tok_continue"));
251
-
252
- case TOK_IN: return ID2SYM(rb_intern("tok_in"));
253
-
254
- case TOK_VAR: return ID2SYM(rb_intern("tok_var"));
255
-
256
- case TOK_WITH: return ID2SYM(rb_intern("tok_with"));
257
-
258
- case TOK_RETURN: return ID2SYM(rb_intern("tok_return"));
259
-
260
- case TOK_NEW: return ID2SYM(rb_intern("tok_new"));
261
-
262
- case TOK_DELETE: return ID2SYM(rb_intern("tok_delete"));
263
-
264
- case TOK_DEFSHARP: return ID2SYM(rb_intern("tok_defsharp"));
265
-
266
- case TOK_USESHARP: return ID2SYM(rb_intern("tok_usesharp"));
267
-
268
- case TOK_TRY: return ID2SYM(rb_intern("tok_try"));
269
-
270
- case TOK_CATCH: return ID2SYM(rb_intern("tok_catch"));
271
-
272
- case TOK_FINALLY: return ID2SYM(rb_intern("tok_finally"));
273
-
274
- case TOK_THROW: return ID2SYM(rb_intern("tok_throw"));
275
-
276
- case TOK_INSTANCEOF: return ID2SYM(rb_intern("tok_instanceof"));
277
-
278
- case TOK_DEBUGGER: return ID2SYM(rb_intern("tok_debugger"));
279
-
280
- case TOK_XMLSTAGO: return ID2SYM(rb_intern("tok_xmlstago"));
281
-
282
- case TOK_XMLETAGO: return ID2SYM(rb_intern("tok_xmletago"));
283
-
284
- case TOK_XMLPTAGC: return ID2SYM(rb_intern("tok_xmlptagc"));
285
-
286
- case TOK_XMLTAGC: return ID2SYM(rb_intern("tok_xmltagc"));
287
-
288
- case TOK_XMLNAME: return ID2SYM(rb_intern("tok_xmlname"));
289
-
290
- case TOK_XMLATTR: return ID2SYM(rb_intern("tok_xmlattr"));
291
-
292
- case TOK_XMLSPACE: return ID2SYM(rb_intern("tok_xmlspace"));
293
-
294
- case TOK_XMLTEXT: return ID2SYM(rb_intern("tok_xmltext"));
295
-
296
- case TOK_XMLCOMMENT: return ID2SYM(rb_intern("tok_xmlcomment"));
297
-
298
- case TOK_XMLCDATA: return ID2SYM(rb_intern("tok_xmlcdata"));
299
-
300
- case TOK_XMLPI: return ID2SYM(rb_intern("tok_xmlpi"));
301
-
302
- case TOK_AT: return ID2SYM(rb_intern("tok_at"));
303
-
304
- case TOK_DBLCOLON: return ID2SYM(rb_intern("tok_dblcolon"));
305
-
306
- case TOK_ANYNAME: return ID2SYM(rb_intern("tok_anyname"));
307
-
308
- case TOK_DBLDOT: return ID2SYM(rb_intern("tok_dbldot"));
309
-
310
- case TOK_FILTER: return ID2SYM(rb_intern("tok_filter"));
311
-
312
- case TOK_XMLELEM: return ID2SYM(rb_intern("tok_xmlelem"));
313
-
314
- case TOK_XMLLIST: return ID2SYM(rb_intern("tok_xmllist"));
315
-
316
- case TOK_YIELD: return ID2SYM(rb_intern("tok_yield"));
317
-
318
- case TOK_ARRAYCOMP: return ID2SYM(rb_intern("tok_arraycomp"));
319
-
320
- case TOK_ARRAYPUSH: return ID2SYM(rb_intern("tok_arraypush"));
321
-
322
- case TOK_LEXICALSCOPE: return ID2SYM(rb_intern("tok_lexicalscope"));
323
-
324
- case TOK_LET: return ID2SYM(rb_intern("tok_let"));
325
-
326
- case TOK_BODY: return ID2SYM(rb_intern("tok_body"));
327
-
328
- case TOK_RESERVED: return ID2SYM(rb_intern("tok_reserved"));
329
-
330
- case TOK_LIMIT: return ID2SYM(rb_intern("tok_limit"));
331
-
332
- }
333
- return INT2NUM((long)(ctx->node->pn_type));
334
- }
335
-
336
- /*
337
- * call-seq:
338
- * pn_expr
339
- *
340
- * Returns the parse node expression as an ImmutableNode.
341
- */
342
- static VALUE data_pn_expr(VALUE self) {
343
- ImmutableNodeContext * ctx;
344
-
345
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
346
- if(ctx->node->pn_expr) {
347
- ImmutableNodeContext *roc;
348
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
349
- roc->js = ctx->js;
350
- roc->node = ctx->node->pn_expr;
351
- return node;
352
- }
353
- return Qnil;
354
- }
355
-
356
- /*
357
- * call-seq:
358
- * pn_kid
359
- *
360
- * Returns the child ImmutableNode.
361
- */
362
- static VALUE data_pn_kid(VALUE self) {
363
- ImmutableNodeContext * ctx;
364
-
365
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
366
- if(ctx->node->pn_kid) {
367
- ImmutableNodeContext *roc;
368
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
369
- roc->js = ctx->js;
370
- roc->node = ctx->node->pn_kid;
371
- return node;
372
- }
373
- return Qnil;
374
- }
375
-
376
- /*
377
- * call-seq:
378
- * pn_kid1
379
- *
380
- * Returns the first child ImmutableNode.
381
- */
382
- static VALUE data_pn_kid1(VALUE self) {
383
- ImmutableNodeContext * ctx;
384
-
385
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
386
- if(ctx->node->pn_kid1) {
387
- ImmutableNodeContext *roc;
388
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
389
- roc->js = ctx->js;
390
- roc->node = ctx->node->pn_kid1;
391
- return node;
392
- }
393
- return Qnil;
394
- }
395
-
396
- /*
397
- * call-seq:
398
- * pn_kid2
399
- *
400
- * Returns the second child ImmutableNode.
401
- */
402
- static VALUE data_pn_kid2(VALUE self) {
403
- ImmutableNodeContext * ctx;
404
-
405
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
406
- if(ctx->node->pn_kid2) {
407
- ImmutableNodeContext *roc;
408
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
409
- roc->js = ctx->js;
410
- roc->node = ctx->node->pn_kid2;
411
- return node;
412
- }
413
- return Qnil;
414
- }
415
-
416
- /*
417
- * call-seq:
418
- * pn_kid3
419
- *
420
- * Returns the third child ImmutableNode.
421
- */
422
- static VALUE data_pn_kid3(VALUE self) {
423
- ImmutableNodeContext * ctx;
424
-
425
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
426
- if(ctx->node->pn_kid3) {
427
- ImmutableNodeContext *roc;
428
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
429
- roc->js = ctx->js;
430
- roc->node = ctx->node->pn_kid3;
431
- return node;
432
- }
433
- return Qnil;
434
- }
435
-
436
- /*
437
- * call-seq:
438
- * pn_dval
439
- *
440
- * Returns the numeric value of the node.
441
- */
442
- static VALUE data_pn_dval(VALUE self) {
443
- ImmutableNodeContext * ctx;
444
-
445
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
446
- if(JSVAL_IS_NUMBER(ATOM_KEY(ctx->node->pn_atom))) {
447
- return rb_float_new(ctx->node->pn_dval);
448
- } else {
449
- return INT2NUM((long)(ctx->node->pn_dval));
450
- }
451
- }
452
-
453
- /*
454
- * call-seq:
455
- * pn_op
456
- *
457
- * Returns the op code for the node as a symbol.
458
- */
459
- static VALUE data_pn_op(VALUE self) {
460
- ImmutableNodeContext * ctx;
461
-
462
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
463
- return jsop_to_symbol(ctx->node->pn_op);
464
- }
465
-
466
- /*
467
- * call-seq:
468
- * pn_left
469
- *
470
- * Returns the left side ImmutableNode.
471
- */
472
- static VALUE data_pn_left(VALUE self) {
473
- ImmutableNodeContext * ctx;
474
-
475
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
476
-
477
- if(ctx->node->pn_left) {
478
- ImmutableNodeContext *roc;
479
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
480
- roc->js = ctx->js;
481
- roc->node = ctx->node->pn_left;
482
- return node;
483
- }
484
- return Qnil;
485
- }
486
-
487
- /*
488
- * call-seq:
489
- * pn_extra
490
- *
491
- * Returns extra informaton about the node as an Integer.
492
- */
493
- static VALUE data_pn_extra(VALUE self) {
494
- ImmutableNodeContext * ctx;
495
-
496
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
497
-
498
- return UINT2NUM((unsigned long)(ctx->node->pn_extra));
499
- }
500
-
501
- /*
502
- * call-seq:
503
- * name
504
- *
505
- * Returns the name of the node.
506
- */
507
- static VALUE name(VALUE self) {
508
- ImmutableNodeContext * ctx;
509
-
510
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
511
- return rb_str_new2(JS_GetStringBytes(ATOM_TO_STRING(ctx->node->pn_atom)));
512
- }
513
-
514
- /*
515
- * call-seq:
516
- * regexp
517
- *
518
- * Returns the regexp value as a String.
519
- */
520
- static VALUE regexp(VALUE self) {
521
- ImmutableNodeContext * ctx;
522
- jsval result;
523
-
524
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
525
- js_regexp_toString(ctx->js, ctx->node->pn_pob->object, &result);
526
- return rb_str_new2(JS_GetStringBytes(JSVAL_TO_STRING(result)));
527
- }
528
-
529
- /*
530
- * call-seq:
531
- * function_name
532
- *
533
- * Returns the function name as a String.
534
- */
535
- static VALUE function_name(VALUE self) {
536
- ImmutableNodeContext * ctx;
537
- JSFunction * f;
538
- JSObject * object;
539
-
540
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
541
- object = ctx->node->pn_funpob->object;
542
- f = (JSFunction *)JS_GetPrivate(ctx->js, ctx->node->pn_funpob->object);
543
-
544
- if(f->atom) {
545
- return rb_str_new2(JS_GetStringBytes(ATOM_TO_STRING(f->atom)));
546
- } else {
547
- return Qnil;
548
- }
549
- }
550
-
551
- /*
552
- * call-seq:
553
- * function_args
554
- *
555
- * Returns the function argument names as an Array of String.
556
- */
557
- static VALUE function_args(VALUE self) {
558
- ImmutableNodeContext * ctx;
559
- JSFunction * f;
560
- JSObject * object;
561
- jsuword* names;
562
- VALUE func_args;
563
- int i;
564
-
565
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
566
- object = ctx->node->pn_funpob->object;
567
- f = (JSFunction *)JS_GetPrivate(ctx->js, ctx->node->pn_funpob->object);
568
-
569
- func_args = rb_ary_new2((long)f->nargs);
570
- if(f->nargs > 0) {
571
- names = js_GetLocalNameArray(ctx->js, f, &ctx->js->tempPool);
572
- for(i = 0; i < f->nargs; i++) {
573
- rb_ary_push(func_args,
574
- rb_str_new2(JS_GetStringBytes(ATOM_TO_STRING(names[i])))
575
- );
576
- }
577
- }
578
- return func_args;
579
- }
580
-
581
- /*
582
- * call-seq:
583
- * function_body
584
- *
585
- * Returns the function body as an ImmutableNode.
586
- */
587
- static VALUE function_body(VALUE self) {
588
- ImmutableNodeContext * ctx;
589
- JSFunction * f;
590
- JSObject * object;
591
-
592
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
593
- object = ctx->node->pn_funpob->object;
594
- f = (JSFunction *)JS_GetPrivate(ctx->js, ctx->node->pn_funpob->object);
595
-
596
- if(ctx->node->pn_body) {
597
- ImmutableNodeContext *roc;
598
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
599
- roc->js = ctx->js;
600
- roc->node = ctx->node->pn_body;
601
- return node;
602
- }
603
- return Qnil;
604
- }
605
-
606
- /*
607
- * call-seq:
608
- * pn_right
609
- *
610
- * Returns right side as an ImmutableNode.
611
- */
612
- static VALUE data_pn_right(VALUE self)
613
- {
614
- ImmutableNodeContext * ctx;
615
-
616
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
617
-
618
- if(ctx->node->pn_right) {
619
- ImmutableNodeContext *roc;
620
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
621
- roc->js = ctx->js;
622
- roc->node = ctx->node->pn_right;
623
- return node;
624
- }
625
- return Qnil;
626
- }
627
-
628
- /*
629
- * call-seq:
630
- * children
631
- *
632
- * Returns children as an Array of ImmutableNode.
633
- */
634
- static VALUE children(VALUE self) {
635
- ImmutableNodeContext * ctx;
636
- JSParseNode * p;
637
- VALUE children;
638
-
639
- Data_Get_Struct(self, ImmutableNodeContext, ctx);
640
- children = rb_ary_new();
641
- for(p = ctx->node->pn_head; p != NULL; p = p->pn_next) {
642
- ImmutableNodeContext *roc;
643
- VALUE node = Data_Make_Struct(cNode, ImmutableNodeContext, NULL, NULL, roc);
644
- roc->js = ctx->js;
645
- roc->node = p;
646
-
647
- rb_ary_push(children, node);
648
- }
649
-
650
- return children;
651
- }
652
-
653
- VALUE jsop_to_symbol(JSUint32 jsop)
654
- {
655
- switch(jsop) {
656
-
657
- case JSOP_NOP: return ID2SYM(rb_intern("jsop_nop"));
658
-
659
- case JSOP_PUSH: return ID2SYM(rb_intern("jsop_push"));
660
-
661
- case JSOP_POPV: return ID2SYM(rb_intern("jsop_popv"));
662
-
663
- case JSOP_ENTERWITH: return ID2SYM(rb_intern("jsop_enterwith"));
664
-
665
- case JSOP_LEAVEWITH: return ID2SYM(rb_intern("jsop_leavewith"));
666
-
667
- case JSOP_RETURN: return ID2SYM(rb_intern("jsop_return"));
668
-
669
- case JSOP_GOTO: return ID2SYM(rb_intern("jsop_goto"));
670
-
671
- case JSOP_IFEQ: return ID2SYM(rb_intern("jsop_ifeq"));
672
-
673
- case JSOP_IFNE: return ID2SYM(rb_intern("jsop_ifne"));
674
-
675
- case JSOP_ARGUMENTS: return ID2SYM(rb_intern("jsop_arguments"));
676
-
677
- case JSOP_FORARG: return ID2SYM(rb_intern("jsop_forarg"));
678
-
679
- case JSOP_FORVAR: return ID2SYM(rb_intern("jsop_forvar"));
680
-
681
- case JSOP_DUP: return ID2SYM(rb_intern("jsop_dup"));
682
-
683
- case JSOP_DUP2: return ID2SYM(rb_intern("jsop_dup2"));
684
-
685
- case JSOP_SETCONST: return ID2SYM(rb_intern("jsop_setconst"));
686
-
687
- case JSOP_BITOR: return ID2SYM(rb_intern("jsop_bitor"));
688
-
689
- case JSOP_BITXOR: return ID2SYM(rb_intern("jsop_bitxor"));
690
-
691
- case JSOP_BITAND: return ID2SYM(rb_intern("jsop_bitand"));
692
-
693
- case JSOP_EQ: return ID2SYM(rb_intern("jsop_eq"));
694
-
695
- case JSOP_NE: return ID2SYM(rb_intern("jsop_ne"));
696
-
697
- case JSOP_LT: return ID2SYM(rb_intern("jsop_lt"));
698
-
699
- case JSOP_LE: return ID2SYM(rb_intern("jsop_le"));
700
-
701
- case JSOP_GT: return ID2SYM(rb_intern("jsop_gt"));
702
-
703
- case JSOP_GE: return ID2SYM(rb_intern("jsop_ge"));
704
-
705
- case JSOP_LSH: return ID2SYM(rb_intern("jsop_lsh"));
706
-
707
- case JSOP_RSH: return ID2SYM(rb_intern("jsop_rsh"));
708
-
709
- case JSOP_URSH: return ID2SYM(rb_intern("jsop_ursh"));
710
-
711
- case JSOP_ADD: return ID2SYM(rb_intern("jsop_add"));
712
-
713
- case JSOP_SUB: return ID2SYM(rb_intern("jsop_sub"));
714
-
715
- case JSOP_MUL: return ID2SYM(rb_intern("jsop_mul"));
716
-
717
- case JSOP_DIV: return ID2SYM(rb_intern("jsop_div"));
718
-
719
- case JSOP_MOD: return ID2SYM(rb_intern("jsop_mod"));
720
-
721
- case JSOP_NOT: return ID2SYM(rb_intern("jsop_not"));
722
-
723
- case JSOP_BITNOT: return ID2SYM(rb_intern("jsop_bitnot"));
724
-
725
- case JSOP_NEG: return ID2SYM(rb_intern("jsop_neg"));
726
-
727
- case JSOP_NEW: return ID2SYM(rb_intern("jsop_new"));
728
-
729
- case JSOP_DELNAME: return ID2SYM(rb_intern("jsop_delname"));
730
-
731
- case JSOP_DELPROP: return ID2SYM(rb_intern("jsop_delprop"));
732
-
733
- case JSOP_DELELEM: return ID2SYM(rb_intern("jsop_delelem"));
734
-
735
- case JSOP_TYPEOF: return ID2SYM(rb_intern("jsop_typeof"));
736
-
737
- case JSOP_VOID: return ID2SYM(rb_intern("jsop_void"));
738
-
739
- case JSOP_INCNAME: return ID2SYM(rb_intern("jsop_incname"));
740
-
741
- case JSOP_INCPROP: return ID2SYM(rb_intern("jsop_incprop"));
742
-
743
- case JSOP_INCELEM: return ID2SYM(rb_intern("jsop_incelem"));
744
-
745
- case JSOP_DECNAME: return ID2SYM(rb_intern("jsop_decname"));
746
-
747
- case JSOP_DECPROP: return ID2SYM(rb_intern("jsop_decprop"));
748
-
749
- case JSOP_DECELEM: return ID2SYM(rb_intern("jsop_decelem"));
750
-
751
- case JSOP_NAMEINC: return ID2SYM(rb_intern("jsop_nameinc"));
752
-
753
- case JSOP_PROPINC: return ID2SYM(rb_intern("jsop_propinc"));
754
-
755
- case JSOP_ELEMINC: return ID2SYM(rb_intern("jsop_eleminc"));
756
-
757
- case JSOP_NAMEDEC: return ID2SYM(rb_intern("jsop_namedec"));
758
-
759
- case JSOP_PROPDEC: return ID2SYM(rb_intern("jsop_propdec"));
760
-
761
- case JSOP_ELEMDEC: return ID2SYM(rb_intern("jsop_elemdec"));
762
-
763
- case JSOP_GETPROP: return ID2SYM(rb_intern("jsop_getprop"));
764
-
765
- case JSOP_SETPROP: return ID2SYM(rb_intern("jsop_setprop"));
766
-
767
- case JSOP_GETELEM: return ID2SYM(rb_intern("jsop_getelem"));
768
-
769
- case JSOP_SETELEM: return ID2SYM(rb_intern("jsop_setelem"));
770
-
771
- case JSOP_CALLNAME: return ID2SYM(rb_intern("jsop_callname"));
772
-
773
- case JSOP_CALL: return ID2SYM(rb_intern("jsop_call"));
774
-
775
- case JSOP_NAME: return ID2SYM(rb_intern("jsop_name"));
776
-
777
- case JSOP_DOUBLE: return ID2SYM(rb_intern("jsop_double"));
778
-
779
- case JSOP_STRING: return ID2SYM(rb_intern("jsop_string"));
780
-
781
- case JSOP_ZERO: return ID2SYM(rb_intern("jsop_zero"));
782
-
783
- case JSOP_ONE: return ID2SYM(rb_intern("jsop_one"));
784
-
785
- case JSOP_NULL: return ID2SYM(rb_intern("jsop_null"));
786
-
787
- case JSOP_THIS: return ID2SYM(rb_intern("jsop_this"));
788
-
789
- case JSOP_FALSE: return ID2SYM(rb_intern("jsop_false"));
790
-
791
- case JSOP_TRUE: return ID2SYM(rb_intern("jsop_true"));
792
-
793
- case JSOP_OR: return ID2SYM(rb_intern("jsop_or"));
794
-
795
- case JSOP_AND: return ID2SYM(rb_intern("jsop_and"));
796
-
797
- case JSOP_TABLESWITCH: return ID2SYM(rb_intern("jsop_tableswitch"));
798
-
799
- case JSOP_LOOKUPSWITCH: return ID2SYM(rb_intern("jsop_lookupswitch"));
800
-
801
- case JSOP_STRICTEQ: return ID2SYM(rb_intern("jsop_stricteq"));
802
-
803
- case JSOP_STRICTNE: return ID2SYM(rb_intern("jsop_strictne"));
804
-
805
- case JSOP_CLOSURE: return ID2SYM(rb_intern("jsop_closure"));
806
-
807
- case JSOP_EXPORTALL: return ID2SYM(rb_intern("jsop_exportall"));
808
-
809
- case JSOP_EXPORTNAME: return ID2SYM(rb_intern("jsop_exportname"));
810
-
811
- case JSOP_IMPORTALL: return ID2SYM(rb_intern("jsop_importall"));
812
-
813
- case JSOP_IMPORTPROP: return ID2SYM(rb_intern("jsop_importprop"));
814
-
815
- case JSOP_IMPORTELEM: return ID2SYM(rb_intern("jsop_importelem"));
816
-
817
- case JSOP_OBJECT: return ID2SYM(rb_intern("jsop_object"));
818
-
819
- case JSOP_POP: return ID2SYM(rb_intern("jsop_pop"));
820
-
821
- case JSOP_POS: return ID2SYM(rb_intern("jsop_pos"));
822
-
823
- case JSOP_TRAP: return ID2SYM(rb_intern("jsop_trap"));
824
-
825
- case JSOP_GETARG: return ID2SYM(rb_intern("jsop_getarg"));
826
-
827
- case JSOP_SETARG: return ID2SYM(rb_intern("jsop_setarg"));
828
-
829
- case JSOP_GETVAR: return ID2SYM(rb_intern("jsop_getvar"));
830
-
831
- case JSOP_SETVAR: return ID2SYM(rb_intern("jsop_setvar"));
832
-
833
- case JSOP_UINT16: return ID2SYM(rb_intern("jsop_uint16"));
834
-
835
- case JSOP_NEWINIT: return ID2SYM(rb_intern("jsop_newinit"));
836
-
837
- case JSOP_ENDINIT: return ID2SYM(rb_intern("jsop_endinit"));
838
-
839
- case JSOP_INITPROP: return ID2SYM(rb_intern("jsop_initprop"));
840
-
841
- case JSOP_INITELEM: return ID2SYM(rb_intern("jsop_initelem"));
842
-
843
- case JSOP_DEFSHARP: return ID2SYM(rb_intern("jsop_defsharp"));
844
-
845
- case JSOP_USESHARP: return ID2SYM(rb_intern("jsop_usesharp"));
846
-
847
- case JSOP_INCARG: return ID2SYM(rb_intern("jsop_incarg"));
848
-
849
- case JSOP_INCVAR: return ID2SYM(rb_intern("jsop_incvar"));
850
-
851
- case JSOP_DECARG: return ID2SYM(rb_intern("jsop_decarg"));
852
-
853
- case JSOP_DECVAR: return ID2SYM(rb_intern("jsop_decvar"));
854
-
855
- case JSOP_ARGINC: return ID2SYM(rb_intern("jsop_arginc"));
856
-
857
- case JSOP_VARINC: return ID2SYM(rb_intern("jsop_varinc"));
858
-
859
- case JSOP_ARGDEC: return ID2SYM(rb_intern("jsop_argdec"));
860
-
861
- case JSOP_VARDEC: return ID2SYM(rb_intern("jsop_vardec"));
862
-
863
- case JSOP_FORIN: return ID2SYM(rb_intern("jsop_forin"));
864
-
865
- case JSOP_FORNAME: return ID2SYM(rb_intern("jsop_forname"));
866
-
867
- case JSOP_FORPROP: return ID2SYM(rb_intern("jsop_forprop"));
868
-
869
- case JSOP_FORELEM: return ID2SYM(rb_intern("jsop_forelem"));
870
-
871
- case JSOP_POPN: return ID2SYM(rb_intern("jsop_popn"));
872
-
873
- case JSOP_BINDNAME: return ID2SYM(rb_intern("jsop_bindname"));
874
-
875
- case JSOP_SETNAME: return ID2SYM(rb_intern("jsop_setname"));
876
-
877
- case JSOP_THROW: return ID2SYM(rb_intern("jsop_throw"));
878
-
879
- case JSOP_IN: return ID2SYM(rb_intern("jsop_in"));
880
-
881
- case JSOP_INSTANCEOF: return ID2SYM(rb_intern("jsop_instanceof"));
882
-
883
- case JSOP_DEBUGGER: return ID2SYM(rb_intern("jsop_debugger"));
884
-
885
- case JSOP_GOSUB: return ID2SYM(rb_intern("jsop_gosub"));
886
-
887
- case JSOP_RETSUB: return ID2SYM(rb_intern("jsop_retsub"));
888
-
889
- case JSOP_EXCEPTION: return ID2SYM(rb_intern("jsop_exception"));
890
-
891
- case JSOP_LINENO: return ID2SYM(rb_intern("jsop_lineno"));
892
-
893
- case JSOP_CONDSWITCH: return ID2SYM(rb_intern("jsop_condswitch"));
894
-
895
- case JSOP_CASE: return ID2SYM(rb_intern("jsop_case"));
896
-
897
- case JSOP_DEFAULT: return ID2SYM(rb_intern("jsop_default"));
898
-
899
- case JSOP_EVAL: return ID2SYM(rb_intern("jsop_eval"));
900
-
901
- case JSOP_ENUMELEM: return ID2SYM(rb_intern("jsop_enumelem"));
902
-
903
- case JSOP_GETTER: return ID2SYM(rb_intern("jsop_getter"));
904
-
905
- case JSOP_SETTER: return ID2SYM(rb_intern("jsop_setter"));
906
-
907
- case JSOP_DEFFUN: return ID2SYM(rb_intern("jsop_deffun"));
908
-
909
- case JSOP_DEFCONST: return ID2SYM(rb_intern("jsop_defconst"));
910
-
911
- case JSOP_DEFVAR: return ID2SYM(rb_intern("jsop_defvar"));
912
-
913
- case JSOP_ANONFUNOBJ: return ID2SYM(rb_intern("jsop_anonfunobj"));
914
-
915
- case JSOP_NAMEDFUNOBJ: return ID2SYM(rb_intern("jsop_namedfunobj"));
916
-
917
- case JSOP_SETLOCALPOP: return ID2SYM(rb_intern("jsop_setlocalpop"));
918
-
919
- case JSOP_GROUP: return ID2SYM(rb_intern("jsop_group"));
920
-
921
- case JSOP_SETCALL: return ID2SYM(rb_intern("jsop_setcall"));
922
-
923
- case JSOP_TRY: return ID2SYM(rb_intern("jsop_try"));
924
-
925
- case JSOP_FINALLY: return ID2SYM(rb_intern("jsop_finally"));
926
-
927
- case JSOP_SWAP: return ID2SYM(rb_intern("jsop_swap"));
928
-
929
- case JSOP_ARGSUB: return ID2SYM(rb_intern("jsop_argsub"));
930
-
931
- case JSOP_ARGCNT: return ID2SYM(rb_intern("jsop_argcnt"));
932
-
933
- case JSOP_DEFLOCALFUN: return ID2SYM(rb_intern("jsop_deflocalfun"));
934
-
935
- case JSOP_GOTOX: return ID2SYM(rb_intern("jsop_gotox"));
936
-
937
- case JSOP_IFEQX: return ID2SYM(rb_intern("jsop_ifeqx"));
938
-
939
- case JSOP_IFNEX: return ID2SYM(rb_intern("jsop_ifnex"));
940
-
941
- case JSOP_ORX: return ID2SYM(rb_intern("jsop_orx"));
942
-
943
- case JSOP_ANDX: return ID2SYM(rb_intern("jsop_andx"));
944
-
945
- case JSOP_GOSUBX: return ID2SYM(rb_intern("jsop_gosubx"));
946
-
947
- case JSOP_CASEX: return ID2SYM(rb_intern("jsop_casex"));
948
-
949
- case JSOP_DEFAULTX: return ID2SYM(rb_intern("jsop_defaultx"));
950
-
951
- case JSOP_TABLESWITCHX: return ID2SYM(rb_intern("jsop_tableswitchx"));
952
-
953
- case JSOP_LOOKUPSWITCHX: return ID2SYM(rb_intern("jsop_lookupswitchx"));
954
-
955
- case JSOP_BACKPATCH: return ID2SYM(rb_intern("jsop_backpatch"));
956
-
957
- case JSOP_BACKPATCH_POP: return ID2SYM(rb_intern("jsop_backpatch_pop"));
958
-
959
- case JSOP_THROWING: return ID2SYM(rb_intern("jsop_throwing"));
960
-
961
- case JSOP_SETRVAL: return ID2SYM(rb_intern("jsop_setrval"));
962
-
963
- case JSOP_RETRVAL: return ID2SYM(rb_intern("jsop_retrval"));
964
-
965
- case JSOP_GETGVAR: return ID2SYM(rb_intern("jsop_getgvar"));
966
-
967
- case JSOP_SETGVAR: return ID2SYM(rb_intern("jsop_setgvar"));
968
-
969
- case JSOP_INCGVAR: return ID2SYM(rb_intern("jsop_incgvar"));
970
-
971
- case JSOP_DECGVAR: return ID2SYM(rb_intern("jsop_decgvar"));
972
-
973
- case JSOP_GVARINC: return ID2SYM(rb_intern("jsop_gvarinc"));
974
-
975
- case JSOP_GVARDEC: return ID2SYM(rb_intern("jsop_gvardec"));
976
-
977
- case JSOP_REGEXP: return ID2SYM(rb_intern("jsop_regexp"));
978
-
979
- case JSOP_DEFXMLNS: return ID2SYM(rb_intern("jsop_defxmlns"));
980
-
981
- case JSOP_ANYNAME: return ID2SYM(rb_intern("jsop_anyname"));
982
-
983
- case JSOP_QNAMEPART: return ID2SYM(rb_intern("jsop_qnamepart"));
984
-
985
- case JSOP_QNAMECONST: return ID2SYM(rb_intern("jsop_qnameconst"));
986
-
987
- case JSOP_QNAME: return ID2SYM(rb_intern("jsop_qname"));
988
-
989
- case JSOP_TOATTRNAME: return ID2SYM(rb_intern("jsop_toattrname"));
990
-
991
- case JSOP_TOATTRVAL: return ID2SYM(rb_intern("jsop_toattrval"));
992
-
993
- case JSOP_ADDATTRNAME: return ID2SYM(rb_intern("jsop_addattrname"));
994
-
995
- case JSOP_ADDATTRVAL: return ID2SYM(rb_intern("jsop_addattrval"));
996
-
997
- case JSOP_BINDXMLNAME: return ID2SYM(rb_intern("jsop_bindxmlname"));
998
-
999
- case JSOP_SETXMLNAME: return ID2SYM(rb_intern("jsop_setxmlname"));
1000
-
1001
- case JSOP_XMLNAME: return ID2SYM(rb_intern("jsop_xmlname"));
1002
-
1003
- case JSOP_DESCENDANTS: return ID2SYM(rb_intern("jsop_descendants"));
1004
-
1005
- case JSOP_FILTER: return ID2SYM(rb_intern("jsop_filter"));
1006
-
1007
- case JSOP_ENDFILTER: return ID2SYM(rb_intern("jsop_endfilter"));
1008
-
1009
- case JSOP_TOXML: return ID2SYM(rb_intern("jsop_toxml"));
1010
-
1011
- case JSOP_TOXMLLIST: return ID2SYM(rb_intern("jsop_toxmllist"));
1012
-
1013
- case JSOP_XMLTAGEXPR: return ID2SYM(rb_intern("jsop_xmltagexpr"));
1014
-
1015
- case JSOP_XMLELTEXPR: return ID2SYM(rb_intern("jsop_xmleltexpr"));
1016
-
1017
- case JSOP_XMLOBJECT: return ID2SYM(rb_intern("jsop_xmlobject"));
1018
-
1019
- case JSOP_XMLCDATA: return ID2SYM(rb_intern("jsop_xmlcdata"));
1020
-
1021
- case JSOP_XMLCOMMENT: return ID2SYM(rb_intern("jsop_xmlcomment"));
1022
-
1023
- case JSOP_XMLPI: return ID2SYM(rb_intern("jsop_xmlpi"));
1024
-
1025
- case JSOP_CALLPROP: return ID2SYM(rb_intern("jsop_callprop"));
1026
-
1027
- case JSOP_GETFUNNS: return ID2SYM(rb_intern("jsop_getfunns"));
1028
-
1029
- case JSOP_FOREACH: return ID2SYM(rb_intern("jsop_foreach"));
1030
-
1031
- case JSOP_DELDESC: return ID2SYM(rb_intern("jsop_deldesc"));
1032
-
1033
- case JSOP_UINT24: return ID2SYM(rb_intern("jsop_uint24"));
1034
-
1035
- case JSOP_INDEXBASE: return ID2SYM(rb_intern("jsop_indexbase"));
1036
-
1037
- case JSOP_RESETBASE: return ID2SYM(rb_intern("jsop_resetbase"));
1038
-
1039
- case JSOP_RESETBASE0: return ID2SYM(rb_intern("jsop_resetbase0"));
1040
-
1041
- case JSOP_STARTXML: return ID2SYM(rb_intern("jsop_startxml"));
1042
-
1043
- case JSOP_STARTXMLEXPR: return ID2SYM(rb_intern("jsop_startxmlexpr"));
1044
-
1045
- case JSOP_CALLELEM: return ID2SYM(rb_intern("jsop_callelem"));
1046
-
1047
- case JSOP_STOP: return ID2SYM(rb_intern("jsop_stop"));
1048
-
1049
- case JSOP_GETXPROP: return ID2SYM(rb_intern("jsop_getxprop"));
1050
-
1051
- case JSOP_CALLXMLNAME: return ID2SYM(rb_intern("jsop_callxmlname"));
1052
-
1053
- case JSOP_TYPEOFEXPR: return ID2SYM(rb_intern("jsop_typeofexpr"));
1054
-
1055
- case JSOP_ENTERBLOCK: return ID2SYM(rb_intern("jsop_enterblock"));
1056
-
1057
- case JSOP_LEAVEBLOCK: return ID2SYM(rb_intern("jsop_leaveblock"));
1058
-
1059
- case JSOP_GETLOCAL: return ID2SYM(rb_intern("jsop_getlocal"));
1060
-
1061
- case JSOP_SETLOCAL: return ID2SYM(rb_intern("jsop_setlocal"));
1062
-
1063
- case JSOP_INCLOCAL: return ID2SYM(rb_intern("jsop_inclocal"));
1064
-
1065
- case JSOP_DECLOCAL: return ID2SYM(rb_intern("jsop_declocal"));
1066
-
1067
- case JSOP_LOCALINC: return ID2SYM(rb_intern("jsop_localinc"));
1068
-
1069
- case JSOP_LOCALDEC: return ID2SYM(rb_intern("jsop_localdec"));
1070
-
1071
- case JSOP_FORLOCAL: return ID2SYM(rb_intern("jsop_forlocal"));
1072
-
1073
- case JSOP_FORCONST: return ID2SYM(rb_intern("jsop_forconst"));
1074
-
1075
- case JSOP_ENDITER: return ID2SYM(rb_intern("jsop_enditer"));
1076
-
1077
- case JSOP_GENERATOR: return ID2SYM(rb_intern("jsop_generator"));
1078
-
1079
- case JSOP_YIELD: return ID2SYM(rb_intern("jsop_yield"));
1080
-
1081
- case JSOP_ARRAYPUSH: return ID2SYM(rb_intern("jsop_arraypush"));
1082
-
1083
- case JSOP_FOREACHKEYVAL: return ID2SYM(rb_intern("jsop_foreachkeyval"));
1084
-
1085
- case JSOP_ENUMCONSTELEM: return ID2SYM(rb_intern("jsop_enumconstelem"));
1086
-
1087
- case JSOP_LEAVEBLOCKEXPR: return ID2SYM(rb_intern("jsop_leaveblockexpr"));
1088
-
1089
- case JSOP_GETTHISPROP: return ID2SYM(rb_intern("jsop_getthisprop"));
1090
-
1091
- case JSOP_GETARGPROP: return ID2SYM(rb_intern("jsop_getargprop"));
1092
-
1093
- case JSOP_GETVARPROP: return ID2SYM(rb_intern("jsop_getvarprop"));
1094
-
1095
- case JSOP_GETLOCALPROP: return ID2SYM(rb_intern("jsop_getlocalprop"));
1096
-
1097
- case JSOP_INDEXBASE1: return ID2SYM(rb_intern("jsop_indexbase1"));
1098
-
1099
- case JSOP_INDEXBASE2: return ID2SYM(rb_intern("jsop_indexbase2"));
1100
-
1101
- case JSOP_INDEXBASE3: return ID2SYM(rb_intern("jsop_indexbase3"));
1102
-
1103
- case JSOP_CALLGVAR: return ID2SYM(rb_intern("jsop_callgvar"));
1104
-
1105
- case JSOP_CALLVAR: return ID2SYM(rb_intern("jsop_callvar"));
1106
-
1107
- case JSOP_CALLARG: return ID2SYM(rb_intern("jsop_callarg"));
1108
-
1109
- case JSOP_CALLLOCAL: return ID2SYM(rb_intern("jsop_calllocal"));
1110
-
1111
- case JSOP_INT8: return ID2SYM(rb_intern("jsop_int8"));
1112
-
1113
- case JSOP_INT32: return ID2SYM(rb_intern("jsop_int32"));
1114
-
1115
- case JSOP_LENGTH: return ID2SYM(rb_intern("jsop_length"));
1116
-
1117
- }
1118
- return UINT2NUM((unsigned long)(jsop));
1119
- }
1120
-
1121
- void init_Johnson_SpiderMonkey_Immutable_Node(VALUE spidermonkey)
1122
- {
1123
- /* HACK: These comments are *only* to make RDoc happy.
1124
- VALUE johnson = rb_define_module("Johnson");
1125
- VALUE spidermonkey = rb_define_module_under(johnson, "SpiderMonkey");
1126
- */
1127
-
1128
- /* ImmutableNode class. */
1129
- cNode = rb_define_class_under(spidermonkey, "ImmutableNode", rb_cObject);
1130
-
1131
- rb_define_alloc_func(cNode, allocate);
1132
- rb_define_singleton_method(cNode, "parse_io", parse_io, -1);
1133
- rb_define_method(cNode, "line", line, 0);
1134
- rb_define_method(cNode, "index", begin_index, 0);
1135
- rb_define_method(cNode, "pn_arity", pn_arity, 0);
1136
- rb_define_method(cNode, "pn_type", pn_type, 0);
1137
- rb_define_method(cNode, "pn_expr", data_pn_expr, 0);
1138
- rb_define_method(cNode, "pn_kid", data_pn_kid, 0);
1139
- rb_define_method(cNode, "pn_kid1", data_pn_kid1, 0);
1140
- rb_define_method(cNode, "pn_kid2", data_pn_kid2, 0);
1141
- rb_define_method(cNode, "pn_kid3", data_pn_kid3, 0);
1142
- rb_define_method(cNode, "pn_dval", data_pn_dval, 0);
1143
- rb_define_method(cNode, "pn_op", data_pn_op, 0);
1144
- rb_define_method(cNode, "pn_left", data_pn_left, 0);
1145
- rb_define_method(cNode, "pn_extra", data_pn_extra, 0);
1146
- rb_define_method(cNode, "name", name, 0);
1147
- rb_define_method(cNode, "regexp", regexp, 0);
1148
- rb_define_method(cNode, "function_name", function_name, 0);
1149
- rb_define_method(cNode, "function_args", function_args, 0);
1150
- rb_define_method(cNode, "function_body", function_body, 0);
1151
- rb_define_method(cNode, "pn_right", data_pn_right, 0);
1152
- rb_define_method(cNode, "children", children, 0);
1153
- }