johnson 1.2.0 → 2.0.0.pre0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (782) hide show
  1. data/CHANGELOG.rdoc +8 -0
  2. data/Manifest.txt +762 -48
  3. data/README.rdoc +2 -1
  4. data/Rakefile +90 -18
  5. data/ext/spidermonkey/conversions.c +9 -2
  6. data/ext/spidermonkey/ruby_land_proxy.c +1 -1
  7. data/ext/spidermonkey/runtime.h +1 -1
  8. data/ext/tracemonkey/context.cc +125 -0
  9. data/ext/tracemonkey/context.h +19 -0
  10. data/ext/tracemonkey/conversions.cc +365 -0
  11. data/ext/tracemonkey/conversions.h +32 -0
  12. data/ext/tracemonkey/debugger.cc +234 -0
  13. data/ext/tracemonkey/debugger.h +10 -0
  14. data/ext/tracemonkey/extconf.rb +37 -0
  15. data/ext/tracemonkey/extensions.cc +37 -0
  16. data/ext/tracemonkey/extensions.h +12 -0
  17. data/ext/tracemonkey/global.cc +40 -0
  18. data/ext/tracemonkey/global.h +11 -0
  19. data/ext/tracemonkey/idhash.cc +16 -0
  20. data/ext/tracemonkey/idhash.h +8 -0
  21. data/ext/tracemonkey/immutable_node.cc +1199 -0
  22. data/ext/tracemonkey/immutable_node.cc.erb +559 -0
  23. data/ext/tracemonkey/immutable_node.h +22 -0
  24. data/ext/tracemonkey/jroot.h +215 -0
  25. data/ext/tracemonkey/js_land_proxy.cc +620 -0
  26. data/ext/tracemonkey/js_land_proxy.h +20 -0
  27. data/ext/tracemonkey/ruby_land_proxy.cc +618 -0
  28. data/ext/tracemonkey/ruby_land_proxy.h +38 -0
  29. data/ext/tracemonkey/runtime.cc +454 -0
  30. data/ext/tracemonkey/runtime.h +27 -0
  31. data/ext/tracemonkey/split_global.cc +392 -0
  32. data/ext/tracemonkey/split_global.h +11 -0
  33. data/ext/tracemonkey/tracemonkey.cc +23 -0
  34. data/ext/tracemonkey/tracemonkey.h +32 -0
  35. data/lib/johnson.rb +12 -4
  36. data/lib/johnson/error.rb +5 -0
  37. data/lib/johnson/js/prelude.js +16 -1
  38. data/lib/johnson/parser.rb +2 -1
  39. data/lib/johnson/runtime.rb +87 -26
  40. data/lib/johnson/spidermonkey/runtime.rb +7 -16
  41. data/lib/johnson/tracemonkey.rb +13 -0
  42. data/lib/johnson/tracemonkey/context.rb +10 -0
  43. data/lib/johnson/tracemonkey/debugger.rb +67 -0
  44. data/lib/johnson/tracemonkey/immutable_node.rb +282 -0
  45. data/lib/johnson/tracemonkey/js_land_proxy.rb +64 -0
  46. data/lib/johnson/tracemonkey/mutable_tree_visitor.rb +242 -0
  47. data/lib/johnson/tracemonkey/ruby_land_proxy.rb +17 -0
  48. data/lib/johnson/tracemonkey/runtime.rb +80 -0
  49. data/test/{johnson_test.rb → generic/johnson_test.rb} +1 -1
  50. data/test/{parser_test.rb → generic/parser_test.rb} +1 -1
  51. data/test/helper.rb +23 -4
  52. data/test/johnson/{browser_test.rb → generic/browser_test.rb} +1 -1
  53. data/test/johnson/{conversions → generic/conversions}/array_test.rb +1 -1
  54. data/test/johnson/{conversions → generic/conversions}/boolean_test.rb +1 -1
  55. data/test/johnson/{conversions → generic/conversions}/callable_test.rb +1 -1
  56. data/test/johnson/{conversions → generic/conversions}/file_test.rb +1 -1
  57. data/test/johnson/generic/conversions/helper.rb +1 -0
  58. data/test/johnson/{conversions → generic/conversions}/nil_test.rb +1 -1
  59. data/test/johnson/{conversions → generic/conversions}/number_test.rb +1 -1
  60. data/test/johnson/{conversions → generic/conversions}/regexp_test.rb +1 -1
  61. data/test/johnson/{conversions → generic/conversions}/string_test.rb +1 -1
  62. data/test/johnson/{conversions → generic/conversions}/struct_test.rb +1 -1
  63. data/test/johnson/{conversions → generic/conversions}/symbol_test.rb +1 -1
  64. data/test/johnson/{conversions → generic/conversions}/thread_test.rb +1 -1
  65. data/test/johnson/{custom_conversions_test.rb → generic/custom_conversions_test.rb} +1 -1
  66. data/test/johnson/generic/default_test.rb +12 -0
  67. data/test/johnson/{error_test.rb → generic/error_test.rb} +1 -1
  68. data/test/johnson/{extensions_test.rb → generic/extensions_test.rb} +1 -1
  69. data/test/johnson/generic/helper.rb +1 -0
  70. data/test/johnson/{nodes → generic/nodes}/array_literal_test.rb +1 -1
  71. data/test/johnson/{nodes → generic/nodes}/array_node_test.rb +1 -1
  72. data/test/johnson/{nodes → generic/nodes}/binary_node_test.rb +1 -1
  73. data/test/johnson/{nodes → generic/nodes}/bracket_access_test.rb +1 -1
  74. data/test/johnson/{nodes → generic/nodes}/delete_test.rb +1 -1
  75. data/test/johnson/{nodes → generic/nodes}/do_while_test.rb +1 -1
  76. data/test/johnson/{nodes → generic/nodes}/dot_accessor_test.rb +1 -1
  77. data/test/johnson/generic/nodes/export_test.rb +11 -0
  78. data/test/johnson/{nodes → generic/nodes}/for_test.rb +1 -1
  79. data/test/johnson/{nodes → generic/nodes}/function_test.rb +1 -1
  80. data/test/johnson/generic/nodes/helper.rb +1 -0
  81. data/test/johnson/{nodes → generic/nodes}/if_test.rb +16 -6
  82. data/test/johnson/generic/nodes/import_test.rb +15 -0
  83. data/test/johnson/{nodes → generic/nodes}/label_test.rb +1 -1
  84. data/test/johnson/{nodes → generic/nodes}/let_test.rb +1 -1
  85. data/test/johnson/{nodes → generic/nodes}/object_literal_test.rb +1 -1
  86. data/test/johnson/{nodes → generic/nodes}/return_test.rb +1 -1
  87. data/test/johnson/{nodes → generic/nodes}/semi_test.rb +1 -1
  88. data/test/johnson/{nodes → generic/nodes}/switch_test.rb +1 -1
  89. data/test/johnson/{nodes → generic/nodes}/ternary_test.rb +1 -1
  90. data/test/johnson/{nodes → generic/nodes}/throw_test.rb +1 -1
  91. data/test/johnson/{nodes → generic/nodes}/try_node_test.rb +36 -6
  92. data/test/johnson/{nodes → generic/nodes}/typeof_test.rb +1 -1
  93. data/test/johnson/{nodes → generic/nodes}/unary_node_test.rb +1 -1
  94. data/test/johnson/{nodes → generic/nodes}/void_test.rb +1 -1
  95. data/test/johnson/{nodes → generic/nodes}/while_test.rb +1 -1
  96. data/test/johnson/{nodes → generic/nodes}/with_test.rb +1 -1
  97. data/test/johnson/{prelude_test.rb → generic/prelude_test.rb} +1 -1
  98. data/test/johnson/{runtime_test.rb → generic/runtime_test.rb} +3 -6
  99. data/test/johnson/generic/version_test.rb +13 -0
  100. data/test/johnson/{visitors → generic/visitors}/dot_visitor_test.rb +1 -1
  101. data/test/johnson/{visitors → generic/visitors}/enumerating_visitor_test.rb +1 -1
  102. data/test/johnson/generic/visitors/helper.rb +1 -0
  103. data/test/johnson/spidermonkey/js_land_proxy_test.rb +1 -5
  104. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +11 -7
  105. data/test/johnson/tracemonkey/context_test.rb +21 -0
  106. data/test/johnson/tracemonkey/immutable_node_test.rb +34 -0
  107. data/test/johnson/tracemonkey/js_land_proxy_test.rb +273 -0
  108. data/test/johnson/tracemonkey/ruby_land_proxy_test.rb +274 -0
  109. data/test/johnson/tracemonkey/runtime_test.rb +41 -0
  110. data/test/johnson/tracemonkey/split_global_test.rb +32 -0
  111. data/vendor/spidermonkey/js.pkg +2 -0
  112. data/vendor/tracemonkey/Makefile.in +668 -0
  113. data/vendor/tracemonkey/Makefile.ref +483 -0
  114. data/vendor/tracemonkey/README.html +54 -0
  115. data/vendor/tracemonkey/SpiderMonkey.rsp +11 -0
  116. data/vendor/tracemonkey/Y.js +19 -0
  117. data/vendor/tracemonkey/aclocal.m4 +9 -0
  118. data/vendor/tracemonkey/bench.sh +5 -0
  119. data/vendor/tracemonkey/build/autoconf/acoutput-fast.pl +202 -0
  120. data/vendor/tracemonkey/build/autoconf/altoptions.m4 +154 -0
  121. data/vendor/tracemonkey/build/autoconf/config.guess +1537 -0
  122. data/vendor/tracemonkey/build/autoconf/config.sub +1595 -0
  123. data/vendor/tracemonkey/build/autoconf/install-sh +119 -0
  124. data/vendor/tracemonkey/build/autoconf/make-makefile +315 -0
  125. data/vendor/tracemonkey/build/autoconf/match-dir.sh +101 -0
  126. data/vendor/tracemonkey/build/autoconf/moznbytetype.m4 +136 -0
  127. data/vendor/tracemonkey/build/autoconf/nspr.m4 +82 -0
  128. data/vendor/tracemonkey/build/autoconf/pkg.m4 +59 -0
  129. data/vendor/tracemonkey/build/autoconf/update-makefile.sh +118 -0
  130. data/vendor/tracemonkey/build/cygwin-wrapper +75 -0
  131. data/vendor/tracemonkey/build/hcc +111 -0
  132. data/vendor/tracemonkey/build/hcpp +155 -0
  133. data/vendor/tracemonkey/build/unix/mddepend.pl +165 -0
  134. data/vendor/tracemonkey/build/unix/uniq.pl +63 -0
  135. data/vendor/tracemonkey/build/win32/pgomerge.py +40 -0
  136. data/vendor/tracemonkey/builtins.tbl +91 -0
  137. data/vendor/tracemonkey/call.js +13 -0
  138. data/vendor/tracemonkey/config.mk +206 -0
  139. data/vendor/tracemonkey/config/Makefile.in +106 -0
  140. data/vendor/tracemonkey/config/Moz/Milestone.pm +232 -0
  141. data/vendor/tracemonkey/config/autoconf.mk.in +362 -0
  142. data/vendor/tracemonkey/config/check-sync-dirs.py +103 -0
  143. data/vendor/tracemonkey/config/check-sync-exceptions +7 -0
  144. data/vendor/tracemonkey/config/config.mk +881 -0
  145. data/vendor/tracemonkey/config/fastcwd.pl +66 -0
  146. data/vendor/tracemonkey/config/gcc_hidden.h +2 -0
  147. data/vendor/tracemonkey/config/insure.mk +53 -0
  148. data/vendor/tracemonkey/config/make-system-wrappers.pl +59 -0
  149. data/vendor/tracemonkey/config/milestone.pl +112 -0
  150. data/vendor/tracemonkey/config/milestone.txt +13 -0
  151. data/vendor/tracemonkey/config/mkdepend/Makefile.in +84 -0
  152. data/vendor/tracemonkey/config/mkdepend/cppsetup.c +233 -0
  153. data/vendor/tracemonkey/config/mkdepend/def.h +184 -0
  154. data/vendor/tracemonkey/config/mkdepend/ifparser.c +551 -0
  155. data/vendor/tracemonkey/config/mkdepend/ifparser.h +83 -0
  156. data/vendor/tracemonkey/config/mkdepend/imakemdep.h +733 -0
  157. data/vendor/tracemonkey/config/mkdepend/include.c +337 -0
  158. data/vendor/tracemonkey/config/mkdepend/main.c +860 -0
  159. data/vendor/tracemonkey/config/mkdepend/mkdepend.man +382 -0
  160. data/vendor/tracemonkey/config/mkdepend/parse.c +686 -0
  161. data/vendor/tracemonkey/config/mkdepend/pr.c +124 -0
  162. data/vendor/tracemonkey/config/nfspwd.pl +50 -0
  163. data/vendor/tracemonkey/config/nsinstall.c +481 -0
  164. data/vendor/tracemonkey/config/nsinstall.py +155 -0
  165. data/vendor/tracemonkey/config/pathsub.c +247 -0
  166. data/vendor/tracemonkey/config/pathsub.h +74 -0
  167. data/vendor/tracemonkey/config/preprocessor.pl +671 -0
  168. data/vendor/tracemonkey/config/revdepth-nt.pl +48 -0
  169. data/vendor/tracemonkey/config/revdepth.pl +51 -0
  170. data/vendor/tracemonkey/config/rules.mk +2310 -0
  171. data/vendor/tracemonkey/config/static-checking-config.mk +21 -0
  172. data/vendor/tracemonkey/config/static-checking.js +92 -0
  173. data/vendor/tracemonkey/config/string-format.js +61 -0
  174. data/vendor/tracemonkey/config/system-headers +1035 -0
  175. data/vendor/tracemonkey/config/version.mk +85 -0
  176. data/vendor/tracemonkey/config/version_win.pl +442 -0
  177. data/vendor/tracemonkey/configure +14183 -0
  178. data/vendor/tracemonkey/configure.in +5363 -0
  179. data/vendor/tracemonkey/correct.sh +23 -0
  180. data/vendor/tracemonkey/correct/check-3d-morph.js +55 -0
  181. data/vendor/tracemonkey/correct/check-3d-raytrace.js +445 -0
  182. data/vendor/tracemonkey/correct/check-access-binary-trees.js +52 -0
  183. data/vendor/tracemonkey/correct/check-access-fannkuch.js +66 -0
  184. data/vendor/tracemonkey/correct/check-access-nbody.js +171 -0
  185. data/vendor/tracemonkey/correct/check-access-nsieve.js +40 -0
  186. data/vendor/tracemonkey/correct/check-bitops-3bit-bits-in-byte.js +35 -0
  187. data/vendor/tracemonkey/correct/check-bitops-bits-in-byte.js +24 -0
  188. data/vendor/tracemonkey/correct/check-bitops-bitwise-and.js +29 -0
  189. data/vendor/tracemonkey/correct/check-bitops-nsieve-bits.js +40 -0
  190. data/vendor/tracemonkey/correct/check-controlflow-recursive.js +27 -0
  191. data/vendor/tracemonkey/correct/check-date-format-tofte.js +302 -0
  192. data/vendor/tracemonkey/correct/check-date-format-xparb.js +421 -0
  193. data/vendor/tracemonkey/correct/check-mont.js +119 -0
  194. data/vendor/tracemonkey/dtoa.c +3335 -0
  195. data/vendor/tracemonkey/editline/Makefile.in +55 -0
  196. data/vendor/tracemonkey/editline/Makefile.ref +143 -0
  197. data/vendor/tracemonkey/editline/README +83 -0
  198. data/vendor/tracemonkey/editline/editline.3 +175 -0
  199. data/vendor/tracemonkey/editline/editline.c +1371 -0
  200. data/vendor/tracemonkey/editline/editline.h +135 -0
  201. data/vendor/tracemonkey/editline/sysunix.c +182 -0
  202. data/vendor/tracemonkey/editline/unix.h +82 -0
  203. data/vendor/tracemonkey/if.js +13 -0
  204. data/vendor/tracemonkey/imacro_asm.js.in +396 -0
  205. data/vendor/tracemonkey/imacros.c.out +1034 -0
  206. data/vendor/tracemonkey/imacros.jsasm +770 -0
  207. data/vendor/tracemonkey/javascript-trace.d +73 -0
  208. data/vendor/tracemonkey/jitstats.tbl +55 -0
  209. data/vendor/tracemonkey/js-config.h.in +82 -0
  210. data/vendor/tracemonkey/js-config.in +111 -0
  211. data/vendor/tracemonkey/js.mdp +0 -0
  212. data/vendor/tracemonkey/js.msg +312 -0
  213. data/vendor/tracemonkey/js3240.rc +79 -0
  214. data/vendor/tracemonkey/jsOS240.def +654 -0
  215. data/vendor/tracemonkey/jsapi.cpp +6005 -0
  216. data/vendor/tracemonkey/jsapi.h +2727 -0
  217. data/vendor/tracemonkey/jsarena.cpp +450 -0
  218. data/vendor/tracemonkey/jsarena.h +318 -0
  219. data/vendor/tracemonkey/jsarray.cpp +3664 -0
  220. data/vendor/tracemonkey/jsarray.h +238 -0
  221. data/vendor/tracemonkey/jsatom.cpp +1244 -0
  222. data/vendor/tracemonkey/jsatom.h +493 -0
  223. data/vendor/tracemonkey/jsbit.h +249 -0
  224. data/vendor/tracemonkey/jsbool.cpp +184 -0
  225. data/vendor/tracemonkey/jsbool.h +88 -0
  226. data/vendor/tracemonkey/jsbuiltins.cpp +415 -0
  227. data/vendor/tracemonkey/jsbuiltins.h +456 -0
  228. data/vendor/tracemonkey/jsclist.h +139 -0
  229. data/vendor/tracemonkey/jscntxt.cpp +1816 -0
  230. data/vendor/tracemonkey/jscntxt.h +1541 -0
  231. data/vendor/tracemonkey/jscompat.h +57 -0
  232. data/vendor/tracemonkey/jsconfig.mk +181 -0
  233. data/vendor/tracemonkey/jscpucfg.cpp +194 -0
  234. data/vendor/tracemonkey/jscpucfg.h +91 -0
  235. data/vendor/tracemonkey/jsdate.cpp +2465 -0
  236. data/vendor/tracemonkey/jsdate.h +129 -0
  237. data/vendor/tracemonkey/jsdbgapi.cpp +2017 -0
  238. data/vendor/tracemonkey/jsdbgapi.h +500 -0
  239. data/vendor/tracemonkey/jsdhash.cpp +876 -0
  240. data/vendor/tracemonkey/jsdhash.h +588 -0
  241. data/vendor/tracemonkey/jsdtoa.cpp +572 -0
  242. data/vendor/tracemonkey/jsdtoa.h +131 -0
  243. data/vendor/tracemonkey/jsdtracef.c +318 -0
  244. data/vendor/tracemonkey/jsdtracef.h +81 -0
  245. data/vendor/tracemonkey/jsemit.cpp +7292 -0
  246. data/vendor/tracemonkey/jsemit.h +802 -0
  247. data/vendor/tracemonkey/jsexn.cpp +1337 -0
  248. data/vendor/tracemonkey/jsexn.h +96 -0
  249. data/vendor/tracemonkey/jsfile.cpp +2747 -0
  250. data/vendor/tracemonkey/jsfile.h +56 -0
  251. data/vendor/tracemonkey/jsfile.msg +90 -0
  252. data/vendor/tracemonkey/jsfun.cpp +3089 -0
  253. data/vendor/tracemonkey/jsfun.h +366 -0
  254. data/vendor/tracemonkey/jsgc.cpp +3816 -0
  255. data/vendor/tracemonkey/jsgc.h +429 -0
  256. data/vendor/tracemonkey/jshash.cpp +477 -0
  257. data/vendor/tracemonkey/jshash.h +151 -0
  258. data/vendor/tracemonkey/jsify.pl +483 -0
  259. data/vendor/tracemonkey/jsinterp.cpp +7441 -0
  260. data/vendor/tracemonkey/jsinterp.h +666 -0
  261. data/vendor/tracemonkey/jsinvoke.cpp +42 -0
  262. data/vendor/tracemonkey/jsiter.cpp +1040 -0
  263. data/vendor/tracemonkey/jsiter.h +140 -0
  264. data/vendor/tracemonkey/jskeyword.tbl +124 -0
  265. data/vendor/tracemonkey/jskwgen.cpp +460 -0
  266. data/vendor/tracemonkey/jslibmath.h +69 -0
  267. data/vendor/tracemonkey/jslock.cpp +1512 -0
  268. data/vendor/tracemonkey/jslock.h +325 -0
  269. data/vendor/tracemonkey/jslocko.asm +60 -0
  270. data/vendor/tracemonkey/jslog2.cpp +111 -0
  271. data/vendor/tracemonkey/jslong.h +167 -0
  272. data/vendor/tracemonkey/jsmath.cpp +806 -0
  273. data/vendor/tracemonkey/jsmath.h +63 -0
  274. data/vendor/tracemonkey/jsnum.cpp +1374 -0
  275. data/vendor/tracemonkey/jsnum.h +280 -0
  276. data/vendor/tracemonkey/jsobj.cpp +6165 -0
  277. data/vendor/tracemonkey/jsobj.h +870 -0
  278. data/vendor/tracemonkey/json.cpp +1338 -0
  279. data/vendor/tracemonkey/json.h +108 -0
  280. data/vendor/tracemonkey/jsopcode.cpp +5484 -0
  281. data/vendor/tracemonkey/jsopcode.h +434 -0
  282. data/vendor/tracemonkey/jsopcode.tbl +591 -0
  283. data/vendor/tracemonkey/jsoplengen.cpp +121 -0
  284. data/vendor/tracemonkey/jsotypes.h +202 -0
  285. data/vendor/tracemonkey/jsparse.cpp +9257 -0
  286. data/vendor/tracemonkey/jsparse.h +900 -0
  287. data/vendor/tracemonkey/jsprf.cpp +1262 -0
  288. data/vendor/tracemonkey/jsprf.h +150 -0
  289. data/vendor/tracemonkey/jsproto.tbl +117 -0
  290. data/vendor/tracemonkey/jsprvtd.h +366 -0
  291. data/vendor/tracemonkey/jspubtd.h +585 -0
  292. data/vendor/tracemonkey/jsregexp.cpp +5051 -0
  293. data/vendor/tracemonkey/jsregexp.h +199 -0
  294. data/vendor/tracemonkey/jsreops.tbl +145 -0
  295. data/vendor/tracemonkey/jsscan.cpp +2040 -0
  296. data/vendor/tracemonkey/jsscan.h +467 -0
  297. data/vendor/tracemonkey/jsscope.cpp +1966 -0
  298. data/vendor/tracemonkey/jsscope.h +487 -0
  299. data/vendor/tracemonkey/jsscript.cpp +1932 -0
  300. data/vendor/tracemonkey/jsscript.h +345 -0
  301. data/vendor/tracemonkey/jsshell.msg +54 -0
  302. data/vendor/tracemonkey/jsstack.js +167 -0
  303. data/vendor/tracemonkey/jsstaticcheck.h +69 -0
  304. data/vendor/tracemonkey/jsstddef.h +87 -0
  305. data/vendor/tracemonkey/jsstdint.h +96 -0
  306. data/vendor/tracemonkey/jsstr.cpp +5277 -0
  307. data/vendor/tracemonkey/jsstr.h +702 -0
  308. data/vendor/tracemonkey/jstracer.cpp +10991 -0
  309. data/vendor/tracemonkey/jstracer.h +794 -0
  310. data/vendor/tracemonkey/jstypes.h +481 -0
  311. data/vendor/tracemonkey/jsutil.cpp +361 -0
  312. data/vendor/tracemonkey/jsutil.h +178 -0
  313. data/vendor/tracemonkey/jsversion.h +243 -0
  314. data/vendor/tracemonkey/jswince.asm +44 -0
  315. data/vendor/tracemonkey/jsxdrapi.cpp +800 -0
  316. data/vendor/tracemonkey/jsxdrapi.h +220 -0
  317. data/vendor/tracemonkey/jsxml.cpp +8327 -0
  318. data/vendor/tracemonkey/jsxml.h +305 -0
  319. data/vendor/tracemonkey/liveconnect/LiveConnect.dsp +157 -0
  320. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsp +120 -0
  321. data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsw +44 -0
  322. data/vendor/tracemonkey/liveconnect/Makefile.in +105 -0
  323. data/vendor/tracemonkey/liveconnect/Makefile.ref +169 -0
  324. data/vendor/tracemonkey/liveconnect/README.html +712 -0
  325. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSException.h +14 -0
  326. data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSObject.h +155 -0
  327. data/vendor/tracemonkey/liveconnect/classes/Makefile.in +89 -0
  328. data/vendor/tracemonkey/liveconnect/classes/Makefile.ref +57 -0
  329. data/vendor/tracemonkey/liveconnect/classes/netscape/Makefile.ref +47 -0
  330. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSException.java +140 -0
  331. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSObject.java +183 -0
  332. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSProxy.java +58 -0
  333. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSRunnable.java +70 -0
  334. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSUtil.java +59 -0
  335. data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/Makefile.ref +53 -0
  336. data/vendor/tracemonkey/liveconnect/config/AIX4.1.mk +45 -0
  337. data/vendor/tracemonkey/liveconnect/config/AIX4.2.mk +45 -0
  338. data/vendor/tracemonkey/liveconnect/config/AIX4.3.mk +50 -0
  339. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.10.mk +43 -0
  340. data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.20.mk +43 -0
  341. data/vendor/tracemonkey/liveconnect/config/HP-UXB.11.00.mk +43 -0
  342. data/vendor/tracemonkey/liveconnect/config/IRIX6.2.mk +43 -0
  343. data/vendor/tracemonkey/liveconnect/config/IRIX6.3.mk +43 -0
  344. data/vendor/tracemonkey/liveconnect/config/IRIX6.5.mk +43 -0
  345. data/vendor/tracemonkey/liveconnect/config/Linux_All.mk +73 -0
  346. data/vendor/tracemonkey/liveconnect/config/OSF1V4.0.mk +65 -0
  347. data/vendor/tracemonkey/liveconnect/config/OSF1V5.0.mk +62 -0
  348. data/vendor/tracemonkey/liveconnect/config/SunOS5.5.1.mk +55 -0
  349. data/vendor/tracemonkey/liveconnect/config/SunOS5.6.mk +39 -0
  350. data/vendor/tracemonkey/liveconnect/config/SunOS5.7.mk +39 -0
  351. data/vendor/tracemonkey/liveconnect/config/SunOS5.8.mk +39 -0
  352. data/vendor/tracemonkey/liveconnect/config/WINNT4.0.mk +53 -0
  353. data/vendor/tracemonkey/liveconnect/jsj.c +886 -0
  354. data/vendor/tracemonkey/liveconnect/jsj.msg +98 -0
  355. data/vendor/tracemonkey/liveconnect/jsj_JSObject.c +1377 -0
  356. data/vendor/tracemonkey/liveconnect/jsj_JavaArray.c +474 -0
  357. data/vendor/tracemonkey/liveconnect/jsj_JavaClass.c +737 -0
  358. data/vendor/tracemonkey/liveconnect/jsj_JavaMember.c +191 -0
  359. data/vendor/tracemonkey/liveconnect/jsj_JavaObject.c +1079 -0
  360. data/vendor/tracemonkey/liveconnect/jsj_JavaPackage.c +569 -0
  361. data/vendor/tracemonkey/liveconnect/jsj_array.c +207 -0
  362. data/vendor/tracemonkey/liveconnect/jsj_class.c +770 -0
  363. data/vendor/tracemonkey/liveconnect/jsj_convert.c +902 -0
  364. data/vendor/tracemonkey/liveconnect/jsj_field.c +421 -0
  365. data/vendor/tracemonkey/liveconnect/jsj_hash.c +488 -0
  366. data/vendor/tracemonkey/liveconnect/jsj_hash.h +161 -0
  367. data/vendor/tracemonkey/liveconnect/jsj_method.c +1825 -0
  368. data/vendor/tracemonkey/liveconnect/jsj_nodl.c +1 -0
  369. data/vendor/tracemonkey/liveconnect/jsj_private.h +677 -0
  370. data/vendor/tracemonkey/liveconnect/jsj_simpleapi.c +219 -0
  371. data/vendor/tracemonkey/liveconnect/jsj_utils.c +513 -0
  372. data/vendor/tracemonkey/liveconnect/jsjava.h +316 -0
  373. data/vendor/tracemonkey/liveconnect/netscape_javascript_JSObject.h +155 -0
  374. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.cpp +785 -0
  375. data/vendor/tracemonkey/liveconnect/nsCLiveconnect.h +197 -0
  376. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.cpp +118 -0
  377. data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.h +76 -0
  378. data/vendor/tracemonkey/liveconnect/nsILiveconnect.h +197 -0
  379. data/vendor/tracemonkey/liveconnect/nsISecureLiveconnect.h +94 -0
  380. data/vendor/tracemonkey/liveconnect/nsISecurityContext.h +136 -0
  381. data/vendor/tracemonkey/lock_SunOS.s +119 -0
  382. data/vendor/tracemonkey/mandelbrot-results.js +3 -0
  383. data/vendor/tracemonkey/math-partial-sums.js +32 -0
  384. data/vendor/tracemonkey/math-trace-tests.js +507 -0
  385. data/vendor/tracemonkey/md5.js +289 -0
  386. data/vendor/tracemonkey/nanojit/Assembler.cpp +1984 -0
  387. data/vendor/tracemonkey/nanojit/Assembler.h +375 -0
  388. data/vendor/tracemonkey/nanojit/Fragmento.cpp +651 -0
  389. data/vendor/tracemonkey/nanojit/Fragmento.h +237 -0
  390. data/vendor/tracemonkey/nanojit/LIR.cpp +2314 -0
  391. data/vendor/tracemonkey/nanojit/LIR.h +879 -0
  392. data/vendor/tracemonkey/nanojit/LIRopcode.tbl +252 -0
  393. data/vendor/tracemonkey/nanojit/Native.h +127 -0
  394. data/vendor/tracemonkey/nanojit/NativeARM.cpp +1742 -0
  395. data/vendor/tracemonkey/nanojit/NativeARM.h +844 -0
  396. data/vendor/tracemonkey/nanojit/NativeSparc.cpp +1130 -0
  397. data/vendor/tracemonkey/nanojit/NativeSparc.h +948 -0
  398. data/vendor/tracemonkey/nanojit/NativeThumb.cpp +1322 -0
  399. data/vendor/tracemonkey/nanojit/NativeThumb.h +525 -0
  400. data/vendor/tracemonkey/nanojit/Nativei386.cpp +1748 -0
  401. data/vendor/tracemonkey/nanojit/Nativei386.h +857 -0
  402. data/vendor/tracemonkey/nanojit/RegAlloc.cpp +183 -0
  403. data/vendor/tracemonkey/nanojit/RegAlloc.h +95 -0
  404. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.cpp +306 -0
  405. data/vendor/tracemonkey/nanojit/TraceTreeDrawer.h +88 -0
  406. data/vendor/tracemonkey/nanojit/avmplus.cpp +56 -0
  407. data/vendor/tracemonkey/nanojit/avmplus.h +1016 -0
  408. data/vendor/tracemonkey/nanojit/nanojit.h +253 -0
  409. data/vendor/tracemonkey/perfect.js +39 -0
  410. data/vendor/tracemonkey/plify_jsdhash.sed +35 -0
  411. data/vendor/tracemonkey/prmjtime.cpp +869 -0
  412. data/vendor/tracemonkey/prmjtime.h +103 -0
  413. data/vendor/tracemonkey/ref-config/AIX4.1.mk +65 -0
  414. data/vendor/tracemonkey/ref-config/AIX4.2.mk +64 -0
  415. data/vendor/tracemonkey/ref-config/AIX4.3.mk +65 -0
  416. data/vendor/tracemonkey/ref-config/Darwin.mk +85 -0
  417. data/vendor/tracemonkey/ref-config/Darwin1.3.mk +81 -0
  418. data/vendor/tracemonkey/ref-config/Darwin1.4.mk +41 -0
  419. data/vendor/tracemonkey/ref-config/Darwin5.2.mk +81 -0
  420. data/vendor/tracemonkey/ref-config/Darwin5.3.mk +81 -0
  421. data/vendor/tracemonkey/ref-config/Darwin64.mk +72 -0
  422. data/vendor/tracemonkey/ref-config/HP-UXB.10.10.mk +77 -0
  423. data/vendor/tracemonkey/ref-config/HP-UXB.10.20.mk +77 -0
  424. data/vendor/tracemonkey/ref-config/HP-UXB.11.00.mk +80 -0
  425. data/vendor/tracemonkey/ref-config/IRIX.mk +87 -0
  426. data/vendor/tracemonkey/ref-config/IRIX5.3.mk +44 -0
  427. data/vendor/tracemonkey/ref-config/IRIX6.1.mk +44 -0
  428. data/vendor/tracemonkey/ref-config/IRIX6.2.mk +44 -0
  429. data/vendor/tracemonkey/ref-config/IRIX6.3.mk +44 -0
  430. data/vendor/tracemonkey/ref-config/IRIX6.5.mk +44 -0
  431. data/vendor/tracemonkey/ref-config/Linux_All.mk +105 -0
  432. data/vendor/tracemonkey/ref-config/Mac_OS10.0.mk +82 -0
  433. data/vendor/tracemonkey/ref-config/OSF1V4.0.mk +72 -0
  434. data/vendor/tracemonkey/ref-config/OSF1V5.0.mk +69 -0
  435. data/vendor/tracemonkey/ref-config/SunOS4.1.4.mk +101 -0
  436. data/vendor/tracemonkey/ref-config/SunOS5.10.mk +50 -0
  437. data/vendor/tracemonkey/ref-config/SunOS5.3.mk +91 -0
  438. data/vendor/tracemonkey/ref-config/SunOS5.4.mk +92 -0
  439. data/vendor/tracemonkey/ref-config/SunOS5.5.1.mk +44 -0
  440. data/vendor/tracemonkey/ref-config/SunOS5.5.mk +87 -0
  441. data/vendor/tracemonkey/ref-config/SunOS5.6.mk +89 -0
  442. data/vendor/tracemonkey/ref-config/SunOS5.7.mk +44 -0
  443. data/vendor/tracemonkey/ref-config/SunOS5.8.mk +44 -0
  444. data/vendor/tracemonkey/ref-config/SunOS5.9.mk +44 -0
  445. data/vendor/tracemonkey/ref-config/WINNT4.0.mk +118 -0
  446. data/vendor/tracemonkey/ref-config/WINNT5.0.mk +118 -0
  447. data/vendor/tracemonkey/ref-config/WINNT5.1.mk +118 -0
  448. data/vendor/tracemonkey/ref-config/WINNT5.2.mk +118 -0
  449. data/vendor/tracemonkey/ref-config/WINNT6.0.mk +118 -0
  450. data/vendor/tracemonkey/ref-config/dgux.mk +64 -0
  451. data/vendor/tracemonkey/resource.h +15 -0
  452. data/vendor/tracemonkey/rules.mk +206 -0
  453. data/vendor/tracemonkey/shell/Makefile.in +72 -0
  454. data/vendor/tracemonkey/shell/js.cpp +4719 -0
  455. data/vendor/tracemonkey/t/3d-cube.js +337 -0
  456. data/vendor/tracemonkey/t/3d-morph.js +54 -0
  457. data/vendor/tracemonkey/t/3d-raytrace.js +441 -0
  458. data/vendor/tracemonkey/t/access-binary-trees.js +50 -0
  459. data/vendor/tracemonkey/t/access-fannkuch.js +66 -0
  460. data/vendor/tracemonkey/t/access-nbody.js +169 -0
  461. data/vendor/tracemonkey/t/access-nsieve.js +38 -0
  462. data/vendor/tracemonkey/t/bitops-3bit-bits-in-byte.js +32 -0
  463. data/vendor/tracemonkey/t/bitops-bits-in-byte.js +21 -0
  464. data/vendor/tracemonkey/t/bitops-bitwise-and.js +28 -0
  465. data/vendor/tracemonkey/t/bitops-nsieve-bits.js +32 -0
  466. data/vendor/tracemonkey/t/controlflow-recursive.js +25 -0
  467. data/vendor/tracemonkey/t/crypto-aes.js +422 -0
  468. data/vendor/tracemonkey/t/crypto-md5.js +286 -0
  469. data/vendor/tracemonkey/t/crypto-sha1.js +224 -0
  470. data/vendor/tracemonkey/t/date-format-tofte.js +299 -0
  471. data/vendor/tracemonkey/t/date-format-xparb.js +417 -0
  472. data/vendor/tracemonkey/t/math-cordic.js +95 -0
  473. data/vendor/tracemonkey/t/math-partial-sums.js +33 -0
  474. data/vendor/tracemonkey/t/math-spectral-norm.js +51 -0
  475. data/vendor/tracemonkey/t/regexp-dna.js +1712 -0
  476. data/vendor/tracemonkey/t/string-base64.js +135 -0
  477. data/vendor/tracemonkey/t/string-fasta.js +85 -0
  478. data/vendor/tracemonkey/t/string-tagcloud.js +265 -0
  479. data/vendor/tracemonkey/t/string-unpack-code.js +68 -0
  480. data/vendor/tracemonkey/t/string-validate-input.js +89 -0
  481. data/vendor/tracemonkey/time.sh +13 -0
  482. data/vendor/tracemonkey/trace-test.js +5564 -0
  483. data/vendor/tracemonkey/v8/base.js +187 -0
  484. data/vendor/tracemonkey/v8/crypto.js +1689 -0
  485. data/vendor/tracemonkey/v8/deltablue.js +880 -0
  486. data/vendor/tracemonkey/v8/earley-boyer.js +4682 -0
  487. data/vendor/tracemonkey/v8/raytrace.js +3418 -0
  488. data/vendor/tracemonkey/v8/richards.js +539 -0
  489. data/vendor/tracemonkey/v8/run-crypto.js +44 -0
  490. data/vendor/tracemonkey/v8/run-deltablue.js +44 -0
  491. data/vendor/tracemonkey/v8/run-earley-boyer.js +44 -0
  492. data/vendor/tracemonkey/v8/run-raytrace.js +44 -0
  493. data/vendor/tracemonkey/v8/run-richards.js +44 -0
  494. data/vendor/tracemonkey/v8/run.js +49 -0
  495. data/vendor/tracemonkey/vprof/readme.txt +93 -0
  496. data/vendor/tracemonkey/vprof/vprof.cpp +360 -0
  497. data/vendor/tracemonkey/vprof/vprof.h +245 -0
  498. data/vendor/tracemonkey/xpconnect/Makefile.in +67 -0
  499. data/vendor/tracemonkey/xpconnect/crashtests/117307-1.html +20 -0
  500. data/vendor/tracemonkey/xpconnect/crashtests/193710.html +11 -0
  501. data/vendor/tracemonkey/xpconnect/crashtests/290162-1.html +5 -0
  502. data/vendor/tracemonkey/xpconnect/crashtests/326615-1.html +16 -0
  503. data/vendor/tracemonkey/xpconnect/crashtests/328553-1.html +13 -0
  504. data/vendor/tracemonkey/xpconnect/crashtests/346258-1.html +12 -0
  505. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame1.xhtml +16 -0
  506. data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame2.xhtml +15 -0
  507. data/vendor/tracemonkey/xpconnect/crashtests/346512-1.xhtml +30 -0
  508. data/vendor/tracemonkey/xpconnect/crashtests/382133-1.html +3 -0
  509. data/vendor/tracemonkey/xpconnect/crashtests/386680-1.html +22 -0
  510. data/vendor/tracemonkey/xpconnect/crashtests/394810-1.html +4 -0
  511. data/vendor/tracemonkey/xpconnect/crashtests/400349-1.html +20 -0
  512. data/vendor/tracemonkey/xpconnect/crashtests/403356-1.html +13 -0
  513. data/vendor/tracemonkey/xpconnect/crashtests/418139-1.svg +22 -0
  514. data/vendor/tracemonkey/xpconnect/crashtests/420513-1.html +11 -0
  515. data/vendor/tracemonkey/xpconnect/crashtests/453935-1.html +37 -0
  516. data/vendor/tracemonkey/xpconnect/crashtests/462926.html +12 -0
  517. data/vendor/tracemonkey/xpconnect/crashtests/468552-1.html +18 -0
  518. data/vendor/tracemonkey/xpconnect/crashtests/471366-1.html +12 -0
  519. data/vendor/tracemonkey/xpconnect/crashtests/475185-1.html +13 -0
  520. data/vendor/tracemonkey/xpconnect/crashtests/475291-1.html +14 -0
  521. data/vendor/tracemonkey/xpconnect/crashtests/503286-1.html +23 -0
  522. data/vendor/tracemonkey/xpconnect/crashtests/crashtests.list +21 -0
  523. data/vendor/tracemonkey/xpconnect/idl/Makefile.in +78 -0
  524. data/vendor/tracemonkey/xpconnect/idl/XPCIDispatch.idl +51 -0
  525. data/vendor/tracemonkey/xpconnect/idl/mozIJSSubScriptLoader.idl +64 -0
  526. data/vendor/tracemonkey/xpconnect/idl/nsIActiveXSecurityPolicy.idl +67 -0
  527. data/vendor/tracemonkey/xpconnect/idl/nsIDispatchSupport.idl +119 -0
  528. data/vendor/tracemonkey/xpconnect/idl/nsIJSContextStack.idl +85 -0
  529. data/vendor/tracemonkey/xpconnect/idl/nsIJSRuntimeService.idl +51 -0
  530. data/vendor/tracemonkey/xpconnect/idl/nsIScriptError.idl +102 -0
  531. data/vendor/tracemonkey/xpconnect/idl/nsIScriptableInterfaces.idl +67 -0
  532. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptNotify.idl +66 -0
  533. data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptable.idl +183 -0
  534. data/vendor/tracemonkey/xpconnect/idl/nsIXPCSecurityManager.idl +114 -0
  535. data/vendor/tracemonkey/xpconnect/idl/nsIXPConnect.idl +819 -0
  536. data/vendor/tracemonkey/xpconnect/idl/xpcIJSModuleLoader.idl +95 -0
  537. data/vendor/tracemonkey/xpconnect/idl/xpcIJSWeakReference.idl +49 -0
  538. data/vendor/tracemonkey/xpconnect/idl/xpccomponents.idl +254 -0
  539. data/vendor/tracemonkey/xpconnect/idl/xpcexception.idl +66 -0
  540. data/vendor/tracemonkey/xpconnect/idl/xpcjsid.idl +83 -0
  541. data/vendor/tracemonkey/xpconnect/loader/ISO8601DateUtils.jsm +176 -0
  542. data/vendor/tracemonkey/xpconnect/loader/Makefile.in +63 -0
  543. data/vendor/tracemonkey/xpconnect/loader/XPCOMUtils.jsm +267 -0
  544. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.cpp +1717 -0
  545. data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.h +172 -0
  546. data/vendor/tracemonkey/xpconnect/loader/mozJSLoaderConstructors.h +101 -0
  547. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.cpp +360 -0
  548. data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.h +66 -0
  549. data/vendor/tracemonkey/xpconnect/public/Makefile.in +54 -0
  550. data/vendor/tracemonkey/xpconnect/public/nsAXPCNativeCallContext.h +89 -0
  551. data/vendor/tracemonkey/xpconnect/public/nsAutoJSValHolder.h +168 -0
  552. data/vendor/tracemonkey/xpconnect/public/xpc_map_end.h +327 -0
  553. data/vendor/tracemonkey/xpconnect/sample/Makefile.in +71 -0
  554. data/vendor/tracemonkey/xpconnect/sample/README +39 -0
  555. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.cpp +337 -0
  556. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.idl +82 -0
  557. data/vendor/tracemonkey/xpconnect/sample/xpcsample1.js +21 -0
  558. data/vendor/tracemonkey/xpconnect/shell/Makefile.in +106 -0
  559. data/vendor/tracemonkey/xpconnect/shell/jsshell.msg +50 -0
  560. data/vendor/tracemonkey/xpconnect/shell/xpcshell.cpp +1817 -0
  561. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.h +43 -0
  562. data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.mm +54 -0
  563. data/vendor/tracemonkey/xpconnect/src/Makefile.in +228 -0
  564. data/vendor/tracemonkey/xpconnect/src/README +3 -0
  565. data/vendor/tracemonkey/xpconnect/src/XPCCrossOriginWrapper.cpp +1186 -0
  566. data/vendor/tracemonkey/xpconnect/src/XPCDispConvert.cpp +593 -0
  567. data/vendor/tracemonkey/xpconnect/src/XPCDispInlines.h +667 -0
  568. data/vendor/tracemonkey/xpconnect/src/XPCDispInterface.cpp +383 -0
  569. data/vendor/tracemonkey/xpconnect/src/XPCDispObject.cpp +516 -0
  570. data/vendor/tracemonkey/xpconnect/src/XPCDispParamPropJSClass.cpp +223 -0
  571. data/vendor/tracemonkey/xpconnect/src/XPCDispParams.cpp +103 -0
  572. data/vendor/tracemonkey/xpconnect/src/XPCDispPrivate.h +1401 -0
  573. data/vendor/tracemonkey/xpconnect/src/XPCDispTearOff.cpp +547 -0
  574. data/vendor/tracemonkey/xpconnect/src/XPCDispTypeInfo.cpp +471 -0
  575. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchClassInfo.cpp +139 -0
  576. data/vendor/tracemonkey/xpconnect/src/XPCIDispatchExtension.cpp +362 -0
  577. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.cpp +1350 -0
  578. data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.h +88 -0
  579. data/vendor/tracemonkey/xpconnect/src/XPCSafeJSObjectWrapper.cpp +1148 -0
  580. data/vendor/tracemonkey/xpconnect/src/XPCSystemOnlyWrapper.cpp +718 -0
  581. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.cpp +850 -0
  582. data/vendor/tracemonkey/xpconnect/src/XPCWrapper.h +394 -0
  583. data/vendor/tracemonkey/xpconnect/src/dom_quickstubs.qsconf +568 -0
  584. data/vendor/tracemonkey/xpconnect/src/nsDispatchSupport.cpp +348 -0
  585. data/vendor/tracemonkey/xpconnect/src/nsScriptError.cpp +201 -0
  586. data/vendor/tracemonkey/xpconnect/src/nsXPConnect.cpp +2609 -0
  587. data/vendor/tracemonkey/xpconnect/src/qsgen.py +1487 -0
  588. data/vendor/tracemonkey/xpconnect/src/xpc.msg +217 -0
  589. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.cpp +148 -0
  590. data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.h +56 -0
  591. data/vendor/tracemonkey/xpconnect/src/xpccallcontext.cpp +579 -0
  592. data/vendor/tracemonkey/xpconnect/src/xpccomponents.cpp +4144 -0
  593. data/vendor/tracemonkey/xpconnect/src/xpccontext.cpp +115 -0
  594. data/vendor/tracemonkey/xpconnect/src/xpcconvert.cpp +2298 -0
  595. data/vendor/tracemonkey/xpconnect/src/xpcdebug.cpp +481 -0
  596. data/vendor/tracemonkey/xpconnect/src/xpcexception.cpp +502 -0
  597. data/vendor/tracemonkey/xpconnect/src/xpcforwards.h +114 -0
  598. data/vendor/tracemonkey/xpconnect/src/xpcinlines.h +772 -0
  599. data/vendor/tracemonkey/xpconnect/src/xpcjsid.cpp +1025 -0
  600. data/vendor/tracemonkey/xpconnect/src/xpcjsruntime.cpp +1342 -0
  601. data/vendor/tracemonkey/xpconnect/src/xpclog.cpp +128 -0
  602. data/vendor/tracemonkey/xpconnect/src/xpclog.h +101 -0
  603. data/vendor/tracemonkey/xpconnect/src/xpcmaps.cpp +761 -0
  604. data/vendor/tracemonkey/xpconnect/src/xpcmaps.h +713 -0
  605. data/vendor/tracemonkey/xpconnect/src/xpcmodule.cpp +136 -0
  606. data/vendor/tracemonkey/xpconnect/src/xpcprivate.h +4138 -0
  607. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.cpp +1128 -0
  608. data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.h +480 -0
  609. data/vendor/tracemonkey/xpconnect/src/xpcruntimesvc.cpp +179 -0
  610. data/vendor/tracemonkey/xpconnect/src/xpcstack.cpp +342 -0
  611. data/vendor/tracemonkey/xpconnect/src/xpcstring.cpp +139 -0
  612. data/vendor/tracemonkey/xpconnect/src/xpcthreadcontext.cpp +599 -0
  613. data/vendor/tracemonkey/xpconnect/src/xpcthrower.cpp +399 -0
  614. data/vendor/tracemonkey/xpconnect/src/xpcvariant.cpp +850 -0
  615. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjs.cpp +670 -0
  616. data/vendor/tracemonkey/xpconnect/src/xpcwrappedjsclass.cpp +2015 -0
  617. data/vendor/tracemonkey/xpconnect/src/xpcwrappednative.cpp +3482 -0
  618. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeinfo.cpp +945 -0
  619. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativejsops.cpp +2003 -0
  620. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeproto.cpp +302 -0
  621. data/vendor/tracemonkey/xpconnect/src/xpcwrappednativescope.cpp +991 -0
  622. data/vendor/tracemonkey/xpconnect/tests/Makefile.in +75 -0
  623. data/vendor/tracemonkey/xpconnect/tests/TestXPC.cpp +785 -0
  624. data/vendor/tracemonkey/xpconnect/tests/chrome/Makefile.in +51 -0
  625. data/vendor/tracemonkey/xpconnect/tests/chrome/test_bug500931.xul +43 -0
  626. data/vendor/tracemonkey/xpconnect/tests/components/Makefile.in +85 -0
  627. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_array.cpp +388 -0
  628. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_attributes.cpp +305 -0
  629. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_calljs.cpp +135 -0
  630. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_child.cpp +225 -0
  631. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_const.cpp +76 -0
  632. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_domstring.cpp +118 -0
  633. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_echo.cpp +616 -0
  634. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_in.cpp +204 -0
  635. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_inout.cpp +171 -0
  636. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_module.cpp +77 -0
  637. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_multiple.cpp +554 -0
  638. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_noisy.cpp +154 -0
  639. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_out.cpp +335 -0
  640. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_overloaded.cpp +250 -0
  641. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_private.h +192 -0
  642. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_string.cpp +185 -0
  643. data/vendor/tracemonkey/xpconnect/tests/components/xpctest_variant.cpp +355 -0
  644. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.cpp +12 -0
  645. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.h +28 -0
  646. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCDispUtilities.h +28 -0
  647. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.cpp +86 -0
  648. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.def +9 -0
  649. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsp +318 -0
  650. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsw +29 -0
  651. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.idl +454 -0
  652. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.rc +145 -0
  653. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.cpp +44 -0
  654. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.h +56 -0
  655. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.rgs +23 -0
  656. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.cpp +221 -0
  657. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.h +53 -0
  658. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.rgs +23 -0
  659. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.cpp +699 -0
  660. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.h +138 -0
  661. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.rgs +23 -0
  662. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.cpp +23 -0
  663. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.h +41 -0
  664. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.rgs +23 -0
  665. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.cpp +256 -0
  666. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.h +88 -0
  667. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.rgs +23 -0
  668. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.cpp +23 -0
  669. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.h +43 -0
  670. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.rgs +23 -0
  671. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.cpp +29 -0
  672. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.h +45 -0
  673. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.rgs +23 -0
  674. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.cpp +177 -0
  675. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.h +50 -0
  676. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.rgs +23 -0
  677. data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/resource.h +36 -0
  678. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Arrays/XPCIDispatchArrayTests.js +54 -0
  679. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Attributes/XPCIDispatchAttributeTests.js +150 -0
  680. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCIDispatchInstantiations.js +122 -0
  681. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCStress.js +58 -0
  682. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Methods/XPCIDispatchMethodTests.js +376 -0
  683. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/shell.js +377 -0
  684. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/General/XPCIDispatchTestWrappedJS.js +76 -0
  685. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/shell.js +377 -0
  686. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/exectests.cmd +1 -0
  687. data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/jsDriver.pl +1288 -0
  688. data/vendor/tracemonkey/xpconnect/tests/idl/Makefile.in +61 -0
  689. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest.idl +312 -0
  690. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest2.idl +51 -0
  691. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_attributes.idl +67 -0
  692. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_calljs.idl +59 -0
  693. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_const.idl +61 -0
  694. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_domstring.idl +59 -0
  695. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_in.idl +88 -0
  696. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_inout.idl +86 -0
  697. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_multiple.idl +77 -0
  698. data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_out.idl +142 -0
  699. data/vendor/tracemonkey/xpconnect/tests/js/checkid.js +82 -0
  700. data/vendor/tracemonkey/xpconnect/tests/js/evaluate.js +311 -0
  701. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-2.js +153 -0
  702. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-3.js +194 -0
  703. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-4.js +297 -0
  704. data/vendor/tracemonkey/xpconnect/tests/js/exceptions-5.js +343 -0
  705. data/vendor/tracemonkey/xpconnect/tests/js/exceptions.js +230 -0
  706. data/vendor/tracemonkey/xpconnect/tests/js/javascript.js +96 -0
  707. data/vendor/tracemonkey/xpconnect/tests/js/multiple-2.js +151 -0
  708. data/vendor/tracemonkey/xpconnect/tests/js/multiple-3.js +148 -0
  709. data/vendor/tracemonkey/xpconnect/tests/js/multiple-4.js +152 -0
  710. data/vendor/tracemonkey/xpconnect/tests/js/multiple.js +137 -0
  711. data/vendor/tracemonkey/xpconnect/tests/js/notscriptable.js +104 -0
  712. data/vendor/tracemonkey/xpconnect/tests/js/old/simpletest.js +36 -0
  713. data/vendor/tracemonkey/xpconnect/tests/js/old/speed.js +60 -0
  714. data/vendor/tracemonkey/xpconnect/tests/js/old/testxpc.js +464 -0
  715. data/vendor/tracemonkey/xpconnect/tests/js/old/threads.js +74 -0
  716. data/vendor/tracemonkey/xpconnect/tests/js/old/try.js +27 -0
  717. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_array.js +308 -0
  718. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_callcontext.js +68 -0
  719. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_echo.js +636 -0
  720. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_and_sort.js +28 -0
  721. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_constants.js +15 -0
  722. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_create.js +200 -0
  723. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_exceptions.js +167 -0
  724. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_ids.js +135 -0
  725. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_observer.js +36 -0
  726. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_overloaded.js +14 -0
  727. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_primitives.js +141 -0
  728. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_propertybag.js +36 -0
  729. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant.js +339 -0
  730. data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant_array.js +30 -0
  731. data/vendor/tracemonkey/xpconnect/tests/js/readonlyattributes.js +74 -0
  732. data/vendor/tracemonkey/xpconnect/tests/js/readwriteattributes.js +101 -0
  733. data/vendor/tracemonkey/xpconnect/tests/js/scriptable.js +120 -0
  734. data/vendor/tracemonkey/xpconnect/tests/js/testin.js +203 -0
  735. data/vendor/tracemonkey/xpconnect/tests/js/xpcfun.js +234 -0
  736. data/vendor/tracemonkey/xpconnect/tests/js/xpctest_primitives.js +200 -0
  737. data/vendor/tracemonkey/xpconnect/tests/mochitest/Makefile.in +66 -0
  738. data/vendor/tracemonkey/xpconnect/tests/mochitest/bug500931_helper.html +7 -0
  739. data/vendor/tracemonkey/xpconnect/tests/mochitest/inner.html +7 -0
  740. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug361111.xul +29 -0
  741. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug384632.html +32 -0
  742. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug390488.html +65 -0
  743. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug393269.html +46 -0
  744. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug396851.html +43 -0
  745. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug428021.html +41 -0
  746. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug446584.html +49 -0
  747. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug448587.html +31 -0
  748. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug462428.html +42 -0
  749. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug478438.html +66 -0
  750. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484107.html +100 -0
  751. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484459.html +36 -0
  752. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug500691.html +28 -0
  753. data/vendor/tracemonkey/xpconnect/tests/mochitest/test_wrappers.html +116 -0
  754. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_element_type.jsm +1 -0
  755. data/vendor/tracemonkey/xpconnect/tests/unit/bogus_exports_type.jsm +1 -0
  756. data/vendor/tracemonkey/xpconnect/tests/unit/bug451678_subscript.js +2 -0
  757. data/vendor/tracemonkey/xpconnect/tests/unit/component_import.js +144 -0
  758. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importA.jsm +44 -0
  759. data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importB.jsm +45 -0
  760. data/vendor/tracemonkey/xpconnect/tests/unit/syntax_error.jsm +1 -0
  761. data/vendor/tracemonkey/xpconnect/tests/unit/test_bogus_files.js +88 -0
  762. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug408412.js +51 -0
  763. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug451678.js +52 -0
  764. data/vendor/tracemonkey/xpconnect/tests/unit/test_bug_442086.js +68 -0
  765. data/vendor/tracemonkey/xpconnect/tests/unit/test_import.js +127 -0
  766. data/vendor/tracemonkey/xpconnect/tests/unit/test_js_weak_references.js +63 -0
  767. data/vendor/tracemonkey/xpconnect/tests/unit/test_recursive_import.js +62 -0
  768. data/vendor/tracemonkey/xpconnect/tools/Makefile.in +49 -0
  769. data/vendor/tracemonkey/xpconnect/tools/idl/Makefile.in +53 -0
  770. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsCompiler.idl +60 -0
  771. data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsProfiler.idl +57 -0
  772. data/vendor/tracemonkey/xpconnect/tools/js/CompileJSFiles.js +28 -0
  773. data/vendor/tracemonkey/xpconnect/tools/js/ListJSFiles.js +18 -0
  774. data/vendor/tracemonkey/xpconnect/tools/src/Makefile.in +76 -0
  775. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsCompiler.cpp +161 -0
  776. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsModule.cpp +65 -0
  777. data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsProfiler.cpp +370 -0
  778. data/vendor/tracemonkey/xpconnect/tools/src/xpctools_private.h +236 -0
  779. metadata +782 -107
  780. data/test/johnson/nodes/export_test.rb +0 -9
  781. data/test/johnson/nodes/import_test.rb +0 -13
  782. data/test/johnson/version_test.rb +0 -13
