[llvm-commits] [hlvm] r38026 - in /hlvm/trunk/hlvm/Writer: Makefile Writer.h XML/ XML/Makefile XML/XMLWriter.cpp XML/XMLWriter.h

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


Author: reid
Date: Sat Jul  7 18:59:05 2007
New Revision: 38026

URL: http://llvm.org/viewvc/llvm-project?rev=38026&view=rev
Log:
Create a skeleton for writing AST -> XML.

Added:
    hlvm/trunk/hlvm/Writer/Writer.h
    hlvm/trunk/hlvm/Writer/XML/
    hlvm/trunk/hlvm/Writer/XML/Makefile   (with props)
    hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
    hlvm/trunk/hlvm/Writer/XML/XMLWriter.h
Modified:
    hlvm/trunk/hlvm/Writer/Makefile

Modified: hlvm/trunk/hlvm/Writer/Makefile
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/Makefile?rev=38026&r1=38025&r2=38026&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Writer/Makefile (original)
+++ hlvm/trunk/hlvm/Writer/Makefile Sat Jul  7 18:59:05 2007
@@ -1,12 +1,5 @@
 ##===- hlvm/Writer/Makefile --------------------------------*- Makefile -*-===##
-#
-# Relative path to the top of the source tree.
-#
 LEVEL=../..
-
-#
-# List all of the subdirectories that we will compile.
-#
-DIRS=
+DIRS=XML
 
 include $(LEVEL)/Makefile.hlvm

Added: hlvm/trunk/hlvm/Writer/Writer.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/Writer.h?rev=38026&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Writer/Writer.h (added)
+++ hlvm/trunk/hlvm/Writer/Writer.h Sat Jul  7 18:59:05 2007
@@ -0,0 +1,46 @@
+//===-- hlvm/Writer/Writer.h - AST Abstract Writer Class --------*- 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 hlvm/Writer/Writer.h
+/// @author Reid Spencer <rspencer at x10sys.com>
+/// @date 2006/05/12
+/// @since 0.1.0
+/// @brief Provides the interface to hlvm::Writer
+//===----------------------------------------------------------------------===//
+
+#ifndef XPS_WRITER_WRITER_H
+#define XPS_WRITER_WRITER_H
+
+#include <llvm/System/Path.h>
+
+namespace hlvm {
+namespace AST { class AST; }
+
+  class Writer
+  {
+  public:
+    /// This method writes the entire content of the AST to the writer's
+    /// destination
+    virtual void write(AST::AST* source) = 0;
+  };
+}
+#endif

Added: hlvm/trunk/hlvm/Writer/XML/Makefile
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XML/Makefile?rev=38026&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/Makefile (added)
+++ hlvm/trunk/hlvm/Writer/XML/Makefile Sat Jul  7 18:59:05 2007
@@ -0,0 +1,13 @@
+#-------------------------------------------------------------------------------
+# 
+# Copyright (C) 2006 HLVM Group. All Rights Reserved
+#
+#-------------------------------------------------------------------------------
+
+LEVEL 			:= ../../..
+LIBRARYNAME 		:= HLVMXMLWriter
+DONT_BUILD_RELINKED 	:= 1
+BUILD_ARCHIVE 		:= 1
+INSTALL_INCLUDES 	:= XMLWriter.h
+
+include $(LEVEL)/Makefile.hlvm

Propchange: hlvm/trunk/hlvm/Writer/XML/Makefile

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

Added: hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp?rev=38026&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp (added)
+++ hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp Sat Jul  7 18:59:05 2007
@@ -0,0 +1,73 @@
+//===-- hlvm/Writer/XML/XMLWriter.cpp - AST XML Writer Class ----*- 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 hlvm/Writer/XML/XMLWriter.cpp
+/// @author Reid Spencer <rspencer at x10sys.com>
+/// @date 2006/05/12
+/// @since 0.1.0
+/// @brief Provides the interface to hlvm::XMLWriter
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/Writer/XML/XMLWriter.h>
+#include <hlvm/AST/AST.h>
+#include <hlvm/AST/Bundle.h>
+#include <iostream>
+#include <fstream>
+
+using namespace hlvm;
+
+namespace {
+
+class XMLWriterImpl : public XMLWriter {
+  llvm::sys::Path path_;
+  std::fstream* out_;
+  AST::AST* ast_;
+public:
+  XMLWriterImpl(const llvm::sys::Path& path) :
+    path_(path), out_(0), ast_(0)
+  {
+  }
+
+  virtual ~XMLWriterImpl() 
+  { 
+    if (out_) {
+      out_->flush();
+      out_->close();
+      delete out_;
+    }
+  }
+
+  virtual void write(AST::AST* ast);
+};
+
+void
+XMLWriterImpl::write(AST::AST* ast) {
+  ast_ = ast;
+}
+
+}
+
+XMLWriter* 
+XMLWriter::create(const llvm::sys::Path& path)
+{
+  return new XMLWriterImpl(path);
+}

Added: hlvm/trunk/hlvm/Writer/XML/XMLWriter.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XML/XMLWriter.h?rev=38026&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/XMLWriter.h (added)
+++ hlvm/trunk/hlvm/Writer/XML/XMLWriter.h Sat Jul  7 18:59:05 2007
@@ -0,0 +1,51 @@
+//===-- hlvm/Writer/XML/XMLWriter.h - AST XML Writer Class ------*- 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 hlvm/Writer/XML/XMLWriter.h
+/// @author Reid Spencer <rspencer at x10sys.com>
+/// @date 2006/05/12
+/// @since 0.1.0
+/// @brief Provides the interface to hlvm::XMLWriter
+//===----------------------------------------------------------------------===//
+
+#ifndef XPS_WRITER_XML_XMLWRITER_H
+#define XPS_WRITER_XML_XMLWRITER_H
+
+#include <hlvm/Writer/Writer.h>
+#include <llvm/System/Path.h>
+
+namespace hlvm {
+
+  class AST::AST;
+
+  class XMLWriter: public Writer
+  {
+  public:
+    /// This method instantiates an XMLReader that is prepared to read from
+    /// the path provided.
+    /// @brief Create a new XmlReader
+    static XMLWriter* create(const llvm::sys::Path& path);
+
+    virtual ~XMLWriter() {}
+  };
+}
+#endif





More information about the llvm-commits mailing list