distil 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (552) hide show
  1. data/Rakefile +28 -0
  2. data/VERSION +1 -0
  3. data/bin/distil +45 -0
  4. data/distil.gemspec +586 -0
  5. data/lib/bootstrap-template.js +56 -0
  6. data/lib/configurable.rb +125 -0
  7. data/lib/file-set.rb +42 -0
  8. data/lib/file-types/css-file.rb +75 -0
  9. data/lib/file-types/html-file.rb +11 -0
  10. data/lib/file-types/javascript-file.rb +98 -0
  11. data/lib/file-types/json-file.rb +14 -0
  12. data/lib/file-types/nib-file.rb +9 -0
  13. data/lib/jsdoc.conf +18 -0
  14. data/lib/jsl.conf +121 -0
  15. data/lib/project.rb +96 -0
  16. data/lib/source-file.rb +181 -0
  17. data/lib/target.rb +96 -0
  18. data/lib/task.rb +239 -0
  19. data/lib/tasks/copy-task.rb +21 -0
  20. data/lib/tasks/css-task.rb +18 -0
  21. data/lib/tasks/javascript-task.rb +125 -0
  22. data/lib/tasks/multiple-output-task.rb +134 -0
  23. data/lib/tasks/nib-task.rb +83 -0
  24. data/lib/tasks/output-task.rb +73 -0
  25. data/lib/tasks/single-output-task.rb +83 -0
  26. data/lib/tasks/test-task.rb +280 -0
  27. data/lib/test/HtmlTestReporter.js +127 -0
  28. data/lib/test/Test.js +248 -0
  29. data/lib/test/TestReporter.js +79 -0
  30. data/lib/test/TestRunner.js +132 -0
  31. data/lib/test/browser.rb +97 -0
  32. data/lib/test/scriptwrapper.html +10 -0
  33. data/lib/test/unittest.html +127 -0
  34. data/vendor/Makefile +35 -0
  35. data/vendor/extconf.rb +3 -0
  36. data/vendor/jsdoc-extras/plugins/distil-plugin.js +142 -0
  37. data/vendor/jsdoc-extras/plugins/interface-plugin.js +36 -0
  38. data/vendor/jsdoc-extras/templates/coherent/allclasses.tmpl +17 -0
  39. data/vendor/jsdoc-extras/templates/coherent/allfiles.tmpl +53 -0
  40. data/vendor/jsdoc-extras/templates/coherent/class.tmpl +803 -0
  41. data/vendor/jsdoc-extras/templates/coherent/index.tmpl +37 -0
  42. data/vendor/jsdoc-extras/templates/coherent/publish.js +242 -0
  43. data/vendor/jsdoc-extras/templates/coherent/showdown.js +421 -0
  44. data/vendor/jsdoc-extras/templates/coherent/static/code-footer.html +3 -0
  45. data/vendor/jsdoc-extras/templates/coherent/static/code-header.html +7 -0
  46. data/vendor/jsdoc-extras/templates/coherent/static/default.css +297 -0
  47. data/vendor/jsdoc-extras/templates/coherent/static/header.html +2 -0
  48. data/vendor/jsdoc-extras/templates/coherent/static/index.html +19 -0
  49. data/vendor/jsdoc-extras/templates/coherent/symbol.tmpl +35 -0
  50. data/vendor/jsdoc-toolkit/README.txt +183 -0
  51. data/vendor/jsdoc-toolkit/app/frame/Chain.js +102 -0
  52. data/vendor/jsdoc-toolkit/app/frame/Dumper.js +144 -0
  53. data/vendor/jsdoc-toolkit/app/frame/Hash.js +84 -0
  54. data/vendor/jsdoc-toolkit/app/frame/Link.js +171 -0
  55. data/vendor/jsdoc-toolkit/app/frame/Namespace.js +10 -0
  56. data/vendor/jsdoc-toolkit/app/frame/Opt.js +134 -0
  57. data/vendor/jsdoc-toolkit/app/frame/Reflection.js +26 -0
  58. data/vendor/jsdoc-toolkit/app/frame/String.js +93 -0
  59. data/vendor/jsdoc-toolkit/app/frame/Testrun.js +129 -0
  60. data/vendor/jsdoc-toolkit/app/frame.js +33 -0
  61. data/vendor/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
  62. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
  63. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
  64. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
  65. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
  66. data/vendor/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +204 -0
  67. data/vendor/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +300 -0
  68. data/vendor/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +126 -0
  69. data/vendor/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
  70. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
  71. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Parser.js +144 -0
  72. data/vendor/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
  73. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +644 -0
  74. data/vendor/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +241 -0
  75. data/vendor/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
  76. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
  77. data/vendor/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
  78. data/vendor/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
  79. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
  80. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Walker.js +499 -0
  81. data/vendor/jsdoc-toolkit/app/lib/JSDOC.js +106 -0
  82. data/vendor/jsdoc-toolkit/app/main.js +129 -0
  83. data/vendor/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
  84. data/vendor/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
  85. data/vendor/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
  86. data/vendor/jsdoc-toolkit/app/plugins/publishSrcHilite.js +54 -0
  87. data/vendor/jsdoc-toolkit/app/plugins/symbolLink.js +10 -0
  88. data/vendor/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
  89. data/vendor/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
  90. data/vendor/jsdoc-toolkit/app/run.js +348 -0
  91. data/vendor/jsdoc-toolkit/app/t/TestDoc.js +144 -0
  92. data/vendor/jsdoc-toolkit/app/t/runner.js +13 -0
  93. data/vendor/jsdoc-toolkit/app/test/addon.js +24 -0
  94. data/vendor/jsdoc-toolkit/app/test/anon_inner.js +14 -0
  95. data/vendor/jsdoc-toolkit/app/test/augments.js +31 -0
  96. data/vendor/jsdoc-toolkit/app/test/augments2.js +26 -0
  97. data/vendor/jsdoc-toolkit/app/test/borrows.js +46 -0
  98. data/vendor/jsdoc-toolkit/app/test/borrows2.js +23 -0
  99. data/vendor/jsdoc-toolkit/app/test/config.js +22 -0
  100. data/vendor/jsdoc-toolkit/app/test/constructs.js +18 -0
  101. data/vendor/jsdoc-toolkit/app/test/encoding.js +10 -0
  102. data/vendor/jsdoc-toolkit/app/test/encoding_other.js +12 -0
  103. data/vendor/jsdoc-toolkit/app/test/event.js +54 -0
  104. data/vendor/jsdoc-toolkit/app/test/exports.js +14 -0
  105. data/vendor/jsdoc-toolkit/app/test/functions_anon.js +39 -0
  106. data/vendor/jsdoc-toolkit/app/test/functions_nested.js +33 -0
  107. data/vendor/jsdoc-toolkit/app/test/global.js +13 -0
  108. data/vendor/jsdoc-toolkit/app/test/globals.js +25 -0
  109. data/vendor/jsdoc-toolkit/app/test/ignore.js +10 -0
  110. data/vendor/jsdoc-toolkit/app/test/inner.js +16 -0
  111. data/vendor/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
  112. data/vendor/jsdoc-toolkit/app/test/lend.js +33 -0
  113. data/vendor/jsdoc-toolkit/app/test/memberof.js +19 -0
  114. data/vendor/jsdoc-toolkit/app/test/memberof2.js +38 -0
  115. data/vendor/jsdoc-toolkit/app/test/memberof3.js +33 -0
  116. data/vendor/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
  117. data/vendor/jsdoc-toolkit/app/test/module.js +17 -0
  118. data/vendor/jsdoc-toolkit/app/test/name.js +19 -0
  119. data/vendor/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
  120. data/vendor/jsdoc-toolkit/app/test/nocode.js +13 -0
  121. data/vendor/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
  122. data/vendor/jsdoc-toolkit/app/test/overview.js +20 -0
  123. data/vendor/jsdoc-toolkit/app/test/param_inline.js +37 -0
  124. data/vendor/jsdoc-toolkit/app/test/params_optional.js +8 -0
  125. data/vendor/jsdoc-toolkit/app/test/prototype.js +17 -0
  126. data/vendor/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
  127. data/vendor/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
  128. data/vendor/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
  129. data/vendor/jsdoc-toolkit/app/test/public.js +10 -0
  130. data/vendor/jsdoc-toolkit/app/test/scripts/code.js +5 -0
  131. data/vendor/jsdoc-toolkit/app/test/scripts/notcode.txt +5 -0
  132. data/vendor/jsdoc-toolkit/app/test/shared.js +42 -0
  133. data/vendor/jsdoc-toolkit/app/test/shared2.js +2 -0
  134. data/vendor/jsdoc-toolkit/app/test/shortcuts.js +22 -0
  135. data/vendor/jsdoc-toolkit/app/test/static_this.js +13 -0
  136. data/vendor/jsdoc-toolkit/app/test/synonyms.js +31 -0
  137. data/vendor/jsdoc-toolkit/app/test/tosource.js +23 -0
  138. data/vendor/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
  139. data/vendor/jsdoc-toolkit/app/test.js +342 -0
  140. data/vendor/jsdoc-toolkit/changes.txt +116 -0
  141. data/vendor/jsdoc-toolkit/conf/sample.conf +31 -0
  142. data/vendor/jsdoc-toolkit/java/build.xml +36 -0
  143. data/vendor/jsdoc-toolkit/java/build_1.4.xml +36 -0
  144. data/vendor/jsdoc-toolkit/java/classes/js.jar +0 -0
  145. data/vendor/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
  146. data/vendor/jsdoc-toolkit/java/src/JsRun.java +21 -0
  147. data/vendor/jsdoc-toolkit/jsdebug.jar +0 -0
  148. data/vendor/jsdoc-toolkit/jsrun.jar +0 -0
  149. data/vendor/jsdoc-toolkit/jsrun.sh +53 -0
  150. data/vendor/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
  151. data/vendor/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
  152. data/vendor/jsdoc-toolkit/templates/jsdoc/class.tmpl +649 -0
  153. data/vendor/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
  154. data/vendor/jsdoc-toolkit/templates/jsdoc/publish.js +201 -0
  155. data/vendor/jsdoc-toolkit/templates/jsdoc/static/code-footer.html +3 -0
  156. data/vendor/jsdoc-toolkit/templates/jsdoc/static/code-header.html +14 -0
  157. data/vendor/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
  158. data/vendor/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
  159. data/vendor/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
  160. data/vendor/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
  161. data/vendor/jsl-0.3.0/src/JavaScriptLintAPI.cpp +333 -0
  162. data/vendor/jsl-0.3.0/src/JavaScriptLintAPI.h +86 -0
  163. data/vendor/jsl-0.3.0/src/Makefile.in +375 -0
  164. data/vendor/jsl-0.3.0/src/Makefile.ref +372 -0
  165. data/vendor/jsl-0.3.0/src/README.html +826 -0
  166. data/vendor/jsl-0.3.0/src/SpiderMonkey.rsp +12 -0
  167. data/vendor/jsl-0.3.0/src/_jsl_online.php +223 -0
  168. data/vendor/jsl-0.3.0/src/config/AIX4.1.mk +65 -0
  169. data/vendor/jsl-0.3.0/src/config/AIX4.2.mk +64 -0
  170. data/vendor/jsl-0.3.0/src/config/AIX4.3.mk +65 -0
  171. data/vendor/jsl-0.3.0/src/config/Darwin.mk +81 -0
  172. data/vendor/jsl-0.3.0/src/config/Darwin1.3.mk +81 -0
  173. data/vendor/jsl-0.3.0/src/config/Darwin1.4.mk +41 -0
  174. data/vendor/jsl-0.3.0/src/config/Darwin5.2.mk +81 -0
  175. data/vendor/jsl-0.3.0/src/config/Darwin5.3.mk +81 -0
  176. data/vendor/jsl-0.3.0/src/config/HP-UXB.10.10.mk +77 -0
  177. data/vendor/jsl-0.3.0/src/config/HP-UXB.10.20.mk +77 -0
  178. data/vendor/jsl-0.3.0/src/config/HP-UXB.11.00.mk +80 -0
  179. data/vendor/jsl-0.3.0/src/config/IRIX.mk +87 -0
  180. data/vendor/jsl-0.3.0/src/config/IRIX5.3.mk +44 -0
  181. data/vendor/jsl-0.3.0/src/config/IRIX6.1.mk +44 -0
  182. data/vendor/jsl-0.3.0/src/config/IRIX6.2.mk +44 -0
  183. data/vendor/jsl-0.3.0/src/config/IRIX6.3.mk +44 -0
  184. data/vendor/jsl-0.3.0/src/config/IRIX6.5.mk +44 -0
  185. data/vendor/jsl-0.3.0/src/config/Linux_All.mk +103 -0
  186. data/vendor/jsl-0.3.0/src/config/Mac_OS10.0.mk +82 -0
  187. data/vendor/jsl-0.3.0/src/config/OSF1V4.0.mk +72 -0
  188. data/vendor/jsl-0.3.0/src/config/OSF1V5.0.mk +69 -0
  189. data/vendor/jsl-0.3.0/src/config/SunOS4.1.4.mk +101 -0
  190. data/vendor/jsl-0.3.0/src/config/SunOS5.3.mk +91 -0
  191. data/vendor/jsl-0.3.0/src/config/SunOS5.4.mk +92 -0
  192. data/vendor/jsl-0.3.0/src/config/SunOS5.5.1.mk +44 -0
  193. data/vendor/jsl-0.3.0/src/config/SunOS5.5.mk +87 -0
  194. data/vendor/jsl-0.3.0/src/config/SunOS5.6.mk +89 -0
  195. data/vendor/jsl-0.3.0/src/config/SunOS5.7.mk +44 -0
  196. data/vendor/jsl-0.3.0/src/config/SunOS5.8.mk +44 -0
  197. data/vendor/jsl-0.3.0/src/config/SunOS5.9.mk +44 -0
  198. data/vendor/jsl-0.3.0/src/config/WINNT4.0.mk +112 -0
  199. data/vendor/jsl-0.3.0/src/config/WINNT5.0.mk +112 -0
  200. data/vendor/jsl-0.3.0/src/config/WINNT5.1.mk +112 -0
  201. data/vendor/jsl-0.3.0/src/config/WINNT5.2.mk +112 -0
  202. data/vendor/jsl-0.3.0/src/config/dgux.mk +64 -0
  203. data/vendor/jsl-0.3.0/src/config.mk +166 -0
  204. data/vendor/jsl-0.3.0/src/editline/Makefile.ref +144 -0
  205. data/vendor/jsl-0.3.0/src/editline/README +83 -0
  206. data/vendor/jsl-0.3.0/src/editline/editline.3 +175 -0
  207. data/vendor/jsl-0.3.0/src/editline/editline.c +1369 -0
  208. data/vendor/jsl-0.3.0/src/editline/editline.h +135 -0
  209. data/vendor/jsl-0.3.0/src/editline/sysunix.c +182 -0
  210. data/vendor/jsl-0.3.0/src/editline/unix.h +82 -0
  211. data/vendor/jsl-0.3.0/src/fdlibm/Makefile.in +127 -0
  212. data/vendor/jsl-0.3.0/src/fdlibm/Makefile.ref +192 -0
  213. data/vendor/jsl-0.3.0/src/fdlibm/e_acos.c +147 -0
  214. data/vendor/jsl-0.3.0/src/fdlibm/e_acosh.c +105 -0
  215. data/vendor/jsl-0.3.0/src/fdlibm/e_asin.c +156 -0
  216. data/vendor/jsl-0.3.0/src/fdlibm/e_atan2.c +165 -0
  217. data/vendor/jsl-0.3.0/src/fdlibm/e_atanh.c +110 -0
  218. data/vendor/jsl-0.3.0/src/fdlibm/e_cosh.c +133 -0
  219. data/vendor/jsl-0.3.0/src/fdlibm/e_exp.c +202 -0
  220. data/vendor/jsl-0.3.0/src/fdlibm/e_fmod.c +184 -0
  221. data/vendor/jsl-0.3.0/src/fdlibm/e_gamma.c +71 -0
  222. data/vendor/jsl-0.3.0/src/fdlibm/e_gamma_r.c +70 -0
  223. data/vendor/jsl-0.3.0/src/fdlibm/e_hypot.c +173 -0
  224. data/vendor/jsl-0.3.0/src/fdlibm/e_j0.c +524 -0
  225. data/vendor/jsl-0.3.0/src/fdlibm/e_j1.c +523 -0
  226. data/vendor/jsl-0.3.0/src/fdlibm/e_jn.c +315 -0
  227. data/vendor/jsl-0.3.0/src/fdlibm/e_lgamma.c +71 -0
  228. data/vendor/jsl-0.3.0/src/fdlibm/e_lgamma_r.c +347 -0
  229. data/vendor/jsl-0.3.0/src/fdlibm/e_log.c +184 -0
  230. data/vendor/jsl-0.3.0/src/fdlibm/e_log10.c +134 -0
  231. data/vendor/jsl-0.3.0/src/fdlibm/e_pow.c +386 -0
  232. data/vendor/jsl-0.3.0/src/fdlibm/e_rem_pio2.c +221 -0
  233. data/vendor/jsl-0.3.0/src/fdlibm/e_remainder.c +120 -0
  234. data/vendor/jsl-0.3.0/src/fdlibm/e_scalb.c +89 -0
  235. data/vendor/jsl-0.3.0/src/fdlibm/e_sinh.c +122 -0
  236. data/vendor/jsl-0.3.0/src/fdlibm/e_sqrt.c +497 -0
  237. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.dsp +160 -0
  238. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.h +273 -0
  239. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.mak +1453 -0
  240. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.mdp +0 -0
  241. data/vendor/jsl-0.3.0/src/fdlibm/k_cos.c +134 -0
  242. data/vendor/jsl-0.3.0/src/fdlibm/k_rem_pio2.c +354 -0
  243. data/vendor/jsl-0.3.0/src/fdlibm/k_sin.c +114 -0
  244. data/vendor/jsl-0.3.0/src/fdlibm/k_standard.c +785 -0
  245. data/vendor/jsl-0.3.0/src/fdlibm/k_tan.c +170 -0
  246. data/vendor/jsl-0.3.0/src/fdlibm/s_asinh.c +101 -0
  247. data/vendor/jsl-0.3.0/src/fdlibm/s_atan.c +175 -0
  248. data/vendor/jsl-0.3.0/src/fdlibm/s_cbrt.c +133 -0
  249. data/vendor/jsl-0.3.0/src/fdlibm/s_ceil.c +120 -0
  250. data/vendor/jsl-0.3.0/src/fdlibm/s_copysign.c +72 -0
  251. data/vendor/jsl-0.3.0/src/fdlibm/s_cos.c +118 -0
  252. data/vendor/jsl-0.3.0/src/fdlibm/s_erf.c +356 -0
  253. data/vendor/jsl-0.3.0/src/fdlibm/s_expm1.c +267 -0
  254. data/vendor/jsl-0.3.0/src/fdlibm/s_fabs.c +70 -0
  255. data/vendor/jsl-0.3.0/src/fdlibm/s_finite.c +71 -0
  256. data/vendor/jsl-0.3.0/src/fdlibm/s_floor.c +121 -0
  257. data/vendor/jsl-0.3.0/src/fdlibm/s_frexp.c +99 -0
  258. data/vendor/jsl-0.3.0/src/fdlibm/s_ilogb.c +85 -0
  259. data/vendor/jsl-0.3.0/src/fdlibm/s_isnan.c +74 -0
  260. data/vendor/jsl-0.3.0/src/fdlibm/s_ldexp.c +66 -0
  261. data/vendor/jsl-0.3.0/src/fdlibm/s_lib_version.c +73 -0
  262. data/vendor/jsl-0.3.0/src/fdlibm/s_log1p.c +211 -0
  263. data/vendor/jsl-0.3.0/src/fdlibm/s_logb.c +79 -0
  264. data/vendor/jsl-0.3.0/src/fdlibm/s_matherr.c +64 -0
  265. data/vendor/jsl-0.3.0/src/fdlibm/s_modf.c +132 -0
  266. data/vendor/jsl-0.3.0/src/fdlibm/s_nextafter.c +124 -0
  267. data/vendor/jsl-0.3.0/src/fdlibm/s_rint.c +131 -0
  268. data/vendor/jsl-0.3.0/src/fdlibm/s_scalbn.c +107 -0
  269. data/vendor/jsl-0.3.0/src/fdlibm/s_signgam.c +40 -0
  270. data/vendor/jsl-0.3.0/src/fdlibm/s_significand.c +68 -0
  271. data/vendor/jsl-0.3.0/src/fdlibm/s_sin.c +118 -0
  272. data/vendor/jsl-0.3.0/src/fdlibm/s_tan.c +112 -0
  273. data/vendor/jsl-0.3.0/src/fdlibm/s_tanh.c +122 -0
  274. data/vendor/jsl-0.3.0/src/fdlibm/w_acos.c +78 -0
  275. data/vendor/jsl-0.3.0/src/fdlibm/w_acosh.c +78 -0
  276. data/vendor/jsl-0.3.0/src/fdlibm/w_asin.c +80 -0
  277. data/vendor/jsl-0.3.0/src/fdlibm/w_atan2.c +79 -0
  278. data/vendor/jsl-0.3.0/src/fdlibm/w_atanh.c +81 -0
  279. data/vendor/jsl-0.3.0/src/fdlibm/w_cosh.c +77 -0
  280. data/vendor/jsl-0.3.0/src/fdlibm/w_exp.c +88 -0
  281. data/vendor/jsl-0.3.0/src/fdlibm/w_fmod.c +78 -0
  282. data/vendor/jsl-0.3.0/src/fdlibm/w_gamma.c +85 -0
  283. data/vendor/jsl-0.3.0/src/fdlibm/w_gamma_r.c +81 -0
  284. data/vendor/jsl-0.3.0/src/fdlibm/w_hypot.c +78 -0
  285. data/vendor/jsl-0.3.0/src/fdlibm/w_j0.c +105 -0
  286. data/vendor/jsl-0.3.0/src/fdlibm/w_j1.c +106 -0
  287. data/vendor/jsl-0.3.0/src/fdlibm/w_jn.c +128 -0
  288. data/vendor/jsl-0.3.0/src/fdlibm/w_lgamma.c +85 -0
  289. data/vendor/jsl-0.3.0/src/fdlibm/w_lgamma_r.c +81 -0
  290. data/vendor/jsl-0.3.0/src/fdlibm/w_log.c +78 -0
  291. data/vendor/jsl-0.3.0/src/fdlibm/w_log10.c +81 -0
  292. data/vendor/jsl-0.3.0/src/fdlibm/w_pow.c +99 -0
  293. data/vendor/jsl-0.3.0/src/fdlibm/w_remainder.c +77 -0
  294. data/vendor/jsl-0.3.0/src/fdlibm/w_scalb.c +95 -0
  295. data/vendor/jsl-0.3.0/src/fdlibm/w_sinh.c +77 -0
  296. data/vendor/jsl-0.3.0/src/fdlibm/w_sqrt.c +77 -0
  297. data/vendor/jsl-0.3.0/src/js.c +2447 -0
  298. data/vendor/jsl-0.3.0/src/js.dsp +420 -0
  299. data/vendor/jsl-0.3.0/src/js.mak +4025 -0
  300. data/vendor/jsl-0.3.0/src/js.mdp +0 -0
  301. data/vendor/jsl-0.3.0/src/js.msg +291 -0
  302. data/vendor/jsl-0.3.0/src/js.pkg +2 -0
  303. data/vendor/jsl-0.3.0/src/js3240.rc +79 -0
  304. data/vendor/jsl-0.3.0/src/jsOS240.def +654 -0
  305. data/vendor/jsl-0.3.0/src/jsapi.c +4405 -0
  306. data/vendor/jsl-0.3.0/src/jsapi.h +1856 -0
  307. data/vendor/jsl-0.3.0/src/jsarena.c +567 -0
  308. data/vendor/jsl-0.3.0/src/jsarena.h +302 -0
  309. data/vendor/jsl-0.3.0/src/jsarray.c +1428 -0
  310. data/vendor/jsl-0.3.0/src/jsarray.h +77 -0
  311. data/vendor/jsl-0.3.0/src/jsatom.c +927 -0
  312. data/vendor/jsl-0.3.0/src/jsatom.h +426 -0
  313. data/vendor/jsl-0.3.0/src/jsbit.h +113 -0
  314. data/vendor/jsl-0.3.0/src/jsbool.c +220 -0
  315. data/vendor/jsl-0.3.0/src/jsbool.h +62 -0
  316. data/vendor/jsl-0.3.0/src/jsclist.h +139 -0
  317. data/vendor/jsl-0.3.0/src/jscntxt.c +1036 -0
  318. data/vendor/jsl-0.3.0/src/jscntxt.h +608 -0
  319. data/vendor/jsl-0.3.0/src/jscompat.h +57 -0
  320. data/vendor/jsl-0.3.0/src/jsconfig.h +489 -0
  321. data/vendor/jsl-0.3.0/src/jsconfig.mk +181 -0
  322. data/vendor/jsl-0.3.0/src/jscpucfg.c +377 -0
  323. data/vendor/jsl-0.3.0/src/jscpucfg.h +204 -0
  324. data/vendor/jsl-0.3.0/src/jsdate.c +2238 -0
  325. data/vendor/jsl-0.3.0/src/jsdate.h +118 -0
  326. data/vendor/jsl-0.3.0/src/jsdbgapi.c +1260 -0
  327. data/vendor/jsl-0.3.0/src/jsdbgapi.h +345 -0
  328. data/vendor/jsl-0.3.0/src/jsdhash.c +763 -0
  329. data/vendor/jsl-0.3.0/src/jsdhash.h +579 -0
  330. data/vendor/jsl-0.3.0/src/jsdtoa.c +3135 -0
  331. data/vendor/jsl-0.3.0/src/jsdtoa.h +130 -0
  332. data/vendor/jsl-0.3.0/src/jsemit.c +4851 -0
  333. data/vendor/jsl-0.3.0/src/jsemit.h +576 -0
  334. data/vendor/jsl-0.3.0/src/jsexn.c +1084 -0
  335. data/vendor/jsl-0.3.0/src/jsexn.h +102 -0
  336. data/vendor/jsl-0.3.0/src/jsfile.c +2610 -0
  337. data/vendor/jsl-0.3.0/src/jsfile.h +50 -0
  338. data/vendor/jsl-0.3.0/src/jsfile.msg +89 -0
  339. data/vendor/jsl-0.3.0/src/jsfun.c +2015 -0
  340. data/vendor/jsl-0.3.0/src/jsfun.h +158 -0
  341. data/vendor/jsl-0.3.0/src/jsgc.c +1441 -0
  342. data/vendor/jsl-0.3.0/src/jsgc.h +230 -0
  343. data/vendor/jsl-0.3.0/src/jshash.c +471 -0
  344. data/vendor/jsl-0.3.0/src/jshash.h +152 -0
  345. data/vendor/jsl-0.3.0/src/jsify.pl +485 -0
  346. data/vendor/jsl-0.3.0/src/jsinterp.c +4797 -0
  347. data/vendor/jsl-0.3.0/src/jsinterp.h +302 -0
  348. data/vendor/jsl-0.3.0/src/jsl-test.js +28 -0
  349. data/vendor/jsl-0.3.0/src/jsl.c +2371 -0
  350. data/vendor/jsl-0.3.0/src/jsl.conf +127 -0
  351. data/vendor/jsl-0.3.0/src/jsl.conf.old +124 -0
  352. data/vendor/jsl-0.3.0/src/jsl.dsp +242 -0
  353. data/vendor/jsl-0.3.0/src/jsl.dsw +59 -0
  354. data/vendor/jsl-0.3.0/src/jslibmath.h +290 -0
  355. data/vendor/jsl-0.3.0/src/jslock.c +1261 -0
  356. data/vendor/jsl-0.3.0/src/jslock.h +289 -0
  357. data/vendor/jsl-0.3.0/src/jslocko.asm +59 -0
  358. data/vendor/jsl-0.3.0/src/jslog2.c +83 -0
  359. data/vendor/jsl-0.3.0/src/jslong.c +281 -0
  360. data/vendor/jsl-0.3.0/src/jslong.h +437 -0
  361. data/vendor/jsl-0.3.0/src/jsmath.c +477 -0
  362. data/vendor/jsl-0.3.0/src/jsmath.h +55 -0
  363. data/vendor/jsl-0.3.0/src/jsnum.c +1148 -0
  364. data/vendor/jsl-0.3.0/src/jsnum.h +257 -0
  365. data/vendor/jsl-0.3.0/src/jsobj.c +4066 -0
  366. data/vendor/jsl-0.3.0/src/jsobj.h +475 -0
  367. data/vendor/jsl-0.3.0/src/jsopcode.c +2730 -0
  368. data/vendor/jsl-0.3.0/src/jsopcode.h +275 -0
  369. data/vendor/jsl-0.3.0/src/jsopcode.tbl +344 -0
  370. data/vendor/jsl-0.3.0/src/jsosdep.h +127 -0
  371. data/vendor/jsl-0.3.0/src/jsotypes.h +211 -0
  372. data/vendor/jsl-0.3.0/src/jsparse.c +4438 -0
  373. data/vendor/jsl-0.3.0/src/jsparse.h +345 -0
  374. data/vendor/jsl-0.3.0/src/jsprf.c +1212 -0
  375. data/vendor/jsl-0.3.0/src/jsprf.h +148 -0
  376. data/vendor/jsl-0.3.0/src/jsprvtd.h +174 -0
  377. data/vendor/jsl-0.3.0/src/jspubtd.h +586 -0
  378. data/vendor/jsl-0.3.0/src/jsregexp.c +3831 -0
  379. data/vendor/jsl-0.3.0/src/jsregexp.h +180 -0
  380. data/vendor/jsl-0.3.0/src/jsscan.c +1814 -0
  381. data/vendor/jsl-0.3.0/src/jsscan.h +267 -0
  382. data/vendor/jsl-0.3.0/src/jsscope.c +1639 -0
  383. data/vendor/jsl-0.3.0/src/jsscope.h +389 -0
  384. data/vendor/jsl-0.3.0/src/jsscript.c +1284 -0
  385. data/vendor/jsl-0.3.0/src/jsscript.h +179 -0
  386. data/vendor/jsl-0.3.0/src/jsshell.msg +50 -0
  387. data/vendor/jsl-0.3.0/src/jsstddef.h +83 -0
  388. data/vendor/jsl-0.3.0/src/jsstr.c +4502 -0
  389. data/vendor/jsl-0.3.0/src/jsstr.h +448 -0
  390. data/vendor/jsl-0.3.0/src/jstypes.h +391 -0
  391. data/vendor/jsl-0.3.0/src/jsutil.c +157 -0
  392. data/vendor/jsl-0.3.0/src/jsutil.h +75 -0
  393. data/vendor/jsl-0.3.0/src/jsxdrapi.c +686 -0
  394. data/vendor/jsl-0.3.0/src/jsxdrapi.h +193 -0
  395. data/vendor/jsl-0.3.0/src/liveconnect/LiveConnect.dsp +157 -0
  396. data/vendor/jsl-0.3.0/src/liveconnect/LiveConnectShell.dsp +120 -0
  397. data/vendor/jsl-0.3.0/src/liveconnect/LiveConnectShell.dsw +44 -0
  398. data/vendor/jsl-0.3.0/src/liveconnect/Makefile.in +106 -0
  399. data/vendor/jsl-0.3.0/src/liveconnect/Makefile.ref +169 -0
  400. data/vendor/jsl-0.3.0/src/liveconnect/README.html +719 -0
  401. data/vendor/jsl-0.3.0/src/liveconnect/_jni/netscape_javascript_JSException.h +14 -0
  402. data/vendor/jsl-0.3.0/src/liveconnect/_jni/netscape_javascript_JSObject.h +155 -0
  403. data/vendor/jsl-0.3.0/src/liveconnect/classes/Makefile.in +89 -0
  404. data/vendor/jsl-0.3.0/src/liveconnect/classes/Makefile.ref +57 -0
  405. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/Makefile.ref +47 -0
  406. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSException.java +140 -0
  407. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSObject.java +183 -0
  408. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSProxy.java +58 -0
  409. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSRunnable.java +70 -0
  410. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSUtil.java +59 -0
  411. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/Makefile.ref +53 -0
  412. data/vendor/jsl-0.3.0/src/liveconnect/config/AIX4.1.mk +45 -0
  413. data/vendor/jsl-0.3.0/src/liveconnect/config/AIX4.2.mk +45 -0
  414. data/vendor/jsl-0.3.0/src/liveconnect/config/AIX4.3.mk +50 -0
  415. data/vendor/jsl-0.3.0/src/liveconnect/config/HP-UXB.10.10.mk +43 -0
  416. data/vendor/jsl-0.3.0/src/liveconnect/config/HP-UXB.10.20.mk +43 -0
  417. data/vendor/jsl-0.3.0/src/liveconnect/config/HP-UXB.11.00.mk +43 -0
  418. data/vendor/jsl-0.3.0/src/liveconnect/config/IRIX6.2.mk +43 -0
  419. data/vendor/jsl-0.3.0/src/liveconnect/config/IRIX6.3.mk +43 -0
  420. data/vendor/jsl-0.3.0/src/liveconnect/config/IRIX6.5.mk +43 -0
  421. data/vendor/jsl-0.3.0/src/liveconnect/config/Linux_All.mk +73 -0
  422. data/vendor/jsl-0.3.0/src/liveconnect/config/OSF1V4.0.mk +65 -0
  423. data/vendor/jsl-0.3.0/src/liveconnect/config/OSF1V5.0.mk +62 -0
  424. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.5.1.mk +55 -0
  425. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.6.mk +39 -0
  426. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.7.mk +39 -0
  427. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.8.mk +39 -0
  428. data/vendor/jsl-0.3.0/src/liveconnect/config/WINNT4.0.mk +53 -0
  429. data/vendor/jsl-0.3.0/src/liveconnect/jsj.c +884 -0
  430. data/vendor/jsl-0.3.0/src/liveconnect/jsj.msg +98 -0
  431. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JSObject.c +1379 -0
  432. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaArray.c +481 -0
  433. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaClass.c +749 -0
  434. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaMember.c +186 -0
  435. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaObject.c +1099 -0
  436. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaPackage.c +548 -0
  437. data/vendor/jsl-0.3.0/src/liveconnect/jsj_array.c +207 -0
  438. data/vendor/jsl-0.3.0/src/liveconnect/jsj_class.c +765 -0
  439. data/vendor/jsl-0.3.0/src/liveconnect/jsj_convert.c +954 -0
  440. data/vendor/jsl-0.3.0/src/liveconnect/jsj_field.c +421 -0
  441. data/vendor/jsl-0.3.0/src/liveconnect/jsj_hash.c +504 -0
  442. data/vendor/jsl-0.3.0/src/liveconnect/jsj_hash.h +161 -0
  443. data/vendor/jsl-0.3.0/src/liveconnect/jsj_method.c +1823 -0
  444. data/vendor/jsl-0.3.0/src/liveconnect/jsj_nodl.c +1 -0
  445. data/vendor/jsl-0.3.0/src/liveconnect/jsj_private.h +689 -0
  446. data/vendor/jsl-0.3.0/src/liveconnect/jsj_simpleapi.c +219 -0
  447. data/vendor/jsl-0.3.0/src/liveconnect/jsj_utils.c +513 -0
  448. data/vendor/jsl-0.3.0/src/liveconnect/jsjava.h +313 -0
  449. data/vendor/jsl-0.3.0/src/liveconnect/liveconnect.pkg +3 -0
  450. data/vendor/jsl-0.3.0/src/liveconnect/netscape_javascript_JSObject.h +155 -0
  451. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnect.cpp +785 -0
  452. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnect.h +197 -0
  453. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnectFactory.cpp +163 -0
  454. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnectFactory.h +76 -0
  455. data/vendor/jsl-0.3.0/src/liveconnect/nsILiveconnect.h +195 -0
  456. data/vendor/jsl-0.3.0/src/liveconnect/nsISecureLiveconnect.h +84 -0
  457. data/vendor/jsl-0.3.0/src/liveconnect/nsISecurityContext.h +135 -0
  458. data/vendor/jsl-0.3.0/src/liveconnect/win32.order +6 -0
  459. data/vendor/jsl-0.3.0/src/lock_SunOS.s +114 -0
  460. data/vendor/jsl-0.3.0/src/perfect.js +39 -0
  461. data/vendor/jsl-0.3.0/src/perlconnect/JS.def +6 -0
  462. data/vendor/jsl-0.3.0/src/perlconnect/JS.dsp +107 -0
  463. data/vendor/jsl-0.3.0/src/perlconnect/JS.pm +318 -0
  464. data/vendor/jsl-0.3.0/src/perlconnect/JS.xs +1050 -0
  465. data/vendor/jsl-0.3.0/src/perlconnect/Makefile.PL +67 -0
  466. data/vendor/jsl-0.3.0/src/perlconnect/Makefile.ref +152 -0
  467. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnect.dsp +103 -0
  468. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnect.dsw +59 -0
  469. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnect.pm +126 -0
  470. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnectShell.dsp +89 -0
  471. data/vendor/jsl-0.3.0/src/perlconnect/README.html +345 -0
  472. data/vendor/jsl-0.3.0/src/perlconnect/bg.jpg +0 -0
  473. data/vendor/jsl-0.3.0/src/perlconnect/jsperl.c +1100 -0
  474. data/vendor/jsl-0.3.0/src/perlconnect/jsperl.h +52 -0
  475. data/vendor/jsl-0.3.0/src/perlconnect/jsperlbuild.pl +81 -0
  476. data/vendor/jsl-0.3.0/src/perlconnect/jsperlpvt.h +57 -0
  477. data/vendor/jsl-0.3.0/src/perlconnect/test.js +73 -0
  478. data/vendor/jsl-0.3.0/src/perlconnect/test.pl +244 -0
  479. data/vendor/jsl-0.3.0/src/perlconnect/typemap +121 -0
  480. data/vendor/jsl-0.3.0/src/plify_jsdhash.sed +31 -0
  481. data/vendor/jsl-0.3.0/src/prmjtime.c +646 -0
  482. data/vendor/jsl-0.3.0/src/prmjtime.h +95 -0
  483. data/vendor/jsl-0.3.0/src/resource.h +15 -0
  484. data/vendor/jsl-0.3.0/src/rules.mk +193 -0
  485. data/vendor/jsl-0.3.0/src/win32.order +391 -0
  486. data/vendor/jsl-0.3.0/tests/conf/always_use_option_explicit.js +4 -0
  487. data/vendor/jsl-0.3.0/tests/conf/define.js +8 -0
  488. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-1.js +7 -0
  489. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-2.js +8 -0
  490. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-3.js +27 -0
  491. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-4.js +4 -0
  492. data/vendor/jsl-0.3.0/tests/conf/lambda_assign_requires_semicolon.js +24 -0
  493. data/vendor/jsl-0.3.0/tests/conf/legacy_control_comments.js +8 -0
  494. data/vendor/jsl-0.3.0/tests/control_comments/control_comments.js +33 -0
  495. data/vendor/jsl-0.3.0/tests/control_comments/declare.js +26 -0
  496. data/vendor/jsl-0.3.0/tests/control_comments/import-overflow.js +9 -0
  497. data/vendor/jsl-0.3.0/tests/control_comments/import.js +5 -0
  498. data/vendor/jsl-0.3.0/tests/control_comments/import2.js +2 -0
  499. data/vendor/jsl-0.3.0/tests/control_comments/invalid_fallthru.js +13 -0
  500. data/vendor/jsl-0.3.0/tests/control_comments/option_explicit-with.js +12 -0
  501. data/vendor/jsl-0.3.0/tests/control_comments/option_explicit.js +64 -0
  502. data/vendor/jsl-0.3.0/tests/errors/unterminated_comment.js +8 -0
  503. data/vendor/jsl-0.3.0/tests/html/script_tag_in_js_literal.html +14 -0
  504. data/vendor/jsl-0.3.0/tests/run_tests.pl +71 -0
  505. data/vendor/jsl-0.3.0/tests/warnings/ambiguous_else_stmt.js +21 -0
  506. data/vendor/jsl-0.3.0/tests/warnings/ambiguous_nested_stmt.js +66 -0
  507. data/vendor/jsl-0.3.0/tests/warnings/ambiguous_newline.js +261 -0
  508. data/vendor/jsl-0.3.0/tests/warnings/anon_no_return_value.js +26 -0
  509. data/vendor/jsl-0.3.0/tests/warnings/assign_to_function_call.js +16 -0
  510. data/vendor/jsl-0.3.0/tests/warnings/block_without_braces.js +13 -0
  511. data/vendor/jsl-0.3.0/tests/warnings/comma_separated_stmts.js +17 -0
  512. data/vendor/jsl-0.3.0/tests/warnings/comparison_type_conv.js +44 -0
  513. data/vendor/jsl-0.3.0/tests/warnings/default_not_at_end.js +15 -0
  514. data/vendor/jsl-0.3.0/tests/warnings/dup_option_explicit.js +5 -0
  515. data/vendor/jsl-0.3.0/tests/warnings/duplicate_case_in_switch.js +62 -0
  516. data/vendor/jsl-0.3.0/tests/warnings/duplicate_formal.js +5 -0
  517. data/vendor/jsl-0.3.0/tests/warnings/empty_statement.js +29 -0
  518. data/vendor/jsl-0.3.0/tests/warnings/equal_as_assign.js +7 -0
  519. data/vendor/jsl-0.3.0/tests/warnings/inc_dec_within_stmt-ignore.js +21 -0
  520. data/vendor/jsl-0.3.0/tests/warnings/inc_dec_within_stmt.js +63 -0
  521. data/vendor/jsl-0.3.0/tests/warnings/jsl_cc_not_understood.js +5 -0
  522. data/vendor/jsl-0.3.0/tests/warnings/leading_decimal_point.js +7 -0
  523. data/vendor/jsl-0.3.0/tests/warnings/legacy_cc_not_understood.js +9 -0
  524. data/vendor/jsl-0.3.0/tests/warnings/meaningless_block.js +12 -0
  525. data/vendor/jsl-0.3.0/tests/warnings/misplaced_regex.js +20 -0
  526. data/vendor/jsl-0.3.0/tests/warnings/missing_break.js +87 -0
  527. data/vendor/jsl-0.3.0/tests/warnings/missing_break_for_last_case.js +19 -0
  528. data/vendor/jsl-0.3.0/tests/warnings/missing_default_case.js +51 -0
  529. data/vendor/jsl-0.3.0/tests/warnings/missing_option_explicit.js +5 -0
  530. data/vendor/jsl-0.3.0/tests/warnings/missing_semicolon.js +19 -0
  531. data/vendor/jsl-0.3.0/tests/warnings/multiple_plus_minus.js +10 -0
  532. data/vendor/jsl-0.3.0/tests/warnings/nested_comment.js +6 -0
  533. data/vendor/jsl-0.3.0/tests/warnings/no_return_value.js +25 -0
  534. data/vendor/jsl-0.3.0/tests/warnings/octal_number.js +5 -0
  535. data/vendor/jsl-0.3.0/tests/warnings/parseint_missing_radix.js +15 -0
  536. data/vendor/jsl-0.3.0/tests/warnings/partial_option_explicit.js +5 -0
  537. data/vendor/jsl-0.3.0/tests/warnings/redeclared_var.js +10 -0
  538. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/bad_backref.js +5 -0
  539. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/deprecated_usage.js +11 -0
  540. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/invalid_backref.js +5 -0
  541. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/trailing_comma.js +5 -0
  542. data/vendor/jsl-0.3.0/tests/warnings/trailing_comma_in_array.js +8 -0
  543. data/vendor/jsl-0.3.0/tests/warnings/trailing_decimal_point.js +7 -0
  544. data/vendor/jsl-0.3.0/tests/warnings/unreachable_code.js +29 -0
  545. data/vendor/jsl-0.3.0/tests/warnings/use_of_label.js +19 -0
  546. data/vendor/jsl-0.3.0/tests/warnings/useless_assign.js +20 -0
  547. data/vendor/jsl-0.3.0/tests/warnings/useless_comparison.js +55 -0
  548. data/vendor/jsl-0.3.0/tests/warnings/useless_void.js +6 -0
  549. data/vendor/jsl-0.3.0/tests/warnings/var_hides_arg.js +4 -0
  550. data/vendor/jsl-0.3.0/tests/warnings/with_statement.js +7 -0
  551. data/vendor/yuicompressor-2.4.2.jar +0 -0
  552. metadata +605 -0
