[llvm-commits] [hlvm] r38114 - in /hlvm/trunk: build/ docs/ hlvm/AST/ hlvm/Pass/ hlvm/Reader/XML/ hlvm/Writer/XML/ test/xml2xml/

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


Author: reid
Date: Sat Jul  7 18:59:57 2007
New Revision: 38114

URL: http://llvm.org/viewvc/llvm-project?rev=38114&view=rev
Log:
Enhancements to get the return.hlx test case to pass correctly. This augments
HLVM with the ability to recognize a Program, Block, and an Operator hierarchy.

Added:
    hlvm/trunk/hlvm/AST/Constants.cpp
    hlvm/trunk/hlvm/AST/Constants.h
    hlvm/trunk/hlvm/AST/ControlFlow.cpp
    hlvm/trunk/hlvm/AST/InputOutput.cpp
    hlvm/trunk/hlvm/AST/InputOutput.h
    hlvm/trunk/hlvm/AST/MemoryOps.cpp
    hlvm/trunk/hlvm/AST/MemoryOps.h
    hlvm/trunk/hlvm/AST/StringOps.cpp
    hlvm/trunk/hlvm/AST/StringOps.h
    hlvm/trunk/test/xml2xml/return.hlx
Modified:
    hlvm/trunk/build/hlvm.py
    hlvm/trunk/docs/RngToXHTML.xsl
    hlvm/trunk/hlvm/AST/AST.cpp
    hlvm/trunk/hlvm/AST/AST.h
    hlvm/trunk/hlvm/AST/Block.h
    hlvm/trunk/hlvm/AST/Bundle.cpp
    hlvm/trunk/hlvm/AST/Bundle.h
    hlvm/trunk/hlvm/AST/ControlFlow.h
    hlvm/trunk/hlvm/AST/Function.h
    hlvm/trunk/hlvm/AST/LinkageItem.h
    hlvm/trunk/hlvm/AST/Node.cpp
    hlvm/trunk/hlvm/AST/Node.h
    hlvm/trunk/hlvm/AST/Operator.cpp
    hlvm/trunk/hlvm/AST/Operator.h
    hlvm/trunk/hlvm/AST/Program.cpp
    hlvm/trunk/hlvm/AST/Program.h
    hlvm/trunk/hlvm/AST/Type.h
    hlvm/trunk/hlvm/Pass/Pass.cpp
    hlvm/trunk/hlvm/Pass/Validate.cpp
    hlvm/trunk/hlvm/Reader/XML/HLVM.rng
    hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
    hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
    hlvm/trunk/test/xml2xml/alias.hlx
    hlvm/trunk/test/xml2xml/array.hlx
    hlvm/trunk/test/xml2xml/bundle.hlx
    hlvm/trunk/test/xml2xml/doc.hlx
    hlvm/trunk/test/xml2xml/enumeration.hlx
    hlvm/trunk/test/xml2xml/intrinsics.hlx
    hlvm/trunk/test/xml2xml/pointer.hlx
    hlvm/trunk/test/xml2xml/resolve.hlx
    hlvm/trunk/test/xml2xml/signature.hlx
    hlvm/trunk/test/xml2xml/structure.hlx
    hlvm/trunk/test/xml2xml/var.hlx
    hlvm/trunk/test/xml2xml/vector.hlx

Modified: hlvm/trunk/build/hlvm.py
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build/hlvm.py?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/build/hlvm.py (original)
+++ hlvm/trunk/build/hlvm.py Sat Jul  7 18:59:57 2007
@@ -115,8 +115,8 @@
 
   if env['debug'] == 1 :
     VariantName += 'D'
-    env.Append(CCFLAGS=' -g')
-    env.Append(CXXFLAGS=' -g')
+    env.Append(CCFLAGS=' -ggdb')
+    env.Append(CXXFLAGS=' -ggdb')
     env.Append(CPPDEFINES={'HLVM_DEBUG':None})
   else :
     VariantName+='d'
@@ -133,8 +133,6 @@
     env.Append(CXXFLAGS=' -O3')
   else :
     VariantName+='o'
-    env.Append(CCFLAGS=' -O1')
-    env.Append(CXXFLAGS=' -O1')
 
   BuildDir = 'build.' + VariantName
   env['Variant'] = VariantName

Modified: hlvm/trunk/docs/RngToXHTML.xsl
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/docs/RngToXHTML.xsl?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/docs/RngToXHTML.xsl (original)
+++ hlvm/trunk/docs/RngToXHTML.xsl Sat Jul  7 18:59:57 2007
@@ -8,8 +8,12 @@
   xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
   exclude-result-prefixes="rng local a"
 >
+<xsl:output method="xml" index="yes" encoding="utf-8" omit-xml-declaration="no"
+  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+  doctype-public="//W3C//DTD XHTML 1.0 Strict//EN"
+/>
 <xsl:template match="/">
-<html>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
     <title>Relax NG Grammar Documentation</title>
@@ -17,13 +21,37 @@
   </head>
   <body>
     <h1>$X Grammar</h1>
-    <div class="contents">
-      <xsl:call-template name="start"/>
-    </div>
+    <xsl:apply-templates/>
   </body>
 </html>
 </xsl:template>
-<xsl:template name="start" match="/grammar/start">
-  <h2>Start Pattern: <xsl:copy-of select="./ref"/></h2>
+
+<xsl:template match="/grammar">
+  <div class="contents">
+    <ul>
+      <xsl:for-each select="start">
+        <li><a href="#{@name}"><xsl:value-of select="@name"/></a></li>
+      </xsl:for-each>
+      <xsl:for-each select="define">
+        <li><a href="#{@name}"><xsl:value-of select="@name"/></a></li>
+      </xsl:for-each>
+    </ul>
+  </div>
+  <div class="descriptions">
+    <xsl:apply-templates name="start"/>
+    <xsl:apply-templates select="define"/>
+  </div>
 </xsl:template>
+
+<xsl:template match="start">
+  <h2>Start Pattern: <xsl:value-of select="@name"/></h2>
+</xsl:template>
+
+<xsl:template name="toc" match="//define">
+  <li><a href="#{@name}"><xsl:value-of select="@name"/></a></li>
+</xsl:template>
+
+<xsl:template name="define" match="//define">
+</xsl:template>
+
 </xsl:transform>

Modified: hlvm/trunk/hlvm/AST/AST.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/AST.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.cpp (original)
+++ hlvm/trunk/hlvm/AST/AST.cpp Sat Jul  7 18:59:57 2007
@@ -29,11 +29,15 @@
 
 #include <hlvm/AST/AST.h>
 #include <hlvm/AST/Bundle.h>
+#include <hlvm/AST/Import.h>
 #include <hlvm/AST/Documentation.h>
 #include <hlvm/AST/ContainerType.h>
-#include <hlvm/AST/Function.h>
-#include <hlvm/AST/Import.h>
 #include <hlvm/AST/Variable.h>
+#include <hlvm/AST/Constants.h>
+#include <hlvm/AST/Function.h>
+#include <hlvm/AST/Program.h>
+#include <hlvm/AST/Block.h>
+#include <hlvm/AST/ControlFlow.h>
 #include <hlvm/AST/SymbolTable.h>
 
 using namespace hlvm;
@@ -122,15 +126,6 @@
   return result;
 }
 
-Function*
-AST::new_Function(const Locator& loc, const std::string& id)
-{
-  Function* result = new Function();
-  result->setLocator(loc);
-  result->setName(id);
-  return result;
-}
-
 Import*
 AST::new_Import(const Locator& loc, const std::string& pfx)
 {
@@ -327,6 +322,20 @@
   return result;
 }
 
+OpaqueType*
+AST::new_OpaqueType(const std::string& id)
+{
+  return new OpaqueType(id);
+}
+
+ConstLiteralInteger*
+AST::new_ConstLiteralInteger(const Locator& loc)
+{
+  ConstLiteralInteger* result = new ConstLiteralInteger();
+  result->setLocator(loc);
+  return result;
+}
+
 Variable*
 AST::new_Variable(const Locator& loc, const std::string& id)
 {
@@ -336,10 +345,38 @@
   return result;
 }
 
-OpaqueType*
-AST::new_OpaqueType(const std::string& id)
+Function*
+AST::new_Function(const Locator& loc, const std::string& id)
 {
-  return new OpaqueType(id);
+  Function* result = new Function();
+  result->setLocator(loc);
+  result->setName(id);
+  return result;
+}
+
+Program*
+AST::new_Program(const Locator& loc, const std::string& id)
+{
+  Program* result = new Program();
+  result->setLocator(loc);
+  result->setName(id);
+  return result;
+}
+
+Block*
+AST::new_Block(const Locator& loc)
+{
+  Block* result = new Block();
+  result->setLocator(loc);
+  return result;
+}
+
+ReturnOp*
+AST::new_ReturnOp(const Locator& loc)
+{
+  ReturnOp* result = new ReturnOp();
+  result->setLocator(loc);
+  return result;
 }
 
 Documentation* 

Modified: hlvm/trunk/hlvm/AST/AST.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/AST.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.h (original)
+++ hlvm/trunk/hlvm/AST/AST.h Sat Jul  7 18:59:57 2007
@@ -41,7 +41,9 @@
 
 class Bundle;   
 class Documentation;
+class Block;
 class Function; 
+class Program; 
 class Import;
 class Locator; 
 class SignatureType;
@@ -63,6 +65,8 @@
 class SignatureType;
 class OpaqueType;
 class EnumerationType;
+class ConstLiteralInteger;
+class ReturnOp;
 
 /// This class is used to hold or contain an Abstract Syntax Tree. It provides
 /// those aspects of the tree that are not part of the tree itself.
@@ -129,6 +133,9 @@
   public:
     Bundle* new_Bundle(const Locator& loc, const std::string& id);
     Function* new_Function(const Locator& loc, const std::string& id);
+    ReturnOp* new_ReturnOp(const Locator& loc);
+    Block* new_Block(const Locator& loc);
+    Program* new_Program(const Locator& loc, const std::string& id);
     Import* new_Import(const Locator& loc, const std::string& id);
     Variable* new_Variable(const Locator& loc, const std::string& id);
     IntegerType* new_IntegerType(
@@ -222,6 +229,7 @@
     IntegerType* new_u8(const Locator& l, const std::string& id)
       { return new_IntegerType(l,id,8,false); }
 
+    ConstLiteralInteger* new_ConstLiteralInteger(const Locator& loc);
     Documentation* new_Documentation(const Locator& loc);
 
   /// @}

Modified: hlvm/trunk/hlvm/AST/Block.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Block.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Block.h (original)
+++ hlvm/trunk/hlvm/AST/Block.h Sat Jul  7 18:59:57 2007
@@ -53,11 +53,22 @@
   /// @name Accessors
   /// @{
   public:
+    const std::string& getLabel() const { return label; }
     static inline bool classof(const Block*) { return true; }
     static inline bool classof(const Operator* O) { return O->isBlock(); }
     static inline bool classof(const Node* N) { return N->isBlock(); }
 
   /// @}
+  /// @name Mutators
+  /// @{
+  public:
+    void setLabel(const std::string& l) { label = l; }
+  /// @}
+  /// @name Data
+  /// @{
+  public:
+    std::string label;
+  /// @}
   friend class AST;
 };
 

Modified: hlvm/trunk/hlvm/AST/Bundle.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Bundle.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.cpp (original)
+++ hlvm/trunk/hlvm/AST/Bundle.cpp Sat Jul  7 18:59:57 2007
@@ -60,7 +60,7 @@
   else if (kid->isFunction())
     funcs.push_back(cast<Function>(kid));
   else
