jbarnette-johnson 1.0.0.200806240111 → 1.0.0.200807291507

Sign up to get free protection for your applications and to get access to all the features.
Files changed (269) hide show
  1. data/MANIFEST +1 -0
  2. data/Rakefile +3 -10
  3. data/bin/johnson +2 -1
  4. data/ext/spidermonkey/context.c +3 -4
  5. data/ext/spidermonkey/context.h +1 -1
  6. data/ext/spidermonkey/conversions.c +39 -33
  7. data/ext/spidermonkey/debugger.c +5 -5
  8. data/ext/spidermonkey/immutable_node.c.erb +11 -11
  9. data/ext/spidermonkey/jroot.h +4 -4
  10. data/ext/spidermonkey/js_land_proxy.c +9 -8
  11. data/ext/spidermonkey/ruby_land_proxy.c +5 -4
  12. data/ext/spidermonkey/runtime.c +1 -1
  13. data/johnson.gemspec +36 -0
  14. data/lib/hoe.rb +0 -7
  15. data/lib/johnson/cli/options.rb +10 -4
  16. data/lib/johnson/spidermonkey/runtime.rb +2 -2
  17. data/lib/johnson/version.rb +4 -2
  18. data/lib/johnson.rb +1 -0
  19. data/test/johnson/runtime_test.rb +11 -0
  20. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +6 -0
  21. data/vendor/spidermonkey/.cvsignore +9 -0
  22. data/vendor/spidermonkey/Makefile.in +462 -0
  23. data/vendor/spidermonkey/Makefile.ref +364 -0
  24. data/vendor/spidermonkey/README.html +820 -0
  25. data/vendor/spidermonkey/SpiderMonkey.rsp +12 -0
  26. data/vendor/spidermonkey/Y.js +19 -0
  27. data/vendor/spidermonkey/build.mk +43 -0
  28. data/vendor/spidermonkey/config/AIX4.1.mk +65 -0
  29. data/vendor/spidermonkey/config/AIX4.2.mk +64 -0
  30. data/vendor/spidermonkey/config/AIX4.3.mk +65 -0
  31. data/vendor/spidermonkey/config/Darwin.mk +83 -0
  32. data/vendor/spidermonkey/config/Darwin1.3.mk +81 -0
  33. data/vendor/spidermonkey/config/Darwin1.4.mk +41 -0
  34. data/vendor/spidermonkey/config/Darwin5.2.mk +81 -0
  35. data/vendor/spidermonkey/config/Darwin5.3.mk +81 -0
  36. data/vendor/spidermonkey/config/HP-UXB.10.10.mk +77 -0
  37. data/vendor/spidermonkey/config/HP-UXB.10.20.mk +77 -0
  38. data/vendor/spidermonkey/config/HP-UXB.11.00.mk +80 -0
  39. data/vendor/spidermonkey/config/IRIX.mk +87 -0
  40. data/vendor/spidermonkey/config/IRIX5.3.mk +44 -0
  41. data/vendor/spidermonkey/config/IRIX6.1.mk +44 -0
  42. data/vendor/spidermonkey/config/IRIX6.2.mk +44 -0
  43. data/vendor/spidermonkey/config/IRIX6.3.mk +44 -0
  44. data/vendor/spidermonkey/config/IRIX6.5.mk +44 -0
  45. data/vendor/spidermonkey/config/Linux_All.mk +103 -0
  46. data/vendor/spidermonkey/config/Mac_OS10.0.mk +82 -0
  47. data/vendor/spidermonkey/config/OSF1V4.0.mk +72 -0
  48. data/vendor/spidermonkey/config/OSF1V5.0.mk +69 -0
  49. data/vendor/spidermonkey/config/SunOS4.1.4.mk +101 -0
  50. data/vendor/spidermonkey/config/SunOS5.10.mk +50 -0
  51. data/vendor/spidermonkey/config/SunOS5.3.mk +91 -0
  52. data/vendor/spidermonkey/config/SunOS5.4.mk +92 -0
  53. data/vendor/spidermonkey/config/SunOS5.5.1.mk +44 -0
  54. data/vendor/spidermonkey/config/SunOS5.5.mk +87 -0
  55. data/vendor/spidermonkey/config/SunOS5.6.mk +89 -0
  56. data/vendor/spidermonkey/config/SunOS5.7.mk +44 -0
  57. data/vendor/spidermonkey/config/SunOS5.8.mk +44 -0
  58. data/vendor/spidermonkey/config/SunOS5.9.mk +44 -0
  59. data/vendor/spidermonkey/config/WINNT4.0.mk +117 -0
  60. data/vendor/spidermonkey/config/WINNT5.0.mk +117 -0
  61. data/vendor/spidermonkey/config/WINNT5.1.mk +117 -0
  62. data/vendor/spidermonkey/config/WINNT5.2.mk +117 -0
  63. data/vendor/spidermonkey/config/WINNT6.0.mk +117 -0
  64. data/vendor/spidermonkey/config/dgux.mk +64 -0
  65. data/vendor/spidermonkey/config.mk +192 -0
  66. data/vendor/spidermonkey/editline/Makefile.ref +144 -0
  67. data/vendor/spidermonkey/editline/README +83 -0
  68. data/vendor/spidermonkey/editline/editline.3 +175 -0
  69. data/vendor/spidermonkey/editline/editline.c +1369 -0
  70. data/vendor/spidermonkey/editline/editline.h +135 -0
  71. data/vendor/spidermonkey/editline/sysunix.c +182 -0
  72. data/vendor/spidermonkey/editline/unix.h +82 -0
  73. data/vendor/spidermonkey/fdlibm/.cvsignore +7 -0
  74. data/vendor/spidermonkey/fdlibm/Makefile.in +127 -0
  75. data/vendor/spidermonkey/fdlibm/Makefile.ref +192 -0
  76. data/vendor/spidermonkey/fdlibm/e_acos.c +147 -0
  77. data/vendor/spidermonkey/fdlibm/e_acosh.c +105 -0
  78. data/vendor/spidermonkey/fdlibm/e_asin.c +156 -0
  79. data/vendor/spidermonkey/fdlibm/e_atan2.c +165 -0
  80. data/vendor/spidermonkey/fdlibm/e_atanh.c +110 -0
  81. data/vendor/spidermonkey/fdlibm/e_cosh.c +133 -0
  82. data/vendor/spidermonkey/fdlibm/e_exp.c +202 -0
  83. data/vendor/spidermonkey/fdlibm/e_fmod.c +184 -0
  84. data/vendor/spidermonkey/fdlibm/e_gamma.c +71 -0
  85. data/vendor/spidermonkey/fdlibm/e_gamma_r.c +70 -0
  86. data/vendor/spidermonkey/fdlibm/e_hypot.c +173 -0
  87. data/vendor/spidermonkey/fdlibm/e_j0.c +524 -0
  88. data/vendor/spidermonkey/fdlibm/e_j1.c +523 -0
  89. data/vendor/spidermonkey/fdlibm/e_jn.c +315 -0
  90. data/vendor/spidermonkey/fdlibm/e_lgamma.c +71 -0
  91. data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +347 -0
  92. data/vendor/spidermonkey/fdlibm/e_log.c +184 -0
  93. data/vendor/spidermonkey/fdlibm/e_log10.c +134 -0
  94. data/vendor/spidermonkey/fdlibm/e_pow.c +386 -0
  95. data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +222 -0
  96. data/vendor/spidermonkey/fdlibm/e_remainder.c +120 -0
  97. data/vendor/spidermonkey/fdlibm/e_scalb.c +89 -0
  98. data/vendor/spidermonkey/fdlibm/e_sinh.c +122 -0
  99. data/vendor/spidermonkey/fdlibm/e_sqrt.c +497 -0
  100. data/vendor/spidermonkey/fdlibm/fdlibm.h +273 -0
  101. data/vendor/spidermonkey/fdlibm/fdlibm.mak +1453 -0
  102. data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
  103. data/vendor/spidermonkey/fdlibm/k_cos.c +135 -0
  104. data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +354 -0
  105. data/vendor/spidermonkey/fdlibm/k_sin.c +114 -0
  106. data/vendor/spidermonkey/fdlibm/k_standard.c +785 -0
  107. data/vendor/spidermonkey/fdlibm/k_tan.c +170 -0
  108. data/vendor/spidermonkey/fdlibm/s_asinh.c +101 -0
  109. data/vendor/spidermonkey/fdlibm/s_atan.c +175 -0
  110. data/vendor/spidermonkey/fdlibm/s_cbrt.c +133 -0
  111. data/vendor/spidermonkey/fdlibm/s_ceil.c +120 -0
  112. data/vendor/spidermonkey/fdlibm/s_copysign.c +72 -0
  113. data/vendor/spidermonkey/fdlibm/s_cos.c +118 -0
  114. data/vendor/spidermonkey/fdlibm/s_erf.c +356 -0
  115. data/vendor/spidermonkey/fdlibm/s_expm1.c +267 -0
  116. data/vendor/spidermonkey/fdlibm/s_fabs.c +70 -0
  117. data/vendor/spidermonkey/fdlibm/s_finite.c +71 -0
  118. data/vendor/spidermonkey/fdlibm/s_floor.c +121 -0
  119. data/vendor/spidermonkey/fdlibm/s_frexp.c +99 -0
  120. data/vendor/spidermonkey/fdlibm/s_ilogb.c +85 -0
  121. data/vendor/spidermonkey/fdlibm/s_isnan.c +74 -0
  122. data/vendor/spidermonkey/fdlibm/s_ldexp.c +66 -0
  123. data/vendor/spidermonkey/fdlibm/s_lib_version.c +73 -0
  124. data/vendor/spidermonkey/fdlibm/s_log1p.c +211 -0
  125. data/vendor/spidermonkey/fdlibm/s_logb.c +79 -0
  126. data/vendor/spidermonkey/fdlibm/s_matherr.c +64 -0
  127. data/vendor/spidermonkey/fdlibm/s_modf.c +132 -0
  128. data/vendor/spidermonkey/fdlibm/s_nextafter.c +124 -0
  129. data/vendor/spidermonkey/fdlibm/s_rint.c +131 -0
  130. data/vendor/spidermonkey/fdlibm/s_scalbn.c +107 -0
  131. data/vendor/spidermonkey/fdlibm/s_signgam.c +40 -0
  132. data/vendor/spidermonkey/fdlibm/s_significand.c +68 -0
  133. data/vendor/spidermonkey/fdlibm/s_sin.c +118 -0
  134. data/vendor/spidermonkey/fdlibm/s_tan.c +112 -0
  135. data/vendor/spidermonkey/fdlibm/s_tanh.c +122 -0
  136. data/vendor/spidermonkey/fdlibm/w_acos.c +78 -0
  137. data/vendor/spidermonkey/fdlibm/w_acosh.c +78 -0
  138. data/vendor/spidermonkey/fdlibm/w_asin.c +80 -0
  139. data/vendor/spidermonkey/fdlibm/w_atan2.c +79 -0
  140. data/vendor/spidermonkey/fdlibm/w_atanh.c +81 -0
  141. data/vendor/spidermonkey/fdlibm/w_cosh.c +77 -0
  142. data/vendor/spidermonkey/fdlibm/w_exp.c +88 -0
  143. data/vendor/spidermonkey/fdlibm/w_fmod.c +78 -0
  144. data/vendor/spidermonkey/fdlibm/w_gamma.c +85 -0
  145. data/vendor/spidermonkey/fdlibm/w_gamma_r.c +81 -0
  146. data/vendor/spidermonkey/fdlibm/w_hypot.c +78 -0
  147. data/vendor/spidermonkey/fdlibm/w_j0.c +105 -0
  148. data/vendor/spidermonkey/fdlibm/w_j1.c +106 -0
  149. data/vendor/spidermonkey/fdlibm/w_jn.c +128 -0
  150. data/vendor/spidermonkey/fdlibm/w_lgamma.c +85 -0
  151. data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +81 -0
  152. data/vendor/spidermonkey/fdlibm/w_log.c +78 -0
  153. data/vendor/spidermonkey/fdlibm/w_log10.c +81 -0
  154. data/vendor/spidermonkey/fdlibm/w_pow.c +99 -0
  155. data/vendor/spidermonkey/fdlibm/w_remainder.c +77 -0
  156. data/vendor/spidermonkey/fdlibm/w_scalb.c +95 -0
  157. data/vendor/spidermonkey/fdlibm/w_sinh.c +77 -0
  158. data/vendor/spidermonkey/fdlibm/w_sqrt.c +77 -0
  159. data/vendor/spidermonkey/javascript-trace.d +73 -0
  160. data/vendor/spidermonkey/js.c +3951 -0
  161. data/vendor/spidermonkey/js.mak +4438 -0
  162. data/vendor/spidermonkey/js.mdp +0 -0
  163. data/vendor/spidermonkey/js.msg +307 -0
  164. data/vendor/spidermonkey/js.pkg +2 -0
  165. data/vendor/spidermonkey/js3240.rc +79 -0
  166. data/vendor/spidermonkey/jsOS240.def +654 -0
  167. data/vendor/spidermonkey/jsapi.c +5836 -0
  168. data/vendor/spidermonkey/jsapi.h +2624 -0
  169. data/vendor/spidermonkey/jsarena.c +450 -0
  170. data/vendor/spidermonkey/jsarena.h +318 -0
  171. data/vendor/spidermonkey/jsarray.c +2988 -0
  172. data/vendor/spidermonkey/jsarray.h +124 -0
  173. data/vendor/spidermonkey/jsatom.c +1045 -0
  174. data/vendor/spidermonkey/jsatom.h +442 -0
  175. data/vendor/spidermonkey/jsbit.h +253 -0
  176. data/vendor/spidermonkey/jsbool.c +176 -0
  177. data/vendor/spidermonkey/jsbool.h +73 -0
  178. data/vendor/spidermonkey/jsclist.h +139 -0
  179. data/vendor/spidermonkey/jscntxt.c +1348 -0
  180. data/vendor/spidermonkey/jscntxt.h +1120 -0
  181. data/vendor/spidermonkey/jscompat.h +57 -0
  182. data/vendor/spidermonkey/jsconfig.h +248 -0
  183. data/vendor/spidermonkey/jsconfig.mk +181 -0
  184. data/vendor/spidermonkey/jscpucfg.c +383 -0
  185. data/vendor/spidermonkey/jscpucfg.h +212 -0
  186. data/vendor/spidermonkey/jsdate.c +2398 -0
  187. data/vendor/spidermonkey/jsdate.h +124 -0
  188. data/vendor/spidermonkey/jsdbgapi.c +1799 -0
  189. data/vendor/spidermonkey/jsdbgapi.h +464 -0
  190. data/vendor/spidermonkey/jsdhash.c +868 -0
  191. data/vendor/spidermonkey/jsdhash.h +592 -0
  192. data/vendor/spidermonkey/jsdtoa.c +3167 -0
  193. data/vendor/spidermonkey/jsdtoa.h +130 -0
  194. data/vendor/spidermonkey/jsdtracef.c +317 -0
  195. data/vendor/spidermonkey/jsdtracef.h +77 -0
  196. data/vendor/spidermonkey/jsemit.c +6909 -0
  197. data/vendor/spidermonkey/jsemit.h +741 -0
  198. data/vendor/spidermonkey/jsexn.c +1371 -0
  199. data/vendor/spidermonkey/jsexn.h +96 -0
  200. data/vendor/spidermonkey/jsfile.c +2736 -0
  201. data/vendor/spidermonkey/jsfile.h +56 -0
  202. data/vendor/spidermonkey/jsfile.msg +90 -0
  203. data/vendor/spidermonkey/jsfun.c +2634 -0
  204. data/vendor/spidermonkey/jsfun.h +254 -0
  205. data/vendor/spidermonkey/jsgc.c +3554 -0
  206. data/vendor/spidermonkey/jsgc.h +403 -0
  207. data/vendor/spidermonkey/jshash.c +476 -0
  208. data/vendor/spidermonkey/jshash.h +151 -0
  209. data/vendor/spidermonkey/jsify.pl +485 -0
  210. data/vendor/spidermonkey/jsinterp.c +6981 -0
  211. data/vendor/spidermonkey/jsinterp.h +521 -0
  212. data/vendor/spidermonkey/jsinvoke.c +43 -0
  213. data/vendor/spidermonkey/jsiter.c +1067 -0
  214. data/vendor/spidermonkey/jsiter.h +122 -0
  215. data/vendor/spidermonkey/jskeyword.tbl +124 -0
  216. data/vendor/spidermonkey/jskwgen.c +460 -0
  217. data/vendor/spidermonkey/jslibmath.h +266 -0
  218. data/vendor/spidermonkey/jslock.c +1309 -0
  219. data/vendor/spidermonkey/jslock.h +313 -0
  220. data/vendor/spidermonkey/jslocko.asm +60 -0
  221. data/vendor/spidermonkey/jslog2.c +94 -0
  222. data/vendor/spidermonkey/jslong.c +264 -0
  223. data/vendor/spidermonkey/jslong.h +412 -0
  224. data/vendor/spidermonkey/jsmath.c +568 -0
  225. data/vendor/spidermonkey/jsmath.h +57 -0
  226. data/vendor/spidermonkey/jsnum.c +1228 -0
  227. data/vendor/spidermonkey/jsnum.h +283 -0
  228. data/vendor/spidermonkey/jsobj.c +5266 -0
  229. data/vendor/spidermonkey/jsobj.h +709 -0
  230. data/vendor/spidermonkey/jsopcode.c +5245 -0
  231. data/vendor/spidermonkey/jsopcode.h +394 -0
  232. data/vendor/spidermonkey/jsopcode.tbl +523 -0
  233. data/vendor/spidermonkey/jsotypes.h +202 -0
  234. data/vendor/spidermonkey/jsparse.c +6680 -0
  235. data/vendor/spidermonkey/jsparse.h +511 -0
  236. data/vendor/spidermonkey/jsprf.c +1262 -0
  237. data/vendor/spidermonkey/jsprf.h +150 -0
  238. data/vendor/spidermonkey/jsproto.tbl +128 -0
  239. data/vendor/spidermonkey/jsprvtd.h +267 -0
  240. data/vendor/spidermonkey/jspubtd.h +744 -0
  241. data/vendor/spidermonkey/jsregexp.c +4352 -0
  242. data/vendor/spidermonkey/jsregexp.h +183 -0
  243. data/vendor/spidermonkey/jsreops.tbl +145 -0
  244. data/vendor/spidermonkey/jsscan.c +2003 -0
  245. data/vendor/spidermonkey/jsscan.h +387 -0
  246. data/vendor/spidermonkey/jsscope.c +1948 -0
  247. data/vendor/spidermonkey/jsscope.h +418 -0
  248. data/vendor/spidermonkey/jsscript.c +1832 -0
  249. data/vendor/spidermonkey/jsscript.h +287 -0
  250. data/vendor/spidermonkey/jsshell.msg +50 -0
  251. data/vendor/spidermonkey/jsstddef.h +83 -0
  252. data/vendor/spidermonkey/jsstr.c +5004 -0
  253. data/vendor/spidermonkey/jsstr.h +641 -0
  254. data/vendor/spidermonkey/jstypes.h +475 -0
  255. data/vendor/spidermonkey/jsutil.c +345 -0
  256. data/vendor/spidermonkey/jsutil.h +157 -0
  257. data/vendor/spidermonkey/jsxdrapi.c +800 -0
  258. data/vendor/spidermonkey/jsxdrapi.h +218 -0
  259. data/vendor/spidermonkey/jsxml.c +8471 -0
  260. data/vendor/spidermonkey/jsxml.h +349 -0
  261. data/vendor/spidermonkey/lock_SunOS.s +119 -0
  262. data/vendor/spidermonkey/perfect.js +39 -0
  263. data/vendor/spidermonkey/plify_jsdhash.sed +36 -0
  264. data/vendor/spidermonkey/prmjtime.c +846 -0
  265. data/vendor/spidermonkey/prmjtime.h +103 -0
  266. data/vendor/spidermonkey/resource.h +15 -0
  267. data/vendor/spidermonkey/rules.mk +197 -0
  268. data/vendor/spidermonkey/win32.order +384 -0
  269. metadata +4 -3
