[llvm-commits] [hlvm] r38136 - in /hlvm/trunk: build/ hlvm/AST/ hlvm/Base/ hlvm/CodeGen/ hlvm/Pass/ hlvm/Reader/XML/ hlvm/Writer/XML/ tools/hlvm-compiler/ tools/hlvm-xml2xml/ tools/hlvm/

Reid Spencer reid at x10sys.com
Sat Jul 7 17:00:11 PDT 2007


Author: reid
Date: Sat Jul  7 19:00:11 2007
New Revision: 38136

URL: http://llvm.org/viewvc/llvm-project?rev=38136&view=rev
Log:
Preparation for the next phase:
1. Implement Pools (partial) so that we can use URI objects.
2. Make several kinds of Locators based on URI objects.
3. Make Locators optional and last in the factory argument lists
4. Document the AST factory methods
5. Various other bits of housekeeping.

Added:
    hlvm/trunk/hlvm/AST/Locator.cpp
    hlvm/trunk/hlvm/AST/URI.cpp
      - copied, changed from r38135, hlvm/trunk/hlvm/Base/URI.cpp
    hlvm/trunk/hlvm/AST/URI.h
      - copied, changed from r38135, hlvm/trunk/hlvm/Base/URI.h
    hlvm/trunk/hlvm/Base/Pool.cpp
    hlvm/trunk/hlvm/Base/Pool.h
Removed:
    hlvm/trunk/hlvm/Base/URI.cpp
    hlvm/trunk/hlvm/Base/URI.h
Modified:
    hlvm/trunk/build/codegen.py
    hlvm/trunk/hlvm/AST/AST.cpp
    hlvm/trunk/hlvm/AST/AST.h
    hlvm/trunk/hlvm/AST/Bundle.cpp
    hlvm/trunk/hlvm/AST/Bundle.h
    hlvm/trunk/hlvm/AST/ContainerType.h
    hlvm/trunk/hlvm/AST/Documentation.h
    hlvm/trunk/hlvm/AST/Locator.h
    hlvm/trunk/hlvm/AST/Node.h
    hlvm/trunk/hlvm/AST/Type.cpp
    hlvm/trunk/hlvm/AST/Type.h
    hlvm/trunk/hlvm/AST/Variable.cpp
    hlvm/trunk/hlvm/AST/Variable.h
    hlvm/trunk/hlvm/Base/Assert.h
    hlvm/trunk/hlvm/Base/Memory.cpp
    hlvm/trunk/hlvm/Base/Memory.h
    hlvm/trunk/hlvm/Base/Source.cpp
    hlvm/trunk/hlvm/Base/Source.h
    hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp
    hlvm/trunk/hlvm/CodeGen/SConscript
    hlvm/trunk/hlvm/CodeGen/string.cxx
    hlvm/trunk/hlvm/Pass/Validate.cpp
    hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
    hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
    hlvm/trunk/tools/hlvm-compiler/SConscript
    hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp
    hlvm/trunk/tools/hlvm-xml2xml/SConscript
    hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
    hlvm/trunk/tools/hlvm/hlvm.cpp

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

==============================================================================
--- hlvm/trunk/build/codegen.py (original)
+++ hlvm/trunk/build/codegen.py Sat Jul  7 19:00:11 2007
@@ -13,6 +13,8 @@
     env['with_llvmdis'] + " -o - | " + 
     env['with_llvm2cpp'] + " " + env['LLVM2CPPFLAGS'] + " -o " + tgt
   )
+  env.Depends(tgt,env['with_llvm2cpp'])
+  env.Depends(tgt,env['with_llvmdis'])
   env.Execute(theAction);
   return 0
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.cpp (original)
+++ hlvm/trunk/hlvm/AST/AST.cpp Sat Jul  7 19:00:11 2007
@@ -28,6 +28,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <hlvm/AST/AST.h>
+#include <hlvm/AST/Locator.h>
 #include <hlvm/AST/Bundle.h>
 #include <hlvm/AST/Import.h>
 #include <hlvm/AST/Documentation.h>
@@ -40,6 +41,7 @@
 #include <hlvm/AST/ControlFlow.h>
 #include <hlvm/AST/SymbolTable.h>
 #include <hlvm/Base/Assert.h>
+#include <hlvm/Base/Pool.h>
 #include <llvm/Support/Casting.h>
 
 using namespace hlvm;
@@ -59,7 +61,9 @@
         SInt64Singleton(0), SInt128Singleton(0),  Float32Singleton(0),
         Float44Singleton(0), Float64Singleton(0), Float80Singleton(0),
         Float128Singleton(0), ProgramTypeSingleton(0)
-      {}
+      {
+        pool = Pool::create("ASTPool",0,false,1024,4,0);
+      }
     ~ASTImpl();
 
   protected:
@@ -176,8 +180,27 @@
   return static_cast<const ASTImpl*>(this)->resolveType(name);
 }
 
+Locator*
+AST::new_Locator(const URI* uri, uint32_t line, uint32_t col, uint32_t line2,
+    uint32_t col2)
+{
+  hlvmAssert(uri != 0);
+  if (line != 0)
+    if (col != 0)
+      if (line2 != 0 && col2 != 0)
+        return new RangeLocator(uri,line,col,line2,col2);
+      else
+        return new LineColumnLocator(uri,line,col);
+    else 
+      return new LineLocator(uri,line);
+  else
+    return new URILocator(uri);
+  hlvmDeadCode("Invalid Locator construction");
+  return 0;
+}
+
 Bundle*
-AST::new_Bundle(const Locator& loc, const std::string& id)
+AST::new_Bundle(const std::string& id, const Locator* loc)
 {
   Bundle* result = new Bundle();
   result->setLocator(loc);
@@ -186,7 +209,7 @@
 }
 
 Import*
-AST::new_Import(const Locator& loc, const std::string& pfx)
+AST::new_Import(const std::string& pfx, const Locator* loc)
 {
   Import* result = new Import();
   result->setLocator(loc);
@@ -196,10 +219,10 @@
 
 IntegerType* 
 AST::new_IntegerType(
-  const Locator&loc, 
   const std::string& id, 
   uint64_t bits, 
-  bool isSigned )
+  bool isSigned,
+  const Locator* loc)
 {
   IntegerType* result = new IntegerType(IntegerTypeID);
   result->setBits(bits);
@@ -211,7 +234,7 @@
 }
 
 RangeType* 
-AST::new_RangeType(const Locator&loc, const std::string& id, int64_t min, int64_t max)
+AST::new_RangeType(const std::string& id, int64_t min, int64_t max, const Locator* loc)
 {
   RangeType* result = new RangeType();
   result->setLocator(loc);
@@ -224,8 +247,8 @@
 
 EnumerationType* 
 AST::new_EnumerationType(
-  const Locator&loc, 
-  const std::string& id )
+  const std::string& id,
+  const Locator* loc)
 {
   EnumerationType* result = new EnumerationType();
   result->setLocator(loc);
@@ -236,10 +259,10 @@
 
 RealType* 
 AST::new_RealType(
-  const Locator&loc,
   const std::string& id,  
   uint32_t mantissa, 
-  uint32_t exponent)
+  uint32_t exponent,
+  const Locator* loc)
 {
   RealType* result = new RealType(RealTypeID);
   result->setMantissa(mantissa);
@@ -251,7 +274,7 @@
 }
 
 AnyType* 
-AST::new_AnyType(const Locator&loc, const std::string& id)
+AST::new_AnyType(const std::string& id, const Locator* loc)
 {
   AnyType* result = new AnyType();
   result->setLocator(loc);
@@ -261,7 +284,7 @@
 }
 
 BooleanType* 
-AST::new_BooleanType(const Locator&loc, const std::string& id)
+AST::new_BooleanType(const std::string& id, const Locator* loc)
 {
   BooleanType* result = new BooleanType();
   result->setLocator(loc);
@@ -271,7 +294,7 @@
 }
 
 CharacterType* 
-AST::new_CharacterType(const Locator&loc, const std::string& id)
+AST::new_CharacterType(const std::string& id, const Locator* loc)
 {
   CharacterType* result = new CharacterType();
   result->setLocator(loc);
@@ -281,7 +304,7 @@
 }
 
 OctetType* 
-AST::new_OctetType(const Locator&loc, const std::string& id)
+AST::new_OctetType(const std::string& id, const Locator* loc)
 {
   OctetType* result = new OctetType();
   result->setLocator(loc);
@@ -291,7 +314,7 @@
 }
 
 VoidType* 
-AST::new_VoidType(const Locator&loc, const std::string& id)
+AST::new_VoidType(const std::string& id, const Locator* loc)
 {
   VoidType* result = new VoidType();
   result->setLocator(loc);
@@ -302,10 +325,9 @@
 
 PointerType* 
 AST::new_PointerType(
-  const Locator& loc, 
   const std::string& id,
-  Type* target
-)
+  Type* target,
+  const Locator* loc)
 {
   PointerType* result = new PointerType();
   result->setLocator(loc);
@@ -317,11 +339,10 @@
 
 ArrayType* 
 AST::new_ArrayType(
-  const Locator& loc, 
   const std::string& id,
   Type* elemType,
-  uint64_t maxSize
-)
+  uint64_t maxSize,
+  const Locator* loc)
 {
   ArrayType* result = new ArrayType();
   result->setLocator(loc);
@@ -334,11 +355,10 @@
 
 VectorType* 
 AST::new_VectorType(
-  const Locator& loc, 
   const std::string& id,
   Type* elemType,
-  uint64_t size
-)
+  uint64_t size,
+  const Locator* loc)
 {
   VectorType* result = new VectorType();
   result->setLocator(loc);
@@ -350,7 +370,7 @@
 }
 
 AliasType* 
-AST::new_AliasType(const Locator& loc, const std::string& id, Type* referrant)
+AST::new_AliasType(const std::string& id, Type* referrant, const Locator* loc)
 {
   AliasType* result = new AliasType();
   result->setLocator(loc);
@@ -361,7 +381,7 @@
 }
 
 StructureType*
-AST::new_StructureType(const Locator& loc, const std::string& id)
+AST::new_StructureType(const std::string& id, const Locator* loc)
 {
   StructureType* result = new StructureType();
   result->setLocator(loc);
@@ -371,7 +391,11 @@
 }
 
 SignatureType*
-AST::new_SignatureType(const Locator& loc, const std::string& id, Type* ty)
+AST::new_SignatureType(
+  const std::string& id, 
+  const Type* ty, 
+  bool isVarArgs,
+  const Locator* loc)
 {
   SignatureType* result = new SignatureType();
   result->setLocator(loc);
@@ -388,7 +412,7 @@
 }
 
 ConstLiteralInteger*
-AST::new_ConstLiteralInteger(const Locator& loc)
+AST::new_ConstLiteralInteger(const Locator* loc)
 {
   ConstLiteralInteger* result = new ConstLiteralInteger();
   result->setLocator(loc);
@@ -396,16 +420,17 @@
 }
 
 Variable*
-AST::new_Variable(const Locator& loc, const std::string& id)
+AST::new_Variable(const std::string& id, const Type* Ty, const Locator* loc)
 {
   Variable* result = new Variable();
   result->setLocator(loc);
+  result->setType(Ty);
   result->setName(id);
   return result;
 }
 
 Function*
-AST::new_Function(const Locator& loc, const std::string& id)
+AST::new_Function(const std::string& id, const Locator* loc)
 {
   Function* result = new Function();
   result->setLocator(loc);
@@ -414,7 +439,7 @@
 }
 
 Program*
-AST::new_Program(const Locator& loc, const std::string& id)
+AST::new_Program(const std::string& id, const Locator* loc)
 {
   ASTImpl* ast = static_cast<ASTImpl*>(this);
   if (!ast->ProgramTypeSingleton) {
@@ -423,10 +448,10 @@
     ast->ProgramTypeSingleton->setName(id);
     Type* intType = getPrimitiveType(SInt32TypeID);
     ast->ProgramTypeSingleton->setResultType(intType);
-    ArrayType* arg_array = new_ArrayType(loc,"arg_array",
-      new_StringType(loc,"string"),0);
-    PointerType* args = new_PointerType(loc,"arg_array_ptr",arg_array);
-    Argument* param = new_Argument(loc,"args",args);
+    ArrayType* arg_array = new_ArrayType("arg_array",
+      new_TextType("string",loc),0,loc);
+    PointerType* args = new_PointerType("arg_array_ptr",arg_array,loc);
+    Argument* param = new_Argument("args",args,loc);
     ast->ProgramTypeSingleton->addArgument(param);
   }
 
@@ -439,15 +464,16 @@
 }
 
 Block*
