cleanup main

seems like these two lines are common to both paths and in fact
the different classes allocated are derived from the same common
base class so this makes sense to me.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1494753003 .

Patch from Reed Kotler <rkotlerimgtec@gmail.com>.
diff --git a/src/IceBrowserCompileServer.h b/src/IceBrowserCompileServer.h
index ce3f60d..a9e221b 100644
--- a/src/IceBrowserCompileServer.h
+++ b/src/IceBrowserCompileServer.h
@@ -37,14 +37,12 @@
 /// defaults that make sense in the browser case. The output file is specified
 /// via a posix FD, and input bytes are pushed to the server.
 class BrowserCompileServer : public CompileServer {
-  BrowserCompileServer() = delete;
   BrowserCompileServer(const BrowserCompileServer &) = delete;
   BrowserCompileServer &operator=(const BrowserCompileServer &) = delete;
   class StringStream;
 
 public:
-  explicit BrowserCompileServer(Compiler &Comp)
-      : CompileServer(Comp), InputStream(nullptr), HadError(false) {}
+  BrowserCompileServer() : HadError(false) {}
 
   ~BrowserCompileServer() final;
 
diff --git a/src/IceBuildDefs.h b/src/IceBuildDefs.h
index 6714297..9269697 100644
--- a/src/IceBuildDefs.h
+++ b/src/IceBuildDefs.h
@@ -35,6 +35,16 @@
 #endif // !NDEBUG
 }
 
+// PNACL_BROWSER_TRANSLATOR can be undefined, or defined to something non-zero
+// to indicate a browser-based translator.
+constexpr bool browser() {
+#if PNACL_BROWSER_TRANSLATOR
+  return true;
+#else  // !PNACL_BROWSER_TRANSLATOR
+  return false;
+#endif // !PNACL_BROWSER_TRANSLATOR
+}
+
 // ALLOW_EXTRA_VALIDATION can be undefined, or defined to something non-zero.
 constexpr bool extraValidation() {
 #if ALLOW_EXTRA_VALIDATION
diff --git a/src/IceCompileServer.h b/src/IceCompileServer.h
index 9b02f92..ca02577 100644
--- a/src/IceCompileServer.h
+++ b/src/IceCompileServer.h
@@ -41,12 +41,11 @@
 /// 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) {}
+  CompileServer() = default;
 
   virtual ~CompileServer() = default;
 
@@ -55,10 +54,15 @@
   virtual ErrorCode &getErrorCode() { return LastError; }
   void transferErrorCode(ErrorCodes Code) { LastError.assign(Code); }
 
-protected:
-  Compiler &getCompiler() const { return Comp; }
+  int runAndReturnErrorCode() {
+    run();
+    return getErrorCode().value();
+  }
 
-  Compiler &Comp;
+protected:
+  Compiler &getCompiler() { return Comp; }
+
+  Compiler Comp;
   ErrorCode LastError;
 };
 
@@ -69,8 +73,7 @@
   CLCompileServer &operator=(const CLCompileServer &) = delete;
 
 public:
-  CLCompileServer(Compiler &Comp, int argc, char **argv)
-      : CompileServer(Comp), argc(argc), argv(argv) {}
+  CLCompileServer(int argc, char **argv) : argc(argc), argv(argv) {}
 
   ~CLCompileServer() final = default;
 
diff --git a/src/main.cpp b/src/main.cpp
index 952db7b..e30ac7d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -14,25 +14,17 @@
 //===----------------------------------------------------------------------===//
 
 #include "IceBrowserCompileServer.h"
-#include "IceCompiler.h"
+#include "IceBuildDefs.h"
 #include "IceCompileServer.h"
 
 int main(int argc, char **argv) {
   // Start file server and "wait" for compile request.
-  Ice::Compiler Comp;
-// Can only compile the BrowserCompileServer w/ the NaCl compiler.
-#if PNACL_BROWSER_TRANSLATOR
-  // There are no real commandline arguments in the browser case. They are
-  // supplied via IPC.
-  assert(argc == 1);
-  (void)argc;
-  (void)argv;
-  Ice::BrowserCompileServer Server(Comp);
-  Server.run();
-  return Server.getErrorCode().value();
-#else  // !PNACL_BROWSER_TRANSLATOR
-  Ice::CLCompileServer Server(Comp, argc, argv);
-  Server.run();
-  return Server.getErrorCode().value();
-#endif // !PNACL_BROWSER_TRANSLATOR
+  // Can only compile the BrowserCompileServer w/ the NaCl compiler.
+  if (Ice::BuildDefs::browser()) {
+    // There are no real commandline arguments in the browser case. They are
+    // supplied via IPC.
+    assert(argc == 1);
+    return Ice::BrowserCompileServer().runAndReturnErrorCode();
+  }
+  return Ice::CLCompileServer(argc, argv).runAndReturnErrorCode();
 }