-    hlvmAssert(isa<LinkageItem>(kid) && "Can't insert that here");
+    hlvmAssert("Don't know how to insert that in a Bundle");
 }
 
 void

Modified: hlvm/trunk/hlvm/AST/Bundle.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Bundle.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.h (original)
+++ hlvm/trunk/hlvm/AST/Bundle.h Sat Jul  7 18:59:57 2007
@@ -45,7 +45,7 @@
 /// a Bundle. Bundles can also be nested in other Bundles. All programming
 /// constructs are defined as child nodes of some Bundle.
 /// @brief HLVM AST Bundle Node
-class Bundle : public NamedNode
+class Bundle : public Documentable
 {
   /// @name Types
   /// @{
@@ -69,13 +69,14 @@
     static Bundle* create(const Locator& location, const std::string& pubid);
 
   protected:
-    Bundle() : NamedNode(BundleID) {}
+    Bundle() : Documentable(BundleID), name(), types(), vars(), funcs() {}
     virtual ~Bundle();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
+    const std::string& getName() const { return name; }
     static inline bool classof(const Bundle*) { return true; }
     static inline bool classof(const Node* N) { return N->isBundle(); }
 
@@ -83,6 +84,7 @@
   /// @name Mutators
   /// @{
   public:
+    void setName(const std::string& n) { name = n; }
     virtual void insertChild(Node* kid);
     virtual void removeChild(Node* kid);
 
@@ -126,9 +128,10 @@
   /// @name Data
   /// @{
   protected:
-    TypeList    types;  ///< The vector of children nodes.
-    VarList     vars;
-    FuncList    funcs;
+    std::string name;   ///< The name for this bundle
+    TypeList    types;  ///< The list of types
+    VarList     vars;   ///< The list of variables
+    FuncList    funcs;  ///< The list of functions
   /// @}
   friend class AST;
 };

Added: hlvm/trunk/hlvm/AST/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Constants.cpp?rev=38114&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/Constants.cpp (added)
+++ hlvm/trunk/hlvm/AST/Constants.cpp Sat Jul  7 18:59:57 2007
@@ -0,0 +1,54 @@
+//===-- AST Constant Expression Operators -----------------------*- 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/AST/Constants.cpp
+/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
+/// @date 2006/05/24
+/// @since 0.1.0
+/// @brief Implements the classes that provide constant expressions
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/AST/Constants.h>
+
+namespace hlvm {
+
+ConstLiteralInteger::~ConstLiteralInteger()
+{
+}
+
+ConstLiteralInteger* 
+ConstLiteralInteger::create()
+{
+  return new ConstLiteralInteger;
+}
+
+ConstLiteralString::~ConstLiteralString()
+{
+}
+
+ConstLiteralString* 
+ConstLiteralString::create()
+{
+  return new ConstLiteralString;
+}
+
+}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Constants.h (added)
+++ hlvm/trunk/hlvm/AST/Constants.h Sat Jul  7 18:59:57 2007
@@ -0,0 +1,112 @@
+//===-- AST Constant Expression Operators -----------------------*- 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/AST/Constants.h
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/05/25
+/// @since 0.1.0
+/// @brief Declares the AST Constant Expression Operators 
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_AST_CONSTANTS_H
+#define HLVM_AST_CONSTANTS_H
+
+#include <hlvm/AST/Operator.h>
+
+namespace hlvm 
+{
+
+/// This class represents an operator that yields a literal constant integer 
+/// value.
+/// @brief HLVM AST Constant Integer Node
+class ConstLiteralInteger : public NilaryOperator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    static ConstLiteralInteger* create();
+
+  protected:
+    ConstLiteralInteger() : NilaryOperator(ConstLiteralIntegerOpID)  {}
+    virtual ~ConstLiteralInteger();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    uint64_t getValue() { return value; }
+    static inline bool classof(const ConstLiteralInteger*) { return true; }
+    static inline bool classof(const Node* N) 
+      { return N->is(ConstLiteralIntegerOpID); }
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    void setValue(uint64_t v) { value = v; }
+
+  /// @}
+  /// @name Data
+  /// @{
+  public:
+    uint64_t value;
+  /// @}
+  friend class AST;
+};
+
+class ConstLiteralString : public NilaryOperator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    static ConstLiteralString* create();
+
+  protected:
+    ConstLiteralString() : NilaryOperator(ConstLiteralStringOpID)  {}
+    virtual ~ConstLiteralString();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    const std::string&  getValue() { return value; }
+    static inline bool classof(const ConstLiteralString*) { return true; }
+    static inline bool classof(const Node* N) 
+      { return N->is(ConstLiteralStringOpID); }
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    void setValue(const std::string& v ) { value = v; }
+
+  /// @}
+  /// @name Data
+  /// @{
+  public:
+    std::string value;
+  /// @}
+  friend class AST;
+};
+
+} // hlvm 
+#endif

Added: hlvm/trunk/hlvm/AST/ControlFlow.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/ControlFlow.cpp?rev=38114&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/ControlFlow.cpp (added)
+++ hlvm/trunk/hlvm/AST/ControlFlow.cpp Sat Jul  7 18:59:57 2007
@@ -0,0 +1,44 @@
+//===-- AST Control Flow Nodes ----------------------------------*- 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/AST/ControlFlow.cpp
+/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
+/// @date 2006/05/24
+/// @since 0.1.0
+/// @brief Implements the classes that provide program control flow
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/AST/ControlFlow.h>
+
+namespace hlvm {
+
+ReturnOp::~ReturnOp()
+{
+}
+
+ReturnOp* 
+ReturnOp::create()
+{
+  return new ReturnOp;
+}
+
+}

Modified: hlvm/trunk/hlvm/AST/ControlFlow.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/ControlFlow.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/ControlFlow.h (original)
+++ hlvm/trunk/hlvm/AST/ControlFlow.h Sat Jul  7 18:59:57 2007
@@ -59,6 +59,11 @@
     static inline bool classof(const Node* N) { return N->is(ReturnOpID); }
 
   /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    void setResult(Operator* op) { op->setParent(this); }
+  /// @}
   friend class AST;
 };
 

Modified: hlvm/trunk/hlvm/AST/Function.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Function.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Function.h (original)
+++ hlvm/trunk/hlvm/AST/Function.h Sat Jul  7 18:59:57 2007
@@ -68,8 +68,9 @@
   public:
     virtual void insertChild(Node* kid);
     virtual void removeChild(Node* kid);
-    //void setSignature(SignatureType* sig) { sig->Node::setParent(this); }
-    //void setBlock(Block* blk) { blk->Node::setParent(this); }
+    void setSignature(SignatureType* sig) { sig->setParent(this); }
+    void setBlock(Block* blk) { blk->setParent(this); }
+
   /// @}
   /// @name Data
   /// @{

Added: hlvm/trunk/hlvm/AST/InputOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/InputOutput.cpp?rev=38114&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/InputOutput.cpp (added)
+++ hlvm/trunk/hlvm/AST/InputOutput.cpp Sat Jul  7 18:59:57 2007
@@ -0,0 +1,64 @@
+//===-- AST Input and Output Nodes ------------------------------*- 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/AST/InputOutput.cpp
+/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
+/// @date 2006/05/24
+/// @since 0.1.0
+/// @brief Implements the functions of class hlvm::AST::InputOutput.
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/AST/InputOutput.h>
+
+namespace hlvm {
+
+OpenOp::~OpenOp()
+{
+}
+
+OpenOp* 
+OpenOp::create()
+{
+  return new OpenOp;
+}
+
+CloseOp::~CloseOp()
+{
+}
+
+CloseOp* 
+CloseOp::create()
+{
+  return new CloseOp;
+}
+
+WriteOp::~WriteOp()
+{
+}
+
+WriteOp* 
+WriteOp::create()
+{
+  return new WriteOp;
+}
+
+}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/InputOutput.h (added)
+++ hlvm/trunk/hlvm/AST/InputOutput.h Sat Jul  7 18:59:57 2007
@@ -0,0 +1,118 @@
+//===-- AST Input/Output Operators ------------------------------*- 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/AST/InputOutput.h
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/05/25
+/// @since 0.1.0
+/// @brief Declares the AST Input/Output classes (Open, Close, Write, Read,etc.)
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_AST_INPUTOUTPUT_H
+#define HLVM_AST_INPUTOUTPUT_H
+
+#include <hlvm/AST/Operator.h>
+
+namespace hlvm 
+{
+
+/// This node type represents a stream open operation. Streams can be files,
+/// sockets, or any other kind of sequential or random access media. The URL
+/// provided to the operator as its first operand determines what will get 
+/// opened and how.
+/// @brief HLVM AST Open Stream Operator
+class OpenOp : public UnaryOperator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    static OpenOp* create();
+
+  protected:
+    OpenOp() : UnaryOperator(OpenOpID)  {}
+    virtual ~OpenOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    static inline bool classof(const OpenOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(OpenOpID); }
+
+  /// @}
+  friend class AST;
+};
+
+/// This node type represents a stream close operation. The operand must be a
+/// value returned by the stream open operation. The associated stream is 
+/// flushed of data and closed permanently.
+/// @brief HLVM AST Close Stream Operator
+class CloseOp : public UnaryOperator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    static CloseOp* create();
+
+  protected:
+    CloseOp() : UnaryOperator(CloseOpID)  {}
+    virtual ~CloseOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    static inline bool classof(const CloseOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(CloseOpID); }
+
+  /// @}
+  friend class AST;
+};
+
+/// This node type represents a stream write operation. There are three 
+/// operands: [1] the stream to write, [2] the data buffer to write, [3] the
+/// length of the data buffer.
+/// @brief HLVM AST Write Stream Operator
+class WriteOp : public TernaryOperator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    static WriteOp* create();
+
+  protected:
+    WriteOp() : TernaryOperator(WriteOpID)  {}
+    virtual ~WriteOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    static inline bool classof(const WriteOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(WriteOpID); }
+
+  /// @}
+  friend class AST;
+};
+
+} // hlvm 
+#endif

Modified: hlvm/trunk/hlvm/AST/LinkageItem.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItem.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItem.h (original)
+++ hlvm/trunk/hlvm/AST/LinkageItem.h Sat Jul  7 18:59:57 2007
@@ -37,7 +37,7 @@
 
 /// This enumeration is used to specify the kinds of linkage that are
 /// permitted for a LinkageItem.
