Changeset 63267 in webkit for trunk/JavaScriptCore/parser/Parser.h
- Timestamp:
- Jul 13, 2010, 5:27:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/Parser.h
r47902 r63267 25 25 26 26 #include "Debugger.h" 27 #include "ExceptionHelpers.h" 27 28 #include "Executable.h" 28 29 #include "JSGlobalObject.h" … … 39 40 40 41 class FunctionBodyNode; 42 41 43 class ProgramNode; 42 44 class UString; … … 47 49 public: 48 50 template <class ParsedNode> 49 PassRefPtr<ParsedNode> parse(JSGlobalData* globalData, Debugger*, ExecState*, const SourceCode& source, int* errLine = 0, UString* errMsg = 0);51 PassRefPtr<ParsedNode> parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger*, ExecState*, const SourceCode& source, JSObject** exception); 50 52 51 53 void didFinishParsing(SourceElements*, ParserArenaData<DeclarationStacks::VarStack>*, … … 56 58 private: 57 59 void parse(JSGlobalData*, int* errLine, UString* errMsg); 60 61 // Used to determine type of error to report. 62 bool isFunctionBodyNode(ScopeNode*) { return false; } 63 bool isFunctionBodyNode(FunctionBodyNode*) { return true; } 58 64 59 65 ParserArena m_arena; … … 68 74 69 75 template <class ParsedNode> 70 PassRefPtr<ParsedNode> Parser::parse(JSGlobalData* globalData, Debugger* debugger, ExecState* debuggerExecState, const SourceCode& source, int* errLine, UString* errMsg)76 PassRefPtr<ParsedNode> Parser::parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger* debugger, ExecState* debuggerExecState, const SourceCode& source, JSObject** exception) 71 77 { 78 ASSERT(exception && !*exception); 79 int errLine; 80 UString errMsg; 81 72 82 m_source = &source; 73 83 if (ParsedNode::scopeIsFunction) 74 84 globalData->lexer->setIsReparsing(); 75 parse(globalData, errLine,errMsg);85 parse(globalData, &errLine, &errMsg); 76 86 77 87 RefPtr<ParsedNode> result; … … 85 95 m_numConstants); 86 96 result->setLoc(m_source->firstLine(), m_lastLine); 97 } else if (lexicalGlobalObject) { 98 // We can never see a syntax error when reparsing a function, since we should have 99 // reported the error when parsing the containing program or eval code. So if we're 100 // parsing a function body node, we assume that what actually happened here is that 101 // we ran out of stack while parsing. If we see an error while parsing eval or program 102 // code we assume that it was a syntax error since running out of stack is much less 103 // likely, and we are currently unable to distinguish between the two cases. 104 if (isFunctionBodyNode(static_cast<ParsedNode*>(0))) 105 *exception = createStackOverflowError(lexicalGlobalObject); 106 else 107 *exception = addErrorInfo(globalData, createSyntaxError(lexicalGlobalObject, errMsg), errLine, source); 87 108 } 88 109 … … 95 116 96 117 if (debugger && !ParsedNode::scopeIsFunction) 97 debugger->sourceParsed(debuggerExecState, source, *errLine, *errMsg);118 debugger->sourceParsed(debuggerExecState, source, errLine, errMsg); 98 119 return result.release(); 99 120 }
Note:
See TracChangeset
for help on using the changeset viewer.