@@ -0,0 +1,199 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ *
3
+ * ***** BEGIN LICENSE BLOCK *****
4
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
+ *
6
+ * The contents of this file are subject to the Mozilla Public License Version
7
+ * 1.1 (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ * http://www.mozilla.org/MPL/
10
+ *
11
+ * Software distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
+ * for the specific language governing rights and limitations under the
14
+ * License.
15
+ *
16
+ * The Original Code is Mozilla Communicator client code, released
17
+ * March 31, 1998.
18
+ *
19
+ * The Initial Developer of the Original Code is
20
+ * Netscape Communications Corporation.
21
+ * Portions created by the Initial Developer are Copyright (C) 1998
22
+ * the Initial Developer. All Rights Reserved.
23
+ *
24
+ * Contributor(s):
25
+ *
26
+ * Alternatively, the contents of this file may be used under the terms of
27
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
28
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
+ * in which case the provisions of the GPL or the LGPL are applicable instead
30
+ * of those above. If you wish to allow use of your version of this file only
31
+ * under the terms of either the GPL or the LGPL, and not to allow others to
32
+ * use your version of this file under the terms of the MPL, indicate your
33
+ * decision by deleting the provisions above and replace them with the notice
34
+ * and other provisions required by the GPL or the LGPL. If you do not delete
35
+ * the provisions above, a recipient may use your version of this file under
36
+ * the terms of any one of the MPL, the GPL or the LGPL.
37
+ *
38
+ * ***** END LICENSE BLOCK ***** */
39
+
40
+ #ifndef jsregexp_h___
41
+ #define jsregexp_h___
42
+ /*
43
+ * JS regular expression interface.
44
+ */
45
+ #include <stddef.h>
46
+ #include "jspubtd.h"
47
+ #include "jsstr.h"
48
+
49
+ #ifdef JS_THREADSAFE
50
+ #include "jsdhash.h"
51
+ #endif
52
+
53
+ JS_BEGIN_EXTERN_C
54
+
55
+ struct JSRegExpStatics {
56
+ JSString *input; /* input string to match (perl $_, GC root) */
57
+ JSBool multiline; /* whether input contains newlines (perl $*) */
58
+ uint16 parenCount; /* number of valid elements in parens[] */
59
+ uint16 moreLength; /* number of allocated elements in moreParens */
60
+ JSSubString parens[9]; /* last set of parens matched (perl $1, $2) */
61
+ JSSubString *moreParens; /* null or realloc'd vector for $10, etc. */
62
+ JSSubString lastMatch; /* last string matched (perl $&) */
63
+ JSSubString lastParen; /* last paren matched (perl $+) */
64
+ JSSubString leftContext; /* input to left of last match (perl $`) */
65
+ JSSubString rightContext; /* input to right of last match (perl $') */
66
+ };
67
+
68
+ extern JS_FRIEND_API(void)
69
+ js_SaveAndClearRegExpStatics(JSContext *cx, JSRegExpStatics *statics,
70
+ JSTempValueRooter *tvr);
71
+
72
+ extern JS_FRIEND_API(void)
73
+ js_RestoreRegExpStatics(JSContext *cx, JSRegExpStatics *statics,
74
+ JSTempValueRooter *tvr);
75
+
76
+ /*
77
+ * This struct holds a bitmap representation of a class from a regexp.
78
+ * There's a list of these referenced by the classList field in the JSRegExp
79
+ * struct below. The initial state has startIndex set to the offset in the
80
+ * original regexp source of the beginning of the class contents. The first
81
+ * use of the class converts the source representation into a bitmap.
82
+ *
83
+ */
84
+ typedef struct RECharSet {
85
+ JSPackedBool converted;
86
+ JSPackedBool sense;
87
+ uint16 length;
88
+ union {
89
+ uint8 *bits;
90
+ struct {
91
+ size_t startIndex;
92
+ size_t length;
93
+ } src;
94
+ } u;
95
+ } RECharSet;
96
+
97
+ /*
98
+ * This macro is safe because moreParens is guaranteed to be allocated and big
99
+ * enough to hold parenCount, or else be null when parenCount is 0.
100
+ */
101
+ #define REGEXP_PAREN_SUBSTRING(res, num) \
102
+ (((jsuint)(num) < (jsuint)(res)->parenCount) \
103
+ ? ((jsuint)(num) < 9) \
104
+ ? &(res)->parens[num] \
105
+ : &(res)->moreParens[(num) - 9] \
106
+ : &js_EmptySubString)
107
+
108
+ typedef struct RENode RENode;
109
+
110
+ struct JSRegExp {
111
+ jsrefcount nrefs; /* reference count */
112
+ uint16 flags; /* flags, see jsapi.h's JSREG_* defines */
113
+ size_t parenCount; /* number of parenthesized submatches */
114
+ size_t classCount; /* count [...] bitmaps */
115
+ RECharSet *classList; /* list of [...] bitmaps */
116
+ JSString *source; /* locked source string, sans // */
117
+ jsbytecode program[1]; /* regular expression bytecode */
118
+ };
119
+
120
+ extern JSRegExp *
121
+ js_NewRegExp(JSContext *cx, JSTokenStream *ts,
122
+ JSString *str, uintN flags, JSBool flat);
123
+
124
+ extern JSRegExp *
125
+ js_NewRegExpOpt(JSContext *cx, JSString *str, JSString *opt, JSBool flat);
126
+
127
+ #define HOLD_REGEXP(cx, re) JS_ATOMIC_INCREMENT(&(re)->nrefs)
128
+ #define DROP_REGEXP(cx, re) js_DestroyRegExp(cx, re)
129
+
130
+ extern void
131
+ js_DestroyRegExp(JSContext *cx, JSRegExp *re);
132
+
133
+ /*
134
+ * Execute re on input str at *indexp, returning null in *rval on mismatch.
135
+ * On match, return true if test is true, otherwise return an array object.
136
+ * Update *indexp and cx->regExpStatics always on match.
137
+ */
138
+ extern JSBool
139
+ js_ExecuteRegExp(JSContext *cx, JSRegExp *re, JSString *str, size_t *indexp,
140
+ JSBool test, jsval *rval);
141
+
142
+ extern void
143
+ js_InitRegExpStatics(JSContext *cx);
144
+
145
+ extern void
146
+ js_TraceRegExpStatics(JSTracer *trc, JSContext *acx);
147
+
148
+ extern void
149
+ js_FreeRegExpStatics(JSContext *cx);
150
+
151
+ #define VALUE_IS_REGEXP(cx, v) \
152
+ (JSVAL_IS_OBJECT(v) && JSVAL_TO_OBJECT(v) && \
153
+ OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)) == &js_RegExpClass)
154
+
155
+ extern JSClass js_RegExpClass;
156
+
157
+ enum regexp_tinyid {
158
+ REGEXP_SOURCE = -1,
159
+ REGEXP_GLOBAL = -2,
160
+ REGEXP_IGNORE_CASE = -3,
161
+ REGEXP_LAST_INDEX = -4,
162
+ REGEXP_MULTILINE = -5,
163
+ REGEXP_STICKY = -6
164
+ };
165
+
166
+ extern JSObject *
167
+ js_InitRegExpClass(JSContext *cx, JSObject *obj);
168
+
169
+ /*
170
+ * Export js_regexp_toString to the decompiler.
171
+ */
172
+ extern JSBool
173
+ js_regexp_toString(JSContext *cx, JSObject *obj, jsval *vp);
174
+
175
+ /*
176
+ * Create, serialize/deserialize, or clone a RegExp object.
177
+ */
178
+ extern JSObject *
179
+ js_NewRegExpObject(JSContext *cx, JSTokenStream *ts,
180
+ jschar *chars, size_t length, uintN flags);
181
+
182
+ extern JSBool
183
+ js_XDRRegExpObject(JSXDRState *xdr, JSObject **objp);
184
+
185
+ extern JSObject *
186
+ js_CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *parent);
187
+
188
+ /*
189
+ * Get and set the per-object (clone or clone-parent) lastIndex slot.
190
+ */
191
+ extern JSBool
192
+ js_GetLastIndex(JSContext *cx, JSObject *obj, jsdouble *lastIndex);
193
+
194
+ extern JSBool
195
+ js_SetLastIndex(JSContext *cx, JSObject *obj, jsdouble lastIndex);
196
+
197
+ JS_END_EXTERN_C
198
+
199
+ #endif /* jsregexp_h___ */
@@ -0,0 +1,145 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ * vim: set ts=8 sw=4 et tw=0 ft=C:
3
+ *
4
+ * ***** BEGIN LICENSE BLOCK *****
5
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "license"); you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ * http://www.mozilla.org/MPL/
11
+ *
12
+ * Software distributed under the License is distributed on an "as is" basis,
13
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
+ * for the specific language governing rights and limitations under the
15
+ * License.
16
+ *
17
+ * The Original Code is Mozilla Communicator client code, released
18
+ * March 31, 1998.
19
+ *
20
+ * The Initial Developer of the Original Code is
21
+ * Netscape Communications Corporation.
22
+ * Portions created by the Initial Developer are Copyright (C) 1998
23
+ * the Initial Developer. All Rights Reserved.
24
+ *
25
+ * Contributor(s):
26
+ *
27
+ * Alternatively, the contentsof this file are subject to the Mozilla Public License Version
28
+ * 1.1 (the "license"); you may not use this file except in compliance with
29
+ * the License. You may obtain a copy of thter (the "lgpl"),
30
+ * in which case the provisions of the GPL or the LGPL are applicable instead
31
+ * of those above. If you wish to allow use of your version of this file only
32
+ * under the terms of either the GPL or the LGPL, and not to allow others to
33
+ * use your version of this file under the terms of the MPL, indicate your
34
+ * decision by deleting the provisions above and replace them with the notice
35
+ * and other provisions required by the GPL or the LGPL. If you do not delete
36
+ * the provisions above, a recipient may use your version of this file under
37
+ * the terms of any one of the MPL, the GPL or the LGPL.
38
+ *
39
+ * ***** END LICENSE BLOCK ***** */
40
+
41
+
42
+ /* Note : contiguity of 'simple opcodes' is important for SimpleMatch() */
43
+
44
+ /* match rest of input against rest of r.e. */
45
+ REOP_DEF(REOP_EMPTY, "empty")
46
+ /* beginning of input (or line if multiline) */
47
+ REOP_DEF(REOP_BOL, "bol")
48
+ /* end of input (or line if multiline) */
49
+ REOP_DEF(REOP_EOL, "eol")
50
+ /* match "" at word boundary */
51
+ REOP_DEF(REOP_WBDRY, "wbdry")
52
+ /* match "" at word non-boundary */
53
+ REOP_DEF(REOP_WNONBDRY, "wnonbdry")
54
+ /* stands for any character */
55
+ REOP_DEF(REOP_DOT, "dot")
56
+ /* match a digit char: [0-9] */
57
+ REOP_DEF(REOP_DIGIT, "digit")
58
+ /* match a non-digit char: [^0-9] */
59
+ REOP_DEF(REOP_NONDIGIT, "nondigit")
60
+ /* match an alphanumeric char: [0-9a-z_A-Z] */
61
+ REOP_DEF(REOP_ALNUM, "alnum")
62
+ /* match a non-alphanumeric char: [^0-9a-z_A-Z] */
63
+ REOP_DEF(REOP_NONALNUM, "nonalnum")
64
+ /* match a whitespace char */
65
+ REOP_DEF(REOP_SPACE, "space")
66
+ /* match a non-whitespace char */
67
+ REOP_DEF(REOP_NONSPACE, "nonspace")
68
+ /* back-reference (e.g., \1) to a parenthetical */
69
+ REOP_DEF(REOP_BACKREF, "backref")
70
+ /* match a flat string */
71
+ REOP_DEF(REOP_FLAT, "flat")
72
+ /* match a single char */
73
+ REOP_DEF(REOP_FLAT1, "flat1")
74
+ /* case-independent REOP_FLAT */
75
+ REOP_DEF(REOP_FLATi, "flati")
76
+ /* case-independent REOP_FLAT1 */
77
+ REOP_DEF(REOP_FLAT1i, "flat1i")
78
+ /* single Unicode char */
79
+ REOP_DEF(REOP_UCFLAT1, "ucflat1")
80
+ /* case-independent REOP_UCFLAT1 */
81
+ REOP_DEF(REOP_UCFLAT1i, "ucflat1i")
82
+ /* flat Unicode string; len immediate counts chars */
83
+ REOP_DEF(REOP_UCFLAT, "ucflat")
84
+ /* case-independent REOP_UCFLAT */
85
+ REOP_DEF(REOP_UCFLATi, "ucflati")
86
+ /* character class with index */
87
+ REOP_DEF(REOP_CLASS, "class")
88
+ /* negated character class with index */
89
+ REOP_DEF(REOP_NCLASS, "nclass")
90
+
91
+ /* NCLASS is considered to be the last "simple" op-code */
92
+
93
+
94
+ /* alternative subexpressions in kid and next */
95
+ REOP_DEF(REOP_ALT, "alt")
96
+ /* quantified atom: atom{1,2} */
97
+ REOP_DEF(REOP_QUANT, "quant")
98
+ /* zero or more occurrences of kid */
99
+ REOP_DEF(REOP_STAR, "star")
100
+ /* one or more occurrences of kid */
101
+ REOP_DEF(REOP_PLUS, "plus")
102
+ /* optional subexpression in kid */
103
+ REOP_DEF(REOP_OPT, "opt")
104
+ /* left paren bytecode: kid is u.num'th sub-regexp */
105
+ REOP_DEF(REOP_LPAREN, "lparen")
106
+ /* right paren bytecode */
107
+ REOP_DEF(REOP_RPAREN, "rparen")
108
+ /* for deoptimized closure loops */
109
+ REOP_DEF(REOP_JUMP, "jump")
110
+ /* optimize .* to use a single opcode */
111
+ REOP_DEF(REOP_DOTSTAR, "dotstar")
112
+ /* non-capturing version of REOP_LPAREN */
113
+ REOP_DEF(REOP_LPARENNON, "lparennon")
114
+ /* zero width positive lookahead assertion */
115
+ REOP_DEF(REOP_ASSERT, "assert")
116
+ /* zero width negative lookahead assertion */
117
+ REOP_DEF(REOP_ASSERT_NOT, "assert_not")
118
+ /* sentinel at end of assertion child */
119
+ REOP_DEF(REOP_ASSERTTEST, "asserttest")
120
+ /* sentinel at end of !assertion child */
121
+ REOP_DEF(REOP_ASSERTNOTTEST, "assertnottest")
122
+ /* non-greedy version of * */
123
+ REOP_DEF(REOP_MINIMALSTAR, "minimalstar")
124
+ /* non-greedy version of + */
125
+ REOP_DEF(REOP_MINIMALPLUS, "minimalplus")
126
+ /* non-greedy version of ? */
127
+ REOP_DEF(REOP_MINIMALOPT, "minimalopt")
128
+ /* non-greedy version of {} */
129
+ REOP_DEF(REOP_MINIMALQUANT, "minimalquant")
130
+ /* sentinel at end of quantifier child */
131
+ REOP_DEF(REOP_ENDCHILD, "endchild")
132
+ /* directs execution of greedy quantifier */
133
+ REOP_DEF(REOP_REPEAT, "repeat")
134
+ /* directs execution of non-greedy quantifier */
135
+ REOP_DEF(REOP_MINIMALREPEAT, "minimalrepeat")
136
+ /* prerequisite for ALT, either of two chars */
137
+ REOP_DEF(REOP_ALTPREREQ, "altprereq")
138
+ /* prerequisite for ALT, a char or a class */
139
+ REOP_DEF(REOP_ALTPREREQ2, "altprereq2")
140
+ /* end of final alternate */
141
+ REOP_DEF(REOP_ENDALT, "endalt")
142
+ /* concatenation of terms (parse time only) */
143
+ REOP_DEF(REOP_CONCAT, "concat")
144
+ /* end of expression */
145
+ REOP_DEF(REOP_END, "end")
@@ -0,0 +1,2040 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ * vim: set sw=4 ts=8 et tw=78:
3
+ *
4
+ * ***** BEGIN LICENSE BLOCK *****
5
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "License"); you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ * http://www.mozilla.org/MPL/
11
+ *
12
+ * Software distributed under the License is distributed on an "AS IS" basis,
13
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
+ * for the specific language governing rights and limitations under the
15
+ * License.
16
+ *
17
+ * The Original Code is Mozilla Communicator client code, released
18
+ * March 31, 1998.
19
+ *
20
+ * The Initial Developer of the Original Code is
21
+ * Netscape Communications Corporation.
22
+ * Portions created by the Initial Developer are Copyright (C) 1998
23
+ * the Initial Developer. All Rights Reserved.
24
+ *
25
+ * Contributor(s):
26
+ *
27
+ * Alternatively, the contents of this file may be used under the terms of
28
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
29
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
+ * in which case the provisions of the GPL or the LGPL are applicable instead
31
+ * of those above. If you wish to allow use of your version of this file only
32
+ * under the terms of either the GPL or the LGPL, and not to allow others to
33
+ * use your version of this file under the terms of the MPL, indicate your
34
+ * decision by deleting the provisions above and replace them with the notice
35
+ * and other provisions required by the GPL or the LGPL. If you do not delete
36
+ * the provisions above, a recipient may use your version of this file under
37
+ * the terms of any one of the MPL, the GPL or the LGPL.
38
+ *
39
+ * ***** END LICENSE BLOCK ***** */
40
+
41
+ /*
42
+ * JS lexical scanner.
43
+ */
44
+ #include "jsstddef.h"
45
+ #include <stdio.h> /* first to avoid trouble on some systems */
46
+ #include <errno.h>
47
+ #include <limits.h>
48
+ #include <math.h>
49
+ #ifdef HAVE_MEMORY_H
50
+ #include <memory.h>
51
+ #endif
52
+ #include <stdarg.h>
53
+ #include <stdlib.h>
54
+ #include <string.h>
55
+ #include "jstypes.h"
56
+ #include "jsarena.h" /* Added by JSIFY */
57
+ #include "jsbit.h"
58
+ #include "jsutil.h" /* Added by JSIFY */
59
+ #include "jsdtoa.h"
60
+ #include "jsprf.h"
61
+ #include "jsapi.h"
62
+ #include "jsatom.h"
63
+ #include "jscntxt.h"
64
+ #include "jsversion.h"
65
+ #include "jsemit.h"
66
+ #include "jsexn.h"
67
+ #include "jsnum.h"
68
+ #include "jsopcode.h"
69
+ #include "jsparse.h"
70
+ #include "jsregexp.h"
71
+ #include "jsscan.h"
72
+ #include "jsscript.h"
73
+ #include "jsstaticcheck.h"
74
+
75
+ #if JS_HAS_XML_SUPPORT
76
+ #include "jsxml.h"
77
+ #endif
78
+
79
+ #define JS_KEYWORD(keyword, type, op, version) \
80
+ const char js_##keyword##_str[] = #keyword;
81
+ #include "jskeyword.tbl"
82
+ #undef JS_KEYWORD
83
+
84
+ struct keyword {
85
+ const char *chars; /* C string with keyword text */
86
+ JSTokenType tokentype; /* JSTokenType */
87
+ JSOp op; /* JSOp */
88
+ JSVersion version; /* JSVersion */
89
+ };
90
+
91
+ static const struct keyword keyword_defs[] = {
92
+ #define JS_KEYWORD(keyword, type, op, version) \
93
+ {js_##keyword##_str, type, op, version},
94
+ #include "jskeyword.tbl"
95
+ #undef JS_KEYWORD
96
+ };
97
+
98
+ #define KEYWORD_COUNT JS_ARRAY_LENGTH(keyword_defs)
99
+
100
+ static const struct keyword *
101
+ FindKeyword(const jschar *s, size_t length)
102
+ {
103
+ register size_t i;
104
+ const struct keyword *kw;
105
+ const char *chars;
106
+
107
+ JS_ASSERT(length != 0);
108
+
109
+ #define JSKW_LENGTH() length
110
+ #define JSKW_AT(column) s[column]
111
+ #define JSKW_GOT_MATCH(index) i = (index); goto got_match;
112
+ #define JSKW_TEST_GUESS(index) i = (index); goto test_guess;
113
+ #define JSKW_NO_MATCH() goto no_match;
114
+ #include "jsautokw.h"
115
+ #undef JSKW_NO_MATCH
116
+ #undef JSKW_TEST_GUESS
117
+ #undef JSKW_GOT_MATCH
118
+ #undef JSKW_AT
119
+ #undef JSKW_LENGTH
120
+
121
+ got_match:
122
+ return &keyword_defs[i];
123
+
124
+ test_guess:
125
+ kw = &keyword_defs[i];
126
+ chars = kw->chars;
127
+ do {
128
+ if (*s++ != (unsigned char)(*chars++))
129
+ goto no_match;
130
+ } while (--length != 0);
131
+ return kw;
132
+
133
+ no_match:
134
+ return NULL;
135
+ }
136
+
137
+ JSTokenType
138
+ js_CheckKeyword(const jschar *str, size_t length)
139
+ {
140
+ const struct keyword *kw;
141
+
142
+ JS_ASSERT(length != 0);
143
+ kw = FindKeyword(str, length);
144
+ return kw ? kw->tokentype : TOK_EOF;
145
+ }
146
+
147
+ JS_FRIEND_API(void)
148
+ js_MapKeywords(void (*mapfun)(const char *))
149
+ {
150
+ size_t i;
151
+
152
+ for (i = 0; i != KEYWORD_COUNT; ++i)
153
+ mapfun(keyword_defs[i].chars);
154
+ }
155
+
156
+ JSBool
157
+ js_IsIdentifier(JSString *str)
158
+ {
159
+ size_t length;
160
+ jschar c, *chars, *end;
161
+
162
+ JSSTRING_CHARS_AND_LENGTH(str, chars, length);
163
+ if (length == 0)
164
+ return JS_FALSE;
165
+ c = *chars;
166
+ if (!JS_ISIDSTART(c))
167
+ return JS_FALSE;
168
+ end = chars + length;
169
+ while (++chars != end) {
170
+ c = *chars;
171
+ if (!JS_ISIDENT(c))
172
+ return JS_FALSE;
173
+ }
174
+ return JS_TRUE;
175
+ }
176
+
177
+ #define TBMIN 64
178
+
179
+ static JSBool
180
+ GrowTokenBuf(JSStringBuffer *sb, size_t newlength)
181
+ {
182
+ JSContext *cx;
183
+ jschar *base;
184
+ ptrdiff_t offset, length;
185
+ size_t tbsize;
186
+ JSArenaPool *pool;
187
+
188
+ cx = (JSContext*) sb->data;
189
+ base = sb->base;
190
+ offset = PTRDIFF(sb->ptr, base, jschar);
191
+ pool = &cx->tempPool;
192
+ if (!base) {
193
+ tbsize = TBMIN * sizeof(jschar);
194
+ length = TBMIN - 1;
195
+ JS_ARENA_ALLOCATE_CAST(base, jschar *, pool, tbsize);
196
+ } else {
197
+ length = PTRDIFF(sb->limit, base, jschar);
198
+ if ((size_t)length >= ~(size_t)0 / sizeof(jschar)) {
199
+ base = NULL;
200
+ } else {
201
+ tbsize = (length + 1) * sizeof(jschar);
202
+ length += length + 1;
203
+ JS_ARENA_GROW_CAST(base, jschar *, pool, tbsize, tbsize);
204
+ }
205
+ }
206
+ if (!base) {
207
+ js_ReportOutOfScriptQuota(cx);
208
+ sb->base = STRING_BUFFER_ERROR_BASE;
209
+ return JS_FALSE;
210
+ }
211
+ sb->base = base;
212
+ sb->limit = base + length;
213
+ sb->ptr = base + offset;
214
+ return JS_TRUE;
215
+ }
216
+
217
+ JSBool
218
+ js_InitTokenStream(JSContext *cx, JSTokenStream *ts,
219
+ const jschar *base, size_t length,
220
+ FILE *fp, const char *filename, uintN lineno)
221
+ {
222
+ jschar *buf;
223
+ size_t nb;
224
+
225
+ JS_ASSERT_IF(fp, !base);
226
+ JS_ASSERT_IF(!base, length == 0);
227
+ nb = fp
228
+ ? 2 * JS_LINE_LIMIT * sizeof(jschar)
229
+ : JS_LINE_LIMIT * sizeof(jschar);
230
+ JS_ARENA_ALLOCATE_CAST(buf, jschar *, &cx->tempPool, nb);
231
+ if (!buf) {
232
+ js_ReportOutOfScriptQuota(cx);
233
+ return JS_FALSE;
234
+ }
235
+ memset(buf, 0, nb);
236
+ memset(ts, 0, sizeof(*ts));
237
+ ts->filename = filename;
238
+ ts->lineno = lineno;
239
+ ts->linebuf.base = ts->linebuf.limit = ts->linebuf.ptr = buf;
240
+ if (fp) {
241
+ ts->file = fp;
242
+ ts->userbuf.base = buf + JS_LINE_LIMIT;
243
+ ts->userbuf.ptr = ts->userbuf.limit = ts->userbuf.base + JS_LINE_LIMIT;
244
+ } else {
245
+ ts->userbuf.base = (jschar *)base;
246
+ ts->userbuf.limit = (jschar *)base + length;
247
+ ts->userbuf.ptr = (jschar *)base;
248
+ }
249
+ ts->tokenbuf.grow = GrowTokenBuf;
250
+ ts->tokenbuf.data = cx;
251
+ ts->listener = cx->debugHooks->sourceHandler;
252
+ ts->listenerData = cx->debugHooks->sourceHandlerData;
253
+ return JS_TRUE;
254
+ }
255
+
256
+ void
257
+ js_CloseTokenStream(JSContext *cx, JSTokenStream *ts)
258
+ {
259
+ if (ts->flags & TSF_OWNFILENAME)
260
+ JS_free(cx, (void *) ts->filename);
261
+ }
262
+
263
+ JS_FRIEND_API(int)
264
+ js_fgets(char *buf, int size, FILE *file)
265
+ {
266
+ int n, i, c;
267
+ JSBool crflag;
268
+
269
+ n = size - 1;
270
+ if (n < 0)
271
+ return -1;
272
+
273
+ crflag = JS_FALSE;
274
+ for (i = 0; i < n && (c = getc(file)) != EOF; i++) {
275
+ buf[i] = c;
276
+ if (c == '\n') { /* any \n ends a line */
277
+ i++; /* keep the \n; we know there is room for \0 */
278
+ break;
279
+ }
280
+ if (crflag) { /* \r not followed by \n ends line at the \r */
281
+ ungetc(c, file);
282
+ break; /* and overwrite c in buf with \0 */
283
+ }
284
+ crflag = (c == '\r');
285
+ }
286
+
287
+ buf[i] = '\0';
288
+ return i;
289
+ }
290
+
291
+ static int32
292
+ GetChar(JSTokenStream *ts)
293
+ {
294
+ int32 c;
295
+ ptrdiff_t i, j, len, olen;
296
+ JSBool crflag;
297
+ char cbuf[JS_LINE_LIMIT];
298
+ jschar *ubuf, *nl;
299
+
300
+ if (ts->ungetpos != 0) {
301
+ c = ts->ungetbuf[--ts->ungetpos];
302
+ } else {
303
+ if (ts->linebuf.ptr == ts->linebuf.limit) {
304
+ len = PTRDIFF(ts->userbuf.limit, ts->userbuf.ptr, jschar);
305
+ if (len <= 0) {
306
+ if (!ts->file) {
307
+ ts->flags |= TSF_EOF;
308
+ return EOF;
309
+ }
310
+
311
+ /* Fill ts->userbuf so that \r and \r\n convert to \n. */
312
+ crflag = (ts->flags & TSF_CRFLAG) != 0;
313
+ len = js_fgets(cbuf, JS_LINE_LIMIT - crflag, ts->file);
314
+ if (len <= 0) {
315
+ ts->flags |= TSF_EOF;
316
+ return EOF;
317
+ }
318
+ olen = len;
319
+ ubuf = ts->userbuf.base;
320
+ i = 0;
321
+ if (crflag) {
322
+ ts->flags &= ~TSF_CRFLAG;
323
+ if (cbuf[0] != '\n') {
324
+ ubuf[i++] = '\n';
325
+ len++;
326
+ ts->linepos--;
327
+ }
328
+ }
329
+ for (j = 0; i < len; i++, j++)
330
+ ubuf[i] = (jschar) (unsigned char) cbuf[j];
331
+ ts->userbuf.limit = ubuf + len;
332
+ ts->userbuf.ptr = ubuf;
333
+ }
334
+ if (ts->listener) {
335
+ ts->listener(ts->filename, ts->lineno, ts->userbuf.ptr, len,
336
+ &ts->listenerTSData, ts->listenerData);
337
+ }
338
+
339
+ nl = ts->saveEOL;
340
+ if (!nl) {
341
+ /*
342
+ * Any one of \n, \r, or \r\n ends a line (the longest
343
+ * match wins). Also allow the Unicode line and paragraph
344
+ * separators.
345
+ */
346
+ for (nl = ts->userbuf.ptr; nl < ts->userbuf.limit; nl++) {
347
+ /*
348
+ * Try to prevent value-testing on most characters by
349
+ * filtering out characters that aren't 000x or 202x.
350
+ */
351
+ if ((*nl & 0xDFD0) == 0) {
352
+ if (*nl == '\n')
353
+ break;
354
+ if (*nl == '\r') {
355
+ if (nl + 1 < ts->userbuf.limit && nl[1] == '\n')
356
+ nl++;
357
+ break;
358
+ }
359
+ if (*nl == LINE_SEPARATOR || *nl == PARA_SEPARATOR)
360
+ break;
361
+ }
362
+ }
363
+ }
364
+
365
+ /*
366
+ * If there was a line terminator, copy thru it into linebuf.
367
+ * Else copy JS_LINE_LIMIT-1 bytes into linebuf.
368
+ */
369
+ if (nl < ts->userbuf.limit)
370
+ len = PTRDIFF(nl, ts->userbuf.ptr, jschar) + 1;
371
+ if (len >= JS_LINE_LIMIT) {
372
+ len = JS_LINE_LIMIT - 1;
373
+ ts->saveEOL = nl;
374
+ } else {
375
+ ts->saveEOL = NULL;
376
+ }
377
+ js_strncpy(ts->linebuf.base, ts->userbuf.ptr, len);
378
+ ts->userbuf.ptr += len;
379
+ olen = len;
380
+
381
+ /*
382
+ * Make sure linebuf contains \n for EOL (don't do this in
383
+ * userbuf because the user's string might be readonly).
384
+ */
385
+ if (nl < ts->userbuf.limit) {
386
+ if (*nl == '\r') {
387
+ if (ts->linebuf.base[len-1] == '\r') {
388
+ /*
389
+ * Does the line segment end in \r? We must check
390
+ * for a \n at the front of the next segment before
391
+ * storing a \n into linebuf. This case matters
392
+ * only when we're reading from a file.
393
+ */
394
+ if (nl + 1 == ts->userbuf.limit && ts->file) {
395
+ len--;
396
+ ts->flags |= TSF_CRFLAG; /* clear NLFLAG? */
397
+ if (len == 0) {
398
+ /*
399
+ * This can happen when a segment ends in
400
+ * \r\r. Start over. ptr == limit in this
401
+ * case, so we'll fall into buffer-filling
402
+ * code.
403
+ */
404
+ return GetChar(ts);
405
+ }
406
+ } else {
407
+ ts->linebuf.base[len-1] = '\n';
408
+ }
409
+ }
410
+ } else if (*nl == '\n') {
411
+ if (nl > ts->userbuf.base &&
412
+ nl[-1] == '\r' &&
413
+ ts->linebuf.base[len-2] == '\r') {
414
+ len--;
415
+ JS_ASSERT(ts->linebuf.base[len] == '\n');
416
+ ts->linebuf.base[len-1] = '\n';
417
+ }
418
+ } else if (*nl == LINE_SEPARATOR || *nl == PARA_SEPARATOR) {
419
+ ts->linebuf.base[len-1] = '\n';
420
+ }
421
+ }
422
+
423
+ /* Reset linebuf based on adjusted segment length. */
424
+ ts->linebuf.limit = ts->linebuf.base + len;
425
+ ts->linebuf.ptr = ts->linebuf.base;
426
+
427
+ /* Update position of linebuf within physical userbuf line. */
428
+ if (!(ts->flags & TSF_NLFLAG))
429
+ ts->linepos += ts->linelen;
430
+ else
431
+ ts->linepos = 0;
432
+ if (ts->linebuf.limit[-1] == '\n')
433
+ ts->flags |= TSF_NLFLAG;
434
+ else
435
+ ts->flags &= ~TSF_NLFLAG;
436
+
437
+ /* Update linelen from original segment length. */
438
+ ts->linelen = olen;
439
+ }
440
+ c = *ts->linebuf.ptr++;
441
+ }
442
+ if (c == '\n')
443
+ ts->lineno++;
444
+ return c;
445
+ }
446
+
447
+ static void
448
+ UngetChar(JSTokenStream *ts, int32 c)
449
+ {
450
+ if (c == EOF)
451
+ return;
452
+ JS_ASSERT(ts->ungetpos < JS_ARRAY_LENGTH(ts->ungetbuf));
453
+ if (c == '\n')
454
+ ts->lineno--;
455
+ ts->ungetbuf[ts->ungetpos++] = (jschar)c;
456
+ }
457
+
458
+ static int32
459
+ PeekChar(JSTokenStream *ts)
460
+ {
461
+ int32 c;
462
+
463
+ c = GetChar(ts);
464
+ UngetChar(ts, c);
465
+ return c;
466
+ }
467
+
468
+ /*
469
+ * Peek n chars ahead into ts. Return true if n chars were read, false if
470
+ * there weren't enough characters in the input stream. This function cannot
471
+ * be used to peek into or past a newline.
472
+ */
473
+ static JSBool
474
+ PeekChars(JSTokenStream *ts, intN n, jschar *cp)
475
+ {
476
+ intN i, j;
477
+ int32 c;
478
+
479
+ for (i = 0; i < n; i++) {
480
+ c = GetChar(ts);
481
+ if (c == EOF)
482
+ break;
483
+ if (c == '\n') {
484
+ UngetChar(ts, c);
485
+ break;
486
+ }
487
+ cp[i] = (jschar)c;
488
+ }
489
+ for (j = i - 1; j >= 0; j--)
490
+ UngetChar(ts, cp[j]);
491
+ return i == n;
492
+ }
493
+
494
+ static void
495
+ SkipChars(JSTokenStream *ts, intN n)
496
+ {
497
+ while (--n >= 0)
498
+ GetChar(ts);
499
+ }
500
+
501
+ static JSBool
502
+ MatchChar(JSTokenStream *ts, int32 expect)
503
+ {
504
+ int32 c;
505
+
506
+ c = GetChar(ts);
507
+ if (c == expect)
508
+ return JS_TRUE;
509
+ UngetChar(ts, c);
510
+ return JS_FALSE;
511
+ }
512
+
513
+ JSBool
514
+ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
515
+ uintN flags, uintN errorNumber, ...)
516
+ {
517
+ JSErrorReport report;
518
+ char *message;
519
+ size_t linelength;
520
+ jschar *linechars;
521
+ char *linebytes;
522
+ va_list ap;
523
+ JSBool warning, ok;
524
+ JSTokenPos *tp;
525
+ uintN index, i;
526
+ JSErrorReporter onError;
527
+
528
+ JS_ASSERT(ts->linebuf.limit < ts->linebuf.base + JS_LINE_LIMIT);
529
+
530
+ if ((flags & JSREPORT_STRICT) && !JS_HAS_STRICT_OPTION(cx))
531
+ return JS_TRUE;
532
+
533
+ memset(&report, 0, sizeof report);
534
+ report.flags = flags;
535
+ report.errorNumber = errorNumber;
536
+ message = NULL;
537
+ linechars = NULL;
538
+ linebytes = NULL;
539
+
540
+ MUST_FLOW_THROUGH("out");
541
+ va_start(ap, errorNumber);
542
+ ok = js_ExpandErrorArguments(cx, js_GetErrorMessage, NULL,
543
+ errorNumber, &message, &report, &warning,
544
+ !(flags & JSREPORT_UC), ap);
545
+ va_end(ap);
546
+ if (!ok) {
547
+ warning = JS_FALSE;
548
+ goto out;
549
+ }
550
+
551
+ report.filename = ts->filename;
552
+
553
+ if (pn) {
554
+ report.lineno = pn->pn_pos.begin.lineno;
555
+ if (report.lineno != ts->lineno)
556
+ goto report;
557
+ tp = &pn->pn_pos;
558
+ } else {
559
+ /* Point to the current token, not the next one to get. */
560
+ tp = &ts->tokens[ts->cursor].pos;
561
+ }
562
+ report.lineno = ts->lineno;
563
+ linelength = PTRDIFF(ts->linebuf.limit, ts->linebuf.base, jschar);
564
+ linechars = (jschar *)JS_malloc(cx, (linelength + 1) * sizeof(jschar));
565
+ if (!linechars) {
566
+ warning = JS_FALSE;
567
+ goto out;
568
+ }
569
+ memcpy(linechars, ts->linebuf.base, linelength * sizeof(jschar));
570
+ linechars[linelength] = 0;
571
+ linebytes = js_DeflateString(cx, linechars, linelength);
572
+ if (!linebytes) {
573
+ warning = JS_FALSE;
574
+ goto out;
575
+ }
576
+ report.linebuf = linebytes;
577
+
578
+ /*
579
+ * FIXME: What should instead happen here is that we should
580
+ * find error-tokens in userbuf, if !ts->file. That will
581
+ * allow us to deliver a more helpful error message, which
582
+ * includes all or part of the bad string or bad token. The
583
+ * code here yields something that looks truncated.
584
+ * See https://bugzilla.mozilla.org/show_bug.cgi?id=352970
585
+ */
586
+ index = 0;
587
+ if (tp->begin.lineno == tp->end.lineno) {
588
+ if (tp->begin.index < ts->linepos)
589
+ goto report;
590
+
591
+ index = tp->begin.index - ts->linepos;
592
+ }
593
+
594
+ report.tokenptr = report.linebuf + index;
595
+ report.uclinebuf = linechars;
596
+ report.uctokenptr = report.uclinebuf + index;
597
+
598
+ /*
599
+ * If there's a runtime exception type associated with this error
600
+ * number, set that as the pending exception. For errors occuring at
601
+ * compile time, this is very likely to be a JSEXN_SYNTAXERR.
602
+ *
603
+ * If an exception is thrown but not caught, the JSREPORT_EXCEPTION
604
+ * flag will be set in report.flags. Proper behavior for an error
605
+ * reporter is to ignore a report with this flag for all but top-level
606
+ * compilation errors. The exception will remain pending, and so long
607
+ * as the non-top-level "load", "eval", or "compile" native function
608
+ * returns false, the top-level reporter will eventually receive the
609
+ * uncaught exception report.
610
+ *
611
+ * XXX it'd probably be best if there was only one call to this
612
+ * function, but there seem to be two error reporter call points.
613
+ */
614
+ report:
615
+ onError = cx->errorReporter;
616
+
617
+ /*
618
+ * Try to raise an exception only if there isn't one already set --
619
+ * otherwise the exception will describe the last compile-time error,
620
+ * which is likely spurious.
621
+ */
622
+ if (!(ts->flags & TSF_ERROR)) {
623
+ if (js_ErrorToException(cx, message, &report))
624
+ onError = NULL;
625
+ }
626
+
627
+ /*
628
+ * Suppress any compile-time errors that don't occur at the top level.
629
+ * This may still fail, as interplevel may be zero in contexts where we
630
+ * don't really want to call the error reporter, as when js is called
631
+ * by other code which could catch the error.
632
+ */
633
+ if (cx->interpLevel != 0 && !JSREPORT_IS_WARNING(flags))
634
+ onError = NULL;
635
+
636
+ if (onError) {
637
+ JSDebugErrorHook hook = cx->debugHooks->debugErrorHook;
638
+
639
+ /*
640
+ * If debugErrorHook is present then we give it a chance to veto
641
+ * sending the error on to the regular error reporter.
642
+ */
643
+ if (hook && !hook(cx, message, &report,
644
+ cx->debugHooks->debugErrorHookData)) {
645
+ onError = NULL;
646
+ }
647
+ }
648
+ if (onError)
649
+ (*onError)(cx, message, &report);
650
+
651
+ out:
652
+ if (linebytes)
653
+ JS_free(cx, linebytes);
654
+ if (linechars)
655
+ JS_free(cx, linechars);
656
+ if (message)
657
+ JS_free(cx, message);
658
+ if (report.ucmessage)
659
+ JS_free(cx, (void *)report.ucmessage);
660
+
661
+ if (report.messageArgs) {
662
+ if (!(flags & JSREPORT_UC)) {
663
+ i = 0;
664
+ while (report.messageArgs[i])
665
+ JS_free(cx, (void *)report.messageArgs[i++]);
666
+ }
667
+ JS_free(cx, (void *)report.messageArgs);
668
+ }
669
+
670
+ if (!JSREPORT_IS_WARNING(flags)) {
671
+ /* Set the error flag to suppress spurious reports. */
672
+ ts->flags |= TSF_ERROR;
673
+ }
674
+
675
+ return warning;
676
+ }
677
+
678
+ static JSBool
679
+ GrowStringBuffer(JSStringBuffer *sb, size_t amount)
680
+ {
681
+ ptrdiff_t offset = sb->ptr - sb->base;
682
+ JS_ASSERT(offset >= 0);
683
+
684
+ /*
685
+ * This addition needs an overflow check, but we can defer bounding against
686
+ * ~size_t(0) / sizeof(jschar) till later to consolidate that test.
687
+ */
688
+ size_t newlength = offset + amount + 1;
689
+ if (size_t(offset) < newlength) {
690
+ /* Grow by powers of two until 16MB, then grow by that chunk size. */
691
+ const size_t CHUNK_SIZE_MASK = JS_BITMASK(24);
692
+
693
+ if (newlength <= CHUNK_SIZE_MASK)
694
+ newlength = JS_BIT(JS_CeilingLog2(newlength));
695
+ else if (newlength & CHUNK_SIZE_MASK)
696
+ newlength = (newlength | CHUNK_SIZE_MASK) + 1;
697
+
698
+ /* Now do the full overflow check. */
699
+ if (size_t(offset) < newlength && newlength < ~size_t(0) / sizeof(jschar)) {
700
+ jschar *bp = (jschar *) realloc(sb->base, newlength * sizeof(jschar));
701
+ if (bp) {
702
+ sb->base = bp;
703
+ sb->ptr = bp + offset;
704
+ sb->limit = bp + newlength - 1;
705
+ return true;
706
+ }
707
+ }
708
+ }
709
+
710
+ /* Either newlength overflow or realloc failure: poison the well. */
711
+ free(sb->base);
712
+ sb->base = STRING_BUFFER_ERROR_BASE;
713
+ return false;
714
+ }
715
+
716
+ static void
717
+ FreeStringBuffer(JSStringBuffer *sb)
718
+ {
719
+ JS_ASSERT(STRING_BUFFER_OK(sb));
720
+ if (sb->base)
721
+ free(sb->base);
722
+ }
723
+
724
+ void
725
+ js_InitStringBuffer(JSStringBuffer *sb)
726
+ {
727
+ sb->base = sb->limit = sb->ptr = NULL;
728
+ sb->data = NULL;
729
+ sb->grow = GrowStringBuffer;
730
+ sb->free = FreeStringBuffer;
731
+ }
732
+
733
+ void
734
+ js_FinishStringBuffer(JSStringBuffer *sb)
735
+ {
736
+ sb->free(sb);
737
+ }
738
+
739
+ void
740
+ js_AppendChar(JSStringBuffer *sb, jschar c)
741
+ {
742
+ jschar *bp;
743
+
744
+ if (!STRING_BUFFER_OK(sb))
745
+ return;
746
+ if (!ENSURE_STRING_BUFFER(sb, 1))
747
+ return;
748
+ bp = sb->ptr;
749
+ *bp++ = c;
750
+ *bp = 0;
751
+ sb->ptr = bp;
752
+ }
753
+
754
+ void
755
+ js_AppendUCString(JSStringBuffer *sb, const jschar *buf, uintN len)
756
+ {
757
+ jschar *bp;
758
+
759
+ if (!STRING_BUFFER_OK(sb))
760
+ return;
761
+ if (len == 0 || !ENSURE_STRING_BUFFER(sb, len))
762
+ return;
763
+ bp = sb->ptr;
764
+ js_strncpy(bp, buf, len);
765
+ bp += len;
766
+ *bp = 0;
767
+ sb->ptr = bp;
768
+ }
769
+
770
+ #if JS_HAS_XML_SUPPORT
771
+
772
+ void
773
+ js_RepeatChar(JSStringBuffer *sb, jschar c, uintN count)
774
+ {
775
+ jschar *bp;
776
+
777
+ if (!STRING_BUFFER_OK(sb) || count == 0)
778
+ return;
779
+ if (!ENSURE_STRING_BUFFER(sb, count))
780
+ return;
781
+ for (bp = sb->ptr; count; --count)
782
+ *bp++ = c;
783
+ *bp = 0;
784
+ sb->ptr = bp;
785
+ }
786
+
787
+ void
788
+ js_AppendCString(JSStringBuffer *sb, const char *asciiz)
789
+ {
790
+ size_t length;
791
+ jschar *bp;
792
+
793
+ if (!STRING_BUFFER_OK(sb) || *asciiz == '\0')
794
+ return;
795
+ length = strlen(asciiz);
796
+ if (!ENSURE_STRING_BUFFER(sb, length))
797
+ return;
798
+ for (bp = sb->ptr; length; --length)
799
+ *bp++ = (jschar) *asciiz++;
800
+ *bp = 0;
801
+ sb->ptr = bp;
802
+ }
803
+
804
+ void
805
+ js_AppendJSString(JSStringBuffer *sb, JSString *str)
806
+ {
807
+ js_AppendUCString(sb, JSSTRING_CHARS(str), JSSTRING_LENGTH(str));
808
+ }
809
+
810
+ static JSBool
811
+ GetXMLEntity(JSContext *cx, JSTokenStream *ts)
812
+ {
813
+ ptrdiff_t offset, length, i;
814
+ int32 c, d;
815
+ JSBool ispair;
816
+ jschar *bp, digit;
817
+ char *bytes;
818
+ JSErrNum msg;
819
+
820
+ /* Put the entity, including the '&' already scanned, in ts->tokenbuf. */
821
+ offset = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar);
822
+ js_FastAppendChar(&ts->tokenbuf, '&');
823
+ if (!STRING_BUFFER_OK(&ts->tokenbuf))
824
+ return JS_FALSE;
825
+ while ((c = GetChar(ts)) != ';') {
826
+ if (c == EOF || c == '\n') {
827
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
828
+ JSMSG_END_OF_XML_ENTITY);
829
+ return JS_FALSE;
830
+ }
831
+ js_FastAppendChar(&ts->tokenbuf, (jschar) c);
832
+ if (!STRING_BUFFER_OK(&ts->tokenbuf))
833
+ return JS_FALSE;
834
+ }
835
+
836
+ /* Let length be the number of jschars after the '&', including the ';'. */
837
+ length = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar) - offset;
838
+ bp = ts->tokenbuf.base + offset;
839
+ c = d = 0;
840
+ ispair = JS_FALSE;
841
+ if (length > 2 && bp[1] == '#') {
842
+ /* Match a well-formed XML Character Reference. */
843
+ i = 2;
844
+ if (length > 3 && JS_TOLOWER(bp[i]) == 'x') {
845
+ if (length > 9) /* at most 6 hex digits allowed */
846
+ goto badncr;
847
+ while (++i < length) {
848
+ digit = bp[i];
849
+ if (!JS7_ISHEX(digit))
850
+ goto badncr;
851
+ c = (c << 4) + JS7_UNHEX(digit);
852
+ }
853
+ } else {
854
+ while (i < length) {
855
+ digit = bp[i++];
856
+ if (!JS7_ISDEC(digit))
857
+ goto badncr;
858
+ c = (c * 10) + JS7_UNDEC(digit);
859
+ if (c < 0)
860
+ goto badncr;
861
+ }
862
+ }
863
+
864
+ if (0x10000 <= c && c <= 0x10FFFF) {
865
+ /* Form a surrogate pair (c, d) -- c is the high surrogate. */
866
+ d = 0xDC00 + (c & 0x3FF);
867
+ c = 0xD7C0 + (c >> 10);
868
+ ispair = JS_TRUE;
869
+ } else {
870
+ /* Enforce the http://www.w3.org/TR/REC-xml/#wf-Legalchar WFC. */
871
+ if (c != 0x9 && c != 0xA && c != 0xD &&
872
+ !(0x20 <= c && c <= 0xD7FF) &&
873
+ !(0xE000 <= c && c <= 0xFFFD)) {
874
+ goto badncr;
875
+ }
876
+ }
877
+ } else {
878
+ /* Try to match one of the five XML 1.0 predefined entities. */
879
+ switch (length) {
880
+ case 3:
881
+ if (bp[2] == 't') {
882
+ if (bp[1] == 'l')
883
+ c = '<';
884
+ else if (bp[1] == 'g')
885
+ c = '>';
886
+ }
887
+ break;
888
+ case 4:
889
+ if (bp[1] == 'a' && bp[2] == 'm' && bp[3] == 'p')
890
+ c = '&';
891
+ break;
892
+ case 5:
893
+ if (bp[3] == 'o') {
894
+ if (bp[1] == 'a' && bp[2] == 'p' && bp[4] == 's')
895
+ c = '\'';
896
+ else if (bp[1] == 'q' && bp[2] == 'u' && bp[4] == 't')
897
+ c = '"';
898
+ }
899
+ break;
900
+ }
901
+ if (c == 0) {
902
+ msg = JSMSG_UNKNOWN_XML_ENTITY;
903
+ goto bad;
904
+ }
905
+ }
906
+
907
+ /* If we matched, retract ts->tokenbuf and store the entity's value. */
908
+ *bp++ = (jschar) c;
909
+ if (ispair)
910
+ *bp++ = (jschar) d;
911
+ *bp = 0;
912
+ ts->tokenbuf.ptr = bp;
913
+ return JS_TRUE;
914
+
915
+ badncr:
916
+ msg = JSMSG_BAD_XML_NCR;
917
+ bad:
918
+ /* No match: throw a TypeError per ECMA-357 10.3.2.1 step 8(a). */
919
+ JS_ASSERT(STRING_BUFFER_OK(&ts->tokenbuf));
920
+ JS_ASSERT(PTRDIFF(ts->tokenbuf.ptr, bp, jschar) >= 1);
921
+ bytes = js_DeflateString(cx, bp + 1,
922
+ PTRDIFF(ts->tokenbuf.ptr, bp, jschar) - 1);
923
+ if (bytes) {
924
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
925
+ msg, bytes);
926
+ JS_free(cx, bytes);
927
+ }
928
+ return JS_FALSE;
929
+ }
930
+
931
+ #endif /* JS_HAS_XML_SUPPORT */
932
+
933
+ JSTokenType
934
+ js_PeekToken(JSContext *cx, JSTokenStream *ts)
935
+ {
936
+ JSTokenType tt;
937
+
938
+ if (ts->lookahead != 0) {
939
+ tt = ts->tokens[(ts->cursor + ts->lookahead) & NTOKENS_MASK].type;
940
+ } else {
941
+ tt = js_GetToken(cx, ts);
942
+ js_UngetToken(ts);
943
+ }
944
+ return tt;
945
+ }
946
+
947
+ JSTokenType
948
+ js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts)
949
+ {
950
+ JSTokenType tt;
951
+
952
+ if (!ON_CURRENT_LINE(ts, CURRENT_TOKEN(ts).pos))
953
+ return TOK_EOL;
954
+ ts->flags |= TSF_NEWLINES;
955
+ tt = js_PeekToken(cx, ts);
956
+ ts->flags &= ~TSF_NEWLINES;
957
+ return tt;
958
+ }
959
+
960
+ /*
961
+ * We have encountered a '\': check for a Unicode escape sequence after it,
962
+ * returning the character code value if we found a Unicode escape sequence.
963
+ * Otherwise, non-destructively return the original '\'.
964
+ */
965
+ static int32
966
+ GetUnicodeEscape(JSTokenStream *ts)
967
+ {
968
+ jschar cp[5];
969
+ int32 c;
970
+
971
+ if (PeekChars(ts, 5, cp) && cp[0] == 'u' &&
972
+ JS7_ISHEX(cp[1]) && JS7_ISHEX(cp[2]) &&
973
+ JS7_ISHEX(cp[3]) && JS7_ISHEX(cp[4]))
974
+ {
975
+ c = (((((JS7_UNHEX(cp[1]) << 4)
976
+ + JS7_UNHEX(cp[2])) << 4)
977
+ + JS7_UNHEX(cp[3])) << 4)
978
+ + JS7_UNHEX(cp[4]);
979
+ SkipChars(ts, 5);
980
+ return c;
981
+ }
982
+ return '\\';
983
+ }
984
+
985
+ static JSToken *
986
+ NewToken(JSTokenStream *ts, ptrdiff_t adjust)
987
+ {
988
+ JSToken *tp;
989
+
990
+ ts->cursor = (ts->cursor + 1) & NTOKENS_MASK;
991
+ tp = &CURRENT_TOKEN(ts);
992
+ tp->ptr = ts->linebuf.ptr + adjust;
993
+ tp->pos.begin.index = ts->linepos +
994
+ PTRDIFF(tp->ptr, ts->linebuf.base, jschar) -
995
+ ts->ungetpos;
996
+ tp->pos.begin.lineno = tp->pos.end.lineno = (uint16)ts->lineno;
997
+ return tp;
998
+ }
999
+
1000
+ static JS_ALWAYS_INLINE JSBool
1001
+ ScanAsSpace(jschar c)
1002
+ {
1003
+ /* Treat little- and big-endian BOMs as whitespace for compatibility. */
1004
+ if (JS_ISSPACE(c) || c == 0xfffe || c == 0xfeff)
1005
+ return JS_TRUE;
1006
+ return JS_FALSE;
1007
+ }
1008
+
1009
+ JSTokenType
1010
+ js_GetToken(JSContext *cx, JSTokenStream *ts)
1011
+ {
1012
+ JSTokenType tt;
1013
+ int32 c, qc;
1014
+ JSToken *tp;
1015
+ JSAtom *atom;
1016
+ JSBool hadUnicodeEscape;
1017
+ const struct keyword *kw;
1018
+ #if JS_HAS_XML_SUPPORT
1019
+ JSBool inTarget;
1020
+ size_t targetLength;
1021
+ ptrdiff_t contentIndex;
1022
+ #endif
1023
+
1024
+ #define INIT_TOKENBUF() (ts->tokenbuf.ptr = ts->tokenbuf.base)
1025
+ #define TOKENBUF_LENGTH() PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar)
1026
+ #define TOKENBUF_OK() STRING_BUFFER_OK(&ts->tokenbuf)
1027
+ #define TOKENBUF_TO_ATOM() (TOKENBUF_OK() \
1028
+ ? js_AtomizeChars(cx, \
1029
+ TOKENBUF_BASE(), \
1030
+ TOKENBUF_LENGTH(), \
1031
+ 0) \
1032
+ : NULL)
1033
+ #define ADD_TO_TOKENBUF(c) JS_BEGIN_MACRO \
1034
+ js_FastAppendChar(&ts->tokenbuf, jschar(c)); \
1035
+ if (!TOKENBUF_OK()) \
1036
+ goto error; \
1037
+ JS_END_MACRO
1038
+
1039
+ /* The following 4 macros should only be used when TOKENBUF_OK() is true. */
1040
+ #define TOKENBUF_BASE() (ts->tokenbuf.base)
1041
+ #define TOKENBUF_END() (ts->tokenbuf.ptr)
1042
+ #define TOKENBUF_CHAR(i) (ts->tokenbuf.base[i])
1043
+ #define TRIM_TOKENBUF(i) (ts->tokenbuf.ptr = ts->tokenbuf.base + i)
1044
+ #define NUL_TERM_TOKENBUF() (*ts->tokenbuf.ptr = 0)
1045
+
1046
+ /* Check for a pushed-back token resulting from mismatching lookahead. */
1047
+ while (ts->lookahead != 0) {
1048
+ JS_ASSERT(!(ts->flags & TSF_XMLTEXTMODE));
1049
+ ts->lookahead--;
1050
+ ts->cursor = (ts->cursor + 1) & NTOKENS_MASK;
1051
+ tt = CURRENT_TOKEN(ts).type;
1052
+ if (tt != TOK_EOL || (ts->flags & TSF_NEWLINES))
1053
+ return tt;
1054
+ }
1055
+
1056
+ /* If there was a fatal error, keep returning TOK_ERROR. */
1057
+ if (ts->flags & TSF_ERROR)
1058
+ return TOK_ERROR;
1059
+
1060
+ #if JS_HAS_XML_SUPPORT
1061
+ if (ts->flags & TSF_XMLTEXTMODE) {
1062
+ tt = TOK_XMLSPACE; /* veto if non-space, return TOK_XMLTEXT */
1063
+ tp = NewToken(ts, 0);
1064
+ INIT_TOKENBUF();
1065
+ qc = (ts->flags & TSF_XMLONLYMODE) ? '<' : '{';
1066
+
1067
+ while ((c = GetChar(ts)) != qc && c != '<' && c != EOF) {
1068
+ if (c == '&' && qc == '<') {
1069
+ if (!GetXMLEntity(cx, ts))
1070
+ goto error;
1071
+ tt = TOK_XMLTEXT;
1072
+ continue;
1073
+ }
1074
+
1075
+ if (!JS_ISXMLSPACE(c))
1076
+ tt = TOK_XMLTEXT;
1077
+ ADD_TO_TOKENBUF(c);
1078
+ }
1079
+ UngetChar(ts, c);
1080
+
1081
+ if (TOKENBUF_LENGTH() == 0) {
1082
+ atom = NULL;
1083
+ } else {
1084
+ atom = TOKENBUF_TO_ATOM();
1085
+ if (!atom)
1086
+ goto error;
1087
+ }
1088
+ tp->pos.end.lineno = (uint16)ts->lineno;
1089
+ tp->t_op = JSOP_STRING;
1090
+ tp->t_atom = atom;
1091
+ goto out;
1092
+ }
1093
+
1094
+ if (ts->flags & TSF_XMLTAGMODE) {
1095
+ tp = NewToken(ts, 0);
1096
+ c = GetChar(ts);
1097
+ if (JS_ISXMLSPACE(c)) {
1098
+ do {
1099
+ c = GetChar(ts);
1100
+ } while (JS_ISXMLSPACE(c));
1101
+ UngetChar(ts, c);
1102
+ tt = TOK_XMLSPACE;
1103
+ goto out;
1104
+ }
1105
+
1106
+ if (c == EOF) {
1107
+ tt = TOK_EOF;
1108
+ goto out;
1109
+ }
1110
+
1111
+ INIT_TOKENBUF();
1112
+ if (JS_ISXMLNSSTART(c)) {
1113
+ JSBool sawColon = JS_FALSE;
1114
+
1115
+ ADD_TO_TOKENBUF(c);
1116
+ while ((c = GetChar(ts)) != EOF && JS_ISXMLNAME(c)) {
1117
+ if (c == ':') {
1118
+ int nextc;
1119
+
1120
+ if (sawColon ||
1121
+ (nextc = PeekChar(ts),
1122
+ ((ts->flags & TSF_XMLONLYMODE) || nextc != '{') &&
1123
+ !JS_ISXMLNAME(nextc))) {
1124
+ js_ReportCompileErrorNumber(cx, ts, NULL,
1125
+ JSREPORT_ERROR,
1126
+ JSMSG_BAD_XML_QNAME);
1127
+ goto error;
1128
+ }
1129
+ sawColon = JS_TRUE;
1130
+ }
1131
+
1132
+ ADD_TO_TOKENBUF(c);
1133
+ }
1134
+
1135
+ UngetChar(ts, c);
1136
+ atom = TOKENBUF_TO_ATOM();
1137
+ if (!atom)
1138
+ goto error;
1139
+ tp->t_op = JSOP_STRING;
1140
+ tp->t_atom = atom;
1141
+ tt = TOK_XMLNAME;
1142
+ goto out;
1143
+ }
1144
+
1145
+ switch (c) {
1146
+ case '{':
1147
+ if (ts->flags & TSF_XMLONLYMODE)
1148
+ goto bad_xml_char;
1149
+ tt = TOK_LC;
1150
+ goto out;
1151
+
1152
+ case '=':
1153
+ tt = TOK_ASSIGN;
1154
+ goto out;
1155
+
1156
+ case '"':
1157
+ case '\'':
1158
+ qc = c;
1159
+ while ((c = GetChar(ts)) != qc) {
1160
+ if (c == EOF) {
1161
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1162
+ JSMSG_UNTERMINATED_STRING);
1163
+ goto error;
1164
+ }
1165
+
1166
+ /*
1167
+ * XML attribute values are double-quoted when pretty-printed,
1168
+ * so escape " if it is expressed directly in a single-quoted
1169
+ * attribute value.
1170
+ */
1171
+ if (c == '"' && !(ts->flags & TSF_XMLONLYMODE)) {
1172
+ JS_ASSERT(qc == '\'');
1173
+ js_AppendCString(&ts->tokenbuf, js_quot_entity_str);
1174
+ continue;
1175
+ }
1176
+
1177
+ if (c == '&' && (ts->flags & TSF_XMLONLYMODE)) {
1178
+ if (!GetXMLEntity(cx, ts))
1179
+ goto error;
1180
+ continue;
1181
+ }
1182
+
1183
+ ADD_TO_TOKENBUF(c);
1184
+ }
1185
+ atom = TOKENBUF_TO_ATOM();
1186
+ if (!atom)
1187
+ goto error;
1188
+ tp->pos.end.lineno = (uint16)ts->lineno;
1189
+ tp->t_op = JSOP_STRING;
1190
+ tp->t_atom = atom;
1191
+ tt = TOK_XMLATTR;
1192
+ goto out;
1193
+
1194
+ case '>':
1195
+ tt = TOK_XMLTAGC;
1196
+ goto out;
1197
+
1198
+ case '/':
1199
+ if (MatchChar(ts, '>')) {
1200
+ tt = TOK_XMLPTAGC;
1201
+ goto out;
1202
+ }
1203
+ /* FALL THROUGH */
1204
+
1205
+ bad_xml_char:
1206
+ default:
1207
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1208
+ JSMSG_BAD_XML_CHARACTER);
1209
+ goto error;
1210
+ }
1211
+ /* NOTREACHED */
1212
+ }
1213
+ #endif /* JS_HAS_XML_SUPPORT */
1214
+
1215
+ retry:
1216
+ do {
1217
+ c = GetChar(ts);
1218
+ if (c == '\n') {
1219
+ ts->flags &= ~TSF_DIRTYLINE;
1220
+ if (ts->flags & TSF_NEWLINES)
1221
+ break;
1222
+ }
1223
+ } while (ScanAsSpace((jschar)c));
1224
+
1225
+ tp = NewToken(ts, -1);
1226
+ if (c == EOF) {
1227
+ tt = TOK_EOF;
1228
+ goto out;
1229
+ }
1230
+
1231
+ hadUnicodeEscape = JS_FALSE;
1232
+ if (JS_ISIDSTART(c) ||
1233
+ (c == '\\' &&
1234
+ (qc = GetUnicodeEscape(ts),
1235
+ hadUnicodeEscape = JS_ISIDSTART(qc)))) {
1236
+ if (hadUnicodeEscape)
1237
+ c = qc;
1238
+ INIT_TOKENBUF();
1239
+ for (;;) {
1240
+ ADD_TO_TOKENBUF(c);
1241
+ c = GetChar(ts);
1242
+ if (c == '\\') {
1243
+ qc = GetUnicodeEscape(ts);
1244
+ if (!JS_ISIDENT(qc))
1245
+ break;
1246
+ c = qc;
1247
+ hadUnicodeEscape = JS_TRUE;
1248
+ } else {
1249
+ if (!JS_ISIDENT(c))
1250
+ break;
1251
+ }
1252
+ }
1253
+ UngetChar(ts, c);
1254
+
1255
+ /*
1256
+ * Check for keywords unless we saw Unicode escape or parser asks
1257
+ * to ignore keywords.
1258
+ */
1259
+ if (!hadUnicodeEscape &&
1260
+ !(ts->flags & TSF_KEYWORD_IS_NAME) &&
1261
+ TOKENBUF_OK() &&
1262
+ (kw = FindKeyword(TOKENBUF_BASE(), TOKENBUF_LENGTH()))) {
1263
+ if (kw->tokentype == TOK_RESERVED) {
1264
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1265
+ JSREPORT_WARNING |
1266
+ JSREPORT_STRICT,
1267
+ JSMSG_RESERVED_ID,
1268
+ kw->chars)) {
1269
+ goto error;
1270
+ }
1271
+ } else if (kw->version <= JSVERSION_NUMBER(cx)) {
1272
+ tt = kw->tokentype;
1273
+ tp->t_op = (JSOp) kw->op;
1274
+ goto out;
1275
+ }
1276
+ }
1277
+
1278
+ atom = TOKENBUF_TO_ATOM();
1279
+ if (!atom)
1280
+ goto error;
1281
+ tp->t_op = JSOP_NAME;
1282
+ tp->t_atom = atom;
1283
+ tt = TOK_NAME;
1284
+ goto out;
1285
+ }
1286
+
1287
+ if (JS7_ISDEC(c) || (c == '.' && JS7_ISDEC(PeekChar(ts)))) {
1288
+ jsint radix;
1289
+ const jschar *endptr;
1290
+ jsdouble dval;
1291
+
1292
+ radix = 10;
1293
+ INIT_TOKENBUF();
1294
+
1295
+ if (c == '0') {
1296
+ ADD_TO_TOKENBUF(c);
1297
+ c = GetChar(ts);
1298
+ if (JS_TOLOWER(c) == 'x') {
1299
+ ADD_TO_TOKENBUF(c);
1300
+ c = GetChar(ts);
1301
+ radix = 16;
1302
+ } else if (JS7_ISDEC(c)) {
1303
+ radix = 8;
1304
+ }
1305
+ }
1306
+
1307
+ while (JS7_ISHEX(c)) {
1308
+ if (radix < 16) {
1309
+ if (JS7_ISLET(c))
1310
+ break;
1311
+
1312
+ /*
1313
+ * We permit 08 and 09 as decimal numbers, which makes our
1314
+ * behaviour a superset of the ECMA numeric grammar. We might
1315
+ * not always be so permissive, so we warn about it.
1316
+ */
1317
+ if (radix == 8 && c >= '8') {
1318
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1319
+ JSREPORT_WARNING,
1320
+ JSMSG_BAD_OCTAL,
1321
+ c == '8' ? "08" : "09")) {
1322
+ goto error;
1323
+ }
1324
+ radix = 10;
1325
+ }
1326
+ }
1327
+ ADD_TO_TOKENBUF(c);
1328
+ c = GetChar(ts);
1329
+ }
1330
+
1331
+ if (radix == 10 && (c == '.' || JS_TOLOWER(c) == 'e')) {
1332
+ if (c == '.') {
1333
+ do {
1334
+ ADD_TO_TOKENBUF(c);
1335
+ c = GetChar(ts);
1336
+ } while (JS7_ISDEC(c));
1337
+ }
1338
+ if (JS_TOLOWER(c) == 'e') {
1339
+ ADD_TO_TOKENBUF(c);
1340
+ c = GetChar(ts);
1341
+ if (c == '+' || c == '-') {
1342
+ ADD_TO_TOKENBUF(c);
1343
+ c = GetChar(ts);
1344
+ }
1345
+ if (!JS7_ISDEC(c)) {
1346
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1347
+ JSMSG_MISSING_EXPONENT);
1348
+ goto error;
1349
+ }
1350
+ do {
1351
+ ADD_TO_TOKENBUF(c);
1352
+ c = GetChar(ts);
1353
+ } while (JS7_ISDEC(c));
1354
+ }
1355
+ }
1356
+
1357
+ /* Put back the next char and NUL-terminate tokenbuf for js_strto*. */
1358
+ UngetChar(ts, c);
1359
+ ADD_TO_TOKENBUF(0);
1360
+
1361
+ if (!TOKENBUF_OK())
1362
+ goto error;
1363
+ if (radix == 10) {
1364
+ if (!js_strtod(cx, TOKENBUF_BASE(), TOKENBUF_END(),
1365
+ &endptr, &dval)) {
1366
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1367
+ JSMSG_OUT_OF_MEMORY);
1368
+ goto error;
1369
+ }
1370
+ } else {
1371
+ if (!js_strtointeger(cx, TOKENBUF_BASE(), TOKENBUF_END(),
1372
+ &endptr, radix, &dval)) {
1373
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1374
+ JSMSG_OUT_OF_MEMORY);
1375
+ goto error;
1376
+ }
1377
+ }
1378
+ tp->t_dval = dval;
1379
+ tt = TOK_NUMBER;
1380
+ goto out;
1381
+ }
1382
+
1383
+ if (c == '"' || c == '\'') {
1384
+ qc = c;
1385
+ INIT_TOKENBUF();
1386
+ while ((c = GetChar(ts)) != qc) {
1387
+ if (c == '\n' || c == EOF) {
1388
+ UngetChar(ts, c);
1389
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1390
+ JSMSG_UNTERMINATED_STRING);
1391
+ goto error;
1392
+ }
1393
+ if (c == '\\') {
1394
+ switch (c = GetChar(ts)) {
1395
+ case 'b': c = '\b'; break;
1396
+ case 'f': c = '\f'; break;
1397
+ case 'n': c = '\n'; break;
1398
+ case 'r': c = '\r'; break;
1399
+ case 't': c = '\t'; break;
1400
+ case 'v': c = '\v'; break;
1401
+
1402
+ default:
1403
+ if ('0' <= c && c < '8') {
1404
+ int32 val = JS7_UNDEC(c);
1405
+
1406
+ c = PeekChar(ts);
1407
+ if ('0' <= c && c < '8') {
1408
+ val = 8 * val + JS7_UNDEC(c);
1409
+ GetChar(ts);
1410
+ c = PeekChar(ts);
1411
+ if ('0' <= c && c < '8') {
1412
+ int32 save = val;
1413
+ val = 8 * val + JS7_UNDEC(c);
1414
+ if (val <= 0377)
1415
+ GetChar(ts);
1416
+ else
1417
+ val = save;
1418
+ }
1419
+ }
1420
+
1421
+ c = (jschar)val;
1422
+ } else if (c == 'u') {
1423
+ jschar cp[4];
1424
+ if (PeekChars(ts, 4, cp) &&
1425
+ JS7_ISHEX(cp[0]) && JS7_ISHEX(cp[1]) &&
1426
+ JS7_ISHEX(cp[2]) && JS7_ISHEX(cp[3])) {
1427
+ c = (((((JS7_UNHEX(cp[0]) << 4)
1428
+ + JS7_UNHEX(cp[1])) << 4)
1429
+ + JS7_UNHEX(cp[2])) << 4)
1430
+ + JS7_UNHEX(cp[3]);
1431
+ SkipChars(ts, 4);
1432
+ }
1433
+ } else if (c == 'x') {
1434
+ jschar cp[2];
1435
+ if (PeekChars(ts, 2, cp) &&
1436
+ JS7_ISHEX(cp[0]) && JS7_ISHEX(cp[1])) {
1437
+ c = (JS7_UNHEX(cp[0]) << 4) + JS7_UNHEX(cp[1]);
1438
+ SkipChars(ts, 2);
1439
+ }
1440
+ } else if (c == '\n') {
1441
+ /* ECMA follows C by removing escaped newlines. */
1442
+ continue;
1443
+ }
1444
+ break;
1445
+ }
1446
+ }
1447
+ ADD_TO_TOKENBUF(c);
1448
+ }
1449
+ atom = TOKENBUF_TO_ATOM();
1450
+ if (!atom)
1451
+ goto error;
1452
+ tp->pos.end.lineno = (uint16)ts->lineno;
1453
+ tp->t_op = JSOP_STRING;
1454
+ tp->t_atom = atom;
1455
+ tt = TOK_STRING;
1456
+ goto out;
1457
+ }
1458
+
1459
+ switch (c) {
1460
+ case '\n': tt = TOK_EOL; goto eol_out;
1461
+ case ';': tt = TOK_SEMI; break;
1462
+ case '[': tt = TOK_LB; break;
1463
+ case ']': tt = TOK_RB; break;
1464
+ case '{': tt = TOK_LC; break;
1465
+ case '}': tt = TOK_RC; break;
1466
+ case '(': tt = TOK_LP; break;
1467
+ case ')': tt = TOK_RP; break;
1468
+ case ',': tt = TOK_COMMA; break;
1469
+ case '?': tt = TOK_HOOK; break;
1470
+
1471
+ case '.':
1472
+ #if JS_HAS_XML_SUPPORT
1473
+ if (MatchChar(ts, c))
1474
+ tt = TOK_DBLDOT;
1475
+ else
1476
+ #endif
1477
+ tt = TOK_DOT;
1478
+ break;
1479
+
1480
+ case ':':
1481
+ #if JS_HAS_XML_SUPPORT
1482
+ if (MatchChar(ts, c)) {
1483
+ tt = TOK_DBLCOLON;
1484
+ break;
1485
+ }
1486
+ #endif
1487
+ /*
1488
+ * Default so compiler can modify to JSOP_GETTER if 'p getter: v' in an
1489
+ * object initializer, likewise for setter.
1490
+ */
1491
+ tp->t_op = JSOP_NOP;
1492
+ tt = TOK_COLON;
1493
+ break;
1494
+
1495
+ case '|':
1496
+ if (MatchChar(ts, c)) {
1497
+ tt = TOK_OR;
1498
+ } else if (MatchChar(ts, '=')) {
1499
+ tp->t_op = JSOP_BITOR;
1500
+ tt = TOK_ASSIGN;
1501
+ } else {
1502
+ tt = TOK_BITOR;
1503
+ }
1504
+ break;
1505
+
1506
+ case '^':
1507
+ if (MatchChar(ts, '=')) {
1508
+ tp->t_op = JSOP_BITXOR;
1509
+ tt = TOK_ASSIGN;
1510
+ } else {
1511
+ tt = TOK_BITXOR;
1512
+ }
1513
+ break;
1514
+
1515
+ case '&':
1516
+ if (MatchChar(ts, c)) {
1517
+ tt = TOK_AND;
1518
+ } else if (MatchChar(ts, '=')) {
1519
+ tp->t_op = JSOP_BITAND;
1520
+ tt = TOK_ASSIGN;
1521
+ } else {
1522
+ tt = TOK_BITAND;
1523
+ }
1524
+ break;
1525
+
1526
+ case '=':
1527
+ if (MatchChar(ts, c)) {
1528
+ tp->t_op = MatchChar(ts, c) ? JSOP_STRICTEQ : JSOP_EQ;
1529
+ tt = TOK_EQOP;
1530
+ } else {
1531
+ tp->t_op = JSOP_NOP;
1532
+ tt = TOK_ASSIGN;
1533
+ }
1534
+ break;
1535
+
1536
+ case '!':
1537
+ if (MatchChar(ts, '=')) {
1538
+ tp->t_op = MatchChar(ts, '=') ? JSOP_STRICTNE : JSOP_NE;
1539
+ tt = TOK_EQOP;
1540
+ } else {
1541
+ tp->t_op = JSOP_NOT;
1542
+ tt = TOK_UNARYOP;
1543
+ }
1544
+ break;
1545
+
1546
+ #if JS_HAS_XML_SUPPORT
1547
+ case '@':
1548
+ tt = TOK_AT;
1549
+ break;
1550
+ #endif
1551
+
1552
+ case '<':
1553
+ #if JS_HAS_XML_SUPPORT
1554
+ /*
1555
+ * After much testing, it's clear that Postel's advice to protocol
1556
+ * designers ("be liberal in what you accept, and conservative in what
1557
+ * you send") invites a natural-law repercussion for JS as "protocol":
1558
+ *
1559
+ * "If you are liberal in what you accept, others will utterly fail to
1560
+ * be conservative in what they send."
1561
+ *
1562
+ * Which means you will get <!-- comments to end of line in the middle
1563
+ * of .js files, and after if conditions whose then statements are on
1564
+ * the next line, and other wonders. See at least the following bugs:
1565
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=309242
1566
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=309712
1567
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=310993
1568
+ *
1569
+ * So without JSOPTION_XML, we changed around Firefox 1.5 never to scan
1570
+ * an XML comment or CDATA literal. Instead, we always scan <! as the
1571
+ * start of an HTML comment hack to end of line, used since Netscape 2
1572
+ * to hide script tag content from script-unaware browsers.
1573
+ *
1574
+ * But this still leaves XML resources with certain internal structure
1575
+ * vulnerable to being loaded as script cross-origin, and some internal
1576
+ * data stolen, so for Firefox 3.5 and beyond, we reject programs whose
1577
+ * source consists only of XML literals. See:
1578
+ *
1579
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=336551
1580
+ *
1581
+ * The check for this is in jsparse.cpp, JSCompiler::compileScript.
1582
+ */
1583
+ if ((ts->flags & TSF_OPERAND) &&
1584
+ (JS_HAS_XML_OPTION(cx) || PeekChar(ts) != '!')) {
1585
+ /* Check for XML comment or CDATA section. */
1586
+ if (MatchChar(ts, '!')) {
1587
+ INIT_TOKENBUF();
1588
+
1589
+ /* Scan XML comment. */
1590
+ if (MatchChar(ts, '-')) {
1591
+ if (!MatchChar(ts, '-'))
1592
+ goto bad_xml_markup;
1593
+ while ((c = GetChar(ts)) != '-' || !MatchChar(ts, '-')) {
1594
+ if (c == EOF)
1595
+ goto bad_xml_markup;
1596
+ ADD_TO_TOKENBUF(c);
1597
+ }
1598
+ tt = TOK_XMLCOMMENT;
1599
+ tp->t_op = JSOP_XMLCOMMENT;
1600
+ goto finish_xml_markup;
1601
+ }
1602
+
1603
+ /* Scan CDATA section. */
1604
+ if (MatchChar(ts, '[')) {
1605
+ jschar cp[6];
1606
+ if (PeekChars(ts, 6, cp) &&
1607
+ cp[0] == 'C' &&
1608
+ cp[1] == 'D' &&
1609
+ cp[2] == 'A' &&
1610
+ cp[3] == 'T' &&
1611
+ cp[4] == 'A' &&
1612
+ cp[5] == '[') {
1613
+ SkipChars(ts, 6);
1614
+ while ((c = GetChar(ts)) != ']' ||
1615
+ !PeekChars(ts, 2, cp) ||
1616
+ cp[0] != ']' ||
1617
+ cp[1] != '>') {
1618
+ if (c == EOF)
1619
+ goto bad_xml_markup;
1620
+ ADD_TO_TOKENBUF(c);
1621
+ }
1622
+ GetChar(ts); /* discard ] but not > */
1623
+ tt = TOK_XMLCDATA;
1624
+ tp->t_op = JSOP_XMLCDATA;
1625
+ goto finish_xml_markup;
1626
+ }
1627
+ goto bad_xml_markup;
1628
+ }
1629
+ }
1630
+
1631
+ /* Check for processing instruction. */
1632
+ if (MatchChar(ts, '?')) {
1633
+ inTarget = JS_TRUE;
1634
+ targetLength = 0;
1635
+ contentIndex = -1;
1636
+
1637
+ INIT_TOKENBUF();
1638
+ while ((c = GetChar(ts)) != '?' || PeekChar(ts) != '>') {
1639
+ if (c == EOF)
1640
+ goto bad_xml_markup;
1641
+ if (inTarget) {
1642
+ if (JS_ISXMLSPACE(c)) {
1643
+ if (TOKENBUF_LENGTH() == 0)
1644
+ goto bad_xml_markup;
1645
+ inTarget = JS_FALSE;
1646
+ } else {
1647
+ if (!((TOKENBUF_LENGTH() == 0)
1648
+ ? JS_ISXMLNSSTART(c)
1649
+ : JS_ISXMLNS(c))) {
1650
+ goto bad_xml_markup;
1651
+ }
1652
+ ++targetLength;
1653
+ }
1654
+ } else {
1655
+ if (contentIndex < 0 && !JS_ISXMLSPACE(c))
1656
+ contentIndex = TOKENBUF_LENGTH();
1657
+ }
1658
+ ADD_TO_TOKENBUF(c);
1659
+ }
1660
+ if (targetLength == 0)
1661
+ goto bad_xml_markup;
1662
+ if (!TOKENBUF_OK())
1663
+ goto error;
1664
+ if (contentIndex < 0) {
1665
+ atom = cx->runtime->atomState.emptyAtom;
1666
+ } else {
1667
+ atom = js_AtomizeChars(cx,
1668
+ &TOKENBUF_CHAR(contentIndex),
1669
+ TOKENBUF_LENGTH() - contentIndex,
1670
+ 0);
1671
+ if (!atom)
1672
+ goto error;
1673
+ }
1674
+ TRIM_TOKENBUF(targetLength);
1675
+ tp->t_atom2 = atom;
1676
+ tt = TOK_XMLPI;
1677
+
1678
+ finish_xml_markup:
1679
+ if (!MatchChar(ts, '>'))
1680
+ goto bad_xml_markup;
1681
+ atom = TOKENBUF_TO_ATOM();
1682
+ if (!atom)
1683
+ goto error;
1684
+ tp->t_atom = atom;
1685
+ tp->pos.end.lineno = (uint16)ts->lineno;
1686
+ goto out;
1687
+ }
1688
+
1689
+ /* An XML start-of-tag character. */
1690
+ tt = MatchChar(ts, '/') ? TOK_XMLETAGO : TOK_XMLSTAGO;
1691
+ goto out;
1692
+
1693
+ bad_xml_markup:
1694
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1695
+ JSMSG_BAD_XML_MARKUP);
1696
+ goto error;
1697
+ }
1698
+ #endif /* JS_HAS_XML_SUPPORT */
1699
+
1700
+ /* NB: treat HTML begin-comment as comment-till-end-of-line */
1701
+ if (MatchChar(ts, '!')) {
1702
+ if (MatchChar(ts, '-')) {
1703
+ if (MatchChar(ts, '-')) {
1704
+ ts->flags |= TSF_IN_HTML_COMMENT;
1705
+ goto skipline;
1706
+ }
1707
+ UngetChar(ts, '-');
1708
+ }
1709
+ UngetChar(ts, '!');
1710
+ }
1711
+ if (MatchChar(ts, c)) {
1712
+ tp->t_op = JSOP_LSH;
1713
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_SHOP;
1714
+ } else {
1715
+ tp->t_op = MatchChar(ts, '=') ? JSOP_LE : JSOP_LT;
1716
+ tt = TOK_RELOP;
1717
+ }
1718
+ break;
1719
+
1720
+ case '>':
1721
+ if (MatchChar(ts, c)) {
1722
+ tp->t_op = MatchChar(ts, c) ? JSOP_URSH : JSOP_RSH;
1723
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_SHOP;
1724
+ } else {
1725
+ tp->t_op = MatchChar(ts, '=') ? JSOP_GE : JSOP_GT;
1726
+ tt = TOK_RELOP;
1727
+ }
1728
+ break;
1729
+
1730
+ case '*':
1731
+ tp->t_op = JSOP_MUL;
1732
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_STAR;
1733
+ break;
1734
+
1735
+ case '/':
1736
+ if (MatchChar(ts, '/')) {
1737
+ /*
1738
+ * Hack for source filters such as the Mozilla XUL preprocessor:
1739
+ * "//@line 123\n" sets the number of the *next* line after the
1740
+ * comment to 123.
1741
+ */
1742
+ if (JS_HAS_ATLINE_OPTION(cx)) {
1743
+ jschar cp[5];
1744
+ uintN i, line, temp;
1745
+ char filename[1024];
1746
+
1747
+ if (PeekChars(ts, 5, cp) &&
1748
+ cp[0] == '@' &&
1749
+ cp[1] == 'l' &&
1750
+ cp[2] == 'i' &&
1751
+ cp[3] == 'n' &&
1752
+ cp[4] == 'e') {
1753
+ SkipChars(ts, 5);
1754
+ while ((c = GetChar(ts)) != '\n' && ScanAsSpace((jschar)c))
1755
+ continue;
1756
+ if (JS7_ISDEC(c)) {
1757
+ line = JS7_UNDEC(c);
1758
+ while ((c = GetChar(ts)) != EOF && JS7_ISDEC(c)) {
1759
+ temp = 10 * line + JS7_UNDEC(c);
1760
+ if (temp < line) {
1761
+ /* Ignore overlarge line numbers. */
1762
+ goto skipline;
1763
+ }
1764
+ line = temp;
1765
+ }
1766
+ while (c != '\n' && ScanAsSpace((jschar)c))
1767
+ c = GetChar(ts);
1768
+ i = 0;
1769
+ if (c == '"') {
1770
+ while ((c = GetChar(ts)) != EOF && c != '"') {
1771
+ if (c == '\n') {
1772
+ UngetChar(ts, c);
1773
+ goto skipline;
1774
+ }
1775
+ if ((c >> 8) != 0 || i >= sizeof filename - 1)
1776
+ goto skipline;
1777
+ filename[i++] = (char) c;
1778
+ }
1779
+ if (c == '"') {
1780
+ while ((c = GetChar(ts)) != '\n' &&
1781
+ ScanAsSpace((jschar)c)) {
1782
+ continue;
1783
+ }
1784
+ }
1785
+ }
1786
+ filename[i] = '\0';
1787
+ if (c == '\n') {
1788
+ if (i > 0) {
1789
+ if (ts->flags & TSF_OWNFILENAME)
1790
+ JS_free(cx, (void *) ts->filename);
1791
+ ts->filename = JS_strdup(cx, filename);
1792
+ if (!ts->filename)
1793
+ goto error;
1794
+ ts->flags |= TSF_OWNFILENAME;
1795
+ }
1796
+ ts->lineno = line;
1797
+ }
1798
+ }
1799
+ UngetChar(ts, c);
1800
+ }
1801
+ }
1802
+
1803
+ skipline:
1804
+ /* Optimize line skipping if we are not in an HTML comment. */
1805
+ if (ts->flags & TSF_IN_HTML_COMMENT) {
1806
+ while ((c = GetChar(ts)) != EOF && c != '\n') {
1807
+ if (c == '-' && MatchChar(ts, '-') && MatchChar(ts, '>'))
1808
+ ts->flags &= ~TSF_IN_HTML_COMMENT;
1809
+ }
1810
+ } else {
1811
+ while ((c = GetChar(ts)) != EOF && c != '\n')
1812
+ continue;
1813
+ }
1814
+ UngetChar(ts, c);
1815
+ ts->cursor = (ts->cursor - 1) & NTOKENS_MASK;
1816
+ goto retry;
1817
+ }
1818
+
1819
+ if (MatchChar(ts, '*')) {
1820
+ uintN lineno = ts->lineno;
1821
+ while ((c = GetChar(ts)) != EOF &&
1822
+ !(c == '*' && MatchChar(ts, '/'))) {
1823
+ /* Ignore all characters until comment close. */
1824
+ }
1825
+ if (c == EOF) {
1826
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1827
+ JSMSG_UNTERMINATED_COMMENT);
1828
+ goto error;
1829
+ }
1830
+ if ((ts->flags & TSF_NEWLINES) && lineno != ts->lineno) {
1831
+ ts->flags &= ~TSF_DIRTYLINE;
1832
+ tt = TOK_EOL;
1833
+ goto eol_out;
1834
+ }
1835
+ ts->cursor = (ts->cursor - 1) & NTOKENS_MASK;
1836
+ goto retry;
1837
+ }
1838
+
1839
+ if (ts->flags & TSF_OPERAND) {
1840
+ uintN flags, length;
1841
+ JSBool inCharClass = JS_FALSE;
1842
+
1843
+ INIT_TOKENBUF();
1844
+ for (;;) {
1845
+ c = GetChar(ts);
1846
+ if (c == '\n' || c == EOF) {
1847
+ UngetChar(ts, c);
1848
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1849
+ JSMSG_UNTERMINATED_REGEXP);
1850
+ goto error;
1851
+ }
1852
+ if (c == '\\') {
1853
+ ADD_TO_TOKENBUF(c);
1854
+ c = GetChar(ts);
1855
+ } else if (c == '[') {
1856
+ inCharClass = JS_TRUE;
1857
+ } else if (c == ']') {
1858
+ inCharClass = JS_FALSE;
1859
+ } else if (c == '/' && !inCharClass) {
1860
+ /* For compat with IE, allow unescaped / in char classes. */
1861
+ break;
1862
+ }
1863
+ ADD_TO_TOKENBUF(c);
1864
+ }
1865
+ for (flags = 0, length = TOKENBUF_LENGTH() + 1; ; length++) {
1866
+ c = PeekChar(ts);
1867
+ if (c == 'g' && !(flags & JSREG_GLOB))
1868
+ flags |= JSREG_GLOB;
1869
+ else if (c == 'i' && !(flags & JSREG_FOLD))
1870
+ flags |= JSREG_FOLD;
1871
+ else if (c == 'm' && !(flags & JSREG_MULTILINE))
1872
+ flags |= JSREG_MULTILINE;
1873
+ else if (c == 'y' && !(flags & JSREG_STICKY))
1874
+ flags |= JSREG_STICKY;
1875
+ else
1876
+ break;
1877
+ GetChar(ts);
1878
+ }
1879
+ c = PeekChar(ts);
1880
+ if (JS7_ISLET(c)) {
1881
+ char buf[2] = { '\0' };
1882
+ tp->pos.begin.index += length + 1;
1883
+ buf[0] = (char)c;
1884
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1885
+ JSMSG_BAD_REGEXP_FLAG, buf);
1886
+ (void) GetChar(ts);
1887
+ goto error;
1888
+ }
1889
+ /* XXXbe fix jsregexp.c so it doesn't depend on NUL termination */
1890
+ if (!TOKENBUF_OK())
1891
+ goto error;
1892
+ NUL_TERM_TOKENBUF();
1893
+ tp->t_reflags = flags;
1894
+ tt = TOK_REGEXP;
1895
+ break;
1896
+ }
1897
+
1898
+ tp->t_op = JSOP_DIV;
1899
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_DIVOP;
1900
+ break;
1901
+
1902
+ case '%':
1903
+ tp->t_op = JSOP_MOD;
1904
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_DIVOP;
1905
+ break;
1906
+
1907
+ case '~':
1908
+ tp->t_op = JSOP_BITNOT;
1909
+ tt = TOK_UNARYOP;
1910
+ break;
1911
+
1912
+ case '+':
1913
+ if (MatchChar(ts, '=')) {
1914
+ tp->t_op = JSOP_ADD;
1915
+ tt = TOK_ASSIGN;
1916
+ } else if (MatchChar(ts, c)) {
1917
+ tt = TOK_INC;
1918
+ } else {
1919
+ tp->t_op = JSOP_POS;
1920
+ tt = TOK_PLUS;
1921
+ }
1922
+ break;
1923
+
1924
+ case '-':
1925
+ if (MatchChar(ts, '=')) {
1926
+ tp->t_op = JSOP_SUB;
1927
+ tt = TOK_ASSIGN;
1928
+ } else if (MatchChar(ts, c)) {
1929
+ if (PeekChar(ts) == '>' && !(ts->flags & TSF_DIRTYLINE)) {
1930
+ ts->flags &= ~TSF_IN_HTML_COMMENT;
1931
+ goto skipline;
1932
+ }
1933
+ tt = TOK_DEC;
1934
+ } else {
1935
+ tp->t_op = JSOP_NEG;
1936
+ tt = TOK_MINUS;
1937
+ }
1938
+ break;
1939
+
1940
+ #if JS_HAS_SHARP_VARS
1941
+ case '#':
1942
+ {
1943
+ uint32 n;
1944
+
1945
+ c = GetChar(ts);
1946
+ if (!JS7_ISDEC(c)) {
1947
+ UngetChar(ts, c);
1948
+ goto badchar;
1949
+ }
1950
+ n = (uint32)JS7_UNDEC(c);
1951
+ for (;;) {
1952
+ c = GetChar(ts);
1953
+ if (!JS7_ISDEC(c))
1954
+ break;
1955
+ n = 10 * n + JS7_UNDEC(c);
1956
+ if (n >= UINT16_LIMIT) {
1957
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1958
+ JSMSG_SHARPVAR_TOO_BIG);
1959
+ goto error;
1960
+ }
1961
+ }
1962
+ tp->t_dval = (jsdouble) n;
1963
+ if (JS_HAS_STRICT_OPTION(cx) &&
1964
+ (c == '=' || c == '#')) {
1965
+ char buf[20];
1966
+ JS_snprintf(buf, sizeof buf, "#%u%c", n, c);
1967
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1968
+ JSREPORT_WARNING |
1969
+ JSREPORT_STRICT,
1970
+ JSMSG_DEPRECATED_USAGE,
1971
+ buf)) {
1972
+ goto error;
1973
+ }
1974
+ }
1975
+ if (c == '=')
1976
+ tt = TOK_DEFSHARP;
1977
+ else if (c == '#')
1978
+ tt = TOK_USESHARP;
1979
+ else
1980
+ goto badchar;
1981
+ break;
1982
+ }
1983
+ #endif /* JS_HAS_SHARP_VARS */
1984
+
1985
+ #if JS_HAS_SHARP_VARS || JS_HAS_XML_SUPPORT
1986
+ badchar:
1987
+ #endif
1988
+
1989
+ default:
1990
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1991
+ JSMSG_ILLEGAL_CHARACTER);
1992
+ goto error;
1993
+ }
1994
+
1995
+ out:
1996
+ JS_ASSERT(tt != TOK_EOL);
1997
+ ts->flags |= TSF_DIRTYLINE;
1998
+
1999
+ eol_out:
2000
+ if (!STRING_BUFFER_OK(&ts->tokenbuf))
2001
+ tt = TOK_ERROR;
2002
+ JS_ASSERT(tt < TOK_LIMIT);
2003
+ tp->pos.end.index = ts->linepos +
2004
+ PTRDIFF(ts->linebuf.ptr, ts->linebuf.base, jschar) -
2005
+ ts->ungetpos;
2006
+ tp->type = tt;
2007
+ return tt;
2008
+
2009
+ error:
2010
+ tt = TOK_ERROR;
2011
+ ts->flags |= TSF_ERROR;
2012
+ goto out;
2013
+
2014
+ #undef INIT_TOKENBUF
2015
+ #undef TOKENBUF_LENGTH
2016
+ #undef TOKENBUF_OK
2017
+ #undef TOKENBUF_TO_ATOM
2018
+ #undef ADD_TO_TOKENBUF
2019
+ #undef TOKENBUF_BASE
2020
+ #undef TOKENBUF_CHAR
2021
+ #undef TRIM_TOKENBUF
2022
+ #undef NUL_TERM_TOKENBUF
2023
+ }
2024
+
2025
+ void
2026
+ js_UngetToken(JSTokenStream *ts)
2027
+ {
2028
+ JS_ASSERT(ts->lookahead < NTOKENS_MASK);
2029
+ ts->lookahead++;
2030
+ ts->cursor = (ts->cursor - 1) & NTOKENS_MASK;
2031
+ }
2032
+
2033
+ JSBool
2034
+ js_MatchToken(JSContext *cx, JSTokenStream *ts, JSTokenType tt)
2035
+ {
2036
+ if (js_GetToken(cx, ts) == tt)
2037
+ return JS_TRUE;
2038
+ js_UngetToken(ts);
2039
+ return JS_FALSE;
2040
+ }