-AST::new_Block(const Locator& loc)
+AST::new_Block(const std::string& label, const Locator* loc)
 {
   Block* result = new Block();
+  result->setLabel(label);
   result->setLocator(loc);
   return result;
 }
 
 ReturnOp*
-AST::new_ReturnOp(const Locator& loc)
+AST::new_ReturnOp(const Locator* loc)
 {
   ReturnOp* result = new ReturnOp();
   result->setLocator(loc);
@@ -455,7 +481,7 @@
 }
 
 Documentation* 
-AST::new_Documentation(const Locator& loc)
+AST::new_Documentation(const Locator* loc)
 {
   Documentation* result = new Documentation();
   result->setLocator(loc);
@@ -463,7 +489,7 @@
 }
 
 Argument* 
-AST::new_Argument(const Locator& loc, const std::string& id, Type* ty )
+AST::new_Argument(const std::string& id, Type* ty , const Locator* loc)
 {
   Argument* result = new Argument();
   result->setLocator(loc);
@@ -472,10 +498,10 @@
   return result;
 }
 
-StringType*
-AST::new_StringType(const Locator& loc, const std::string& id)
+TextType*
+AST::new_TextType(const std::string& id, const Locator* loc)
 {
-  StringType* result = new StringType(id);
+  TextType* result = new TextType(id);
   result->setLocator(loc);
   return result;
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.h (original)
+++ hlvm/trunk/hlvm/AST/AST.h Sat Jul  7 19:00:11 2007
@@ -54,6 +54,7 @@
 class ConstLiteralInteger;
 class ReturnOp;
 class AliasType;
+class Pool;
 typedef AliasType Argument;
 typedef AliasType Field;
 
@@ -77,7 +78,7 @@
     static void destroy(AST* ast);
 
   protected:
-    AST() : Node(TreeTopID), sysid(), pubid(), bundles() {}
+    AST() : Node(TreeTopID), sysid(), pubid(), bundles(), pool(0) {}
     ~AST();
 
   /// @}
@@ -86,6 +87,7 @@
   public:
     const std::string& getSystemID() const { return sysid; }
     const std::string& getPublicID() const { return pubid; }
+    Pool* getPool() const { return pool; }
 
   /// @}
   /// @name Mutators
@@ -120,112 +122,286 @@
   /// @name Factories
   /// @{
   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);
+    /// Get one of the primitive types directly by its identifier
+    Type* getPrimitiveType(NodeIDs kind);
+
+    /// Create a new Locator object. Locators indicate where in the source
+    /// a particular AST node is located. Locators can be very general (just
+    /// the URI) or very specific (the exact range of bytes in the file). The
+    /// Locator returned can be used with any of the other factory methods 
+    /// in this class.
+    Locator* new_Locator(
+      const URI* uri,        ///< The URI of the source
+      uint32_t line = 0,     ///< The line number of the location
+      uint32_t col = 0,      ///< The column number of the location
+      uint32_t line2 =0,     ///< The ending line number of the location range
+      uint32_t col2 = 0      ///< The ending column number of the location range
+    );
+
+    /// Create a new Documentation node. A documentation node contains the
+    /// documentation that accompanies the program. 
+    Documentation* new_Documentation(
+      const Locator* loc = 0 ///< The source locator
+    );
+
+    /// Create a new Bundle node. A bundle is the general container of other AST
+    /// nodes. Bundles are also the unit of loading and linking.
+    Bundle* new_Bundle(
+      const std::string& id, ///< The name of the bundle
+      const Locator* loc = 0 ///< The source locator
+    );
+    /// Create a new Import node. An import node may be attached to a bundle to
+    /// indicate that the declarations of some external bundle are needed in
+    /// order to satisfy the definitions of the current bundle.
+    Import* new_Import(
+      const std::string& id,  ///< The name of the import
+      const Locator* loc = 0 ///< 
+    );
+    /// Create a new Function node. 
+    Function* new_Function(
+      const std::string& id, ///< The name of the function
+      const Locator* loc = 0 ///< The source locator
+    );
+    /// Create a new Argument node. Arguments are used as the formal argument
+    /// value to a function.
+    Argument* new_Argument(
+      const std::string& id, ///< The name of the function argument
+      Type* ty,              ///< The type of the function argument 
+      const Locator* loc = 0 ///< The source locator
+    );
+    /// Create a new Program node. Programs are like functions except that their
+    /// signature is fixed and they represent the entry point to a complete
+    /// program. Unlike other languages, you can have multiple Program nodes
+    /// (entry points) in the same compilation unit.
+    Program* new_Program(
+      const std::string& id, ///< The name of the program
+      const Locator* loc = 0 ///< The source locator
+    );
+    /// Create a new Block node. A block is a sequence of operators.
+    Block* new_Block(
+      const std::string& id, ///< The name (label) of the block
+      const Locator* loc = 0 ///< The source locator
+    );
+    /// Create a new IntegerType node. This is a general interface for creating
+    /// integer types. By default it creates a signed 32-bit integer.
     IntegerType* new_IntegerType(
-      const Locator&loc,      ///< The locator of the declaration
-      const std::string& id,  ///< The name of the atom
+      const std::string& id,  ///< The name of the type
       uint64_t bits = 32,     ///< The number of bits
-      bool isSigned = true    ///< The signedness
+      bool isSigned = true,    ///< The signedness
+      const Locator* loc = 0  ///< The locator of the declaration
     );
+    /// Create a new RangeType node. RangeType nodes are integer nodes that
+    /// perform range checking to ensure the assigned values are kept in range
     RangeType* new_RangeType(
-      const Locator&loc,      ///< The locator of the declaration
-      const std::string& id,  ///< The name of the atom
+      const std::string& id,  ///< The name of the type
       int64_t min,            ///< The minimum value accepted in range
-      int64_t max             ///< The maximum value accepted in range
+      int64_t max,            ///< The maximum value accepted in range
+      const Locator*loc = 0   ///< The locator of the declaration
     );
+    /// Create a new EnumerationType node. EnumerationType nodes are RangeType
+    /// nodes that associate specific enumerated names for the values of the
+    /// enumeration.
     EnumerationType* new_EnumerationType(
-      const Locator&loc,      ///< The locator of the declaration
-      const std::string& id   ///< The name of the atom
+      const std::string& id,   ///< The name of the type
+      const Locator*loc = 0    ///< The locator of the declaration
     );
+    /// Create a new RealType node. This is the generalized interface for 
+    /// construction real number types. By default it creates a 64-bit double
+    /// precision floating point type.
     RealType* new_RealType(
-      const Locator&loc,      ///< The locator of the declaration
-      const std::string& id,  ///< The name of the atom
+      const std::string& id,  ///< The name of the type
       uint32_t mantissa = 52, ///< The bits in the mantissa (fraction)
-      uint32_t exponent = 11  ///< The bits in the exponent
+      uint32_t exponent = 11, ///< The bits in the exponent
+      const Locator* loc = 0   ///< The locator 
+    );
+    /// Create a new AnyType node. An AnyType node is a type that can hold a
+    /// value of any other HLVM type. 
+    AnyType* new_AnyType(
+      const std::string& id, ///< The name of the type
+      const Locator* loc = 0  ///< The source locator 
+    );
+    /// Create a new BooleanType node. A BooleanType has a simple binary value,
+    /// true or false.
+    BooleanType* new_BooleanType(
+      const std::string& id,  ///< The name of the type
+      const Locator* loc = 0  ///< The source locator
     );
-    AnyType* new_AnyType(const Locator&loc, const std::string& id);
-    BooleanType* 
-      new_BooleanType(const Locator&loc, const std::string& id);
-    CharacterType* 
-      new_CharacterType(const Locator&loc, const std::string& id);
-    OctetType* 
-      new_OctetType(const Locator&loc, const std::string& id);
-    VoidType* new_VoidType(const Locator&loc, const std::string& id);
+    /// Create a new CharacterType node. A CharacterType represents a single 
+    /// textual character in UTF-16 encoding.
+    CharacterType* new_CharacterType(
+      const std::string& id,  ///< The name of the type
+      const Locator* loc = 0  ///< The source locator
+    );
+    /// Create a new TextType node. A TextType represents a string or block 
+    /// of text of arbitrary length in UTF-16 encoding.
+    TextType* new_TextType(
+      const std::string& id,  ///< The name of the type
+      const Locator* loc = 0  ///< The source locator
+    );
+    /// Create a new OctetType node. An OctetType represents an 8-bit 
+    /// non-numerical quantity. You can't do arithmetic with octets.
+    OctetType* new_OctetType(
+      const std::string& id,  ///< The name of the type
+      const Locator*loc = 0   ///< The source locator
+    );
+    /// Create a new VoidType node. A VoidType represents a zero-length entity
+    /// that has no address. In other words, its nothing, zilch, nada, empty,
+    /// vacuum, etc. As you there's lots of ways to name the concept of 
+    /// nothing and that's why this method exists.
+    VoidType* new_VoidType(
+      const std::string& id,  ///< The name of the type
+      const Locator* loc =0   ///< The source locator     
+    );
+    /// Create a new PointerType node. A PointerType just refers to a location
+    /// of some other type.
     PointerType* new_PointerType(
-      const Locator& loc, 
-      const std::string& id,
-      Type* target
+      const std::string& id,  ///< The name of the pointer type
+      Type* target,           ///< The referent type
+      const Locator* loc = 0  ///< The source locator
     );
+    /// Create a new ArrayType node. An ArrayType is a sequential arrangement of
+    /// memory locations of uniform type. Arrays can be dynamically expanded
+    /// or shrunk, but not beyond the maxSize parameter. 
     ArrayType* new_ArrayType(
-      const Locator& loc, 
-      const std::string& id,
-      Type* elemType,
-      uint64_t maxSize
+      const std::string& id,  ///< The name of the array type
+      Type* elemType,         ///< The element type
+      uint64_t maxSize,       ///< The maximum number of elements in the array
+      const Locator* loc = 0  ///< The source locator
     );
+    /// Create a new VectorType node. A VectorType is a sequential arrangement
+    /// of memory locations of uniform type and constant size. Unlike Arrays,
+    /// a vector's size is always constant.
     VectorType* new_VectorType(
-      const Locator& loc, 
-      const std::string& id,
-      Type* elemType,
-      uint64_t size
+      const std::string& id,  ///< The name of the vector type
+      Type* elemType,         ///< The element type
+      uint64_t size,          ///< The number of elements in the vector
+      const Locator* loc = 0  ///< The source locator
     );
+    /// Create a new AliasType node. An AliasType node is simply a way of giving
+    /// a new name to another type. Since type naming equates to type
+    /// equivalence in HLVM, this node allows two different types to be
+    /// equivalent without having the same name.
     AliasType* new_AliasType(
-      const Locator& loc,
-      const std::string& id,
-      Type* referrant
+      const std::string& id,  ///< The name of the alias
+      Type* referrant,        ///< The type for which this type is an alias
+      const Locator* loc = 0  ///< The source locator
     );
