2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
6 * Copyright (C) 2007 Maks Orlovich
7 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public License
20 * along with this library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
31 #include "SymbolTable.h"
32 #include <wtf/ListRefPtr.h>
33 #include <wtf/OwnPtr.h>
34 #include <wtf/Vector.h>
36 #if PLATFORM(X86) && COMPILER(GCC)
37 #define KJS_FAST_CALL __attribute__((regparm(3)))
43 #define KJS_NO_INLINE __attribute__((noinline))
51 class PropertyListNode;
94 struct DeclarationStacks {
95 typedef Vector<Node*, 16> NodeStack;
96 typedef Vector<VarDeclNode*, 16> VarStack;
97 typedef Vector<FuncDeclNode*, 16> FunctionStack;
99 DeclarationStacks(ExecState* e, NodeStack& n, VarStack& v, FunctionStack& f)
108 NodeStack& nodeStack;
110 FunctionStack& functionStack;
113 class Node : Noncopyable {
115 Node() KJS_FAST_CALL;
116 Node(PlacementNewAdoptType) KJS_FAST_CALL { }
119 UString toString() const KJS_FAST_CALL;
120 int lineNo() const KJS_FAST_CALL { return m_line; }
121 void ref() KJS_FAST_CALL;
122 void deref() KJS_FAST_CALL;
123 unsigned refcount() KJS_FAST_CALL;
124 static void clearNewNodes() KJS_FAST_CALL;
127 virtual void streamTo(SourceStream&) const KJS_FAST_CALL = 0;
128 virtual Precedence precedence() const = 0;
130 // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries.
131 bool mayHaveDeclarations() const { return m_mayHaveDeclarations; }
132 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL { ASSERT_NOT_REACHED(); }
134 // Used for iterative, depth-first traversal of the node tree. Does not cross function call boundaries.
135 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL { }
138 Completion createErrorCompletion(ExecState *, ErrorType, const char *msg) KJS_FAST_CALL;
139 Completion createErrorCompletion(ExecState *, ErrorType, const char *msg, const Identifier &) KJS_FAST_CALL;
141 JSValue* throwError(ExecState*, ErrorType, const char* msg) KJS_FAST_CALL;
142 JSValue* throwError(ExecState*, ErrorType, const char* msg, const char*) KJS_FAST_CALL;
143 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*) KJS_FAST_CALL;
144 JSValue* throwError(ExecState*, ErrorType, const char* msg, const Identifier&) KJS_FAST_CALL;
145 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, const Identifier&) KJS_FAST_CALL;
146 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, Node*) KJS_FAST_CALL;
147 JSValue* throwError(ExecState*, ErrorType, const char* msg, JSValue*, Node*, const Identifier&) KJS_FAST_CALL;
149 JSValue* throwUndefinedVariableError(ExecState*, const Identifier&) KJS_FAST_CALL;
151 void handleException(ExecState*) KJS_FAST_CALL;
152 void handleException(ExecState*, JSValue*) KJS_FAST_CALL;
154 Completion rethrowException(ExecState*) KJS_FAST_CALL;
157 bool m_mayHaveDeclarations : 1;
160 class ExpressionNode : public Node {
162 ExpressionNode() KJS_FAST_CALL { }
164 // Special constructor for cases where we overwrite an object in place.
165 ExpressionNode(PlacementNewAdoptType) KJS_FAST_CALL
166 : Node(PlacementNewAdopt)
170 virtual bool isNumber() const KJS_FAST_CALL { return false; }
171 virtual bool isLocation() const KJS_FAST_CALL { return false; }
172 virtual bool isResolveNode() const KJS_FAST_CALL { return false; }
173 virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return false; }
174 virtual bool isDotAccessorNode() const KJS_FAST_CALL { return false; }
176 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL = 0;
177 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
178 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
180 // Used to optimize those nodes that do extra work when returning a result, even if the result has no semantic relevance
181 virtual void optimizeForUnnecessaryResult() { }
184 class StatementNode : public Node {
186 StatementNode() KJS_FAST_CALL;
187 void setLoc(int line0, int line1) KJS_FAST_CALL;
188 int firstLine() const KJS_FAST_CALL { return lineNo(); }
189 int lastLine() const KJS_FAST_CALL { return m_lastLine; }
190 bool hitStatement(ExecState*) KJS_FAST_CALL;
191 virtual Completion execute(ExecState *exec) KJS_FAST_CALL = 0;
192 void pushLabel(const Identifier &id) KJS_FAST_CALL { ls.push(id); }
193 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
200 class NullNode : public ExpressionNode {
202 NullNode() KJS_FAST_CALL { }
203 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
204 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
205 virtual Precedence precedence() const { return PrecPrimary; }
208 class FalseNode : public ExpressionNode {
210 FalseNode() KJS_FAST_CALL { }
211 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
212 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return false; }
213 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
214 virtual Precedence precedence() const { return PrecPrimary; }
217 class TrueNode : public ExpressionNode {
219 TrueNode() KJS_FAST_CALL { }
220 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
221 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL { return true; }
222 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
223 virtual Precedence precedence() const { return PrecPrimary; }
226 class NumberNode : public ExpressionNode {
228 NumberNode(double v) KJS_FAST_CALL : m_double(v) {}
229 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
230 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
231 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
232 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
233 virtual Precedence precedence() const { return PrecPrimary; }
235 virtual bool isNumber() const KJS_FAST_CALL { return true; }
236 double value() const KJS_FAST_CALL { return m_double; }
237 virtual void setValue(double d) KJS_FAST_CALL { m_double = d; }
243 class ImmediateNumberNode : public NumberNode {
245 ImmediateNumberNode(JSValue* v, double d) KJS_FAST_CALL : NumberNode(d), m_value(v) { ASSERT(v == JSImmediate::from(d)); }
246 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
248 virtual void setValue(double d) KJS_FAST_CALL { m_double = d; m_value = JSImmediate::from(d); ASSERT(m_value); }
253 class StringNode : public ExpressionNode {
255 StringNode(const UString *v) KJS_FAST_CALL { value = *v; }
256 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
257 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
258 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
259 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
260 virtual Precedence precedence() const { return PrecPrimary; }
266 class RegExpNode : public ExpressionNode {
268 RegExpNode(const UString &p, const UString &f) KJS_FAST_CALL
269 : pattern(p), flags(f) { }
270 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
271 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
272 virtual Precedence precedence() const { return PrecPrimary; }
274 UString pattern, flags;
277 class ThisNode : public ExpressionNode {
279 ThisNode() KJS_FAST_CALL {}
280 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
281 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
282 virtual Precedence precedence() const { return PrecPrimary; }
285 class ResolveNode : public ExpressionNode {
287 ResolveNode(const Identifier &s) KJS_FAST_CALL
292 // Special constructor for cases where we overwrite an object in place.
293 ResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
294 : ExpressionNode(PlacementNewAdopt)
295 , ident(PlacementNewAdopt)
299 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
301 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
302 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
303 virtual Precedence precedence() const { return PrecPrimary; }
305 virtual bool isLocation() const KJS_FAST_CALL { return true; }
306 virtual bool isResolveNode() const KJS_FAST_CALL { return true; }
307 const Identifier& identifier() const KJS_FAST_CALL { return ident; }
311 size_t index; // Used by LocalVarAccessNode.
314 class LocalVarAccessNode : public ResolveNode {
316 // Overwrites a ResolveNode in place.
317 LocalVarAccessNode(size_t i) KJS_FAST_CALL
318 : ResolveNode(PlacementNewAdopt)
320 ASSERT(i != missingSymbolMarker());
323 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
324 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
325 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
327 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*);
330 class ElementNode : public Node {
332 ElementNode(int e, ExpressionNode* n) KJS_FAST_CALL : elision(e), node(n) { }
333 ElementNode(ElementNode* l, int e, ExpressionNode* n) KJS_FAST_CALL
334 : elision(e), node(n) { l->next = this; }
335 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
336 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
337 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
339 PassRefPtr<ElementNode> releaseNext() KJS_FAST_CALL { return next.release(); }
341 JSValue* evaluate(ExecState*) KJS_FAST_CALL;
344 friend class ArrayNode;
345 ListRefPtr<ElementNode> next;
347 RefPtr<ExpressionNode> node;
350 class ArrayNode : public ExpressionNode {
352 ArrayNode(int e) KJS_FAST_CALL : elision(e), opt(true) { }
353 ArrayNode(ElementNode* ele) KJS_FAST_CALL
354 : element(ele), elision(0), opt(false) { }
355 ArrayNode(int eli, ElementNode* ele) KJS_FAST_CALL
356 : element(ele), elision(eli), opt(true) { }
357 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
358 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
359 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
360 virtual Precedence precedence() const { return PrecPrimary; }
362 RefPtr<ElementNode> element;
367 class PropertyNode : public Node {
369 enum Type { Constant, Getter, Setter };
370 PropertyNode(const Identifier& n, ExpressionNode* a, Type t) KJS_FAST_CALL
371 : m_name(n), assign(a), type(t) { }
372 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
373 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
374 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
376 JSValue* evaluate(ExecState*) KJS_FAST_CALL;
377 const Identifier& name() const { return m_name; }
380 friend class PropertyListNode;
382 RefPtr<ExpressionNode> assign;
386 class PropertyListNode : public Node {
388 PropertyListNode(PropertyNode* n) KJS_FAST_CALL
390 PropertyListNode(PropertyNode* n, PropertyListNode* l) KJS_FAST_CALL
391 : node(n) { l->next = this; }
392 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
393 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
394 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
396 JSValue* evaluate(ExecState*) KJS_FAST_CALL;
397 PassRefPtr<PropertyListNode> releaseNext() KJS_FAST_CALL { return next.release(); }
400 friend class ObjectLiteralNode;
401 RefPtr<PropertyNode> node;
402 ListRefPtr<PropertyListNode> next;
405 class ObjectLiteralNode : public ExpressionNode {
407 ObjectLiteralNode() KJS_FAST_CALL { }
408 ObjectLiteralNode(PropertyListNode* l) KJS_FAST_CALL : list(l) { }
409 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
410 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
411 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
412 virtual Precedence precedence() const { return PrecPrimary; }
414 RefPtr<PropertyListNode> list;
417 class BracketAccessorNode : public ExpressionNode {
419 BracketAccessorNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL : expr1(e1), expr2(e2) {}
420 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
421 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
422 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
423 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
424 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
425 virtual Precedence precedence() const { return PrecMember; }
427 virtual bool isLocation() const KJS_FAST_CALL { return true; }
428 virtual bool isBracketAccessorNode() const KJS_FAST_CALL { return true; }
429 ExpressionNode* base() KJS_FAST_CALL { return expr1.get(); }
430 ExpressionNode* subscript() KJS_FAST_CALL { return expr2.get(); }
433 ALWAYS_INLINE JSValue* inlineEvaluate(ExecState*);
434 RefPtr<ExpressionNode> expr1;
435 RefPtr<ExpressionNode> expr2;
438 class DotAccessorNode : public ExpressionNode {
440 DotAccessorNode(ExpressionNode* e, const Identifier& s) KJS_FAST_CALL : expr(e), ident(s) { }
441 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
442 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
443 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
444 virtual Precedence precedence() const { return PrecMember; }
446 virtual bool isLocation() const KJS_FAST_CALL { return true; }
447 virtual bool isDotAccessorNode() const KJS_FAST_CALL { return true; }
448 ExpressionNode* base() const KJS_FAST_CALL { return expr.get(); }
449 const Identifier& identifier() const KJS_FAST_CALL { return ident; }
452 RefPtr<ExpressionNode> expr;
456 class ArgumentListNode : public Node {
458 ArgumentListNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) { }
459 ArgumentListNode(ArgumentListNode* l, ExpressionNode* e) KJS_FAST_CALL
460 : expr(e) { l->next = this; }
461 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
462 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
463 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
465 void evaluateList(ExecState*, List&) KJS_FAST_CALL;
466 PassRefPtr<ArgumentListNode> releaseNext() KJS_FAST_CALL { return next.release(); }
469 friend class ArgumentsNode;
470 ListRefPtr<ArgumentListNode> next;
471 RefPtr<ExpressionNode> expr;
474 class ArgumentsNode : public Node {
476 ArgumentsNode() KJS_FAST_CALL { }
477 ArgumentsNode(ArgumentListNode* l) KJS_FAST_CALL
479 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
480 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
481 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
483 void evaluateList(ExecState* exec, List& list) KJS_FAST_CALL { if (listNode) listNode->evaluateList(exec, list); }
486 RefPtr<ArgumentListNode> listNode;
489 class NewExprNode : public ExpressionNode {
491 NewExprNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
492 NewExprNode(ExpressionNode* e, ArgumentsNode* a) KJS_FAST_CALL : expr(e), args(a) {}
493 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
494 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
495 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
496 virtual Precedence precedence() const { return PrecLeftHandSide; }
498 RefPtr<ExpressionNode> expr;
499 RefPtr<ArgumentsNode> args;
502 class FunctionCallValueNode : public ExpressionNode {
504 FunctionCallValueNode(ExpressionNode* e, ArgumentsNode* a) KJS_FAST_CALL : expr(e), args(a) {}
505 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
506 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
507 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
508 virtual Precedence precedence() const { return PrecCall; }
510 RefPtr<ExpressionNode> expr;
511 RefPtr<ArgumentsNode> args;
514 class FunctionCallResolveNode : public ExpressionNode {
516 FunctionCallResolveNode(const Identifier& i, ArgumentsNode* a) KJS_FAST_CALL
522 FunctionCallResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
523 : ExpressionNode(PlacementNewAdopt)
524 , ident(PlacementNewAdopt)
525 , args(PlacementNewAdopt)
529 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
530 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
531 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
532 virtual Precedence precedence() const { return PrecCall; }
536 RefPtr<ArgumentsNode> args;
537 size_t index; // Used by LocalVarFunctionCallNode.
540 class LocalVarFunctionCallNode : public FunctionCallResolveNode {
542 LocalVarFunctionCallNode(size_t i) KJS_FAST_CALL
543 : FunctionCallResolveNode(PlacementNewAdopt)
545 ASSERT(i != missingSymbolMarker());
549 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
552 class FunctionCallBracketNode : public ExpressionNode {
554 FunctionCallBracketNode(ExpressionNode* b, ExpressionNode* s, ArgumentsNode* a) KJS_FAST_CALL : base(b), subscript(s), args(a) {}
555 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
556 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
557 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
558 virtual Precedence precedence() const { return PrecCall; }
560 RefPtr<ExpressionNode> base;
561 RefPtr<ExpressionNode> subscript;
562 RefPtr<ArgumentsNode> args;
565 class FunctionCallDotNode : public ExpressionNode {
567 FunctionCallDotNode(ExpressionNode* b, const Identifier& i, ArgumentsNode* a) KJS_FAST_CALL : base(b), ident(i), args(a) {}
568 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
569 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
570 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
571 virtual Precedence precedence() const { return PrecCall; }
573 RefPtr<ExpressionNode> base;
575 RefPtr<ArgumentsNode> args;
578 class PrePostResolveNode : public ExpressionNode {
580 PrePostResolveNode(const Identifier& i) KJS_FAST_CALL : m_ident(i) {}
582 PrePostResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
583 : ExpressionNode(PlacementNewAdopt)
584 , m_ident(PlacementNewAdopt)
590 size_t m_index; // Used by LocalVarPostfixNode.
593 class PostIncResolveNode : public PrePostResolveNode {
595 PostIncResolveNode(const Identifier& i) KJS_FAST_CALL : PrePostResolveNode(i) {}
597 PostIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
598 : PrePostResolveNode(PlacementNewAdopt)
602 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
603 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
604 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
605 virtual Precedence precedence() const { return PrecPostfix; }
606 virtual void optimizeForUnnecessaryResult();
610 class PostIncLocalVarNode : public PostIncResolveNode {
612 PostIncLocalVarNode(size_t i) KJS_FAST_CALL
613 : PostIncResolveNode(PlacementNewAdopt)
615 ASSERT(i != missingSymbolMarker());
619 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
620 virtual void optimizeForUnnecessaryResult();
623 class PostDecResolveNode : public PrePostResolveNode {
625 PostDecResolveNode(const Identifier& i) KJS_FAST_CALL : PrePostResolveNode(i) {}
627 PostDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
628 : PrePostResolveNode(PlacementNewAdopt)
632 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
633 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
634 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
635 virtual Precedence precedence() const { return PrecPostfix; }
636 virtual void optimizeForUnnecessaryResult();
639 class PostDecLocalVarNode : public PostDecResolveNode {
641 PostDecLocalVarNode(size_t i) KJS_FAST_CALL
642 : PostDecResolveNode(PlacementNewAdopt)
644 ASSERT(i != missingSymbolMarker());
648 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
649 virtual void optimizeForUnnecessaryResult();
652 class PostfixBracketNode : public ExpressionNode {
654 PostfixBracketNode(ExpressionNode* b, ExpressionNode* s) KJS_FAST_CALL : m_base(b), m_subscript(s) {}
655 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
656 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
657 virtual Precedence precedence() const { return PrecPostfix; }
659 virtual bool isIncrement() const = 0;
660 RefPtr<ExpressionNode> m_base;
661 RefPtr<ExpressionNode> m_subscript;
664 class PostIncBracketNode : public PostfixBracketNode {
666 PostIncBracketNode(ExpressionNode* b, ExpressionNode* s) KJS_FAST_CALL : PostfixBracketNode(b, s) {}
667 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
669 virtual bool isIncrement() const { return true; }
672 class PostDecBracketNode : public PostfixBracketNode {
674 PostDecBracketNode(ExpressionNode* b, ExpressionNode* s) KJS_FAST_CALL : PostfixBracketNode(b, s) {}
675 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
677 virtual bool isIncrement() const { return false; }
680 class PostfixDotNode : public ExpressionNode {
682 PostfixDotNode(ExpressionNode* b, const Identifier& i) KJS_FAST_CALL : m_base(b), m_ident(i) {}
683 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
684 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
685 virtual Precedence precedence() const { return PrecPostfix; }
687 virtual bool isIncrement() const = 0;
688 RefPtr<ExpressionNode> m_base;
692 class PostIncDotNode : public PostfixDotNode {
694 PostIncDotNode(ExpressionNode* b, const Identifier& i) KJS_FAST_CALL : PostfixDotNode(b, i) {}
695 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
697 virtual bool isIncrement() const { return true; }
700 class PostDecDotNode : public PostfixDotNode {
702 PostDecDotNode(ExpressionNode* b, const Identifier& i) KJS_FAST_CALL : PostfixDotNode(b, i) {}
703 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
705 virtual bool isIncrement() const { return false; }
708 class PostfixErrorNode : public ExpressionNode {
710 PostfixErrorNode(ExpressionNode* e, Operator o) KJS_FAST_CALL : m_expr(e), m_oper(o) {}
711 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
712 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
713 virtual Precedence precedence() const { return PrecPostfix; }
715 RefPtr<ExpressionNode> m_expr;
719 class DeleteResolveNode : public ExpressionNode {
721 DeleteResolveNode(const Identifier& i) KJS_FAST_CALL : m_ident(i) {}
722 DeleteResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
723 : ExpressionNode(PlacementNewAdopt)
724 , m_ident(PlacementNewAdopt)
728 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
729 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
730 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
731 virtual Precedence precedence() const { return PrecUnary; }
736 class LocalVarDeleteNode : public DeleteResolveNode {
738 LocalVarDeleteNode() KJS_FAST_CALL
739 : DeleteResolveNode(PlacementNewAdopt)
743 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
746 class DeleteBracketNode : public ExpressionNode {
748 DeleteBracketNode(ExpressionNode* base, ExpressionNode* subscript) KJS_FAST_CALL : m_base(base), m_subscript(subscript) {}
749 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
750 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
751 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
752 virtual Precedence precedence() const { return PrecUnary; }
754 RefPtr<ExpressionNode> m_base;
755 RefPtr<ExpressionNode> m_subscript;
758 class DeleteDotNode : public ExpressionNode {
760 DeleteDotNode(ExpressionNode* base, const Identifier& i) KJS_FAST_CALL : m_base(base), m_ident(i) {}
761 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
762 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
763 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
764 virtual Precedence precedence() const { return PrecUnary; }
766 RefPtr<ExpressionNode> m_base;
770 class DeleteValueNode : public ExpressionNode {
772 DeleteValueNode(ExpressionNode* e) KJS_FAST_CALL : m_expr(e) {}
773 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
774 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
775 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
776 virtual Precedence precedence() const { return PrecUnary; }
778 RefPtr<ExpressionNode> m_expr;
781 class VoidNode : public ExpressionNode {
783 VoidNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
784 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
785 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
786 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
787 virtual Precedence precedence() const { return PrecUnary; }
789 RefPtr<ExpressionNode> expr;
792 class TypeOfResolveNode : public ExpressionNode {
794 TypeOfResolveNode(const Identifier &s) KJS_FAST_CALL
799 TypeOfResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
800 : ExpressionNode(PlacementNewAdopt)
801 , m_ident(PlacementNewAdopt)
805 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
807 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
808 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
809 virtual Precedence precedence() const { return PrecUnary; }
811 const Identifier& identifier() const KJS_FAST_CALL { return m_ident; }
815 size_t m_index; // Used by LocalTypeOfNode.
818 class LocalVarTypeOfNode : public TypeOfResolveNode {
820 LocalVarTypeOfNode(size_t i) KJS_FAST_CALL
821 : TypeOfResolveNode(PlacementNewAdopt)
823 ASSERT(i != missingSymbolMarker());
827 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
830 class TypeOfValueNode : public ExpressionNode {
832 TypeOfValueNode(ExpressionNode* e) KJS_FAST_CALL : m_expr(e) {}
833 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
834 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
835 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
836 virtual Precedence precedence() const { return PrecUnary; }
838 RefPtr<ExpressionNode> m_expr;
841 class PreIncResolveNode : public PrePostResolveNode {
843 PreIncResolveNode(const Identifier &s) KJS_FAST_CALL
844 : PrePostResolveNode(s)
848 PreIncResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
849 : PrePostResolveNode(PlacementNewAdopt)
853 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
855 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
856 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
857 virtual Precedence precedence() const { return PrecUnary; }
860 class PreIncLocalVarNode : public PreIncResolveNode {
862 PreIncLocalVarNode(size_t i) KJS_FAST_CALL
863 : PreIncResolveNode(PlacementNewAdopt)
865 ASSERT(i != missingSymbolMarker());
869 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
872 class PreDecResolveNode : public PrePostResolveNode {
874 PreDecResolveNode(const Identifier &s) KJS_FAST_CALL
875 : PrePostResolveNode(s)
879 PreDecResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
880 : PrePostResolveNode(PlacementNewAdopt)
884 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
886 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
887 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
888 virtual Precedence precedence() const { return PrecUnary; }
891 class PreDecLocalVarNode : public PreDecResolveNode {
893 PreDecLocalVarNode(size_t i) KJS_FAST_CALL
894 : PreDecResolveNode(PlacementNewAdopt)
896 ASSERT(i != missingSymbolMarker());
900 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
903 class PrefixBracketNode : public ExpressionNode {
905 PrefixBracketNode(ExpressionNode* b, ExpressionNode* s) KJS_FAST_CALL : m_base(b), m_subscript(s) {}
907 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
908 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
909 virtual Precedence precedence() const { return PrecUnary; }
911 virtual bool isIncrement() const = 0;
912 RefPtr<ExpressionNode> m_base;
913 RefPtr<ExpressionNode> m_subscript;
916 class PreIncBracketNode : public PrefixBracketNode {
918 PreIncBracketNode(ExpressionNode* b, ExpressionNode* s) KJS_FAST_CALL : PrefixBracketNode(b, s) {}
919 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
921 bool isIncrement() const { return true; }
924 class PreDecBracketNode : public PrefixBracketNode {
926 PreDecBracketNode(ExpressionNode* b, ExpressionNode* s) KJS_FAST_CALL : PrefixBracketNode(b, s) {}
927 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
929 bool isIncrement() const { return false; }
932 class PrefixDotNode : public ExpressionNode {
934 PrefixDotNode(ExpressionNode* b, const Identifier& i) KJS_FAST_CALL : m_base(b), m_ident(i) {}
935 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
936 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
937 virtual Precedence precedence() const { return PrecPostfix; }
939 virtual bool isIncrement() const = 0;
940 RefPtr<ExpressionNode> m_base;
944 class PreIncDotNode : public PrefixDotNode {
946 PreIncDotNode(ExpressionNode* b, const Identifier& i) KJS_FAST_CALL : PrefixDotNode(b, i) {}
947 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
949 virtual bool isIncrement() const { return true; }
952 class PreDecDotNode : public PrefixDotNode {
954 PreDecDotNode(ExpressionNode* b, const Identifier& i) KJS_FAST_CALL : PrefixDotNode(b, i) {}
955 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
957 virtual bool isIncrement() const { return false; }
960 class PrefixErrorNode : public ExpressionNode {
962 PrefixErrorNode(ExpressionNode* e, Operator o) KJS_FAST_CALL : m_expr(e), m_oper(o) {}
963 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
964 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
965 virtual Precedence precedence() const { return PrecUnary; }
967 RefPtr<ExpressionNode> m_expr;
971 class UnaryPlusNode : public ExpressionNode {
973 UnaryPlusNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
974 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
975 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
976 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
977 virtual Precedence precedence() const { return PrecUnary; }
979 RefPtr<ExpressionNode> expr;
982 class NegateNode : public ExpressionNode {
984 NegateNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
985 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
986 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
987 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
988 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
989 virtual Precedence precedence() const { return PrecUnary; }
991 RefPtr<ExpressionNode> expr;
994 class BitwiseNotNode : public ExpressionNode {
996 BitwiseNotNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
997 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
998 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
999 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1000 virtual Precedence precedence() const { return PrecUnary; }
1002 RefPtr<ExpressionNode> expr;
1005 class LogicalNotNode : public ExpressionNode {
1007 LogicalNotNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
1008 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1009 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1010 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1011 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1012 virtual Precedence precedence() const { return PrecUnary; }
1014 RefPtr<ExpressionNode> expr;
1017 class MultNode : public ExpressionNode {
1019 MultNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL : term1(t1), term2(t2) {}
1020 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1021 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1022 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
1023 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1024 virtual Precedence precedence() const { return PrecMultiplicitave; }
1026 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*);
1027 RefPtr<ExpressionNode> term1;
1028 RefPtr<ExpressionNode> term2;
1031 class DivNode : public ExpressionNode {
1033 DivNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL : term1(t1), term2(t2) {}
1034 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1035 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1036 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
1037 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1038 virtual Precedence precedence() const { return PrecMultiplicitave; }
1040 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*);
1041 RefPtr<ExpressionNode> term1;
1042 RefPtr<ExpressionNode> term2;
1045 class ModNode : public ExpressionNode {
1047 ModNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL : term1(t1), term2(t2) {}
1048 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1049 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1050 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
1051 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1052 virtual Precedence precedence() const { return PrecMultiplicitave; }
1054 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*);
1055 RefPtr<ExpressionNode> term1;
1056 RefPtr<ExpressionNode> term2;
1059 class AddNode : public ExpressionNode {
1061 AddNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL : term1(t1), term2(t2) {}
1062 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1063 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1064 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
1065 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1066 virtual Precedence precedence() const { return PrecAdditive; }
1068 RefPtr<ExpressionNode> term1;
1069 RefPtr<ExpressionNode> term2;
1072 class SubNode : public ExpressionNode {
1074 SubNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL : term1(t1), term2(t2) {}
1075 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1076 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1077 virtual double evaluateToNumber(ExecState*) KJS_FAST_CALL;
1078 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1079 virtual Precedence precedence() const { return PrecAdditive; }
1081 ALWAYS_INLINE double inlineEvaluateToNumber(ExecState*);
1082 RefPtr<ExpressionNode> term1;
1083 RefPtr<ExpressionNode> term2;
1086 class LeftShiftNode : public ExpressionNode {
1088 LeftShiftNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL
1089 : term1(t1), term2(t2) {}
1090 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1091 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1092 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1093 virtual Precedence precedence() const { return PrecShift; }
1095 RefPtr<ExpressionNode> term1;
1096 RefPtr<ExpressionNode> term2;
1099 class RightShiftNode : public ExpressionNode {
1101 RightShiftNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL
1102 : term1(t1), term2(t2) {}
1103 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1104 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1105 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1106 virtual Precedence precedence() const { return PrecShift; }
1108 RefPtr<ExpressionNode> term1;
1109 RefPtr<ExpressionNode> term2;
1112 class UnsignedRightShiftNode : public ExpressionNode {
1114 UnsignedRightShiftNode(ExpressionNode* t1, ExpressionNode* t2) KJS_FAST_CALL
1115 : term1(t1), term2(t2) {}
1116 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1117 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1118 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1119 virtual Precedence precedence() const { return PrecShift; }
1121 RefPtr<ExpressionNode> term1;
1122 RefPtr<ExpressionNode> term2;
1125 class LessNode : public ExpressionNode {
1127 LessNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1128 expr1(e1), expr2(e2) {}
1129 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1130 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1131 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1132 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1133 virtual Precedence precedence() const { return PrecRelational; }
1135 RefPtr<ExpressionNode> expr1;
1136 RefPtr<ExpressionNode> expr2;
1139 class GreaterNode : public ExpressionNode {
1141 GreaterNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1142 expr1(e1), expr2(e2) {}
1143 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1144 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1145 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1146 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1147 virtual Precedence precedence() const { return PrecRelational; }
1149 RefPtr<ExpressionNode> expr1;
1150 RefPtr<ExpressionNode> expr2;
1153 class LessEqNode : public ExpressionNode {
1155 LessEqNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1156 expr1(e1), expr2(e2) {}
1157 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1158 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1159 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1160 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1161 virtual Precedence precedence() const { return PrecRelational; }
1163 RefPtr<ExpressionNode> expr1;
1164 RefPtr<ExpressionNode> expr2;
1167 class GreaterEqNode : public ExpressionNode {
1169 GreaterEqNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1170 expr1(e1), expr2(e2) {}
1171 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1172 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1173 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1174 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1175 virtual Precedence precedence() const { return PrecRelational; }
1177 RefPtr<ExpressionNode> expr1;
1178 RefPtr<ExpressionNode> expr2;
1181 class InstanceOfNode : public ExpressionNode {
1183 InstanceOfNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1184 expr1(e1), expr2(e2) {}
1185 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1186 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1187 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1188 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1189 virtual Precedence precedence() const { return PrecRelational; }
1191 RefPtr<ExpressionNode> expr1;
1192 RefPtr<ExpressionNode> expr2;
1195 class InNode : public ExpressionNode {
1197 InNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1198 expr1(e1), expr2(e2) {}
1199 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1200 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1201 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1202 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1203 virtual Precedence precedence() const { return PrecRelational; }
1205 RefPtr<ExpressionNode> expr1;
1206 RefPtr<ExpressionNode> expr2;
1209 class EqualNode : public ExpressionNode {
1211 EqualNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL
1212 : expr1(e1), expr2(e2) {}
1213 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1214 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1215 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1216 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1217 virtual Precedence precedence() const { return PrecEquality; }
1219 RefPtr<ExpressionNode> expr1;
1220 RefPtr<ExpressionNode> expr2;
1223 class NotEqualNode : public ExpressionNode {
1225 NotEqualNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL
1226 : expr1(e1), expr2(e2) {}
1227 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1228 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1229 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1230 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1231 virtual Precedence precedence() const { return PrecEquality; }
1233 RefPtr<ExpressionNode> expr1;
1234 RefPtr<ExpressionNode> expr2;
1237 class StrictEqualNode : public ExpressionNode {
1239 StrictEqualNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL
1240 : expr1(e1), expr2(e2) {}
1241 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1242 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1243 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1244 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1245 virtual Precedence precedence() const { return PrecEquality; }
1247 RefPtr<ExpressionNode> expr1;
1248 RefPtr<ExpressionNode> expr2;
1251 class NotStrictEqualNode : public ExpressionNode {
1253 NotStrictEqualNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL
1254 : expr1(e1), expr2(e2) {}
1255 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1256 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1257 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1258 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1259 virtual Precedence precedence() const { return PrecEquality; }
1261 RefPtr<ExpressionNode> expr1;
1262 RefPtr<ExpressionNode> expr2;
1265 class BitAndNode : public ExpressionNode {
1267 BitAndNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1268 expr1(e1), expr2(e2) {}
1269 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1270 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1271 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1272 virtual Precedence precedence() const { return PrecBitwiseAnd; }
1274 RefPtr<ExpressionNode> expr1;
1275 RefPtr<ExpressionNode> expr2;
1278 class BitOrNode : public ExpressionNode {
1280 BitOrNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1281 expr1(e1), expr2(e2) {}
1282 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1283 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1284 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1285 virtual Precedence precedence() const { return PrecBitwiseOr; }
1287 RefPtr<ExpressionNode> expr1;
1288 RefPtr<ExpressionNode> expr2;
1291 class BitXOrNode : public ExpressionNode {
1293 BitXOrNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1294 expr1(e1), expr2(e2) {}
1295 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1296 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1297 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1298 virtual Precedence precedence() const { return PrecBitwiseXor; }
1300 RefPtr<ExpressionNode> expr1;
1301 RefPtr<ExpressionNode> expr2;
1305 * expr1 && expr2, expr1 || expr2
1307 class LogicalAndNode : public ExpressionNode {
1309 LogicalAndNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1310 expr1(e1), expr2(e2) {}
1311 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1312 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1313 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1314 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1315 virtual Precedence precedence() const { return PrecLogicalAnd; }
1317 RefPtr<ExpressionNode> expr1;
1318 RefPtr<ExpressionNode> expr2;
1321 class LogicalOrNode : public ExpressionNode {
1323 LogicalOrNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1324 expr1(e1), expr2(e2) {}
1325 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1326 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1327 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1328 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1329 virtual Precedence precedence() const { return PrecLogicalOr; }
1331 RefPtr<ExpressionNode> expr1;
1332 RefPtr<ExpressionNode> expr2;
1336 * The ternary operator, "logical ? expr1 : expr2"
1338 class ConditionalNode : public ExpressionNode {
1340 ConditionalNode(ExpressionNode* l, ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL :
1341 logical(l), expr1(e1), expr2(e2) {}
1342 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1343 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1344 virtual bool evaluateToBoolean(ExecState*) KJS_FAST_CALL;
1345 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1346 virtual Precedence precedence() const { return PrecConditional; }
1348 RefPtr<ExpressionNode> logical;
1349 RefPtr<ExpressionNode> expr1;
1350 RefPtr<ExpressionNode> expr2;
1353 class ReadModifyResolveNode : public ExpressionNode {
1355 ReadModifyResolveNode(const Identifier &ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL
1362 ReadModifyResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
1363 : ExpressionNode(PlacementNewAdopt)
1364 , m_ident(PlacementNewAdopt)
1365 , m_right(PlacementNewAdopt)
1369 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1370 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1371 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1372 virtual Precedence precedence() const { return PrecAssignment; }
1376 RefPtr<ExpressionNode> m_right;
1377 size_t m_index; // Used by ReadModifyLocalVarNode.
1380 class ReadModifyLocalVarNode : public ReadModifyResolveNode {
1382 ReadModifyLocalVarNode(size_t i) KJS_FAST_CALL
1383 : ReadModifyResolveNode(PlacementNewAdopt)
1385 ASSERT(i != missingSymbolMarker());
1389 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1392 class AssignResolveNode : public ExpressionNode {
1394 AssignResolveNode(const Identifier &ident, ExpressionNode* right) KJS_FAST_CALL
1400 AssignResolveNode(PlacementNewAdoptType) KJS_FAST_CALL
1401 : ExpressionNode(PlacementNewAdopt)
1402 , m_ident(PlacementNewAdopt)
1403 , m_right(PlacementNewAdopt)
1407 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1408 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1409 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1410 virtual Precedence precedence() const { return PrecAssignment; }
1413 RefPtr<ExpressionNode> m_right;
1414 size_t m_index; // Used by ReadModifyLocalVarNode.
1417 class AssignLocalVarNode : public AssignResolveNode {
1419 AssignLocalVarNode(size_t i) KJS_FAST_CALL
1420 : AssignResolveNode(PlacementNewAdopt)
1422 ASSERT(i != missingSymbolMarker());
1426 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1429 class ReadModifyBracketNode : public ExpressionNode {
1431 ReadModifyBracketNode(ExpressionNode* base, ExpressionNode* subscript, Operator oper, ExpressionNode* right) KJS_FAST_CALL
1432 : m_base(base), m_subscript(subscript), m_oper(oper), m_right(right) {}
1433 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1434 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1435 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1436 virtual Precedence precedence() const { return PrecAssignment; }
1438 RefPtr<ExpressionNode> m_base;
1439 RefPtr<ExpressionNode> m_subscript;
1441 RefPtr<ExpressionNode> m_right;
1444 class AssignBracketNode : public ExpressionNode {
1446 AssignBracketNode(ExpressionNode* base, ExpressionNode* subscript, ExpressionNode* right) KJS_FAST_CALL
1447 : m_base(base), m_subscript(subscript), m_right(right) {}
1448 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1449 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1450 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1451 virtual Precedence precedence() const { return PrecAssignment; }
1453 RefPtr<ExpressionNode> m_base;
1454 RefPtr<ExpressionNode> m_subscript;
1455 RefPtr<ExpressionNode> m_right;
1458 class AssignDotNode : public ExpressionNode {
1460 AssignDotNode(ExpressionNode* base, const Identifier& ident, ExpressionNode* right) KJS_FAST_CALL
1461 : m_base(base), m_ident(ident), m_right(right) {}
1462 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1463 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1464 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1465 virtual Precedence precedence() const { return PrecAssignment; }
1467 RefPtr<ExpressionNode> m_base;
1469 RefPtr<ExpressionNode> m_right;
1472 class ReadModifyDotNode : public ExpressionNode {
1474 ReadModifyDotNode(ExpressionNode* base, const Identifier& ident, Operator oper, ExpressionNode* right) KJS_FAST_CALL
1475 : m_base(base), m_ident(ident), m_oper(oper), m_right(right) {}
1476 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1477 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1478 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1479 virtual Precedence precedence() const { return PrecAssignment; }
1481 RefPtr<ExpressionNode> m_base;
1484 RefPtr<ExpressionNode> m_right;
1487 class AssignErrorNode : public ExpressionNode {
1489 AssignErrorNode(ExpressionNode* left, Operator oper, ExpressionNode* right) KJS_FAST_CALL
1490 : m_left(left), m_oper(oper), m_right(right) {}
1491 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1492 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1493 virtual Precedence precedence() const { return PrecAssignment; }
1495 RefPtr<ExpressionNode> m_left;
1497 RefPtr<ExpressionNode> m_right;
1500 class CommaNode : public ExpressionNode {
1502 CommaNode(ExpressionNode* e1, ExpressionNode* e2) KJS_FAST_CALL : expr1(e1), expr2(e2)
1504 e1->optimizeForUnnecessaryResult();
1506 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1507 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1508 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1509 virtual Precedence precedence() const { return PrecExpression; }
1511 RefPtr<ExpressionNode> expr1;
1512 RefPtr<ExpressionNode> expr2;
1515 class AssignExprNode : public ExpressionNode {
1517 AssignExprNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
1518 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1519 virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1520 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1521 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
1523 RefPtr<ExpressionNode> expr;
1526 class VarDeclNode : public ExpressionNode {
1528 enum Type { Variable, Constant };
1529 VarDeclNode(const Identifier &id, AssignExprNode *in, Type t) KJS_FAST_CALL;
1530 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1531 virtual KJS::JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1532 void evaluateSingle(ExecState*) KJS_FAST_CALL;
1533 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1534 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1535 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
1536 PassRefPtr<VarDeclNode> releaseNext() KJS_FAST_CALL { return next.release(); }
1540 ListRefPtr<VarDeclNode> next;
1542 void handleSlowCase(ExecState*, const ScopeChain&, JSValue*) KJS_FAST_CALL KJS_NO_INLINE;
1543 RefPtr<AssignExprNode> init;
1546 class VarStatementNode : public StatementNode {
1548 VarStatementNode(VarDeclNode* l) KJS_FAST_CALL : next(l) { m_mayHaveDeclarations = true; }
1549 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1550 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1551 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1552 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1554 RefPtr<VarDeclNode> next;
1557 typedef Vector<RefPtr<StatementNode> > SourceElements;
1559 class BlockNode : public StatementNode {
1561 BlockNode(SourceElements* children) KJS_FAST_CALL;
1562 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1563 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1564 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1565 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1567 OwnPtr<SourceElements> m_children;
1570 class EmptyStatementNode : public StatementNode {
1572 EmptyStatementNode() KJS_FAST_CALL { } // debug
1573 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1574 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1577 class ExprStatementNode : public StatementNode {
1579 ExprStatementNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) { }
1580 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1581 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1582 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1584 RefPtr<ExpressionNode> expr;
1587 class IfNode : public StatementNode {
1589 IfNode(ExpressionNode* e, StatementNode *s1, StatementNode *s2) KJS_FAST_CALL
1590 : expr(e), statement1(s1), statement2(s2) { m_mayHaveDeclarations = statement1->mayHaveDeclarations() || (statement2 && statement2->mayHaveDeclarations()); }
1591 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1592 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1593 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1594 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1596 RefPtr<ExpressionNode> expr;
1597 RefPtr<StatementNode> statement1;
1598 RefPtr<StatementNode> statement2;
1601 class DoWhileNode : public StatementNode {
1603 DoWhileNode(StatementNode *s, ExpressionNode* e) KJS_FAST_CALL : statement(s), expr(e) { m_mayHaveDeclarations = true; }
1604 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1605 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1606 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1607 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1609 RefPtr<StatementNode> statement;
1610 RefPtr<ExpressionNode> expr;
1613 class WhileNode : public StatementNode {
1615 WhileNode(ExpressionNode* e, StatementNode *s) KJS_FAST_CALL : expr(e), statement(s) { m_mayHaveDeclarations = true; }
1616 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1617 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1618 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1619 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1621 RefPtr<ExpressionNode> expr;
1622 RefPtr<StatementNode> statement;
1625 class ForNode : public StatementNode {
1627 ForNode(ExpressionNode* e1, ExpressionNode* e2, ExpressionNode* e3, StatementNode* s) KJS_FAST_CALL :
1628 expr1(e1), expr2(e2), expr3(e3), statement(s)
1630 m_mayHaveDeclarations = true;
1632 expr1->optimizeForUnnecessaryResult();
1634 expr3->optimizeForUnnecessaryResult();
1637 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1638 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1639 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1640 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1642 RefPtr<ExpressionNode> expr1;
1643 RefPtr<ExpressionNode> expr2;
1644 RefPtr<ExpressionNode> expr3;
1645 RefPtr<StatementNode> statement;
1648 class ForInNode : public StatementNode {
1650 ForInNode(ExpressionNode* l, ExpressionNode* e, StatementNode *s) KJS_FAST_CALL;
1651 ForInNode(const Identifier &i, AssignExprNode *in, ExpressionNode* e, StatementNode *s) KJS_FAST_CALL;
1652 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1653 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1654 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1655 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1658 RefPtr<AssignExprNode> init;
1659 RefPtr<ExpressionNode> lexpr;
1660 RefPtr<ExpressionNode> expr;
1661 RefPtr<VarDeclNode> varDecl;
1662 RefPtr<StatementNode> statement;
1665 class ContinueNode : public StatementNode {
1667 ContinueNode() KJS_FAST_CALL { }
1668 ContinueNode(const Identifier &i) KJS_FAST_CALL : ident(i) { }
1669 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1670 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1675 class BreakNode : public StatementNode {
1677 BreakNode() KJS_FAST_CALL { }
1678 BreakNode(const Identifier &i) KJS_FAST_CALL : ident(i) { }
1679 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1680 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1685 class ReturnNode : public StatementNode {
1687 ReturnNode(ExpressionNode* v) KJS_FAST_CALL : value(v) {}
1688 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1689 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1690 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1692 RefPtr<ExpressionNode> value;
1695 class WithNode : public StatementNode {
1697 WithNode(ExpressionNode* e, StatementNode* s) KJS_FAST_CALL : expr(e), statement(s) { m_mayHaveDeclarations = true; }
1698 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1699 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1700 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1701 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1703 RefPtr<ExpressionNode> expr;
1704 RefPtr<StatementNode> statement;
1707 class LabelNode : public StatementNode {
1709 LabelNode(const Identifier &l, StatementNode *s) KJS_FAST_CALL : label(l), statement(s) { m_mayHaveDeclarations = true; }
1710 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1711 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1712 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1713 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1716 RefPtr<StatementNode> statement;
1719 class ThrowNode : public StatementNode {
1721 ThrowNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) {}
1722 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1723 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1724 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1726 RefPtr<ExpressionNode> expr;
1729 class TryNode : public StatementNode {
1731 TryNode(StatementNode *b, const Identifier &e, StatementNode *c, StatementNode *f) KJS_FAST_CALL
1732 : tryBlock(b), exceptionIdent(e), catchBlock(c), finallyBlock(f) { m_mayHaveDeclarations = true; }
1733 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1734 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1735 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1736 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1738 RefPtr<StatementNode> tryBlock;
1739 Identifier exceptionIdent;
1740 RefPtr<StatementNode> catchBlock;
1741 RefPtr<StatementNode> finallyBlock;
1744 class ParameterNode : public Node {
1746 ParameterNode(const Identifier& i) KJS_FAST_CALL : id(i) { }
1747 ParameterNode(ParameterNode* l, const Identifier& i) KJS_FAST_CALL
1748 : id(i) { l->next = this; }
1749 Identifier ident() KJS_FAST_CALL { return id; }
1750 ParameterNode *nextParam() KJS_FAST_CALL { return next.get(); }
1751 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1752 PassRefPtr<ParameterNode> releaseNext() KJS_FAST_CALL { return next.release(); }
1753 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
1755 friend class FuncDeclNode;
1756 friend class FuncExprNode;
1758 ListRefPtr<ParameterNode> next;
1761 // inherited by ProgramNode
1762 class FunctionBodyNode : public BlockNode {
1764 FunctionBodyNode(SourceElements* children) KJS_FAST_CALL;
1765 int sourceId() KJS_FAST_CALL { return m_sourceId; }
1766 const UString& sourceURL() KJS_FAST_CALL { return m_sourceURL; }
1768 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1770 SymbolTable& symbolTable() { return m_symbolTable; }
1772 void addParam(const Identifier& ident) KJS_FAST_CALL;
1773 size_t numParams() const KJS_FAST_CALL { return m_parameters.size(); }
1774 Identifier paramName(size_t pos) const KJS_FAST_CALL { return m_parameters[pos]; }
1775 UString paramString() const KJS_FAST_CALL;
1776 Vector<Identifier>& parameters() KJS_FAST_CALL { return m_parameters; }
1777 ALWAYS_INLINE void processDeclarations(ExecState*);
1778 ALWAYS_INLINE void processDeclarationsForFunctionCode(ExecState*);
1779 ALWAYS_INLINE void processDeclarationsForProgramCode(ExecState*);
1781 UString m_sourceURL;
1784 void initializeDeclarationStacks(ExecState*);
1785 bool m_initializedDeclarationStacks;
1787 void initializeSymbolTable();
1788 bool m_initializedSymbolTable;
1790 void optimizeVariableAccess();
1791 bool m_optimizedResolveNodes;
1793 // Properties that will go into the ActivationImp's local storage. (Used for initializing the ActivationImp.)
1794 DeclarationStacks::VarStack m_varStack;
1795 DeclarationStacks::FunctionStack m_functionStack;
1796 Vector<Identifier> m_parameters;
1798 // Mapping from property name -> local storage index. (Used once to transform the AST, and subsequently for residual slow case lookups.)
1799 SymbolTable m_symbolTable;
1802 class FuncExprNode : public ExpressionNode {
1804 FuncExprNode(const Identifier& i, FunctionBodyNode* b, ParameterNode* p = 0) KJS_FAST_CALL
1805 : ident(i), param(p), body(b) { addParams(); }
1806 virtual JSValue *evaluate(ExecState*) KJS_FAST_CALL;
1807 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1808 virtual Precedence precedence() const { return PrecMember; }
1810 void addParams() KJS_FAST_CALL;
1811 // Used for streamTo
1812 friend class PropertyNode;
1814 RefPtr<ParameterNode> param;
1815 RefPtr<FunctionBodyNode> body;
1818 class FuncDeclNode : public StatementNode {
1820 FuncDeclNode(const Identifier& i, FunctionBodyNode* b) KJS_FAST_CALL
1821 : ident(i), body(b) { addParams(); m_mayHaveDeclarations = true; }
1822 FuncDeclNode(const Identifier& i, ParameterNode* p, FunctionBodyNode* b) KJS_FAST_CALL
1823 : ident(i), param(p), body(b) { addParams(); m_mayHaveDeclarations = true; }
1824 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1825 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1826 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1827 ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL;
1830 void addParams() KJS_FAST_CALL;
1831 RefPtr<ParameterNode> param;
1832 RefPtr<FunctionBodyNode> body;
1835 class CaseClauseNode : public Node {
1837 CaseClauseNode(ExpressionNode* e) KJS_FAST_CALL : expr(e) { m_mayHaveDeclarations = true; }
1838 CaseClauseNode(ExpressionNode* e, SourceElements* children) KJS_FAST_CALL
1839 : expr(e), m_children(children) { m_mayHaveDeclarations = true; }
1840 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1841 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1842 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1843 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
1845 JSValue* evaluate(ExecState*) KJS_FAST_CALL;
1846 Completion evalStatements(ExecState*) KJS_FAST_CALL;
1849 RefPtr<ExpressionNode> expr;
1850 OwnPtr<SourceElements> m_children;
1853 class ClauseListNode : public Node {
1855 ClauseListNode(CaseClauseNode* c) KJS_FAST_CALL : clause(c) { m_mayHaveDeclarations = true; }
1856 ClauseListNode(ClauseListNode* n, CaseClauseNode* c) KJS_FAST_CALL
1857 : clause(c) { n->next = this; m_mayHaveDeclarations = true; }
1858 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1859 CaseClauseNode* getClause() const KJS_FAST_CALL { return clause.get(); }
1860 ClauseListNode* getNext() const KJS_FAST_CALL { return next.get(); }
1861 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1862 PassRefPtr<ClauseListNode> releaseNext() KJS_FAST_CALL { return next.release(); }
1863 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1864 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
1866 friend class CaseBlockNode;
1867 RefPtr<CaseClauseNode> clause;
1868 ListRefPtr<ClauseListNode> next;
1871 class CaseBlockNode : public Node {
1873 CaseBlockNode(ClauseListNode* l1, CaseClauseNode* d, ClauseListNode* l2) KJS_FAST_CALL;
1874 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1875 Completion evalBlock(ExecState *exec, JSValue *input) KJS_FAST_CALL;
1876 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1877 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1878 virtual Precedence precedence() const { ASSERT_NOT_REACHED(); return PrecExpression; }
1880 RefPtr<ClauseListNode> list1;
1881 RefPtr<CaseClauseNode> def;
1882 RefPtr<ClauseListNode> list2;
1885 class SwitchNode : public StatementNode {
1887 SwitchNode(ExpressionNode* e, CaseBlockNode *b) KJS_FAST_CALL : expr(e), block(b) { m_mayHaveDeclarations = true; }
1888 virtual void optimizeVariableAccess(FunctionBodyNode*, DeclarationStacks::NodeStack&) KJS_FAST_CALL;
1889 virtual Completion execute(ExecState*) KJS_FAST_CALL;
1890 virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
1891 virtual void getDeclarations(DeclarationStacks&) KJS_FAST_CALL;
1893 RefPtr<ExpressionNode> expr;
1894 RefPtr<CaseBlockNode> block;
1897 class ProgramNode : public FunctionBodyNode {
1899 ProgramNode(SourceElements* children) KJS_FAST_CALL;
1902 struct ElementList {
1907 struct PropertyList {
1908 PropertyListNode* head;
1909 PropertyListNode* tail;
1912 struct ArgumentList {
1913 ArgumentListNode* head;
1914 ArgumentListNode* tail;
1917 struct VarDeclList {
1922 struct ParameterList {
1923 ParameterNode* head;
1924 ParameterNode* tail;
1928 ClauseListNode* head;
1929 ClauseListNode* tail;