|
|
|
|
| 148 |
F(ARRAYPUSH) \ |
148 |
F(ARRAYPUSH) \ |
| 149 |
F(LEXICALSCOPE) \ |
149 |
F(LEXICALSCOPE) \ |
| 150 |
F(LET) \ |
150 |
F(LET) \ |
| 151 |
F(SEQ) \ |
151 |
F(SEQ) \ |
| 152 |
F(FORIN) \ |
152 |
F(FORIN) \ |
| 153 |
F(FORHEAD) \ |
153 |
F(FORHEAD) \ |
| 154 |
F(ARGSBODY) \ |
154 |
F(ARGSBODY) \ |
| 155 |
F(SPREAD) \ |
155 |
F(SPREAD) \ |
|
|
156 |
F(MODULE) \ |
| 156 |
\ |
157 |
\ |
| 157 |
/* Equality operators. */ \ |
158 |
/* Equality operators. */ \ |
| 158 |
F(STRICTEQ) \ |
159 |
F(STRICTEQ) \ |
| 159 |
F(EQ) \ |
160 |
F(EQ) \ |
| 160 |
F(STRICTNE) \ |
161 |
F(STRICTNE) \ |
| 161 |
F(NE) \ |
162 |
F(NE) \ |
| 162 |
\ |
163 |
\ |
| 163 |
/* Unary operators. */ \ |
164 |
/* Unary operators. */ \ |
|
|
| 478 |
* pn_kid: array comprehension expression |
479 |
* pn_kid: array comprehension expression |
| 479 |
* PNK_NOP nullary |
480 |
* PNK_NOP nullary |
| 480 |
*/ |
481 |
*/ |
| 481 |
enum ParseNodeArity { |
482 |
enum ParseNodeArity { |
| 482 |
PN_NULLARY, /* 0 kids, only pn_atom/pn_dval/etc. */ |
483 |
PN_NULLARY, /* 0 kids, only pn_atom/pn_dval/etc. */ |
| 483 |
PN_UNARY, /* one kid, plus a couple of scalars */ |
484 |
PN_UNARY, /* one kid, plus a couple of scalars */ |
| 484 |
PN_BINARY, /* two kids, plus a couple of scalars */ |
485 |
PN_BINARY, /* two kids, plus a couple of scalars */ |
| 485 |
PN_TERNARY, /* three kids */ |
486 |
PN_TERNARY, /* three kids */ |
|
|
487 |
PN_MODULE, /* module definition node */ |
| 486 |
PN_FUNC, /* function definition node */ |
488 |
PN_FUNC, /* function definition node */ |
| 487 |
PN_LIST, /* generic singly linked list */ |
489 |
PN_LIST, /* generic singly linked list */ |
| 488 |
PN_NAME /* name use or definition node */ |
490 |
PN_NAME /* name use or definition node */ |
| 489 |
}; |
491 |
}; |
| 490 |
|
492 |
|
| 491 |
struct Definition; |
493 |
struct Definition; |
| 492 |
|
494 |
|
| 493 |
class LoopControlStatement; |
495 |
class LoopControlStatement; |
| 494 |
class BreakStatement; |
496 |
class BreakStatement; |
| 495 |
class ContinueStatement; |
497 |
class ContinueStatement; |
| 496 |
class XMLProcessingInstruction; |
498 |
class XMLProcessingInstruction; |
| 497 |
class ConditionalExpression; |
499 |
class ConditionalExpression; |
| 498 |
class PropertyAccess; |
500 |
class PropertyAccess; |
|
|
501 |
class ModuleBox; |
| 499 |
|
502 |
|
| 500 |
struct ParseNode { |
503 |
struct ParseNode { |
| 501 |
private: |
504 |
private: |
| 502 |
uint32_t pn_type : 16, /* PNK_* type */ |
505 |
uint32_t pn_type : 16, /* PNK_* type */ |
| 503 |
pn_op : 8, /* see JSOp enum and jsopcode.tbl */ |
506 |
pn_op : 8, /* see JSOp enum and jsopcode.tbl */ |
| 504 |
pn_arity : 5, /* see ParseNodeArity enum */ |
507 |
pn_arity : 5, /* see ParseNodeArity enum */ |
| 505 |
pn_parens : 1, /* this expr was enclosed in parens */ |
508 |
pn_parens : 1, /* this expr was enclosed in parens */ |
| 506 |
pn_used : 1, /* name node is on a use-chain */ |
509 |
pn_used : 1, /* name node is on a use-chain */ |
|
|
| 602 |
struct { /* one kid if unary */ |
605 |
struct { /* one kid if unary */ |
| 603 |
ParseNode *kid; |
606 |
ParseNode *kid; |
| 604 |
bool hidden; /* hidden genexp-induced JSOP_YIELD |
607 |
bool hidden; /* hidden genexp-induced JSOP_YIELD |
| 605 |
or directive prologue member (as |
608 |
or directive prologue member (as |
| 606 |
pn_prologue) */ |
609 |
pn_prologue) */ |
| 607 |
} unary; |
610 |
} unary; |
| 608 |
struct { /* name, labeled statement, etc. */ |
611 |
struct { /* name, labeled statement, etc. */ |
| 609 |
union { |
612 |
union { |
| 610 |
JSAtom *atom; /* lexical name or label atom */ |
613 |
JSAtom *atom; /* lexical name or label atom */ |
| 611 |
ObjectBox *objbox; /* block or regexp object */ |
614 |
ObjectBox *objbox; /* block or regexp object */ |
| 612 |
FunctionBox *funbox; /* function object */ |
615 |
ModuleBox *modulebox; /* module object */ |
|
|
616 |
FunctionBox *funbox; /* function object */ |
| 613 |
}; |
617 |
}; |
| 614 |
union { |
618 |
union { |
| 615 |
ParseNode *expr; /* function body, var initializer, argument default, |
619 |
ParseNode *expr; /* function body, var initializer, argument default, |
| 616 |
or base object of PNK_DOT */ |
620 |
or base object of PNK_DOT */ |
| 617 |
Definition *lexdef; /* lexical definition for this use */ |
621 |
Definition *lexdef; /* lexical definition for this use */ |
| 618 |
}; |
622 |
}; |
| 619 |
UpvarCookie cookie; /* upvar cookie with absolute frame |
623 |
UpvarCookie cookie; /* upvar cookie with absolute frame |
| 620 |
level (not relative skip), possibly |
624 |
level (not relative skip), possibly |
| 621 |
in current frame */ |
625 |
in current frame */ |
| 622 |
uint32_t dflags:12, /* definition/use flags, see below */ |
626 |
uint32_t dflags:12, /* definition/use flags, see below */ |
| 623 |
blockid:20; /* block number, for subset dominance |
627 |
blockid:20; /* block number, for subset dominance |
| 624 |
computation */ |
628 |
computation */ |
| 625 |
} name; |
629 |
} name; |
|
|
| 630 |
} loopControl; |
634 |
} loopControl; |
| 631 |
class { /* E4X <?target data?> XML PI */ |
635 |
class { /* E4X <?target data?> XML PI */ |
| 632 |
friend class XMLProcessingInstruction; |
636 |
friend class XMLProcessingInstruction; |
| 633 |
PropertyName *target; /* non-empty */ |
637 |
PropertyName *target; /* non-empty */ |
| 634 |
JSAtom *data; /* may be empty, never null */ |
638 |
JSAtom *data; /* may be empty, never null */ |
| 635 |
} xmlpi; |
639 |
} xmlpi; |
| 636 |
} pn_u; |
640 |
} pn_u; |
| 637 |
|
641 |
|
|
|
642 |
#define pn_modulebox pn_u.name.modulebox |
| 638 |
#define pn_funbox pn_u.name.funbox |
643 |
#define pn_funbox pn_u.name.funbox |
| 639 |
#define pn_body pn_u.name.expr |
644 |
#define pn_body pn_u.name.expr |
| 640 |
#define pn_cookie pn_u.name.cookie |
645 |
#define pn_cookie pn_u.name.cookie |
| 641 |
#define pn_dflags pn_u.name.dflags |
646 |
#define pn_dflags pn_u.name.dflags |
| 642 |
#define pn_blockid pn_u.name.blockid |
647 |
#define pn_blockid pn_u.name.blockid |
| 643 |
#define pn_index pn_u.name.blockid /* reuse as object table index */ |
648 |
#define pn_index pn_u.name.blockid /* reuse as object table index */ |
| 644 |
#define pn_head pn_u.list.head |
649 |
#define pn_head pn_u.list.head |
| 645 |
#define pn_tail pn_u.list.tail |
650 |
#define pn_tail pn_u.list.tail |
|
Lines 1030-1045
struct ListNode : public ParseNode
|
Link Here
|
|---|
|
| 1030 |
return node.isArity(PN_LIST); |
1035 |
return node.isArity(PN_LIST); |
| 1031 |
} |
1036 |
} |
| 1032 |
|
1037 |
|
| 1033 |
#ifdef DEBUG |
1038 |
#ifdef DEBUG |
| 1034 |
void dump(int indent); |
1039 |
void dump(int indent); |
| 1035 |
#endif |
1040 |
#endif |
| 1036 |
}; |
1041 |
}; |
| 1037 |
|
1042 |
|
|
|
1043 |
struct ModuleNode : public ParseNode { |
| 1044 |
static inline ModuleNode *create(ParseNodeKind kind, Parser *parser) { |
| 1045 |
return (ModuleNode *) ParseNode::create(kind, PN_MODULE, parser); |
| 1046 |
} |
| 1047 |
|
| 1048 |
static bool test(const ParseNode &node) { |
| 1049 |
return node.isArity(PN_MODULE); |
| 1050 |
} |
| 1051 |
}; |
| 1052 |
|
| 1038 |
struct FunctionNode : public ParseNode { |
1053 |
struct FunctionNode : public ParseNode { |
| 1039 |
static inline FunctionNode *create(ParseNodeKind kind, Parser *parser) { |
1054 |
static inline FunctionNode *create(ParseNodeKind kind, Parser *parser) { |
| 1040 |
return (FunctionNode *) ParseNode::create(kind, PN_FUNC, parser); |
1055 |
return (FunctionNode *) ParseNode::create(kind, PN_FUNC, parser); |
| 1041 |
} |
1056 |
} |
| 1042 |
|
1057 |
|
| 1043 |
static bool test(const ParseNode &node) { |
1058 |
static bool test(const ParseNode &node) { |
| 1044 |
return node.isArity(PN_FUNC); |
1059 |
return node.isArity(PN_FUNC); |
| 1045 |
} |
1060 |
} |