-    StructureType* 
-      new_StructureType(const Locator& l, const std::string& id);
+    /// Create a new StructureType node. A StructureType is a type that is an
+    /// ordered sequential arrangement of memory locations of various but 
+    /// definite types.
+    StructureType* new_StructureType(
+      const std::string& id,  ///< The name of the structure type
+      const Locator* loc = 0  ///< The source locator
+    );
+    /// Create a new SignatureType node. A SignatureType specifies the type of
+    /// a Function. It identifies the names and types of the arguments of a
+    /// function and the type of its result value.
     SignatureType* new_SignatureType(
-      const Locator& loc, 
-      const std::string& id,
-      Type *resultType
-    );
-    OpaqueType* new_OpaqueType(const std::string& id);
-    RealType* new_f128(const Locator& l, const std::string& id)
-      { return new_RealType(l,id,112,15); }
-    RealType* new_f80(const Locator& l, const std::string& id)
-      { return new_RealType(l,id,64,15); }
-    RealType* new_f64(const Locator& l, const std::string& id)
-      { return new_RealType(l,id,52,11); }
-    RealType* new_f43(const Locator& l, const std::string& id)
-      { return new_RealType(l,id,32,11); }
-    RealType* new_f32(const Locator& l, const std::string& id)
-      { return new_RealType(l,id,23,8); }
-    IntegerType* new_s128(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,128,true); }
-    IntegerType* new_s64(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,64,true); }
-    IntegerType* new_s32(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,32,true); }
-    IntegerType* new_s16(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,16,true); }
-    IntegerType* new_s8(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,8,true); }
-    IntegerType* new_u128(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,128,false); }
-    IntegerType* new_u64(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,64,false); }
-    IntegerType* new_u32(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,32,false); }
-    IntegerType* new_u16(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,16,false); }
-    IntegerType* new_u8(const Locator& l, const std::string& id)
-      { return new_IntegerType(l,id,8,false); }
-
-    Argument* 
-      new_Argument(const Locator& loc, const std::string& id, Type* ty );
-
-    StringType* new_StringType(const Locator& loc, const std::string& id);
-
-    ConstLiteralInteger* new_ConstLiteralInteger(const Locator& loc);
-    Documentation* new_Documentation(const Locator& loc);
-    Type* getPrimitiveType(NodeIDs kind);
+      const std::string& id,  ///< The name of the function signature type
+      const Type *resultType, ///< The result type of the function
+      bool isVarArgs = false, ///< Indicates variable number of arguments
+      const Locator* loc = 0  ///< The source locator
+    );
+    /// Create a new OpaqueType node. An OpaqueType is used as a place holder
+    /// for situations where the full type is either not known or should not
+    /// be exposed. You cannot create an object of OpaqueType but you can 
+    /// obtain its location.
+    OpaqueType* new_OpaqueType(
+      const std::string& id   ///< The name of the opaque type
+    );
+    /// Create a new 128 bit primitive floating point type.
+    RealType* new_f128(
+      const std::string& id,  ///< The name of the 128-bit floating point type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_RealType(id,112,15,loc); }
+    /// Create a new 80 bit primitive floating point type.
+    RealType* new_f80(
+      const std::string& id,  ///< The name of the 80-bit floating point type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_RealType(id,64,15,loc); }
+    /// Create a new 64 bit primitive floating point type.
+    RealType* new_f64(
+      const std::string& id,  ///< The name of the 64-bit floating point type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_RealType(id,52,11,loc); }
+    /// Create a new 44 bit primitive floating point type.
+    RealType* new_f44(
+      const std::string& id,  ///< The name of the 44-bit floating point type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_RealType(id,32,11,loc); }
+    /// Create a new 32 bit primitive floating point type.
+    RealType* new_f32(
+      const std::string& id,  ///< The name of teh 32-bit floating point type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_RealType(id,23,8,loc); }
+    /// Create a new 128 bit primitive signed integer point type.
+    IntegerType* new_s128(
+      const std::string& id,  ///< The name of the 128-bit signed integer type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_IntegerType(id,128,true,loc); }
+    /// Create a new 64 bit primitive signed integer point type.
+    IntegerType* new_s64(
+      const std::string& id,  ///< The name of the 64-bit signed integer type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_IntegerType(id,64,true,loc); }
+    /// Create a new 32 bit primitive signed integer point type.
+    IntegerType* new_s32(
+      const std::string& id,  ///< The name of teh 32-bit signed integer type
+      const Locator* loc = 0  ///< The source locator
+    ) { return new_IntegerType(id,32,true,loc); }
+    /// Create a new 16 bit primitive signed integer point type.
+    IntegerType* new_s16(
+      const std::string& id,  ///< The name of the 16-bit signed integer type
+      const Locator* loc = 0  ///< THe source locator
+    ) { return new_IntegerType(id,16,true,loc); }
+    /// Create a new 8 bit primitive signed integer point type.
+    IntegerType* new_s8(
+      const std::string& id,  ///< The name of the 8-bit signed integer type
+      const Locator* l = 0    ///< The source locator
+    ) { return new_IntegerType(id,8,true,loc); }
+    /// Create a new 128 bit primitive unsigned integer point type.
+    IntegerType* new_u128(
+      const std::string& id,  ///< The name of the 128-bit unsigned integer type
+      const Locator* l = 0    ///< The source locator
+    ) { return new_IntegerType(id,128,false,loc); }
+    /// Create a new 64 bit primitive unsigned integer point type.
+    IntegerType* new_u64(
+      const std::string& id,  ///< The name of the 64-bit unsigned integer type
+      const Locator* l = 0    ///< The source locator
+    ) { return new_IntegerType(id,64,false,loc); }
+    /// Create a new 32 bit primitive unsigned integer point type.
+    IntegerType* new_u32(
+      const std::string& id,  ///< The name of the 32-bit unsigned integer type
+      const Locator* l = 0    ///< The source locator
+    ) { return new_IntegerType(id,32,false,loc); }
+    /// Create a new 16 bit primitive unsigned integer point type.
+    IntegerType* new_u16(
+      const std::string& id,  ///< The name of the 16-bit unsigned integer type
+      const Locator* l = 0    ///< The source locator
+    ) { return new_IntegerType(id,16,false,loc); }
+    /// Create a new 8 bit primitive unsigned integer point type.
+    IntegerType* new_u8(
+      const std::string& id,  ///< The name of the 8-bit unsigned integer type
+      const Locator* l = 0    ///< The source locator
+    ) { return new_IntegerType(id,8,false,loc); }
+    /// Create a new Variable node. A Variable node represents a storage
+    /// location. Variables can be declared in Bundles, Functions and Blocks.
+    /// Their life span is the lifespan of the container in which they are
+    /// declared.
+    Variable* new_Variable(
+      const std::string& id,  ///< The name of the variable
+      const Type* ty,         ///< The type of the variable
+      const Locator* loc = 0  ///< The source locator
+    );
+    /// Create a new ConstantLiteralInteger node.
+    ConstLiteralInteger* new_ConstLiteralInteger(
+      const Locator* loc = 0  ///< The source locator
+    );
+    /// Create a new ReturnOp node. The ReturnOp is an operator that returns
+    /// immediately from the enclosing function, possibly with a result value.
+    ReturnOp* new_ReturnOp(
+      const Locator* loc = 0 ///< The 
+    );
 
   /// @}
   /// @name Data
@@ -234,6 +410,7 @@
     std::string sysid;
     std::string pubid;
     BundleList bundles;
+    Pool* pool;
   /// @}
 };
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.cpp (original)
+++ hlvm/trunk/hlvm/AST/Bundle.cpp Sat Jul  7 19:00:11 2007
@@ -38,7 +38,7 @@
 namespace hlvm {
 
 Bundle*
-Bundle::create(const Locator& loc, const std::string& id)
+Bundle::create(const Locator* loc, const std::string& id)
 {
   Bundle* result = new Bundle();
   result->setLocator(loc);

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.h (original)
+++ hlvm/trunk/hlvm/AST/Bundle.h Sat Jul  7 19:00:11 2007
@@ -66,7 +66,7 @@
   /// @name Constructors
   /// @{
   public:
-    static Bundle* create(const Locator& location, const std::string& pubid);
+    static Bundle* create(const Locator* location, const std::string& pubid);
 
   protected:
     Bundle() : Documentable(BundleID), name(), types(), vars(), funcs() {}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/ContainerType.h (original)
+++ hlvm/trunk/hlvm/AST/ContainerType.h Sat Jul  7 19:00:11 2007
@@ -145,7 +145,7 @@
   /// @name Accessors
   /// @{
   public:
-    Type* getResultType() const { return result; }
+    const Type* getResultType() const { return result; }
     bool  isVarArgs() const { return varargs; }
 
     // Methods to support type inquiry via is, cast, dyn_cast
@@ -158,7 +158,7 @@
   /// @name Mutators
   /// @{
   public:
-    void setResultType(Type* ty) { result = ty; }
+    void setResultType(const Type* ty) { result = ty; }
     void setIsVarArgs(bool is) { varargs = is; }
     void addArgument(Argument* arg) { contents.push_back(arg); }
 
@@ -166,8 +166,8 @@
   /// @name Data
   /// @{
   protected:
-    Type* result;    ///< The result type of the function signature
-    bool varargs;  ///< Indicates variable arguments function
+    const Type* result;  ///< The result type of the function signature
+    bool varargs;        ///< Indicates variable arguments function
   /// @}
   friend class AST;
 };

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Documentation.h (original)
+++ hlvm/trunk/hlvm/AST/Documentation.h Sat Jul  7 19:00:11 2007
@@ -24,7 +24,7 @@
 /// @author Reid Spencer <reid at hlvm.org> (original author)
 /// @date 2006/05/19
 /// @since 0.1.0
-/// @brief Declares the class hlvm::AST::Documentation
+/// @brief Declares the class hlvm::Documentation
 //===----------------------------------------------------------------------===//
 
 #ifndef HLVM_AST_DOCUMENTATION_H

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Locator.cpp (added)
+++ hlvm/trunk/hlvm/AST/Locator.cpp Sat Jul  7 19:00:11 2007
@@ -0,0 +1,108 @@
+//===-- AST Locator Classes Implementation ----------------------*- 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/Locator.cpp
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Defines the methods of class hlvm::AST::Locator and friends
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/AST/Locator.h>
+#include <hlvm/Base/Assert.h>
+#include <llvm/ADT/StringExtras.h>
+
+namespace hlvm
+{
+
+bool 
+URILocator::equals(const Locator& that) const
+{
+  if (this == &that)
+    return true;
+  if (that.id() >= this->SubclassID)
+    return this->uri == static_cast<const URILocator&>(that).uri;
+  return false;
+}
+
+void 
+URILocator::getReference(std::string& ref) const
+{
+  hlvmAssert(uri != 0);
+  ref = uri->as_string();
+}
+
+void 
+LineLocator::getReference(std::string& ref) const
+{
+  URILocator::getReference(ref);
+  ref += ":" + llvm::utostr(line);
+}
+
+bool 
+LineLocator::equals(const Locator& that) const
+{
+  if (this == &that)
+    return true;
+  if (that.id() >= this->SubclassID)
+    return URILocator::equals(that) && 
+      this->line == static_cast<const LineLocator&>(that).line;
+  return false;
+}
+void
+LineColumnLocator::getReference(std::string& ref) const
+{
+  LineLocator::getReference(ref);
+  ref += ":" + llvm::utostr(col);
+}
+
+bool
+LineColumnLocator::equals(const Locator& that) const
+{
+  if (this == &that)
+    return true;
+  if (that.id() >= this->SubclassID)
+    return LineLocator::equals(that) && 
+      this->col == static_cast<const LineColumnLocator&>(that).line;
+  return false;
+}
+
+void
+RangeLocator::getReference(std::string& ref) const
+{
+  URILocator::getReference(ref);
+  ref += "(" + llvm::utostr(line) + ":" + llvm::utostr(col) + "," 
+             + llvm::utostr(line2) + ":" + llvm::utostr(col2) + ")"; 
+}
+
+bool
+RangeLocator::equals(const Locator& that) const
+{
+  if (this == &that)
+    return true;
+  if (that.id() >= this->SubclassID)
+    return LineColumnLocator::equals(that) && 
+      this->line2 == static_cast<const RangeLocator&>(that).line2 &&
+      this->col2 == static_cast<const RangeLocator&>(that).col2 ;
+  return false;
+}
+} // hlvm

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Locator.h (original)
+++ hlvm/trunk/hlvm/AST/Locator.h Sat Jul  7 19:00:11 2007
@@ -21,15 +21,16 @@
 //
 //===----------------------------------------------------------------------===//
 /// @file hlvm/AST/Locator.h
-/// @author Reid Spencer <reid at hlvm.org> (original author)
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
 /// @date 2006/05/04
 /// @since 0.1.0
-/// @brief Declares the class hlvm::AST::Locator
+/// @brief Declares the class hlvm::AST::Locator and friends
 //===----------------------------------------------------------------------===//
 
 #ifndef HLVM_AST_LOCATOR_H
 #define HLVM_AST_LOCATOR_H
 
+#include <hlvm/AST/URI.h>
 #include <string>
 
 namespace hlvm
@@ -42,24 +43,110 @@
 class Locator
 {
   /// @name Constructors
+  protected:
+    Locator() : SubclassID(0) {}
+  /// @name Accessors
+  /// @{
+  public:
+    virtual void getReference(std::string& ref) const = 0;
+    virtual bool equals(const Locator& that) const = 0;
+    bool operator==(const Locator& that) { return this->equals(that); }
+    unsigned short id() const { return SubclassID; }
+  /// @}
+  protected:
+    unsigned short SubclassID;
+};
+
+class URILocator : public Locator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    URILocator(const URI* u) : Locator(), uri(u) { SubclassID = 1; }
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    virtual void getReference(std::string& ref) const;
+    virtual bool equals(const Locator& that) const;
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    const URI* uri;
+  /// @}
+};
+
+class LineLocator : public URILocator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    LineLocator(const URI* u, uint32_t l) : URILocator(u), line(l) {
+      SubclassID = 2; 
+    }
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    virtual void getReference(std::string& ref) const;
+    virtual bool equals(const Locator& that) const;
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    uint32_t line;           ///< Line number of source location
+  /// @}
+};
+
+class LineColumnLocator : public LineLocator
+{
+  /// @name Constructors
+  /// @{
+  public:
+    LineColumnLocator(const URI* u, uint32_t l, uint32_t c) 
+      : LineLocator(u,l), col(c) { SubclassID = 3; }
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    virtual void getReference(std::string& ref) const;
+    virtual bool equals(const Locator& that) const;
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    uint32_t col;            ///< Column number of source location
+  /// @}
+};
+
+class RangeLocator : public LineColumnLocator
+{
+  /// @name Constructors
   /// @{
   public:
-    Locator(uint32_t line, uint32_t col, const std::string* fname)
-      : line_(line), col_(col), fname_(fname) {}
-    Locator() : line_(0), col_(0), fname_(0) {}
+    RangeLocator(const URI* u, uint32_t l, uint32_t c, uint32_t l2, uint32_t c2)
+      : LineColumnLocator(u,l,c), line2(l2), col2(c2) { SubclassID = 4; }
 
   /// @}
   /// @name Accessors
   /// @{
   public:
+    virtual void getReference(std::string& ref) const;
+    virtual bool equals(const Locator& that) const;
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    uint32_t line_;           ///< Line number of source location
-    uint32_t col_;            ///< Column number of source location
-    const std::string* fname_;///< File name of source location
+    uint32_t line2;           ///< Column number of source location
+    uint32_t col2;            ///< Column number of source location
   /// @}
 };
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul  7 19:00:11 2007
@@ -80,7 +80,7 @@
   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)
+  TextTypeID,              ///< The Text Type (Array of UTF-16 chars + length)
 
   // Container Types
   AliasTypeID,             ///< A new name for an existing type
@@ -221,7 +221,7 @@
   FirstPrimitiveTypeID = VoidTypeID, ///< First Primitive Type
   LastPrimitiveTypeID  = Float128TypeID, ///< Last Primitive Type
   FirstSimpleTypeID    = AnyTypeID,
-  LastSimpleTypeID     = StringTypeID,
+  LastSimpleTypeID     = TextTypeID,  
   FirstContainerTypeID = PointerTypeID, ///< First Container Type
   LastContainerTypeID  = ContinuationTypeID, ///< Last Container Type
   FirstTypeID          = VoidTypeID,
@@ -250,7 +250,7 @@
   /// @name Constructors
   /// @{
   protected:
-    Node(NodeIDs ID) : id(ID), parent(0), loc() {}
+    Node(NodeIDs ID) : id(ID), parent(0), loc(0) {}
   public:
     virtual ~Node();
 
@@ -270,7 +270,7 @@
     inline unsigned getFlags() const { return flags; }
 
     /// Get the Locator
-    inline const Locator& getLocator() const { return loc; }
+    inline const Locator* getLocator() const { return loc; }
 
     /// Determine if the node is a specific kind
     inline bool is(NodeIDs kind) const { return id == unsigned(kind); }
@@ -366,7 +366,7 @@
   /// @name Mutators
   /// @{
   public:
-    void setLocator(const Locator& l) { loc = l; }
+    void setLocator(const Locator* l) { loc = l; }
     void setFlags(unsigned f); 
     virtual void setParent(Node* parent);
 
@@ -388,7 +388,7 @@
     unsigned id : 8;         ///< Really a value in NodeIDs
     unsigned flags : 24;     ///< 24 boolean flags, subclass dependent interp.
     Node* parent;            ///< The node that owns this node.
-    Locator loc;             ///< The source location corresponding to node.
+    const Locator* loc;      ///< The source location corresponding to node.
   /// @}
   friend class AST;
 };

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Type.cpp (original)
+++ hlvm/trunk/hlvm/AST/Type.cpp Sat Jul  7 19:00:11 2007
@@ -245,7 +245,7 @@
   return type->getPrimitiveName();
 }
 
-StringType::~StringType()
+TextType::~TextType()
 {
 }
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Type.h (original)
+++ hlvm/trunk/hlvm/AST/Type.h Sat Jul  7 19:00:11 2007
@@ -581,23 +581,23 @@
   /// @}
 };
 
-class StringType : public Type
+class TextType : public Type
 {
   /// @name Constructors
   /// @{
   public:
-    StringType(const std::string& nm) : 
-      Type(StringTypeID) { this->setName(nm); }
+    TextType(const std::string& nm) : 
+      Type(TextTypeID) { this->setName(nm); }
   public:
-    virtual ~StringType();
+    virtual ~TextType();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    static inline bool classof(const StringType*) { return true; }
+    static inline bool classof(const TextType*) { return true; }
     static inline bool classof(const Node* N) 
-      { return N->is(StringTypeID); }
+      { return N->is(TextTypeID); }
 
   /// @}
   friend class AST;

Copied: hlvm/trunk/hlvm/AST/URI.cpp (from r38135, hlvm/trunk/hlvm/Base/URI.cpp)
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/URI.cpp?p2=hlvm/trunk/hlvm/AST/URI.cpp&p1=hlvm/trunk/hlvm/Base/URI.cpp&r1=38135&r2=38136&rev=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Base/URI.cpp (original)
+++ hlvm/trunk/hlvm/AST/URI.cpp Sat Jul  7 19:00:11 2007
@@ -27,52 +27,92 @@
 /// @brief Declares the class hlvm::Base::URI
 //===----------------------------------------------------------------------===//
 
-#include <hlvm/Base/URI.h>
-#include <hlvm/Base/Memory.h>
+#include <hlvm/AST/URI.h>
+#include <hlvm/Base/Pool.h>
+#include <apr-1/apr_uri.h>
+#include <apr-1/apr_pools.h>
 #include <iostream>
 
-namespace hlvm { namespace Base {
-
-URI::URI( const char * text)
+namespace 
 {
-  apr_uri_parse(POOL, text, &uri_);
-}
 
-URI::URI( const std::string& str)
+class URIImpl : public hlvm::URI 
 {
-  apr_uri_parse(POOL, str.c_str(), &uri_);
-}
+  apr_pool_t* pool;
+  apr_uri_t uri_;
 
-URI::~URI ( void )
-{
-}
+public:
+  URIImpl(hlvm::Pool* p) 
+    : pool(reinterpret_cast<apr_pool_t*>(p->getAprPool())) {}
+
+  virtual const char* const scheme() const { return uri_.scheme; }
+  virtual const char* const password() const { return uri_.password; }
+  virtual const char* const user() const { return uri_.user; }
+  virtual const char* const hostname() const { return uri_.hostname; }
+  virtual uint32_t port() const { return atoi(uri_.port_str); }
+  virtual const char* const path() const { return uri_.path; }
+  virtual const char* const query() const { return uri_.query; }
+  virtual const char* const fragment() const { return uri_.fragment; }
+
+  virtual hlvm::URI& assign( const hlvm::URI& that ) {
+    this->uri_ = reinterpret_cast<const URIImpl&>(that).uri_;
+    return *this;
+  }
+
+  virtual const char* const hostinfo() const { return ""; }
+  virtual bool equals(const hlvm::URI& uri) const { 
+    if (&uri == this)
+      return true;
+    return uri.as_string() == this->as_string();
+  }
+
+  virtual void assign( const std::string& that ) {
+    apr_uri_parse(pool, that.c_str(), &uri_);
+  }
+  virtual void clear( void ) {}
+  virtual void scheme( const char* const scheme ) {}
+  virtual void opaque( const char* const opaque ) {}
+  virtual void authority( const char* const authority ) {}
+  virtual void user( const char* const user ) {}
+  virtual void server( const char* const server ) {}
+  virtual void port( uint32_t portnum ) {}
+
+  virtual std::string as_string( void ) const {
+    const char* result = apr_uri_unparse(pool, &uri_, 0);
+    return std::string( result );
+  }
+
+  void get_string(std::string& str) const {
+    str = apr_uri_unparse(pool, &uri_, 0);
+  }
+
+  std::string resolveToFile() const {
+    const char* scheme = this->scheme();
+    if (scheme)
+    {
+      if (strncmp("file",this->scheme(),4) == 0)
+      {
+        return this->path();
+      }
+    }
+    return "";
+  }
+};
 
-std::string 
-URI::as_string( void ) const
-{
-  const char* result = apr_uri_unparse(POOL, &uri_, 0);
-  return std::string( result );
 }
 
-/// @brief Clears the URI, releases memory.
-void 
-URI::clear( void )
+namespace hlvm {
+
+URI::~URI ( void )
 {
-  /// FIXME: how do we do this with the APR pools?
 }
 
-std::string 
-URI::resolveToFile() const
+URI*
+URI::create( const std::string& str, Pool* p)
 {
-  const char* scheme = this->scheme();
-  if (scheme)
-  {
-    if (strncmp("file",this->scheme(),4) == 0)
-    {
-      return this->path();
-    }
-  }
-  return "";
+  URIImpl* result = new URIImpl(p);
+  result->assign(str);
+  return result;
 }
 
-}}
+}

Copied: hlvm/trunk/hlvm/AST/URI.h (from r38135, hlvm/trunk/hlvm/Base/URI.h)
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/URI.h?p2=hlvm/trunk/hlvm/AST/URI.h&p1=hlvm/trunk/hlvm/Base/URI.h&r1=38135&r2=38136&rev=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Base/URI.h (original)
+++ hlvm/trunk/hlvm/AST/URI.h Sat Jul  7 19:00:11 2007
@@ -27,13 +27,16 @@
 /// @brief Declares the class hlvm::Base::URI
 //===----------------------------------------------------------------------===//
 
-#ifndef HLVM_BASE_URI_H
-#define HLVM_BASE_URI_H
+#ifndef HLVM_AST_URI_H
+#define HLVM_AST_URI_H
 
-#include <apr-1/apr_uri.h>
 #include <string>
 
-namespace hlvm { namespace Base {
+namespace hlvm {
+
+// Forward References
+class AST; 
+class Pool;
 
 /// A class to represent Uniform Resource Identifiers (URIs). This class can
 /// also support URLs and URNs. The implementation is based on the APR-UTIL
@@ -56,20 +59,15 @@
 /// @name Constructors
 /// @{
 public:
-  /// @brief Default Constructor builds empty uri
-  URI ( void );
-
-  /// @brief Parsing constructor builds uri by parsing the string parameter
-  URI( const char * str );
-
   /// @brief Parsing constructor builds uri by parsing the string parameter
-  URI( const std::string& xmlStr);
+  static URI* create( const std::string& xmlStr, Pool* p);
 
-  /// @brief Copy Constructor.
-  URI ( const URI & that );
+  virtual ~URI ( void );
 
-  /// @brief Destructor.
-  ~URI ( void );
+protected:
+  // This is an abstract class, don't allow instantiation
+  URI () {}
+  URI ( const URI & that ) {}
 
 /// @}
 /// @name Operators
@@ -88,72 +86,72 @@
 
   /// @brief Return the URI as a string (escaped). Caller must
   /// free the returned string.
-  std::string as_string( void ) const;
+  virtual std::string as_string( void ) const = 0;
 
   /// @brief Set a string to the value of the URI with escapes.
-  void get_string( std::string& str_to_fill ) const;
+  virtual void get_string( std::string& str_to_fill ) const = 0;
 
   /// @brief Return the scheme of the URI
-  const char* const scheme() const;
+  virtual const char* const scheme() const = 0;
 
   /// @brief Return the password part of the URI
-  const char* const password() const;
+  virtual const char* const password() const = 0;
 
   /// @brief Return the user part of the URI
-  const char* const user() const;
+  virtual const char* const user() const = 0;
 
   /// @brief Return the host name from the URI
-  const char* const hostname() const;
+  virtual const char* const hostname() const = 0;
 
   /// @brief Return the combined [user[:password]\@host:port/ part of the URI
-  const char* const hostinfo() const;
+  virtual const char* const hostinfo() const = 0;
 
   /// @brief Return the port part of the URI
-  uint32_t port() const;
+  virtual uint32_t port() const = 0;
 
   /// @brief Return the path part of the URI
-  const char* const path() const;
+  virtual const char* const path() const = 0;
 
   /// @brief Return the query part of the URI
-  const char* const query() const;
+  virtual const char* const query() const = 0;
 
   /// @brief Return the fragment identifier part of the URI
-  const char* const fragment() const;
+  virtual const char* const fragment() const = 0;
 
   /// @brief Determines if two URIs are equal
-  bool equals( const URI& that ) const;
+  virtual bool equals( const URI& that ) const = 0;
 
-  std::string resolveToFile() const;
+  virtual std::string resolveToFile() const = 0;
 /// @}
 /// @name Mutators
 /// @{
 public:
   /// @brief Assignment of one URI to another
-  URI& assign( const URI& that );
+  virtual URI& assign( const URI& that ) = 0;
 
   /// @brief Assignment of an std::string to a URI. 
-  void assign( const std::string& that );
+  virtual void assign( const std::string& that ) = 0;
 
   /// @brief Clears the URI, releases memory.
-  void clear( void );
+  virtual void clear( void ) = 0;
 
   /// @brief Sets the scheme
-  //void scheme( const char* const scheme );
+  virtual void scheme( const char* const scheme ) = 0;
 
   /// @brief Set the opaque part of the URI
-  //void opaque( const char* const opaque );
+  virtual void opaque( const char* const opaque ) = 0;
 
   /// @brief Sets the authority.
-  //void authority( const char* const authority );
+  virtual void authority( const char* const authority ) = 0;
 
   /// @brief Sets the user.
-  //void user( const char* const user );
+  virtual void user( const char* const user ) = 0;
 
   /// @brief Sets the server.
-  //void server( const char* const server );
+  virtual void server( const char* const server ) = 0;
 
   /// @brief Sets the port.
-  //void port( uint32_t portnum );
+  virtual void port( uint32_t portnum ) = 0;
 
 /// @}
 /// @name Functions
@@ -162,36 +160,9 @@
   static uint32_t port_for_scheme( const char* scheme );
 
 /// @}
-/// @name Data
-/// @{
-private:
-  apr_uri_t uri_;
-/// @}
-/// @name Unimplemented
-/// @{
-private:
-/// @}
 
 };
 
-inline
-URI::URI()
-{
-}
-
-inline URI&
-URI::assign( const URI& that )
-{
-  this->uri_ = that.uri_;
-  return *this;
-}
-
-inline
-URI::URI ( const URI & that )
-{
-  this->assign(that);
-}
-
 inline URI & 
 URI::operator = ( const URI & that )
 {
@@ -204,54 +175,6 @@
   return this->equals(that);
 }
 
-inline const char* const
-URI::scheme() const
-{
-  return uri_.scheme;
-}
-
-inline const char* const
-URI::password() const
-{
-  return uri_.password;
-}
-
-inline const char* const
-URI::user() const 
-{
-  return uri_.user;
-}
-
-inline const char* const
-URI::hostname() const 
-{
-  return uri_.hostname;
-}
-
-inline uint32_t 
-URI::port() const 
-{
-  return atoi(uri_.port_str);
-}
-
-inline const char* const
-URI::path() const 
-{
-  return uri_.path;
-}
-
-inline const char* const
-URI::query() const 
-{
-  return uri_.query;
-}
-
-inline const char* const
-URI::fragment() const 
-{
-  return uri_.fragment;
-}
-
-}}
+} // end hlvm namespace
 
 #endif

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Variable.cpp (original)
+++ hlvm/trunk/hlvm/AST/Variable.cpp Sat Jul  7 19:00:11 2007
@@ -31,15 +31,6 @@
 
 namespace hlvm {
 
-Variable* 
-Variable::create(const Locator& loc, std::string name)
-{
-  Variable* result = new Variable();
-  result->setName(name);
-  result->setLocator(loc);
-  return result;
-}
-
 Variable::~Variable()
 {
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Variable.h (original)
+++ hlvm/trunk/hlvm/AST/Variable.h Sat Jul  7 19:00:11 2007
@@ -58,7 +58,7 @@
   /// @name Accessors
   /// @{
   public:
-    Type* getType() const { return type; }
+    const Type* getType() const { return type; }
     static inline bool classof(const Variable*) { return true; }
     static inline bool classof(const Node* N) { return N->isVariable(); }
 
@@ -66,13 +66,13 @@
   /// @name Accessors
   /// @{
   public:
-    void setType(Type* t) { type = t; }
+    void setType(const Type* t) { type = t; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    Type* type; ///< The type of the variable
+    const Type* type; ///< The type of the variable
   /// @}
   friend class AST;
 };

Modified: hlvm/trunk/hlvm/Base/Assert.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Assert.h?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Base/Assert.h (original)
+++ hlvm/trunk/hlvm/Base/Assert.h Sat Jul  7 19:00:11 2007
@@ -110,4 +110,8 @@
 #define hlvmRangeCheck(value,min,max) {}
 #endif
 
+namespace hlvm {
+void panic(const char* msg);
+}
+
 #endif

Modified: hlvm/trunk/hlvm/Base/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Memory.cpp?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Base/Memory.cpp (original)
+++ hlvm/trunk/hlvm/Base/Memory.cpp Sat Jul  7 19:00:11 2007
@@ -30,11 +30,12 @@
 #include <hlvm/Base/Memory.h>
 #include <hlvm/Base/Assert.h>
 #include <llvm/System/Signals.h>
+#include <apr-1/apr_general.h>
 #include <memory>
 #include <new>
 #include <iostream>
 
-namespace hlvm { namespace Base {
+namespace hlvm {
 
 // The following provides a 64KByte emergency memory reserve for the program 
 // heap.  Application writers are encouraged to use the memory facilities 
@@ -54,7 +55,7 @@
   }
   else
   {
-    hlvmAssert( _memory_reserve != 0 && "No memory!");
+    panic("No memory");
   }
 }
 
@@ -85,9 +86,8 @@
   return _memory_reserve == 0;
 }
 
-apr_pool_t* POOL = 0;
-
 static bool initialized = false;
+
 void
 initialize(int& /*argc*/, char** /*argv*/)
 {
@@ -111,10 +111,6 @@
       if (APR_SUCCESS != apr_initialize())
         hlvmAssert(!"Can't initialize APR");
 
-      // Allocate the master pool
-      if (APR_SUCCESS != apr_pool_create(&POOL,0))
-        hlvmAssert(!"Can't allocate the master pool");
-
 #ifdef XPS_DEBUG
       // Make sure we print stack trace if we get bad signals
       llvm::sys::PrintStackTraceOnErrorSignal();
@@ -150,16 +146,11 @@
   }
 }
 
-}}
-
-void* 
-operator new(size_t size, apr_pool_t* pool) 
+void
+panic(const char* msg)
 {
-  return apr_palloc(pool,size);
+  std::cerr << "HLVM PANIC: " << msg << "\n";
+  exit(99);
 }
 