-enum LinkageTypes {
+enum LinkageKinds {
   ExternalLinkage,    ///< Externally visible item
   InternalLinkage,    ///< Rename collisions when linking (static funcs)
   LinkOnceLinkage,    ///< Keep one copy of item when linking (inline)
@@ -50,32 +50,36 @@
 /// elsewhere and linked into another bundle to resolve the reference. The
 /// LinkageItem declares what kind of linkage is to be performed.
 /// @brief HLVM AST Bundle Node
-class LinkageItem : public NamedNode
+class LinkageItem : public Value
 {
   /// @name Constructors
   /// @{
   protected:
-    LinkageItem(
-      NodeIDs id ///< Subclass's node identifier
-    ) : NamedNode(id) {}
+    LinkageItem( NodeIDs id ) : Value(id), kind(InternalLinkage), name() {}
   public:
     virtual ~LinkageItem();
 
   /// @}
-  /// @name Mutators
+  /// @name Accessors
   /// @{
   public:
+    inline const std::string& getName() { return name; }
+    inline LinkageKinds getLinkageKind() { return kind; }
     static inline bool classof(const LinkageItem*) { return true; }
     static inline bool classof(const Node* N) { return N->isLinkageItem(); }
+
   /// @}
   /// @name Mutators
   /// @{
+    void setName(const std::string& n) { name = n; }
+    void setLinkageKind(LinkageKinds k) { kind = k; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    LinkageTypes type_; ///< The type of linkage to perform for this item
+    LinkageKinds kind; ///< The type of linkage to perform for this item
+    std::string name;
   /// @}
   friend class AST;
 };

Added: hlvm/trunk/hlvm/AST/MemoryOps.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/MemoryOps.cpp?rev=38114&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/MemoryOps.cpp (added)
+++ hlvm/trunk/hlvm/AST/MemoryOps.cpp Sat Jul  7 18:59:57 2007
@@ -0,0 +1,35 @@
+//===-- HLVM AST String Operators -------------------------------*- 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/AST/StringOps.cpp
+/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
+/// @date 2006/05/18
+/// @since 0.1.0
+/// @brief Implements the various AST string operators.
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/AST/StringOps.h>
+
+namespace hlvm {
+
+
+}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/MemoryOps.h (added)
+++ hlvm/trunk/hlvm/AST/MemoryOps.h Sat Jul  7 18:59:57 2007
@@ -0,0 +1,107 @@
+//===-- HLVM AST Memory Operations ------------------------------*- 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/AST/MemoryOps.h
+/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
+/// @date 2006/05/18
+/// @since 0.1.0
+/// @brief Provides the interface to the HLVM memory operations.
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_AST_MEMORYOPS_H
+#define HLVM_AST_MEMORYOPS_H
+
+#include <hlvm/AST/Operator.h>
+
+namespace hlvm
+{
+
+/// This operator represents the load operation for loading a variable into a
+/// register.
+/// @brief HLVM AST Memory Load Operator
+class LoadOp : public UnaryOperator
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    LoadOp() : UnaryOperator(LoadOpID) {}
+
+  public:
+    virtual ~LoadOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    static inline bool classof(const LoadOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(LoadOpID); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+  public:
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+  /// @}
+  friend class AST;
+};
+
+/// This operator represents the 
+/// @brief HLVM AST String Insert Node
+class LoadOp : public UnaryOperator
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    LoadOp() : UnaryOperator(LoadOpID) {}
+
+  public:
+    virtual ~LoadOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    static inline bool classof(const LoadOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(LoadOpID); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+  public:
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+  /// @}
+  friend class AST;
+};
+} // hlvm
+
+#endif
+namespace hlvm {
+
+}

Modified: hlvm/trunk/hlvm/AST/Node.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.cpp (original)
+++ hlvm/trunk/hlvm/AST/Node.cpp Sat Jul  7 18:59:57 2007
@@ -36,18 +36,6 @@
 {
 }
 
-bool 
-Node::isNamedNode() const
-{
-  return isType() || isBundle() || isFunction() || isProgram() || isVariable();
-}
-
-bool 
-Node::isLinkageItem() const
-{
-  return isFunction() || isType() || isProgram() || isVariable();
-}
-
 
 void 
 Node::insertChild(Node* child)
@@ -93,7 +81,7 @@
 {
 }
 
-NamedNode::~NamedNode()
+Value::~Value()
 {
 }
 

Modified: hlvm/trunk/hlvm/AST/Node.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul  7 18:59:57 2007
@@ -37,6 +37,7 @@
 namespace hlvm
 {
 
+class Type;
 class Documentation;
 
 /// This enumeration is used to identify a specific type. Its organization is
@@ -45,152 +46,155 @@
 /// group things by inheritance rather than by function. 
 enum NodeIDs 
 {
-  NoTypeID = 0,       ///< Use this for an invalid type ID.
+  NoTypeID = 0,            ///< Use this for an invalid type ID.
   // Primitive Types (no child nodes)
-  VoidTypeID = 1,     ///< The Void Type (The Null Type)
-  AnyTypeID,          ///< The Any Type (Union of any type)
-  BooleanTypeID,      ///< The Boolean Type (A simple on/off boolean value)
-  CharacterTypeID,    ///< The Character Type (UTF-16 encoded character)
-  OctetTypeID,        ///< The Octet Type (8 bits uninterpreted)
-  IntegerTypeID,      ///< The Integer Type (A number of bits of integer data)
-  RangeTypeID,        ///< The Range Type (A Range of Integer Values)
-  EnumerationTypeID,  ///< The Enumeration Type (set of enumerated ids)
-  RealTypeID,         ///< The Real Number Type (Any Real Number)
-  RationalTypeID,     ///< The Rational Number Type (p/q type number)
-  StringTypeID,       ///< The String Type (Array of UTF-16 chars + length)
+  VoidTypeID = 1,          ///< The Void Type (The Null Type)
+  AnyTypeID,               ///< The Any Type (Union of any type)
+  BooleanTypeID,           ///< The Boolean Type (A simple on/off boolean value)
+  CharacterTypeID,         ///< The Character Type (UTF-16 encoded character)
+  OctetTypeID,             ///< The Octet Type (8 bits uninterpreted)
+  IntegerTypeID,           ///< The Integer Type (A # of bits of integer data)
+  RangeTypeID,             ///< The Range Type (A Range of Integer Values)
+  EnumerationTypeID,       ///< The Enumeration Type (set of enumerated ids)
+  RealTypeID,              ///< The Real Number Type (Any Real Number)
+  RationalTypeID,          ///< The Rational Number Type (p/q type number)
+  StringTypeID,            ///< The String Type (Array of UTF-16 chars + length)
 
   // Container Types
-  AliasTypeID,        ///< A new name for an existing type
-  PointerTypeID,      ///< The Pointer Type (Pointer To storage of other Type)
-  ArrayTypeID,        ///< The Array Type (Linear array of some type)
-  VectorTypeID,       ///< The Vector Type (Packed Fixed Size Vector)
-  StructureTypeID,    ///< The Structure Type (Sequence of various types)
-  SignatureTypeID,    ///< The Function Signature Type
-  ContinuationTypeID, ///< A Continuation Type (data passing to continuations)
-  OpaqueTypeID,       ///< A placeholder for unresolved types
+  AliasTypeID,             ///< A new name for an existing type
+  PointerTypeID,           ///< The Pointer Type (Pointer To object of Type)
+  ArrayTypeID,             ///< The Array Type (Linear array of some type)
+  VectorTypeID,            ///< The Vector Type (Packed Fixed Size Vector)
+  StructureTypeID,         ///< The Structure Type (Sequence of various types)
+  SignatureTypeID,         ///< The Function Signature Type
+  ContinuationTypeID,      ///< A Continuation Type (data to continuations)
+  OpaqueTypeID,            ///< A placeholder for unresolved types
 
   // Class Constructs (TBD)
-  InterfaceID,        ///< The Interface Type (set of Signatures)
-  ClassID,            ///< The Class Type (Object Oriented Class Definition)
-  MethodID,           ///< The Method Node (define a method)
-  ImplementsID,       ///< Specifies set of Interfaces implemented by class
+  InterfaceID,             ///< The Interface Type (set of Signatures)
+  ClassID,                 ///< The Class Type (OO Class Definition)
+  MethodID,                ///< The Method Node (define a method)
+  ImplementsID,            ///< Specifies set of Interfaces implemented by class
 
   // Linkage Items
-  VariableID,         ///< The Variable Node (a storage location)
-  FunctionID,         ///< The Function Node (a callable function)
-  ProgramID,          ///< The Program Node (a program starting point)
+  VariableID,              ///< The Variable Node (a storage location)
+  FunctionID,              ///< The Function Node (a callable function)
+  ProgramID,               ///< The Program Node (a program starting point)
 
   // Container
-  BundleID,           ///< The Bundle Node (a group of other declarations)
-  BlockID,            ///< A Block Of Code Nodes
-  ImportID,           ///< A bundle's Import declaration
+  BundleID,                ///< The Bundle Node (a group of other declarations)
+  BlockID,                 ///< A Block Of Code Nodes
+  ImportID,                ///< A bundle's Import declaration
 
   // Nilary Operators (those taking no operands)
-  BreakOpID,          ///< Break out of the enclosing loop
-  PInfOpID,           ///< Constant Positive Infinity Real Value
-  NInfOpID,           ///< Constant Negative Infinity Real Value
-  NaNOpID,            ///< Constant Not-A-Number Real Value
+  BreakOpID,               ///< Break out of the enclosing loop
+  ConstLiteralIntegerOpID, ///< Constant Literal Integer
+  ConstLiteralRealOpID,    ///< Constant Literal Real
+  ConstLiteralStringOpID,  ///< Constant Literal String
+  PInfOpID,                ///< Constant Positive Infinity Real Value
+  NInfOpID,                ///< Constant Negative Infinity Real Value
+  NaNOpID,                 ///< Constant Not-A-Number Real Value
 
   // Control Flow Unary Operators
-  ReturnOpID,         ///< The Return A Value Operator
-  ThrowOpID,          ///< The Throw an Exception Operator
-  JumpToOpID,         ///< The Jump To Labelled Block Operator
+  ReturnOpID,              ///< The Return A Value Operator
+  ThrowOpID,               ///< The Throw an Exception Operator
+  JumpToOpID,              ///< The Jump To Labelled Block Operator
 
   // Integer Arithmetic Unary Operators
-  NegateOpID,         ///< The Negation Unary Integer Operator
-  ComplementOpID,     ///< The Bitwise Complement Unary Integer Operator
-  PreIncrOpID,        ///< The Pre-Increment Unary Integer Operator
-  PostIncrOpID,       ///< The Post-Increment Unary Integer Operator
-  PreDecrOpID,        ///< The Pre-Decrement Unary Integer Operator
-  PostDecrOpID,       ///< The Post-Decrement Unary Integer Operator
+  NotOpID,                 ///< Not Unary Boolean Operator
+  NegateOpID,              ///< Negation Unary Integer Operator
+  ComplementOpID,          ///< Bitwise Complement Unary Integer Operator
+  PreIncrOpID,             ///< Pre-Increment Unary Integer Operator
+  PostIncrOpID,            ///< Post-Increment Unary Integer Operator
+  PreDecrOpID,             ///< Pre-Decrement Unary Integer Operator
+  PostDecrOpID,            ///< Post-Decrement Unary Integer Operator
 
   // Real Arithmetic Unary Operators
-  IsPInfOpID,         ///< Real Number Positive Infinity Test Operator
-  IsNInfOpID,         ///< Real Number Negative Infinity Test Operator
-  IsNaNOpID,          ///< Real Number Not-A-Number Test Operator
-  TruncOpID,          ///< Real Number Truncation Operator
-  RoundOpID,          ///< Real Number Rounding Operator
-  FloorOpID,          ///< Real Number Floor Operator
-  CeilingOpID,        ///< Real Number Ceiling Operator
-  LogEOpID,           ///< Real Number Base e (Euler's Number) logarithm 
-  Log2OpID,           ///< Real Number Base 2 logarithm Operator
-  Log10OpID,          ///< Real Number Base 10 logarithm Operator
-  SqRootOpID,         ///< Real Number Square Root Operator
-  FactorialOpID,      ///< Real Number Factorial Operator
+  IsPInfOpID,              ///< Real Number Positive Infinity Test Operator
+  IsNInfOpID,              ///< Real Number Negative Infinity Test Operator
+  IsNaNOpID,               ///< Real Number Not-A-Number Test Operator
+  TruncOpID,               ///< Real Number Truncation Operator
+  RoundOpID,               ///< Real Number Rounding Operator
+  FloorOpID,               ///< Real Number Floor Operator
+  CeilingOpID,             ///< Real Number Ceiling Operator
+  LogEOpID,                ///< Real Number Base e (Euler's Number) logarithm 
+  Log2OpID,                ///< Real Number Base 2 logarithm Operator
+  Log10OpID,               ///< Real Number Base 10 logarithm Operator
+  SqRootOpID,              ///< Real Number Square Root Operator
+  FactorialOpID,           ///< Real Number Factorial Operator
 
   // Memory Unary Operators
-  LoadOpID,           ///< The Load Operator (load a value from a location)
-  AllocateOpID,       ///< The Allocate Memory Operator (get some heap memory)
-  FreeOpID,           ///< The Free Memory Operator (free some heap memory)
-  StackAllocOpID,     ///< The Stack Allocation Operator (get some stack mem)
-  ReferenceOpID,      ///< The Reference A Memory Object Operator (for GC)
-  DereferenceOpID,    ///< The Dereference A Memory Object Operator (for GC)
+  LoadOpID,                ///< The Load Operator (load a value from a location)
+  AllocateOpID,            ///< The Allocate Memory Operator (get some heap memory)
+  FreeOpID,                ///< The Free Memory Operator (free some heap memory)
+  StackAllocOpID,          ///< The Stack Allocation Operator (get some stack mem)
+  ReferenceOpID,           ///< The Reference A Memory Object Operator (for GC)
+  DereferenceOpID,         ///< The Dereference A Memory Object Operator (for GC)
 
   // Other Unary Operators
-  TellOpID,           ///< Tell the position of a stream
-  CloseOpID,          ///< Close a stream previously opened.
-  LengthOpID,         ///< Extract Length of a String Operator
-  WithOpID,           ///< Scoping Operator (shorthand for a Bundle, e.g.using) 
+  TellOpID,                ///< Tell the position of a stream
+  CloseOpID,               ///< Close a stream previously opened.
+  LengthOpID,              ///< Extract Length of a String Operator
+  WithOpID,                ///< Scoping Operator (shorthand for a Bundle, e.g.using) 
 
   // Arithmetic Binary Operators
-  AddOpID,            ///< The Addition Binary Integer Operator
-  SubtractOpID,       ///< The Subtraction Binary Integer Operator
-  MultiplyOpID,       ///< The Multiplcation Binary Integer Operator
-  DivideOpID,         ///< The Division Binary Integer Operator
-  ModulusOpID,        ///< The Modulus Binary Integer Operator
-  BAndOpID,           ///< The Bitwise And Binary Integer Operator
-  BOrOpID,            ///< The Bitwise Or Binary Integer Operator
-  BXOrOpID,           ///< The Bitwise XOr Binary Integer Operator
+  AddOpID,                 ///< Addition Binary Operator
+  SubtractOpID,            ///< Subtraction Binary Operator
+  MultiplyOpID,            ///< Multiplcation Binary Operator
+  DivideOpID,              ///< Division Binary Operator
+  ModulusOpID,             ///< Modulus Binary Operator
+  BAndOpID,                ///< Bitwise And Binary Operator
+  BOrOpID,                 ///< Bitwise Or Binary Operator
+  BXOrOpID,                ///< Bitwise XOr Binary Operator
 
   // Boolean Binary Operators
-  AndOpID,            ///< The And Binary Boolean Operator
-  OrOpID,             ///< The Or Binary Boolean Operator
-  NorOpID,            ///< The Nor Binary Boolean Operator
-  XorOpID,            ///< The Xor Binary Boolean Operator
-  NotOpID,            ///< The Not Unary Boolean Operator
-  LTOpID,             ///< The less-than Binary Boolean Operator
-  GTOpID,             ///< The greater-than Binary Boolean Operator
-  LEOpID,             ///< The less-than-or-equal Binary Boolean Operator
-  GEOpID,             ///< The greather-than-or-equal Binary Boolean Operator
-  EQOpID,             ///< The esual Binary Boolean Operator
-  NEOpID,             ///< The not-equal Binary Comparison Operator
+  AndOpID,                 ///< And Binary Boolean Operator
+  OrOpID,                  ///< Or Binary Boolean Operator
+  NorOpID,                 ///< Nor Binary Boolean Operator
+  XorOpID,                 ///< Xor Binary Boolean Operator
+  LTOpID,                  ///< <  Binary Comparison Operator
+  GTOpID,                  ///< >  Binary Comparison Operator
+  LEOpID,                  ///< <= Binary Comparison Operator
+  GEOpID,                  ///< >= Binary Comparison Operator
+  EQOpID,                  ///< == Binary Comparison Operator
+  NEOpID,                  ///< != Binary Comparison Operator
 
   // Real Arithmetic Binary Operators
-  PowerOpID,          ///< Real Number Power Operator
-  RootOpID,           ///< Real Number Arbitrary Root Operator
-  GCDOpID,            ///< Real Number Greatest Common Divisor Operator
-  LCMOpID,            ///< Real Number Least Common Multiplicator Operator
+  PowerOpID,               ///< Real Number Power Operator
+  RootOpID,                ///< Real Number Arbitrary Root Operator
+  GCDOpID,                 ///< Real Number Greatest Common Divisor Operator
+  LCMOpID,                 ///< Real Number Least Common Multiplicator Operator
   
   // Memory Binary Operators
-  ReallocateOpID,     ///< The Reallocate Memory Operator (realloc heap mem)
-  StoreOpID,          ///< The Store Operator (store a value to a location)
+  ReallocateOpID,          ///< The Reallocate Memory Operator 
+  StoreOpID,               ///< The Store Operator (store a value to a location)
 
   // Other Binary Operators
-  OpenOpID,           ///< Open a stream from a URL
-  ReadOpID,           ///< Read from a stream
-  WriteOpID,          ///< Write to a stream
-  CreateContOpID,     ///< The Create Continutation Operator
+  OpenOpID,                ///< Open a stream from a URL
+  ReadOpID,                ///< Read from a stream
+  WriteOpID,               ///< Write to a stream
+  CreateContOpID,          ///< The Create Continutation Operator
 
   // Ternary Operators
-  IfOpID,             ///< The If-Then-Else Operator
-  StrInsertOpID,      ///< Insert(str,where,what)
-  StrEraseOpID,       ///< Erase(str,at,len)
-  StrReplaceOpID,     ///< Replace(str,at,len,what)
-  PositionOpID,       ///< Position a stream (stream,where,relative-to)
+  IfOpID,                  ///< The If-Then-Else Operator
+  StrInsertOpID,           ///< Insert(str,where,what)
+  StrEraseOpID,            ///< Erase(str,at,len)
+  StrReplaceOpID,          ///< Replace(str,at,len,what)
+  PositionOpID,            ///< Position a stream (stream,where,relative-to)
 
   // Multi Operators
-  CallOpID,           ///< The Call Operator (n operands)
-  InvokeOpID,         ///< The Invoke Operator (n operands)
-  DispatchOpID,       ///< The Object Method Dispatch  Operator (n operands)
-  CallWithContOpID,   ///< The Call with Continuation Operator (n operands)
-  SelectOpID,         ///< The Select An Alternate Operator (n operands)
-  LoopOpID,           ///< The General Purpose Loop Operator (5 operands)
+  CallOpID,                ///< The Call Operator (n operands)
+  InvokeOpID,              ///< The Invoke Operator (n operands)
+  DispatchOpID,            ///< The Object Method Dispatch Operator (n operands)
+  CallWithContOpID,        ///< The Call with Continuation Operator (n operands)
+  SelectOpID,              ///< The Select An Alternate Operator (n operands)
+  LoopOpID,                ///< The General Purpose Loop Operator (5 operands)
 
   // Miscellaneous Nodes
-  DocumentationID,    ///< XHTML Documentation Node
+  DocumentationID,         ///< XHTML Documentation Node
 
   // Enumeration Ranges and Limits
-  NumNodeIDs,         ///< The number of node identifiers in the enum
+  NumNodeIDs,              ///< The number of node identifiers in the enum
   FirstPrimitiveTypeID = VoidTypeID, ///< First Primitive Type
   LastPrimitiveTypeID  = StringTypeID, ///< Last Primitive Type
   FirstContainerTypeID = PointerTypeID, ///< First Container Type
@@ -268,21 +272,24 @@
       return id >= FirstMultiOpID && id <= LastMultiOpID;
     }
 
-    /// Determine if the node is a NamedNode
-    bool isNamedNode() const ; 
-
     /// Determine if the node is a Documentable Node
-    bool isDocumentable() const;
+    bool isDocumentable() const { return isValue() || isType() || isBundle();}
 
     /// Determine if the node is a LinkageItem
-    bool isLinkageItem() const;
+    bool isLinkageItem() const {
+      return isFunction() || isVariable();
+    }
+
+    /// Determine if the node is a Value
+    bool isValue() const { return isLinkageItem() || isOperator(); }
 
     /// Determine if the node is a Block
     inline bool isBlock() const { return id == BlockID; }
     /// Determine if the node is a Bundle
     inline bool isBundle() const { return id == BundleID; }
     /// Determine if the node is a Function
-    inline bool isFunction() const { return id == FunctionID; }
+    inline bool isFunction() const 
+      { return id == FunctionID || id == ProgramID;}
     /// Determine if the node is a Program
     inline bool isProgram() const { return id == ProgramID; }
     /// Determine if the node is a Variable
@@ -356,36 +363,36 @@
   friend class AST;
 };
 
-class NamedNode : public Documentable 
+class Value : public Documentable
 {
   /// @name Constructors
   /// @{
   protected:
-    NamedNode(NodeIDs id) : Documentable(id), name() {}
+    Value(NodeIDs id) : Documentable(id), type(0)  {}
   public:
-    virtual ~NamedNode();
+    virtual ~Value();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    /// Get the name of the node
-    inline const std::string& getName() { return name; }
+    // Get the type of the value
+    inline const Type* getType() const { return type; }
 
-    static inline bool classof(const NamedNode*) { return true; }
-    static inline bool classof(const Node* N) { return N->isNamedNode(); }
+    static inline bool classof(const Value*) { return true; }
+    static inline bool classof(const Node* N) { return N->isValue(); }
 
   /// @}
   /// @name Mutators
   /// @{
   public:
-    void setName(const std::string& n) { name = n; }
+    void setType(const Type* t) { type = t; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    std::string name;  ///< The name of this node.
+    const Type* type; ///< The type of this node.
   /// @}
   friend class AST;
 };

Modified: hlvm/trunk/hlvm/AST/Operator.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.cpp (original)
+++ hlvm/trunk/hlvm/AST/Operator.cpp Sat Jul  7 18:59:57 2007
@@ -28,6 +28,10 @@
 //===----------------------------------------------------------------------===//
 
 #include <hlvm/AST/Operator.h>
+#include <hlvm/Base/Assert.h>
+#include <llvm/Support/Casting.h>
+
+using namespace llvm;
 
 namespace hlvm {
 
@@ -40,9 +44,27 @@
 }
 
 Operator*
-NilaryOperator::getOperand(unsigned idx)
+NilaryOperator::getOperand(unsigned idx) const
+{
+  hlvmAssert(!"Can't get operands from a NilaryOperator");
+}
+
+size_t  
+NilaryOperator::numOperands() const
+{
+  return 0;
+}
+
+void 
+NilaryOperator::insertChild(Node* child)
+{
+  hlvmAssert(!"NilaryOperators don't accept children");
+}
+
+void 
+NilaryOperator::removeChild(Node* child)
 {
-  assert(!"Can't get operands from a NilaryOperator");
+  hlvmAssert(!"Can't remove from a NilaryOperator");
 }
 
 UnaryOperator::~UnaryOperator()
@@ -50,43 +72,155 @@
 }
 
 Operator*
-UnaryOperator::getOperand(unsigned idx)
+UnaryOperator::getOperand(unsigned idx) const
 {
   assert(idx == 0 && "Operand index out of range");
   return op1;
 }
 
+size_t  
+UnaryOperator::numOperands() const
+{
+  return op1 != 0;
+}
+
+void 
+UnaryOperator::insertChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  if (!op1)
+    op1 = cast<Operator>(child);
+  else
+    hlvmAssert("UnaryOperator full");
+}
+
+void 
+UnaryOperator::removeChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  if (op1 == child) {
+    op1 = 0;
+  } else
+    hlvmAssert(!"Can't remove child from UnaryOperator");
+}
+
 BinaryOperator::~BinaryOperator()
 {
 }
 
 Operator*
-BinaryOperator::getOperand(unsigned idx)
+BinaryOperator::getOperand(unsigned idx) const
 {
   assert(idx <= 1 && "Operand index out of range");
   return ops[idx];
 }
 
+size_t  
+BinaryOperator::numOperands() const
+{
+  return (ops[0] ? 1 : 0) + (ops[1] ? 1 : 0);
+}
+
+void 
+BinaryOperator::insertChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  if (!ops[0])
+    ops[0] = cast<Operator>(child);
+  else if (!ops[1])
+    ops[1] = cast<Operator>(child);
+  else
+    hlvmAssert(!"BinaryOperator full!");
+}
+
+void 
+BinaryOperator::removeChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  if (ops[0] == child)
+    ops[0] = 0;
+  else if (ops[1] == child)
+    ops[1] = 0;
+  else
+    hlvmAssert(!"Can't remove child from BinaryOperator");
+}
+
 TernaryOperator::~TernaryOperator()
 {
 }
 
 Operator*
