PageRenderTime 82ms CodeModel.GetById 62ms app.highlight 13ms RepoModel.GetById 2ms app.codeStats 0ms

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