-void*
-operator new[](size_t size, apr_pool_t* pool)
-{
-  return apr_palloc(pool,size);
-}
+} // end hlvm namespace

Modified: hlvm/trunk/hlvm/Base/Memory.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Memory.h?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Base/Memory.h (original)
+++ hlvm/trunk/hlvm/Base/Memory.h Sat Jul  7 19:00:11 2007
@@ -30,16 +30,7 @@
 #ifndef HLVM_BASE_MEMORY_H
 #define HLVM_BASE_MEMORY_H
 
-#include <apr-1/apr_pools.h>
-
-namespace hlvm { namespace Base {
-
-/// An APR pool to allocate memory into. This is the master pool of all XPS
-/// allocated pools and generally the one used to allocate APRish stuff into.
-/// Note that this doesn't exist until after the call to initialize()
-/// @see initialize
-/// @brief The main memory pool for XPS
-extern apr_pool_t* POOL;
+namespace hlvm {
 
 /// Determine if emergency memory reserve has been exhausted.
 /// @brief Detemine if heap memory is low.
@@ -48,9 +39,6 @@
 void initialize(int& argc, char**argv );
 void terminate();
 
-}}
-
-void* operator new(size_t size, apr_pool_t* pool);
-void* operator new[](size_t size, apr_pool_t* pool);
+} // end hlvm namespace
 
 #endif

