[llvm-commits] [hlvm] r38014 - in /hlvm/trunk/tools: Makefile hlvm-xml2xml/ hlvm-xml2xml/Makefile hlvm-xml2xml/hlvm-xml2xml.cpp hlvm-xml2yaml/ hlvm-yaml2xml/

Reid Spencer reid at x10sys.com
Sat Jul 7 16:58:58 PDT 2007


Author: reid
Date: Sat Jul  7 18:58:58 2007
New Revision: 38014

URL: http://llvm.org/viewvc/llvm-project?rev=38014&view=rev
Log:
Back off having two programs initially. We can use a single XML->AST->XML
translator for testing purpose much better than using two formats. It also
cuts down the amount of work we have to do initially.

Added:
    hlvm/trunk/tools/hlvm-xml2xml/
    hlvm/trunk/tools/hlvm-xml2xml/Makefile   (with props)
    hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
Removed:
    hlvm/trunk/tools/hlvm-xml2yaml/
    hlvm/trunk/tools/hlvm-yaml2xml/
Modified:
    hlvm/trunk/tools/Makefile

Modified: hlvm/trunk/tools/Makefile
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/Makefile?rev=38014&r1=38013&r2=38014&view=diff

==============================================================================
--- hlvm/trunk/tools/Makefile (original)
+++ hlvm/trunk/tools/Makefile Sat Jul  7 18:58:58 2007
@@ -1,6 +1,6 @@
 ##===- tools/Makefile --------------------------------------*- Makefile -*-===##
 
 LEVEL=..
-DIRS=hlvm-yaml2xml hlvm-xml2yaml
+DIRS=hlvm-xml2xml
 
 include $(LEVEL)/Makefile.hlvm

Added: hlvm/trunk/tools/hlvm-xml2xml/Makefile
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/Makefile?rev=38014&view=auto

==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/Makefile (added)
+++ hlvm/trunk/tools/hlvm-xml2xml/Makefile Sat Jul  7 18:58:58 2007
@@ -0,0 +1,8 @@
+##===- tools/hlvm-xml2xml/Makefile -------------------------*- Makefile -*-===##
+
+LEVEL = ../..
+TOOLNAME = hlvm-xml2xml
+LLVMLIBS = LLVMSupport.a LLVMSystem.a
+
+include $(LEVEL)/Makefile.hlvm
+

Propchange: hlvm/trunk/tools/hlvm-xml2xml/Makefile

------------------------------------------------------------------------------
    svn:executable = *

Added: hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp?rev=38014&view=auto

==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp (added)
+++ hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp Sat Jul  7 18:58:58 2007
@@ -0,0 +1,83 @@
+//===-- tools/hlvm-xml2xml/hlvm-xml2xml.cpp - Main Program ------*- C++ -*-===//
+//
+//                      High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it 
+// under the terms of the GNU Lesser General Public License as published by 
+// the Free Software Foundation; either version 2.1 of the License, or (at 
+// your option) any later version.
+//
+// This software 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 Lesser General Public License for 
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License 
+// along with this library in the file named LICENSE.txt; if not, write to the 
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file tools/hlvm-xml2xml/hlvm-xml2xml.cpp
+/// @author Reid Spencer <reid at hlvm.org> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Implements the main program for the hlvm-xml2xml executable
+//===----------------------------------------------------------------------===//
+
+#include <llvm/Support/CommandLine.h>
+#include <llvm/System/Signals.h>
+#include <fstream>
+
+static cl::opt<std::string>
+InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-"));
+
+static cl::opt<std::string>
+OutputFilename("o", cl::desc("Override output filename"),
+               cl::value_desc("filename"));
+
+int main(int argc, char**argv) 
+{
+  try {
+    cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
+    sys::PrintStackTraceOnErrorSignal();
+
+    std::ostream *Out = &std::cout;  // Default to printing to stdout.
+
+    if (OutputFilename != "") {   // Specified an output filename?
+      if (OutputFilename != "-") { // Not stdout?
+        Out = new std::ofstream(OutputFilename.c_str());
+        sys::RemoveFileOnSignal(sys::Path(OutputFilename));
+      }
+    } else {
+      if (InputFilename == "-") {
+        OutputFilename = "-";
+      } else {
+        std::string IFN = InputFilename;
+        OutputFilename = InputFilename + ".out";
+
+        Out = new std::ofstream(OutputFilename.c_str());
+        sys::RemoveFileOnSignal(sys::Path(OutputFilename));
+      }
+    }
+
+    if (!Out->good()) {
+      std::cerr << argv[0] << ": error opening " << OutputFilename
+                << ": sending to stdout instead!\n";
+      Out = &std::cout;
+    }
+
+    if (Out != &std::cout) {
+      ((std::ofstream*)Out)->close();
+      delete Out;
+    }
+    return 0;
+  } catch (const std::string& msg) {
+    std::cerr << argv[0] << ": " << msg << "\n";
+  } catch (...) {
+    std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+  }
+  return 1;
+}





More information about the llvm-commits mailing list