-TernaryOperator::getOperand(unsigned idx)
+TernaryOperator::getOperand(unsigned idx) const
 {
   assert(idx <= 2 && "Operand index out of range");
   return ops[idx];
 }
 
+size_t  
+TernaryOperator::numOperands() const
+{
+  return (ops[0] ? 1 : 0) + (ops[1] ? 1 : 0) + (ops[2] ? 1 : 0);
+}
+
+void 
+TernaryOperator::insertChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  if (!ops[0])
+    ops[0] = cast<Operator>(child);
+  else if (!ops[1])
+    ops[1] = cast<Operator>(child);
+  else if (!ops[2])
+    ops[2] = cast<Operator>(child);
+  else
+    hlvmAssert(!"TernaryOperator full!");
+}
+
+void 
+TernaryOperator::removeChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  if (ops[0] == child)
+    ops[0] = 0;
+  else if (ops[1] == child)
+    ops[1] = 0;
+  else if (ops[2] == child)
+    ops[2] = 0;
+  else
+    hlvmAssert(!"Can't remove child from TernaryOperator!");
+}
+
 MultiOperator::~MultiOperator()
 {
 }
 
 Operator*
-MultiOperator::getOperand(unsigned idx)
+MultiOperator::getOperand(unsigned idx) const
 {
   assert(idx <= ops.size() && "Operand index out of range");
   return ops[idx];
 }
 