Added: hlvm/trunk/hlvm/Base/Pool.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Pool.cpp?rev=38136&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/Pool.cpp (added)
+++ hlvm/trunk/hlvm/Base/Pool.cpp Sat Jul  7 19:00:11 2007
@@ -0,0 +1,217 @@
+//===-- HLVM Memory Pool Implementation -------------------------*- 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/Base/Pool.cpp
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/06/01
+/// @since 0.1.0
+/// @brief Defines the hlvm::Pool class 
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/Base/Pool.h>
+#include <hlvm/Base/Assert.h>
+#include <llvm/ADT/StringExtras.h>
+
+// Set up the maximum amount of APR pool debugging if we're in debug mode
+// This must be set before including apr_pools.h
+#ifdef HLVM_DEBUG
+#define APR_POOL_DEBUG 0xFF
+#endif
+#include <apr-1/apr_pools.h>
+
+namespace {
+
+/// Base class for all pool implementations
+class PoolBase : public hlvm::Pool {
+  protected:
+    PoolBase(
+      const std::string& name, Pool* parent, const char * where 
+    )
+      : Pool(name,parent)
+    {
+      if (parent)
+        allocator = 0;
+      else
+        if (APR_SUCCESS != apr_allocator_create(&allocator))
+          hlvm::panic("Can't create APR allocator");
+
+#ifdef HLVM_DEBUG
+      if (APR_SUCCESS != apr_pool_create_ex_debug(&pool,
+          (parent?static_cast<const PoolBase*>(parent->getParent())->pool:0), 
+           aborter, allocator, where))
+#else
+      if (APR_SUCCESS != apr_pool_create_ex(&pool,
+          (parent?static_cast<const PoolBase*>(parent->getParent())->pool:0), 
+           aborter, allocator))
+#endif
+        hlvm::panic("Can't create APR pool");
+    }
+    virtual void* getAprPool() {
+      return pool;
+    }
+  protected:
+    static int aborter(int retcode) {
+      std::string msg("Pool abort: retcode=");
+      msg += llvm::itostr(retcode);
+      hlvm::panic(msg.c_str());
+      return 0;
+    }
+
+  protected:
+    apr_pool_t* pool;
+    apr_allocator_t* allocator;
+};
+
+/// A non-deallocating pool. This is fast, but should only be used for pools
+/// where it doesn't matter if the objects in the pool can be deallocated. 
+class ConstPool : public PoolBase {
+  /// @name Constructors
+  /// @{
+  public:
+    ConstPool(const std::string& name, Pool* parent, const char * where)
+      : PoolBase(name,parent,where)
+    {
+    }
+  /// @}
+  /// @name Allocators
+  /// @{
+  public:
+    virtual void* allocate(size_t block_size, const char* where) {
+      return 0;
+    }
+
+    virtual void* callocate(size_t block_siz, const char* where ) {
+      return 0;
+    }
+
+    virtual void deallocate(void* block, const char* where) {
+    }
+
+    virtual void clear(const char* where) {
+    }
+  /// @}
+};
+
+/// A very efficient pool for creating lots of small objects in a range of
+/// sizes from tiny to moderate. This re-uses deallocated blocks of a similar
+/// size so a new allocation is not needed. Handles memory churn of small 
+/// objects well.
+class SmallPool : public PoolBase {
+  /// @name Constructors
+  /// @{
+  public:
+    SmallPool(const std::string& name, Pool* parent, 
+              uint32_t max_size, uint32_t increment, const char * where)
+      : PoolBase(name,parent,where)
+    {
+    }
+  /// @}
+  /// @name Allocators
+  /// @{
+  public:
+    virtual void* allocate(size_t block_size, const char* where) {
+      return 0;
+    }
+
+    virtual void* callocate(size_t block_siz, const char* where ) {
+      return 0;
+    }
+
+    virtual void deallocate(void* block, const char* where) {
+    }
+
+    virtual void clear(const char* where) {
+    }
+  /// @}
+};
+
+/// A simple allocator/deallocator similar to malloc. General purpose, nothing
+/// fancy.
+class SimplePool : public PoolBase {
+  /// @name Constructors
+  /// @{
+  public:
+    SimplePool(const std::string& name, Pool* parent, const char * where)
+      : PoolBase(name,parent,where)
+    {
+    }
+  /// @}
+  /// @name Allocators
+  /// @{
+  public:
+    virtual void* allocate(size_t block_size, const char* where) {
+      return 0;
+    }
+
+    virtual void* callocate(size_t block_siz, const char* where ) {
+      return 0;
+    }
+
+    virtual void deallocate(void* block, const char* where) {
+    }
+
+    virtual void clear(const char* where) {
+    }
+  /// @}
+};
+
+} // end anonymous namespace
+
+namespace hlvm {
+
+// Just to get the vtable in this file
+Pool::~Pool()
+{
+}
+
+// The interface to creating one of the pool classes
+Pool*
+Pool::create(
+  const std::string& name,
+  Pool* parent,
+  bool no_dealloc,
+  uint32_t max_elem_size,
+  uint32_t increment,
+  const char* where
+)
+{
+  // If they don't want to deallocate, they always get a ConstPool
+  if (no_dealloc)
+    return new ConstPool(name,parent,where);
+
+  // If they've specified an elem size and increment then if that combination
+  // yields a table of less than 16K entries the we allocate a SmallPool. This
+  // keeps the SmallPool's entry table under 64KBytes on a 32-bit machine.
+  if (max_elem_size > 0 && increment > 0 && max_elem_size / increment <= 16384)
+    return new SmallPool(name,parent,max_elem_size,increment,where);
+
+  // Just use a standard pool
+  return new SimplePool(name,parent,where);
+}
+
+void Pool::destroy(Pool* p, const char* where)
+{
+  p->clear(where);
+  delete p;
+}
+
+} // end hlvm namespace

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

