+2006-03-05 Darin Adler <darin@apple.com>
+
+ Reviewed by Maciej.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=7616
+ get all references to KJS::Node out of internal.h
+
+ * JavaScriptCore.xcodeproj/project.pbxproj: Updated for file changes.
+
+ * kjs/Parser.cpp: Added.
+ * kjs/Parser.h: Added.
+
+ * kjs/internal.cpp: Removed the Parser class.
+ * kjs/internal.h: Ditto. Also removed unnecessary declarations of classes
+ not used in this header.
+
+ * kjs/nodes.h: Added an include of "Parser.h".
+ * kjs/function.h: Added a declaration of FunctionBodyNode.
+
2006-03-05 Geoffrey Garen <ggaren@apple.com>
Reviewed by Maciej.
93E26CCF08B2921900F85226 /* softlinking.h in Headers */ = {isa = PBXBuildFile; fileRef = 93E26CCE08B2921900F85226 /* softlinking.h */; };
93E26CF708B29A1C00F85226 /* pcre_get.c in Sources */ = {isa = PBXBuildFile; fileRef = 93E26CF608B29A1C00F85226 /* pcre_get.c */; };
93E26DDC08B2A4F400F85226 /* pcre_printint.c in Sources */ = {isa = PBXBuildFile; fileRef = 93E26DDB08B2A4F400F85226 /* pcre_printint.c */; };
+ 93F0B3AB09BB4DC00068FCE3 /* Parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F0B3A909BB4DC00068FCE3 /* Parser.cpp */; };
+ 93F0B3AC09BB4DC00068FCE3 /* Parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F0B3AA09BB4DC00068FCE3 /* Parser.h */; };
/* End PBXBuildFile section */
/* Begin PBXBuildRule section */
93E26CCE08B2921900F85226 /* softlinking.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = softlinking.h; path = bindings/softlinking.h; sourceTree = "<group>"; tabWidth = 8; };
93E26CF608B29A1C00F85226 /* pcre_get.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; name = pcre_get.c; path = pcre/pcre_get.c; sourceTree = "<group>"; tabWidth = 8; };
93E26DDB08B2A4F400F85226 /* pcre_printint.c */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.c; name = pcre_printint.c; path = pcre/pcre_printint.c; sourceTree = "<group>"; tabWidth = 8; };
+ 93F0B3A909BB4DC00068FCE3 /* Parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Parser.cpp; sourceTree = "<group>"; };
+ 93F0B3AA09BB4DC00068FCE3 /* Parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Parser.h; sourceTree = "<group>"; };
93F1981A08245AAE001E9ABC /* keywords.table */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = text; path = keywords.table; sourceTree = "<group>"; tabWidth = 8; };
F5341390030CEEB1018BE7F3 /* reference.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reference.cpp; sourceTree = "<group>"; tabWidth = 8; };
F5341391030CEEB1018BE7F3 /* reference.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = reference.h; sourceTree = "<group>"; tabWidth = 8; };
F692A8740255597D01FF60F7 /* object_object.h */,
F692A8770255597D01FF60F7 /* operations.cpp */,
F692A8780255597D01FF60F7 /* operations.h */,
+ 93F0B3A909BB4DC00068FCE3 /* Parser.cpp */,
+ 93F0B3AA09BB4DC00068FCE3 /* Parser.h */,
F692A8790255597D01FF60F7 /* property_map.cpp */,
F692A87A0255597D01FF60F7 /* property_map.h */,
65621E6B089E859700760F35 /* property_slot.cpp */,
14ABB36F099C076400E2A24F /* value.h in Headers */,
14ABB455099C2A0F00E2A24F /* JSType.h in Headers */,
65D6D87F09B5A32E0002E4D7 /* Platform.h in Headers */,
+ 93F0B3AC09BB4DC00068FCE3 /* Parser.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */,
65EA4C9B092AF9E20093D800 /* JSLock.cpp in Sources */,
14760864099C633800437128 /* JSImmediate.cpp in Sources */,
+ 93F0B3AB09BB4DC00068FCE3 /* Parser.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+// -*- c-basic-offset: 4 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "Parser.h"
+
+#include "lexer.h"
+#include "nodes.h"
+#include <kxmlcore/HashSet.h>
+#include <kxmlcore/Vector.h>
+
+extern int kjsyyparse();
+
+namespace KJS {
+
+int Parser::sid = 0;
+
+static RefPtr<ProgramNode>* progNode;
+static Vector<RefPtr<Node> >* newNodes;
+static HashSet<Node*>* nodeCycles;
+
+void Parser::saveNewNode(Node *node)
+{
+ if (!newNodes)
+ newNodes = new Vector<RefPtr<Node> >;
+ newNodes->append(node);
+}
+
+void Parser::noteNodeCycle(Node *node)
+{
+ if (!nodeCycles)
+ nodeCycles = new HashSet<Node*>;
+ nodeCycles->add(node);
+}
+
+void Parser::removeNodeCycle(Node *node)
+{
+ ASSERT(nodeCycles);
+ nodeCycles->remove(node);
+}
+
+static void clearNewNodes()
+{
+ if (nodeCycles) {
+ for (HashSet<Node*>::iterator it = nodeCycles->begin(); it != nodeCycles->end(); ++it)
+ (*it)->breakCycle();
+ delete nodeCycles;
+ nodeCycles = 0;
+ }
+
+ delete newNodes;
+ newNodes = 0;
+}
+
+PassRefPtr<ProgramNode> Parser::parse(const UString& sourceURL, int startingLineNumber,
+ const UChar* code, unsigned length,
+ int* sourceId, int* errLine, UString* errMsg)
+{
+ if (errLine)
+ *errLine = -1;
+ if (errMsg)
+ *errMsg = 0;
+ if (!progNode)
+ progNode = new RefPtr<ProgramNode>;
+
+ Lexer::curr()->setCode(sourceURL, startingLineNumber, code, length);
+ *progNode = 0;
+ sid++;
+ if (sourceId)
+ *sourceId = sid;
+
+ // Enable this and the #define YYDEBUG in grammar.y to debug a parse error
+ //extern int kjsyydebug;
+ //kjsyydebug=1;
+
+ int parseError = kjsyyparse();
+ bool lexError = Lexer::curr()->sawError();
+ Lexer::curr()->doneParsing();
+ PassRefPtr<ProgramNode> prog = progNode->release();
+ *progNode = 0;
+
+ clearNewNodes();
+
+ if (parseError || lexError) {
+ int eline = Lexer::curr()->lineNo();
+ if (errLine)
+ *errLine = eline;
+ if (errMsg)
+ *errMsg = "Parse error";
+ return 0;
+ }
+
+ return prog;
+}
+
+void Parser::accept(PassRefPtr<ProgramNode> prog)
+{
+ *progNode = prog;
+}
+
+}
--- /dev/null
+// -*- c-basic-offset: 4 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2003, 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef Parser_h
+#define Parser_h
+
+#include <kxmlcore/PassRefPtr.h>
+
+namespace KJS {
+
+ class Node;
+ class ProgramNode;
+ class UChar;
+ class UString;
+
+ /**
+ * @internal
+ *
+ * Parses ECMAScript source code and converts into ProgramNode objects, which
+ * represent the root of a parse tree. This class provides a convenient workaround
+ * for the problem of the bison parser working in a static context.
+ */
+ class Parser {
+ public:
+ static PassRefPtr<ProgramNode> parse(const UString& sourceURL, int startingLineNumber,
+ const UChar* code, unsigned length,
+ int* sourceId = 0, int* errLine = 0, UString* errMsg = 0);
+
+ static void accept(PassRefPtr<ProgramNode>);
+
+ static void saveNewNode(Node*);
+ static void noteNodeCycle(Node*);
+ static void removeNodeCycle(Node*);
+
+ static int sid;
+ };
+
+} // namespace
+
+#endif
namespace KJS {
- class Parameter;
class ActivationImp;
+ class FunctionBodyNode;
+ class Parameter;
/**
* @short Implementation class for internal Functions.
#include <math.h>
#include <stdio.h>
-extern int kjsyyparse();
-
namespace KJS {
#if PLATFORM(WIN_OS)
}
}
-// ------------------------------ Parser ---------------------------------------
-
-static RefPtr<ProgramNode> *progNode;
-int Parser::sid = 0;
-
-static Vector<RefPtr<Node> >* newNodes;
-static HashSet<Node*>* nodeCycles;
-
-void Parser::saveNewNode(Node *node)
-{
- if (!newNodes)
- newNodes = new Vector<RefPtr<Node> >;
-
- newNodes->append(node);
-}
-
-void Parser::noteNodeCycle(Node *node)
-{
- if (!nodeCycles)
- nodeCycles = new HashSet<Node*>;
- nodeCycles->add(node);
-}
-
-void Parser::removeNodeCycle(Node *node)
-{
- ASSERT(nodeCycles);
- nodeCycles->remove(node);
-}
-
-static void clearNewNodes()
-{
- if (nodeCycles) {
- for (HashSet<Node*>::iterator it = nodeCycles->begin(); it != nodeCycles->end(); ++it)
- (*it)->breakCycle();
- delete nodeCycles;
- nodeCycles = 0;
- }
-
- delete newNodes;
- newNodes = 0;
-}
-
-RefPtr<ProgramNode> Parser::parse(const UString &sourceURL, int startingLineNumber,
- const UChar *code, unsigned int length, int *sourceId,
- int *errLine, UString *errMsg)
-{
- if (errLine)
- *errLine = -1;
- if (errMsg)
- *errMsg = 0;
- if (!progNode)
- progNode = new RefPtr<ProgramNode>;
-
- Lexer::curr()->setCode(sourceURL, startingLineNumber, code, length);
- *progNode = 0;
- sid++;
- if (sourceId)
- *sourceId = sid;
- // Enable this (and the #define YYDEBUG in grammar.y) to debug a parse error
- //extern int kjsyydebug;
- //kjsyydebug=1;
- int parseError = kjsyyparse();
- bool lexError = Lexer::curr()->sawError();
- Lexer::curr()->doneParsing();
- RefPtr<ProgramNode> prog = *progNode;
- *progNode = 0;
-
- clearNewNodes();
-
- if (parseError || lexError) {
- int eline = Lexer::curr()->lineNo();
- if (errLine)
- *errLine = eline;
- if (errMsg)
- *errMsg = "Parse error";
- return RefPtr<ProgramNode>();
- }
-
- return prog;
-}
-
-void Parser::accept(ProgramNode *prog)
-{
- *progNode = prog;
-}
-
// ------------------------------ InterpreterImp -------------------------------
InterpreterImp* InterpreterImp::s_hook = 0L;
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
namespace KJS {
- class Node;
- class ProgramNode;
- class FunctionBodyNode;
- class FunctionPrototype;
- class FunctionImp;
class Debugger;
+ class FunctionPrototype;
// ---------------------------------------------------------------------------
// Primitive impls
// ---------------------------------------------------------------------------
- // Parsing & evaluation
+ // Evaluation
// ---------------------------------------------------------------------------
enum CodeType { GlobalCode,
FunctionCode,
AnonymousCode };
- /**
- * @internal
- *
- * Parses ECMAScript source code and converts into ProgramNode objects, which
- * represent the root of a parse tree. This class provides a conveniant workaround
- * for the problem of the bison parser working in a static context.
- */
- class Parser {
- public:
- static RefPtr<ProgramNode> parse(const UString &sourceURL, int startingLineNumber,
- const UChar *code, unsigned int length, int *sourceId = 0,
- int *errLine = 0, UString *errMsg = 0);
- static void accept(ProgramNode *prog);
-
- static void saveNewNode(Node *node);
- static void noteNodeCycle(Node *node);
- static void removeNodeCycle(Node *node);
-
- static int sid;
- };
-
class SavedBuiltinsInternal {
friend class InterpreterImp;
private:
* This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
*
*/
-#ifndef _NODES_H_
-#define _NODES_H_
-
-#include <kxmlcore/RefPtr.h>
-#include <kxmlcore/ListRefPtr.h>
+#ifndef NODES_H_
+#define NODES_H_
+#include "Parser.h"
#include "internal.h"
+#include <kxmlcore/ListRefPtr.h>
+#include <kxmlcore/RefPtr.h>
namespace KJS {