diff options
Diffstat (limited to 'src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h')
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h | 375 |
1 files changed, 117 insertions, 258 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h b/src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h index 185cedeee2..2f8d850116 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h @@ -34,25 +34,17 @@ #include "SourceCode.h" #include "SymbolTable.h" #include <wtf/MathExtras.h> -#include <wtf/OwnPtr.h> - -#ifdef QT_BUILD_SCRIPT_LIB -#include "SourcePoolQt.h" -#endif namespace JSC { class ArgumentListNode; - class CodeBlock; class BytecodeGenerator; - class FuncDeclNode; - class EvalCodeBlock; - class JSFunction; - class ProgramCodeBlock; + class FunctionBodyNode; class PropertyListNode; class ReadModifyResolveNode; class RegisterID; class ScopeChainNode; + class ScopeNode; typedef unsigned CodeFeatures; @@ -90,8 +82,8 @@ namespace JSC { namespace DeclarationStacks { enum VarAttrs { IsConstant = 1, HasInitializer = 2 }; - typedef Vector<std::pair<Identifier, unsigned> > VarStack; - typedef Vector<FuncDeclNode*> FunctionStack; + typedef Vector<std::pair<const Identifier*, unsigned> > VarStack; + typedef Vector<FunctionBodyNode*> FunctionStack; } struct SwitchInfo { @@ -100,24 +92,23 @@ namespace JSC { SwitchType switchType; }; - class ParserArenaDeletable { - protected: - ParserArenaDeletable() { } + class ParserArenaFreeable { + public: + // ParserArenaFreeable objects are are freed when the arena is deleted. + // Destructors are not called. Clients must not call delete on such objects. + void* operator new(size_t, JSGlobalData*); + }; + class ParserArenaDeletable { public: virtual ~ParserArenaDeletable() { } - // Objects created with this version of new are deleted when the arena is deleted. + // ParserArenaDeletable objects are deleted when the arena is deleted. + // Clients must not call delete directly on such objects. void* operator new(size_t, JSGlobalData*); - - // Objects created with this version of new are not deleted when the arena is deleted. - // Other arrangements must be made. - void* operator new(size_t); - - void operator delete(void*); }; - class ParserArenaRefCounted : public RefCountedCustomAllocated<ParserArenaRefCounted> { + class ParserArenaRefCounted : public RefCounted<ParserArenaRefCounted> { protected: ParserArenaRefCounted(JSGlobalData*); @@ -128,34 +119,14 @@ namespace JSC { } }; - class Node : public ParserArenaDeletable { + class Node : public ParserArenaFreeable { protected: Node(JSGlobalData*); public: - /* - Return value: The register holding the production's value. - dst: An optional parameter specifying the most efficient - destination at which to store the production's value. - The callee must honor dst. - - dst provides for a crude form of copy propagation. For example, + virtual ~Node() { } - x = 1 - - becomes - - load r[x], 1 - - instead of - - load r0, 1 - mov r[x], r0 - - because the assignment node, "x =", passes r[x] as dst to the number - node, "1". - */ - virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* dst = 0) = 0; + virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* destination = 0) = 0; int lineNo() const { return m_line; } @@ -164,9 +135,10 @@ namespace JSC { }; class ExpressionNode : public Node { - public: + protected: ExpressionNode(JSGlobalData*, ResultType = ResultType::unknownType()); + public: virtual bool isNumber() const { return false; } virtual bool isString() const { return false; } virtual bool isNull() const { return false; } @@ -184,18 +156,16 @@ namespace JSC { ResultType resultDescriptor() const { return m_resultType; } - // This needs to be in public in order to compile using GCC 3.x - typedef enum { EvalOperator, FunctionCall } CallerType; - private: ResultType m_resultType; }; class StatementNode : public Node { - public: + protected: StatementNode(JSGlobalData*); - void setLoc(int line0, int line1, int column); + public: + void setLoc(int firstLine, int lastLine, int column); int firstLine() const { return lineNo(); } int lastLine() const { return m_lastLine; } int column() const { return m_column; } @@ -235,10 +205,10 @@ namespace JSC { class NumberNode : public ExpressionNode { public: - NumberNode(JSGlobalData*, double v); + NumberNode(JSGlobalData*, double value); - double value() const { return m_double; } - void setValue(double d) { m_double = d; } + double value() const { return m_value; } + void setValue(double value) { m_value = value; } private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); @@ -246,22 +216,23 @@ namespace JSC { virtual bool isNumber() const { return true; } virtual bool isPure(BytecodeGenerator&) const { return true; } - double m_double; + double m_value; }; class StringNode : public ExpressionNode { public: - StringNode(JSGlobalData*, const Identifier& v); + StringNode(JSGlobalData*, const Identifier&); const Identifier& value() { return m_value; } - virtual bool isPure(BytecodeGenerator&) const { return true; } private: + virtual bool isPure(BytecodeGenerator&) const { return true; } + virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); virtual bool isString() const { return true; } - Identifier m_value; + const Identifier& m_value; }; class ThrowableExpressionData { @@ -292,8 +263,9 @@ namespace JSC { uint16_t endOffset() const { return m_endOffset; } protected: - RegisterID* emitThrowError(BytecodeGenerator&, ErrorType, const char* msg); - RegisterID* emitThrowError(BytecodeGenerator&, ErrorType, const char* msg, const Identifier&); + RegisterID* emitThrowError(BytecodeGenerator&, ErrorType, const char* message); + RegisterID* emitThrowError(BytecodeGenerator&, ErrorType, const char* message, const UString&); + RegisterID* emitThrowError(BytecodeGenerator&, ErrorType, const char* message, const Identifier&); private: uint32_t m_divot; @@ -304,8 +276,7 @@ namespace JSC { class ThrowableSubExpressionData : public ThrowableExpressionData { public: ThrowableSubExpressionData() - : ThrowableExpressionData() - , m_subexpressionDivotOffset(0) + : m_subexpressionDivotOffset(0) , m_subexpressionEndOffset(0) { } @@ -334,8 +305,7 @@ namespace JSC { class ThrowablePrefixedSubExpressionData : public ThrowableExpressionData { public: ThrowablePrefixedSubExpressionData() - : ThrowableExpressionData() - , m_subexpressionDivotOffset(0) + : m_subexpressionDivotOffset(0) , m_subexpressionStartOffset(0) { } @@ -363,13 +333,13 @@ namespace JSC { class RegExpNode : public ExpressionNode, public ThrowableExpressionData { public: - RegExpNode(JSGlobalData*, const UString& pattern, const UString& flags); + RegExpNode(JSGlobalData*, const Identifier& pattern, const Identifier& flags); private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - UString m_pattern; - UString m_flags; + const Identifier& m_pattern; + const Identifier& m_flags; }; class ThisNode : public ExpressionNode { @@ -393,11 +363,11 @@ namespace JSC { virtual bool isLocation() const { return true; } virtual bool isResolveNode() const { return true; } - Identifier m_ident; + const Identifier& m_ident; int32_t m_startOffset; }; - class ElementNode : public ParserArenaDeletable { + class ElementNode : public ParserArenaFreeable { public: ElementNode(JSGlobalData*, int elision, ExpressionNode*); ElementNode(JSGlobalData*, ElementNode*, int elision, ExpressionNode*); @@ -430,17 +400,18 @@ namespace JSC { bool m_optional; }; - class PropertyNode : public ParserArenaDeletable { + class PropertyNode : public ParserArenaFreeable { public: enum Type { Constant, Getter, Setter }; PropertyNode(JSGlobalData*, const Identifier& name, ExpressionNode* value, Type); + PropertyNode(JSGlobalData*, double name, ExpressionNode* value, Type); const Identifier& name() const { return m_name; } private: friend class PropertyListNode; - Identifier m_name; + const Identifier& m_name; ExpressionNode* m_assign; Type m_type; }; @@ -500,7 +471,7 @@ namespace JSC { virtual bool isDotAccessorNode() const { return true; } ExpressionNode* m_base; - Identifier m_ident; + const Identifier& m_ident; }; class ArgumentListNode : public Node { @@ -515,7 +486,7 @@ namespace JSC { virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); }; - class ArgumentsNode : public ParserArenaDeletable { + class ArgumentsNode : public ParserArenaFreeable { public: ArgumentsNode(JSGlobalData*); ArgumentsNode(JSGlobalData*, ArgumentListNode*); @@ -563,7 +534,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; ArgumentsNode* m_args; size_t m_index; // Used by LocalVarFunctionCallNode. size_t m_scopeDepth; // Used by ScopedVarFunctionCallNode and NonLocalVarFunctionCallNode @@ -590,7 +561,7 @@ namespace JSC { protected: ExpressionNode* m_base; - const Identifier m_ident; + const Identifier& m_ident; ArgumentsNode* m_args; }; @@ -615,7 +586,7 @@ namespace JSC { PrePostResolveNode(JSGlobalData*, const Identifier&, unsigned divot, unsigned startOffset, unsigned endOffset); protected: - const Identifier m_ident; + const Identifier& m_ident; }; class PostfixResolveNode : public PrePostResolveNode { @@ -648,7 +619,7 @@ namespace JSC { virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); ExpressionNode* m_base; - Identifier m_ident; + const Identifier& m_ident; Operator m_operator; }; @@ -670,7 +641,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; }; class DeleteBracketNode : public ExpressionNode, public ThrowableExpressionData { @@ -692,7 +663,7 @@ namespace JSC { virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); ExpressionNode* m_base; - Identifier m_ident; + const Identifier& m_ident; }; class DeleteValueNode : public ExpressionNode { @@ -724,7 +695,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; }; class TypeOfValueNode : public ExpressionNode { @@ -767,7 +738,7 @@ namespace JSC { virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); ExpressionNode* m_base; - Identifier m_ident; + const Identifier& m_ident; Operator m_operator; }; @@ -826,7 +797,7 @@ namespace JSC { BinaryOpNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments); BinaryOpNode(JSGlobalData*, ResultType, ExpressionNode* expr1, ExpressionNode* expr2, OpcodeID, bool rightHasAssignments); - RegisterID* emitStrcat(BytecodeGenerator& generator, RegisterID* dst, RegisterID* lhs = 0, ReadModifyResolveNode* emitExpressionInfoForMe = 0); + RegisterID* emitStrcat(BytecodeGenerator& generator, RegisterID* destination, RegisterID* lhs = 0, ReadModifyResolveNode* emitExpressionInfoForMe = 0); private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); @@ -1009,7 +980,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; ExpressionNode* m_right; size_t m_index; // Used by ReadModifyLocalVarNode. Operator m_operator; @@ -1023,7 +994,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; ExpressionNode* m_right; size_t m_index; // Used by ReadModifyLocalVarNode. bool m_rightHasAssignments; @@ -1066,7 +1037,7 @@ namespace JSC { virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); ExpressionNode* m_base; - Identifier m_ident; + const Identifier& m_ident; ExpressionNode* m_right; bool m_rightHasAssignments; }; @@ -1079,7 +1050,7 @@ namespace JSC { virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); ExpressionNode* m_base; - Identifier m_ident; + const Identifier& m_ident; ExpressionNode* m_right; Operator m_operator : 31; bool m_rightHasAssignments : 1; @@ -1099,10 +1070,12 @@ namespace JSC { typedef Vector<ExpressionNode*, 8> ExpressionVector; - class CommaNode : public ExpressionNode { + class CommaNode : public ExpressionNode, public ParserArenaDeletable { public: CommaNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2); + using ParserArenaDeletable::operator new; + void append(ExpressionNode* expr) { m_expressions.append(expr); } private: @@ -1123,7 +1096,7 @@ namespace JSC { virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); virtual RegisterID* emitCodeSingle(BytecodeGenerator&); - Identifier m_ident; + const Identifier& m_ident; public: ConstDeclNode* m_next; @@ -1142,36 +1115,33 @@ namespace JSC { ConstDeclNode* m_next; }; - typedef Vector<StatementNode*> StatementVector; - class SourceElements : public ParserArenaDeletable { public: SourceElements(JSGlobalData*); void append(StatementNode*); - void releaseContentsIntoVector(StatementVector& destination) - { - ASSERT(destination.isEmpty()); - m_statements.swap(destination); - destination.shrinkToFit(); - } + + StatementNode* singleStatement() const; + StatementNode* lastStatement() const; + + void emitBytecode(BytecodeGenerator&, RegisterID* destination); private: - StatementVector m_statements; + Vector<StatementNode*> m_statements; }; class BlockNode : public StatementNode { public: - BlockNode(JSGlobalData*, SourceElements* children); + BlockNode(JSGlobalData*, SourceElements* = 0); - StatementVector& children() { return m_children; } + StatementNode* lastStatement() const; private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); virtual bool isBlock() const { return true; } - StatementVector m_children; + SourceElements* m_statements; }; class EmptyStatementNode : public StatementNode { @@ -1281,7 +1251,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; ExpressionNode* m_init; ExpressionNode* m_lexpr; ExpressionNode* m_expr; @@ -1297,7 +1267,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; }; class BreakNode : public StatementNode, public ThrowableExpressionData { @@ -1308,7 +1278,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_ident; + const Identifier& m_ident; }; class ReturnNode : public StatementNode, public ThrowableExpressionData { @@ -1343,7 +1313,7 @@ namespace JSC { private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - Identifier m_name; + const Identifier& m_name; StatementNode* m_statement; }; @@ -1362,16 +1332,16 @@ namespace JSC { TryNode(JSGlobalData*, StatementNode* tryBlock, const Identifier& exceptionIdent, bool catchHasEval, StatementNode* catchBlock, StatementNode* finallyBlock); private: - virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* dst = 0); + virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); StatementNode* m_tryBlock; - Identifier m_exceptionIdent; + const Identifier& m_exceptionIdent; StatementNode* m_catchBlock; StatementNode* m_finallyBlock; bool m_catchHasEval; }; - class ParameterNode : public ParserArenaDeletable { + class ParameterNode : public ParserArenaFreeable { public: ParameterNode(JSGlobalData*, const Identifier&); ParameterNode(JSGlobalData*, ParameterNode*, const Identifier&); @@ -1380,11 +1350,11 @@ namespace JSC { ParameterNode* nextParam() const { return m_next; } private: - Identifier m_ident; + const Identifier& m_ident; ParameterNode* m_next; }; - struct ScopeNodeData { + struct ScopeNodeData : FastAllocBase { typedef DeclarationStacks::VarStack VarStack; typedef DeclarationStacks::FunctionStack FunctionStack; @@ -1394,9 +1364,7 @@ namespace JSC { VarStack m_varStack; FunctionStack m_functionStack; int m_numConstants; - StatementVector m_children; - - void mark(); + SourceElements* m_statements; }; class ScopeNode : public StatementNode, public ParserArenaRefCounted { @@ -1407,6 +1375,8 @@ namespace JSC { ScopeNode(JSGlobalData*); ScopeNode(JSGlobalData*, const SourceCode&, SourceElements*, VarStack*, FunctionStack*, CodeFeatures, int numConstants); + using ParserArenaRefCounted::operator new; + void adoptData(std::auto_ptr<ScopeNodeData> data) { ASSERT(!data->m_arena.contains(this)); @@ -1432,8 +1402,6 @@ namespace JSC { VarStack& varStack() { ASSERT(m_data); return m_data->m_varStack; } FunctionStack& functionStack() { ASSERT(m_data); return m_data->m_functionStack; } - StatementVector& children() { ASSERT(m_data); return m_data->m_children; } - int neededConstants() { ASSERT(m_data); @@ -1442,33 +1410,13 @@ namespace JSC { return m_data->m_numConstants + 2; } - virtual void mark() { } + StatementNode* singleStatement() const; -#if ENABLE(JIT) - JITCode& generatedJITCode() - { - ASSERT(m_jitCode); - return m_jitCode; - } - - ExecutablePool* getExecutablePool() - { - return m_jitCode.getExecutablePool(); - } - - void setJITCode(const JITCode jitCode) - { - m_jitCode = jitCode; - } -#endif + void emitStatementsBytecode(BytecodeGenerator&, RegisterID* destination); protected: void setSource(const SourceCode& source) { m_source = source; } -#if ENABLE(JIT) - JITCode m_jitCode; -#endif - private: OwnPtr<ScopeNodeData> m_data; CodeFeatures m_features; @@ -1479,190 +1427,101 @@ namespace JSC { public: static PassRefPtr<ProgramNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); - ProgramCodeBlock& bytecode(ScopeChainNode* scopeChain) - { - if (!m_code) - generateBytecode(scopeChain); - return *m_code; - } - -#if ENABLE(JIT) - JITCode& jitCode(ScopeChainNode* scopeChain) - { - if (!m_jitCode) - generateJITCode(scopeChain); - return m_jitCode; - } -#endif + static const bool scopeIsFunction = false; private: ProgramNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); - void generateBytecode(ScopeChainNode*); virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - -#if ENABLE(JIT) - void generateJITCode(ScopeChainNode*); -#endif - - OwnPtr<ProgramCodeBlock> m_code; }; class EvalNode : public ScopeNode { public: static PassRefPtr<EvalNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); - EvalCodeBlock& bytecode(ScopeChainNode* scopeChain) - { - if (!m_code) - generateBytecode(scopeChain); - return *m_code; - } - - EvalCodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*); - - virtual void mark(); - -#if ENABLE(JIT) - JITCode& jitCode(ScopeChainNode* scopeChain) - { - if (!m_jitCode) - generateJITCode(scopeChain); - return m_jitCode; - } -#endif + static const bool scopeIsFunction = false; private: EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); - void generateBytecode(ScopeChainNode*); virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); + }; -#if ENABLE(JIT) - void generateJITCode(ScopeChainNode*); -#endif - - OwnPtr<EvalCodeBlock> m_code; + class FunctionParameters : public Vector<Identifier>, public RefCounted<FunctionParameters> { + public: + static PassRefPtr<FunctionParameters> create(ParameterNode* firstParameter) { return adoptRef(new FunctionParameters(firstParameter)); } + + private: + FunctionParameters(ParameterNode*); }; class FunctionBodyNode : public ScopeNode { - friend class JIT; public: -#if ENABLE(JIT) - static PassRefPtr<FunctionBodyNode> createNativeThunk(JSGlobalData*); -#endif static FunctionBodyNode* create(JSGlobalData*); static PassRefPtr<FunctionBodyNode> create(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); + virtual ~FunctionBodyNode(); - const Identifier* parameters() const { return m_parameters; } - size_t parameterCount() const { return m_parameterCount; } - UString paramString() const ; - Identifier* copyParameters(); + FunctionParameters* parameters() const { return m_parameters.get(); } + size_t parameterCount() const { return m_parameters->size(); } virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - bool isGenerated() const - { - return m_code; - } - - bool isHostFunction() const; - - virtual void mark(); - - void finishParsing(const SourceCode&, ParameterNode*); - void finishParsing(Identifier* parameters, size_t parameterCount); + void finishParsing(const SourceCode&, ParameterNode*, const Identifier&); + void finishParsing(PassRefPtr<FunctionParameters>, const Identifier&); - UString toSourceString() const { return source().toString(); } + const Identifier& ident() { return m_ident; } - CodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*); -#if ENABLE(JIT) - JITCode& jitCode(ScopeChainNode* scopeChain) - { - if (!m_jitCode) - generateJITCode(scopeChain); - return m_jitCode; - } -#endif + static const bool scopeIsFunction = true; - CodeBlock& bytecode(ScopeChainNode* scopeChain) - { - ASSERT(scopeChain); - if (!m_code) - generateBytecode(scopeChain); - return *m_code; - } - - CodeBlock& generatedBytecode() - { - ASSERT(m_code); - return *m_code; - } - private: FunctionBodyNode(JSGlobalData*); FunctionBodyNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants); - void generateBytecode(ScopeChainNode*); -#if ENABLE(JIT) - void generateJITCode(ScopeChainNode*); -#endif - Identifier* m_parameters; - size_t m_parameterCount; - OwnPtr<CodeBlock> m_code; -#ifdef QT_BUILD_SCRIPT_LIB - SourcePool::SourcePoolToken* sourceToken; -#endif + Identifier m_ident; + RefPtr<FunctionParameters> m_parameters; }; - class FuncExprNode : public ExpressionNode, public ParserArenaRefCounted { + class FuncExprNode : public ExpressionNode { public: FuncExprNode(JSGlobalData*, const Identifier&, FunctionBodyNode* body, const SourceCode& source, ParameterNode* parameter = 0); - JSFunction* makeFunction(ExecState*, ScopeChainNode*); - - FunctionBodyNode* body() { return m_body.get(); } + FunctionBodyNode* body() { return m_body; } private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); virtual bool isFuncExprNode() const { return true; } - Identifier m_ident; - RefPtr<FunctionBodyNode> m_body; + FunctionBodyNode* m_body; }; - class FuncDeclNode : public StatementNode, public ParserArenaRefCounted { + class FuncDeclNode : public StatementNode { public: FuncDeclNode(JSGlobalData*, const Identifier&, FunctionBodyNode*, const SourceCode&, ParameterNode* = 0); - JSFunction* makeFunction(ExecState*, ScopeChainNode*); - - Identifier m_ident; - - FunctionBodyNode* body() { return m_body.get(); } + FunctionBodyNode* body() { return m_body; } private: virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0); - RefPtr<FunctionBodyNode> m_body; + FunctionBodyNode* m_body; }; - class CaseClauseNode : public ParserArenaDeletable { + class CaseClauseNode : public ParserArenaFreeable { public: - CaseClauseNode(JSGlobalData*, ExpressionNode*); - CaseClauseNode(JSGlobalData*, ExpressionNode*, SourceElements*); + CaseClauseNode(JSGlobalData*, ExpressionNode*, SourceElements* = 0); ExpressionNode* expr() const { return m_expr; } - StatementVector& children() { return m_children; } + + void emitBytecode(BytecodeGenerator&, RegisterID* destination); private: ExpressionNode* m_expr; - StatementVector m_children; + SourceElements* m_statements; }; - class ClauseListNode : public ParserArenaDeletable { + class ClauseListNode : public ParserArenaFreeable { public: ClauseListNode(JSGlobalData*, CaseClauseNode*); ClauseListNode(JSGlobalData*, ClauseListNode*, CaseClauseNode*); @@ -1675,11 +1534,11 @@ namespace JSC { ClauseListNode* m_next; }; - class CaseBlockNode : public ParserArenaDeletable { + class CaseBlockNode : public ParserArenaFreeable { public: CaseBlockNode(JSGlobalData*, ClauseListNode* list1, CaseClauseNode* defaultClause, ClauseListNode* list2); - RegisterID* emitBytecodeForBlock(BytecodeGenerator&, RegisterID* input, RegisterID* dst = 0); + RegisterID* emitBytecodeForBlock(BytecodeGenerator&, RegisterID* input, RegisterID* destination); private: SwitchInfo::SwitchType tryOptimizedSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num); |