source: webkit/trunk/JavaScriptCore/kjs/Parser.cpp@ 34628

Last change on this file since 34628 was 34628, checked in by [email protected], 17 years ago

Reviewed by Tim H.

Remove bogus ASSERT which tripped every time for those who use PAC files.

  • kjs/Parser.cpp: (KJS::Parser::parse):
  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1// -*- c-basic-offset: 4 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2001 Harri Porten ([email protected])
5 * Copyright (C) 2001 Peter Kelly ([email protected])
6 * Copyright (C) 2003, 2006, 2007 Apple Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25#include "config.h"
26#include "Parser.h"
27#include "debugger.h"
28
29#include "lexer.h"
30#include <wtf/HashSet.h>
31#include <wtf/Vector.h>
32
33extern int kjsyyparse(void*);
34
35namespace KJS {
36
37Parser::Parser()
38 : m_sourceId(0)
39{
40}
41
42void Parser::parse(ExecState* exec, const UString& sourceURL, int startingLineNumber,
43 PassRefPtr<SourceProvider> prpSource,
44 int* sourceId, int* errLine, UString* errMsg)
45{
46 ASSERT(!m_sourceElements);
47
48 int defaultSourceId;
49 int defaultErrLine;
50 UString defaultErrMsg;
51
52 RefPtr<SourceProvider> source = prpSource;
53
54 if (!sourceId)
55 sourceId = &defaultSourceId;
56 if (!errLine)
57 errLine = &defaultErrLine;
58 if (!errMsg)
59 errMsg = &defaultErrMsg;
60
61 *errLine = -1;
62 *errMsg = 0;
63
64 Lexer& lexer = *JSGlobalData::threadInstance().lexer;
65
66 if (startingLineNumber <= 0)
67 startingLineNumber = 1;
68
69 lexer.setCode(startingLineNumber, source);
70 *sourceId = ++m_sourceId;
71
72 int parseError = kjsyyparse(&JSGlobalData::threadInstance());
73 bool lexError = lexer.sawError();
74 lexer.clear();
75
76 ParserRefCounted::deleteNewObjects();
77
78 if (parseError || lexError) {
79 *errLine = lexer.lineNo();
80 *errMsg = "Parse error";
81 m_sourceElements.clear();
82 }
83
84 if (Debugger* debugger = exec->dynamicGlobalObject()->debugger())
85 debugger->sourceParsed(exec, *sourceId, sourceURL, *source, startingLineNumber, *errLine, *errMsg);
86}
87
88void Parser::didFinishParsing(SourceElements* sourceElements, ParserRefCountedData<DeclarationStacks::VarStack>* varStack,
89 ParserRefCountedData<DeclarationStacks::FunctionStack>* funcStack, bool usesEval, bool needsClosure, int lastLine)
90{
91 m_sourceElements = sourceElements;
92 m_varDeclarations = varStack;
93 m_funcDeclarations = funcStack;
94 m_usesEval = usesEval;
95 m_needsClosure = needsClosure;
96 m_lastLine = lastLine;
97}
98
99} // namespace KJS
Note: See TracBrowser for help on using the repository browser.