==============================================================================
--- hlvm/trunk/hlvm/Base/Pool.h (added)
+++ hlvm/trunk/hlvm/Base/Pool.h Sat Jul  7 19:00:11 2007
@@ -0,0 +1,127 @@
+//===-- HLVM Memory Pool Facilities -----------------------------*- 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/Base/Pool.h
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/06/01
+/// @since 0.1.0
+/// @brief Declares the hlvm::Pool class and memory pooling facilities for HLVM
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_BASE_POOL_H
+#define HLVM_BASE_POOL_H
+
+#ifdef HLVM_DEBUG
+#define HLVM_STRINGIZE(X) #X
+#define HLVM_NEW(pool,type,args) \
+  (::new(pool,__FILE__ ":" HLVM_STRINGIZE(__LINE__)) type args )
+#else
+#define HLVM_NEW(pool,type,args) \
+  (::new(pool) type args )
+#endif
+
+#include <string>
+
+namespace hlvm {
+
+/// A memory pool abstraction. This is the is is the master pool of all XPS
+/// allocated pools and generally the one used to allocate APRish stuff into.
+/// Note that this doesn't exist until after the call to initialize()
+/// @brief The memory pool for HLVM.
+class Pool {
+
+  /// @name Constructors
+  /// @{
+  protected:
+    Pool(const std::string& name, Pool* parent) {}
+    virtual ~Pool();
+  public:
+    static Pool* create(
+      const std::string& name = "", ///< name for the pool
+      Pool* parent = 0,             ///< parent pool, 0 = root pool
+      bool no_dealloc = false,      ///< allow deallocations?
+      uint32_t max_elem_size = 0,   ///< maximum allocation size, 0=max
+      uint32_t increment = 8,       ///< min difference between alloc sizes
+      const char * where = 0        ///< location of the pool creation
+    );
+
+    static void destroy(Pool* p, const char* where = 0);
+
+  /// @}
+  /// @name Allocators
+  /// @{
+  public:
+    /// Allocate a block of data of size block_size and return it
+    virtual void* allocate(size_t block_size, const char* where = 0) = 0;
+
+    /// Allocate a block of data of size block_size, zero its content  and 
+    /// return it
+    virtual void* callocate(size_t block_siz, const char* where = 0 ) = 0;
+
+    /// Deallocate a block of data
+    virtual void deallocate(void* block, const char* where = 0) = 0;
+
+    /// Clear all memory in the pool and any sub-pools
+    virtual void clear(const char* where = 0) = 0; 
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    const std::string& getName() { return name; }
+    const Pool* getParent() { return parent; }
+    virtual void* getAprPool() = 0;
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    std::string name;
+    Pool* parent;
+  /// @}
+};
+
+} // end hlvm namespace
+
+#ifdef HLVM_DEBUG
+inline void* operator new(size_t size, hlvm::Pool* p, const char* where)
+{
+  return p->callocate(size,where);
+}
+
+inline void* operator new[](size_t size, hlvm::Pool* p, const char* where)
+{
+  return p->callocate(size,where);
+}
+#else
+inline void* operator new(size_t size, hlvm::Pool* p)
+{
+  return p->callocate(size);
+}
+
+inline void* operator new[](size_t size, hlvm::Pool* p)
+{
+  return p->callocate(size);
+}
+#endif
+
+#endif

Modified: hlvm/trunk/hlvm/Base/Source.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Source.cpp?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Base/Source.cpp (original)
+++ hlvm/trunk/hlvm/Base/Source.cpp Sat Jul  7 19:00:11 2007
@@ -28,6 +28,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <hlvm/Base/Source.h>
+#include <hlvm/AST/URI.h>
 #include <llvm/System/MappedFile.h>
 #include <iostream>
 #include <ios>
@@ -37,7 +38,7 @@
 namespace 
 {
 
-class MappedFileSource : public Base::Source 
+class MappedFileSource : public Source 
 {
 public:
   MappedFileSource(llvm::sys::MappedFile& mf)
@@ -105,7 +106,7 @@
   intptr_t read_len_;
 };
 
-class StreamSource : public Base::Source 
+class StreamSource : public Source 
 {
 public:
   StreamSource(std::istream& strm, std::string sysId, size_t bsize) : s_(strm) 
@@ -178,19 +179,19 @@
   size_t buffSize;
 };
 
-class URISource : public Base::Source 
+class URISource : public Source 
 {
 private:
-  hlvm::Base::URI uri_;
+  const hlvm::URI* uri_;
   llvm::sys::MappedFile* mf_;
   MappedFileSource* mfs_;
 public:
-  URISource(const Base::URI& uri ) 
+  URISource(const URI* uri ) 
     : uri_(uri) 
     , mf_(0)
     , mfs_(0)
   {
-    mf_ = new llvm::sys::MappedFile(llvm::sys::Path(uri_.resolveToFile()));
+    mf_ = new llvm::sys::MappedFile(llvm::sys::Path(uri_->resolveToFile()));
     mfs_ = new MappedFileSource(*mf_);
   }
   virtual ~URISource() {}
@@ -205,7 +206,7 @@
 
 }
 
-namespace hlvm { namespace Base {
+namespace hlvm {
 
 Source::~Source() 
 {
@@ -225,9 +226,9 @@
 }
 
 Source* 
-new_URISource(const Base::URI& uri)
+new_URISource(const URI* uri)
 {
   return new URISource(uri);
 }
 
-}}
+} // end hlvm namespace

Modified: hlvm/trunk/hlvm/Base/Source.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Source.h?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Base/Source.h (original)
+++ hlvm/trunk/hlvm/Base/Source.h Sat Jul  7 19:00:11 2007
@@ -30,50 +30,52 @@
 #ifndef HLVM_BASE_SOURCE_H
 #define HLVM_BASE_SOURCE_H
 
-#include <hlvm/Base/URI.h>
 #include <llvm/System/MappedFile.h>
 #include <istream>
 
-namespace hlvm { namespace Base {
-  /// This class is the base class of a family of input source classes that can
-  /// be used to provide input to some parsing facility. This abstracts away
-  /// the details of how the input is acquired. Four functions must be 
-  /// implemented by subclasses: prepare, more, read, and finish.
-  /// @brief Abstract Input Source Class
-  class Source
-  {
-  /// @name Methods
-  /// @{
-  public:
-    /// @brief This destructor does nothing, but declared virtual for subclasses
-    virtual ~Source();
-
-    /// @brief Tells the source to prepare to be read
-    virtual void prepare(intptr_t block_len) = 0;
-
-    /// @brief Requests a block of data.
-    virtual const char* read(intptr_t& actual_len) = 0;
-
-    /// @brief Indicates if more data waits
-    virtual bool more() = 0;
-
-    /// @brief Tells the source to finish up.
-    virtual void finish() = 0;
-
-    /// @brief Get the system identifier of the source
-    virtual std::string systemId() const = 0;
-
-    /// @brief Get the public identifier of the source
-    virtual std::string publicId() const = 0;
-
-  /// @}
-  };
-
-  Source* new_MappedFileSource(llvm::sys::MappedFile& mf);
-  Source* new_StreamSource(std::istream&, std::string sysId = "<istream>", 
-      size_t bSize = 65536);
-  Source* new_URISource(const URI& uri);
+namespace hlvm {
 
-}}
+class URI;
+
+/// This class is the base class of a family of input source classes that can
+/// be used to provide input to some parsing facility. This abstracts away
+/// the details of how the input is acquired. Four functions must be 
+/// implemented by subclasses: prepare, more, read, and finish.
+/// @brief Abstract Input Source Class
+class Source
+{
+/// @name Methods
+/// @{
+public:
+  /// @brief This destructor does nothing, but declared virtual for subclasses
+  virtual ~Source();
+
+  /// @brief Tells the source to prepare to be read
+  virtual void prepare(intptr_t block_len) = 0;
+
+  /// @brief Requests a block of data.
+  virtual const char* read(intptr_t& actual_len) = 0;
+
+  /// @brief Indicates if more data waits
+  virtual bool more() = 0;
+
+  /// @brief Tells the source to finish up.
+  virtual void finish() = 0;
+
+  /// @brief Get the system identifier of the source
+  virtual std::string systemId() const = 0;
+
+  /// @brief Get the public identifier of the source
+  virtual std::string publicId() const = 0;
+
+/// @}
+};
+
+Source* new_MappedFileSource(llvm::sys::MappedFile& mf);
+Source* new_StreamSource(std::istream&, std::string sysId = "<istream>", 
+    size_t bSize = 65536);
+Source* new_URISource(const URI* uri);
+
+} // end hlvm namespace
 
 #endif

Removed: hlvm/trunk/hlvm/Base/URI.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/URI.cpp?rev=38135&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/URI.cpp (original)
+++ hlvm/trunk/hlvm/Base/URI.cpp (removed)
@@ -1,78 +0,0 @@
-//===-- Uniform Resource Identifier -----------------------------*- 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/Base/URI.cpp
-/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
-/// @date 2006/05/04
-/// @since 0.1.0
-/// @brief Declares the class hlvm::Base::URI
-//===----------------------------------------------------------------------===//
-
-#include <hlvm/Base/URI.h>
-#include <hlvm/Base/Memory.h>
-#include <iostream>
-
-namespace hlvm { namespace Base {
-
-URI::URI( const char * text)
-{
-  apr_uri_parse(POOL, text, &uri_);
-}
-
-URI::URI( const std::string& str)
-{
-  apr_uri_parse(POOL, str.c_str(), &uri_);
-}
-
-URI::~URI ( void )
-{
-}
-
-std::string 
-URI::as_string( void ) const
-{
-  const char* result = apr_uri_unparse(POOL, &uri_, 0);
-  return std::string( result );
-}
-
-/// @brief Clears the URI, releases memory.
-void 
-URI::clear( void )
-{
-  /// FIXME: how do we do this with the APR pools?
-}
-
-std::string 
-URI::resolveToFile() const
-{
-  const char* scheme = this->scheme();
-  if (scheme)
-  {
-    if (strncmp("file",this->scheme(),4) == 0)
-    {
-      return this->path();
-    }
-  }
-  return "";
-}
-
-}}

Removed: hlvm/trunk/hlvm/Base/URI.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/URI.h?rev=38135&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/URI.h (original)
+++ hlvm/trunk/hlvm/Base/URI.h (removed)
@@ -1,257 +0,0 @@
-//===-- Uniform Resource Identifier -----------------------------*- 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/Base/URI.h
-/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
-/// @date 2006/05/04
-/// @since 0.1.0
-/// @brief Declares the class hlvm::Base::URI
-//===----------------------------------------------------------------------===//
-
-#ifndef HLVM_BASE_URI_H
-#define HLVM_BASE_URI_H
-
-#include <apr-1/apr_uri.h>
-#include <string>
-
-namespace hlvm { namespace Base {
-
-/// A class to represent Uniform Resource Identifiers (URIs). This class can
-/// also support URLs and URNs. The implementation is based on the APR-UTIL
-/// apr_uri set of functions and associated data types. 
-/// @see RFC 2396 states that hostnames take the form described in 
-/// @see RFC 1034 (Section 3) Hostname Syntax
-/// @see RFC 1123 (Section 2.1). Hostnames
-/// @see RFC 1609 Universal Resource Identifiers in WWW - Berners-Lee.
-/// @see RFC 1738 Uniform Resource Locators - Berners-Lee.
-/// @see RFC 1808 Relative Uniform Resource Locators - Fielding
-/// @see RFC 2059 Uniform Resource Locators for z39.50 - Denenberg
-/// @see RFC 2111 Content-ID and Message-ID Uniform Resource Locators-Levinson
-/// @see RFC 2396 Uniform Resource Identifiers (URI) - Berners-Lee
-/// @see RFC 3305 URI/URL/URN Clarifications and Recommendations - Mealling
-/// @see RFC 3406 URN Namespace Definition Mechanisms - Daigle
-/// @see RFC 3508 URL Schem Registration - Levin
-/// @brief HLVM Uniform Resource Identifier Class
-class URI
-{
-/// @name Constructors
-/// @{
-public:
-  /// @brief Default Constructor builds empty uri
-  URI ( void );
-
-  /// @brief Parsing constructor builds uri by parsing the string parameter
-  URI( const char * str );
-
-  /// @brief Parsing constructor builds uri by parsing the string parameter
-  URI( const std::string& xmlStr);
-
-  /// @brief Copy Constructor.
-  URI ( const URI & that );
-
-  /// @brief Destructor.
-  ~URI ( void );
-
-/// @}
-/// @name Operators
-/// @{
-public:
-  /// @brief Equality Operator.
-  bool operator == ( const URI & that ) const;
-
-  /// @brief Assignment Operator.
-  URI & operator = ( const URI & that );
-
-/// @}
-/// @name Accessors
-/// @{
-public:
-
-  /// @brief Return the URI as a string (escaped). Caller must
-  /// free the returned string.
-  std::string as_string( void ) const;
-
-  /// @brief Set a string to the value of the URI with escapes.
-  void get_string( std::string& str_to_fill ) const;
-
-  /// @brief Return the scheme of the URI
-  const char* const scheme() const;
-
-  /// @brief Return the password part of the URI
-  const char* const password() const;
-
-  /// @brief Return the user part of the URI
-  const char* const user() const;
-
-  /// @brief Return the host name from the URI
-  const char* const hostname() const;
-
-  /// @brief Return the combined [user[:password]\@host:port/ part of the URI
-  const char* const hostinfo() const;
-
-  /// @brief Return the port part of the URI
-  uint32_t port() const;
-
-  /// @brief Return the path part of the URI
-  const char* const path() const;
-
-  /// @brief Return the query part of the URI
-  const char* const query() const;
-
-  /// @brief Return the fragment identifier part of the URI
-  const char* const fragment() const;
-
-  /// @brief Determines if two URIs are equal
-  bool equals( const URI& that ) const;
-
-  std::string resolveToFile() const;
-/// @}
-/// @name Mutators
-/// @{
-public:
-  /// @brief Assignment of one URI to another
-  URI& assign( const URI& that );
-
-  /// @brief Assignment of an std::string to a URI. 
-  void assign( const std::string& that );
-
-  /// @brief Clears the URI, releases memory.
-  void clear( void );
-
-  /// @brief Sets the scheme
-  //void scheme( const char* const scheme );
-
-  /// @brief Set the opaque part of the URI
-  //void opaque( const char* const opaque );
-
-  /// @brief Sets the authority.
-  //void authority( const char* const authority );
-
-  /// @brief Sets the user.
-  //void user( const char* const user );
-
-  /// @brief Sets the server.
-  //void server( const char* const server );
-
-  /// @brief Sets the port.
-  //void port( uint32_t portnum );
-
-/// @}
-/// @name Functions
-/// @{
-public:
-  static uint32_t port_for_scheme( const char* scheme );
-
-/// @}
-/// @name Data
-/// @{
-private:
-  apr_uri_t uri_;
-/// @}
-/// @name Unimplemented
-/// @{
-private:
-/// @}
-
-};
-
-inline
-URI::URI()
-{
-}
-
-inline URI&
-URI::assign( const URI& that )
-{
-  this->uri_ = that.uri_;
-  return *this;
-}
-
-inline
-URI::URI ( const URI & that )
-{
-  this->assign(that);
-}
-
-inline URI & 
-URI::operator = ( const URI & that )
-{
-  return this->assign(that);
-}
-
-inline bool 
-URI::operator == ( const URI & that ) const
-{
-  return this->equals(that);
-}
-
-inline const char* const
-URI::scheme() const
-{
-  return uri_.scheme;
-}
-
-inline const char* const
-URI::password() const
-{
-  return uri_.password;
-}
-
-inline const char* const
-URI::user() const 
-{
-  return uri_.user;
-}
-
-inline const char* const
-URI::hostname() const 
-{
-  return uri_.hostname;
-}
-
-inline uint32_t 
-URI::port() const 
-{
-  return atoi(uri_.port_str);
-}
-
-inline const char* const
-URI::path() const 
-{
-  return uri_.path;
-}
-
-inline const char* const
-URI::query() const 
-{
-  return uri_.query;
-}
-
-inline const char* const
-URI::fragment() const 
-{
-  return uri_.fragment;
-}
-
-}}
-
-#endif

Modified: hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp (original)
+++ hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp Sat Jul  7 19:00:11 2007
@@ -48,6 +48,7 @@
 #include <llvm/DerivedTypes.h>
 #include <llvm/TypeSymbolTable.h>
 #include <llvm/Constants.h>
+#include <llvm/CallingConv.h>
 #include <llvm/Linker.h>
 #include <llvm/Bytecode/Writer.h>
 #include <llvm/PassManager.h>
@@ -56,6 +57,7 @@
 namespace {
 using namespace llvm;
 #include <hlvm/CodeGen/string_decl.inc>
+#include <hlvm/CodeGen/string_clear.inc>
 #include <hlvm/CodeGen/program.inc>
 }
 
@@ -174,7 +176,7 @@
       break;
     case RealTypeID:
       hlvmNotImplemented("arbitrary precision real");
-    case StringTypeID: {
+    case TextTypeID: {
       std::vector<const llvm::Type*> Fields;
       Fields.push_back(llvm::Type::UIntTy);
       Fields.push_back(llvm::PointerType::get(llvm::Type::UShortTy));

Modified: hlvm/trunk/hlvm/CodeGen/SConscript
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/CodeGen/SConscript?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/CodeGen/SConscript (original)
+++ hlvm/trunk/hlvm/CodeGen/SConscript Sat Jul  7 19:00:11 2007
@@ -25,6 +25,8 @@
 hlvm.GetCpp2LLVMCpp(env)
 env.Cpp2LLVMCpp('string_decl.inc','string.cxx',
   LLVM2CPPFLAGS='-gen-type -for struct._hlvm_string -funcname getStringDecl')
+env.Cpp2LLVMCpp('string_clear.inc','string.cxx',
+  LLVM2CPPFLAGS='-gen-inline -for _hlvm_string_clear -funcname getStringClear')
 env.Cpp2LLVMCpp('program.inc','program.cxx',
   LLVM2CPPFLAGS='-gen-contents -funcname "getProgramDef"')
 lib = env.Library('HLVMCodeGen',hlvm.GetAllCXXFiles(env))

Modified: hlvm/trunk/hlvm/CodeGen/string.cxx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/CodeGen/string.cxx?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/hlvm/CodeGen/string.cxx (original)
+++ hlvm/trunk/hlvm/CodeGen/string.cxx Sat Jul  7 19:00:11 2007
@@ -10,8 +10,17 @@
   _hlvm_char* ptr;
 };
 
-extern void _hlvm_string_clear(_hlvm_string* str); 
+extern void _hlvm_free_array(
+  void* array, 
+  _hlvm_size count, 
+  _hlvm_size elem_size
+);
 
-_hlvm_string astring;
+void _hlvm_string_clear(_hlvm_string* str) 
+{
+  _hlvm_free_array(str->ptr,str->len,sizeof(_hlvm_char));
+  str->len = 0;
+  str->ptr = 0;
+}
 
 }

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

==============================================================================
--- hlvm/trunk/hlvm/Pass/Validate.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Validate.cpp Sat Jul  7 19:00:11 2007
@@ -179,7 +179,7 @@
       break;
     case RationalTypeID:
       break; // Not implemented yet
-    case StringTypeID:
+    case TextTypeID:
       break; // Not imlpemented yet
     case AliasTypeID:
       validateAliasType(cast<AliasType>(n));

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

==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp Sat Jul  7 19:00:11 2007
@@ -61,12 +61,15 @@
   std::string path;
   AST* ast;
   xmlDocPtr doc;
+  Locator* loc;
+  URI* uri;
 public:
   XMLReaderImpl(const std::string& p)
-    : path(p), ast(0)
+    : path(p), ast(0), loc(0)
   {
     ast = AST::create();
     ast->setSystemID(p);
+    uri = URI::create(p,ast->getPool());
   }
 
   virtual ~XMLReaderImpl() 
@@ -87,6 +90,15 @@
     return HLVMTokenizer::lookup(token);
   }
 