@@ -0,0 +1,1814 @@
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
+ /*
41
+ * JS lexical scanner.
42
+ */
43
+ #include "jsstddef.h"
44
+ #include <stdio.h> /* first to avoid trouble on some systems */
45
+ #include <errno.h>
46
+ #include <limits.h>
47
+ #include <math.h>
48
+ #ifdef HAVE_MEMORY_H
49
+ #include <memory.h>
50
+ #endif
51
+ #include <stdarg.h>
52
+ #include <stdlib.h>
53
+ #include <string.h>
54
+ #include "jstypes.h"
55
+ #include "jsarena.h" /* Added by JSIFY */
56
+ #include "jsutil.h" /* Added by JSIFY */
57
+ #include "jsdtoa.h"
58
+ #include "jsprf.h"
59
+ #include "jsapi.h"
60
+ #include "jsatom.h"
61
+ #include "jscntxt.h"
62
+ #include "jsconfig.h"
63
+ #include "jsemit.h"
64
+ #include "jsexn.h"
65
+ #include "jsnum.h"
66
+ #include "jsopcode.h"
67
+ #include "jsregexp.h"
68
+ #include "jsscan.h"
69
+
70
+ #define RESERVE_JAVA_KEYWORDS
71
+ #define RESERVE_ECMA_KEYWORDS
72
+
73
+ static struct keyword {
74
+ const char *name;
75
+ JSTokenType tokentype; /* JSTokenType */
76
+ JSOp op; /* JSOp */
77
+ JSVersion version; /* JSVersion */
78
+ } keywords[] = {
79
+ {"break", TOK_BREAK, JSOP_NOP, JSVERSION_DEFAULT},
80
+ {"case", TOK_CASE, JSOP_NOP, JSVERSION_DEFAULT},
81
+ {"continue", TOK_CONTINUE, JSOP_NOP, JSVERSION_DEFAULT},
82
+ {"default", TOK_DEFAULT, JSOP_NOP, JSVERSION_DEFAULT},
83
+ {js_delete_str, TOK_DELETE, JSOP_NOP, JSVERSION_DEFAULT},
84
+ {"do", TOK_DO, JSOP_NOP, JSVERSION_DEFAULT},
85
+ {"else", TOK_ELSE, JSOP_NOP, JSVERSION_DEFAULT},
86
+ {"export", TOK_EXPORT, JSOP_NOP, JSVERSION_1_2},
87
+ {js_false_str, TOK_PRIMARY, JSOP_FALSE, JSVERSION_DEFAULT},
88
+ {"for", TOK_FOR, JSOP_NOP, JSVERSION_DEFAULT},
89
+ {js_function_str, TOK_FUNCTION, JSOP_NOP, JSVERSION_DEFAULT},
90
+ {"if", TOK_IF, JSOP_NOP, JSVERSION_DEFAULT},
91
+ {js_in_str, TOK_IN, JSOP_IN, JSVERSION_DEFAULT},
92
+ {js_new_str, TOK_NEW, JSOP_NEW, JSVERSION_DEFAULT},
93
+ {js_null_str, TOK_PRIMARY, JSOP_NULL, JSVERSION_DEFAULT},
94
+ {"return", TOK_RETURN, JSOP_NOP, JSVERSION_DEFAULT},
95
+ {"switch", TOK_SWITCH, JSOP_NOP, JSVERSION_DEFAULT},
96
+ {js_this_str, TOK_PRIMARY, JSOP_THIS, JSVERSION_DEFAULT},
97
+ {js_true_str, TOK_PRIMARY, JSOP_TRUE, JSVERSION_DEFAULT},
98
+ {js_typeof_str, TOK_UNARYOP, JSOP_TYPEOF,JSVERSION_DEFAULT},
99
+ {"var", TOK_VAR, JSOP_DEFVAR,JSVERSION_DEFAULT},
100
+ {js_void_str, TOK_UNARYOP, JSOP_VOID, JSVERSION_DEFAULT},
101
+ {"while", TOK_WHILE, JSOP_NOP, JSVERSION_DEFAULT},
102
+ {"with", TOK_WITH, JSOP_NOP, JSVERSION_DEFAULT},
103
+
104
+ #if JS_HAS_CONST
105
+ {js_const_str, TOK_VAR, JSOP_DEFCONST,JSVERSION_DEFAULT},
106
+ #else
107
+ {js_const_str, TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
108
+ #endif
109
+
110
+ #if JS_HAS_EXCEPTIONS
111
+ {"try", TOK_TRY, JSOP_NOP, JSVERSION_DEFAULT},
112
+ {"catch", TOK_CATCH, JSOP_NOP, JSVERSION_DEFAULT},
113
+ {"finally", TOK_FINALLY, JSOP_NOP, JSVERSION_DEFAULT},
114
+ {"throw", TOK_THROW, JSOP_NOP, JSVERSION_DEFAULT},
115
+ #else
116
+ {"try", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
117
+ {"catch", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
118
+ {"finally", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
119
+ {"throw", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
120
+ #endif
121
+
122
+ #if JS_HAS_INSTANCEOF
123
+ {js_instanceof_str, TOK_INSTANCEOF, JSOP_INSTANCEOF,JSVERSION_1_4},
124
+ #else
125
+ {js_instanceof_str, TOK_RESERVED, JSOP_NOP, JSVERSION_1_4},
126
+ #endif
127
+
128
+ #ifdef RESERVE_JAVA_KEYWORDS
129
+ {"abstract", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
130
+ {"boolean", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
131
+ {"byte", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
132
+ {"char", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
133
+ {"class", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
134
+ {"double", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
135
+ {"extends", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
136
+ {"final", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
137
+ {"float", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
138
+ {"goto", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
139
+ {"implements", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
140
+ {"import", TOK_IMPORT, JSOP_NOP, JSVERSION_DEFAULT},
141
+ {"int", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
142
+ {"interface", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
143
+ {"long", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
144
+ {"native", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
145
+ {"package", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
146
+ {"private", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
147
+ {"protected", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
148
+ {"public", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
149
+ {"short", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
150
+ {"static", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
151
+ {"super", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
152
+ {"synchronized", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
153
+ {"throws", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
154
+ {"transient", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
155
+ {"volatile", TOK_RESERVED, JSOP_NOP, JSVERSION_DEFAULT},
156
+ #endif
157
+
158
+ #ifdef RESERVE_ECMA_KEYWORDS
159
+ {"enum", TOK_RESERVED, JSOP_NOP, JSVERSION_1_3},
160
+ #endif
161
+
162
+ #if JS_HAS_DEBUGGER_KEYWORD
163
+ {"debugger", TOK_DEBUGGER, JSOP_NOP, JSVERSION_1_3},
164
+ #elif defined(RESERVE_ECMA_KEYWORDS)
165
+ {"debugger", TOK_RESERVED, JSOP_NOP, JSVERSION_1_3},
166
+ #endif
167
+ {0, TOK_EOF, JSOP_NOP, JSVERSION_DEFAULT}
168
+ };
169
+
170
+ JSBool
171
+ js_InitScanner(JSContext *cx)
172
+ {
173
+ struct keyword *kw;
174
+ JSAtom *atom;
175
+
176
+ for (kw = keywords; kw->name; kw++) {
177
+ atom = js_Atomize(cx, kw->name, strlen(kw->name), ATOM_PINNED);
178
+ if (!atom)
179
+ return JS_FALSE;
180
+ ATOM_SET_KEYWORD(atom, kw);
181
+ }
182
+ return JS_TRUE;
183
+ }
184
+
185
+ JS_FRIEND_API(void)
186
+ js_MapKeywords(void (*mapfun)(const char *))
187
+ {
188
+ struct keyword *kw;
189
+
190
+ for (kw = keywords; kw->name; kw++)
191
+ mapfun(kw->name);
192
+ }
193
+
194
+ JSTokenStream *
195
+ js_NewTokenStream(JSContext *cx, const jschar *base, size_t length,
196
+ const char *filename, uintN lineno,
197
+ JSPrincipals *principals)
198
+ {
199
+ JSTokenStream *ts;
200
+
201
+ ts = js_NewBufferTokenStream(cx, base, length);
202
+ if (!ts)
203
+ return NULL;
204
+ ts->filename = filename;
205
+ ts->lineno = lineno;
206
+ if (principals)
207
+ JSPRINCIPALS_HOLD(cx, principals);
208
+ ts->principals = principals;
209
+ return ts;
210
+ }
211
+
212
+ JS_FRIEND_API(JSTokenStream *)
213
+ js_NewBufferTokenStream(JSContext *cx, const jschar *base, size_t length)
214
+ {
215
+ size_t nb;
216
+ JSTokenStream *ts;
217
+
218
+ nb = sizeof(JSTokenStream) + JS_LINE_LIMIT * sizeof(jschar);
219
+ JS_ARENA_ALLOCATE_CAST(ts, JSTokenStream *, &cx->tempPool, nb);
220
+ if (!ts) {
221
+ JS_ReportOutOfMemory(cx);
222
+ return NULL;
223
+ }
224
+ memset(ts, 0, nb);
225
+ ts->lineno = 1;
226
+ ts->linebuf.base = ts->linebuf.limit = ts->linebuf.ptr = (jschar *)(ts + 1);
227
+ ts->userbuf.base = (jschar *)base;
228
+ ts->userbuf.limit = (jschar *)base + length;
229
+ ts->userbuf.ptr = (jschar *)base;
230
+ ts->listener = cx->runtime->sourceHandler;
231
+ ts->listenerData = cx->runtime->sourceHandlerData;
232
+ return ts;
233
+ }
234
+
235
+ JS_FRIEND_API(JSTokenStream *)
236
+ js_NewFileTokenStream(JSContext *cx, const char *filename, FILE *defaultfp)
237
+ {
238
+ jschar *base;
239
+ JSTokenStream *ts;
240
+ FILE *file;
241
+
242
+ JS_ARENA_ALLOCATE_CAST(base, jschar *, &cx->tempPool,
243
+ JS_LINE_LIMIT * sizeof(jschar));
244
+ if (!base)
245
+ return NULL;
246
+ ts = js_NewBufferTokenStream(cx, base, JS_LINE_LIMIT);
247
+ if (!ts)
248
+ return NULL;
249
+ if (!filename || strcmp(filename, "-") == 0) {
250
+ file = defaultfp;
251
+ } else {
252
+ file = fopen(filename, "r");
253
+ if (!file) {
254
+ JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_OPEN,
255
+ filename, "No such file or directory");
256
+ return NULL;
257
+ }
258
+ }
259
+ ts->userbuf.ptr = ts->userbuf.limit;
260
+ ts->file = file;
261
+ ts->filename = filename;
262
+ return ts;
263
+ }
264
+
265
+ JS_FRIEND_API(JSBool)
266
+ js_CloseTokenStream(JSContext *cx, JSTokenStream *ts)
267
+ {
268
+ if (ts->flags & TSF_OWNFILENAME)
269
+ JS_free(cx, (void *) ts->filename);
270
+ if (ts->principals)
271
+ JSPRINCIPALS_DROP(cx, ts->principals);
272
+ return !ts->file || fclose(ts->file) == 0;
273
+ }
274
+
275
+ static int
276
+ my_fgets(char *buf, int size, FILE *file)
277
+ {
278
+ int n, i, c;
279
+ JSBool crflag;
280
+
281
+ n = size - 1;
282
+ if (n < 0)
283
+ return -1;
284
+
285
+ crflag = JS_FALSE;
286
+ for (i = 0; i < n && (c = getc(file)) != EOF; i++) {
287
+ buf[i] = c;
288
+ if (c == '\n') { /* any \n ends a line */
289
+ i++; /* keep the \n; we know there is room for \0 */
290
+ break;
291
+ }
292
+ if (crflag) { /* \r not followed by \n ends line at the \r */
293
+ ungetc(c, file);
294
+ break; /* and overwrite c in buf with \0 */
295
+ }
296
+ crflag = (c == '\r');
297
+ }
298
+
299
+ buf[i] = '\0';
300
+ return i;
301
+ }
302
+
303
+ static int32
304
+ GetChar(JSTokenStream *ts)
305
+ {
306
+ int32 c;
307
+ ptrdiff_t i, j, len, olen;
308
+ JSBool crflag;
309
+ char cbuf[JS_LINE_LIMIT];
310
+ jschar *ubuf, *nl;
311
+
312
+ if (ts->ungetpos != 0) {
313
+ c = ts->ungetbuf[--ts->ungetpos];
314
+ } else {
315
+ do {
316
+ if (ts->linebuf.ptr == ts->linebuf.limit) {
317
+ len = PTRDIFF(ts->userbuf.limit, ts->userbuf.ptr, jschar);
318
+ if (len <= 0) {
319
+ if (!ts->file) {
320
+ ts->flags |= TSF_EOF;
321
+ return EOF;
322
+ }
323
+
324
+ /* Fill ts->userbuf so that \r and \r\n convert to \n. */
325
+ crflag = (ts->flags & TSF_CRFLAG) != 0;
326
+ len = my_fgets(cbuf, JS_LINE_LIMIT - crflag, ts->file);
327
+ if (len <= 0) {
328
+ ts->flags |= TSF_EOF;
329
+ return EOF;
330
+ }
331
+ olen = len;
332
+ ubuf = ts->userbuf.base;
333
+ i = 0;
334
+ if (crflag) {
335
+ ts->flags &= ~TSF_CRFLAG;
336
+ if (cbuf[0] != '\n') {
337
+ ubuf[i++] = '\n';
338
+ len++;
339
+ ts->linepos--;
340
+ }
341
+ }
342
+ for (j = 0; i < len; i++, j++)
343
+ ubuf[i] = (jschar) (unsigned char) cbuf[j];
344
+ ts->userbuf.limit = ubuf + len;
345
+ ts->userbuf.ptr = ubuf;
346
+ }
347
+ if (ts->listener) {
348
+ ts->listener(ts->filename, ts->lineno, ts->userbuf.ptr, len,
349
+ &ts->listenerTSData, ts->listenerData);
350
+ }
351
+
352
+ nl = ts->saveEOL;
353
+ if (!nl) {
354
+ /*
355
+ * Any one of \n, \r, or \r\n ends a line (the longest
356
+ * match wins). Also allow the Unicode line and paragraph
357
+ * separators.
358
+ */
359
+ for (nl = ts->userbuf.ptr; nl < ts->userbuf.limit; nl++) {
360
+ /*
361
+ * Try to prevent value-testing on most characters by
362
+ * filtering out characters that aren't 000x or 202x.
363
+ */
364
+ if ((*nl & 0xDFD0) == 0) {
365
+ if (*nl == '\n')
366
+ break;
367
+ if (*nl == '\r') {
368
+ if (nl + 1 < ts->userbuf.limit && nl[1] == '\n')
369
+ nl++;
370
+ break;
371
+ }
372
+ if (*nl == LINE_SEPARATOR || *nl == PARA_SEPARATOR)
373
+ break;
374
+ }
375
+ }
376
+ }
377
+
378
+ /*
379
+ * If there was a line terminator, copy thru it into linebuf.
380
+ * Else copy JS_LINE_LIMIT-1 bytes into linebuf.
381
+ */
382
+ if (nl < ts->userbuf.limit)
383
+ len = PTRDIFF(nl, ts->userbuf.ptr, jschar) + 1;
384
+ if (len >= JS_LINE_LIMIT) {
385
+ len = JS_LINE_LIMIT - 1;
386
+ ts->saveEOL = nl;
387
+ } else {
388
+ ts->saveEOL = NULL;
389
+ }
390
+ js_strncpy(ts->linebuf.base, ts->userbuf.ptr, len);
391
+ ts->userbuf.ptr += len;
392
+ olen = len;
393
+
394
+ /*
395
+ * Make sure linebuf contains \n for EOL (don't do this in
396
+ * userbuf because the user's string might be readonly).
397
+ */
398
+ if (nl < ts->userbuf.limit) {
399
+ if (*nl == '\r') {
400
+ if (ts->linebuf.base[len-1] == '\r') {
401
+ /*
402
+ * Does the line segment end in \r? We must check
403
+ * for a \n at the front of the next segment before
404
+ * storing a \n into linebuf. This case matters
405
+ * only when we're reading from a file.
406
+ */
407
+ if (nl + 1 == ts->userbuf.limit && ts->file) {
408
+ len--;
409
+ ts->flags |= TSF_CRFLAG; /* clear NLFLAG? */
410
+ if (len == 0) {
411
+ /*
412
+ * This can happen when a segment ends in
413
+ * \r\r. Start over. ptr == limit in this
414
+ * case, so we'll fall into buffer-filling
415
+ * code.
416
+ */
417
+ return GetChar(ts);
418
+ }
419
+ } else {
420
+ ts->linebuf.base[len-1] = '\n';
421
+ }
422
+ }
423
+ } else if (*nl == '\n') {
424
+ if (nl > ts->userbuf.base &&
425
+ nl[-1] == '\r' &&
426
+ ts->linebuf.base[len-2] == '\r') {
427
+ len--;
428
+ JS_ASSERT(ts->linebuf.base[len] == '\n');
429
+ ts->linebuf.base[len-1] = '\n';
430
+ }
431
+ } else if (*nl == LINE_SEPARATOR || *nl == PARA_SEPARATOR) {
432
+ ts->linebuf.base[len-1] = '\n';
433
+ }
434
+ }
435
+
436
+ /* Reset linebuf based on adjusted segment length. */
437
+ ts->linebuf.limit = ts->linebuf.base + len;
438
+ ts->linebuf.ptr = ts->linebuf.base;
439
+
440
+ /* Update position of linebuf within physical userbuf line. */
441
+ if (!(ts->flags & TSF_NLFLAG))
442
+ ts->linepos += ts->linelen;
443
+ else
444
+ ts->linepos = 0;
445
+ if (ts->linebuf.limit[-1] == '\n')
446
+ ts->flags |= TSF_NLFLAG;
447
+ else
448
+ ts->flags &= ~TSF_NLFLAG;
449
+
450
+ /* Update linelen from original segment length. */
451
+ ts->linelen = olen;
452
+ }
453
+ c = *ts->linebuf.ptr++;
454
+ } while (JS_ISFORMAT(c));
455
+ }
456
+ if (c == '\n')
457
+ ts->lineno++;
458
+ return c;
459
+ }
460
+
461
+ static void
462
+ UngetChar(JSTokenStream *ts, int32 c)
463
+ {
464
+ if (c == EOF)
465
+ return;
466
+ JS_ASSERT(ts->ungetpos < sizeof ts->ungetbuf / sizeof ts->ungetbuf[0]);
467
+ if (c == '\n')
468
+ ts->lineno--;
469
+ ts->ungetbuf[ts->ungetpos++] = (jschar)c;
470
+ }
471
+
472
+ static int32
473
+ PeekChar(JSTokenStream *ts)
474
+ {
475
+ int32 c;
476
+
477
+ c = GetChar(ts);
478
+ UngetChar(ts, c);
479
+ return c;
480
+ }
481
+
482
+ static JSBool
483
+ PeekChars(JSTokenStream *ts, intN n, jschar *cp)
484
+ {
485
+ intN i, j;
486
+ int32 c;
487
+
488
+ for (i = 0; i < n; i++) {
489
+ c = GetChar(ts);
490
+ if (c == EOF)
491
+ break;
492
+ cp[i] = (jschar)c;
493
+ }
494
+ for (j = i - 1; j >= 0; j--)
495
+ UngetChar(ts, cp[j]);
496
+ return i == n;
497
+ }
498
+
499
+ static void
500
+ SkipChars(JSTokenStream *ts, intN n)
501
+ {
502
+ while (--n >= 0)
503
+ GetChar(ts);
504
+ }
505
+
506
+ static JSBool
507
+ MatchChar(JSTokenStream *ts, int32 expect)
508
+ {
509
+ int32 c;
510
+
511
+ c = GetChar(ts);
512
+ if (c == expect)
513
+ return JS_TRUE;
514
+ UngetChar(ts, c);
515
+ return JS_FALSE;
516
+ }
517
+
518
+ JSBool
519
+ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts,
520
+ JSCodeGenerator *cg, uintN flags,
521
+ const uintN errorNumber, ...)
522
+ {
523
+ va_list ap;
524
+ JSErrorReporter onError;
525
+ JSErrorReport report;
526
+ jschar *tokenptr;
527
+ JSString *linestr = NULL;
528
+ char *message;
529
+ JSBool warning;
530
+
531
+ if ((flags & JSREPORT_STRICT) && !JS_HAS_STRICT_OPTION(cx))
532
+ return JS_TRUE;
533
+
534
+ memset(&report, 0, sizeof (struct JSErrorReport));
535
+ report.flags = flags;
536
+ report.errorNumber = errorNumber;
537
+ message = NULL;
538
+
539
+ va_start(ap, errorNumber);
540
+ if (!js_ExpandErrorArguments(cx, js_GetErrorMessage, NULL,
541
+ errorNumber, &message, &report, &warning,
542
+ JS_TRUE, ap)) {
543
+ return JS_FALSE;
544
+ }
545
+ va_end(ap);
546
+
547
+ js_AddRoot(cx, &linestr, "error line buffer");
548
+
549
+ JS_ASSERT(!ts || ts->linebuf.limit < ts->linebuf.base + JS_LINE_LIMIT);
550
+ onError = cx->errorReporter;
551
+ if (onError) {
552
+ /*
553
+ * We are typically called with non-null ts and null cg from jsparse.c.
554
+ * We can be called with null ts from the regexp compilation functions.
555
+ * The code generator (jsemit.c) may pass null ts and non-null cg.
556
+ */
557
+ if (ts) {
558
+ report.filename = ts->filename;
559
+ report.lineno = ts->lineno;
560
+ linestr = js_NewStringCopyN(cx, ts->linebuf.base,
561
+ ts->linebuf.limit - ts->linebuf.base,
562
+ 0);
563
+ report.linebuf = linestr
564
+ ? JS_GetStringBytes(linestr)
565
+ : NULL;
566
+ tokenptr =
567
+ ts->tokens[(ts->cursor + ts->lookahead) & NTOKENS_MASK].ptr;
568
+ report.tokenptr = linestr
569
+ ? report.linebuf + (tokenptr - ts->linebuf.base)
570
+ : NULL;
571
+ report.uclinebuf = linestr
572
+ ? JS_GetStringChars(linestr)
573
+ : NULL;
574
+ report.uctokenptr = linestr
575
+ ? report.uclinebuf + (tokenptr - ts->linebuf.base)
576
+ : NULL;
577
+ } else if (cg) {
578
+ report.filename = cg->filename;
579
+ report.lineno = CG_CURRENT_LINE(cg);
580
+ }
581
+
582
+ #if JS_HAS_ERROR_EXCEPTIONS
583
+ /*
584
+ * If there's a runtime exception type associated with this error
585
+ * number, set that as the pending exception. For errors occuring at
586
+ * compile time, this is very likely to be a JSEXN_SYNTAXERR.
587
+ *
588
+ * If an exception is thrown but not caught, the JSREPORT_EXCEPTION
589
+ * flag will be set in report.flags. Proper behavior for an error
590
+ * reporter is to ignore a report with this flag for all but top-level
591
+ * compilation errors. The exception will remain pending, and so long
592
+ * as the non-top-level "load", "eval", or "compile" native function
593
+ * returns false, the top-level reporter will eventually receive the
594
+ * uncaught exception report.
595
+ *
596
+ * XXX it'd probably be best if there was only one call to this
597
+ * function, but there seem to be two error reporter call points.
598
+ */
599
+
600
+ /*
601
+ * Only try to raise an exception if there isn't one already set -
602
+ * otherwise the exception will describe only the last compile error,
603
+ * which is likely spurious.
604
+ */
605
+ if (!(ts && (ts->flags & TSF_ERROR)))
606
+ if (js_ErrorToException(cx, message, &report))
607
+ onError = NULL;
608
+
609
+ /*
610
+ * Suppress any compiletime errors that don't occur at the top level.
611
+ * This may still fail, as interplevel may be zero in contexts where we
612
+ * don't really want to call the error reporter, as when js is called
613
+ * by other code which could catch the error.
614
+ */
615
+ if (cx->interpLevel != 0)
616
+ onError = NULL;
617
+ #endif
618
+ if (cx->runtime->debugErrorHook && onError) {
619
+ JSDebugErrorHook hook = cx->runtime->debugErrorHook;
620
+ /* test local in case debugErrorHook changed on another thread */
621
+ if (hook && !hook(cx, message, &report,
622
+ cx->runtime->debugErrorHookData)) {
623
+ onError = NULL;
624
+ }
625
+ }
626
+ if (onError)
627
+ (*onError)(cx, message, &report);
628
+ }
629
+ if (message)
630
+ JS_free(cx, message);
631
+ if (report.messageArgs) {
632
+ int i = 0;
633
+ while (report.messageArgs[i])
634
+ JS_free(cx, (void *)report.messageArgs[i++]);
635
+ JS_free(cx, (void *)report.messageArgs);
636
+ }
637
+ if (report.ucmessage)
638
+ JS_free(cx, (void *)report.ucmessage);
639
+
640
+ js_RemoveRoot(cx->runtime, &linestr);
641
+
642
+ if (ts && !JSREPORT_IS_WARNING(flags)) {
643
+ /* Set the error flag to suppress spurious reports. */
644
+ ts->flags |= TSF_ERROR;
645
+ }
646
+ return warning;
647
+ }
648
+
649
+ JSTokenType
650
+ js_PeekToken(JSContext *cx, JSTokenStream *ts)
651
+ {
652
+ JSTokenType tt;
653
+
654
+ if (ts->lookahead != 0) {
655
+ tt = ts->tokens[(ts->cursor + ts->lookahead) & NTOKENS_MASK].type;
656
+ } else {
657
+ tt = js_GetToken(cx, ts);
658
+ js_UngetToken(ts);
659
+ }
660
+ return tt;
661
+ }
662
+
663
+ JSTokenType
664
+ js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts)
665
+ {
666
+ JSTokenType tt;
667
+
668
+ JS_ASSERT(ts->lookahead == 0 ||
669
+ ON_CURRENT_LINE(ts, CURRENT_TOKEN(ts).pos));
670
+ ts->flags |= TSF_NEWLINES;
671
+ tt = js_PeekToken(cx, ts);
672
+ ts->flags &= ~TSF_NEWLINES;
673
+ return tt;
674
+ }
675
+
676
+ #define TBMIN 64
677
+
678
+ static JSBool
679
+ GrowTokenBuf(JSContext *cx, JSTokenBuf *tb)
680
+ {
681
+ jschar *base;
682
+ ptrdiff_t offset, length;
683
+ size_t tbsize;
684
+ JSArenaPool *pool;
685
+
686
+ base = tb->base;
687
+ offset = PTRDIFF(tb->ptr, base, jschar);
688
+ pool = &cx->tempPool;
689
+ if (!base) {
690
+ tbsize = TBMIN * sizeof(jschar);
691
+ length = TBMIN;
692
+ JS_ARENA_ALLOCATE_CAST(base, jschar *, pool, tbsize);
693
+ } else {
694
+ length = PTRDIFF(tb->limit, base, jschar);
695
+ tbsize = length * sizeof(jschar);
696
+ length <<= 1;
697
+ JS_ARENA_GROW_CAST(base, jschar *, pool, tbsize, tbsize);
698
+ }
699
+ if (!base) {
700
+ JS_ReportOutOfMemory(cx);
701
+ return JS_FALSE;
702
+ }
703
+ tb->base = base;
704
+ tb->limit = base + length;
705
+ tb->ptr = base + offset;
706
+ return JS_TRUE;
707
+ }
708
+
709
+ static JSBool
710
+ AddToTokenBuf(JSContext *cx, JSTokenBuf *tb, jschar c)
711
+ {
712
+ if (tb->ptr == tb->limit && !GrowTokenBuf(cx, tb))
713
+ return JS_FALSE;
714
+ *tb->ptr++ = c;
715
+ return JS_TRUE;
716
+ }
717
+
718
+ /*
719
+ * We have encountered a '\': check for a Unicode escape sequence after it,
720
+ * returning the character code value if we found a Unicode escape sequence.
721
+ * Otherwise, non-destructively return the original '\'.
722
+ */
723
+ static int32
724
+ GetUnicodeEscape(JSTokenStream *ts)
725
+ {
726
+ jschar cp[5];
727
+ int32 c;
728
+
729
+ if (PeekChars(ts, 5, cp) && cp[0] == 'u' &&
730
+ JS7_ISHEX(cp[1]) && JS7_ISHEX(cp[2]) &&
731
+ JS7_ISHEX(cp[3]) && JS7_ISHEX(cp[4]))
732
+ {
733
+ c = (((((JS7_UNHEX(cp[1]) << 4)
734
+ + JS7_UNHEX(cp[2])) << 4)
735
+ + JS7_UNHEX(cp[3])) << 4)
736
+ + JS7_UNHEX(cp[4]);
737
+ SkipChars(ts, 5);
738
+ return c;
739
+ }
740
+ return '\\';
741
+ }
742
+
743
+ static JSToken *
744
+ NewToken(JSTokenStream *ts)
745
+ {
746
+ JSToken *tp;
747
+
748
+ ts->cursor = (ts->cursor + 1) & NTOKENS_MASK;
749
+ tp = &CURRENT_TOKEN(ts);
750
+ tp->ptr = ts->linebuf.ptr - 1;
751
+ tp->pos.begin.index = ts->linepos + (tp->ptr - ts->linebuf.base);
752
+ tp->pos.begin.lineno = tp->pos.end.lineno = (uint16)ts->lineno;
753
+ return tp;
754
+ }
755
+
756
+ JSBool
757
+ AllowNewlineBetweenTokens(JSToken *tp, JSTokenType tt)
758
+ {
759
+ /* okay if there's a left curly, right curly, or right bracket on the next line */
760
+ if (tt == TOK_LC || tt == TOK_RC || tt == TOK_RB)
761
+ return JS_TRUE;
762
+
763
+ switch (tp->type) {
764
+ case TOK_EOF:
765
+ case TOK_COMMA:
766
+ case TOK_DOT:
767
+ case TOK_SEMI:
768
+ case TOK_COLON:
769
+ case TOK_LC:
770
+ case TOK_RC:
771
+ case TOK_LP:
772
+ case TOK_LB:
773
+ case TOK_ASSIGN:
774
+ case TOK_RELOP:
775
+ case TOK_HOOK:
776
+ case TOK_PLUS:
777
+ case TOK_MINUS:
778
+ case TOK_STAR:
779
+ case TOK_DIVOP:
780
+ case TOK_EQOP:
781
+ case TOK_SHOP:
782
+ case TOK_OR:
783
+ case TOK_AND:
784
+ case TOK_BITOR :
785
+ case TOK_BITXOR:
786
+ case TOK_BITAND:
787
+ case TOK_ELSE:
788
+ case TOK_TRY:
789
+ return JS_TRUE;
790
+
791
+ case TOK_UNARYOP:
792
+ return (tp->t_op == JSOP_NOT || tp->t_op == JSOP_BITNOT);
793
+
794
+ default:
795
+ return JS_FALSE;
796
+ }
797
+ }
798
+
799
+ typedef struct JSLControlComment
800
+ {
801
+ JSBool isAtFormat;
802
+ JSBool endedWithAt;
803
+ const char *controlCommentIgnoreAll;
804
+ const char *controlCommentIgnore;
805
+ const char *controlCommentEnd;
806
+ const char *controlCommentOptionExplicit;
807
+ const char *controlCommentImport;
808
+ const char *controlCommentFallthru;
809
+ const char *controlCommentPass;
810
+ const char *controlCommentDeclare;
811
+
812
+ /*arbitrary size*/
813
+ char value[1024];
814
+ char *valuePos;
815
+ } JSLControlComment;
816
+
817
+ JSBool
818
+ js_MatchedPartialControlComment(JSLControlComment *jslCC, const char *str)
819
+ {
820
+ /* matched if pointing to null terminator */
821
+ return str && !*str;
822
+ }
823
+
824
+ JSBool
825
+ js_MatchedEntireControlComment(JSLControlComment *jslCC, const char *str)
826
+ {
827
+ if (!js_MatchedPartialControlComment(jslCC, str))
828
+ return JS_FALSE;
829
+
830
+ /* require final '@' */
831
+ if (jslCC->isAtFormat && !jslCC->endedWithAt)
832
+ return JS_FALSE;
833
+
834
+ return JS_TRUE;
835
+ }
836
+
837
+ void
838
+ js_MatchNextControlCommentChar(JSLControlComment *jslCC, JSBool allowValue, const char **strp, int32 c)
839
+ {
840
+ /* check for a value that needs to be processed */
841
+ if (allowValue && js_MatchedPartialControlComment(jslCC, *strp)) {
842
+ if (jslCC->valuePos && jslCC->valuePos - jslCC->value < sizeof(jslCC->value)-1) {
843
+ *jslCC->valuePos++ = (char)c;
844
+ *jslCC->valuePos = 0;
845
+ }
846
+ else {
847
+ jslCC->valuePos = NULL;
848
+ }
849
+ return;
850
+ }
851
+
852
+ if (*strp) {
853
+ if (jslCC->isAtFormat && c == '@' && !jslCC->endedWithAt) {
854
+ /*
855
+ * Expect a single '@' at the end of the string (must not be preceded by another '@')
856
+ * Assume that the '@' character is never included as a part of a control comment string.
857
+ */
858
+ }
859
+ else if (**strp && **strp == JS_TOLOWER(c)) {
860
+ /* increment to next expected character */
861
+ (*strp)++;
862
+ }
863
+ else {
864
+ /* unexpected character; nullify */
865
+ *strp = 0;
866
+ }
867
+ }
868
+ }
869
+
870
+ JSBool
871
+ js_StartControlComment(JSTokenStream *ts, JSLint *lint, JSLControlComment *jslCC)
872
+ {
873
+ /*
874
+ * Both JavaScript Lint and the JScript interpreter (for example, Internet Explorer) confuse each other
875
+ * with the syntax for the @...@ control comments and JScript conditional comments. The "jsl:" syntax
876
+ * is preferred for this reason.
877
+ */
878
+ jschar controlCommentPrefix[4];
879
+ if (PeekChars(ts, 4, controlCommentPrefix) &&
880
+ JS_TOLOWER(controlCommentPrefix[0]) == 'j' &&
881
+ JS_TOLOWER(controlCommentPrefix[1]) == 's' &&
882
+ JS_TOLOWER(controlCommentPrefix[2]) == 'l' &&
883
+ JS_TOLOWER(controlCommentPrefix[3]) == ':') {
884
+ /* jsl format */
885
+ SkipChars(ts, 4);
886
+ jslCC->isAtFormat = JS_FALSE;
887
+ }
888
+ else if (lint->enableLegacyControlComments && MatchChar(ts, '@')) {
889
+ /* legacy format */
890
+ jslCC->isAtFormat = JS_TRUE;
891
+ }
892
+ else
893
+ return JS_FALSE;
894
+
895
+ jslCC->endedWithAt = JS_FALSE;
896
+ jslCC->controlCommentIgnoreAll = "ignoreall";
897
+ jslCC->controlCommentIgnore = "ignore";
898
+ jslCC->controlCommentEnd = "end";
899
+ jslCC->controlCommentOptionExplicit = "option explicit";
900
+ jslCC->controlCommentImport = "import ";
901
+ jslCC->controlCommentFallthru = "fallthru";
902
+ jslCC->controlCommentPass = "pass";
903
+ jslCC->controlCommentDeclare = "declare";
904
+ jslCC->value[0] = 0;
905
+ jslCC->valuePos = jslCC->value;
906
+ return JS_TRUE;
907
+ }
908
+
909
+ void
910
+ js_ReadControlComment(JSContext *cx, JSTokenStream *ts, JSLControlComment *jslCC, int32 c)
911
+ {
912
+ /* try to advance control comment */
913
+ js_MatchNextControlCommentChar(jslCC, JS_FALSE, &jslCC->controlCommentIgnoreAll, c);
914
+ js_MatchNextControlCommentChar(jslCC, JS_FALSE, &jslCC->controlCommentIgnore, c);
915
+ js_MatchNextControlCommentChar(jslCC, JS_FALSE, &jslCC->controlCommentEnd, c);
916
+ js_MatchNextControlCommentChar(jslCC, JS_FALSE, &jslCC->controlCommentOptionExplicit, c);
917
+ js_MatchNextControlCommentChar(jslCC, JS_FALSE, &jslCC->controlCommentFallthru, c);
918
+ js_MatchNextControlCommentChar(jslCC, JS_FALSE, &jslCC->controlCommentPass, c);
919
+ js_MatchNextControlCommentChar(jslCC, JS_TRUE, &jslCC->controlCommentDeclare, c);
920
+ js_MatchNextControlCommentChar(jslCC, JS_TRUE, &jslCC->controlCommentImport, c);
921
+
922
+ jslCC->endedWithAt = (c == '@');
923
+ }
924
+
925
+ JSBool
926
+ js_ProcessControlComment(JSContext *cx, JSTokenStream *ts, JSLControlComment *jslCC,
927
+ JSTokenPos commentPos)
928
+ {
929
+ uintN defaultErrNumber;
930
+ defaultErrNumber = jslCC->isAtFormat ? JSMSG_LEGACY_CC_NOT_UNDERSTOOD : JSMSG_JSL_CC_NOT_UNDERSTOOD;
931
+
932
+ /* check for oversized control comments */
933
+ if (!jslCC->valuePos)
934
+ return js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, defaultErrNumber);
935
+
936
+ if (jslCC->valuePos > jslCC->value) {
937
+ /* trim @ */
938
+ if (jslCC->isAtFormat) {
939
+ jslCC->valuePos--;
940
+ *jslCC->valuePos = 0;
941
+ }
942
+
943
+ /* trim trailing whitespace */
944
+ while (jslCC->valuePos > jslCC->value && JS_ISSPACE(*(jslCC->valuePos-1))) {
945
+ jslCC->valuePos--;
946
+ *jslCC->valuePos = 0;
947
+ }
948
+
949
+ /* trim leading whitespace */
950
+ jslCC->valuePos = jslCC->value;
951
+ while (*jslCC->valuePos && JS_ISSPACE(*jslCC->valuePos))
952
+ jslCC->valuePos++;
953
+ }
954
+
955
+ if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentIgnoreAll)) {
956
+ cx->lint->controlCommentsIgnoreAll = JS_TRUE;
957
+ }
958
+ else if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentIgnore)) {
959
+ /* check nesting */
960
+ if (cx->lint->controlCommentsIgnore &&
961
+ !js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING,
962
+ JSMSG_MISMATCH_CTRL_COMMENTS))
963
+ {
964
+ return JS_FALSE;
965
+ }
966
+ cx->lint->controlCommentsIgnore = JS_TRUE;
967
+ }
968
+ else if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentEnd)) {
969
+ /* check nesting */
970
+ if (!cx->lint->controlCommentsIgnore &&
971
+ !js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING,
972
+ JSMSG_MISMATCH_CTRL_COMMENTS)) {
973
+ return JS_FALSE;
974
+ }
975
+ cx->lint->controlCommentsIgnore = JS_FALSE;
976
+ }
977
+ else if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentOptionExplicit)) {
978
+ if (cx->lint->controlCommentsOptionExplicit) {
979
+ /* warn about duplicates */
980
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, JSMSG_DUP_OPTION_EXPLICIT))
981
+ return JS_FALSE;
982
+ }
983
+ else if (cx->lint->hasCompletedPartialScript) {
984
+ /* warn about partial script that was missed */
985
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, JSMSG_PARTIAL_OPTION_EXPLICIT))
986
+ return JS_FALSE;
987
+ }
988
+ else {
989
+ cx->lint->controlCommentsOptionExplicit = JS_TRUE;
990
+ }
991
+ }
992
+ else if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentFallthru)) {
993
+ if (cx->lint->controlCommentsAllowFallthru && !cx->lint->controlCommentsHadFallthru)
994
+ cx->lint->controlCommentsHadFallthru = JS_TRUE;
995
+ else if (!js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, JSMSG_INVALID_FALLTHRU))
996
+ return JS_FALSE;
997
+ }
998
+ else if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentPass)) {
999
+ if (cx->lint->controlCommentsAllowPass && !cx->lint->controlCommentsFoundPass)
1000
+ cx->lint->controlCommentsFoundPass = JS_TRUE;
1001
+ else if (!js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, JSMSG_INVALID_PASS))
1002
+ return JS_FALSE;
1003
+ }
1004
+ else if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentDeclare)) {
1005
+ if (*jslCC->valuePos && JS_IsValidIdentifier(jslCC->valuePos)) {
1006
+ JSToken* tp;
1007
+
1008
+ tp = NewToken(ts);
1009
+ tp->type = TOK_VAR;
1010
+ tp->t_op = JSOP_DEFVAR;
1011
+
1012
+ tp = NewToken(ts);
1013
+ tp->type = TOK_NAME;
1014
+ tp->t_op = JSOP_NAME;
1015
+ tp->t_atom = js_Atomize(cx, jslCC->valuePos, strlen(jslCC->valuePos), 0);
1016
+
1017
+ tp = NewToken(ts);
1018
+ tp->type = TOK_SEMI;
1019
+
1020
+ js_UngetToken(ts);
1021
+ js_UngetToken(ts);
1022
+ js_UngetToken(ts);
1023
+ }
1024
+ else if (!js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, defaultErrNumber)) {
1025
+ return JS_FALSE;
1026
+ }
1027
+ }
1028
+ else if (js_MatchedEntireControlComment(jslCC, jslCC->controlCommentImport)) {
1029
+ if (*jslCC->valuePos) {
1030
+ /* add the path to the list of files to import */
1031
+ if (cx->lint->importPaths) {
1032
+ JSLImportPathList *newItem;
1033
+ newItem = JS_malloc(cx, sizeof(JSLImportPathList));
1034
+ JS_INIT_CLIST(&newItem->links);
1035
+ newItem->importPath = JS_strdup(cx, jslCC->valuePos);
1036
+ JS_APPEND_LINK(&newItem->links, &cx->lint->importPaths->links);
1037
+ }
1038
+ }
1039
+ else if (!js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, defaultErrNumber)) {
1040
+ return JS_FALSE;
1041
+ }
1042
+ }
1043
+ else {
1044
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING, defaultErrNumber))
1045
+ return JS_FALSE;
1046
+ }
1047
+
1048
+ return JS_TRUE;
1049
+ }
1050
+
1051
+ JSTokenType
1052
+ js_GetToken(JSContext *cx, JSTokenStream *ts)
1053
+ {
1054
+ JSTokenType tt;
1055
+ int32 c, qc;
1056
+ JSToken *tp;
1057
+ JSAtom *atom;
1058
+ JSBool hadUnicodeEscape;
1059
+ JSBool hasLineBreak;
1060
+ JSToken *origtoken;
1061
+
1062
+ hasLineBreak = JS_FALSE;
1063
+ origtoken = &CURRENT_TOKEN(ts);
1064
+
1065
+ #define INIT_TOKENBUF() (ts->tokenbuf.ptr = ts->tokenbuf.base)
1066
+ #define TRIM_TOKENBUF(i) (ts->tokenbuf.ptr = ts->tokenbuf.base + i)
1067
+ #define TOKENBUF_LENGTH() (ts->tokenbuf.ptr - ts->tokenbuf.base)
1068
+ #define TOKENBUF_BASE() (ts->tokenbuf.base)
1069
+ #define TOKENBUF_CHAR(i) (ts->tokenbuf.base[i])
1070
+ #define TOKENBUF_TO_ATOM() (js_AtomizeChars(cx, \
1071
+ TOKENBUF_BASE(), \
1072
+ TOKENBUF_LENGTH(), \
1073
+ 0))
1074
+
1075
+ #define ADD_TO_TOKENBUF(c) \
1076
+ JS_BEGIN_MACRO \
1077
+ if (!AddToTokenBuf(cx, &ts->tokenbuf, (jschar)c)) \
1078
+ goto error; \
1079
+ JS_END_MACRO
1080
+
1081
+ /* If there was a fatal error, keep returning TOK_ERROR. */
1082
+ if (ts->flags & TSF_ERROR)
1083
+ return TOK_ERROR;
1084
+
1085
+ /* Check for a pushed-back token resulting from mismatching lookahead. */
1086
+ while (ts->lookahead != 0) {
1087
+ ts->lookahead--;
1088
+ ts->cursor = (ts->cursor + 1) & NTOKENS_MASK;
1089
+ tt = CURRENT_TOKEN(ts).type;
1090
+ if (tt != TOK_EOL || (ts->flags & TSF_NEWLINES))
1091
+ return tt;
1092
+ }
1093
+
1094
+ retry:
1095
+ do {
1096
+ c = GetChar(ts);
1097
+ if (c == '\n') {
1098
+ hasLineBreak = JS_TRUE;
1099
+ ts->flags &= ~TSF_DIRTYLINE;
1100
+ if (ts->flags & TSF_NEWLINES)
1101
+ break;
1102
+ }
1103
+ } while (JS_ISSPACE(c));
1104
+
1105
+ tp = NewToken(ts);
1106
+ if (c == EOF) {
1107
+ tt = TOK_EOF;
1108
+ goto out;
1109
+ }
1110
+
1111
+ if (c != '-' && c != '\n')
1112
+ ts->flags |= TSF_DIRTYLINE;
1113
+
1114
+ hadUnicodeEscape = JS_FALSE;
1115
+ if (JS_ISIDENT_START(c) ||
1116
+ (c == '\\' &&
1117
+ (c = GetUnicodeEscape(ts),
1118
+ hadUnicodeEscape = JS_ISIDENT_START(c)))) {
1119
+ INIT_TOKENBUF();
1120
+ for (;;) {
1121
+ ADD_TO_TOKENBUF(c);
1122
+ c = GetChar(ts);
1123
+ if (c == '\\') {
1124
+ c = GetUnicodeEscape(ts);
1125
+ if (!JS_ISIDENT(c))
1126
+ break;
1127
+ hadUnicodeEscape = JS_TRUE;
1128
+ } else {
1129
+ if (!JS_ISIDENT(c))
1130
+ break;
1131
+ }
1132
+ }
1133
+ UngetChar(ts, c);
1134
+
1135
+ atom = TOKENBUF_TO_ATOM();
1136
+ if (!atom)
1137
+ goto error;
1138
+ if (!hadUnicodeEscape && ATOM_KEYWORD(atom)) {
1139
+ struct keyword *kw = ATOM_KEYWORD(atom);
1140
+
1141
+ if (JSVERSION_IS_ECMA(cx->version) || kw->version <= cx->version) {
1142
+ tp->t_op = (JSOp) kw->op;
1143
+ tt = kw->tokentype;
1144
+ goto out;
1145
+ }
1146
+ }
1147
+ tp->t_op = JSOP_NAME;
1148
+ tp->t_atom = atom;
1149
+ tt = TOK_NAME;
1150
+ goto out;
1151
+ }
1152
+
1153
+ if (JS7_ISDEC(c) || (c == '.' && JS7_ISDEC(PeekChar(ts)))) {
1154
+ jsint radix;
1155
+ const jschar *endptr;
1156
+ jsdouble dval;
1157
+
1158
+ radix = 10;
1159
+ INIT_TOKENBUF();
1160
+
1161
+ if (cx->lint && c == '.' &&
1162
+ !js_ReportCompileErrorNumber(cx, ts, NULL,
1163
+ JSREPORT_WARNING |
1164
+ JSREPORT_STRICT,
1165
+ JSMSG_LEADING_DECIMAL_POINT)) {
1166
+ goto error;
1167
+ }
1168
+
1169
+ if (c == '0') {
1170
+ ADD_TO_TOKENBUF(c);
1171
+ c = GetChar(ts);
1172
+ if (JS_TOLOWER(c) == 'x') {
1173
+ ADD_TO_TOKENBUF(c);
1174
+ c = GetChar(ts);
1175
+ radix = 16;
1176
+ } else if (JS7_ISDEC(c)) {
1177
+ radix = 8;
1178
+
1179
+ if (cx->lint &&
1180
+ !js_ReportCompileErrorNumber(cx, ts, NULL,
1181
+ JSREPORT_WARNING |
1182
+ JSREPORT_STRICT,
1183
+ JSMSG_OCTAL_NUMBER)) {
1184
+ goto error;
1185
+ }
1186
+ }
1187
+ }
1188
+
1189
+ while (JS7_ISHEX(c)) {
1190
+ if (radix < 16) {
1191
+ if (JS7_ISLET(c))
1192
+ break;
1193
+
1194
+ /*
1195
+ * We permit 08 and 09 as decimal numbers, which makes our
1196
+ * behaviour a superset of the ECMA numeric grammar. We might
1197
+ * not always be so permissive, so we warn about it.
1198
+ */
1199
+ if (radix == 8 && c >= '8') {
1200
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1201
+ JSREPORT_WARNING,
1202
+ JSMSG_BAD_OCTAL,
1203
+ c == '8' ? "08" : "09")) {
1204
+ goto error;
1205
+ }
1206
+ radix = 10;
1207
+ }
1208
+ }
1209
+ ADD_TO_TOKENBUF(c);
1210
+ c = GetChar(ts);
1211
+ }
1212
+
1213
+ if (radix == 10 && (c == '.' || JS_TOLOWER(c) == 'e')) {
1214
+ if (c == '.') {
1215
+ int digitsafterdecimal = -1;
1216
+ do {
1217
+ ADD_TO_TOKENBUF(c);
1218
+ digitsafterdecimal++;
1219
+ c = GetChar(ts);
1220
+ } while (JS7_ISDEC(c));
1221
+
1222
+ if (cx->lint && !digitsafterdecimal) {
1223
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1224
+ JSREPORT_WARNING |
1225
+ JSREPORT_STRICT,
1226
+ JSMSG_TRAILING_DECIMAL_POINT)) {
1227
+ goto error;
1228
+ }
1229
+ }
1230
+ }
1231
+ if (JS_TOLOWER(c) == 'e') {
1232
+ ADD_TO_TOKENBUF(c);
1233
+ c = GetChar(ts);
1234
+ if (c == '+' || c == '-') {
1235
+ ADD_TO_TOKENBUF(c);
1236
+ c = GetChar(ts);
1237
+ }
1238
+ if (!JS7_ISDEC(c)) {
1239
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1240
+ JSMSG_MISSING_EXPONENT);
1241
+ goto error;
1242
+ }
1243
+ do {
1244
+ ADD_TO_TOKENBUF(c);
1245
+ c = GetChar(ts);
1246
+ } while (JS7_ISDEC(c));
1247
+ }
1248
+ }
1249
+
1250
+ if (cx->lint && c == '.') {
1251
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1252
+ JSREPORT_WARNING |
1253
+ JSREPORT_STRICT,
1254
+ JSMSG_TRAILING_DECIMAL_POINT)) {
1255
+ goto error;
1256
+ }
1257
+ }
1258
+
1259
+ /* Put back the next char and NUL-terminate tokenbuf for js_strto*. */
1260
+ UngetChar(ts, c);
1261
+ ADD_TO_TOKENBUF(0);
1262
+
1263
+ if (radix == 10) {
1264
+ if (!js_strtod(cx, TOKENBUF_BASE(), &endptr, &dval)) {
1265
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1266
+ JSMSG_OUT_OF_MEMORY);
1267
+ goto error;
1268
+ }
1269
+ } else {
1270
+ if (!js_strtointeger(cx, TOKENBUF_BASE(), &endptr, radix, &dval)) {
1271
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1272
+ JSMSG_OUT_OF_MEMORY);
1273
+ goto error;
1274
+ }
1275
+ }
1276
+ tp->t_dval = dval;
1277
+ tt = TOK_NUMBER;
1278
+ goto out;
1279
+ }
1280
+
1281
+ if (c == '"' || c == '\'') {
1282
+ qc = c;
1283
+ INIT_TOKENBUF();
1284
+ while ((c = GetChar(ts)) != qc) {
1285
+ if (c == '\n' || c == EOF) {
1286
+ UngetChar(ts, c);
1287
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1288
+ JSMSG_UNTERMINATED_STRING);
1289
+ goto error;
1290
+ }
1291
+ if (c == '\\') {
1292
+ switch (c = GetChar(ts)) {
1293
+ case 'b': c = '\b'; break;
1294
+ case 'f': c = '\f'; break;
1295
+ case 'n': c = '\n'; break;
1296
+ case 'r': c = '\r'; break;
1297
+ case 't': c = '\t'; break;
1298
+ case 'v': c = '\v'; break;
1299
+
1300
+ default:
1301
+ if ('0' <= c && c < '8') {
1302
+ int32 val = JS7_UNDEC(c);
1303
+
1304
+ c = PeekChar(ts);
1305
+ if ('0' <= c && c < '8') {
1306
+ val = 8 * val + JS7_UNDEC(c);
1307
+ GetChar(ts);
1308
+ c = PeekChar(ts);
1309
+ if ('0' <= c && c < '8') {
1310
+ int32 save = val;
1311
+ val = 8 * val + JS7_UNDEC(c);
1312
+ if (val <= 0377)
1313
+ GetChar(ts);
1314
+ else
1315
+ val = save;
1316
+ }
1317
+ }
1318
+
1319
+ c = (jschar)val;
1320
+ } else if (c == 'u') {
1321
+ jschar cp[4];
1322
+ if (PeekChars(ts, 4, cp) &&
1323
+ JS7_ISHEX(cp[0]) && JS7_ISHEX(cp[1]) &&
1324
+ JS7_ISHEX(cp[2]) && JS7_ISHEX(cp[3])) {
1325
+ c = (((((JS7_UNHEX(cp[0]) << 4)
1326
+ + JS7_UNHEX(cp[1])) << 4)
1327
+ + JS7_UNHEX(cp[2])) << 4)
1328
+ + JS7_UNHEX(cp[3]);
1329
+ SkipChars(ts, 4);
1330
+ }
1331
+ } else if (c == 'x') {
1332
+ jschar cp[2];
1333
+ if (PeekChars(ts, 2, cp) &&
1334
+ JS7_ISHEX(cp[0]) && JS7_ISHEX(cp[1])) {
1335
+ c = (JS7_UNHEX(cp[0]) << 4) + JS7_UNHEX(cp[1]);
1336
+ SkipChars(ts, 2);
1337
+ }
1338
+ } else if (c == '\n' && JSVERSION_IS_ECMA(cx->version)) {
1339
+ /* ECMA follows C by removing escaped newlines. */
1340
+ continue;
1341
+ }
1342
+ break;
1343
+ }
1344
+ }
1345
+ ADD_TO_TOKENBUF(c);
1346
+ }
1347
+ atom = TOKENBUF_TO_ATOM();
1348
+ if (!atom)
1349
+ goto error;
1350
+ tp->pos.end.lineno = (uint16)ts->lineno;
1351
+ tp->t_op = JSOP_STRING;
1352
+ tp->t_atom = atom;
1353
+ tt = TOK_STRING;
1354
+ goto out;
1355
+ }
1356
+
1357
+ switch (c) {
1358
+ case '\n':
1359
+ tt = TOK_EOL;
1360
+ break;
1361
+
1362
+ case ';': tt = TOK_SEMI; break;
1363
+ case '[': tt = TOK_LB; break;
1364
+ case ']': tt = TOK_RB; break;
1365
+ case '{': tt = TOK_LC; break;
1366
+ case '}': tt = TOK_RC; break;
1367
+ case '(': tt = TOK_LP; break;
1368
+ case ')': tt = TOK_RP; break;
1369
+ case ',': tt = TOK_COMMA; break;
1370
+ case '?': tt = TOK_HOOK; break;
1371
+
1372
+ case '.':
1373
+ tt = TOK_DOT;
1374
+ break;
1375
+
1376
+ case ':':
1377
+ /*
1378
+ * Default so compiler can modify to JSOP_GETTER if 'p getter: v' in an
1379
+ * object initializer, likewise for setter.
1380
+ */
1381
+ tp->t_op = JSOP_NOP;
1382
+ tt = TOK_COLON;
1383
+ break;
1384
+
1385
+ case '|':
1386
+ if (MatchChar(ts, c)) {
1387
+ tt = TOK_OR;
1388
+ } else if (MatchChar(ts, '=')) {
1389
+ tp->t_op = JSOP_BITOR;
1390
+ tt = TOK_ASSIGN;
1391
+ } else {
1392
+ tt = TOK_BITOR;
1393
+ }
1394
+ break;
1395
+
1396
+ case '^':
1397
+ if (MatchChar(ts, '=')) {
1398
+ tp->t_op = JSOP_BITXOR;
1399
+ tt = TOK_ASSIGN;
1400
+ } else {
1401
+ tt = TOK_BITXOR;
1402
+ }
1403
+ break;
1404
+
1405
+ case '&':
1406
+ if (MatchChar(ts, c)) {
1407
+ tt = TOK_AND;
1408
+ } else if (MatchChar(ts, '=')) {
1409
+ tp->t_op = JSOP_BITAND;
1410
+ tt = TOK_ASSIGN;
1411
+ } else {
1412
+ tt = TOK_BITAND;
1413
+ }
1414
+ break;
1415
+
1416
+ case '=':
1417
+ if (MatchChar(ts, c)) {
1418
+ #if JS_HAS_TRIPLE_EQOPS
1419
+ tp->t_op = MatchChar(ts, c) ? JSOP_NEW_EQ : (JSOp)cx->jsop_eq;
1420
+ #else
1421
+ tp->t_op = cx->jsop_eq;
1422
+ #endif
1423
+ tt = TOK_EQOP;
1424
+ } else {
1425
+ tp->t_op = JSOP_NOP;
1426
+ tt = TOK_ASSIGN;
1427
+ }
1428
+ break;
1429
+
1430
+ case '!':
1431
+ if (MatchChar(ts, '=')) {
1432
+ #if JS_HAS_TRIPLE_EQOPS
1433
+ tp->t_op = MatchChar(ts, '=') ? JSOP_NEW_NE : (JSOp)cx->jsop_ne;
1434
+ #else
1435
+ tp->t_op = cx->jsop_ne;
1436
+ #endif
1437
+ tt = TOK_EQOP;
1438
+ } else {
1439
+ tp->t_op = JSOP_NOT;
1440
+ tt = TOK_UNARYOP;
1441
+ }
1442
+ break;
1443
+
1444
+ case '<':
1445
+ /* NB: treat HTML begin-comment as comment-till-end-of-line */
1446
+ if (MatchChar(ts, '!')) {
1447
+ if (MatchChar(ts, '-')) {
1448
+ if (MatchChar(ts, '-'))
1449
+ goto skipline;
1450
+ UngetChar(ts, '-');
1451
+ }
1452
+ UngetChar(ts, '!');
1453
+ }
1454
+ if (MatchChar(ts, c)) {
1455
+ tp->t_op = JSOP_LSH;
1456
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_SHOP;
1457
+ } else {
1458
+ tp->t_op = MatchChar(ts, '=') ? JSOP_LE : JSOP_LT;
1459
+ tt = TOK_RELOP;
1460
+ }
1461
+ break;
1462
+
1463
+ case '>':
1464
+ if (MatchChar(ts, c)) {
1465
+ tp->t_op = MatchChar(ts, c) ? JSOP_URSH : JSOP_RSH;
1466
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_SHOP;
1467
+ } else {
1468
+ tp->t_op = MatchChar(ts, '=') ? JSOP_GE : JSOP_GT;
1469
+ tt = TOK_RELOP;
1470
+ }
1471
+ break;
1472
+
1473
+ case '*':
1474
+ tp->t_op = JSOP_MUL;
1475
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_STAR;
1476
+ break;
1477
+
1478
+ case '/':
1479
+ if (MatchChar(ts, '/')) {
1480
+ /*
1481
+ * Hack for source filters such as the Mozilla XUL preprocessor:
1482
+ * "//@line 123\n" sets the number of the *next* line after the
1483
+ * comment to 123.
1484
+ */
1485
+ if (JS_HAS_ATLINE_OPTION(cx)) {
1486
+ jschar cp[5];
1487
+ uintN i, line, temp;
1488
+ char filename[1024];
1489
+
1490
+ if (PeekChars(ts, 5, cp) &&
1491
+ cp[0] == '@' &&
1492
+ cp[1] == 'l' &&
1493
+ cp[2] == 'i' &&
1494
+ cp[3] == 'n' &&
1495
+ cp[4] == 'e') {
1496
+ SkipChars(ts, 5);
1497
+ while ((c = GetChar(ts)) != '\n' && JS_ISSPACE(c))
1498
+ continue;
1499
+ if (JS7_ISDEC(c)) {
1500
+ line = JS7_UNDEC(c);
1501
+ while ((c = GetChar(ts)) != EOF && JS7_ISDEC(c)) {
1502
+ temp = 10 * line + JS7_UNDEC(c);
1503
+ if (temp < line) {
1504
+ /* Ignore overlarge line numbers. */
1505
+ goto skipline;
1506
+ }
1507
+ line = temp;
1508
+ }
1509
+ while (c != '\n' && JS_ISSPACE(c))
1510
+ c = GetChar(ts);
1511
+ i = 0;
1512
+ if (c == '"') {
1513
+ while ((c = GetChar(ts)) != EOF && c != '"') {
1514
+ if (c == '\n') {
1515
+ UngetChar(ts, c);
1516
+ goto skipline;
1517
+ }
1518
+ if ((c >> 8) != 0 || i >= sizeof filename - 1)
1519
+ goto skipline;
1520
+ filename[i++] = (char) c;
1521
+ }
1522
+ if (c == '"') {
1523
+ while ((c = GetChar(ts)) != '\n' &&
1524
+ JS_ISSPACE(c)) {
1525
+ continue;
1526
+ }
1527
+ }
1528
+ }
1529
+ filename[i] = '\0';
1530
+ if (c == '\n') {
1531
+ if (i > 0) {
1532
+ if (ts->flags & TSF_OWNFILENAME)
1533
+ JS_free(cx, (void *) ts->filename);
1534
+ ts->filename = JS_strdup(cx, filename);
1535
+ if (!ts->filename)
1536
+ goto error;
1537
+ ts->flags |= TSF_OWNFILENAME;
1538
+ }
1539
+ ts->lineno = line;
1540
+ }
1541
+ }
1542
+ UngetChar(ts, c);
1543
+ }
1544
+ }
1545
+
1546
+ skipline:
1547
+ while ((c = GetChar(ts)) != EOF && c != '\n')
1548
+ continue;
1549
+ UngetChar(ts, c);
1550
+ goto retry;
1551
+ }
1552
+ if (MatchChar(ts, '*')) {
1553
+ JSLControlComment jslCC;
1554
+ JSTokenPos commentPos;
1555
+ JSBool useCC = JS_FALSE;
1556
+ commentPos = CURRENT_TOKEN(ts).pos;
1557
+
1558
+ if (cx->lint)
1559
+ useCC = js_StartControlComment(ts, cx->lint, &jslCC);
1560
+
1561
+ while ((c = GetChar(ts)) != EOF &&
1562
+ !(c == '*' && MatchChar(ts, '/'))) {
1563
+
1564
+ /* check for nested comments */
1565
+ if (c == '/' && PeekChar(ts) == '*' &&
1566
+ !js_ReportCompileErrorNumber(cx, ts, NULL,
1567
+ JSREPORT_WARNING |
1568
+ JSREPORT_STRICT,
1569
+ JSMSG_NESTED_COMMENT)) {
1570
+ goto error;
1571
+ }
1572
+
1573
+ /* check for control comments */
1574
+ if (useCC)
1575
+ js_ReadControlComment(cx, ts, &jslCC, c);
1576
+ }
1577
+
1578
+ if (c == EOF) {
1579
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1580
+ JSMSG_UNTERMINATED_COMMENT);
1581
+ goto error;
1582
+ }
1583
+
1584
+ if (useCC) {
1585
+ if (!js_ProcessControlComment(cx, ts, &jslCC, commentPos))
1586
+ goto error;
1587
+ /* recurse to handle generated tokens */
1588
+ if (ts->lookahead != 0)
1589
+ return js_GetToken(cx, ts);
1590
+ }
1591
+
1592
+ goto retry;
1593
+ }
1594
+
1595
+ #if JS_HAS_REGEXPS
1596
+ if (ts->flags & TSF_OPERAND) {
1597
+ JSObject *obj;
1598
+ uintN flags;
1599
+
1600
+ INIT_TOKENBUF();
1601
+ while ((c = GetChar(ts)) != '/') {
1602
+ if (c == '\n' || c == EOF) {
1603
+ UngetChar(ts, c);
1604
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1605
+ JSMSG_UNTERMINATED_REGEXP);
1606
+ goto error;
1607
+ }
1608
+ if (c == '\\') {
1609
+ ADD_TO_TOKENBUF(c);
1610
+ c = GetChar(ts);
1611
+ }
1612
+ ADD_TO_TOKENBUF(c);
1613
+ }
1614
+ for (flags = 0; ; ) {
1615
+ if (MatchChar(ts, 'g'))
1616
+ flags |= JSREG_GLOB;
1617
+ else if (MatchChar(ts, 'i'))
1618
+ flags |= JSREG_FOLD;
1619
+ else if (MatchChar(ts, 'm'))
1620
+ flags |= JSREG_MULTILINE;
1621
+ else
1622
+ break;
1623
+ }
1624
+ c = PeekChar(ts);
1625
+ if (JS7_ISLET(c)) {
1626
+ tp->ptr = ts->linebuf.ptr - 1;
1627
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1628
+ JSMSG_BAD_REGEXP_FLAG);
1629
+ (void) GetChar(ts);
1630
+ goto error;
1631
+ }
1632
+ obj = js_NewRegExpObject(cx, ts,
1633
+ TOKENBUF_BASE(),
1634
+ TOKENBUF_LENGTH(),
1635
+ flags);
1636
+ if (!obj)
1637
+ goto error;
1638
+ atom = js_AtomizeObject(cx, obj, 0);
1639
+ if (!atom)
1640
+ goto error;
1641
+
1642
+ if (cx->lint && (!origtoken || (origtoken->type != TOK_COMMA &&
1643
+ (origtoken->type != TOK_ASSIGN || origtoken->t_op != JSOP_NOP) &&
1644
+ origtoken->type != TOK_COLON && origtoken->type != TOK_LP))) {
1645
+ /* report bad regex placement */
1646
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1647
+ JSREPORT_WARNING |
1648
+ JSREPORT_STRICT,
1649
+ JSMSG_MISPLACED_REGEX)) {
1650
+ goto error;
1651
+ }
1652
+ }
1653
+
1654
+ /*
1655
+ * If the regexp's script is one-shot, we can avoid the extra
1656
+ * fork-on-exec costs of JSOP_REGEXP by selecting JSOP_OBJECT.
1657
+ * Otherwise, to avoid incorrect proto, parent, and lastIndex
1658
+ * sharing among threads and sequentially across re-execution,
1659
+ * select JSOP_REGEXP.
1660
+ */
1661
+ tp->t_op = (cx->fp->flags & (JSFRAME_EVAL | JSFRAME_COMPILE_N_GO))
1662
+ ? JSOP_OBJECT
1663
+ : JSOP_REGEXP;
1664
+ tp->t_atom = atom;
1665
+ tt = TOK_OBJECT;
1666
+ break;
1667
+ }
1668
+ #endif /* JS_HAS_REGEXPS */
1669
+
1670
+ tp->t_op = JSOP_DIV;
1671
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_DIVOP;
1672
+ break;
1673
+
1674
+ case '%':
1675
+ tp->t_op = JSOP_MOD;
1676
+ tt = MatchChar(ts, '=') ? TOK_ASSIGN : TOK_DIVOP;
1677
+ break;
1678
+
1679
+ case '~':
1680
+ tp->t_op = JSOP_BITNOT;
1681
+ tt = TOK_UNARYOP;
1682
+ break;
1683
+
1684
+ case '+':
1685
+ if (MatchChar(ts, '=')) {
1686
+ tp->t_op = JSOP_ADD;
1687
+ tt = TOK_ASSIGN;
1688
+ } else if (MatchChar(ts, c)) {
1689
+ tt = TOK_INC;
1690
+ } else {
1691
+ tp->t_op = JSOP_POS;
1692
+ tt = TOK_PLUS;
1693
+ }
1694
+ break;
1695
+
1696
+ case '-':
1697
+ if (MatchChar(ts, '=')) {
1698
+ tp->t_op = JSOP_SUB;
1699
+ tt = TOK_ASSIGN;
1700
+ } else if (MatchChar(ts, c)) {
1701
+ if (PeekChar(ts) == '>' && !(ts->flags & TSF_DIRTYLINE))
1702
+ goto skipline;
1703
+ tt = TOK_DEC;
1704
+ } else {
1705
+ tp->t_op = JSOP_NEG;
1706
+ tt = TOK_MINUS;
1707
+ }
1708
+ ts->flags |= TSF_DIRTYLINE;
1709
+ break;
1710
+
1711
+ #if JS_HAS_SHARP_VARS
1712
+ case '#':
1713
+ {
1714
+ uint32 n;
1715
+
1716
+ c = GetChar(ts);
1717
+ if (!JS7_ISDEC(c)) {
1718
+ UngetChar(ts, c);
1719
+ goto badchar;
1720
+ }
1721
+ n = (uint32)JS7_UNDEC(c);
1722
+ for (;;) {
1723
+ c = GetChar(ts);
1724
+ if (!JS7_ISDEC(c))
1725
+ break;
1726
+ n = 10 * n + JS7_UNDEC(c);
1727
+ if (n >= ATOM_INDEX_LIMIT) {
1728
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1729
+ JSMSG_SHARPVAR_TOO_BIG);
1730
+ goto error;
1731
+ }
1732
+ }
1733
+ tp->t_dval = (jsdouble) n;
1734
+ if (JS_HAS_STRICT_OPTION(cx) &&
1735
+ (c == '=' || c == '#')) {
1736
+ char buf[20];
1737
+ JS_snprintf(buf, sizeof buf, "#%u%c", n, c);
1738
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1739
+ JSREPORT_WARNING |
1740
+ JSREPORT_STRICT,
1741
+ JSMSG_DEPRECATED_USAGE,
1742
+ buf)) {
1743
+ goto error;
1744
+ }
1745
+ }
1746
+ if (c == '=')
1747
+ tt = TOK_DEFSHARP;
1748
+ else if (c == '#')
1749
+ tt = TOK_USESHARP;
1750
+ else
1751
+ goto badchar;
1752
+ break;
1753
+ }
1754
+
1755
+ badchar:
1756
+ #endif /* JS_HAS_SHARP_VARS */
1757
+
1758
+ default:
1759
+ js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
1760
+ JSMSG_ILLEGAL_CHARACTER);
1761
+ goto error;
1762
+ }
1763
+
1764
+ /* check tokens on end of line */
1765
+ if (cx->lint && hasLineBreak && origtoken &&
1766
+ !AllowNewlineBetweenTokens(origtoken, tt)) {
1767
+ if (!js_ReportCompileErrorNumber(cx, ts, NULL,
1768
+ JSREPORT_WARNING |
1769
+ JSREPORT_STRICT,
1770
+ JSMSG_AMBIGUOUS_NEWLINE)) {
1771
+ goto error;
1772
+ }
1773
+ }
1774
+
1775
+ out:
1776
+ JS_ASSERT(tt < TOK_LIMIT);
1777
+ tp->pos.end.index = ts->linepos +
1778
+ (ts->linebuf.ptr - ts->linebuf.base) -
1779
+ ts->ungetpos;
1780
+ tp->type = tt;
1781
+ return tt;
1782
+
1783
+ error:
1784
+ tt = TOK_ERROR;
1785
+ ts->flags |= TSF_ERROR;
1786
+ goto out;
1787
+
1788
+ #undef INIT_TOKENBUF
1789
+ #undef TRIM_TOKENBUF
1790
+ #undef TOKENBUF_LENGTH
1791
+ #undef TOKENBUF_BASE
1792
+ #undef TOKENBUF_CHAR
1793
+ #undef TOKENBUF_TO_ATOM
1794
+ #undef ADD_TO_TOKENBUF
1795
+ }
1796
+
1797
+ void
1798
+ js_UngetToken(JSTokenStream *ts)
1799
+ {
1800
+ JS_ASSERT(ts->lookahead < NTOKENS_MASK);
1801
+ if (ts->flags & TSF_ERROR)
1802
+ return;
1803
+ ts->lookahead++;
1804
+ ts->cursor = (ts->cursor - 1) & NTOKENS_MASK;
1805
+ }
1806
+
1807
+ JSBool
1808
+ js_MatchToken(JSContext *cx, JSTokenStream *ts, JSTokenType tt)
1809
+ {
1810
+ if (js_GetToken(cx, ts) == tt)
1811
+ return JS_TRUE;
1812
+ js_UngetToken(ts);
1813
+ return JS_FALSE;
1814
+ }