1 // -*- c-basic-offset: 2 -*-
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
5 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
6 * Copyright (C) 2003 Apple Computer, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
28 #include "fast_malloc.h"
31 //#include "debugger.h"
41 class SourceElementsNode;
44 class PropertyValueNode;
47 enum Operator { OpEqual,
85 virtual Value evaluate(ExecState *exec) = 0;
86 virtual Reference evaluateReference(ExecState *exec);
87 UString toString() const;
88 virtual void streamTo(SourceStream &s) const = 0;
89 virtual void processVarDecls(ExecState */*exec*/) {}
90 int lineNo() const { return line; }
93 // reference counting mechanism
94 virtual void ref() { refcount++; }
96 virtual bool deref() { assert( refcount > 0 ); return (!--refcount); }
98 virtual bool deref() { return (!--refcount); }
103 static void finalCheck();
106 Value throwError(ExecState *exec, ErrorType e, const char *msg);
107 Value throwError(ExecState *exec, ErrorType e, const char *msg, Value v, Node *expr);
108 Value throwError(ExecState *exec, ErrorType e, const char *msg, Identifier label);
109 void setExceptionDetailsIfNeeded(ExecState *exec);
112 unsigned int refcount;
113 virtual int sourceId() const { return -1; }
116 // List of all nodes, for debugging purposes. Don't remove!
117 static std::list<Node *> *s_nodes;
119 // disallow assignment
120 Node& operator=(const Node&);
121 Node(const Node &other);
124 class StatementNode : public Node {
127 void setLoc(int line0, int line1, int sourceId);
128 int firstLine() const { return l0; }
129 int lastLine() const { return l1; }
130 int sourceId() const { return sid; }
131 bool hitStatement(ExecState *exec);
132 bool abortStatement(ExecState *exec);
133 virtual Completion execute(ExecState *exec) = 0;
134 void pushLabel(const Identifier &id) { ls.push(id); }
135 virtual void processFuncDecl(ExecState *exec);
139 Value evaluate(ExecState */*exec*/) { return Undefined(); }
145 class NullNode : public Node {
148 Value evaluate(ExecState *exec);
149 virtual void streamTo(SourceStream &s) const;
152 class BooleanNode : public Node {
154 BooleanNode(bool v) : value(v) {}
155 Value evaluate(ExecState *exec);
156 virtual void streamTo(SourceStream &s) const;
161 class NumberNode : public Node {
163 NumberNode(double v) : value(v) { }
164 Value evaluate(ExecState *exec);
165 virtual void streamTo(SourceStream &s) const;
170 class StringNode : public Node {
172 StringNode(const UString *v) { value = *v; }
173 Value evaluate(ExecState *exec);
174 virtual void streamTo(SourceStream &s) const;
179 class RegExpNode : public Node {
181 RegExpNode(const UString &p, const UString &f)
182 : pattern(p), flags(f) { }
183 Value evaluate(ExecState *exec);
184 virtual void streamTo(SourceStream &s) const;
186 UString pattern, flags;
189 class ThisNode : public Node {
192 Value evaluate(ExecState *exec);
193 virtual void streamTo(SourceStream &s) const;
196 class ResolveNode : public Node {
198 ResolveNode(const Identifier &s) : ident(s) { }
199 Value evaluate(ExecState *exec);
200 virtual Reference evaluateReference(ExecState *exec);
201 virtual void streamTo(SourceStream &s) const;
206 class GroupNode : public Node {
208 GroupNode(Node *g) : group(g) { }
210 virtual bool deref();
211 virtual Value evaluate(ExecState *exec);
212 virtual Reference evaluateReference(ExecState *exec);
213 virtual void streamTo(SourceStream &s) const { group->streamTo(s); }
218 class ElementNode : public Node {
220 // list pointer is tail of a circular list, cracked in the ArrayNode ctor
221 ElementNode(int e, Node *n) : list(this), elision(e), node(n) { }
222 ElementNode(ElementNode *l, int e, Node *n)
223 : list(l->list), elision(e), node(n) { l->list = this; }
225 virtual bool deref();
226 Value evaluate(ExecState *exec);
227 virtual void streamTo(SourceStream &s) const;
229 friend class ArrayNode;
235 class ArrayNode : public Node {
237 ArrayNode(int e) : element(0), elision(e), opt(true) { }
238 ArrayNode(ElementNode *ele)
239 : element(ele->list), elision(0), opt(false) { ele->list = 0; }
240 ArrayNode(int eli, ElementNode *ele)
241 : element(ele->list), elision(eli), opt(true) { ele->list = 0; }
243 virtual bool deref();
244 Value evaluate(ExecState *exec);
245 virtual void streamTo(SourceStream &s) const;
247 ElementNode *element;
252 class PropertyValueNode : public Node {
254 // list pointer is tail of a circular list, cracked in the ObjectLiteralNode ctor
255 PropertyValueNode(PropertyNode *n, Node *a)
256 : name(n), assign(a), list(this) { }
257 PropertyValueNode(PropertyNode *n, Node *a, PropertyValueNode *l)
258 : name(n), assign(a), list(l->list) { l->list = this; }
260 virtual bool deref();
261 Value evaluate(ExecState *exec);
262 virtual void streamTo(SourceStream &s) const;
264 friend class ObjectLiteralNode;
267 PropertyValueNode *list;
270 class ObjectLiteralNode : public Node {
272 ObjectLiteralNode() : list(0) { }
273 ObjectLiteralNode(PropertyValueNode *l) : list(l->list) { l->list = 0; }
275 virtual bool deref();
276 Value evaluate(ExecState *exec);
277 virtual void streamTo(SourceStream &s) const;
279 PropertyValueNode *list;
282 class PropertyNode : public Node {
284 PropertyNode(double d) : numeric(d) { }
285 PropertyNode(const Identifier &s) : str(s) { }
286 Value evaluate(ExecState *exec);
287 virtual void streamTo(SourceStream &s) const;
293 class AccessorNode1 : public Node {
295 AccessorNode1(Node *e1, Node *e2) : expr1(e1), expr2(e2) {}
297 virtual bool deref();
298 Value evaluate(ExecState *exec);
299 virtual Reference evaluateReference(ExecState *exec);
300 virtual void streamTo(SourceStream &s) const;
306 class AccessorNode2 : public Node {
308 AccessorNode2(Node *e, const Identifier &s) : expr(e), ident(s) { }
310 virtual bool deref();
311 Value evaluate(ExecState *exec);
312 virtual Reference evaluateReference(ExecState *exec);
313 virtual void streamTo(SourceStream &s) const;
319 class ArgumentListNode : public Node {
321 // list pointer is tail of a circular list, cracked in the ArgumentsNode ctor
322 ArgumentListNode(Node *e) : list(this), expr(e) { }
323 ArgumentListNode(ArgumentListNode *l, Node *e)
324 : list(l->list), expr(e) { l->list = this; }
326 virtual bool deref();
327 Value evaluate(ExecState *exec);
328 List evaluateList(ExecState *exec);
329 virtual void streamTo(SourceStream &s) const;
331 friend class ArgumentsNode;
332 ArgumentListNode *list;
336 class ArgumentsNode : public Node {
338 ArgumentsNode() : list(0) { }
339 ArgumentsNode(ArgumentListNode *l)
340 : list(l->list) { l->list = 0; }
342 virtual bool deref();
343 Value evaluate(ExecState *exec);
344 List evaluateList(ExecState *exec);
345 virtual void streamTo(SourceStream &s) const;
347 ArgumentListNode *list;
350 class NewExprNode : public Node {
352 NewExprNode(Node *e) : expr(e), args(0) {}
353 NewExprNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
355 virtual bool deref();
356 Value evaluate(ExecState *exec);
357 virtual void streamTo(SourceStream &s) const;
363 class FunctionCallNode : public Node {
365 FunctionCallNode(Node *e, ArgumentsNode *a) : expr(e), args(a) {}
367 virtual bool deref();
368 Value evaluate(ExecState *exec);
369 virtual void streamTo(SourceStream &s) const;
375 class PostfixNode : public Node {
377 PostfixNode(Node *e, Operator o) : expr(e), oper(o) {}
379 virtual bool deref();
380 Value evaluate(ExecState *exec);
381 virtual void streamTo(SourceStream &s) const;
387 class DeleteNode : public Node {
389 DeleteNode(Node *e) : expr(e) {}
391 virtual bool deref();
392 Value evaluate(ExecState *exec);
393 virtual void streamTo(SourceStream &s) const;
398 class VoidNode : public Node {
400 VoidNode(Node *e) : expr(e) {}
402 virtual bool deref();
403 Value evaluate(ExecState *exec);
404 virtual void streamTo(SourceStream &s) const;
409 class TypeOfNode : public Node {
411 TypeOfNode(Node *e) : expr(e) {}
413 virtual bool deref();
414 Value evaluate(ExecState *exec);
415 virtual void streamTo(SourceStream &s) const;
420 class PrefixNode : public Node {
422 PrefixNode(Operator o, Node *e) : oper(o), expr(e) {}
424 virtual bool deref();
425 Value evaluate(ExecState *exec);
426 virtual void streamTo(SourceStream &s) const;
432 class UnaryPlusNode : public Node {
434 UnaryPlusNode(Node *e) : expr(e) {}
436 virtual bool deref();
437 Value evaluate(ExecState *exec);
438 virtual void streamTo(SourceStream &s) const;
443 class NegateNode : public Node {
445 NegateNode(Node *e) : expr(e) {}
447 virtual bool deref();
448 Value evaluate(ExecState *exec);
449 virtual void streamTo(SourceStream &s) const;
454 class BitwiseNotNode : public Node {
456 BitwiseNotNode(Node *e) : expr(e) {}
458 virtual bool deref();
459 Value evaluate(ExecState *exec);
460 virtual void streamTo(SourceStream &s) const;
465 class LogicalNotNode : public Node {
467 LogicalNotNode(Node *e) : expr(e) {}
469 virtual bool deref();
470 Value evaluate(ExecState *exec);
471 virtual void streamTo(SourceStream &s) const;
476 class MultNode : public Node {
478 MultNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {}
480 virtual bool deref();
481 Value evaluate(ExecState *exec);
482 virtual void streamTo(SourceStream &s) const;
488 class AddNode : public Node {
490 AddNode(Node *t1, Node *t2, char op) : term1(t1), term2(t2), oper(op) {}
492 virtual bool deref();
493 Value evaluate(ExecState *exec);
494 virtual void streamTo(SourceStream &s) const;
500 class ShiftNode : public Node {
502 ShiftNode(Node *t1, Operator o, Node *t2)
503 : term1(t1), term2(t2), oper(o) {}
505 virtual bool deref();
506 Value evaluate(ExecState *exec);
507 virtual void streamTo(SourceStream &s) const;
513 class RelationalNode : public Node {
515 RelationalNode(Node *e1, Operator o, Node *e2) :
516 expr1(e1), expr2(e2), oper(o) {}
518 virtual bool deref();
519 Value evaluate(ExecState *exec);
520 virtual void streamTo(SourceStream &s) const;
526 class EqualNode : public Node {
528 EqualNode(Node *e1, Operator o, Node *e2)
529 : expr1(e1), expr2(e2), oper(o) {}
531 virtual bool deref();
532 Value evaluate(ExecState *exec);
533 virtual void streamTo(SourceStream &s) const;
539 class BitOperNode : public Node {
541 BitOperNode(Node *e1, Operator o, Node *e2) :
542 expr1(e1), expr2(e2), oper(o) {}
544 virtual bool deref();
545 Value evaluate(ExecState *exec);
546 virtual void streamTo(SourceStream &s) const;
553 * expr1 && expr2, expr1 || expr2
555 class BinaryLogicalNode : public Node {
557 BinaryLogicalNode(Node *e1, Operator o, Node *e2) :
558 expr1(e1), expr2(e2), oper(o) {}
560 virtual bool deref();
561 Value evaluate(ExecState *exec);
562 virtual void streamTo(SourceStream &s) const;
569 * The ternary operator, "logical ? expr1 : expr2"
571 class ConditionalNode : public Node {
573 ConditionalNode(Node *l, Node *e1, Node *e2) :
574 logical(l), expr1(e1), expr2(e2) {}
576 virtual bool deref();
577 Value evaluate(ExecState *exec);
578 virtual void streamTo(SourceStream &s) const;
580 Node *logical, *expr1, *expr2;
583 class AssignNode : public Node {
585 AssignNode(Node *l, Operator o, Node *e) : left(l), oper(o), expr(e) {}
587 virtual bool deref();
588 Value evaluate(ExecState *exec);
589 virtual void streamTo(SourceStream &s) const;
596 class CommaNode : public Node {
598 CommaNode(Node *e1, Node *e2) : expr1(e1), expr2(e2) {}
600 virtual bool deref();
601 Value evaluate(ExecState *exec);
602 virtual void streamTo(SourceStream &s) const;
607 class StatListNode : public StatementNode {
609 // list pointer is tail of a circular list, cracked in the CaseClauseNode ctor
610 StatListNode(StatementNode *s);
611 StatListNode(StatListNode *l, StatementNode *s);
613 virtual bool deref();
614 virtual Completion execute(ExecState *exec);
615 virtual void processVarDecls(ExecState *exec);
616 virtual void streamTo(SourceStream &s) const;
618 friend class CaseClauseNode;
619 StatementNode *statement;
623 class AssignExprNode : public Node {
625 AssignExprNode(Node *e) : expr(e) {}
627 virtual bool deref();
628 Value evaluate(ExecState *exec);
629 virtual void streamTo(SourceStream &s) const;
634 class VarDeclNode : public Node {
636 VarDeclNode(const Identifier &id, AssignExprNode *in);
638 virtual bool deref();
639 Value evaluate(ExecState *exec);
640 virtual void processVarDecls(ExecState *exec);
641 virtual void streamTo(SourceStream &s) const;
644 AssignExprNode *init;
647 class VarDeclListNode : public Node {
649 // list pointer is tail of a circular list, cracked in the ForNode/VarStatementNode ctor
650 VarDeclListNode(VarDeclNode *v) : list(this), var(v) {}
651 VarDeclListNode(VarDeclListNode *l, VarDeclNode *v)
652 : list(l->list), var(v) { l->list = this; }
654 virtual bool deref();
655 Value evaluate(ExecState *exec);
656 virtual void processVarDecls(ExecState *exec);
657 virtual void streamTo(SourceStream &s) const;
659 friend class ForNode;
660 friend class VarStatementNode;
661 VarDeclListNode *list;
665 class VarStatementNode : public StatementNode {
667 VarStatementNode(VarDeclListNode *l)
668 : list(l->list) { l->list = 0; }
670 virtual bool deref();
671 virtual Completion execute(ExecState *exec);
672 virtual void processVarDecls(ExecState *exec);
673 virtual void streamTo(SourceStream &s) const;
675 VarDeclListNode *list;
678 class BlockNode : public StatementNode {
680 BlockNode(SourceElementsNode *s);
682 virtual bool deref();
683 virtual Completion execute(ExecState *exec);
684 virtual void processVarDecls(ExecState *exec);
685 virtual void streamTo(SourceStream &s) const;
687 SourceElementsNode *source;
690 class EmptyStatementNode : public StatementNode {
692 EmptyStatementNode() { } // debug
693 virtual Completion execute(ExecState *exec);
694 virtual void streamTo(SourceStream &s) const;
697 class ExprStatementNode : public StatementNode {
699 ExprStatementNode(Node *e) : expr(e) { }
701 virtual bool deref();
702 virtual Completion execute(ExecState *exec);
703 virtual void streamTo(SourceStream &s) const;
708 class IfNode : public StatementNode {
710 IfNode(Node *e, StatementNode *s1, StatementNode *s2)
711 : expr(e), statement1(s1), statement2(s2) {}
713 virtual bool deref();
714 virtual Completion execute(ExecState *exec);
715 virtual void processVarDecls(ExecState *exec);
716 virtual void streamTo(SourceStream &s) const;
719 StatementNode *statement1, *statement2;
722 class DoWhileNode : public StatementNode {
724 DoWhileNode(StatementNode *s, Node *e) : statement(s), expr(e) {}
726 virtual bool deref();
727 virtual Completion execute(ExecState *exec);
728 virtual void processVarDecls(ExecState *exec);
729 virtual void streamTo(SourceStream &s) const;
731 StatementNode *statement;
735 class WhileNode : public StatementNode {
737 WhileNode(Node *e, StatementNode *s) : expr(e), statement(s) {}
739 virtual bool deref();
740 virtual Completion execute(ExecState *exec);
741 virtual void processVarDecls(ExecState *exec);
742 virtual void streamTo(SourceStream &s) const;
745 StatementNode *statement;
748 class ForNode : public StatementNode {
750 ForNode(Node *e1, Node *e2, Node *e3, StatementNode *s) :
751 expr1(e1), expr2(e2), expr3(e3), statement(s) {}
752 ForNode(VarDeclListNode *e1, Node *e2, Node *e3, StatementNode *s) :
753 expr1(e1->list), expr2(e2), expr3(e3), statement(s) { e1->list = 0; }
755 virtual bool deref();
756 virtual Completion execute(ExecState *exec);
757 virtual void processVarDecls(ExecState *exec);
758 virtual void streamTo(SourceStream &s) const;
760 Node *expr1, *expr2, *expr3;
761 StatementNode *statement;
764 class ForInNode : public StatementNode {
766 ForInNode(Node *l, Node *e, StatementNode *s);
767 ForInNode(const Identifier &i, AssignExprNode *in, Node *e, StatementNode *s);
769 virtual bool deref();
770 virtual Completion execute(ExecState *exec);
771 virtual void processVarDecls(ExecState *exec);
772 virtual void streamTo(SourceStream &s) const;
775 AssignExprNode *init;
777 VarDeclNode *varDecl;
778 StatementNode *statement;
781 class ContinueNode : public StatementNode {
784 ContinueNode(const Identifier &i) : ident(i) { }
785 virtual Completion execute(ExecState *exec);
786 virtual void streamTo(SourceStream &s) const;
791 class BreakNode : public StatementNode {
794 BreakNode(const Identifier &i) : ident(i) { }
795 virtual Completion execute(ExecState *exec);
796 virtual void streamTo(SourceStream &s) const;
801 class ReturnNode : public StatementNode {
803 ReturnNode(Node *v) : value(v) {}
805 virtual bool deref();
806 virtual Completion execute(ExecState *exec);
807 virtual void streamTo(SourceStream &s) const;
812 class WithNode : public StatementNode {
814 WithNode(Node *e, StatementNode *s) : expr(e), statement(s) {}
816 virtual bool deref();
817 virtual Completion execute(ExecState *exec);
818 virtual void processVarDecls(ExecState *exec);
819 virtual void streamTo(SourceStream &s) const;
822 StatementNode *statement;
825 class CaseClauseNode : public Node {
827 CaseClauseNode(Node *e) : expr(e), list(0) { }
828 CaseClauseNode(Node *e, StatListNode *l)
829 : expr(e), list(l->list) { l->list = 0; }
831 virtual bool deref();
832 Value evaluate(ExecState *exec);
833 Completion evalStatements(ExecState *exec);
834 virtual void processVarDecls(ExecState *exec);
835 virtual void streamTo(SourceStream &s) const;
841 class ClauseListNode : public Node {
843 // list pointer is tail of a circular list, cracked in the CaseBlockNode ctor
844 ClauseListNode(CaseClauseNode *c) : cl(c), nx(this) { }
845 ClauseListNode(ClauseListNode *n, CaseClauseNode *c)
846 : cl(c), nx(n->nx) { n->nx = this; }
848 virtual bool deref();
849 Value evaluate(ExecState *exec);
850 CaseClauseNode *clause() const { return cl; }
851 ClauseListNode *next() const { return nx; }
852 virtual void processVarDecls(ExecState *exec);
853 virtual void streamTo(SourceStream &s) const;
855 friend class CaseBlockNode;
860 class CaseBlockNode : public Node {
862 CaseBlockNode(ClauseListNode *l1, CaseClauseNode *d, ClauseListNode *l2);
864 virtual bool deref();
865 Value evaluate(ExecState *exec);
866 Completion evalBlock(ExecState *exec, const Value& input);
867 virtual void processVarDecls(ExecState *exec);
868 virtual void streamTo(SourceStream &s) const;
870 ClauseListNode *list1;
872 ClauseListNode *list2;
875 class SwitchNode : public StatementNode {
877 SwitchNode(Node *e, CaseBlockNode *b) : expr(e), block(b) { }
879 virtual bool deref();
880 virtual Completion execute(ExecState *exec);
881 virtual void processVarDecls(ExecState *exec);
882 virtual void streamTo(SourceStream &s) const;
885 CaseBlockNode *block;
888 class LabelNode : public StatementNode {
890 LabelNode(const Identifier &l, StatementNode *s) : label(l), statement(s) { }
892 virtual bool deref();
893 virtual Completion execute(ExecState *exec);
894 virtual void processVarDecls(ExecState *exec);
895 virtual void streamTo(SourceStream &s) const;
898 StatementNode *statement;
901 class ThrowNode : public StatementNode {
903 ThrowNode(Node *e) : expr(e) {}
905 virtual bool deref();
906 virtual Completion execute(ExecState *exec);
907 virtual void streamTo(SourceStream &s) const;
912 class CatchNode : public StatementNode {
914 CatchNode(const Identifier &i, StatementNode *b) : ident(i), block(b) {}
916 virtual bool deref();
917 virtual Completion execute(ExecState *exec);
918 Completion execute(ExecState *exec, const Value &arg);
919 virtual void processVarDecls(ExecState *exec);
920 virtual void streamTo(SourceStream &s) const;
923 StatementNode *block;
926 class FinallyNode : public StatementNode {
928 FinallyNode(StatementNode *b) : block(b) {}
930 virtual bool deref();
931 virtual Completion execute(ExecState *exec);
932 virtual void processVarDecls(ExecState *exec);
933 virtual void streamTo(SourceStream &s) const;
935 StatementNode *block;
938 class TryNode : public StatementNode {
940 TryNode(StatementNode *b, CatchNode *c)
941 : block(b), _catch(c), _final(0) {}
942 TryNode(StatementNode *b, FinallyNode *f)
943 : block(b), _catch(0), _final(f) {}
944 TryNode(StatementNode *b, CatchNode *c, FinallyNode *f)
945 : block(b), _catch(c), _final(f) {}
947 virtual bool deref();
948 virtual Completion execute(ExecState *exec);
949 virtual void processVarDecls(ExecState *exec);
950 virtual void streamTo(SourceStream &s) const;
952 StatementNode *block;
957 class ParameterNode : public Node {
959 // list pointer is tail of a circular list, cracked in the FuncDeclNode/FuncExprNode ctor
960 ParameterNode(const Identifier &i) : id(i), next(this) { }
961 ParameterNode(ParameterNode *list, const Identifier &i)
962 : id(i), next(list->next) { list->next = this; }
964 virtual bool deref();
965 Value evaluate(ExecState *exec);
966 Identifier ident() { return id; }
967 ParameterNode *nextParam() { return next; }
968 virtual void streamTo(SourceStream &s) const;
970 friend class FuncDeclNode;
971 friend class FuncExprNode;
976 // inherited by ProgramNode
977 class FunctionBodyNode : public BlockNode {
979 FunctionBodyNode(SourceElementsNode *s);
980 void processFuncDecl(ExecState *exec);
983 class FuncDeclNode : public StatementNode {
985 FuncDeclNode(const Identifier &i, FunctionBodyNode *b)
986 : ident(i), param(0), body(b) { }
987 FuncDeclNode(const Identifier &i, ParameterNode *p, FunctionBodyNode *b)
988 : ident(i), param(p->next), body(b) { p->next = 0; }
990 virtual bool deref();
991 Completion execute(ExecState */*exec*/)
992 { /* empty */ return Completion(); }
993 void processFuncDecl(ExecState *exec);
994 virtual void streamTo(SourceStream &s) const;
997 ParameterNode *param;
998 FunctionBodyNode *body;
1001 class FuncExprNode : public Node {
1003 FuncExprNode(FunctionBodyNode *b) : param(0), body(b) { }
1004 FuncExprNode(ParameterNode *p, FunctionBodyNode *b)
1005 : param(p->next), body(b) { p->next = 0; }
1007 virtual bool deref();
1008 Value evaluate(ExecState *exec);
1009 virtual void streamTo(SourceStream &s) const;
1011 ParameterNode *param;
1012 FunctionBodyNode *body;
1015 // A linked list of source element nodes
1016 class SourceElementsNode : public StatementNode {
1018 // list pointer is tail of a circular list, cracked in the BlockNode (or subclass) ctor
1019 SourceElementsNode(StatementNode *s1);
1020 SourceElementsNode(SourceElementsNode *s1, StatementNode *s2);
1022 virtual bool deref();
1023 Completion execute(ExecState *exec);
1024 void processFuncDecl(ExecState *exec);
1025 virtual void processVarDecls(ExecState *exec);
1026 virtual void streamTo(SourceStream &s) const;
1028 friend class BlockNode;
1029 StatementNode *element; // 'this' element
1030 SourceElementsNode *elements; // pointer to next
1033 class ProgramNode : public FunctionBodyNode {
1035 ProgramNode(SourceElementsNode *s);