+  Locator* getLocator(xmlNodePtr& cur) {
+    if (loc) {
+      LineLocator tmp(uri,cur->line);
+      if (*loc == tmp)
+        return loc;
+    }
+    return loc = new LineLocator(uri,cur->line);
+  }
+
   inline void handleParseError(xmlErrorPtr error);
   inline void handleValidationError(xmlErrorPtr error);
 
@@ -261,8 +273,7 @@
   }
   if (child) skipBlanks(child);
   hlvmAssert(!child && "Illegal chlldren of <bin> element");
-  Locator loc(cur->line,0,&ast->getSystemID());
-  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(getLocator(cur));
   result->setType(ast->getPrimitiveType(UInt64TypeID));
   result->setValue(value);
   return result;
@@ -285,8 +296,7 @@
   }
   if (child) skipBlanks(child);
   hlvmAssert(!child && "Illegal chlldren of <oct> element");
-  Locator loc(cur->line,0,&ast->getSystemID());
-  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(getLocator(cur));
   result->setType(ast->getPrimitiveType(UInt64TypeID));
   result->setValue(value);
   return result;
@@ -309,8 +319,7 @@
   }
   if (child) skipBlanks(child);
   hlvmAssert(!child && "Illegal chlldren of <dec> element");
-  Locator loc(cur->line,0,&ast->getSystemID());
-  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(getLocator(cur));
   result->setType(ast->getPrimitiveType(UInt64TypeID));
   result->setValue(value);
   return result;
@@ -353,8 +362,7 @@
   }
   if (child) skipBlanks(child);
   hlvmAssert(!child && "Illegal chlldren of <hex> element");
-  Locator loc(cur->line,0,&ast->getSystemID());
-  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(loc);
+  ConstLiteralInteger* result = ast->new_ConstLiteralInteger(getLocator(cur));
   result->setType(ast->getPrimitiveType(UInt64TypeID));
   result->setValue(value);
   return result;
@@ -366,7 +374,6 @@
   // Documentation is always optional so don't error out if the
   // node is not a TKN_doc
   if (cur && skipBlanks(cur) && getToken(cur->name) == TKN_doc) {
-    Locator loc(cur->line,0,&ast->getSystemID());
     xmlBufferPtr buffer = xmlBufferCreate();
     xmlNodeDump(buffer,doc,cur,0,0);
     int length = xmlBufferLength(buffer);
@@ -374,7 +381,7 @@
       str(reinterpret_cast<const char*>(xmlBufferContent(buffer)),length);
     str.erase(0,5); // Zap the <doc> at the start
     str.erase(str.length()-6); // Zap the </doc> at the end
-    Documentation* progDoc = ast->new_Documentation(loc);
+    Documentation* progDoc = ast->new_Documentation(getLocator(cur));
     progDoc->setDoc(str);
     xmlBufferFree(buffer);
     return progDoc;
@@ -399,9 +406,8 @@
 XMLReaderImpl::parseImport(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_import);
-  Locator loc(cur->line,0,&ast->getSystemID());
   std::string pfx = getAttribute(cur,"prefix");
-  Import* imp = ast->new_Import(loc,pfx);
+  Import* imp = ast->new_Import(pfx,getLocator(cur));
   checkDoc(cur,imp);
   return imp;
 }
@@ -410,10 +416,10 @@
 XMLReaderImpl::parseAlias(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_alias);
-  Locator loc(cur->line,0,&ast->getSystemID());
   std::string name = getAttribute(cur,"name");
   std::string type = getAttribute(cur,"renames");
-  AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
+  AliasType* alias = 
+    ast->new_AliasType(name,ast->resolveType(type),getLocator(cur));
   checkDoc(cur,alias);
   return alias;
 }
@@ -422,7 +428,7 @@
 XMLReaderImpl::parseAtom(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_atom);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name = getAttribute(cur,"name");
   xmlNodePtr child = cur->children;
   Documentation* theDoc = parseDocumentation(child);