+size_t  
+MultiOperator::numOperands() const
+{
+  return ops.size();
+}
+
+void 
+MultiOperator::insertChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  ops.push_back(cast<Operator>(child));
+}
+
+void 
+MultiOperator::removeChild(Node* child)
+{
+  hlvmAssert(isa<Operator>(child));
+  for (iterator I = begin(), E = end(); I != E; ++I ) {
+      if (*I == child) { ops.erase(I); return; }
+  }
+}
+
 }

Modified: hlvm/trunk/hlvm/AST/Operator.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.h (original)
+++ hlvm/trunk/hlvm/AST/Operator.h Sat Jul  7 18:59:57 2007
@@ -40,12 +40,12 @@
 /// This class is the abstract superclass for all Operators. It provides the
 /// methods and virtual signature that is common to all Operator nodes.
 /// @brief HLVM AST Abstract Operator Node
-class Operator : public Documentable
+class Operator : public Value
 {
   /// @name Constructors
   /// @{
   protected:
-    Operator(NodeIDs opID) : Documentable(opID)  {}
+    Operator(NodeIDs opID) : Value(opID)  {}
     virtual ~Operator();
 
   /// @}
@@ -53,7 +53,8 @@
   /// @{
   public:
     /// Get a specific operand of this operator.
-    virtual Operator* getOperand(unsigned opnum) = 0;
+    virtual size_t  numOperands() const = 0;
+    virtual Operator* getOperand(unsigned opnum) const = 0;
 
     /// Determine if this is a classof some other type.
     static inline bool classof(const Operator*) { return true; }
@@ -76,9 +77,17 @@
   /// @name Accessors
   /// @{
   public:
-    virtual Operator* getOperand(unsigned opnum);
+    virtual size_t  numOperands() const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const NilaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isNilaryOperator(); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+  protected:
+    virtual void insertChild(Node* child);
+    virtual void removeChild(Node* child);
   /// @}
   friend class AST;
 };
@@ -95,11 +104,19 @@
   /// @name Accessors
   /// @{
   public:
-    virtual Operator* getOperand(unsigned opnum);
+    virtual size_t  numOperands() const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const UnaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isUnaryOperator(); }
 
   /// @}
+  /// @name Mutators
+  /// @{
+  protected:
+    virtual void insertChild(Node* child);
+    virtual void removeChild(Node* child);
+
+  /// @}
   /// @name Data
   /// @{
   protected:
@@ -121,11 +138,19 @@
   /// @name Accessors
   /// @{
   public:
-    virtual Operator* getOperand(unsigned opnum);
+    virtual size_t  numOperands() const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const BinaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isBinaryOperator(); }
 
   /// @}
+  /// @name Mutators
+  /// @{
+  protected:
+    virtual void insertChild(Node* child);
+    virtual void removeChild(Node* child);
+
+  /// @}
   /// @name Data
   /// @{
   protected:
@@ -147,11 +172,19 @@
   /// @name Accessors
   /// @{
   public:
-    virtual Operator* getOperand(unsigned opnum);
+    virtual size_t  numOperands() const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const TernaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isTernaryOperator(); }
 
   /// @}
+  /// @name Mutators
+  /// @{
+  protected:
+    virtual void insertChild(Node* child);
+    virtual void removeChild(Node* child);
+
+  /// @}
   /// @name Data
   /// @{
   protected:
@@ -173,14 +206,15 @@
   /// @name Constructors
   /// @{
   protected:
-    MultiOperator(NodeIDs opID) : Operator(opID), ops(8) {}
+    MultiOperator(NodeIDs opID) : Operator(opID), ops() {}
     virtual ~MultiOperator();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    virtual Operator* getOperand(unsigned opnum);
+    virtual size_t  numOperands() const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const MultiOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isMultiOperator(); }
 
@@ -200,6 +234,15 @@
     const Operator*back()  const { return ops.back(); }
 
   /// @}
+  /// @name Mutators
+  /// @{
+  public:
+    void addOperand(Operator* op) { op->setParent(this); }
+  protected:
+    virtual void insertChild(Node* child);
+    virtual void removeChild(Node* child);
+
+  /// @}
   /// @name Data
   /// @{
   protected:

Modified: hlvm/trunk/hlvm/AST/Program.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Program.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Program.cpp (original)
+++ hlvm/trunk/hlvm/AST/Program.cpp Sat Jul  7 18:59:57 2007
@@ -30,17 +30,20 @@
 #include <hlvm/AST/Program.h>
 #include <hlvm/AST/ContainerType.h>
 
-namespace hlvm {
+using namespace hlvm;
 
-SignatureType* Program::initSignature() {
+namespace {
+SignatureType* initSignature() {
   SignatureType* result = new SignatureType();
   result->setName("_hlvm_ProgramSignature");
   return result;
 }
-SignatureType* Program::SignatureTy = Program::initSignature();
+}
+
+
+SignatureType* 
+Program::SignatureTy = initSignature();
 
 Program::~Program()
 {
 }
-
-}

Modified: hlvm/trunk/hlvm/AST/Program.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Program.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Program.h (original)
+++ hlvm/trunk/hlvm/AST/Program.h Sat Jul  7 18:59:57 2007
@@ -50,7 +50,8 @@
   /// @name Constructors
   /// @{
   public:
-    Program() : Function(ProgramID) {}
+    Program() : Function(ProgramID) 
+    { setSignature(SignatureTy); setLinkageKind(ExternalLinkage); }
     virtual ~Program();
 
   /// @}
@@ -58,6 +59,7 @@
   /// @{
   public:
     static inline bool classof(const Program*) { return true; }
+    static inline bool classof(const Function*F) { return F->isProgram(); }
     static inline bool classof(const Node* N) { return N->isProgram(); }
 
   /// @}
@@ -65,7 +67,7 @@
   /// @{
   private:
     static SignatureType* SignatureTy; ///< The signature for programs
-    static SignatureType* initSignature(); 
+    LinkageItem::setLinkageKind;
   /// @}
   friend class AST;
 };

Added: hlvm/trunk/hlvm/AST/StringOps.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/StringOps.cpp?rev=38114&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/StringOps.cpp (added)
+++ hlvm/trunk/hlvm/AST/StringOps.cpp Sat Jul  7 18:59:57 2007
@@ -0,0 +1,35 @@
+//===-- HLVM AST String Operators -------------------------------*- 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/AST/StringOps.cpp
+/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
+/// @date 2006/05/18
+/// @since 0.1.0
+/// @brief Implements the various AST string operators.
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/AST/StringOps.h>
+
+namespace hlvm {
+
+
+}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/StringOps.h (added)
+++ hlvm/trunk/hlvm/AST/StringOps.h Sat Jul  7 18:59:57 2007
@@ -0,0 +1,74 @@
+//===-- HLVM AST String Operations ------------------------------*- 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/AST/StringOps.h
+/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
+/// @date 2006/05/18
+/// @since 0.1.0
+/// @brief Provides the interface to class hlvm::AST::StringOps.
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_AST_STRINGOPS_H
+#define HLVM_AST_STRINGOPS_H
+
+#include <hlvm/AST/Operator.h>
+
+namespace hlvm
+{
+
+/// Represents the String insert operator.
+/// @brief HLVM AST String Insert Node
+class StrInsertOp : public TernaryOperator
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    StrInsertOp() : TernaryOperator(StrInsertOpID) {}
+
+  public:
+    virtual ~StrInsertOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    static inline bool classof(const StrInsertOp*) { return true; }
+    static inline bool classof(const Node* N) { return N->is(StrInsertOpID); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+  public:
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+  /// @}
+  friend class AST;
+};
+
+} // hlvm
+#endif
+namespace hlvm {
+
+}

Modified: hlvm/trunk/hlvm/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Type.h?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/AST/Type.h (original)
+++ hlvm/trunk/hlvm/AST/Type.h Sat Jul  7 18:59:57 2007
@@ -30,7 +30,7 @@
 #ifndef HLVM_AST_TYPE_H
 #define HLVM_AST_TYPE_H
 
