Reviewed by Maciej.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Mar 2006 05:29:48 +0000 (05:29 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Mar 2006 05:29:48 +0000 (05:29 +0000)
        - 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13153 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/kjs/Parser.cpp [new file with mode: 0644]
JavaScriptCore/kjs/Parser.h [new file with mode: 0644]
JavaScriptCore/kjs/function.h
JavaScriptCore/kjs/internal.cpp
JavaScriptCore/kjs/internal.h
JavaScriptCore/kjs/nodes.h

index 72face1fcd274903713a8a20a54a7e8f8b26972c..9d328bff3bc83a39fae071af4985d77aebc748bd 100644 (file)
@@ -1,3 +1,22 @@
+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.
index a7db5addacf56faeb38f57563ab27ca5f42690d0..eb87b90c6da856e7de3db0a6048327bdf659cd60 100644 (file)
                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;
                };
diff --git a/JavaScriptCore/kjs/Parser.cpp b/JavaScriptCore/kjs/Parser.cpp
new file mode 100644 (file)
index 0000000..530f97c
--- /dev/null
@@ -0,0 +1,122 @@
+// -*- 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;
+}
+
+}
diff --git a/JavaScriptCore/kjs/Parser.h b/JavaScriptCore/kjs/Parser.h
new file mode 100644 (file)
index 0000000..5bb4391
--- /dev/null
@@ -0,0 +1,61 @@
+// -*- 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
index 49416d0e88b370c96c8424cc8df68491420df7f3..93b363a8559d44f8fd4508ceaf028d7720e0a120 100644 (file)
@@ -29,8 +29,9 @@
 
 namespace KJS {
 
-  class Parameter;
   class ActivationImp;
+  class FunctionBodyNode;
+  class Parameter;
 
   /**
    * @short Implementation class for internal Functions.
index e375557232ba9c2d33a0d6b32e06641e06c68fde..2d80696b13d76febe4a5e6ec59f523e98fa71347 100644 (file)
@@ -48,8 +48,6 @@
 #include <math.h>
 #include <stdio.h>
 
-extern int kjsyyparse();
-
 namespace KJS {
 
 #if PLATFORM(WIN_OS)
@@ -250,92 +248,6 @@ void ContextImp::mark()
   }
 }
 
-// ------------------------------ 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;
index 301caa7622e77969061456480db3d48872e2cbc9..9c59a920f9f7284c990ef58e8dcbbee8622ee818 100644 (file)
@@ -3,7 +3,7 @@
  *  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
@@ -135,7 +131,7 @@ namespace KJS {
 
 
   // ---------------------------------------------------------------------------
-  //                            Parsing & evaluation
+  //                            Evaluation
   // ---------------------------------------------------------------------------
 
   enum CodeType { GlobalCode,
@@ -143,27 +139,6 @@ namespace KJS {
                   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:
index 83ffaf7089b392cf6d36bbb2b3f43cf718c56d01..82ebb18ff2bf0f676bb7559716357206405e109f 100644 (file)
@@ -3,7 +3,7 @@
  *  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 {