Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: src/IceCompileServer.h

Issue 997773002: Refactor Subzero initialization and add a browser callback handler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add argv note Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceClFlagsExtra.h ('k') | src/IceCompileServer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCompileServer.h
diff --git a/src/IceCompileServer.h b/src/IceCompileServer.h
new file mode 100644
index 0000000000000000000000000000000000000000..a0a0e7ad5d1551ab2a15511b2d9ceb536304edca
--- /dev/null
+++ b/src/IceCompileServer.h
@@ -0,0 +1,84 @@
+//===- subzero/src/IceCompileServer.h - Compile server ----------*- C++ -*-===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the compile server. Given a compiler implementation,
+// it dispatches compile requests to the implementation.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUBZERO_SRC_ICECOMPILESERVER_H
+#define SUBZERO_SRC_ICECOMPILESERVER_H
+
+#include "IceCompiler.h"
+#include "IceDefs.h"
+#include "IceGlobalContext.h"
+
+namespace llvm {
+class DataStreamer;
+class raw_fd_ostream;
+};
+
+namespace Ice {
+
+// A CompileServer awaits compile requests, and dispatches the requests
+// to a given Compiler. Each request is paired with an input stream,
+// a context (which has the output stream), and a set of arguments.
+// The CompileServer takes over the current thread to listen to requests,
+// and compile requests are handled on separate threads.
+//
+// Currently, this only handles a single request.
+//
+// When run on the commandline, it receives and therefore dispatches
+// the request immediately. When run in the browser, it blocks waiting
+// for a request.
+class CompileServer {
+ CompileServer() = delete;
+ CompileServer(const CompileServer &) = delete;
+ CompileServer &operator=(const CompileServer &) = delete;
+
+public:
+ explicit CompileServer(Compiler &Comp) : Comp(Comp) {}
+
+ virtual ~CompileServer() {}
+
+ virtual void run() = 0;
+
+ ErrorCode &getErrorCode() { return LastError; }
+ void transferErrorCode(ErrorCodes Code) { LastError.assign(Code); }
+
+protected:
+ Compiler &getCompiler() const { return Comp; }
+
+ Compiler &Comp;
+ ErrorCode LastError;
+};
+
+// Commandline variant of the compile server.
+class CLCompileServer : public CompileServer {
+ CLCompileServer() = delete;
+ CLCompileServer(const CLCompileServer &) = delete;
+ CLCompileServer &operator=(const CLCompileServer &) = delete;
+
+public:
+ CLCompileServer(Compiler &Comp, int argc, char **argv)
+ : CompileServer(Comp), argc(argc), argv(argv) {}
+
+ ~CLCompileServer() final {}
+
+ void run() final;
+
+private:
+ int argc;
+ char **argv;
+ std::unique_ptr<GlobalContext> Ctx;
+};
+
+} // end of namespace Ice
+
+#endif // SUBZERO_SRC_ICECOMPILESERVER_H
« no previous file with comments | « src/IceClFlagsExtra.h ('k') | src/IceCompileServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698