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

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

Reviewed by Geoff.

Remove more threadInstance() calls.

  • kjs/JSFunction.cpp: (KJS::JSFunction::getParameterName): (KJS::IndexToNameMap::unMap): (KJS::Arguments::deleteProperty):
  • kjs/JSFunction.h: Access nullIdentifier without going to thread specific storage.
  • JavaScriptCore.exp:
  • kjs/JSGlobalData.cpp: (KJS::JSGlobalData::JSGlobalData):
  • kjs/JSGlobalData.h:
  • kjs/Parser.cpp: (KJS::Parser::parse):
  • kjs/Parser.h: (KJS::ParserRefCountedData::ParserRefCountedData): (KJS::Parser::parse):
  • kjs/grammar.y:
  • kjs/nodes.cpp: (KJS::ParserRefCounted::ParserRefCounted): (KJS::ParserRefCounted::ref): (KJS::ParserRefCounted::deref): (KJS::ParserRefCounted::hasOneRef): (KJS::ParserRefCounted::deleteNewObjects): (KJS::Node::Node): (KJS::StatementNode::StatementNode): (KJS::BreakpointCheckStatement::BreakpointCheckStatement): (KJS::ConstDeclNode::ConstDeclNode): (KJS::BlockNode::BlockNode): (KJS::ForInNode::ForInNode): (KJS::ScopeNode::ScopeNode): (KJS::ProgramNode::ProgramNode): (KJS::ProgramNode::create): (KJS::EvalNode::EvalNode): (KJS::EvalNode::create): (KJS::FunctionBodyNode::FunctionBodyNode): (KJS::FunctionBodyNode::create):
  • kjs/nodes.h: (KJS::ExpressionNode::): (KJS::NullNode::): (KJS::BooleanNode::): (KJS::NumberNode::): (KJS::ImmediateNumberNode::): (KJS::StringNode::): (KJS::RegExpNode::): (KJS::ThisNode::): (KJS::ResolveNode::): (KJS::ElementNode::): (KJS::ArrayNode::): (KJS::PropertyNode::): (KJS::PropertyListNode::): (KJS::ObjectLiteralNode::): (KJS::BracketAccessorNode::): (KJS::DotAccessorNode::): (KJS::ArgumentListNode::): (KJS::ArgumentsNode::): (KJS::NewExprNode::): (KJS::EvalFunctionCallNode::): (KJS::FunctionCallValueNode::): (KJS::FunctionCallResolveNode::): (KJS::FunctionCallBracketNode::): (KJS::FunctionCallDotNode::): (KJS::PrePostResolveNode::): (KJS::PostIncResolveNode::): (KJS::PostDecResolveNode::): (KJS::PostfixBracketNode::): (KJS::PostIncBracketNode::): (KJS::PostDecBracketNode::): (KJS::PostfixDotNode::): (KJS::PostIncDotNode::): (KJS::PostDecDotNode::): (KJS::PostfixErrorNode::): (KJS::DeleteResolveNode::): (KJS::DeleteBracketNode::): (KJS::DeleteDotNode::): (KJS::DeleteValueNode::): (KJS::VoidNode::): (KJS::TypeOfResolveNode::): (KJS::TypeOfValueNode::): (KJS::PreIncResolveNode::): (KJS::PreDecResolveNode::): (KJS::PrefixBracketNode::): (KJS::PreIncBracketNode::): (KJS::PreDecBracketNode::): (KJS::PrefixDotNode::): (KJS::PreIncDotNode::): (KJS::PreDecDotNode::): (KJS::PrefixErrorNode::): (KJS::UnaryOpNode::UnaryOpNode): (KJS::UnaryPlusNode::): (KJS::NegateNode::): (KJS::BitwiseNotNode::): (KJS::LogicalNotNode::): (KJS::BinaryOpNode::BinaryOpNode): (KJS::ReverseBinaryOpNode::ReverseBinaryOpNode): (KJS::MultNode::): (KJS::DivNode::): (KJS::ModNode::): (KJS::AddNode::): (KJS::SubNode::): (KJS::LeftShiftNode::): (KJS::RightShiftNode::): (KJS::UnsignedRightShiftNode::): (KJS::LessNode::): (KJS::GreaterNode::): (KJS::LessEqNode::): (KJS::GreaterEqNode::): (KJS::InstanceOfNode::): (KJS::InNode::): (KJS::EqualNode::): (KJS::NotEqualNode::): (KJS::StrictEqualNode::): (KJS::NotStrictEqualNode::): (KJS::BitAndNode::): (KJS::BitOrNode::): (KJS::BitXOrNode::): (KJS::LogicalAndNode::): (KJS::LogicalOrNode::): (KJS::ConditionalNode::): (KJS::ReadModifyResolveNode::): (KJS::AssignResolveNode::): (KJS::ReadModifyBracketNode::): (KJS::AssignBracketNode::): (KJS::AssignDotNode::): (KJS::ReadModifyDotNode::): (KJS::AssignErrorNode::): (KJS::CommaNode::): (KJS::VarDeclCommaNode::): (KJS::ConstStatementNode::): (KJS::SourceElements::SourceElements): (KJS::EmptyStatementNode::): (KJS::DebuggerStatementNode::): (KJS::ExprStatementNode::): (KJS::VarStatementNode::): (KJS::IfNode::): (KJS::IfElseNode::): (KJS::DoWhileNode::): (KJS::WhileNode::): (KJS::ForNode::): (KJS::ContinueNode::): (KJS::BreakNode::): (KJS::ReturnNode::): (KJS::WithNode::): (KJS::LabelNode::): (KJS::ThrowNode::): (KJS::TryNode::): (KJS::ParameterNode::): (KJS::FuncExprNode::): (KJS::FuncDeclNode::): (KJS::CaseClauseNode::): (KJS::ClauseListNode::): (KJS::CaseBlockNode::): (KJS::SwitchNode::): Changed ParserRefCounted to hold a JSGlobalData pointer, and used it to replace threadInstance calls.
  • 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 = *exec->lexer();
65
66 if (startingLineNumber <= 0)
67 startingLineNumber = 1;
68
69 lexer.setCode(startingLineNumber, source);
70 *sourceId = ++m_sourceId;
71
72 int parseError = kjsyyparse(&exec->globalData());
73 bool lexError = lexer.sawError();
74 lexer.clear();
75
76 ParserRefCounted::deleteNewObjects(&exec->globalData());
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.