OLD | NEW |
1 //===- subzero/src/IceBrowserCompileServer.h - Browser server ---*- C++ -*-===// | 1 //===- subzero/src/IceBrowserCompileServer.h - Browser 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 browser-specific compile server. | 10 // This file declares the browser-specific compile server. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 CompileThread.join(); | 68 CompileThread.join(); |
69 LastError.assign(Ctx->getErrorStatus()->value()); | 69 LastError.assign(Ctx->getErrorStatus()->value()); |
70 // Reset some state. The InputStream is deleted by the compiler | 70 // Reset some state. The InputStream is deleted by the compiler |
71 // so only reset this to nullptr. Free and flush the rest | 71 // so only reset this to nullptr. Free and flush the rest |
72 // of the streams. | 72 // of the streams. |
73 InputStream = nullptr; | 73 InputStream = nullptr; |
74 EmitStream.reset(nullptr); | 74 EmitStream.reset(nullptr); |
75 ELFStream.reset(nullptr); | 75 ELFStream.reset(nullptr); |
76 } | 76 } |
77 | 77 |
78 StringStream &getErrorStream() { | 78 StringStream &getErrorStream() { return *ErrorStream; } |
79 return *ErrorStream; | |
80 } | |
81 | 79 |
82 private: | 80 private: |
83 class StringStream { | 81 class StringStream { |
84 public: | 82 public: |
85 StringStream() : StrBuf(Buffer) {} | 83 StringStream() : StrBuf(Buffer) {} |
86 const IceString &getContents() { return StrBuf.str(); } | 84 const IceString &getContents() { return StrBuf.str(); } |
87 Ostream &getStream() { return StrBuf; } | 85 Ostream &getStream() { return StrBuf; } |
| 86 |
88 private: | 87 private: |
89 std::string Buffer; | 88 std::string Buffer; |
90 llvm::raw_string_ostream StrBuf; | 89 llvm::raw_string_ostream StrBuf; |
91 }; | 90 }; |
92 // This currently only handles a single compile request, hence one copy | 91 // This currently only handles a single compile request, hence one copy |
93 // of the state. | 92 // of the state. |
94 std::unique_ptr<GlobalContext> Ctx; | 93 std::unique_ptr<GlobalContext> Ctx; |
95 // A borrowed reference to the current InputStream. The compiler owns | 94 // A borrowed reference to the current InputStream. The compiler owns |
96 // the actual reference so the server must be careful not to access | 95 // the actual reference so the server must be careful not to access |
97 // after the compiler is done. | 96 // after the compiler is done. |
98 llvm::QueueStreamer *InputStream; | 97 llvm::QueueStreamer *InputStream; |
99 std::unique_ptr<Ostream> LogStream; | 98 std::unique_ptr<Ostream> LogStream; |
100 std::unique_ptr<llvm::raw_fd_ostream> EmitStream; | 99 std::unique_ptr<llvm::raw_fd_ostream> EmitStream; |
101 std::unique_ptr<StringStream> ErrorStream; | 100 std::unique_ptr<StringStream> ErrorStream; |
102 std::unique_ptr<ELFStreamer> ELFStream; | 101 std::unique_ptr<ELFStreamer> ELFStream; |
103 ClFlags Flags; | 102 ClFlags Flags; |
104 ClFlagsExtra ExtraFlags; | 103 ClFlagsExtra ExtraFlags; |
105 std::thread CompileThread; | 104 std::thread CompileThread; |
106 }; | 105 }; |
107 | 106 |
108 } // end of namespace Ice | 107 } // end of namespace Ice |
109 | 108 |
110 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H | 109 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H |
OLD | NEW |