-#include <hlvm/AST/LinkageItem.h>
+#include <hlvm/AST/Node.h>
 
 namespace hlvm 
 {
@@ -40,20 +40,19 @@
 /// This class represents a Type in the HLVM Abstract Syntax Tree.  
 /// A Type defines the format of storage. 
 /// @brief HLVM AST Type Node
-class Type : public LinkageItem
+class Type : public Documentable
 {
   /// @name Constructors
   /// @{
   protected:
-    Type(
-      NodeIDs id ///< The Type identifier
-    ) : LinkageItem(id)  {}
+    Type( NodeIDs id ) : Documentable(id)  {}
     virtual ~Type();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
+    const std::string& getName() const { return name; }
     virtual const char* getPrimitiveName() const;
     bool isPrimitive() const { return getPrimitiveName() != 0; }
 
@@ -85,6 +84,7 @@
 
     // Methods to support type inquiry via is, cast, dyn_cast
     static inline bool classof(const Type*) { return true; }
+    static inline bool classof(const Documentable* n) { return n->isType(); }
     static inline bool classof(const Node* n) { return n->isType(); }
 
   /// @}
@@ -96,10 +96,13 @@
     // again.
     virtual void insertChild(Node* n);
 
+    virtual void setName(const std::string n) { name = n; }
+
   /// @}
   /// @name Data
   /// @{
   protected:
+    std::string name;
   /// @}
   friend class AST;
 };
@@ -562,7 +565,7 @@
   /// @name Constructors
   /// @{
   public:
-    AliasType() : Type(AliasTypeID) {}
+    AliasType() : Type(AliasTypeID), type(0) {}
     virtual ~AliasType();
 
   /// @}
@@ -570,8 +573,6 @@
   /// @{
   public:
     virtual const char* getPrimitiveName() const;
-    // Get the name for the type
-    const std::string&  getName() const { return name; }
     
     // Get the type for the name
     Type *  getType() const { return type; }
@@ -584,9 +585,6 @@
   /// @name Mutators
   /// @{
   public:
-    // Set the name for the type
-    void setName(const std::string& n) { name = n; }
-    
     // Set the type for the name
     void setType(Type * t) { type = t; }
 
@@ -595,7 +593,6 @@
   /// @{
   protected:
     Type* type;
-    std::string name;
   /// @}
 };
 

Modified: hlvm/trunk/hlvm/Pass/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Pass/Pass.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Pass/Pass.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Pass.cpp Sat Jul  7 18:59:57 2007
@@ -107,6 +107,10 @@
 PassManagerImpl::runOn(Operator* op)
 {
   runPreOrder(op);
+  size_t limit = op->numOperands();
+  for (size_t i = 0; i < limit; ++i) {
+    runOn(op->getOperand(i));
+  }
   runPostOrder(op);
 }
 
@@ -115,6 +119,8 @@
 {
   runPreOrder(b);
   for (Block::iterator I = b->begin(), E = b->end(); I != E; ++I) {
+    if (!*I)
+      break;
     if (isa<Block>(*I))
       runOn(cast<Block>(*I)); // recurse!
     else

Modified: hlvm/trunk/hlvm/Pass/Validate.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Pass/Validate.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Pass/Validate.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Validate.cpp Sat Jul  7 18:59:57 2007
@@ -46,7 +46,7 @@
     ValidateImpl() : Pass(0,Pass::PostOrderTraversal) {}
     virtual void handle(Node* b,Pass::TraversalKinds k);
     inline void error(Node*n, const char* msg);
-    inline void validateName(NamedNode* n);
+    inline void validateName(Node*n, const std::string& name);
     inline void validateIntegerType(IntegerType* n);
     inline void validateRangeType(RangeType* n);
     inline void validateEnumerationType(EnumerationType* n);
@@ -70,17 +70,16 @@
 }
 
 inline void
-ValidateImpl::validateName(NamedNode* n)
+ValidateImpl::validateName(Node*n, const std::string& name)
 {
-  const std::string& name = n->getName();
   if (name.empty()) {
-    error(n,"Empty Name");
+    error(0,"Empty Name");
   }
 }
 inline void
 ValidateImpl::validateIntegerType(IntegerType* n)
 {
-  validateName(n);
+  validateName(n,n->getName());
   if (n->getBits() == 0) {
     error(n,"Invalid number of bits");
   }
@@ -164,7 +163,7 @@
     case BooleanTypeID:
     case CharacterTypeID:
     case OctetTypeID:
-      validateName(cast<NamedNode>(n));
+      validateName(n,cast<Type>(n)->getName());
       break; 
     case IntegerTypeID:
       validateIntegerType(cast<IntegerType>(n));
@@ -292,6 +291,7 @@
     case PInfOpID:
     case NInfOpID:
     case NaNOpID:
+    case ConstLiteralIntegerOpID:
       break; // Not implemented yet
     case DocumentationID:
       /// Nothing to validate (any doc is a good thing :)

Modified: hlvm/trunk/hlvm/Reader/XML/HLVM.rng
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/HLVM.rng?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/HLVM.rng (original)
+++ hlvm/trunk/hlvm/Reader/XML/HLVM.rng Sat Jul  7 18:59:57 2007
@@ -144,6 +144,7 @@
   <!-- HLVM PATTERN -->
   <define name="HLVM.elem">
     <element name="hlvm">
+      <attribute name="pubid"><data type="anyURI"/></attribute>
       <oneOrMore>
         <ref name="Bundle.elem"/>
       </oneOrMore>
@@ -154,33 +155,31 @@
 
   <define name="Bundle.elem">
     <element name="bundle">
-      <ref name="bundle.pat"/>
-    </element>
-  </define>
-
-  <define name="bundle.pat">
-    <attribute name="pubid"><data type="anyURI"/></attribute>
-    <ref name="Documentation.pat"/>
-    <optional>
+      <ref name="Named_Element.pat"/>
+      <ref name="Documentation.pat"/>
+      <optional>
+        <zeroOrMore>
+          <ref name="import.elem"/>
+        </zeroOrMore>
+      </optional>
       <zeroOrMore>
-        <ref name="import.elem"/>
+        <choice>
+          <ref name="Alias.elem"/>
+          <ref name="Array.elem"/>
+          <ref name="Atom.elem"/>
+          <ref name="Bundle.elem"/>
+          <ref name="Enumeration.elem"/>
+          <ref name="Function.elem"/>
+          <ref name="Pointer.elem"/>
+          <ref name="Structure.elem"/>
+          <ref name="Signature.elem"/>
+          <ref name="Vector.elem"/>
+          <ref name="Variable.elem"/>
+          <ref name="Function.elem"/>
+          <ref name="Program.elem"/>
+        </choice>
       </zeroOrMore>
-    </optional>
-    <zeroOrMore>
-      <choice>
-        <ref name="Alias.elem"/>
-        <ref name="Array.elem"/>
-        <ref name="Atom.elem"/>
-        <ref name="Bundle.elem"/>
-        <ref name="Enumeration.elem"/>
-        <ref name="Function.elem"/>
-        <ref name="Pointer.elem"/>
-        <ref name="Structure.elem"/>
-        <ref name="Signature.elem"/>
-        <ref name="Variable.elem"/>
-        <ref name="Vector.elem"/>
-      </choice>
-    </zeroOrMore>
+    </element>
   </define>
 
   <define name="import.elem">
@@ -399,16 +398,20 @@
     <element name="function">
       <ref name="Named_Typed_Element.pat"/>
       <optional>
-        <attribute name="symbol"><ref name="Identifier.type"/></attribute>
-      </optional>
-      <optional>
         <attribute name="linkage"><ref name="Linkage.type"/></attribute>
       </optional>
       <zeroOrMore>
-        <element name="var">
-          <ref name="Named_Typed_Element.pat"/>
-        </element>
+        <ref name="Block.elem"/>
       </zeroOrMore>
+    </element>
+  </define>
+
+  <define name="Program.elem">
+    <element name="program">
+      <ref name="Named_Element.pat"/>
+      <optional>
+        <attribute name="linkage"><ref name="Linkage.type"/></attribute>
+      </optional>
       <zeroOrMore>
         <ref name="Block.elem"/>
       </zeroOrMore>
@@ -420,6 +423,9 @@
       <optional>
         <attribute name="label"><ref name="Identifier.type"/></attribute>
       </optional>
+      <oneOrMore>
+        <ref name="Operator.pat"/>
+      </oneOrMore>
     </element>
   </define>
 
@@ -607,4 +613,26 @@
       </oneOrMore>
     </element>
   </define>
+
+  <!-- PATTERNS FOR OPERATORS -->
+
+  <define name="Operator.pat">
+    <choice>
+      <ref name="ControlFlowOps.pat"/>
+      <ref name="Literal.pat"/>
+    </choice>
+  </define>
+
+  <define name="ControlFlowOps.pat">
+    <choice>
+      <ref name="Return.elem"/>
+    </choice>
+  </define>
+
+  <define name="Return.elem">
+    <element name="ret">
+      <ref name="Operator.pat"/>
+    </element>
+  </define>
+
 </grammar>

Modified: hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp Sat Jul  7 18:59:57 2007
@@ -38,6 +38,9 @@
 #include <hlvm/AST/Function.h>
 #include <hlvm/AST/Import.h>
 #include <hlvm/AST/Variable.h>
+#include <hlvm/AST/Program.h>
+#include <hlvm/AST/Constants.h>
+#include <hlvm/AST/ControlFlow.h>
 #include <hlvm/Base/Assert.h>
 #include <libxml/parser.h>
 #include <libxml/relaxng.h>
@@ -87,7 +90,11 @@
   inline void handleParseError(xmlErrorPtr error);
   inline void handleValidationError(xmlErrorPtr error);
 
-  void                parseTree          ();
+  inline ConstLiteralInteger* parseBinary(xmlNodePtr& cur);
+  inline ConstLiteralInteger* parseOctal(xmlNodePtr& cur);
+  inline ConstLiteralInteger* parseDecimal(xmlNodePtr& cur);
+  inline ConstLiteralInteger* parseHexadecimal(xmlNodePtr& cur);
+  void           parseTree          ();
   AliasType*     parseAlias         (xmlNodePtr& cur);
   Type*          parseArray         (xmlNodePtr& cur);
   Type*          parseAtom          (xmlNodePtr& cur);
@@ -101,6 +108,10 @@
   Type*          parseSignature     (xmlNodePtr& cur);
   Variable*      parseVariable      (xmlNodePtr& cur);
   Type*          parseVector        (xmlNodePtr& cur);
+  ReturnOp*      parseReturn        (xmlNodePtr& cur);
+  Operator*      parseOperator      (xmlNodePtr& cur);
+  Block*         parseBlock         (xmlNodePtr& cur);
+  Program*       parseProgram       (xmlNodePtr& cur);
   inline xmlNodePtr   checkDoc(xmlNodePtr cur, Documentable* node);
 private:
 };
@@ -140,19 +151,47 @@
 }
 
 
+inline int 
+getToken(const xmlChar* name)
+{
+  return HLVMTokenizer::recognize(reinterpret_cast<const char*>(name));
+}
+
 inline bool 