@@ -0,0 +1,511 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ * vim: set ts=8 sw=4 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
+ #ifndef jsparse_h___
42
+ #define jsparse_h___
43
+ /*
44
+ * JS parser definitions.
45
+ */
46
+ #include "jsconfig.h"
47
+ #include "jsprvtd.h"
48
+ #include "jspubtd.h"
49
+ #include "jsscan.h"
50
+
51
+ JS_BEGIN_EXTERN_C
52
+
53
+ /*
54
+ * Parsing builds a tree of nodes that directs code generation. This tree is
55
+ * not a concrete syntax tree in all respects (for example, || and && are left
56
+ * associative, but (A && B && C) translates into the right-associated tree
57
+ * <A && <B && C>> so that code generation can emit a left-associative branch
58
+ * around <B && C> when A is false). Nodes are labeled by token type, with a
59
+ * JSOp secondary label when needed:
60
+ *
61
+ * Label Variant Members
62
+ * ----- ------- -------
63
+ * <Definitions>
64
+ * TOK_FUNCTION func pn_funpob: JSParsedObjectBox holding function
65
+ * object containing arg and var properties. We
66
+ * create the function object at parse (not emit)
67
+ * time to specialize arg and var bytecodes early.
68
+ * pn_body: TOK_LC node for function body statements
69
+ * pn_flags: TCF_FUN_* flags (see jsemit.h) collected
70
+ * while parsing the function's body
71
+ * pn_sclen: maximum lexical scope chain length
72
+ *
73
+ * <Statements>
74
+ * TOK_LC list pn_head: list of pn_count statements
75
+ * TOK_EXPORT list pn_head: list of pn_count TOK_NAMEs or one TOK_STAR
76
+ * (which is not a multiply node)
77
+ * TOK_IMPORT list pn_head: list of pn_count sub-trees of the form
78
+ * a.b.*, a[b].*, a.*, a.b, or a[b] -- but never a.
79
+ * Each member is expressed with TOK_DOT or TOK_LB.
80
+ * Each sub-tree's root node has a pn_op in the set
81
+ * JSOP_IMPORT{ALL,PROP,ELEM}
82
+ * TOK_IF ternary pn_kid1: cond, pn_kid2: then, pn_kid3: else or null
83
+ * TOK_SWITCH binary pn_left: discriminant
84
+ * pn_right: list of TOK_CASE nodes, with at most one
85
+ * TOK_DEFAULT node, or if there are let bindings
86
+ * in the top level of the switch body's cases, a
87
+ * TOK_LEXICALSCOPE node that contains the list of
88
+ * TOK_CASE nodes.
89
+ * TOK_CASE, binary pn_left: case expr or null if TOK_DEFAULT
90
+ * TOK_DEFAULT pn_right: TOK_LC node for this case's statements
91
+ * pn_val: constant value if lookup or table switch
92
+ * TOK_WHILE binary pn_left: cond, pn_right: body
93
+ * TOK_DO binary pn_left: body, pn_right: cond
94
+ * TOK_FOR binary pn_left: either
95
+ * for/in loop: a binary TOK_IN node with
96
+ * pn_left: TOK_VAR or TOK_NAME to left of 'in'
97
+ * if TOK_VAR, its pn_extra may have PNX_POPVAR
98
+ * and PNX_FORINVAR bits set
99
+ * pn_right: object expr to right of 'in'
100
+ * for(;;) loop: a ternary TOK_RESERVED node with
101
+ * pn_kid1: init expr before first ';'
102
+ * pn_kid2: cond expr before second ';'
103
+ * pn_kid3: update expr after second ';'
104
+ * any kid may be null
105
+ * pn_right: body
106
+ * TOK_THROW unary pn_op: JSOP_THROW, pn_kid: exception
107
+ * TOK_TRY ternary pn_kid1: try block
108
+ * pn_kid2: null or TOK_RESERVED list of
109
+ * TOK_LEXICALSCOPE nodes, each with pn_expr pointing
110
+ * to a TOK_CATCH node
111
+ * pn_kid3: null or finally block
112
+ * TOK_CATCH ternary pn_kid1: TOK_NAME, TOK_RB, or TOK_RC catch var node
113
+ * (TOK_RB or TOK_RC if destructuring)
114
+ * pn_kid2: null or the catch guard expression
115
+ * pn_kid3: catch block statements
116
+ * TOK_BREAK name pn_atom: label or null
117
+ * TOK_CONTINUE name pn_atom: label or null
118
+ * TOK_WITH binary pn_left: head expr, pn_right: body
119
+ * TOK_VAR list pn_head: list of pn_count TOK_NAME nodes
120
+ * each name node has
121
+ * pn_atom: variable name
122
+ * pn_expr: initializer or null
123
+ * TOK_RETURN unary pn_kid: return expr or null
124
+ * TOK_SEMI unary pn_kid: expr or null statement
125
+ * TOK_COLON name pn_atom: label, pn_expr: labeled statement
126
+ *
127
+ * <Expressions>
128
+ * All left-associated binary trees of the same type are optimized into lists
129
+ * to avoid recursion when processing expression chains.
130
+ * TOK_COMMA list pn_head: list of pn_count comma-separated exprs
131
+ * TOK_ASSIGN binary pn_left: lvalue, pn_right: rvalue
132
+ * pn_op: JSOP_ADD for +=, etc.
133
+ * TOK_HOOK ternary pn_kid1: cond, pn_kid2: then, pn_kid3: else
134
+ * TOK_OR binary pn_left: first in || chain, pn_right: rest of chain
135
+ * TOK_AND binary pn_left: first in && chain, pn_right: rest of chain
136
+ * TOK_BITOR binary pn_left: left-assoc | expr, pn_right: ^ expr
137
+ * TOK_BITXOR binary pn_left: left-assoc ^ expr, pn_right: & expr
138
+ * TOK_BITAND binary pn_left: left-assoc & expr, pn_right: EQ expr
139
+ * TOK_EQOP binary pn_left: left-assoc EQ expr, pn_right: REL expr
140
+ * pn_op: JSOP_EQ, JSOP_NE,
141
+ * JSOP_STRICTEQ, JSOP_STRICTNE
142
+ * TOK_RELOP binary pn_left: left-assoc REL expr, pn_right: SH expr
143
+ * pn_op: JSOP_LT, JSOP_LE, JSOP_GT, JSOP_GE
144
+ * TOK_SHOP binary pn_left: left-assoc SH expr, pn_right: ADD expr
145
+ * pn_op: JSOP_LSH, JSOP_RSH, JSOP_URSH
146
+ * TOK_PLUS, binary pn_left: left-assoc ADD expr, pn_right: MUL expr
147
+ * pn_extra: if a left-associated binary TOK_PLUS
148
+ * tree has been flattened into a list (see above
149
+ * under <Expressions>), pn_extra will contain
150
+ * PNX_STRCAT if at least one list element is a
151
+ * string literal (TOK_STRING); if such a list has
152
+ * any non-string, non-number term, pn_extra will
153
+ * contain PNX_CANTFOLD.
154
+ * pn_
155
+ * TOK_MINUS pn_op: JSOP_ADD, JSOP_SUB
156
+ * TOK_STAR, binary pn_left: left-assoc MUL expr, pn_right: UNARY expr
157
+ * TOK_DIVOP pn_op: JSOP_MUL, JSOP_DIV, JSOP_MOD
158
+ * TOK_UNARYOP unary pn_kid: UNARY expr, pn_op: JSOP_NEG, JSOP_POS,
159
+ * JSOP_NOT, JSOP_BITNOT, JSOP_TYPEOF, JSOP_VOID
160
+ * TOK_INC, unary pn_kid: MEMBER expr
161
+ * TOK_DEC
162
+ * TOK_NEW list pn_head: list of ctor, arg1, arg2, ... argN
163
+ * pn_count: 1 + N (where N is number of args)
164
+ * ctor is a MEMBER expr
165
+ * TOK_DELETE unary pn_kid: MEMBER expr
166
+ * TOK_DOT, name pn_expr: MEMBER expr to left of .
167
+ * TOK_DBLDOT pn_atom: name to right of .
168
+ * TOK_LB binary pn_left: MEMBER expr to left of [
169
+ * pn_right: expr between [ and ]
170
+ * TOK_LP list pn_head: list of call, arg1, arg2, ... argN
171
+ * pn_count: 1 + N (where N is number of args)
172
+ * call is a MEMBER expr naming a callable object
173
+ * TOK_RB list pn_head: list of pn_count array element exprs
174
+ * [,,] holes are represented by TOK_COMMA nodes
175
+ * #n=[...] produces TOK_DEFSHARP at head of list
176
+ * pn_extra: PN_ENDCOMMA if extra comma at end
177
+ * TOK_RC list pn_head: list of pn_count TOK_COLON nodes where
178
+ * each has pn_left: property id, pn_right: value
179
+ * #n={...} produces TOK_DEFSHARP at head of list
180
+ * var {x} = object destructuring shorthand shares
181
+ * PN_NAME node for x on left and right of TOK_COLON
182
+ * node in TOK_RC's list, has PNX_SHORTHAND flag
183
+ * TOK_DEFSHARP unary pn_num: jsint value of n in #n=
184
+ * pn_kid: null for #n=[...] and #n={...}, primary
185
+ * if #n=primary for function, paren, name, object
186
+ * literal expressions
187
+ * TOK_USESHARP nullary pn_num: jsint value of n in #n#
188
+ * TOK_RP unary pn_kid: parenthesized expression
189
+ * TOK_NAME, name pn_atom: name, string, or object atom
190
+ * TOK_STRING, pn_op: JSOP_NAME, JSOP_STRING, or JSOP_OBJECT, or
191
+ * JSOP_REGEXP
192
+ * TOK_REGEXP If JSOP_NAME, pn_op may be JSOP_*ARG or JSOP_*VAR
193
+ * with pn_slot >= 0 and pn_const telling const-ness
194
+ * TOK_NUMBER dval pn_dval: double value of numeric literal
195
+ * TOK_PRIMARY nullary pn_op: JSOp bytecode
196
+ *
197
+ * <E4X node descriptions>
198
+ * TOK_ANYNAME nullary pn_op: JSOP_ANYNAME
199
+ * pn_atom: cx->runtime->atomState.starAtom
200
+ * TOK_AT unary pn_op: JSOP_TOATTRNAME; pn_kid attribute id/expr
201
+ * TOK_DBLCOLON binary pn_op: JSOP_QNAME
202
+ * pn_left: TOK_ANYNAME or TOK_NAME node
203
+ * pn_right: TOK_STRING "*" node, or expr within []
204
+ * name pn_op: JSOP_QNAMECONST
205
+ * pn_expr: TOK_ANYNAME or TOK_NAME left operand
206
+ * pn_atom: name on right of ::
207
+ * TOK_XMLELEM list XML element node
208
+ * pn_head: start tag, content1, ... contentN, end tag
209
+ * pn_count: 2 + N where N is number of content nodes
210
+ * N may be > x.length() if {expr} embedded
211
+ * TOK_XMLLIST list XML list node
212
+ * pn_head: content1, ... contentN
213
+ * TOK_XMLSTAGO, list XML start, end, and point tag contents
214
+ * TOK_XMLETAGC, pn_head: tag name or {expr}, ... XML attrs ...
215
+ * TOK_XMLPTAGO
216
+ * TOK_XMLNAME nullary pn_atom: XML name, with no {expr} embedded
217
+ * TOK_XMLNAME list pn_head: tag name or {expr}, ... name or {expr}
218
+ * TOK_XMLATTR, nullary pn_atom: attribute value string; pn_op: JSOP_STRING
219
+ * TOK_XMLCDATA,
220
+ * TOK_XMLCOMMENT
221
+ * TOK_XMLPI nullary pn_atom: XML processing instruction target
222
+ * pn_atom2: XML PI content, or null if no content
223
+ * TOK_XMLTEXT nullary pn_atom: marked-up text, or null if empty string
224
+ * TOK_LC unary {expr} in XML tag or content; pn_kid is expr
225
+ *
226
+ * So an XML tag with no {expr} and three attributes is a list with the form:
227
+ *
228
+ * (tagname attrname1 attrvalue1 attrname2 attrvalue2 attrname2 attrvalue3)
229
+ *
230
+ * An XML tag with embedded expressions like so:
231
+ *
232
+ * <name1{expr1} name2{expr2}name3={expr3}>
233
+ *
234
+ * would have the form:
235
+ *
236
+ * ((name1 {expr1}) (name2 {expr2} name3) {expr3})
237
+ *
238
+ * where () bracket a list with elements separated by spaces, and {expr} is a
239
+ * TOK_LC unary node with expr as its kid.
240
+ *
241
+ * Thus, the attribute name/value pairs occupy successive odd and even list
242
+ * locations, where pn_head is the TOK_XMLNAME node at list location 0. The
243
+ * parser builds the same sort of structures for elements:
244
+ *
245
+ * <a x={x}>Hi there!<b y={y}>How are you?</b><answer>{x + y}</answer></a>
246
+ *
247
+ * translates to:
248
+ *
249
+ * ((a x {x}) 'Hi there!' ((b y {y}) 'How are you?') ((answer) {x + y}))
250
+ *
251
+ * <Non-E4X node descriptions, continued>
252
+ *
253
+ * Label Variant Members
254
+ * ----- ------- -------
255
+ * TOK_LEXICALSCOPE name pn_op: JSOP_LEAVEBLOCK or JSOP_LEAVEBLOCKEXPR
256
+ * pn_pob: block object
257
+ * pn_expr: block body
258
+ * TOK_ARRAYCOMP list pn_head: list of pn_count (1 or 2) elements
259
+ * if pn_count is 2, first element is #n=[...]
260
+ * last element is block enclosing for loop(s)
261
+ * and optionally if-guarded TOK_ARRAYPUSH
262
+ * pn_extra: stack slot, used during code gen
263
+ * TOK_ARRAYPUSH unary pn_op: JSOP_ARRAYCOMP
264
+ * pn_kid: array comprehension expression
265
+ */
266
+ typedef enum JSParseNodeArity {
267
+ PN_FUNC = -3,
268
+ PN_LIST = -2,
269
+ PN_TERNARY = 3,
270
+ PN_BINARY = 2,
271
+ PN_UNARY = 1,
272
+ PN_NAME = -1,
273
+ PN_NULLARY = 0
274
+ } JSParseNodeArity;
275
+
276
+ struct JSParseNode {
277
+ uint16 pn_type;
278
+ uint8 pn_op;
279
+ int8 pn_arity;
280
+ JSTokenPos pn_pos;
281
+ ptrdiff_t pn_offset; /* first generated bytecode offset */
282
+ union {
283
+ struct { /* TOK_FUNCTION node */
284
+ JSParsedObjectBox *funpob; /* function object */
285
+ JSParseNode *body; /* TOK_LC list of statements */
286
+ uint16 flags; /* accumulated tree context flags */
287
+ uint16 sclen; /* maximum scope chain length */
288
+ uint32 index; /* emitter's index */
289
+ } func;
290
+ struct { /* list of next-linked nodes */
291
+ JSParseNode *head; /* first node in list */
292
+ JSParseNode **tail; /* ptr to ptr to last node in list */
293
+ uint32 count; /* number of nodes in list */
294
+ uint32 extra; /* extra flags, see below */
295
+ } list;
296
+ struct { /* ternary: if, for(;;), ?: */
297
+ JSParseNode *kid1; /* condition, discriminant, etc. */
298
+ JSParseNode *kid2; /* then-part, case list, etc. */
299
+ JSParseNode *kid3; /* else-part, default case, etc. */
300
+ } ternary;
301
+ struct { /* two kids if binary */
302
+ JSParseNode *left;
303
+ JSParseNode *right;
304
+ jsval val; /* switch case value */
305
+ } binary;
306
+ struct { /* one kid if unary */
307
+ JSParseNode *kid;
308
+ jsint num; /* -1 or sharp variable number */
309
+ JSBool hidden; /* hidden genexp-induced JSOP_YIELD */
310
+ } unary;
311
+ struct { /* name, labeled statement, etc. */
312
+ JSAtom *atom; /* name or label atom, null if slot */
313
+ JSParseNode *expr; /* object or initializer */
314
+ jsint slot; /* -1 or arg or local var slot */
315
+ JSBool isconst; /* true for const names */
316
+ } name;
317
+ struct { /* lexical scope. */
318
+ JSParsedObjectBox *pob; /* block object */
319
+ JSParseNode *expr; /* object or initializer */
320
+ jsint slot; /* -1 or arg or local var slot */
321
+ } lexical;
322
+ struct {
323
+ JSAtom *atom; /* first atom in pair */
324
+ JSAtom *atom2; /* second atom in pair or null */
325
+ } apair;
326
+ struct { /* object literal */
327
+ JSParsedObjectBox *pob;
328
+ } object;
329
+ jsdouble dval; /* aligned numeric literal value */
330
+ } pn_u;
331
+ JSParseNode *pn_next; /* to align dval and pn_u on RISCs */
332
+ };
333
+
334
+ #define pn_funpob pn_u.func.funpob
335
+ #define pn_body pn_u.func.body
336
+ #define pn_flags pn_u.func.flags
337
+ #define pn_sclen pn_u.func.sclen
338
+ #define pn_index pn_u.func.index
339
+ #define pn_head pn_u.list.head
340
+ #define pn_tail pn_u.list.tail
341
+ #define pn_count pn_u.list.count
342
+ #define pn_extra pn_u.list.extra
343
+ #define pn_kid1 pn_u.ternary.kid1
344
+ #define pn_kid2 pn_u.ternary.kid2
345
+ #define pn_kid3 pn_u.ternary.kid3
346
+ #define pn_left pn_u.binary.left
347
+ #define pn_right pn_u.binary.right
348
+ #define pn_val pn_u.binary.val
349
+ #define pn_kid pn_u.unary.kid
350
+ #define pn_num pn_u.unary.num
351
+ #define pn_hidden pn_u.unary.hidden
352
+ #define pn_atom pn_u.name.atom
353
+ #define pn_expr pn_u.name.expr
354
+ #define pn_slot pn_u.name.slot
355
+ #define pn_const pn_u.name.isconst
356
+ #define pn_dval pn_u.dval
357
+ #define pn_atom2 pn_u.apair.atom2
358
+ #define pn_pob pn_u.object.pob
359
+
360
+ /* PN_LIST pn_extra flags. */
361
+ #define PNX_STRCAT 0x01 /* TOK_PLUS list has string term */
362
+ #define PNX_CANTFOLD 0x02 /* TOK_PLUS list has unfoldable term */
363
+ #define PNX_POPVAR 0x04 /* TOK_VAR last result needs popping */
364
+ #define PNX_FORINVAR 0x08 /* TOK_VAR is left kid of TOK_IN node,
365
+ which is left kid of TOK_FOR */
366
+ #define PNX_ENDCOMMA 0x10 /* array literal has comma at end */
367
+ #define PNX_XMLROOT 0x20 /* top-most node in XML literal tree */
368
+ #define PNX_GROUPINIT 0x40 /* var [a, b] = [c, d]; unit list */
369
+ #define PNX_NEEDBRACES 0x80 /* braces necessary due to closure */
370
+ #define PNX_FUNCDEFS 0x100 /* contains top-level function
371
+ statements */
372
+ #define PNX_SHORTHAND 0x200 /* shorthand syntax used, at present
373
+ object destructuring ({x,y}) only */
374
+
375
+ /*
376
+ * Move pn2 into pn, preserving pn->pn_pos and pn->pn_offset and handing off
377
+ * any kids in pn2->pn_u, by clearing pn2.
378
+ */
379
+ #define PN_MOVE_NODE(pn, pn2) \
380
+ JS_BEGIN_MACRO \
381
+ (pn)->pn_type = (pn2)->pn_type; \
382
+ (pn)->pn_op = (pn2)->pn_op; \
383
+ (pn)->pn_arity = (pn2)->pn_arity; \
384
+ (pn)->pn_u = (pn2)->pn_u; \
385
+ PN_CLEAR_NODE(pn2); \
386
+ JS_END_MACRO
387
+
388
+ #define PN_CLEAR_NODE(pn) \
389
+ JS_BEGIN_MACRO \
390
+ (pn)->pn_type = TOK_EOF; \
391
+ (pn)->pn_op = JSOP_NOP; \
392
+ (pn)->pn_arity = PN_NULLARY; \
393
+ JS_END_MACRO
394
+
395
+ /* True if pn is a parsenode representing a literal constant. */
396
+ #define PN_IS_CONSTANT(pn) \
397
+ ((pn)->pn_type == TOK_NUMBER || \
398
+ (pn)->pn_type == TOK_STRING || \
399
+ ((pn)->pn_type == TOK_PRIMARY && (pn)->pn_op != JSOP_THIS))
400
+
401
+ #define PN_OP(pn) ((JSOp)(pn)->pn_op)
402
+ #define PN_TYPE(pn) ((JSTokenType)(pn)->pn_type)
403
+
404
+ /*
405
+ * Compute a pointer to the last JSParseNode element in a singly-linked list.
406
+ * NB: list must be non-empty for correct PN_LAST usage!
407
+ */
408
+ #define PN_LAST(list) \
409
+ ((JSParseNode *)((char *)(list)->pn_tail - offsetof(JSParseNode, pn_next)))
410
+
411
+ #define PN_INIT_LIST(list) \
412
+ JS_BEGIN_MACRO \
413
+ (list)->pn_head = NULL; \
414
+ (list)->pn_tail = &(list)->pn_head; \
415
+ (list)->pn_count = (list)->pn_extra = 0; \
416
+ JS_END_MACRO
417
+
418
+ #define PN_INIT_LIST_1(list, pn) \
419
+ JS_BEGIN_MACRO \
420
+ (list)->pn_head = (pn); \
421
+ (list)->pn_tail = &(pn)->pn_next; \
422
+ (list)->pn_count = 1; \
423
+ (list)->pn_extra = 0; \
424
+ JS_END_MACRO
425
+
426
+ #define PN_APPEND(list, pn) \
427
+ JS_BEGIN_MACRO \
428
+ *(list)->pn_tail = (pn); \
429
+ (list)->pn_tail = &(pn)->pn_next; \
430
+ (list)->pn_count++; \
431
+ JS_END_MACRO
432
+
433
+ struct JSParsedObjectBox {
434
+ JSParsedObjectBox *traceLink;
435
+ JSParsedObjectBox *emitLink;
436
+ JSObject *object;
437
+ };
438
+
439
+ struct JSParseContext {
440
+ JSTokenStream tokenStream;
441
+ void *tempPoolMark; /* initial JSContext.tempPool mark */
442
+ JSPrincipals *principals; /* principals associated with source */
443
+ JSParseNode *nodeList; /* list of recyclable parse-node
444
+ structs */
445
+ JSParsedObjectBox *traceListHead; /* list of parsed object for GC
446
+ tracing */
447
+ JSTempValueRooter tempRoot; /* root to trace traceListHead */
448
+ };
449
+
450
+ /*
451
+ * Convenience macro to access JSParseContext.tokenStream as a pointer.
452
+ */
453
+ #define TS(pc) (&(pc)->tokenStream)
454
+
455
+ /*
456
+ * Parse a top-level JS script.
457
+ */
458
+ extern JSParseNode *
459
+ js_ParseScript(JSContext *cx, JSObject *chain, JSParseContext *pc);
460
+
461
+ extern JSScript *
462
+ js_CompileScript(JSContext *cx, JSObject *obj, JSPrincipals *principals,
463
+ uint32 tcflags, const jschar *chars, size_t length,
464
+ FILE *file, const char *filename, uintN lineno);
465
+
466
+ extern JSBool
467
+ js_CompileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *principals,
468
+ const jschar *chars, size_t length,
469
+ const char *filename, uintN lineno);
470
+
471
+ extern JSBool
472
+ js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc);
473
+
474
+ #if JS_HAS_XML_SUPPORT
475
+ JS_FRIEND_API(JSParseNode *)
476
+ js_ParseXMLText(JSContext *cx, JSObject *chain, JSParseContext *pc,
477
+ JSBool allowList);
478
+ #endif
479
+
480
+ /*
481
+ * Initialize a parse context. All parameters after pc are passed to
482
+ * js_InitTokenStream.
483
+ *
484
+ * The parse context owns the arena pool "tops-of-stack" space above the
485
+ * current JSContext.tempPool mark. This means you cannot allocate from
486
+ * tempPool and save the pointer beyond the next js_FinishParseContext.
487
+ */
488
+ extern JSBool
489
+ js_InitParseContext(JSContext *cx, JSParseContext *pc, JSPrincipals *principals,
490
+ const jschar *base, size_t length, FILE *fp,
491
+ const char *filename, uintN lineno);
492
+
493
+ extern void
494
+ js_FinishParseContext(JSContext *cx, JSParseContext *pc);
495
+
496
+ extern void
497
+ js_InitCompilePrincipals(JSContext *cx, JSParseContext *pc,
498
+ JSPrincipals *principals);
499
+
500
+ /*
501
+ * Allocate a new parseed object node from cx->tempPool.
502
+ */
503
+ extern JSParsedObjectBox *
504
+ js_NewParsedObjectBox(JSContext *cx, JSParseContext *pc, JSObject *obj);
505
+
506
+ extern void
507
+ js_TraceParseContext(JSTracer *trc, JSParseContext *pc);
508
+
509
+ JS_END_EXTERN_C
510
+
511
+ #endif /* jsparse_h___ */