Changeset 47304 in webkit for trunk/JavaScriptCore/parser/Parser.h
- Timestamp:
- Aug 14, 2009, 6:14:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/Parser.h
r45891 r47304 25 25 26 26 #include "Debugger.h" 27 #include "Executable.h" 27 28 #include "Nodes.h" 28 29 #include "SourceProvider.h" … … 42 43 class Parser : public Noncopyable { 43 44 public: 44 template <class ParsedNode> PassRefPtr<ParsedNode> parse(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0); 45 template <class ParsedNode> PassRefPtr<ParsedNode> reparse(JSGlobalData*, ParsedNode*); 45 template <class ParsedNode> 46 PassRefPtr<ParsedNode> parse(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0); 47 template <class ParsedNode> 48 PassRefPtr<ParsedNode> reparse(JSGlobalData*, ParsedNode*); 46 49 void reparseInPlace(JSGlobalData*, FunctionBodyNode*); 50 PassRefPtr<FunctionBodyNode> parseFunctionFromGlobalCode(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0); 47 51 48 52 void didFinishParsing(SourceElements*, ParserArenaData<DeclarationStacks::VarStack>*, … … 64 68 }; 65 69 66 template <class ParsedNode> PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg) 70 template <class ParsedNode> 71 PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg) 67 72 { 68 73 m_source = &source; … … 91 96 } 92 97 93 template <class ParsedNode> PassRefPtr<ParsedNode> Parser::reparse(JSGlobalData* globalData, ParsedNode* oldParsedNode) 98 template <class ParsedNode> 99 PassRefPtr<ParsedNode> Parser::reparse(JSGlobalData* globalData, ParsedNode* oldParsedNode) 94 100 { 95 101 m_source = &oldParsedNode->source(); … … 116 122 } 117 123 124 inline PassRefPtr<FunctionBodyNode> Parser::parseFunctionFromGlobalCode(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg) 125 { 126 RefPtr<ProgramNode> program = parse<ProgramNode>(exec, debugger, source, errLine, errMsg); 127 128 if (!program) 129 return 0; 130 131 StatementVector& children = program->children(); 132 if (children.size() != 1) 133 return 0; 134 135 StatementNode* exprStatement = children[0]; 136 ASSERT(exprStatement); 137 ASSERT(exprStatement->isExprStatement()); 138 if (!exprStatement || !exprStatement->isExprStatement()) 139 return 0; 140 141 ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr(); 142 ASSERT(funcExpr); 143 ASSERT(funcExpr->isFuncExprNode()); 144 if (!funcExpr || !funcExpr->isFuncExprNode()) 145 return 0; 146 147 RefPtr<FunctionBodyNode> body = static_cast<FuncExprNode*>(funcExpr)->body(); 148 ASSERT(body); 149 return body.release(); 150 } 151 152 template<class ASTNodeType, class CodeBlockType> 153 inline JSObject* TemplateExecutable<ASTNodeType, CodeBlockType>::parse(ExecState* exec, bool allowDebug) 154 { 155 int errLine; 156 UString errMsg; 157 m_node = exec->globalData().parser->parse<ASTNodeType>(exec, allowDebug ? exec->dynamicGlobalObject()->debugger() : 0, m_source, &errLine, &errMsg); 158 159 if (!m_node) 160 return Error::create(exec, SyntaxError, errMsg, errLine, m_source.provider()->asID(), m_source.provider()->url()); 161 return 0; 162 } 163 118 164 } // namespace JSC 119 165
Note:
See TracChangeset
for help on using the changeset viewer.