-skipBlanks(xmlNodePtr &cur)
+skipBlanks(xmlNodePtr &cur, bool skipText = true)
 {
-  while (cur && 
-      (cur->type == XML_TEXT_NODE ||
-       cur->type == XML_COMMENT_NODE ||
-       cur->type == XML_PI_NODE))
-  {
-    cur = cur -> next;
+  while (cur) {
+    switch (cur->type) {
+      case XML_TEXT_NODE:
+        if (!skipText)
+          return true;
+        /* FALL THROUGH */
+      case XML_COMMENT_NODE:
+      case XML_PI_NODE:
+        break;
+      default:
+        return true;
+    }
+    cur = cur->next;
   }
   return cur != 0;
 }
 
+LinkageKinds
+recognize_LinkageKinds(const xmlChar* str)
+{
+  switch (getToken(str)) 
+  {
+    case TKN_weak      : return WeakLinkage;
+    case TKN_appending : return AppendingLinkage;
+    case TKN_external  : return ExternalLinkage;
+    case TKN_internal  : return InternalLinkage;
+    case TKN_linkonce  : return LinkOnceLinkage;
+    default:
+      hlvmDeadCode("Invalid Linkage Type");
+  }
+}
+
 uint64_t
 recognize_nonNegativeInteger(const char* str)
 {
@@ -165,6 +204,7 @@
   return ::atoll(str);
 }
 
+
 inline bool 
 recognize_boolean(const std::string& str)
 {
@@ -197,12 +237,6 @@
   return result;
 }
 
-inline int 
-getToken(const xmlChar* name)
-{
-  return HLVMTokenizer::recognize(reinterpret_cast<const char*>(name));
-}
-
 inline void 
 getNameType(xmlNodePtr& cur, std::string& name, std::string& type)
 {
@@ -210,6 +244,118 @@
   type = getAttribute(cur,"type");
 }
 
+inline ConstLiteralInteger*
+XMLReaderImpl::parseBinary(xmlNodePtr& cur)
+{
+  uint64_t value = 0;
+  xmlNodePtr child = cur->children;
+  if (child) skipBlanks(child,false);
+  while (child && child->type == XML_TEXT_NODE) {
+    const xmlChar* p = child->content;
+    while (*p != 0) {
+      value <<= 1;
+      hlvmAssert(*p == '1' || *p == '0');
+      value |= (*p++ == '1' ? 1 : 0);
+    }
+    child = child->next;
+  }
+  if (child) skipBlanks(child);
+  hlvmAssert(!child && "Illegal chlldren of <bin> element");
+  Locator loc(cur->line,0,&ast->getSystemID());
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  result->setValue(value);
+  return result;
+}
+
+inline ConstLiteralInteger*
+XMLReaderImpl::parseOctal(xmlNodePtr& cur)
+{
+  uint64_t value = 0;
+  xmlNodePtr child = cur->children;
+  if (child) skipBlanks(child,false);
+  while (child && child->type == XML_TEXT_NODE) {
+    const xmlChar* p = cur->content;
+    while (*p != 0) {
+      value <<= 3;
+      hlvmAssert(*p >= '0' || *p == '7');
+      value |= *p++ - '0';
+    }
+    child = child->next;
+  }
+  if (child) skipBlanks(child);
+  hlvmAssert(!child && "Illegal chlldren of <oct> element");
+  Locator loc(cur->line,0,&ast->getSystemID());
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  result->setValue(value);
+  return result;
+}
+
+inline ConstLiteralInteger*
+XMLReaderImpl::parseDecimal(xmlNodePtr& cur)
+{
+  uint64_t value = 0;
+  xmlNodePtr child = cur->children;
+  if (child) skipBlanks(child,false);
+  while (child && child->type == XML_TEXT_NODE) {
+    const xmlChar* p = child->content;
+    while (*p != 0) {
+      value *= 10;
+      hlvmAssert(*p >= '0' || *p <= '9');
+      value |= *p++ - '0';
+    }
+    child = child->next;
+  }
+  if (child) skipBlanks(child);
+  hlvmAssert(!child && "Illegal chlldren of <dec> element");
+  Locator loc(cur->line,0,&ast->getSystemID());
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  result->setValue(value);
+  return result;
+}
+
+inline ConstLiteralInteger*
+XMLReaderImpl::parseHexadecimal(xmlNodePtr& cur)
+{
+  uint64_t value = 0;
+  xmlNodePtr child = cur->children;
+  if (child) skipBlanks(child,false);
+  while (child && child->type == XML_TEXT_NODE) {
+    const xmlChar* p = cur->content;
+    while (*p != 0) {
+      value <<= 4;
+      switch (*p) {
+        case '0': break;
+        case '1': value |= 1; break;
+        case '2': value |= 2; break;
+        case '3': value |= 3; break;
+        case '4': value |= 4; break;
+        case '5': value |= 5; break;
+        case '6': value |= 6; break;
+        case '7': value |= 7; break;
+        case '8': value |= 8; break;
+        case '9': value |= 9; break;
+        case 'a': case 'A': value |= 10; break;
+        case 'b': case 'B': value |= 11; break;
+        case 'c': case 'C': value |= 12; break;
+        case 'd': case 'D': value |= 13; break;
+        case 'e': case 'E': value |= 14; break;
+        case 'f': case 'F': value |= 15; break;
+        default:
+          hlvmAssert("Invalid hex digit");
+          break;
+      }
+      p++;
+    }
+    child = child->next;
+  }
+  if (child) skipBlanks(child);
+  hlvmAssert(!child && "Illegal chlldren of <hex> element");
+  Locator loc(cur->line,0,&ast->getSystemID());
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  result->setValue(value);
+  return result;
+}
+
 Documentation*
 XMLReaderImpl::parseDocumentation(xmlNodePtr& cur)
 {
@@ -245,18 +391,6 @@
   return child;
 }
 
-Function*
-XMLReaderImpl::parseFunction(xmlNodePtr& cur)
-{
-  hlvmAssert(getToken(cur->name)==TKN_function);
-  Locator loc(cur->line,0,&ast->getSystemID());
-  std::string name, type;
-  getNameType(cur, name, type);
-  Function* func = ast->new_Function(loc,name);
-  checkDoc(cur,func);
-  return func;
-}
-
 Import*
 XMLReaderImpl::parseImport(xmlNodePtr& cur)
 {
@@ -498,11 +632,92 @@
   return var;
 }
 
+ReturnOp*
+XMLReaderImpl::parseReturn(xmlNodePtr& cur)
+{
+  hlvmAssert(getToken(cur->name) == TKN_ret && "Expecting block element");
+  Locator loc(cur->line,0,&ast->getSystemID());
+  ReturnOp* ret = ast->new_ReturnOp(loc);
+  xmlNodePtr child = cur->children;
+  if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
+    Operator* op = parseOperator(child);
+    ret->setResult(op);
+  }
+  return ret;
+}
+
+Operator*
+XMLReaderImpl::parseOperator(xmlNodePtr& cur)
+{
+  int tkn = getToken(cur->name);
+  Operator* op = 0;
+  switch (tkn) {
+    case TKN_bin:          op = parseBinary(cur); break;
+    case TKN_oct:          op = parseOctal(cur); break;
+    case TKN_dec:          op = parseDecimal(cur); break;
+    case TKN_hex:          op = parseHexadecimal(cur); break;
+    case TKN_ret:          op = parseReturn(cur); break;
+    case TKN_block:        op = parseBlock(cur); break;
+    default:
+      hlvmDeadCode("Unrecognized operator");
+      break;
+  }
+  return op;
+}
+
+Block*
+XMLReaderImpl::parseBlock(xmlNodePtr& cur)
+{
+  hlvmAssert(getToken(cur->name) == TKN_block && "Expecting block element");
+  Locator loc(cur->line,0,&ast->getSystemID());
+  const char* label = getAttribute(cur, "label",false);
+  Block* block = ast->new_Block(loc);
+  if (label)
+    block->setLabel(label);
+  xmlNodePtr child = cur->children;
+  while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) 
+  {
+    Operator* op = parseOperator(child);
+    block->addOperand(op);
+    child = child->next;
+  }
+  return block;
+}
+
+Function*
+XMLReaderImpl::parseFunction(xmlNodePtr& cur)
+{
+  hlvmAssert(getToken(cur->name)==TKN_function);
+  Locator loc(cur->line,0,&ast->getSystemID());
+  std::string name, type;
+  getNameType(cur, name, type);
+  Function* func = ast->new_Function(loc,name);
+  checkDoc(cur,func);
+  return func;
+}
+
+Program*
+XMLReaderImpl::parseProgram(xmlNodePtr& cur)
+{
+  hlvmAssert(getToken(cur->name) == TKN_program && "Expecting program element");
+  Locator loc(cur->line,0,&ast->getSystemID());
+  std::string name(getAttribute(cur, "name"));
+  Program* program = ast->new_Program(loc,name);
+  xmlNodePtr child = cur->children;
+  if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
+    Block* b = parseBlock(child);
+    program->setBlock(b);
+  } else {
+    hlvmDeadCode("Program Without Block!");
+  }
+  return program;
+}
+
 Bundle*
 XMLReaderImpl::parseBundle(xmlNodePtr& cur) 
 {
   hlvmAssert(getToken(cur->name) == TKN_bundle && "Expecting bundle element");
-  std::string pubid(getAttribute(cur, "pubid"));
+  std::string pubid(getAttribute(cur, "name"));
   Locator loc(cur->line,0,&ast->getSystemID());
   Bundle* bundle = ast->new_Bundle(loc,pubid);
   xmlNodePtr child = cur->children;
@@ -519,7 +734,6 @@
       }
       case TKN_import   : { n = parseImport(child); break; }
       case TKN_bundle   : { n = parseBundle(child); break; }
-      case TKN_function : { n = parseFunction(child); break; }
       case TKN_alias    : { n = parseAlias(child); break; }
       case TKN_atom     : { n = parseAtom(child); break; }
       case TKN_enumeration: { n = parseEnumeration(child); break; }
@@ -529,6 +743,8 @@
       case TKN_structure: { n = parseStructure(child); break; }
       case TKN_signature: { n = parseSignature(child); break; }
       case TKN_var      : { n = parseVariable(child); break; }
+      case TKN_program  : { n = parseProgram(child); break; }
+      case TKN_function : { n = parseFunction(child); break; }
       default:
       {
         hlvmDeadCode("Invalid content for bundle");
@@ -551,6 +767,8 @@
     return;
   }
   hlvmAssert(getToken(cur->name) == TKN_hlvm && "Expecting hlvm element");
+  const std::string pubid = getAttribute(cur,"pubid");
+  ast->setPublicID(pubid);
   cur = cur->children;
   if (skipBlanks(cur)) {
     Bundle* bundle = parseBundle(cur);

Modified: hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp Sat Jul  7 18:59:57 2007
@@ -30,11 +30,14 @@
 #include <hlvm/Writer/XML/XMLWriter.h>
 #include <hlvm/AST/AST.h>
 #include <hlvm/AST/Bundle.h>
-#include <hlvm/AST/Documentation.h>
-#include <hlvm/AST/Function.h>
 #include <hlvm/AST/Import.h>
+#include <hlvm/AST/Documentation.h>
 #include <hlvm/AST/ContainerType.h>
 #include <hlvm/AST/Variable.h>
+#include <hlvm/AST/Program.h>
+#include <hlvm/AST/Block.h>
+#include <hlvm/AST/ControlFlow.h>
+#include <hlvm/AST/Constants.h>
 #include <hlvm/Base/Assert.h>
 #include <hlvm/Pass/Pass.h>
 #include <llvm/ADT/StringExtras.h>
@@ -88,14 +91,15 @@
       { xmlTextWriterWriteElement(writer,
           reinterpret_cast<const xmlChar*>(elem),
           reinterpret_cast<const xmlChar*>(body)); }
+    inline void writeString(const std::string& text)
+      { xmlTextWriterWriteString(writer,
+          reinterpret_cast<const xmlChar*>(text.c_str())); }
 
     inline void putHeader();
     inline void putFooter();
     inline void putDoc(Documentable* node);
     inline void put(Bundle* b);
     inline void put(Documentation* b);
-    inline void put(Variable* v);
-    inline void put(Function* f);
     inline void put(AliasType* t);
     inline void put(AnyType* t);
     inline void put(BooleanType* t);
@@ -111,6 +115,12 @@
     inline void put(VectorType* t);
     inline void put(StructureType* t);
     inline void put(SignatureType* t);
+    inline void put(ConstLiteralInteger* t);
+    inline void put(Variable* v);
+    inline void put(Function* f);
+    inline void put(Program* p);
+    inline void put(Block* f);
+    inline void put(ReturnOp* f);
 
     virtual void handle(Node* n,Pass::TraversalKinds mode);
 
@@ -123,6 +133,22 @@
   WriterPass pass;
 };
 