@@ -437,26 +443,26 @@
           hlvmAssert(!"intrinsic element requires 'is' attribute");
         int typeTkn = getToken(reinterpret_cast<const xmlChar*>(is));
         switch (typeTkn) {
-          case TKN_any:  result=ast->new_AnyType(loc,name); break;
-          case TKN_bool: result=ast->new_BooleanType(loc,name); break;
-          case TKN_char: result=ast->new_CharacterType(loc,name); break;
-          case TKN_f128: result=ast->new_f128(loc,name); break;
-          case TKN_f32:  result=ast->new_f32(loc,name); break;
-          case TKN_f43:  result=ast->new_f43(loc,name); break;
-          case TKN_f64:  result=ast->new_f64(loc,name); break;
-          case TKN_f80:  result=ast->new_f80(loc,name); break;
-          case TKN_octet:result=ast->new_OctetType(loc,name); break;
-          case TKN_s128: result=ast->new_s128(loc,name); break;
-          case TKN_s16:  result=ast->new_s16(loc,name); break;
-          case TKN_s32:  result=ast->new_s32(loc,name); break;
-          case TKN_s64:  result=ast->new_s64(loc,name); break;
-          case TKN_s8:   result=ast->new_s8(loc,name); break;
-          case TKN_u128: result=ast->new_u128(loc,name); break;
-          case TKN_u16:  result=ast->new_u16(loc,name); break;
-          case TKN_u32:  result=ast->new_u32(loc,name); break;
-          case TKN_u64:  result=ast->new_u64(loc,name); break;
-          case TKN_u8:   result=ast->new_u8(loc,name); break;
-          case TKN_void: result=ast->new_VoidType(loc,name); break;
+          case TKN_any:  result=ast->new_AnyType(name,loc); break;
+          case TKN_bool: result=ast->new_BooleanType(name,loc); break;
+          case TKN_char: result=ast->new_CharacterType(name,loc); break;
+          case TKN_f128: result=ast->new_f128(name,loc); break;
+          case TKN_f32:  result=ast->new_f32(name,loc); break;
+          case TKN_f43:  result=ast->new_f44(name,loc); break;
+          case TKN_f64:  result=ast->new_f64(name,loc); break;
+          case TKN_f80:  result=ast->new_f80(name,loc); break;
+          case TKN_octet:result=ast->new_OctetType(name,loc); break;
+          case TKN_s128: result=ast->new_s128(name,loc); break;
+          case TKN_s16:  result=ast->new_s16(name,loc); break;
+          case TKN_s32:  result=ast->new_s32(name,loc); break;
+          case TKN_s64:  result=ast->new_s64(name,loc); break;
+          case TKN_s8:   result=ast->new_s8(name,loc); break;
+          case TKN_u128: result=ast->new_u128(name,loc); break;
+          case TKN_u16:  result=ast->new_u16(name,loc); break;
+          case TKN_u32:  result=ast->new_u32(name,loc); break;
+          case TKN_u64:  result=ast->new_u64(name,loc); break;
+          case TKN_u8:   result=ast->new_u8(name,loc); break;
+          case TKN_void: result=ast->new_VoidType(name,loc); break;
           default:
             hlvmDeadCode("Invalid intrinsic kind");
         }
@@ -466,7 +472,7 @@
         const char* bits = getAttribute(child,"bits");
         if (bits) {
           uint64_t numBits = recognize_nonNegativeInteger(bits);
-          result = ast->new_IntegerType(loc,name,numBits,/*signed=*/true);
+          result = ast->new_IntegerType(name,numBits,/*signed=*/true,loc);
           break;
         }
         hlvmAssert(!"Missing 'bits' attribute");
@@ -476,7 +482,7 @@
         const char* bits = getAttribute(child,"bits");
         if (bits) {
           uint64_t numBits = recognize_nonNegativeInteger(bits);
-          result = ast->new_IntegerType(loc,name,numBits,/*signed=*/false);
+          result = ast->new_IntegerType(name,numBits,/*signed=*/false,loc);
           break;
         }
         hlvmAssert(!"Missing 'bits' attribute");
@@ -488,7 +494,7 @@
         if (min && max) {
           int64_t minVal = recognize_Integer(min);
           int64_t maxVal = recognize_Integer(max);
-          result = ast->new_RangeType(loc,name,minVal,maxVal);
+          result = ast->new_RangeType(name,minVal,maxVal,loc);
           break;
         }
         hlvmAssert(!"Missing 'min' or 'max' attribute");
@@ -500,7 +506,7 @@
         if (mantissa && exponent) {
           int32_t mantVal = recognize_nonNegativeInteger(mantissa);
           int32_t expoVal = recognize_nonNegativeInteger(exponent);
-          result = ast->new_RealType(loc,name,mantVal,expoVal);
+          result = ast->new_RealType(name,mantVal,expoVal,loc);
         }
         break;
       }
@@ -522,9 +528,9 @@
 XMLReaderImpl::parseEnumeration(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_enumeration);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name = getAttribute(cur,"name");
-  EnumerationType* en = ast->new_EnumerationType(loc,name);
+  EnumerationType* en = ast->new_EnumerationType(name,loc);
   xmlNodePtr child = checkDoc(cur,en);
   while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
     hlvmAssert(getToken(child->name) == TKN_enumerator);
@@ -539,11 +545,11 @@
 XMLReaderImpl::parsePointer(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_pointer);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name = getAttribute(cur,"name");
   std::string type = getAttribute(cur,"to");
   PointerType* result = 
-    ast->new_PointerType(loc,name,ast->resolveType(type));
+    ast->new_PointerType(name,ast->resolveType(type),loc);
   checkDoc(cur,result);
   return result;
 }
@@ -552,12 +558,12 @@
 XMLReaderImpl::parseArray(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_array);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name = getAttribute(cur,"name");
   std::string type = getAttribute(cur,"of");
   const char* len = getAttribute(cur,"length");
   ArrayType* result = ast->new_ArrayType(
-    loc, name, ast->resolveType(type), recognize_nonNegativeInteger(len));
+    name, ast->resolveType(type), recognize_nonNegativeInteger(len),loc);
   checkDoc(cur,result);
   return result;
 }
@@ -566,13 +572,13 @@
 XMLReaderImpl::parseVector(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_vector);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name = getAttribute(cur,"name");
   std::string type = getAttribute(cur,"of");
   const char* len  = getAttribute(cur,"length");
   VectorType* result =
     ast->new_VectorType(
-      loc,name,ast->resolveType(type), recognize_nonNegativeInteger(len));
+      name,ast->resolveType(type), recognize_nonNegativeInteger(len),loc);
   checkDoc(cur,result);
   return result;
 }
@@ -581,16 +587,16 @@
 XMLReaderImpl::parseStructure(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_structure);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name = getAttribute(cur,"name");
-  StructureType* struc = ast->new_StructureType(loc,name);
+  StructureType* struc = ast->new_StructureType(name,loc);
   xmlNodePtr child = checkDoc(cur,struc); 
   while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
     hlvmAssert(getToken(child->name) == TKN_field && 
                "Structure only has fields");
     std::string name = getAttribute(child,"name");
     std::string type = getAttribute(child,"type");
-    AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
+    AliasType* alias = ast->new_AliasType(name,ast->resolveType(type),loc);
     alias->setParent(struc);
     checkDoc(child,alias);
     child = child->next;
@@ -602,12 +608,12 @@
 XMLReaderImpl::parseSignature(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_signature);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name = getAttribute(cur,"name");
   std::string result = getAttribute(cur,"result");
   const char* varargs = getAttribute(cur,"varargs",false);
   SignatureType* sig = 
-    ast->new_SignatureType(loc,name,ast->resolveType(result));
+    ast->new_SignatureType(name,ast->resolveType(result),loc);
   if (varargs)
     sig->setIsVarArgs(recognize_boolean(varargs));
   xmlNodePtr child = checkDoc(cur,sig); 
@@ -615,7 +621,7 @@
     hlvmAssert(getToken(child->name) == TKN_arg && "Signature only has args");
     std::string name = getAttribute(child,"name");
     std::string type = getAttribute(child,"type");
-    AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
+    AliasType* alias = ast->new_AliasType(name,ast->resolveType(type),loc);
     alias->setParent(sig);
     checkDoc(child,alias);
     child = child->next;
@@ -627,11 +633,10 @@
 XMLReaderImpl::parseVariable(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_var);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name, type;
   getNameType(cur, name, type);
-  Variable* var = ast->new_Variable(loc,name);
-  var->setType(ast->resolveType(type));
+  Variable* var = ast->new_Variable(name,ast->resolveType(type),loc);
   checkDoc(cur,var);
   return var;
 }
@@ -640,7 +645,7 @@
 XMLReaderImpl::parseReturn(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name) == TKN_ret && "Expecting block element");
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   ReturnOp* ret = ast->new_ReturnOp(loc);
   xmlNodePtr child = cur->children;
   if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
@@ -673,11 +678,13 @@
 XMLReaderImpl::parseBlock(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name) == TKN_block && "Expecting block element");
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   const char* label = getAttribute(cur, "label",false);
-  Block* block = ast->new_Block(loc);
+  Block* block = 0;
   if (label)
-    block->setLabel(label);
+    block = ast->new_Block(label,loc);
+  else
+    block = ast->new_Block("",loc);
   xmlNodePtr child = cur->children;
   while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) 
   {
@@ -692,10 +699,10 @@
 XMLReaderImpl::parseFunction(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_function);
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name, type;
   getNameType(cur, name, type);
-  Function* func = ast->new_Function(loc,name);
+  Function* func = ast->new_Function(name,loc);
   checkDoc(cur,func);
   return func;
 }
@@ -704,9 +711,9 @@
 XMLReaderImpl::parseProgram(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name) == TKN_program && "Expecting program element");
-  Locator loc(cur->line,0,&ast->getSystemID());
+  Locator* loc = getLocator(cur);
   std::string name(getAttribute(cur, "name"));
-  Program* program = ast->new_Program(loc,name);
+  Program* program = ast->new_Program(name,loc);
   xmlNodePtr child = cur->children;
   if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
     Block* b = parseBlock(child);
@@ -722,8 +729,8 @@
 {
   hlvmAssert(getToken(cur->name) == TKN_bundle && "Expecting bundle element");
   std::string pubid(getAttribute(cur, "name"));
-  Locator loc(cur->line,0,&ast->getSystemID());
-  Bundle* bundle = ast->new_Bundle(loc,pubid);
+  Locator* loc = getLocator(cur);
+  Bundle* bundle = ast->new_Bundle(pubid,loc);
   xmlNodePtr child = cur->children;
   while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) 
   {

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

==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp Sat Jul  7 19:00:11 2007
@@ -83,7 +83,7 @@
           reinterpret_cast<const xmlChar*>(val)); }
     inline void writeAttribute(const char* name, const std::string& val) 
       { writeAttribute(name, val.c_str()); }
-    inline void writeAttribute(const char* name, Type* t)
+    inline void writeAttribute(const char* name, const Type* t)
       { writeAttribute(name, t->getName()); }
     inline void writeAttribute(const char* name, uint64_t val)
       { writeAttribute(name, llvm::utostr(val)); }

Modified: hlvm/trunk/tools/hlvm-compiler/SConscript
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-compiler/SConscript?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-compiler/SConscript (original)
+++ hlvm/trunk/tools/hlvm-compiler/SConscript Sat Jul  7 19:00:11 2007
@@ -39,6 +39,7 @@
    'LLVMSupport',
    'LLVMbzip2',
    'LLVMSystem',
+   'aprutil-1',
    'apr-1',
    'stdc++'
   ]

Modified: hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp (original)
+++ hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp Sat Jul  7 19:00:11 2007
@@ -69,7 +69,7 @@
 int main(int argc, char**argv) 
 {
   try {
-    Base::initialize(argc,argv);
+    initialize(argc,argv);
     cl::ParseCommandLineOptions(argc, argv, 
       "hlvm-xml2xml XML->AST->XML translator\n");
 

Modified: hlvm/trunk/tools/hlvm-xml2xml/SConscript
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/SConscript?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/SConscript (original)
+++ hlvm/trunk/tools/hlvm-xml2xml/SConscript Sat Jul  7 19:00:11 2007
@@ -32,6 +32,7 @@
    'xml2',
    'LLVMSupport',
    'LLVMSystem',
+   'aprutil-1',
    'apr-1',
    'stdc++'
   ]

Modified: hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp (original)
+++ hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp Sat Jul  7 19:00:11 2007
@@ -48,7 +48,7 @@
 int main(int argc, char**argv) 
 {
   try {
-    Base::initialize(argc,argv);
+    initialize(argc,argv);
     cl::ParseCommandLineOptions(argc, argv, 
       "hlvm-xml2xml XML->AST->XML translator\n");
 

Modified: hlvm/trunk/tools/hlvm/hlvm.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm/hlvm.cpp?rev=38136&r1=38135&r2=38136&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm/hlvm.cpp (original)
+++ hlvm/trunk/tools/hlvm/hlvm.cpp Sat Jul  7 19:00:11 2007
@@ -43,7 +43,7 @@
 int main(int argc, char**argv) 
 {
   try {
-    Base::initialize(argc,argv);
+    initialize(argc,argv);
     cl::ParseCommandLineOptions(argc, argv, 
       "hlvm: High Level Virtual Machine\n");
 





More information about the llvm-commits mailing list