source: webkit/trunk/JavaScriptCore/kjs/Parser.h@ 34861

Last change on this file since 34861 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: 4.0 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#ifndef Parser_h
26#define Parser_h
27
28#include "nodes.h"
29#include "SourceProvider.h"
30#include <wtf/Forward.h>
31#include <wtf/Noncopyable.h>
32#include <wtf/OwnPtr.h>
33#include <wtf/RefPtr.h>
34
35namespace KJS {
36
37 class FunctionBodyNode;
38 class ProgramNode;
39 class UString;
40
41 template <typename T> struct ParserRefCountedData : ParserRefCounted {
42 ParserRefCountedData(JSGlobalData* globalData)
43 : ParserRefCounted(globalData)
44 {
45 }
46
47 T data;
48 };
49
50 class Parser : Noncopyable {
51 public:
52 template <class ParsedNode>
53 PassRefPtr<ParsedNode> parse(ExecState*, const UString& sourceURL, int startingLineNumber,
54 PassRefPtr<SourceProvider> source,
55 int* sourceId = 0, int* errLine = 0, UString* errMsg = 0);
56
57 UString sourceURL() const { return m_sourceURL; }
58 int sourceId() const { return m_sourceId; }
59
60 void didFinishParsing(SourceElements*, ParserRefCountedData<DeclarationStacks::VarStack>*,
61 ParserRefCountedData<DeclarationStacks::FunctionStack>*, bool usesEval, bool needsClosure, int lastLine);
62
63 private:
64 friend struct JSGlobalData;
65 Parser();
66
67 void parse(ExecState*, const UString& sourceURL, int startingLineNumber, PassRefPtr<SourceProvider> source,
68 int* sourceId, int* errLine, UString* errMsg);
69
70 UString m_sourceURL;
71 int m_sourceId;
72 RefPtr<SourceElements> m_sourceElements;
73 RefPtr<ParserRefCountedData<DeclarationStacks::VarStack> > m_varDeclarations;
74 RefPtr<ParserRefCountedData<DeclarationStacks::FunctionStack> > m_funcDeclarations;
75 bool m_usesEval;
76 bool m_needsClosure;
77 int m_lastLine;
78 };
79
80 template <class ParsedNode>
81 PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, const UString& sourceURL, int startingLineNumber,
82 PassRefPtr<SourceProvider> source,
83 int* sourceId, int* errLine, UString* errMsg)
84 {
85 m_sourceURL = sourceURL;
86 parse(exec, sourceURL, startingLineNumber, source, sourceId, errLine, errMsg);
87 if (!m_sourceElements) {
88 m_sourceURL = UString();
89 return 0;
90 }
91 RefPtr<ParsedNode> node = ParsedNode::create(&exec->globalData(),
92 m_sourceElements.release().get(),
93 m_varDeclarations ? &m_varDeclarations->data : 0,
94 m_funcDeclarations ? &m_funcDeclarations->data : 0,
95 m_usesEval,
96 m_needsClosure);
97 m_varDeclarations = 0;
98 m_funcDeclarations = 0;
99 m_sourceURL = UString();
100 node->setLoc(startingLineNumber, m_lastLine);
101 return node.release();
102 }
103
104} // namespace KJS
105
106#endif // Parser_h
Note: See TracBrowser for help on using the repository browser.