+inline const char* 
+getLinkageKind(LinkageKinds lk)
+{
+  switch (lk) {
+    case WeakLinkage:        return "weak";
+    case ExternalLinkage:    return "external";
+    case InternalLinkage:    return "internal";
+    case LinkOnceLinkage:    return "linkonce";
+    case AppendingLinkage:   return "appending";
+    default:
+      hlvmDeadCode("Bad LinkageKinds");
+      break;
+  }
+  return "error";
+}
+
 inline void
 XMLWriterImpl::WriterPass::putDoc(Documentable* node)
 {
@@ -138,6 +164,7 @@
   xmlTextWriterStartDocument(writer,0,"UTF-8",0);
   startElement("hlvm");
   writeAttribute("xmlns","http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng");
+  writeAttribute("pubid",node->getPublicID());
 }
 
 void
@@ -146,12 +173,6 @@
   endElement();
   xmlTextWriterEndDocument(writer);
 }
-
-void
-XMLWriterImpl::WriterPass::put(Function* f)
-{
-}
-
 void 
 XMLWriterImpl::WriterPass::put(Documentation* b)
 {
@@ -185,7 +206,7 @@
 XMLWriterImpl::WriterPass::put(BooleanType* t)
 {
   startElement("atom");
-  writeAttribute("name",t->getName().c_str());
+  writeAttribute("name",t->getName());
   putDoc(t);
   startElement("intrinsic");
   writeAttribute("is","bool");
@@ -196,7 +217,7 @@
 XMLWriterImpl::WriterPass::put(CharacterType* t)
 {
   startElement("atom");
-  writeAttribute("name",t->getName().c_str());
+  writeAttribute("name",t->getName());
   putDoc(t);
   startElement("intrinsic");
   writeAttribute("is","char");
@@ -207,7 +228,7 @@
 XMLWriterImpl::WriterPass::put(IntegerType* t)
 {
   startElement("atom");
-  writeAttribute("name",t->getName().c_str());
+  writeAttribute("name",t->getName());
   putDoc(t);
   const char* primName = t->getPrimitiveName();
   if (primName) {
@@ -252,7 +273,7 @@
 XMLWriterImpl::WriterPass::put(RealType* t)
 {
   startElement("atom");
-  writeAttribute("name",t->getName().c_str());
+  writeAttribute("name",t->getName());
   putDoc(t);
   const char* primName = t->getPrimitiveName();
   if (primName) {
@@ -271,7 +292,7 @@
 XMLWriterImpl::WriterPass::put(OctetType* t)
 {
   startElement("atom");
-  writeAttribute("name",t->getName().c_str());
+  writeAttribute("name",t->getName());
   putDoc(t);
   startElement("intrinsic");
   writeAttribute("is","octet");
@@ -352,20 +373,61 @@
   }
 }
 
+void 
+XMLWriterImpl::WriterPass::put(ConstLiteralInteger* i)
+{
+  startElement("dec");
+  writeString(llvm::utostr(i->getValue()));
+}
+
 void
 XMLWriterImpl::WriterPass::put(Variable* v)
 {
   startElement("var");
-  writeAttribute("name",v->getName().c_str());
-  writeAttribute("type",v->getType()->getName().c_str());
+  writeAttribute("name",v->getName());
+  writeAttribute("type",v->getType()->getName());
   putDoc(v);
 }
 
+void
+XMLWriterImpl::WriterPass::put(Function* f)
+{
+  startElement("function");
+  writeAttribute("name",f->getName());
+  writeAttribute("type",f->getSignature()->getName());
+  writeAttribute("linkage",getLinkageKind(f->getLinkageKind()));
+  putDoc(f);
+}
+
+void 
+XMLWriterImpl::WriterPass::put(Program* p)
+{
+  startElement("program");
+  writeAttribute("name",p->getName());
+  putDoc(p);
+}
+
+void 
+XMLWriterImpl::WriterPass::put(Block* b)
+{
+  startElement("block");
+  if (!b->getLabel().empty())
+    writeAttribute("label",b->getLabel());
+  putDoc(b);
+}
+
+void 
+XMLWriterImpl::WriterPass::put(ReturnOp* r)
+{
+  startElement("ret");
+  putDoc(r);
+}
+
 void 
 XMLWriterImpl::WriterPass::put(Bundle* b)
 {
   startElement("bundle");
-  writeAttribute("pubid",b->getName().c_str());
+  writeAttribute("name",b->getName());
   putDoc(b);
 }
 
@@ -375,24 +437,28 @@
   if (mode & Pass::PreOrderTraversal) {
     switch (n->getID()) 
     {
-      case AliasTypeID:        put(cast<AliasType>(n)); break;
-      case AnyTypeID:          put(cast<AnyType>(n)); break;
-      case BooleanTypeID:      put(cast<BooleanType>(n)); break;
-      case BundleID:           put(cast<Bundle>(n)); break;
-      case CharacterTypeID:    put(cast<CharacterType>(n)); break;
-      case IntegerTypeID:      put(cast<IntegerType>(n)); break;
-      case RangeTypeID:        put(cast<RangeType>(n)); break;
-      case EnumerationTypeID:  put(cast<EnumerationType>(n)); break;
-      case RealTypeID:         put(cast<RealType>(n)); break;
-      case OctetTypeID:        put(cast<OctetType>(n)); break;
-      case VoidTypeID:         put(cast<VoidType>(n)); break;
-      case PointerTypeID:      put(cast<PointerType>(n)); break;
-      case ArrayTypeID:        put(cast<ArrayType>(n)); break;
-      case VectorTypeID:       put(cast<VectorType>(n)); break;
-      case StructureTypeID:    put(cast<StructureType>(n)); break;
-      case SignatureTypeID:    put(cast<SignatureType>(n)); break;
-      case VariableID:         put(cast<Variable>(n)); break;
-      case FunctionID:         put(cast<Function>(n)); break;
+      case AliasTypeID:               put(cast<AliasType>(n)); break;
+      case AnyTypeID:                 put(cast<AnyType>(n)); break;
+      case BooleanTypeID:             put(cast<BooleanType>(n)); break;
+      case BundleID:                  put(cast<Bundle>(n)); break;
+      case CharacterTypeID:           put(cast<CharacterType>(n)); break;
+      case IntegerTypeID:             put(cast<IntegerType>(n)); break;
+      case RangeTypeID:               put(cast<RangeType>(n)); break;
+      case EnumerationTypeID:         put(cast<EnumerationType>(n)); break;
+      case RealTypeID:                put(cast<RealType>(n)); break;
+      case OctetTypeID:               put(cast<OctetType>(n)); break;
+      case VoidTypeID:                put(cast<VoidType>(n)); break;
+      case PointerTypeID:             put(cast<PointerType>(n)); break;
+      case ArrayTypeID:               put(cast<ArrayType>(n)); break;
+      case VectorTypeID:              put(cast<VectorType>(n)); break;
+      case StructureTypeID:           put(cast<StructureType>(n)); break;
+      case SignatureTypeID:           put(cast<SignatureType>(n)); break;
+      case ConstLiteralIntegerOpID:   put(cast<ConstLiteralInteger>(n)); break;
+      case VariableID:                put(cast<Variable>(n)); break;
+      case FunctionID:                put(cast<Function>(n)); break;
+      case ProgramID:                 put(cast<Program>(n)); break;
+      case BlockID:                   put(cast<Block>(n)); break;
+      case ReturnOpID:                put(cast<ReturnOp>(n)); break;
       default:
         hlvmDeadCode("Unknown Type");
         break;

Modified: hlvm/trunk/test/xml2xml/alias.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/alias.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/alias.hlx (original)
+++ hlvm/trunk/test/xml2xml/alias.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <atom name="someType">
       <intrinsic is="any"/>
     </atom>

Modified: hlvm/trunk/test/xml2xml/array.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/array.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/array.hlx (original)
+++ hlvm/trunk/test/xml2xml/array.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <atom name="someType">
       <intrinsic is="any"/>
     </atom>

Modified: hlvm/trunk/test/xml2xml/bundle.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/bundle.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/bundle.hlx (original)
+++ hlvm/trunk/test/xml2xml/bundle.hlx Sat Jul  7 18:59:57 2007
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="name"/>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="name"/>
 </hlvm>

Modified: hlvm/trunk/test/xml2xml/doc.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/doc.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/doc.hlx (original)
+++ hlvm/trunk/test/xml2xml/doc.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <doc><p>This is a documentation node for a bundle element</p></doc>
     <atom name="someType">
       <doc><p>Atom Doc</p></doc>

Modified: hlvm/trunk/test/xml2xml/enumeration.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/enumeration.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/enumeration.hlx (original)
+++ hlvm/trunk/test/xml2xml/enumeration.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <enumeration name="anEnumeration">
       <enumerator id="one"/>
       <enumerator id="two"/>

Modified: hlvm/trunk/test/xml2xml/intrinsics.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/intrinsics.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/intrinsics.hlx (original)
+++ hlvm/trunk/test/xml2xml/intrinsics.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <atom name="1">
       <intrinsic is="any"/>
     </atom>

Modified: hlvm/trunk/test/xml2xml/pointer.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/pointer.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/pointer.hlx (original)
+++ hlvm/trunk/test/xml2xml/pointer.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <atom name="someType">
       <intrinsic is="any"/>
     </atom>

Modified: hlvm/trunk/test/xml2xml/resolve.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/resolve.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/resolve.hlx (original)
+++ hlvm/trunk/test/xml2xml/resolve.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <structure name="struct1">
       <field name="field1" type="SomeType"/>
     </structure>

Added: hlvm/trunk/test/xml2xml/return.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/return.hlx?rev=38114&view=auto

==============================================================================
--- hlvm/trunk/test/xml2xml/return.hlx (added)
+++ hlvm/trunk/test/xml2xml/return.hlx Sat Jul  7 18:59:57 2007
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/helloworld.hlx">
+  <bundle name="return">
+    <program name="return">
+      <block>
+        <ret>
+          <dec>42</dec>
+        </ret>
+      </block>
+    </program>
+  </bundle>
+</hlvm>

Modified: hlvm/trunk/test/xml2xml/signature.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/signature.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/signature.hlx (original)
+++ hlvm/trunk/test/xml2xml/signature.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <atom name="someType">
       <intrinsic is="any"/>
     </atom>

Modified: hlvm/trunk/test/xml2xml/structure.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/structure.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/structure.hlx (original)
+++ hlvm/trunk/test/xml2xml/structure.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <atom name="someType">
       <intrinsic is="any"/>
     </atom>

Modified: hlvm/trunk/test/xml2xml/var.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/var.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/var.hlx (original)
+++ hlvm/trunk/test/xml2xml/var.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <var name="var" type="int"/>
   </bundle>
 </hlvm>

Modified: hlvm/trunk/test/xml2xml/vector.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/vector.hlx?rev=38114&r1=38113&r2=38114&view=diff

==============================================================================
--- hlvm/trunk/test/xml2xml/vector.hlx (original)
+++ hlvm/trunk/test/xml2xml/vector.hlx Sat Jul  7 18:59:57 2007
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng">
-  <bundle pubid="bundle">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="name">
+  <bundle name="bundle">
     <vector name="aVector" of="f32" length="128"/>
   </bundle>
 </hlvm>





More information about the llvm-commits mailing list