/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/jsparse.h

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs · C++ Header · 508 lines · 199 code · 29 blank · 280 comment · 7 complexity · 77c76fab19146d72d286e1e54dee4233 MD5 · raw file

  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. #ifndef jsparse_h___
  41. #define jsparse_h___
  42. /*
  43. * JS parser definitions.
  44. */
  45. #include "jsversion.h"
  46. #include "jsprvtd.h"
  47. #include "jspubtd.h"
  48. #include "jsscan.h"
  49. JS_BEGIN_EXTERN_C
  50. /*
  51. * Parsing builds a tree of nodes that directs code generation. This tree is
  52. * not a concrete syntax tree in all respects (for example, || and && are left
  53. * associative, but (A && B && C) translates into the right-associated tree
  54. * <A && <B && C>> so that code generation can emit a left-associative branch
  55. * around <B && C> when A is false). Nodes are labeled by token type, with a
  56. * JSOp secondary label when needed:
  57. *
  58. * Label Variant Members
  59. * ----- ------- -------
  60. * <Definitions>
  61. * TOK_FUNCTION func pn_funpob: JSParsedObjectBox holding function
  62. * object containing arg and var properties. We
  63. * create the function object at parse (not emit)
  64. * time to specialize arg and var bytecodes early.
  65. * pn_body: TOK_LC node for function body statements
  66. * pn_flags: TCF_FUN_* flags (see jsemit.h) collected
  67. * while parsing the function's body
  68. *
  69. * <Statements>
  70. * TOK_LC list pn_head: list of pn_count statements
  71. * TOK_IF ternary pn_kid1: cond, pn_kid2: then, pn_kid3: else or null
  72. * TOK_SWITCH binary pn_left: discriminant
  73. * pn_right: list of TOK_CASE nodes, with at most one
  74. * TOK_DEFAULT node, or if there are let bindings
  75. * in the top level of the switch body's cases, a
  76. * TOK_LEXICALSCOPE node that contains the list of
  77. * TOK_CASE nodes.
  78. * TOK_CASE, binary pn_left: case expr or null if TOK_DEFAULT
  79. * TOK_DEFAULT pn_right: TOK_LC node for this case's statements
  80. * pn_val: constant value if lookup or table switch
  81. * TOK_WHILE binary pn_left: cond, pn_right: body
  82. * TOK_DO binary pn_left: body, pn_right: cond
  83. * TOK_FOR binary pn_left: either
  84. * for/in loop: a binary TOK_IN node with
  85. * pn_left: TOK_VAR or TOK_NAME to left of 'in'
  86. * if TOK_VAR, its pn_extra may have PNX_POPVAR
  87. * and PNX_FORINVAR bits set
  88. * pn_right: object expr to right of 'in'
  89. * for(;;) loop: a ternary TOK_RESERVED node with
  90. * pn_kid1: init expr before first ';'
  91. * pn_kid2: cond expr before second ';'
  92. * pn_kid3: update expr after second ';'
  93. * any kid may be null
  94. * pn_right: body
  95. * TOK_THROW unary pn_op: JSOP_THROW, pn_kid: exception
  96. * TOK_TRY ternary pn_kid1: try block
  97. * pn_kid2: null or TOK_RESERVED list of
  98. * TOK_LEXICALSCOPE nodes, each with pn_expr pointing
  99. * to a TOK_CATCH node
  100. * pn_kid3: null or finally block
  101. * TOK_CATCH ternary pn_kid1: TOK_NAME, TOK_RB, or TOK_RC catch var node
  102. * (TOK_RB or TOK_RC if destructuring)
  103. * pn_kid2: null or the catch guard expression
  104. * pn_kid3: catch block statements
  105. * TOK_BREAK name pn_atom: label or null
  106. * TOK_CONTINUE name pn_atom: label or null
  107. * TOK_WITH binary pn_left: head expr, pn_right: body
  108. * TOK_VAR list pn_head: list of pn_count TOK_NAME nodes
  109. * each name node has
  110. * pn_atom: variable name
  111. * pn_expr: initializer or null
  112. * TOK_RETURN unary pn_kid: return expr or null
  113. * TOK_SEMI unary pn_kid: expr or null statement
  114. * TOK_COLON name pn_atom: label, pn_expr: labeled statement
  115. *
  116. * <Expressions>
  117. * All left-associated binary trees of the same type are optimized into lists
  118. * to avoid recursion when processing expression chains.
  119. * TOK_COMMA list pn_head: list of pn_count comma-separated exprs
  120. * TOK_ASSIGN binary pn_left: lvalue, pn_right: rvalue
  121. * pn_op: JSOP_ADD for +=, etc.
  122. * TOK_HOOK ternary pn_kid1: cond, pn_kid2: then, pn_kid3: else
  123. * TOK_OR binary pn_left: first in || chain, pn_right: rest of chain
  124. * TOK_AND binary pn_left: first in && chain, pn_right: rest of chain
  125. * TOK_BITOR binary pn_left: left-assoc | expr, pn_right: ^ expr
  126. * TOK_BITXOR binary pn_left: left-assoc ^ expr, pn_right: & expr
  127. * TOK_BITAND binary pn_left: left-assoc & expr, pn_right: EQ expr
  128. * TOK_EQOP binary pn_left: left-assoc EQ expr, pn_right: REL expr
  129. * pn_op: JSOP_EQ, JSOP_NE,
  130. * JSOP_STRICTEQ, JSOP_STRICTNE
  131. * TOK_RELOP binary pn_left: left-assoc REL expr, pn_right: SH expr
  132. * pn_op: JSOP_LT, JSOP_LE, JSOP_GT, JSOP_GE
  133. * TOK_SHOP binary pn_left: left-assoc SH expr, pn_right: ADD expr
  134. * pn_op: JSOP_LSH, JSOP_RSH, JSOP_URSH
  135. * TOK_PLUS, binary pn_left: left-assoc ADD expr, pn_right: MUL expr
  136. * pn_extra: if a left-associated binary TOK_PLUS
  137. * tree has been flattened into a list (see above
  138. * under <Expressions>), pn_extra will contain
  139. * PNX_STRCAT if at least one list element is a
  140. * string literal (TOK_STRING); if such a list has
  141. * any non-string, non-number term, pn_extra will
  142. * contain PNX_CANTFOLD.
  143. * pn_
  144. * TOK_MINUS pn_op: JSOP_ADD, JSOP_SUB
  145. * TOK_STAR, binary pn_left: left-assoc MUL expr, pn_right: UNARY expr
  146. * TOK_DIVOP pn_op: JSOP_MUL, JSOP_DIV, JSOP_MOD
  147. * TOK_UNARYOP unary pn_kid: UNARY expr, pn_op: JSOP_NEG, JSOP_POS,
  148. * JSOP_NOT, JSOP_BITNOT, JSOP_TYPEOF, JSOP_VOID
  149. * TOK_INC, unary pn_kid: MEMBER expr
  150. * TOK_DEC
  151. * TOK_NEW list pn_head: list of ctor, arg1, arg2, ... argN
  152. * pn_count: 1 + N (where N is number of args)
  153. * ctor is a MEMBER expr
  154. * TOK_DELETE unary pn_kid: MEMBER expr
  155. * TOK_DOT, name pn_expr: MEMBER expr to left of .
  156. * TOK_DBLDOT pn_atom: name to right of .
  157. * TOK_LB binary pn_left: MEMBER expr to left of [
  158. * pn_right: expr between [ and ]
  159. * TOK_LP list pn_head: list of call, arg1, arg2, ... argN
  160. * pn_count: 1 + N (where N is number of args)
  161. * call is a MEMBER expr naming a callable object
  162. * TOK_RB list pn_head: list of pn_count array element exprs
  163. * [,,] holes are represented by TOK_COMMA nodes
  164. * #n=[...] produces TOK_DEFSHARP at head of list
  165. * pn_extra: PN_ENDCOMMA if extra comma at end
  166. * TOK_RC list pn_head: list of pn_count TOK_COLON nodes where
  167. * each has pn_left: property id, pn_right: value
  168. * #n={...} produces TOK_DEFSHARP at head of list
  169. * var {x} = object destructuring shorthand shares
  170. * PN_NAME node for x on left and right of TOK_COLON
  171. * node in TOK_RC's list, has PNX_SHORTHAND flag
  172. * TOK_DEFSHARP unary pn_num: jsint value of n in #n=
  173. * pn_kid: null for #n=[...] and #n={...}, primary
  174. * if #n=primary for function, paren, name, object
  175. * literal expressions
  176. * TOK_USESHARP nullary pn_num: jsint value of n in #n#
  177. * TOK_RP unary pn_kid: parenthesized expression
  178. * TOK_NAME, name pn_atom: name, string, or object atom
  179. * TOK_STRING, pn_op: JSOP_NAME, JSOP_STRING, or JSOP_OBJECT, or
  180. * JSOP_REGEXP
  181. * TOK_REGEXP If JSOP_NAME, pn_op may be JSOP_*ARG or JSOP_*VAR
  182. * with pn_slot >= 0 and pn_const telling const-ness
  183. * TOK_NUMBER dval pn_dval: double value of numeric literal
  184. * TOK_PRIMARY nullary pn_op: JSOp bytecode
  185. *
  186. * <E4X node descriptions>
  187. * TOK_ANYNAME nullary pn_op: JSOP_ANYNAME
  188. * pn_atom: cx->runtime->atomState.starAtom
  189. * TOK_AT unary pn_op: JSOP_TOATTRNAME; pn_kid attribute id/expr
  190. * TOK_DBLCOLON binary pn_op: JSOP_QNAME
  191. * pn_left: TOK_ANYNAME or TOK_NAME node
  192. * pn_right: TOK_STRING "*" node, or expr within []
  193. * name pn_op: JSOP_QNAMECONST
  194. * pn_expr: TOK_ANYNAME or TOK_NAME left operand
  195. * pn_atom: name on right of ::
  196. * TOK_XMLELEM list XML element node
  197. * pn_head: start tag, content1, ... contentN, end tag
  198. * pn_count: 2 + N where N is number of content nodes
  199. * N may be > x.length() if {expr} embedded
  200. * TOK_XMLLIST list XML list node
  201. * pn_head: content1, ... contentN
  202. * TOK_XMLSTAGO, list XML start, end, and point tag contents
  203. * TOK_XMLETAGC, pn_head: tag name or {expr}, ... XML attrs ...
  204. * TOK_XMLPTAGO
  205. * TOK_XMLNAME nullary pn_atom: XML name, with no {expr} embedded
  206. * TOK_XMLNAME list pn_head: tag name or {expr}, ... name or {expr}
  207. * TOK_XMLATTR, nullary pn_atom: attribute value string; pn_op: JSOP_STRING
  208. * TOK_XMLCDATA,
  209. * TOK_XMLCOMMENT
  210. * TOK_XMLPI nullary pn_atom: XML processing instruction target
  211. * pn_atom2: XML PI content, or null if no content
  212. * TOK_XMLTEXT nullary pn_atom: marked-up text, or null if empty string
  213. * TOK_LC unary {expr} in XML tag or content; pn_kid is expr
  214. *
  215. * So an XML tag with no {expr} and three attributes is a list with the form:
  216. *
  217. * (tagname attrname1 attrvalue1 attrname2 attrvalue2 attrname2 attrvalue3)
  218. *
  219. * An XML tag with embedded expressions like so:
  220. *
  221. * <name1{expr1} name2{expr2}name3={expr3}>
  222. *
  223. * would have the form:
  224. *
  225. * ((name1 {expr1}) (name2 {expr2} name3) {expr3})
  226. *
  227. * where () bracket a list with elements separated by spaces, and {expr} is a
  228. * TOK_LC unary node with expr as its kid.
  229. *
  230. * Thus, the attribute name/value pairs occupy successive odd and even list
  231. * locations, where pn_head is the TOK_XMLNAME node at list location 0. The
  232. * parser builds the same sort of structures for elements:
  233. *
  234. * <a x={x}>Hi there!<b y={y}>How are you?</b><answer>{x + y}</answer></a>
  235. *
  236. * translates to:
  237. *
  238. * ((a x {x}) 'Hi there!' ((b y {y}) 'How are you?') ((answer) {x + y}))
  239. *
  240. * <Non-E4X node descriptions, continued>
  241. *
  242. * Label Variant Members
  243. * ----- ------- -------
  244. * TOK_LEXICALSCOPE name pn_op: JSOP_LEAVEBLOCK or JSOP_LEAVEBLOCKEXPR
  245. * pn_pob: block object
  246. * pn_expr: block body
  247. * TOK_ARRAYCOMP list pn_head: list of pn_count (1 or 2) elements
  248. * if pn_count is 2, first element is #n=[...]
  249. * last element is block enclosing for loop(s)
  250. * and optionally if-guarded TOK_ARRAYPUSH
  251. * pn_extra: stack slot, used during code gen
  252. * TOK_ARRAYPUSH unary pn_op: JSOP_ARRAYCOMP
  253. * pn_kid: array comprehension expression
  254. */
  255. typedef enum JSParseNodeArity {
  256. PN_FUNC = -3,
  257. PN_LIST = -2,
  258. PN_TERNARY = 3,
  259. PN_BINARY = 2,
  260. PN_UNARY = 1,
  261. PN_NAME = -1,
  262. PN_NULLARY = 0
  263. } JSParseNodeArity;
  264. struct JSParseNode {
  265. uint16 pn_type;
  266. uint8 pn_op;
  267. int8 pn_arity;
  268. JSTokenPos pn_pos;
  269. ptrdiff_t pn_offset; /* first generated bytecode offset */
  270. union {
  271. struct { /* TOK_FUNCTION node */
  272. JSParsedObjectBox *funpob; /* function object */
  273. JSParseNode *body; /* TOK_LC list of statements */
  274. uint16 flags; /* accumulated tree context flags */
  275. uint32 index; /* emitter's index */
  276. } func;
  277. struct { /* list of next-linked nodes */
  278. JSParseNode *head; /* first node in list */
  279. JSParseNode **tail; /* ptr to ptr to last node in list */
  280. uint32 count; /* number of nodes in list */
  281. uint32 extra; /* extra flags, see below */
  282. } list;
  283. struct { /* ternary: if, for(;;), ?: */
  284. JSParseNode *kid1; /* condition, discriminant, etc. */
  285. JSParseNode *kid2; /* then-part, case list, etc. */
  286. JSParseNode *kid3; /* else-part, default case, etc. */
  287. } ternary;
  288. struct { /* two kids if binary */
  289. JSParseNode *left;
  290. JSParseNode *right;
  291. jsval val; /* switch case value */
  292. uintN iflags; /* JSITER_* flags for TOK_FOR node */
  293. } binary;
  294. struct { /* one kid if unary */
  295. JSParseNode *kid;
  296. jsint num; /* -1 or sharp variable number */
  297. JSBool hidden; /* hidden genexp-induced JSOP_YIELD */
  298. } unary;
  299. struct { /* name, labeled statement, etc. */
  300. JSAtom *atom; /* name or label atom, null if slot */
  301. JSParseNode *expr; /* object or initializer */
  302. jsint slot; /* -1 or arg or local var slot */
  303. JSBool isconst; /* true for const names */
  304. } name;
  305. struct { /* lexical scope. */
  306. JSParsedObjectBox *pob; /* block object */
  307. JSParseNode *expr; /* object or initializer */
  308. jsint slot; /* -1 or arg or local var slot */
  309. } lexical;
  310. struct {
  311. JSAtom *atom; /* first atom in pair */
  312. JSAtom *atom2; /* second atom in pair or null */
  313. } apair;
  314. struct { /* object literal */
  315. JSParsedObjectBox *pob;
  316. } object;
  317. jsdouble dval; /* aligned numeric literal value */
  318. } pn_u;
  319. JSParseNode *pn_next; /* to align dval and pn_u on RISCs */
  320. };
  321. #define pn_funpob pn_u.func.funpob
  322. #define pn_body pn_u.func.body
  323. #define pn_flags pn_u.func.flags
  324. #define pn_index pn_u.func.index
  325. #define pn_head pn_u.list.head
  326. #define pn_tail pn_u.list.tail
  327. #define pn_count pn_u.list.count
  328. #define pn_extra pn_u.list.extra
  329. #define pn_kid1 pn_u.ternary.kid1
  330. #define pn_kid2 pn_u.ternary.kid2
  331. #define pn_kid3 pn_u.ternary.kid3
  332. #define pn_left pn_u.binary.left
  333. #define pn_right pn_u.binary.right
  334. #define pn_val pn_u.binary.val
  335. #define pn_iflags pn_u.binary.iflags
  336. #define pn_kid pn_u.unary.kid
  337. #define pn_num pn_u.unary.num
  338. #define pn_hidden pn_u.unary.hidden
  339. #define pn_atom pn_u.name.atom
  340. #define pn_expr pn_u.name.expr
  341. #define pn_slot pn_u.name.slot
  342. #define pn_const pn_u.name.isconst
  343. #define pn_dval pn_u.dval
  344. #define pn_atom2 pn_u.apair.atom2
  345. #define pn_pob pn_u.object.pob
  346. /* PN_LIST pn_extra flags. */
  347. #define PNX_STRCAT 0x01 /* TOK_PLUS list has string term */
  348. #define PNX_CANTFOLD 0x02 /* TOK_PLUS list has unfoldable term */
  349. #define PNX_POPVAR 0x04 /* TOK_VAR last result needs popping */
  350. #define PNX_FORINVAR 0x08 /* TOK_VAR is left kid of TOK_IN node,
  351. which is left kid of TOK_FOR */
  352. #define PNX_ENDCOMMA 0x10 /* array literal has comma at end */
  353. #define PNX_XMLROOT 0x20 /* top-most node in XML literal tree */
  354. #define PNX_GROUPINIT 0x40 /* var [a, b] = [c, d]; unit list */
  355. #define PNX_NEEDBRACES 0x80 /* braces necessary due to closure */
  356. #define PNX_FUNCDEFS 0x100 /* contains top-level function
  357. statements */
  358. #define PNX_SHORTHAND 0x200 /* shorthand syntax used, at present
  359. object destructuring ({x,y}) only */
  360. /*
  361. * Move pn2 into pn, preserving pn->pn_pos and pn->pn_offset and handing off
  362. * any kids in pn2->pn_u, by clearing pn2.
  363. */
  364. #define PN_MOVE_NODE(pn, pn2) \
  365. JS_BEGIN_MACRO \
  366. (pn)->pn_type = (pn2)->pn_type; \
  367. (pn)->pn_op = (pn2)->pn_op; \
  368. (pn)->pn_arity = (pn2)->pn_arity; \
  369. (pn)->pn_u = (pn2)->pn_u; \
  370. PN_CLEAR_NODE(pn2); \
  371. JS_END_MACRO
  372. #define PN_CLEAR_NODE(pn) \
  373. JS_BEGIN_MACRO \
  374. (pn)->pn_type = TOK_EOF; \
  375. (pn)->pn_op = JSOP_NOP; \
  376. (pn)->pn_arity = PN_NULLARY; \
  377. JS_END_MACRO
  378. /* True if pn is a parsenode representing a literal constant. */
  379. #define PN_IS_CONSTANT(pn) \
  380. ((pn)->pn_type == TOK_NUMBER || \
  381. (pn)->pn_type == TOK_STRING || \
  382. ((pn)->pn_type == TOK_PRIMARY && (pn)->pn_op != JSOP_THIS))
  383. #define PN_OP(pn) ((JSOp)(pn)->pn_op)
  384. #define PN_TYPE(pn) ((JSTokenType)(pn)->pn_type)
  385. /*
  386. * Compute a pointer to the last JSParseNode element in a singly-linked list.
  387. * NB: list must be non-empty for correct PN_LAST usage!
  388. */
  389. #define PN_LAST(list) \
  390. ((JSParseNode *)((char *)(list)->pn_tail - offsetof(JSParseNode, pn_next)))
  391. #define PN_INIT_LIST(list) \
  392. JS_BEGIN_MACRO \
  393. (list)->pn_head = NULL; \
  394. (list)->pn_tail = &(list)->pn_head; \
  395. (list)->pn_count = (list)->pn_extra = 0; \
  396. JS_END_MACRO
  397. #define PN_INIT_LIST_1(list, pn) \
  398. JS_BEGIN_MACRO \
  399. (list)->pn_head = (pn); \
  400. (list)->pn_tail = &(pn)->pn_next; \
  401. (list)->pn_count = 1; \
  402. (list)->pn_extra = 0; \
  403. JS_END_MACRO
  404. #define PN_APPEND(list, pn) \
  405. JS_BEGIN_MACRO \
  406. *(list)->pn_tail = (pn); \
  407. (list)->pn_tail = &(pn)->pn_next; \
  408. (list)->pn_count++; \
  409. JS_END_MACRO
  410. struct JSParsedObjectBox {
  411. JSParsedObjectBox *traceLink;
  412. JSParsedObjectBox *emitLink;
  413. JSObject *object;
  414. };
  415. struct JSParseContext {
  416. JSTokenStream tokenStream;
  417. void *tempPoolMark; /* initial JSContext.tempPool mark */
  418. JSPrincipals *principals; /* principals associated with source */
  419. JSStackFrame *callerFrame; /* scripted caller frame for eval and
  420. debug scripts */
  421. JSParseNode *nodeList; /* list of recyclable parse-node
  422. structs */
  423. JSParsedObjectBox *traceListHead; /* list of parsed object for GC
  424. tracing */
  425. JSTempValueRooter tempRoot; /* root to trace traceListHead */
  426. };
  427. /*
  428. * Convenience macro to access JSParseContext.tokenStream as a pointer.
  429. */
  430. #define TS(pc) (&(pc)->tokenStream)
  431. /*
  432. * Parse a top-level JS script.
  433. */
  434. extern JSParseNode *
  435. js_ParseScript(JSContext *cx, JSObject *chain, JSParseContext *pc);
  436. extern JSScript *
  437. js_CompileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *callerFrame,
  438. JSPrincipals *principals, uint32 tcflags,
  439. const jschar *chars, size_t length,
  440. FILE *file, const char *filename, uintN lineno);
  441. extern JSBool
  442. js_CompileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *principals,
  443. const jschar *chars, size_t length,
  444. const char *filename, uintN lineno);
  445. extern JSBool
  446. js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc,
  447. bool inCond = false);
  448. #if JS_HAS_XML_SUPPORT
  449. JS_FRIEND_API(JSParseNode *)
  450. js_ParseXMLText(JSContext *cx, JSObject *chain, JSParseContext *pc,
  451. JSBool allowList);
  452. #endif
  453. /*
  454. * Initialize a parse context. All parameters after pc are passed to
  455. * js_InitTokenStream.
  456. *
  457. * The parse context owns the arena pool "tops-of-stack" space above the
  458. * current JSContext.tempPool mark. This means you cannot allocate from
  459. * tempPool and save the pointer beyond the next js_FinishParseContext.
  460. */
  461. extern JSBool
  462. js_InitParseContext(JSContext *cx, JSParseContext *pc, JSPrincipals *principals,
  463. JSStackFrame *callerFrame,
  464. const jschar *base, size_t length, FILE *fp,
  465. const char *filename, uintN lineno);
  466. extern void
  467. js_FinishParseContext(JSContext *cx, JSParseContext *pc);
  468. extern void
  469. js_InitCompilePrincipals(JSContext *cx, JSParseContext *pc,
  470. JSPrincipals *principals);
  471. /*
  472. * Allocate a new parseed object node from cx->tempPool.
  473. */
  474. extern JSParsedObjectBox *
  475. js_NewParsedObjectBox(JSContext *cx, JSParseContext *pc, JSObject *obj);
  476. extern void
  477. js_TraceParseContext(JSTracer *trc, JSParseContext *pc);
  478. JS_END_EXTERN_C
  479. #endif /* jsparse_h___ */