From: Jay Freeman (saurik) <saurik@saurik.com>
Date: Tue, 10 Sep 2013 06:58:34 +0000 (-0700)
Subject: Clean up dependencies now that they are tracked.
X-Git-Tag: v0.9.500%b1~11
X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/b12a99658d0a609d28ff522b82be8826928107cf

Clean up dependencies now that they are tracked.
---

diff --git a/Console.cpp b/Console.cpp
index e955311..3dede2f 100644
--- a/Console.cpp
+++ b/Console.cpp
@@ -51,8 +51,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include "Cycript.tab.hh"
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -65,8 +63,11 @@
 
 #include <dlfcn.h>
 
-#include "Replace.hpp"
 #include "Display.hpp"
+#include "Replace.hpp"
+
+#include "Cycript.tab.hh"
+#include "Driver.hpp"
 
 static volatile enum {
     Working,
diff --git a/Cycript.yy.in b/Cycript.yy.in
index 047983b..14f6aad 100644
--- a/Cycript.yy.in
+++ b/Cycript.yy.in
@@ -28,6 +28,7 @@
 @if Bison24 }
 
 @if Bison24 %code requires {
+#include "Driver.hpp"
 #include "Parser.hpp"
 #define CYNew new($pool)
 
diff --git a/Driver.cpp b/Driver.cpp
new file mode 100644
index 0000000..4b1286c
--- /dev/null
+++ b/Driver.cpp
@@ -0,0 +1,62 @@
+/* Cycript - Optimizing JavaScript Compiler/Runtime
+ * Copyright (C) 2009-2013  Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cycript is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cycript 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cycript.  If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#include "Cycript.tab.hh"
+#include "Driver.hpp"
+
+CYDriver::CYDriver(std::istream &data, const std::string &filename) :
+    state_(CYClear),
+    data_(data),
+    strict_(false),
+    commented_(false),
+    filename_(filename),
+    program_(NULL),
+    auto_(false),
+    context_(NULL),
+    mode_(AutoNone)
+{
+    memset(&no_, 0, sizeof(no_));
+    in_.push(false);
+    ScannerInit();
+}
+
+CYDriver::~CYDriver() {
+    ScannerDestroy();
+}
+
+void CYDriver::Warning(const cy::location &location, const char *message) {
+    if (!strict_)
+        return;
+
+    CYDriver::Error error;
+    error.warning_ = true;
+    error.location_ = location;
+    error.message_ = message;
+    errors_.push_back(error);
+}
+
+void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
+    CYDriver::Error error;
+    error.warning_ = false;
+    error.location_ = location;
+    error.message_ = message;
+    driver.errors_.push_back(error);
+}
diff --git a/Driver.hpp b/Driver.hpp
new file mode 100644
index 0000000..3948274
--- /dev/null
+++ b/Driver.hpp
@@ -0,0 +1,122 @@
+/* Cycript - Optimizing JavaScript Compiler/Runtime
+ * Copyright (C) 2009-2013  Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cycript is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cycript 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cycript.  If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#ifndef CYCRIPT_DRIVER_HPP
+#define CYCRIPT_DRIVER_HPP
+
+#include <iostream>
+
+#include <stack>
+#include <string>
+#include <vector>
+
+#include "location.hh"
+
+#include "Parser.hpp"
+
+enum CYState {
+    CYClear,
+    CYRestricted,
+    CYNewLine
+};
+
+class CYDriver {
+  public:
+    void *scanner_;
+
+    CYState state_;
+    std::stack<bool> in_;
+
+    struct {
+        bool AtImplementation;
+        bool Function;
+        bool OpenBrace;
+    } no_;
+
+    std::istream &data_;
+
+    bool strict_;
+    bool commented_;
+
+    enum Condition {
+        RegExpCondition,
+        XMLContentCondition,
+        XMLTagCondition,
+    };
+
+    std::string filename_;
+
+    struct Error {
+        bool warning_;
+        cy::location location_;
+        std::string message_;
+    };
+
+    typedef std::vector<Error> Errors;
+
+    CYProgram *program_;
+    Errors errors_;
+
+    bool auto_;
+
+    struct Context {
+        CYExpression *context_;
+
+        Context(CYExpression *context) :
+            context_(context)
+        {
+        }
+
+        typedef std::vector<CYWord *> Words;
+        Words words_;
+    };
+
+    typedef std::vector<Context> Contexts;
+    Contexts contexts_;
+
+    CYExpression *context_;
+
+    enum Mode {
+        AutoNone,
+        AutoPrimary,
+        AutoDirect,
+        AutoIndirect,
+        AutoMessage
+    } mode_;
+
+  private:
+    void ScannerInit();
+    void ScannerDestroy();
+
+  public:
+    CYDriver(std::istream &data, const std::string &filename = "");
+    ~CYDriver();
+
+    Condition GetCondition();
+    void SetCondition(Condition condition);
+
+    void PushCondition(Condition condition);
+    void PopCondition();
+
+    void Warning(const cy::location &location, const char *message);
+};
+
+#endif/*CYCRIPT_DRIVER_HPP*/
diff --git a/Execute.cpp b/Execute.cpp
index 51e76ab..4c9e198 100644
--- a/Execute.cpp
+++ b/Execute.cpp
@@ -41,7 +41,6 @@
 #include <cmath>
 
 #include "Parser.hpp"
-#include "Cycript.tab.hh"
 
 #include "Error.hpp"
 #include "JavaScript.hpp"
diff --git a/Handler.mm b/Handler.mm
index 39624e3..d49274a 100644
--- a/Handler.mm
+++ b/Handler.mm
@@ -19,14 +19,6 @@
 **/
 /* }}} */
 
-#include "cycript.hpp"
-#include "JavaScript.hpp"
-
-#include "Pooling.hpp"
-#include "Parser.hpp"
-
-#include "Cycript.tab.hh"
-
 #include <Foundation/Foundation.h>
 #include <pthread.h>
 #include <unistd.h>
@@ -37,6 +29,15 @@
 #include <netinet/in.h>
 #include <sys/un.h>
 
+#include "cycript.hpp"
+
+#include "JavaScript.hpp"
+#include "Parser.hpp"
+#include "Pooling.hpp"
+
+#include "Cycript.tab.hh"
+#include "Driver.hpp"
+
 struct CYExecute_ {
     CYPool &pool_;
     const char * volatile data_;
diff --git a/Highlight.cpp b/Highlight.cpp
index e5a476d..4b7d669 100644
--- a/Highlight.cpp
+++ b/Highlight.cpp
@@ -20,9 +20,10 @@
 /* }}} */
 
 #include "Highlight.hpp"
+#include "Parser.hpp"
 
 #include "Cycript.tab.hh"
-#include "Parser.hpp"
+#include "Driver.hpp"
 
 static void Skip(const char *data, size_t size, std::ostream &output, size_t &offset, cy::position &current, cy::position target) {
     while (current.line != target.line || current.column != target.column) {
diff --git a/Library.cpp b/Library.cpp
index 30f6117..1f61c0e 100644
--- a/Library.cpp
+++ b/Library.cpp
@@ -34,13 +34,14 @@
 #include <sstream>
 #include <cmath>
 
-#include "Parser.hpp"
-#include "Cycript.tab.hh"
-
 #include "Error.hpp"
-#include "String.hpp"
 #include "Execute.hpp"
 #include "JavaScript.hpp"
+#include "Parser.hpp"
+#include "String.hpp"
+
+#include "Cycript.tab.hh"
+#include "Driver.hpp"
 
 #include "ConvertUTF.h"
 
diff --git a/Makefile.am b/Makefile.am
index 40f1d4a..137cc44 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,7 +43,7 @@ lib_LTLIBRARIES += libcycript.la
 libcycript_la_LDFLAGS = $(CY_LDFLAGS)
 libcycript_la_LIBADD = $(LTLIBFFI) -ldl
 
-libcycript_la_SOURCES = ConvertUTF.c Highlight.cpp Network.cpp Output.cpp Parser.cpp Replace.cpp
+libcycript_la_SOURCES = ConvertUTF.c Driver.cpp Highlight.cpp Network.cpp Output.cpp Parser.cpp Replace.cpp
 libcycript_la_SOURCES += Cycript.tab.cc lex.cy.cpp
 
 filters = $(CY_FILTERS)
@@ -119,7 +119,7 @@ CLEANFILES += lex.cy.cpp
 lex.cy.cpp: Cycript.l
 	$(FLEX) -t $< | $(SED) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
 
-Console.$(OBJEXT) Execute.lo Handler.lo Highlight.lo Library.lo Output.lo Parser.lo lex.cy.lo: Cycript.tab.hh
+Console.$(OBJEXT) Cycript.tab.lo Driver.lo Handler.lo Highlight.lo Library.lo lex.cy.lo: Cycript.tab.hh
 
 CLEANFILES += Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output
 Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output: Cycript.yy
diff --git a/Makefile.in b/Makefile.in
index 2ffd5d5..af9bfd6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -183,7 +183,7 @@ am__DEPENDENCIES_1 =
 @CY_OBJECTIVEC_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
 libcycript_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3)
-am__libcycript_la_SOURCES_DIST = ConvertUTF.c Highlight.cpp \
+am__libcycript_la_SOURCES_DIST = ConvertUTF.c Driver.cpp Highlight.cpp \
 	Network.cpp Output.cpp Parser.cpp Replace.cpp Cycript.tab.cc \
 	lex.cy.cpp sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp \
 	Bridge.cpp Execute.cpp JavaScriptCore.cpp Library.cpp \
@@ -197,9 +197,9 @@ am__dirstamp = $(am__leading_dot)dirstamp
 @CY_OBJECTIVEC_TRUE@	ObjectiveC/Replace.lo \
 @CY_OBJECTIVEC_TRUE@	ObjectiveC/Library.lo
 @CY_MACH_TRUE@am__objects_3 = Handler.lo
-am_libcycript_la_OBJECTS = ConvertUTF.lo Highlight.lo Network.lo \
-	Output.lo Parser.lo Replace.lo Cycript.tab.lo lex.cy.lo \
-	$(am__objects_1) $(am__objects_2) $(am__objects_3)
+am_libcycript_la_OBJECTS = ConvertUTF.lo Driver.lo Highlight.lo \
+	Network.lo Output.lo Parser.lo Replace.lo Cycript.tab.lo \
+	lex.cy.lo $(am__objects_1) $(am__objects_2) $(am__objects_3)
 libcycript_la_OBJECTS = $(am_libcycript_la_OBJECTS)
 libcycript_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(OBJCXXLD) $(AM_OBJCXXFLAGS) \
@@ -546,9 +546,9 @@ lib_LTLIBRARIES = $(am__append_1) libcycript.la
 libcycript_la_LDFLAGS = $(CY_LDFLAGS)
 libcycript_la_LIBADD = $(LTLIBFFI) -ldl $(am__append_3) \
 	$(am__append_9)
-libcycript_la_SOURCES = ConvertUTF.c Highlight.cpp Network.cpp \
-	Output.cpp Parser.cpp Replace.cpp Cycript.tab.cc lex.cy.cpp \
-	$(am__append_2) $(am__append_8) $(am__append_10)
+libcycript_la_SOURCES = ConvertUTF.c Driver.cpp Highlight.cpp \
+	Network.cpp Output.cpp Parser.cpp Replace.cpp Cycript.tab.cc \
+	lex.cy.cpp $(am__append_2) $(am__append_8) $(am__append_10)
 filters = $(CY_FILTERS) $(am__append_5) $(am__append_7)
 @CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp Display.cpp \
 @CY_CONSOLE_TRUE@	$(am__append_11)
@@ -749,6 +749,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConvertUTF.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cycript.tab.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Display.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Driver.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Execute.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Handler.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Highlight.Plo@am__quote@
@@ -1334,7 +1335,7 @@ Cycript.l: Cycript.l.in
 lex.cy.cpp: Cycript.l
 	$(FLEX) -t $< | $(SED) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
 
-Console.$(OBJEXT) Execute.lo Handler.lo Highlight.lo Library.lo Output.lo Parser.lo lex.cy.lo: Cycript.tab.hh
+Console.$(OBJEXT) Cycript.tab.lo Driver.lo Handler.lo Highlight.lo Library.lo lex.cy.lo: Cycript.tab.hh
 Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.output: Cycript.yy
 	$(BISON) -v --report=state $<
 	! grep -n '^ *$$default  reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep 'shift, and go to state [0-9]*$$'
diff --git a/Parser.cpp b/Parser.cpp
index 032997d..14e78b2 100644
--- a/Parser.cpp
+++ b/Parser.cpp
@@ -19,48 +19,8 @@
 **/
 /* }}} */
 
-#include "Cycript.tab.hh"
 #include "Parser.hpp"
 
 CYRange DigitRange_    (0x3ff000000000000LLU, 0x000000000000000LLU); // 0-9
 CYRange WordStartRange_(0x000001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$
 CYRange WordEndRange_  (0x3ff001000000000LLU, 0x7fffffe87fffffeLLU); // A-Za-z_$0-9
-
-CYDriver::CYDriver(std::istream &data, const std::string &filename) :
-    state_(CYClear),
-    data_(data),
-    strict_(false),
-    commented_(false),
-    filename_(filename),
-    program_(NULL),
-    auto_(false),
-    context_(NULL),
-    mode_(AutoNone)
-{
-    memset(&no_, 0, sizeof(no_));
-    in_.push(false);
-    ScannerInit();
-}
-
-CYDriver::~CYDriver() {
-    ScannerDestroy();
-}
-
-void CYDriver::Warning(const cy::location &location, const char *message) {
-    if (!strict_)
-        return;
-
-    CYDriver::Error error;
-    error.warning_ = true;
-    error.location_ = location;
-    error.message_ = message;
-    errors_.push_back(error);
-}
-
-void cy::parser::error(const cy::parser::location_type &location, const std::string &message) {
-    CYDriver::Error error;
-    error.warning_ = false;
-    error.location_ = location;
-    error.message_ = message;
-    driver.errors_.push_back(error);
-}
diff --git a/Parser.hpp b/Parser.hpp
index 9dbb9b9..2102091 100644
--- a/Parser.hpp
+++ b/Parser.hpp
@@ -24,7 +24,6 @@
 
 #include <iostream>
 
-#include <stack>
 #include <string>
 #include <vector>
 #include <map>
@@ -33,8 +32,6 @@
 #include <cstdio>
 #include <cstdlib>
 
-#include "location.hh"
-
 #include "List.hpp"
 #include "Pooling.hpp"
 #include "Options.hpp"
@@ -463,12 +460,6 @@ struct CYBlock :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
-enum CYState {
-    CYClear,
-    CYRestricted,
-    CYNewLine
-};
-
 class CYStream :
     public std::istream
 {
@@ -490,87 +481,6 @@ class CYStream :
     }
 };
 
-class CYDriver {
-  public:
-    void *scanner_;
-
-    CYState state_;
-    std::stack<bool> in_;
-
-    struct {
-        bool AtImplementation;
-        bool Function;
-        bool OpenBrace;
-    } no_;
-
-    std::istream &data_;
-
-    bool strict_;
-    bool commented_;
-
-    enum Condition {
-        RegExpCondition,
-        XMLContentCondition,
-        XMLTagCondition,
-    };
-
-    std::string filename_;
-
-    struct Error {
-        bool warning_;
-        cy::location location_;
-        std::string message_;
-    };
-
-    typedef std::vector<Error> Errors;
-
-    CYProgram *program_;
-    Errors errors_;
-
-    bool auto_;
-
-    struct Context {
-        CYExpression *context_;
-
-        Context(CYExpression *context) :
-            context_(context)
-        {
-        }
-
-        typedef std::vector<CYWord *> Words;
-        Words words_;
-    };
-
-    typedef std::vector<Context> Contexts;
-    Contexts contexts_;
-
-    CYExpression *context_;
-
-    enum Mode {
-        AutoNone,
-        AutoPrimary,
-        AutoDirect,
-        AutoIndirect,
-        AutoMessage
-    } mode_;
-
-  private:
-    void ScannerInit();
-    void ScannerDestroy();
-
-  public:
-    CYDriver(std::istream &data, const std::string &filename = "");
-    ~CYDriver();
-
-    Condition GetCondition();
-    void SetCondition(Condition condition);
-
-    void PushCondition(Condition condition);
-    void PopCondition();
-
-    void Warning(const cy::location &location, const char *message);
-};
-
 struct CYForInitialiser {
     virtual ~CYForInitialiser() {
     }