| OLD | NEW |
| 1 //===- subzero/src/IceCompileServer.h - Compile server ----------*- C++ -*-===// | 1 //===- subzero/src/IceCompileServer.h - Compile server ----------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 /// |
| 10 // This file declares the compile server. Given a compiler implementation, | 10 /// \file |
| 11 // it dispatches compile requests to the implementation. | 11 /// This file declares the compile server. Given a compiler implementation, |
| 12 // | 12 /// it dispatches compile requests to the implementation. |
| 13 /// |
| 13 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
| 14 | 15 |
| 15 #ifndef SUBZERO_SRC_ICECOMPILESERVER_H | 16 #ifndef SUBZERO_SRC_ICECOMPILESERVER_H |
| 16 #define SUBZERO_SRC_ICECOMPILESERVER_H | 17 #define SUBZERO_SRC_ICECOMPILESERVER_H |
| 17 | 18 |
| 18 #include "IceCompiler.h" | 19 #include "IceCompiler.h" |
| 19 #include "IceDefs.h" | 20 #include "IceDefs.h" |
| 20 #include "IceGlobalContext.h" | 21 #include "IceGlobalContext.h" |
| 21 | 22 |
| 22 namespace llvm { | 23 namespace llvm { |
| 23 class DataStreamer; | 24 class DataStreamer; |
| 24 class raw_fd_ostream; | 25 class raw_fd_ostream; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace Ice { | 28 namespace Ice { |
| 28 | 29 |
| 29 // A CompileServer awaits compile requests, and dispatches the requests | 30 /// A CompileServer awaits compile requests, and dispatches the requests |
| 30 // to a given Compiler. Each request is paired with an input stream, | 31 /// to a given Compiler. Each request is paired with an input stream, |
| 31 // a context (which has the output stream), and a set of arguments. | 32 /// a context (which has the output stream), and a set of arguments. |
| 32 // The CompileServer takes over the current thread to listen to requests, | 33 /// The CompileServer takes over the current thread to listen to requests, |
| 33 // and compile requests are handled on separate threads. | 34 /// and compile requests are handled on separate threads. |
| 34 // | 35 /// |
| 35 // Currently, this only handles a single request. | 36 /// Currently, this only handles a single request. |
| 36 // | 37 /// |
| 37 // When run on the commandline, it receives and therefore dispatches | 38 /// When run on the commandline, it receives and therefore dispatches |
| 38 // the request immediately. When run in the browser, it blocks waiting | 39 /// the request immediately. When run in the browser, it blocks waiting |
| 39 // for a request. | 40 /// for a request. |
| 40 class CompileServer { | 41 class CompileServer { |
| 41 CompileServer() = delete; | 42 CompileServer() = delete; |
| 42 CompileServer(const CompileServer &) = delete; | 43 CompileServer(const CompileServer &) = delete; |
| 43 CompileServer &operator=(const CompileServer &) = delete; | 44 CompileServer &operator=(const CompileServer &) = delete; |
| 44 | 45 |
| 45 public: | 46 public: |
| 46 explicit CompileServer(Compiler &Comp) : Comp(Comp) {} | 47 explicit CompileServer(Compiler &Comp) : Comp(Comp) {} |
| 47 | 48 |
| 48 virtual ~CompileServer() = default; | 49 virtual ~CompileServer() = default; |
| 49 | 50 |
| 50 virtual void run() = 0; | 51 virtual void run() = 0; |
| 51 | 52 |
| 52 virtual ErrorCode &getErrorCode() { return LastError; } | 53 virtual ErrorCode &getErrorCode() { return LastError; } |
| 53 void transferErrorCode(ErrorCodes Code) { LastError.assign(Code); } | 54 void transferErrorCode(ErrorCodes Code) { LastError.assign(Code); } |
| 54 | 55 |
| 55 protected: | 56 protected: |
| 56 Compiler &getCompiler() const { return Comp; } | 57 Compiler &getCompiler() const { return Comp; } |
| 57 | 58 |
| 58 Compiler &Comp; | 59 Compiler &Comp; |
| 59 ErrorCode LastError; | 60 ErrorCode LastError; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 // Commandline variant of the compile server. | 63 /// Commandline variant of the compile server. |
| 63 class CLCompileServer : public CompileServer { | 64 class CLCompileServer : public CompileServer { |
| 64 CLCompileServer() = delete; | 65 CLCompileServer() = delete; |
| 65 CLCompileServer(const CLCompileServer &) = delete; | 66 CLCompileServer(const CLCompileServer &) = delete; |
| 66 CLCompileServer &operator=(const CLCompileServer &) = delete; | 67 CLCompileServer &operator=(const CLCompileServer &) = delete; |
| 67 | 68 |
| 68 public: | 69 public: |
| 69 CLCompileServer(Compiler &Comp, int argc, char **argv) | 70 CLCompileServer(Compiler &Comp, int argc, char **argv) |
| 70 : CompileServer(Comp), argc(argc), argv(argv) {} | 71 : CompileServer(Comp), argc(argc), argv(argv) {} |
| 71 | 72 |
| 72 ~CLCompileServer() final = default; | 73 ~CLCompileServer() final = default; |
| 73 | 74 |
| 74 void run() final; | 75 void run() final; |
| 75 | 76 |
| 76 private: | 77 private: |
| 77 int argc; | 78 int argc; |
| 78 char **argv; | 79 char **argv; |
| 79 std::unique_ptr<GlobalContext> Ctx; | 80 std::unique_ptr<GlobalContext> Ctx; |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 } // end of namespace Ice | 83 } // end of namespace Ice |
| 83 | 84 |
| 84 #endif // SUBZERO_SRC_ICECOMPILESERVER_H | 85 #endif // SUBZERO_SRC_ICECOMPILESERVER_H |
| OLD | NEW |