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, 2008, 2009 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 "ResultType.h"
32 #include "SourceCode.h"
33 #include "SymbolTable.h"
34 #include <wtf/MathExtras.h>
35 #include <wtf/OwnPtr.h>
36 #include <wtf/Vector.h>
38 #if PLATFORM(X86) && COMPILER(GCC)
39 #define JSC_FAST_CALL __attribute__((regparm(3)))
47 class BytecodeGenerator
;
52 class ProgramCodeBlock
;
53 class PropertyListNode
;
57 typedef unsigned CodeFeatures
;
59 const CodeFeatures NoFeatures
= 0;
60 const CodeFeatures EvalFeature
= 1 << 0;
61 const CodeFeatures ClosureFeature
= 1 << 1;
62 const CodeFeatures AssignFeature
= 1 << 2;
63 const CodeFeatures ArgumentsFeature
= 1 << 3;
64 const CodeFeatures WithFeature
= 1 << 4;
65 const CodeFeatures CatchFeature
= 1 << 5;
66 const CodeFeatures ThisFeature
= 1 << 6;
67 const CodeFeatures AllFeatures
= EvalFeature
| ClosureFeature
| AssignFeature
| ArgumentsFeature
| WithFeature
| CatchFeature
| ThisFeature
;
86 enum LogicalOperator
{
91 namespace DeclarationStacks
{
92 enum VarAttrs
{ IsConstant
= 1, HasInitializer
= 2 };
93 typedef Vector
<std::pair
<Identifier
, unsigned> > VarStack
;
94 typedef Vector
<RefPtr
<FuncDeclNode
> > FunctionStack
;
98 enum SwitchType
{ SwitchNone
, SwitchImmediate
, SwitchCharacter
, SwitchString
};
99 uint32_t bytecodeOffset
;
100 SwitchType switchType
;
103 class ParserRefCounted
: Noncopyable
{
105 ParserRefCounted(JSGlobalData
*) JSC_FAST_CALL
;
108 virtual ~ParserRefCounted();
110 // Nonrecursive destruction.
111 virtual void releaseNodes(NodeReleaser
&);
113 void ref() JSC_FAST_CALL
;
114 void deref() JSC_FAST_CALL
;
115 bool hasOneRef() JSC_FAST_CALL
;
117 static void deleteNewObjects(JSGlobalData
*) JSC_FAST_CALL
;
120 JSGlobalData
* m_globalData
;
123 class Node
: public ParserRefCounted
{
125 Node(JSGlobalData
*) JSC_FAST_CALL
;
128 Return value: The register holding the production's value.
129 dst: An optional parameter specifying the most efficient
130 destination at which to store the production's value.
131 The callee must honor dst.
133 dst provides for a crude form of copy propagation. For example,
146 because the assignment node, "x =", passes r[x] as dst to the number
149 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* dst
= 0) JSC_FAST_CALL
= 0;
151 int lineNo() const { return m_line
; }
157 class ExpressionNode
: public Node
{
159 ExpressionNode(JSGlobalData
* globalData
, ResultType resultDesc
= ResultType::unknownType()) JSC_FAST_CALL
161 , m_resultDesc(resultDesc
)
165 virtual bool isNumber() const JSC_FAST_CALL
{ return false; }
166 virtual bool isString() const JSC_FAST_CALL
{ return false; }
167 virtual bool isNull() const JSC_FAST_CALL
{ return false; }
168 virtual bool isPure(BytecodeGenerator
&) const JSC_FAST_CALL
{ return false; }
169 virtual bool isLocation() const JSC_FAST_CALL
{ return false; }
170 virtual bool isResolveNode() const JSC_FAST_CALL
{ return false; }
171 virtual bool isBracketAccessorNode() const JSC_FAST_CALL
{ return false; }
172 virtual bool isDotAccessorNode() const JSC_FAST_CALL
{ return false; }
173 virtual bool isFuncExprNode() const JSC_FAST_CALL
{ return false; }
175 virtual ExpressionNode
* stripUnaryPlus() { return this; }
177 ResultType
resultDescriptor() const JSC_FAST_CALL
{ return m_resultDesc
; }
179 // This needs to be in public in order to compile using GCC 3.x
180 typedef enum { EvalOperator
, FunctionCall
} CallerType
;
183 ResultType m_resultDesc
;
186 class StatementNode
: public Node
{
188 StatementNode(JSGlobalData
*) JSC_FAST_CALL
;
189 void setLoc(int line0
, int line1
) JSC_FAST_CALL
;
190 int firstLine() const JSC_FAST_CALL
{ return lineNo(); }
191 int lastLine() const JSC_FAST_CALL
{ return m_lastLine
; }
193 virtual bool isEmptyStatement() const JSC_FAST_CALL
{ return false; }
194 virtual bool isReturnNode() const JSC_FAST_CALL
{ return false; }
195 virtual bool isExprStatement() const JSC_FAST_CALL
{ return false; }
197 virtual bool isBlock() const JSC_FAST_CALL
{ return false; }
198 virtual bool isLoop() const JSC_FAST_CALL
{ return false; }
204 class NullNode
: public ExpressionNode
{
206 NullNode(JSGlobalData
* globalData
) JSC_FAST_CALL
207 : ExpressionNode(globalData
, ResultType::nullType())
211 virtual bool isNull() const JSC_FAST_CALL
{ return true; }
213 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
216 class BooleanNode
: public ExpressionNode
{
218 BooleanNode(JSGlobalData
* globalData
, bool value
) JSC_FAST_CALL
219 : ExpressionNode(globalData
, ResultType::booleanType())
224 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
226 virtual bool isPure(BytecodeGenerator
&) const JSC_FAST_CALL
{ return true; }
232 class NumberNode
: public ExpressionNode
{
234 NumberNode(JSGlobalData
* globalData
, double v
) JSC_FAST_CALL
235 : ExpressionNode(globalData
, ResultType::numberType())
240 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
242 virtual bool isNumber() const JSC_FAST_CALL
{ return true; }
243 virtual bool isPure(BytecodeGenerator
&) const JSC_FAST_CALL
{ return true; }
244 double value() const JSC_FAST_CALL
{ return m_double
; }
245 void setValue(double d
) JSC_FAST_CALL
{ m_double
= d
; }
251 class StringNode
: public ExpressionNode
{
253 StringNode(JSGlobalData
* globalData
, const Identifier
& v
) JSC_FAST_CALL
254 : ExpressionNode(globalData
, ResultType::stringType())
259 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
261 virtual bool isString() const JSC_FAST_CALL
{ return true; }
262 const Identifier
& value() { return m_value
; }
263 virtual bool isPure(BytecodeGenerator
&) const JSC_FAST_CALL
{ return true; }
269 class ThrowableExpressionData
{
271 ThrowableExpressionData()
272 : m_divot(static_cast<uint32_t>(-1))
273 , m_startOffset(static_cast<uint16_t>(-1))
274 , m_endOffset(static_cast<uint16_t>(-1))
278 ThrowableExpressionData(unsigned divot
, unsigned startOffset
, unsigned endOffset
)
280 , m_startOffset(startOffset
)
281 , m_endOffset(endOffset
)
285 void setExceptionSourceCode(unsigned divot
, unsigned startOffset
, unsigned endOffset
)
288 m_startOffset
= startOffset
;
289 m_endOffset
= endOffset
;
292 uint32_t divot() const { return m_divot
; }
293 uint16_t startOffset() const { return m_startOffset
; }
294 uint16_t endOffset() const { return m_endOffset
; }
297 RegisterID
* emitThrowError(BytecodeGenerator
&, ErrorType
, const char* msg
);
298 RegisterID
* emitThrowError(BytecodeGenerator
&, ErrorType
, const char* msg
, const Identifier
&);
302 uint16_t m_startOffset
;
303 uint16_t m_endOffset
;
306 class ThrowableSubExpressionData
: public ThrowableExpressionData
{
308 ThrowableSubExpressionData()
309 : ThrowableExpressionData()
310 , m_subexpressionDivotOffset(0)
311 , m_subexpressionEndOffset(0)
315 ThrowableSubExpressionData(unsigned divot
, unsigned startOffset
, unsigned endOffset
)
316 : ThrowableExpressionData(divot
, startOffset
, endOffset
)
317 , m_subexpressionDivotOffset(0)
318 , m_subexpressionEndOffset(0)
322 void setSubexpressionInfo(uint32_t subexpressionDivot
, uint16_t subexpressionOffset
)
324 ASSERT(subexpressionDivot
<= divot());
325 if ((divot() - subexpressionDivot
) & ~0xFFFF) // Overflow means we can't do this safely, so just point at the primary divot
327 m_subexpressionDivotOffset
= divot() - subexpressionDivot
;
328 m_subexpressionEndOffset
= subexpressionOffset
;
332 uint16_t m_subexpressionDivotOffset
;
333 uint16_t m_subexpressionEndOffset
;
336 class ThrowablePrefixedSubExpressionData
: public ThrowableExpressionData
{
338 ThrowablePrefixedSubExpressionData()
339 : ThrowableExpressionData()
340 , m_subexpressionDivotOffset(0)
341 , m_subexpressionStartOffset(0)
345 ThrowablePrefixedSubExpressionData(unsigned divot
, unsigned startOffset
, unsigned endOffset
)
346 : ThrowableExpressionData(divot
, startOffset
, endOffset
)
347 , m_subexpressionDivotOffset(0)
348 , m_subexpressionStartOffset(0)
352 void setSubexpressionInfo(uint32_t subexpressionDivot
, uint16_t subexpressionOffset
)
354 ASSERT(subexpressionDivot
>= divot());
355 if ((subexpressionDivot
- divot()) & ~0xFFFF) // Overflow means we can't do this safely, so just point at the primary divot
357 m_subexpressionDivotOffset
= subexpressionDivot
- divot();
358 m_subexpressionStartOffset
= subexpressionOffset
;
362 uint16_t m_subexpressionDivotOffset
;
363 uint16_t m_subexpressionStartOffset
;
366 class RegExpNode
: public ExpressionNode
, public ThrowableExpressionData
{
368 RegExpNode(JSGlobalData
* globalData
, const UString
& pattern
, const UString
& flags
) JSC_FAST_CALL
369 : ExpressionNode(globalData
)
375 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
382 class ThisNode
: public ExpressionNode
{
384 ThisNode(JSGlobalData
* globalData
) JSC_FAST_CALL
385 : ExpressionNode(globalData
)
389 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
392 class ResolveNode
: public ExpressionNode
{
394 ResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, int startOffset
) JSC_FAST_CALL
395 : ExpressionNode(globalData
)
397 , m_startOffset(startOffset
)
401 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
403 virtual bool isPure(BytecodeGenerator
&) const JSC_FAST_CALL
;
404 virtual bool isLocation() const JSC_FAST_CALL
{ return true; }
405 virtual bool isResolveNode() const JSC_FAST_CALL
{ return true; }
406 const Identifier
& identifier() const JSC_FAST_CALL
{ return m_ident
; }
410 int32_t m_startOffset
;
413 class ElementNode
: public ParserRefCounted
{
415 ElementNode(JSGlobalData
* globalData
, int elision
, ExpressionNode
* node
) JSC_FAST_CALL
416 : ParserRefCounted(globalData
)
422 ElementNode(JSGlobalData
* globalData
, ElementNode
* l
, int elision
, ExpressionNode
* node
) JSC_FAST_CALL
423 : ParserRefCounted(globalData
)
430 virtual ~ElementNode();
431 virtual void releaseNodes(NodeReleaser
&);
433 int elision() const { return m_elision
; }
434 ExpressionNode
* value() { return m_node
.get(); }
436 ElementNode
* next() { return m_next
.get(); }
439 RefPtr
<ElementNode
> m_next
;
441 RefPtr
<ExpressionNode
> m_node
;
444 class ArrayNode
: public ExpressionNode
{
446 ArrayNode(JSGlobalData
* globalData
, int elision
) JSC_FAST_CALL
447 : ExpressionNode(globalData
)
453 ArrayNode(JSGlobalData
* globalData
, ElementNode
* element
) JSC_FAST_CALL
454 : ExpressionNode(globalData
)
461 ArrayNode(JSGlobalData
* globalData
, int elision
, ElementNode
* element
) JSC_FAST_CALL
462 : ExpressionNode(globalData
)
469 virtual ~ArrayNode();
470 virtual void releaseNodes(NodeReleaser
&);
472 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
475 RefPtr
<ElementNode
> m_element
;
480 class PropertyNode
: public ParserRefCounted
{
482 enum Type
{ Constant
, Getter
, Setter
};
484 PropertyNode(JSGlobalData
* globalData
, const Identifier
& name
, ExpressionNode
* assign
, Type type
) JSC_FAST_CALL
485 : ParserRefCounted(globalData
)
492 virtual ~PropertyNode();
493 virtual void releaseNodes(NodeReleaser
&);
495 const Identifier
& name() const { return m_name
; }
498 friend class PropertyListNode
;
500 RefPtr
<ExpressionNode
> m_assign
;
504 class PropertyListNode
: public Node
{
506 PropertyListNode(JSGlobalData
* globalData
, PropertyNode
* node
) JSC_FAST_CALL
512 PropertyListNode(JSGlobalData
* globalData
, PropertyNode
* node
, PropertyListNode
* list
) JSC_FAST_CALL
519 virtual ~PropertyListNode();
520 virtual void releaseNodes(NodeReleaser
&);
522 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
525 RefPtr
<PropertyNode
> m_node
;
526 RefPtr
<PropertyListNode
> m_next
;
529 class ObjectLiteralNode
: public ExpressionNode
{
531 ObjectLiteralNode(JSGlobalData
* globalData
) JSC_FAST_CALL
532 : ExpressionNode(globalData
)
536 ObjectLiteralNode(JSGlobalData
* globalData
, PropertyListNode
* list
) JSC_FAST_CALL
537 : ExpressionNode(globalData
)
542 virtual ~ObjectLiteralNode();
543 virtual void releaseNodes(NodeReleaser
&);
545 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
548 RefPtr
<PropertyListNode
> m_list
;
551 class BracketAccessorNode
: public ExpressionNode
, public ThrowableExpressionData
{
553 BracketAccessorNode(JSGlobalData
* globalData
, ExpressionNode
* base
, ExpressionNode
* subscript
, bool subscriptHasAssignments
) JSC_FAST_CALL
554 : ExpressionNode(globalData
)
556 , m_subscript(subscript
)
557 , m_subscriptHasAssignments(subscriptHasAssignments
)
561 virtual ~BracketAccessorNode();
562 virtual void releaseNodes(NodeReleaser
&);
564 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
566 virtual bool isLocation() const JSC_FAST_CALL
{ return true; }
567 virtual bool isBracketAccessorNode() const JSC_FAST_CALL
{ return true; }
568 ExpressionNode
* base() JSC_FAST_CALL
{ return m_base
.get(); }
569 ExpressionNode
* subscript() JSC_FAST_CALL
{ return m_subscript
.get(); }
572 RefPtr
<ExpressionNode
> m_base
;
573 RefPtr
<ExpressionNode
> m_subscript
;
574 bool m_subscriptHasAssignments
;
577 class DotAccessorNode
: public ExpressionNode
, public ThrowableExpressionData
{
579 DotAccessorNode(JSGlobalData
* globalData
, ExpressionNode
* base
, const Identifier
& ident
) JSC_FAST_CALL
580 : ExpressionNode(globalData
)
586 virtual ~DotAccessorNode();
587 virtual void releaseNodes(NodeReleaser
&);
589 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
591 virtual bool isLocation() const JSC_FAST_CALL
{ return true; }
592 virtual bool isDotAccessorNode() const JSC_FAST_CALL
{ return true; }
593 ExpressionNode
* base() const JSC_FAST_CALL
{ return m_base
.get(); }
594 const Identifier
& identifier() const JSC_FAST_CALL
{ return m_ident
; }
597 RefPtr
<ExpressionNode
> m_base
;
601 class ArgumentListNode
: public Node
{
603 ArgumentListNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
609 ArgumentListNode(JSGlobalData
* globalData
, ArgumentListNode
* listNode
, ExpressionNode
* expr
) JSC_FAST_CALL
613 listNode
->m_next
= this;
616 virtual ~ArgumentListNode();
617 virtual void releaseNodes(NodeReleaser
&);
619 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
621 RefPtr
<ArgumentListNode
> m_next
;
622 RefPtr
<ExpressionNode
> m_expr
;
625 class ArgumentsNode
: public ParserRefCounted
{
627 ArgumentsNode(JSGlobalData
* globalData
) JSC_FAST_CALL
628 : ParserRefCounted(globalData
)
632 ArgumentsNode(JSGlobalData
* globalData
, ArgumentListNode
* listNode
) JSC_FAST_CALL
633 : ParserRefCounted(globalData
)
634 , m_listNode(listNode
)
638 virtual ~ArgumentsNode();
639 virtual void releaseNodes(NodeReleaser
&);
641 RefPtr
<ArgumentListNode
> m_listNode
;
644 class NewExprNode
: public ExpressionNode
, public ThrowableExpressionData
{
646 NewExprNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
647 : ExpressionNode(globalData
)
652 NewExprNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, ArgumentsNode
* args
) JSC_FAST_CALL
653 : ExpressionNode(globalData
)
659 virtual ~NewExprNode();
660 virtual void releaseNodes(NodeReleaser
&);
662 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
665 RefPtr
<ExpressionNode
> m_expr
;
666 RefPtr
<ArgumentsNode
> m_args
;
669 class EvalFunctionCallNode
: public ExpressionNode
, public ThrowableExpressionData
{
671 EvalFunctionCallNode(JSGlobalData
* globalData
, ArgumentsNode
* args
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
672 : ExpressionNode(globalData
)
673 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
678 virtual ~EvalFunctionCallNode();
679 virtual void releaseNodes(NodeReleaser
&);
681 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
684 RefPtr
<ArgumentsNode
> m_args
;
687 class FunctionCallValueNode
: public ExpressionNode
, public ThrowableExpressionData
{
689 FunctionCallValueNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, ArgumentsNode
* args
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
690 : ExpressionNode(globalData
)
691 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
697 virtual ~FunctionCallValueNode();
698 virtual void releaseNodes(NodeReleaser
&);
700 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
703 RefPtr
<ExpressionNode
> m_expr
;
704 RefPtr
<ArgumentsNode
> m_args
;
707 class FunctionCallResolveNode
: public ExpressionNode
, public ThrowableExpressionData
{
709 FunctionCallResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, ArgumentsNode
* args
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
710 : ExpressionNode(globalData
)
711 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
717 virtual ~FunctionCallResolveNode();
718 virtual void releaseNodes(NodeReleaser
&);
720 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
724 RefPtr
<ArgumentsNode
> m_args
;
725 size_t m_index
; // Used by LocalVarFunctionCallNode.
726 size_t m_scopeDepth
; // Used by ScopedVarFunctionCallNode and NonLocalVarFunctionCallNode
729 class FunctionCallBracketNode
: public ExpressionNode
, public ThrowableSubExpressionData
{
731 FunctionCallBracketNode(JSGlobalData
* globalData
, ExpressionNode
* base
, ExpressionNode
* subscript
, ArgumentsNode
* args
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
732 : ExpressionNode(globalData
)
733 , ThrowableSubExpressionData(divot
, startOffset
, endOffset
)
735 , m_subscript(subscript
)
740 virtual ~FunctionCallBracketNode();
741 virtual void releaseNodes(NodeReleaser
&);
743 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
746 RefPtr
<ExpressionNode
> m_base
;
747 RefPtr
<ExpressionNode
> m_subscript
;
748 RefPtr
<ArgumentsNode
> m_args
;
751 class FunctionCallDotNode
: public ExpressionNode
, public ThrowableSubExpressionData
{
753 FunctionCallDotNode(JSGlobalData
* globalData
, ExpressionNode
* base
, const Identifier
& ident
, ArgumentsNode
* args
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
754 : ExpressionNode(globalData
)
755 , ThrowableSubExpressionData(divot
, startOffset
, endOffset
)
762 virtual ~FunctionCallDotNode();
763 virtual void releaseNodes(NodeReleaser
&);
765 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
768 RefPtr
<ExpressionNode
> m_base
;
770 RefPtr
<ArgumentsNode
> m_args
;
773 class PrePostResolveNode
: public ExpressionNode
, public ThrowableExpressionData
{
775 PrePostResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
776 : ExpressionNode(globalData
, ResultType::numberType()) // could be reusable for pre?
777 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
786 class PostfixResolveNode
: public PrePostResolveNode
{
788 PostfixResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
789 : PrePostResolveNode(globalData
, ident
, divot
, startOffset
, endOffset
)
794 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
800 class PostfixBracketNode
: public ExpressionNode
, public ThrowableSubExpressionData
{
802 PostfixBracketNode(JSGlobalData
* globalData
, ExpressionNode
* base
, ExpressionNode
* subscript
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
803 : ExpressionNode(globalData
)
804 , ThrowableSubExpressionData(divot
, startOffset
, endOffset
)
806 , m_subscript(subscript
)
811 virtual ~PostfixBracketNode();
812 virtual void releaseNodes(NodeReleaser
&);
814 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
817 RefPtr
<ExpressionNode
> m_base
;
818 RefPtr
<ExpressionNode
> m_subscript
;
822 class PostfixDotNode
: public ExpressionNode
, public ThrowableSubExpressionData
{
824 PostfixDotNode(JSGlobalData
* globalData
, ExpressionNode
* base
, const Identifier
& ident
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
825 : ExpressionNode(globalData
)
826 , ThrowableSubExpressionData(divot
, startOffset
, endOffset
)
833 virtual ~PostfixDotNode();
834 virtual void releaseNodes(NodeReleaser
&);
836 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
839 RefPtr
<ExpressionNode
> m_base
;
844 class PostfixErrorNode
: public ExpressionNode
, public ThrowableSubExpressionData
{
846 PostfixErrorNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
847 : ExpressionNode(globalData
)
848 , ThrowableSubExpressionData(divot
, startOffset
, endOffset
)
854 virtual ~PostfixErrorNode();
855 virtual void releaseNodes(NodeReleaser
&);
857 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
860 RefPtr
<ExpressionNode
> m_expr
;
864 class DeleteResolveNode
: public ExpressionNode
, public ThrowableExpressionData
{
866 DeleteResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
867 : ExpressionNode(globalData
)
868 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
873 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
879 class DeleteBracketNode
: public ExpressionNode
, public ThrowableExpressionData
{
881 DeleteBracketNode(JSGlobalData
* globalData
, ExpressionNode
* base
, ExpressionNode
* subscript
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
882 : ExpressionNode(globalData
)
883 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
885 , m_subscript(subscript
)
889 virtual ~DeleteBracketNode();
890 virtual void releaseNodes(NodeReleaser
&);
892 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
895 RefPtr
<ExpressionNode
> m_base
;
896 RefPtr
<ExpressionNode
> m_subscript
;
899 class DeleteDotNode
: public ExpressionNode
, public ThrowableExpressionData
{
901 DeleteDotNode(JSGlobalData
* globalData
, ExpressionNode
* base
, const Identifier
& ident
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
902 : ExpressionNode(globalData
)
903 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
909 virtual ~DeleteDotNode();
910 virtual void releaseNodes(NodeReleaser
&);
912 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
915 RefPtr
<ExpressionNode
> m_base
;
919 class DeleteValueNode
: public ExpressionNode
{
921 DeleteValueNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
922 : ExpressionNode(globalData
)
927 virtual ~DeleteValueNode();
928 virtual void releaseNodes(NodeReleaser
&);
930 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
933 RefPtr
<ExpressionNode
> m_expr
;
936 class VoidNode
: public ExpressionNode
{
938 VoidNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
939 : ExpressionNode(globalData
)
945 virtual void releaseNodes(NodeReleaser
&);
947 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
950 RefPtr
<ExpressionNode
> m_expr
;
953 class TypeOfResolveNode
: public ExpressionNode
{
955 TypeOfResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
) JSC_FAST_CALL
956 : ExpressionNode(globalData
, ResultType::stringType())
961 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
963 const Identifier
& identifier() const JSC_FAST_CALL
{ return m_ident
; }
969 class TypeOfValueNode
: public ExpressionNode
{
971 TypeOfValueNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
972 : ExpressionNode(globalData
, ResultType::stringType())
977 virtual ~TypeOfValueNode();
978 virtual void releaseNodes(NodeReleaser
&);
980 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
983 RefPtr
<ExpressionNode
> m_expr
;
986 class PrefixResolveNode
: public PrePostResolveNode
{
988 PrefixResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
989 : PrePostResolveNode(globalData
, ident
, divot
, startOffset
, endOffset
)
994 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1000 class PrefixBracketNode
: public ExpressionNode
, public ThrowablePrefixedSubExpressionData
{
1002 PrefixBracketNode(JSGlobalData
* globalData
, ExpressionNode
* base
, ExpressionNode
* subscript
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1003 : ExpressionNode(globalData
)
1004 , ThrowablePrefixedSubExpressionData(divot
, startOffset
, endOffset
)
1006 , m_subscript(subscript
)
1011 virtual ~PrefixBracketNode();
1012 virtual void releaseNodes(NodeReleaser
&);
1014 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1017 RefPtr
<ExpressionNode
> m_base
;
1018 RefPtr
<ExpressionNode
> m_subscript
;
1019 Operator m_operator
;
1022 class PrefixDotNode
: public ExpressionNode
, public ThrowablePrefixedSubExpressionData
{
1024 PrefixDotNode(JSGlobalData
* globalData
, ExpressionNode
* base
, const Identifier
& ident
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1025 : ExpressionNode(globalData
)
1026 , ThrowablePrefixedSubExpressionData(divot
, startOffset
, endOffset
)
1033 virtual ~PrefixDotNode();
1034 virtual void releaseNodes(NodeReleaser
&);
1036 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1039 RefPtr
<ExpressionNode
> m_base
;
1041 Operator m_operator
;
1044 class PrefixErrorNode
: public ExpressionNode
, public ThrowableExpressionData
{
1046 PrefixErrorNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, Operator oper
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1047 : ExpressionNode(globalData
)
1048 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
1054 virtual ~PrefixErrorNode();
1055 virtual void releaseNodes(NodeReleaser
&);
1057 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1060 RefPtr
<ExpressionNode
> m_expr
;
1061 Operator m_operator
;
1064 class UnaryOpNode
: public ExpressionNode
{
1066 UnaryOpNode(JSGlobalData
* globalData
, ExpressionNode
* expr
)
1067 : ExpressionNode(globalData
)
1072 UnaryOpNode(JSGlobalData
* globalData
, ResultType type
, ExpressionNode
* expr
)
1073 : ExpressionNode(globalData
, type
)
1078 virtual ~UnaryOpNode();
1079 virtual void releaseNodes(NodeReleaser
&);
1081 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1082 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
= 0;
1085 RefPtr
<ExpressionNode
> m_expr
;
1088 class UnaryPlusNode
: public UnaryOpNode
{
1090 UnaryPlusNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
1091 : UnaryOpNode(globalData
, ResultType::numberType(), expr
)
1095 virtual ExpressionNode
* stripUnaryPlus() { return m_expr
.get(); }
1097 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_to_jsnumber
; }
1100 class NegateNode
: public UnaryOpNode
{
1102 NegateNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
1103 : UnaryOpNode(globalData
, ResultType::numberTypeCanReuse(), expr
)
1107 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_negate
; }
1110 class BitwiseNotNode
: public UnaryOpNode
{
1112 BitwiseNotNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
1113 : UnaryOpNode(globalData
, ResultType::forBitOp(), expr
)
1117 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_bitnot
; }
1120 class LogicalNotNode
: public UnaryOpNode
{
1122 LogicalNotNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
1123 : UnaryOpNode(globalData
, ResultType::booleanType(), expr
)
1127 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_not
; }
1130 class BinaryOpNode
: public ExpressionNode
{
1132 BinaryOpNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
)
1133 : ExpressionNode(globalData
)
1136 , m_rightHasAssignments(rightHasAssignments
)
1140 BinaryOpNode(JSGlobalData
* globalData
, ResultType type
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
)
1141 : ExpressionNode(globalData
, type
)
1144 , m_rightHasAssignments(rightHasAssignments
)
1148 virtual ~BinaryOpNode();
1149 virtual void releaseNodes(NodeReleaser
&);
1151 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1152 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
= 0;
1155 RefPtr
<ExpressionNode
> m_expr1
;
1156 RefPtr
<ExpressionNode
> m_expr2
;
1157 bool m_rightHasAssignments
;
1160 class ReverseBinaryOpNode
: public BinaryOpNode
{
1162 ReverseBinaryOpNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
)
1163 : BinaryOpNode(globalData
, expr1
, expr2
, rightHasAssignments
)
1167 ReverseBinaryOpNode(JSGlobalData
* globalData
, ResultType type
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
)
1168 : BinaryOpNode(globalData
, type
, expr1
, expr2
, rightHasAssignments
)
1172 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1175 class MultNode
: public BinaryOpNode
{
1177 MultNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1178 : BinaryOpNode(globalData
, ResultType::numberTypeCanReuse(), expr1
, expr2
, rightHasAssignments
)
1182 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_mul
; }
1185 class DivNode
: public BinaryOpNode
{
1187 DivNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1188 : BinaryOpNode(globalData
, ResultType::numberTypeCanReuse(), expr1
, expr2
, rightHasAssignments
)
1192 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_div
; }
1195 class ModNode
: public BinaryOpNode
{
1197 ModNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1198 : BinaryOpNode(globalData
, ResultType::numberTypeCanReuse(), expr1
, expr2
, rightHasAssignments
)
1202 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_mod
; }
1205 class AddNode
: public BinaryOpNode
{
1207 AddNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1208 : BinaryOpNode(globalData
, ResultType::forAdd(expr1
->resultDescriptor(), expr2
->resultDescriptor()), expr1
, expr2
, rightHasAssignments
)
1212 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_add
; }
1215 class SubNode
: public BinaryOpNode
{
1217 SubNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1218 : BinaryOpNode(globalData
, ResultType::numberTypeCanReuse(), expr1
, expr2
, rightHasAssignments
)
1222 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_sub
; }
1225 class LeftShiftNode
: public BinaryOpNode
{
1227 LeftShiftNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1228 : BinaryOpNode(globalData
, ResultType::forBitOp(), expr1
, expr2
, rightHasAssignments
)
1232 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_lshift
; }
1235 class RightShiftNode
: public BinaryOpNode
{
1237 RightShiftNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1238 : BinaryOpNode(globalData
, ResultType::forBitOp(), expr1
, expr2
, rightHasAssignments
)
1242 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_rshift
; }
1245 class UnsignedRightShiftNode
: public BinaryOpNode
{
1247 UnsignedRightShiftNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1248 : BinaryOpNode(globalData
, ResultType::numberTypeCanReuse(), expr1
, expr2
, rightHasAssignments
)
1252 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_urshift
; }
1255 class LessNode
: public BinaryOpNode
{
1257 LessNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1258 : BinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1262 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_less
; }
1265 class GreaterNode
: public ReverseBinaryOpNode
{
1267 GreaterNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1268 : ReverseBinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1272 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_less
; }
1275 class LessEqNode
: public BinaryOpNode
{
1277 LessEqNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1278 : BinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1282 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_lesseq
; }
1285 class GreaterEqNode
: public ReverseBinaryOpNode
{
1287 GreaterEqNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1288 : ReverseBinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1292 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_lesseq
; }
1295 class ThrowableBinaryOpNode
: public BinaryOpNode
, public ThrowableExpressionData
{
1297 ThrowableBinaryOpNode(JSGlobalData
* globalData
, ResultType type
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1298 : BinaryOpNode(globalData
, type
, expr1
, expr2
, rightHasAssignments
)
1301 ThrowableBinaryOpNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1302 : BinaryOpNode(globalData
, expr1
, expr2
, rightHasAssignments
)
1305 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1308 class InstanceOfNode
: public ThrowableBinaryOpNode
{
1310 InstanceOfNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1311 : ThrowableBinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1315 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_instanceof
; }
1317 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1320 class InNode
: public ThrowableBinaryOpNode
{
1322 InNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1323 : ThrowableBinaryOpNode(globalData
, expr1
, expr2
, rightHasAssignments
)
1327 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_in
; }
1330 class EqualNode
: public BinaryOpNode
{
1332 EqualNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1333 : BinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1337 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1338 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_eq
; }
1341 class NotEqualNode
: public BinaryOpNode
{
1343 NotEqualNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1344 : BinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1348 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_neq
; }
1351 class StrictEqualNode
: public BinaryOpNode
{
1353 StrictEqualNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1354 : BinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1358 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1359 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_stricteq
; }
1362 class NotStrictEqualNode
: public BinaryOpNode
{
1364 NotStrictEqualNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1365 : BinaryOpNode(globalData
, ResultType::booleanType(), expr1
, expr2
, rightHasAssignments
)
1369 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_nstricteq
; }
1372 class BitAndNode
: public BinaryOpNode
{
1374 BitAndNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1375 : BinaryOpNode(globalData
, ResultType::forBitOp(), expr1
, expr2
, rightHasAssignments
)
1379 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_bitand
; }
1382 class BitOrNode
: public BinaryOpNode
{
1384 BitOrNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1385 : BinaryOpNode(globalData
, ResultType::forBitOp(), expr1
, expr2
, rightHasAssignments
)
1389 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_bitor
; }
1392 class BitXOrNode
: public BinaryOpNode
{
1394 BitXOrNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, bool rightHasAssignments
) JSC_FAST_CALL
1395 : BinaryOpNode(globalData
, ResultType::forBitOp(), expr1
, expr2
, rightHasAssignments
)
1399 virtual OpcodeID
opcodeID() const JSC_FAST_CALL
{ return op_bitxor
; }
1403 * m_expr1 && m_expr2, m_expr1 || m_expr2
1405 class LogicalOpNode
: public ExpressionNode
{
1407 LogicalOpNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, LogicalOperator oper
) JSC_FAST_CALL
1408 : ExpressionNode(globalData
, ResultType::booleanType())
1415 virtual ~LogicalOpNode();
1416 virtual void releaseNodes(NodeReleaser
&);
1418 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1421 RefPtr
<ExpressionNode
> m_expr1
;
1422 RefPtr
<ExpressionNode
> m_expr2
;
1423 LogicalOperator m_operator
;
1427 * The ternary operator, "m_logical ? m_expr1 : m_expr2"
1429 class ConditionalNode
: public ExpressionNode
{
1431 ConditionalNode(JSGlobalData
* globalData
, ExpressionNode
* logical
, ExpressionNode
* expr1
, ExpressionNode
* expr2
) JSC_FAST_CALL
1432 : ExpressionNode(globalData
)
1433 , m_logical(logical
)
1439 virtual ~ConditionalNode();
1440 virtual void releaseNodes(NodeReleaser
&);
1442 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1445 RefPtr
<ExpressionNode
> m_logical
;
1446 RefPtr
<ExpressionNode
> m_expr1
;
1447 RefPtr
<ExpressionNode
> m_expr2
;
1450 class ReadModifyResolveNode
: public ExpressionNode
, public ThrowableExpressionData
{
1452 ReadModifyResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, Operator oper
, ExpressionNode
* right
, bool rightHasAssignments
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1453 : ExpressionNode(globalData
)
1454 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
1458 , m_rightHasAssignments(rightHasAssignments
)
1462 virtual ~ReadModifyResolveNode();
1463 virtual void releaseNodes(NodeReleaser
&);
1465 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1469 RefPtr
<ExpressionNode
> m_right
;
1470 size_t m_index
; // Used by ReadModifyLocalVarNode.
1471 Operator m_operator
: 31;
1472 bool m_rightHasAssignments
: 1;
1475 class AssignResolveNode
: public ExpressionNode
, public ThrowableExpressionData
{
1477 AssignResolveNode(JSGlobalData
* globalData
, const Identifier
& ident
, ExpressionNode
* right
, bool rightHasAssignments
) JSC_FAST_CALL
1478 : ExpressionNode(globalData
)
1481 , m_rightHasAssignments(rightHasAssignments
)
1485 virtual ~AssignResolveNode();
1486 virtual void releaseNodes(NodeReleaser
&);
1488 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1492 RefPtr
<ExpressionNode
> m_right
;
1493 size_t m_index
; // Used by ReadModifyLocalVarNode.
1494 bool m_rightHasAssignments
;
1497 class ReadModifyBracketNode
: public ExpressionNode
, public ThrowableSubExpressionData
{
1499 ReadModifyBracketNode(JSGlobalData
* globalData
, ExpressionNode
* base
, ExpressionNode
* subscript
, Operator oper
, ExpressionNode
* right
, bool subscriptHasAssignments
, bool rightHasAssignments
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1500 : ExpressionNode(globalData
)
1501 , ThrowableSubExpressionData(divot
, startOffset
, endOffset
)
1503 , m_subscript(subscript
)
1506 , m_subscriptHasAssignments(subscriptHasAssignments
)
1507 , m_rightHasAssignments(rightHasAssignments
)
1511 virtual ~ReadModifyBracketNode();
1512 virtual void releaseNodes(NodeReleaser
&);
1514 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1517 RefPtr
<ExpressionNode
> m_base
;
1518 RefPtr
<ExpressionNode
> m_subscript
;
1519 RefPtr
<ExpressionNode
> m_right
;
1520 Operator m_operator
: 30;
1521 bool m_subscriptHasAssignments
: 1;
1522 bool m_rightHasAssignments
: 1;
1525 class AssignBracketNode
: public ExpressionNode
, public ThrowableExpressionData
{
1527 AssignBracketNode(JSGlobalData
* globalData
, ExpressionNode
* base
, ExpressionNode
* subscript
, ExpressionNode
* right
, bool subscriptHasAssignments
, bool rightHasAssignments
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1528 : ExpressionNode(globalData
)
1529 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
1531 , m_subscript(subscript
)
1533 , m_subscriptHasAssignments(subscriptHasAssignments
)
1534 , m_rightHasAssignments(rightHasAssignments
)
1538 virtual ~AssignBracketNode();
1539 virtual void releaseNodes(NodeReleaser
&);
1541 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1544 RefPtr
<ExpressionNode
> m_base
;
1545 RefPtr
<ExpressionNode
> m_subscript
;
1546 RefPtr
<ExpressionNode
> m_right
;
1547 bool m_subscriptHasAssignments
: 1;
1548 bool m_rightHasAssignments
: 1;
1551 class AssignDotNode
: public ExpressionNode
, public ThrowableExpressionData
{
1553 AssignDotNode(JSGlobalData
* globalData
, ExpressionNode
* base
, const Identifier
& ident
, ExpressionNode
* right
, bool rightHasAssignments
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1554 : ExpressionNode(globalData
)
1555 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
1559 , m_rightHasAssignments(rightHasAssignments
)
1563 virtual ~AssignDotNode();
1564 virtual void releaseNodes(NodeReleaser
&);
1566 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1569 RefPtr
<ExpressionNode
> m_base
;
1571 RefPtr
<ExpressionNode
> m_right
;
1572 bool m_rightHasAssignments
;
1575 class ReadModifyDotNode
: public ExpressionNode
, public ThrowableSubExpressionData
{
1577 ReadModifyDotNode(JSGlobalData
* globalData
, ExpressionNode
* base
, const Identifier
& ident
, Operator oper
, ExpressionNode
* right
, bool rightHasAssignments
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1578 : ExpressionNode(globalData
)
1579 , ThrowableSubExpressionData(divot
, startOffset
, endOffset
)
1584 , m_rightHasAssignments(rightHasAssignments
)
1588 virtual ~ReadModifyDotNode();
1589 virtual void releaseNodes(NodeReleaser
&);
1591 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1594 RefPtr
<ExpressionNode
> m_base
;
1596 RefPtr
<ExpressionNode
> m_right
;
1597 Operator m_operator
: 31;
1598 bool m_rightHasAssignments
: 1;
1601 class AssignErrorNode
: public ExpressionNode
, public ThrowableExpressionData
{
1603 AssignErrorNode(JSGlobalData
* globalData
, ExpressionNode
* left
, Operator oper
, ExpressionNode
* right
, unsigned divot
, unsigned startOffset
, unsigned endOffset
) JSC_FAST_CALL
1604 : ExpressionNode(globalData
)
1605 , ThrowableExpressionData(divot
, startOffset
, endOffset
)
1612 virtual ~AssignErrorNode();
1613 virtual void releaseNodes(NodeReleaser
&);
1615 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1618 RefPtr
<ExpressionNode
> m_left
;
1619 Operator m_operator
;
1620 RefPtr
<ExpressionNode
> m_right
;
1623 class CommaNode
: public ExpressionNode
{
1625 CommaNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
) JSC_FAST_CALL
1626 : ExpressionNode(globalData
)
1632 virtual ~CommaNode();
1633 virtual void releaseNodes(NodeReleaser
&);
1635 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1638 RefPtr
<ExpressionNode
> m_expr1
;
1639 RefPtr
<ExpressionNode
> m_expr2
;
1642 class VarDeclCommaNode
: public CommaNode
{
1644 VarDeclCommaNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
) JSC_FAST_CALL
1645 : CommaNode(globalData
, expr1
, expr2
)
1650 class ConstDeclNode
: public ExpressionNode
{
1652 ConstDeclNode(JSGlobalData
* globalData
, const Identifier
& ident
, ExpressionNode
* in
) JSC_FAST_CALL
;
1654 virtual ~ConstDeclNode();
1655 virtual void releaseNodes(NodeReleaser
&);
1658 RefPtr
<ConstDeclNode
> m_next
;
1659 RefPtr
<ExpressionNode
> m_init
;
1661 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1662 virtual RegisterID
* emitCodeSingle(BytecodeGenerator
&) JSC_FAST_CALL
;
1665 class ConstStatementNode
: public StatementNode
{
1667 ConstStatementNode(JSGlobalData
* globalData
, ConstDeclNode
* next
) JSC_FAST_CALL
1668 : StatementNode(globalData
)
1673 virtual ~ConstStatementNode();
1674 virtual void releaseNodes(NodeReleaser
&);
1676 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1679 RefPtr
<ConstDeclNode
> m_next
;
1682 typedef Vector
<RefPtr
<StatementNode
> > StatementVector
;
1684 class SourceElements
: public ParserRefCounted
{
1686 SourceElements(JSGlobalData
* globalData
) : ParserRefCounted(globalData
) {}
1688 void append(PassRefPtr
<StatementNode
>);
1689 void releaseContentsIntoVector(StatementVector
& destination
)
1691 ASSERT(destination
.isEmpty());
1692 m_statements
.swap(destination
);
1693 destination
.shrinkToFit();
1697 StatementVector m_statements
;
1700 class BlockNode
: public StatementNode
{
1702 BlockNode(JSGlobalData
*, SourceElements
* children
) JSC_FAST_CALL
;
1704 virtual ~BlockNode();
1705 virtual void releaseNodes(NodeReleaser
&);
1707 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1709 StatementVector
& children() { return m_children
; }
1711 virtual bool isBlock() const JSC_FAST_CALL
{ return true; }
1714 StatementVector m_children
;
1717 class EmptyStatementNode
: public StatementNode
{
1719 EmptyStatementNode(JSGlobalData
* globalData
) JSC_FAST_CALL
// debug
1720 : StatementNode(globalData
)
1724 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1726 virtual bool isEmptyStatement() const JSC_FAST_CALL
{ return true; }
1729 class DebuggerStatementNode
: public StatementNode
{
1731 DebuggerStatementNode(JSGlobalData
* globalData
) JSC_FAST_CALL
1732 : StatementNode(globalData
)
1736 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1739 class ExprStatementNode
: public StatementNode
{
1741 ExprStatementNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
1742 : StatementNode(globalData
)
1747 virtual bool isExprStatement() const JSC_FAST_CALL
{ return true; }
1749 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1751 ExpressionNode
* expr() const { return m_expr
.get(); }
1754 RefPtr
<ExpressionNode
> m_expr
;
1757 class VarStatementNode
: public StatementNode
{
1759 VarStatementNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
1760 : StatementNode(globalData
)
1765 virtual ~VarStatementNode();
1766 virtual void releaseNodes(NodeReleaser
&);
1768 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1771 RefPtr
<ExpressionNode
> m_expr
;
1774 class IfNode
: public StatementNode
{
1776 IfNode(JSGlobalData
* globalData
, ExpressionNode
* condition
, StatementNode
* ifBlock
) JSC_FAST_CALL
1777 : StatementNode(globalData
)
1778 , m_condition(condition
)
1779 , m_ifBlock(ifBlock
)
1784 virtual void releaseNodes(NodeReleaser
&);
1786 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1789 RefPtr
<ExpressionNode
> m_condition
;
1790 RefPtr
<StatementNode
> m_ifBlock
;
1793 class IfElseNode
: public IfNode
{
1795 IfElseNode(JSGlobalData
* globalData
, ExpressionNode
* condition
, StatementNode
* ifBlock
, StatementNode
* elseBlock
) JSC_FAST_CALL
1796 : IfNode(globalData
, condition
, ifBlock
)
1797 , m_elseBlock(elseBlock
)
1801 virtual ~IfElseNode();
1802 virtual void releaseNodes(NodeReleaser
&);
1804 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1807 RefPtr
<StatementNode
> m_elseBlock
;
1810 class DoWhileNode
: public StatementNode
{
1812 DoWhileNode(JSGlobalData
* globalData
, StatementNode
* statement
, ExpressionNode
* expr
) JSC_FAST_CALL
1813 : StatementNode(globalData
)
1814 , m_statement(statement
)
1819 virtual ~DoWhileNode();
1820 virtual void releaseNodes(NodeReleaser
&);
1822 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1824 virtual bool isLoop() const JSC_FAST_CALL
{ return true; }
1827 RefPtr
<StatementNode
> m_statement
;
1828 RefPtr
<ExpressionNode
> m_expr
;
1831 class WhileNode
: public StatementNode
{
1833 WhileNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, StatementNode
* statement
) JSC_FAST_CALL
1834 : StatementNode(globalData
)
1836 , m_statement(statement
)
1840 virtual ~WhileNode();
1841 virtual void releaseNodes(NodeReleaser
&);
1843 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1845 virtual bool isLoop() const JSC_FAST_CALL
{ return true; }
1848 RefPtr
<ExpressionNode
> m_expr
;
1849 RefPtr
<StatementNode
> m_statement
;
1852 class ForNode
: public StatementNode
{
1854 ForNode(JSGlobalData
* globalData
, ExpressionNode
* expr1
, ExpressionNode
* expr2
, ExpressionNode
* expr3
, StatementNode
* statement
, bool expr1WasVarDecl
) JSC_FAST_CALL
1855 : StatementNode(globalData
)
1859 , m_statement(statement
)
1860 , m_expr1WasVarDecl(expr1
&& expr1WasVarDecl
)
1866 virtual void releaseNodes(NodeReleaser
&);
1868 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1870 virtual bool isLoop() const JSC_FAST_CALL
{ return true; }
1873 RefPtr
<ExpressionNode
> m_expr1
;
1874 RefPtr
<ExpressionNode
> m_expr2
;
1875 RefPtr
<ExpressionNode
> m_expr3
;
1876 RefPtr
<StatementNode
> m_statement
;
1877 bool m_expr1WasVarDecl
;
1880 class ForInNode
: public StatementNode
, public ThrowableExpressionData
{
1882 ForInNode(JSGlobalData
*, ExpressionNode
*, ExpressionNode
*, StatementNode
*) JSC_FAST_CALL
;
1883 ForInNode(JSGlobalData
*, const Identifier
&, ExpressionNode
*, ExpressionNode
*, StatementNode
*, int divot
, int startOffset
, int endOffset
) JSC_FAST_CALL
;
1885 virtual ~ForInNode();
1886 virtual void releaseNodes(NodeReleaser
&);
1888 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1890 virtual bool isLoop() const JSC_FAST_CALL
{ return true; }
1894 RefPtr
<ExpressionNode
> m_init
;
1895 RefPtr
<ExpressionNode
> m_lexpr
;
1896 RefPtr
<ExpressionNode
> m_expr
;
1897 RefPtr
<StatementNode
> m_statement
;
1898 bool m_identIsVarDecl
;
1901 class ContinueNode
: public StatementNode
, public ThrowableExpressionData
{
1903 ContinueNode(JSGlobalData
* globalData
) JSC_FAST_CALL
1904 : StatementNode(globalData
)
1908 ContinueNode(JSGlobalData
* globalData
, const Identifier
& ident
) JSC_FAST_CALL
1909 : StatementNode(globalData
)
1914 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1920 class BreakNode
: public StatementNode
, public ThrowableExpressionData
{
1922 BreakNode(JSGlobalData
* globalData
) JSC_FAST_CALL
1923 : StatementNode(globalData
)
1927 BreakNode(JSGlobalData
* globalData
, const Identifier
& ident
) JSC_FAST_CALL
1928 : StatementNode(globalData
)
1933 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1939 class ReturnNode
: public StatementNode
, public ThrowableExpressionData
{
1941 ReturnNode(JSGlobalData
* globalData
, ExpressionNode
* value
) JSC_FAST_CALL
1942 : StatementNode(globalData
)
1947 virtual ~ReturnNode();
1948 virtual void releaseNodes(NodeReleaser
&);
1950 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1951 virtual bool isReturnNode() const JSC_FAST_CALL
{ return true; }
1954 RefPtr
<ExpressionNode
> m_value
;
1957 class WithNode
: public StatementNode
{
1959 WithNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, StatementNode
* statement
, uint32_t divot
, uint32_t expressionLength
) JSC_FAST_CALL
1960 : StatementNode(globalData
)
1962 , m_statement(statement
)
1964 , m_expressionLength(expressionLength
)
1968 virtual ~WithNode();
1969 virtual void releaseNodes(NodeReleaser
&);
1971 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1974 RefPtr
<ExpressionNode
> m_expr
;
1975 RefPtr
<StatementNode
> m_statement
;
1977 uint32_t m_expressionLength
;
1980 class LabelNode
: public StatementNode
, public ThrowableExpressionData
{
1982 LabelNode(JSGlobalData
* globalData
, const Identifier
& name
, StatementNode
* statement
) JSC_FAST_CALL
1983 : StatementNode(globalData
)
1985 , m_statement(statement
)
1989 virtual ~LabelNode();
1990 virtual void releaseNodes(NodeReleaser
&);
1992 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
1996 RefPtr
<StatementNode
> m_statement
;
1999 class ThrowNode
: public StatementNode
, public ThrowableExpressionData
{
2001 ThrowNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
2002 : StatementNode(globalData
)
2007 virtual ~ThrowNode();
2008 virtual void releaseNodes(NodeReleaser
&);
2010 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
2013 RefPtr
<ExpressionNode
> m_expr
;
2016 class TryNode
: public StatementNode
{
2018 TryNode(JSGlobalData
* globalData
, StatementNode
* tryBlock
, const Identifier
& exceptionIdent
, bool catchHasEval
, StatementNode
* catchBlock
, StatementNode
* finallyBlock
) JSC_FAST_CALL
2019 : StatementNode(globalData
)
2020 , m_tryBlock(tryBlock
)
2021 , m_exceptionIdent(exceptionIdent
)
2022 , m_catchBlock(catchBlock
)
2023 , m_finallyBlock(finallyBlock
)
2024 , m_catchHasEval(catchHasEval
)
2029 virtual void releaseNodes(NodeReleaser
&);
2031 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* dst
= 0) JSC_FAST_CALL
;
2034 RefPtr
<StatementNode
> m_tryBlock
;
2035 Identifier m_exceptionIdent
;
2036 RefPtr
<StatementNode
> m_catchBlock
;
2037 RefPtr
<StatementNode
> m_finallyBlock
;
2038 bool m_catchHasEval
;
2041 class ParameterNode
: public ParserRefCounted
{
2043 ParameterNode(JSGlobalData
* globalData
, const Identifier
& ident
) JSC_FAST_CALL
2044 : ParserRefCounted(globalData
)
2049 ParameterNode(JSGlobalData
* globalData
, ParameterNode
* l
, const Identifier
& ident
) JSC_FAST_CALL
2050 : ParserRefCounted(globalData
)
2056 virtual ~ParameterNode();
2057 virtual void releaseNodes(NodeReleaser
&);
2059 const Identifier
& ident() const JSC_FAST_CALL
{ return m_ident
; }
2060 ParameterNode
* nextParam() const JSC_FAST_CALL
{ return m_next
.get(); }
2064 RefPtr
<ParameterNode
> m_next
;
2067 struct ScopeNodeData
{
2068 typedef DeclarationStacks::VarStack VarStack
;
2069 typedef DeclarationStacks::FunctionStack FunctionStack
;
2071 ScopeNodeData(SourceElements
*, VarStack
*, FunctionStack
*, int numConstants
);
2073 VarStack m_varStack
;
2074 FunctionStack m_functionStack
;
2076 StatementVector m_children
;
2081 class ScopeNode
: public StatementNode
{
2083 typedef DeclarationStacks::VarStack VarStack
;
2084 typedef DeclarationStacks::FunctionStack FunctionStack
;
2086 ScopeNode(JSGlobalData
*) JSC_FAST_CALL
;
2087 ScopeNode(JSGlobalData
*, const SourceCode
&, SourceElements
*, VarStack
*, FunctionStack
*, CodeFeatures
, int numConstants
) JSC_FAST_CALL
;
2088 virtual ~ScopeNode();
2089 virtual void releaseNodes(NodeReleaser
&);
2091 void adoptData(std::auto_ptr
<ScopeNodeData
> data
) { m_data
.adopt(data
); }
2092 ScopeNodeData
* data() const { return m_data
.get(); }
2093 void destroyData() { m_data
.clear(); }
2095 const SourceCode
& source() const { return m_source
; }
2096 const UString
& sourceURL() const JSC_FAST_CALL
{ return m_source
.provider()->url(); }
2097 intptr_t sourceID() const { return m_source
.provider()->asID(); }
2099 void setFeatures(CodeFeatures features
) { m_features
= features
; }
2100 CodeFeatures
features() { return m_features
; }
2102 bool usesEval() const { return m_features
& EvalFeature
; }
2103 bool usesArguments() const { return m_features
& ArgumentsFeature
; }
2104 void setUsesArguments() { m_features
|= ArgumentsFeature
; }
2105 bool usesThis() const { return m_features
& ThisFeature
; }
2106 bool needsActivation() const { return m_features
& (EvalFeature
| ClosureFeature
| WithFeature
| CatchFeature
); }
2108 VarStack
& varStack() { ASSERT(m_data
); return m_data
->m_varStack
; }
2109 FunctionStack
& functionStack() { ASSERT(m_data
); return m_data
->m_functionStack
; }
2111 StatementVector
& children() { ASSERT(m_data
); return m_data
->m_children
; }
2113 int neededConstants()
2116 // We may need 2 more constants than the count given by the parser,
2117 // because of the various uses of jsUndefined() and jsNull().
2118 return m_data
->m_numConstants
+ 2;
2121 virtual void mark() { }
2124 void setSource(const SourceCode
& source
) { m_source
= source
; }
2127 OwnPtr
<ScopeNodeData
> m_data
;
2128 CodeFeatures m_features
;
2129 SourceCode m_source
;
2132 class ProgramNode
: public ScopeNode
{
2134 static ProgramNode
* create(JSGlobalData
*, SourceElements
*, VarStack
*, FunctionStack
*, const SourceCode
&, CodeFeatures
, int numConstants
) JSC_FAST_CALL
;
2136 ProgramCodeBlock
& bytecode(ScopeChainNode
* scopeChain
) JSC_FAST_CALL
2139 generateBytecode(scopeChain
);
2144 ProgramNode(JSGlobalData
*, SourceElements
*, VarStack
*, FunctionStack
*, const SourceCode
&, CodeFeatures
, int numConstants
) JSC_FAST_CALL
;
2146 void generateBytecode(ScopeChainNode
*) JSC_FAST_CALL
;
2147 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
2149 OwnPtr
<ProgramCodeBlock
> m_code
;
2152 class EvalNode
: public ScopeNode
{
2154 static EvalNode
* create(JSGlobalData
*, SourceElements
*, VarStack
*, FunctionStack
*, const SourceCode
&, CodeFeatures
, int numConstants
) JSC_FAST_CALL
;
2156 EvalCodeBlock
& bytecode(ScopeChainNode
* scopeChain
) JSC_FAST_CALL
2159 generateBytecode(scopeChain
);
2163 EvalCodeBlock
& bytecodeForExceptionInfoReparse(ScopeChainNode
*, CodeBlock
*) JSC_FAST_CALL
;
2165 virtual void mark();
2168 EvalNode(JSGlobalData
*, SourceElements
*, VarStack
*, FunctionStack
*, const SourceCode
&, CodeFeatures
, int numConstants
) JSC_FAST_CALL
;
2170 void generateBytecode(ScopeChainNode
*) JSC_FAST_CALL
;
2171 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
2173 OwnPtr
<EvalCodeBlock
> m_code
;
2176 class FunctionBodyNode
: public ScopeNode
{
2179 static FunctionBodyNode
* create(JSGlobalData
*) JSC_FAST_CALL
;
2180 static FunctionBodyNode
* create(JSGlobalData
*, SourceElements
*, VarStack
*, FunctionStack
*, const SourceCode
&, CodeFeatures
, int numConstants
) JSC_FAST_CALL
;
2181 virtual ~FunctionBodyNode();
2183 const Identifier
* parameters() const JSC_FAST_CALL
{ return m_parameters
; }
2184 size_t parameterCount() const { return m_parameterCount
; }
2185 UString
paramString() const JSC_FAST_CALL
;
2186 Identifier
* copyParameters();
2188 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
2190 CodeBlock
& bytecode(ScopeChainNode
* scopeChain
) JSC_FAST_CALL
2194 generateBytecode(scopeChain
);
2198 CodeBlock
& generatedBytecode() JSC_FAST_CALL
2204 bool isGenerated() JSC_FAST_CALL
2209 virtual void mark();
2211 void finishParsing(const SourceCode
&, ParameterNode
*);
2212 void finishParsing(Identifier
* parameters
, size_t parameterCount
);
2214 UString
toSourceString() const JSC_FAST_CALL
{ return source().toString(); }
2216 // These objects are ref/deref'd a lot in the scope chain, so this is a faster ref/deref.
2217 // If the virtual machine changes so this doesn't happen as much we can change back.
2220 if (++m_refCount
== 1)
2230 CodeBlock
& bytecodeForExceptionInfoReparse(ScopeChainNode
*, CodeBlock
*) JSC_FAST_CALL
;
2233 FunctionBodyNode(JSGlobalData
*) JSC_FAST_CALL
;
2234 FunctionBodyNode(JSGlobalData
*, SourceElements
*, VarStack
*, FunctionStack
*, const SourceCode
&, CodeFeatures
, int numConstants
) JSC_FAST_CALL
;
2236 void generateBytecode(ScopeChainNode
*) JSC_FAST_CALL
;
2238 Identifier
* m_parameters
;
2239 size_t m_parameterCount
;
2240 OwnPtr
<CodeBlock
> m_code
;
2241 unsigned m_refCount
;
2244 class FuncExprNode
: public ExpressionNode
{
2246 FuncExprNode(JSGlobalData
* globalData
, const Identifier
& ident
, FunctionBodyNode
* body
, const SourceCode
& source
, ParameterNode
* parameter
= 0) JSC_FAST_CALL
2247 : ExpressionNode(globalData
)
2249 , m_parameter(parameter
)
2252 m_body
->finishParsing(source
, m_parameter
.get());
2255 virtual ~FuncExprNode();
2256 virtual void releaseNodes(NodeReleaser
&);
2258 virtual bool isFuncExprNode() const JSC_FAST_CALL
{ return true; }
2260 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
2261 JSFunction
* makeFunction(ExecState
*, ScopeChainNode
*) JSC_FAST_CALL
;
2263 FunctionBodyNode
* body() { return m_body
.get(); }
2267 RefPtr
<ParameterNode
> m_parameter
;
2268 RefPtr
<FunctionBodyNode
> m_body
;
2271 class FuncDeclNode
: public StatementNode
{
2273 FuncDeclNode(JSGlobalData
* globalData
, const Identifier
& ident
, FunctionBodyNode
* body
, const SourceCode
& source
, ParameterNode
* parameter
= 0) JSC_FAST_CALL
2274 : StatementNode(globalData
)
2276 , m_parameter(parameter
)
2279 m_body
->finishParsing(source
, m_parameter
.get());
2282 virtual ~FuncDeclNode();
2283 virtual void releaseNodes(NodeReleaser
&);
2285 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
2287 JSFunction
* makeFunction(ExecState
*, ScopeChainNode
*) JSC_FAST_CALL
;
2291 FunctionBodyNode
* body() { return m_body
.get(); }
2294 RefPtr
<ParameterNode
> m_parameter
;
2295 RefPtr
<FunctionBodyNode
> m_body
;
2298 class CaseClauseNode
: public ParserRefCounted
{
2300 CaseClauseNode(JSGlobalData
* globalData
, ExpressionNode
* expr
) JSC_FAST_CALL
2301 : ParserRefCounted(globalData
)
2306 CaseClauseNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, SourceElements
* children
) JSC_FAST_CALL
2307 : ParserRefCounted(globalData
)
2311 children
->releaseContentsIntoVector(m_children
);
2314 virtual ~CaseClauseNode();
2315 virtual void releaseNodes(NodeReleaser
&);
2317 ExpressionNode
* expr() const { return m_expr
.get(); }
2318 StatementVector
& children() { return m_children
; }
2321 RefPtr
<ExpressionNode
> m_expr
;
2322 StatementVector m_children
;
2325 class ClauseListNode
: public ParserRefCounted
{
2327 ClauseListNode(JSGlobalData
* globalData
, CaseClauseNode
* clause
) JSC_FAST_CALL
2328 : ParserRefCounted(globalData
)
2333 ClauseListNode(JSGlobalData
* globalData
, ClauseListNode
* clauseList
, CaseClauseNode
* clause
) JSC_FAST_CALL
2334 : ParserRefCounted(globalData
)
2337 clauseList
->m_next
= this;
2340 virtual ~ClauseListNode();
2341 virtual void releaseNodes(NodeReleaser
&);
2343 CaseClauseNode
* getClause() const JSC_FAST_CALL
{ return m_clause
.get(); }
2344 ClauseListNode
* getNext() const JSC_FAST_CALL
{ return m_next
.get(); }
2347 RefPtr
<CaseClauseNode
> m_clause
;
2348 RefPtr
<ClauseListNode
> m_next
;
2351 class CaseBlockNode
: public ParserRefCounted
{
2353 CaseBlockNode(JSGlobalData
* globalData
, ClauseListNode
* list1
, CaseClauseNode
* defaultClause
, ClauseListNode
* list2
) JSC_FAST_CALL
2354 : ParserRefCounted(globalData
)
2356 , m_defaultClause(defaultClause
)
2361 virtual ~CaseBlockNode();
2362 virtual void releaseNodes(NodeReleaser
&);
2364 RegisterID
* emitBytecodeForBlock(BytecodeGenerator
&, RegisterID
* input
, RegisterID
* dst
= 0) JSC_FAST_CALL
;
2367 SwitchInfo::SwitchType
tryOptimizedSwitch(Vector
<ExpressionNode
*, 8>& literalVector
, int32_t& min_num
, int32_t& max_num
);
2368 RefPtr
<ClauseListNode
> m_list1
;
2369 RefPtr
<CaseClauseNode
> m_defaultClause
;
2370 RefPtr
<ClauseListNode
> m_list2
;
2373 class SwitchNode
: public StatementNode
{
2375 SwitchNode(JSGlobalData
* globalData
, ExpressionNode
* expr
, CaseBlockNode
* block
) JSC_FAST_CALL
2376 : StatementNode(globalData
)
2382 virtual ~SwitchNode();
2383 virtual void releaseNodes(NodeReleaser
&);
2385 virtual RegisterID
* emitBytecode(BytecodeGenerator
&, RegisterID
* = 0) JSC_FAST_CALL
;
2388 RefPtr
<ExpressionNode
> m_expr
;
2389 RefPtr
<CaseBlockNode
> m_block
;
2392 struct ElementList
{
2397 struct PropertyList
{
2398 PropertyListNode
* head
;
2399 PropertyListNode
* tail
;
2402 struct ArgumentList
{
2403 ArgumentListNode
* head
;
2404 ArgumentListNode
* tail
;
2407 struct ConstDeclList
{
2408 ConstDeclNode
* head
;
2409 ConstDeclNode
* tail
;
2412 struct ParameterList
{
2413 ParameterNode
* head
;
2414 ParameterNode
* tail
;
2418 ClauseListNode
* head
;
2419 ClauseListNode
* tail
;