[llvm-commits] [hlvm] r38263 - in /hlvm/trunk: ./ hlvm/AST/ hlvm/CodeGen/ hlvm/Pass/ hlvm/Reader/ hlvm/Runtime/ hlvm/Writer/ test/return0/ test/xml2xml/ tools/hlvm-compiler/ tools/hlvm-config/

Reid Spencer reid at x10sys.com
Sat Jul 7 17:01:45 PDT 2007


Author: reid
Date: Sat Jul  7 19:01:45 2007
New Revision: 38263

URL: http://llvm.org/viewvc/llvm-project?rev=38263&view=rev
Log:
Too many changes to list individually, but basically this is a complete rewrite
of how we were handling constants. Constants must be named like types and
variables and functions. Constants cannot be interspersed with operators; to
access one, you use the ConstantReferenceOp operator. This patch fixes lots of
other bugs and introduces the "string" primitive type.

Added:
    hlvm/trunk/test/return0/arithmetic.hlx
    hlvm/trunk/test/return0/bitwise.hlx
    hlvm/trunk/test/return0/boolean.hlx
Removed:
    hlvm/trunk/hlvm/AST/Constant.cpp
    hlvm/trunk/hlvm/AST/Constant.h
    hlvm/trunk/hlvm/AST/LinkageItem.cpp
    hlvm/trunk/hlvm/AST/LinkageItem.h
Modified:
    hlvm/trunk/README.txt
    hlvm/trunk/hlvm/AST/AST.cpp
    hlvm/trunk/hlvm/AST/AST.h
    hlvm/trunk/hlvm/AST/Block.cpp
    hlvm/trunk/hlvm/AST/Block.h
    hlvm/trunk/hlvm/AST/Bundle.cpp
    hlvm/trunk/hlvm/AST/Bundle.h
    hlvm/trunk/hlvm/AST/Constants.cpp
    hlvm/trunk/hlvm/AST/Constants.h
    hlvm/trunk/hlvm/AST/ContainerType.h
    hlvm/trunk/hlvm/AST/Documentation.cpp
    hlvm/trunk/hlvm/AST/Documentation.h
    hlvm/trunk/hlvm/AST/LinkageItems.cpp
    hlvm/trunk/hlvm/AST/LinkageItems.h
    hlvm/trunk/hlvm/AST/Locator.cpp
    hlvm/trunk/hlvm/AST/Locator.h
    hlvm/trunk/hlvm/AST/MemoryOps.cpp
    hlvm/trunk/hlvm/AST/MemoryOps.h
    hlvm/trunk/hlvm/AST/Node.cpp
    hlvm/trunk/hlvm/AST/Node.h
    hlvm/trunk/hlvm/AST/Operator.cpp
    hlvm/trunk/hlvm/AST/Operator.h
    hlvm/trunk/hlvm/AST/RuntimeType.h
    hlvm/trunk/hlvm/AST/StringOps.h
    hlvm/trunk/hlvm/AST/SymbolTable.cpp
    hlvm/trunk/hlvm/AST/SymbolTable.h
    hlvm/trunk/hlvm/AST/Type.cpp
    hlvm/trunk/hlvm/AST/Type.h
    hlvm/trunk/hlvm/AST/URI.h
    hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp
    hlvm/trunk/hlvm/Pass/Pass.cpp
    hlvm/trunk/hlvm/Pass/Pass.h
    hlvm/trunk/hlvm/Pass/Validate.cpp
    hlvm/trunk/hlvm/Reader/HLVM.rng
    hlvm/trunk/hlvm/Reader/XMLReader.cpp
    hlvm/trunk/hlvm/Runtime/Stream.cpp
    hlvm/trunk/hlvm/Runtime/Stream.h
    hlvm/trunk/hlvm/Writer/Writer.h
    hlvm/trunk/hlvm/Writer/XMLWriter.cpp
    hlvm/trunk/test/return0/complement.hlx
    hlvm/trunk/test/return0/helloworld.hlx
    hlvm/trunk/test/return0/return0.hlx
    hlvm/trunk/test/xml2xml/arithmetic.hlx
    hlvm/trunk/test/xml2xml/autovar.hlx
    hlvm/trunk/test/xml2xml/booleanops.hlx
    hlvm/trunk/test/xml2xml/helloworld.hlx
    hlvm/trunk/test/xml2xml/loop.hlx
    hlvm/trunk/test/xml2xml/return.hlx
    hlvm/trunk/test/xml2xml/select.hlx
    hlvm/trunk/test/xml2xml/switch.hlx
    hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp
    hlvm/trunk/tools/hlvm-config/hlvm-config.cpp

Modified: hlvm/trunk/README.txt
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/README.txt?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/README.txt (original)
+++ hlvm/trunk/README.txt Sat Jul  7 19:01:45 2007
@@ -34,6 +34,6 @@
 locations. 
 
 The usual will work:
-    make
+    make 
     make check
     make install

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.cpp (original)
+++ hlvm/trunk/hlvm/AST/AST.cpp Sat Jul  7 19:01:45 2007
@@ -56,7 +56,7 @@
   public:
     ASTImpl()
       : types(), vars(), funcs(), unresolvedTypes(), 
-        AnyTypeSingleton(0),
+        AnyTypeSingleton(0), StringTypeSingleton(0),
         VoidSingleton(0), BooleanSingleton(), CharacterSingleton(0), 
         OctetSingleton(0), UInt8Singleton(0), UInt16Singleton(0), 
         UInt32Singleton(0), UInt64Singleton(0), UInt128Singleton(0),
@@ -82,6 +82,7 @@
     SymbolTable    funcs;
     SymbolTable    unresolvedTypes;
     AnyType*       AnyTypeSingleton;
+    StringType*    StringTypeSingleton;
     VoidType*      VoidSingleton;
     BooleanType*   BooleanSingleton;
     CharacterType* CharacterSingleton;
@@ -228,6 +229,13 @@
   return PT;
 }
 
+URI* 
+AST::new_URI(const std::string& uri)
+{
+  URI* result = URI::create(uri,getPool());
+  return result;
+}
+
 Locator*
 AST::new_Locator(const URI* uri, uint32_t line, uint32_t col, uint32_t line2,
     uint32_t col2)
@@ -276,13 +284,11 @@
 IntegerType* 
 AST::new_IntegerType(
   const std::string& id, 
-  uint64_t bits, 
+  uint16_t bits, 
   bool isSigned,
   const Locator* loc)
 {
-  IntegerType* result = new IntegerType(IntegerTypeID);
-  result->setBits(bits);
-  result->setSigned(isSigned);
+  IntegerType* result = new IntegerType(IntegerTypeID,bits,isSigned);
   result->setLocator(loc);
   result->setName(id);
   static_cast<ASTImpl*>(this)->addType(result);
@@ -339,6 +345,16 @@
   return result;
 }
 
+StringType* 
+AST::new_StringType(const std::string& id, const Locator* loc)
+{
+  StringType* result = new StringType();
+  result->setLocator(loc);
+  result->setName(id);
+  static_cast<ASTImpl*>(this)->addType(result);
+  return result;
+}
+
 BooleanType* 
 AST::new_BooleanType(const std::string& id, const Locator* loc)
 {
@@ -500,9 +516,10 @@
 }
 
 ConstantInteger*
-AST::new_ConstantInteger(uint64_t v, Type* Ty, const Locator* loc)
+AST::new_ConstantInteger(
+  const std::string&  v, uint16_t base, const Type* Ty, const Locator* loc)
 {
-  ConstantInteger* result = new ConstantInteger();
+  ConstantInteger* result = new ConstantInteger(base);
   result->setLocator(loc);
   result->setValue(v);
   result->setType(Ty);
@@ -510,7 +527,7 @@
 }
 
 ConstantReal*
-AST::new_ConstantReal(double v, Type* Ty, const Locator* loc)
+AST::new_ConstantReal(const std::string& v, const Type* Ty, const Locator* loc)
 {
   ConstantReal* result = new ConstantReal();
   result->setLocator(loc);
@@ -519,13 +536,13 @@
   return result;
 }
 
-ConstantText*
-AST::new_ConstantText(const std::string& v, const Locator* loc)
+ConstantString*
+AST::new_ConstantString(const std::string& v, const Locator* loc)
 {
-  ConstantText* result = new ConstantText();
+  ConstantString* result = new ConstantString();
   result->setLocator(loc);
   result->setValue(v);
-  result->setType( getPrimitiveType(TextTypeID) );
+  result->setType( getPrimitiveType(StringTypeID) );
   return result;
 }
 
@@ -534,25 +551,20 @@
 {
   ASTImpl* ast = static_cast<ASTImpl*>(this);
   if (t_or_f) {
-    if (!ast->BooleanTrueSingleton)
+    if (!ast->BooleanTrueSingleton) {
       ast->BooleanTrueSingleton = new ConstantBoolean(true);
+      ast->BooleanTrueSingleton->setType(getPrimitiveType(BooleanTypeID));
+    }
     return ast->BooleanTrueSingleton;
   } else {
-    if (!ast->BooleanFalseSingleton)
+    if (!ast->BooleanFalseSingleton) {
       ast->BooleanFalseSingleton = new ConstantBoolean(false);
+      ast->BooleanFalseSingleton->setType(getPrimitiveType(BooleanTypeID));
+    }
     return ast->BooleanFalseSingleton;
   }
 }
 
-ConstantZero*
-AST::new_ConstantZero(const Type* Ty, const Locator* loc)
-{
-  ConstantZero* result = new ConstantZero();
-  result->setLocator(loc);
-  result->setType(Ty);
-  return result;
-}
-
 Variable*
 AST::new_Variable(const std::string& id, const Type* Ty, const Locator* loc)
 {
@@ -631,6 +643,17 @@
   return result;
 }
 
+ConstantReferenceOp* 
+AST::new_ConstantReferenceOp(const Constant* C, const Locator* loc)
+{
+  hlvmAssert(C != 0 && "ConstantReferenceOp must have a Constant to reference");
+  ConstantReferenceOp* result = new ConstantReferenceOp();
+  result->setLocator(loc);
+  result->setReferent(C);
+  result->setType(C->getType());
+  return result;
+}
+
 template<class OpClass> OpClass* 
 AST::new_NilaryOp(
   const Type* Ty,    ///< Result type of the operator
@@ -656,7 +679,7 @@
 template<class OpClass> OpClass* 
 AST::new_UnaryOp(
   const Type* Ty,    ///< Result type of the operator
-  Value* oprnd1,     ///< The first operand
+  Operator* oprnd1,     ///< The first operand
   const Locator* loc ///< The source locator
 )
 {
@@ -671,7 +694,7 @@
 
 template<class OpClass> OpClass* 
 AST::new_UnaryOp(
-  Value* oprnd1,     ///< The first operand
+  Operator* oprnd1,     ///< The first operand
   const Locator* loc ///< The source locator
 )
 {
@@ -682,8 +705,8 @@
 template<class OpClass> OpClass* 
 AST::new_BinaryOp(
   const Type* Ty,    ///< Result type of the operator
-  Value* oprnd1,     ///< The first operand
-  Value* oprnd2,     ///< The second operand
+  Operator* oprnd1,     ///< The first operand
+  Operator* oprnd2,     ///< The second operand
   const Locator* loc ///< The source locator
 )
 {
@@ -701,8 +724,8 @@
 /// Provide a template function for creating a binary operator
 template<class OpClass> OpClass* 
 AST::new_BinaryOp(
-  Value* oprnd1,     ///< The first operand
-  Value* oprnd2,     ///< The second operand
+  Operator* oprnd1,     ///< The first operand
+  Operator* oprnd2,     ///< The second operand
   const Locator* loc ///< The source locator
 )
 {
@@ -713,9 +736,9 @@
 template<class OpClass> OpClass* 
 AST::new_TernaryOp(
   const Type* Ty,    ///< Result type of the operator
-  Value* oprnd1,     ///< The first operand
-  Value* oprnd2,     ///< The second operand
-  Value* oprnd3,     ///< The third operand
+  Operator* oprnd1,     ///< The first operand
+  Operator* oprnd2,     ///< The second operand
+  Operator* oprnd3,     ///< The third operand
   const Locator* loc ///< The source locator
 )
 {
@@ -734,9 +757,9 @@
 
 template<class OpClass> OpClass* 
 AST::new_TernaryOp(
-  Value* oprnd1,     ///< The first operand
-  Value* oprnd2,     ///< The second operand
-  Value* oprnd3,     ///< The third operand
+  Operator* oprnd1,     ///< The first operand
+  Operator* oprnd2,     ///< The second operand
+  Operator* oprnd3,     ///< The third operand
   const Locator* loc ///< The source locator
 )
 {
@@ -746,7 +769,7 @@
 template<class OpClass> OpClass* 
 AST::new_MultiOp(
   const Type* Ty,         ///< Result type of the operator
-  const std::vector<Value*>& oprnds,
+  const std::vector<Operator*>& oprnds,
   const Locator* loc
 ) 
 {
@@ -760,7 +783,7 @@
 
 template<class OpClass> OpClass* 
 AST::new_MultiOp(
-  const std::vector<Value*>& oprnds,
+  const std::vector<Operator*>& oprnds,
   const Locator* loc
 )
 {
@@ -770,166 +793,200 @@
 // Arithmetic Operators
 template NegateOp*
 AST::new_UnaryOp<NegateOp>(
-    const Type* Ty, Value* op1, const Locator* loc);
+    const Type* Ty, Operator* op1, const Locator* loc);
 template NegateOp*
-AST::new_UnaryOp<NegateOp>(Value* op1, const Locator* loc);
+AST::new_UnaryOp<NegateOp>(Operator* op1, const Locator* loc);
 
 template ComplementOp*
 AST::new_UnaryOp<ComplementOp>(
-    const Type* Ty, Value* op1, const Locator* loc);
+    const Type* Ty, Operator* op1, const Locator* loc);
 template ComplementOp*
-AST::new_UnaryOp<ComplementOp>(Value* op1, const Locator* loc);
+AST::new_UnaryOp<ComplementOp>(Operator* op1, const Locator* loc);
 
 template PreIncrOp*
 AST::new_UnaryOp<PreIncrOp>(
-    const Type* Ty, Value* op1, const Locator* loc);
+    const Type* Ty, Operator* op1, const Locator* loc);
 template PreIncrOp*
-AST::new_UnaryOp<PreIncrOp>(Value* op1, const Locator* loc);
+AST::new_UnaryOp<PreIncrOp>(Operator* op1, const Locator* loc);
 
 template PreDecrOp*
 AST::new_UnaryOp<PreDecrOp>(
-    const Type* Ty, Value* op1, const Locator* loc);
+    const Type* Ty, Operator* op1, const Locator* loc);
 template PreDecrOp*
-AST::new_UnaryOp<PreDecrOp>(Value* op1, const Locator* loc);
+AST::new_UnaryOp<PreDecrOp>(Operator* op1, const Locator* loc);
 
 template PostIncrOp*
 AST::new_UnaryOp<PostIncrOp>(
-    const Type* Ty, Value* op1, const Locator* loc);
+    const Type* Ty, Operator* op1, const Locator* loc);
 template PostIncrOp*
-AST::new_UnaryOp<PostIncrOp>(Value* op1, const Locator* loc);
+AST::new_UnaryOp<PostIncrOp>(Operator* op1, const Locator* loc);
 
 template PostDecrOp*
 AST::new_UnaryOp<PostDecrOp>(
-    const Type* Ty, Value* op1, const Locator* loc);
+    const Type* Ty, Operator* op1, const Locator* loc);
 template PostDecrOp*
-AST::new_UnaryOp<PostDecrOp>(Value* op1, const Locator* loc);
+AST::new_UnaryOp<PostDecrOp>(Operator* op1, const Locator* loc);
 
 template AddOp*
 AST::new_BinaryOp<AddOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template AddOp*
-AST::new_BinaryOp<AddOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<AddOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template SubtractOp*
 AST::new_BinaryOp<SubtractOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template SubtractOp*
-AST::new_BinaryOp<SubtractOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<SubtractOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template MultiplyOp*
 AST::new_BinaryOp<MultiplyOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template MultiplyOp*
-AST::new_BinaryOp<MultiplyOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<MultiplyOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template DivideOp*
 AST::new_BinaryOp<DivideOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template DivideOp*
-AST::new_BinaryOp<DivideOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<DivideOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template ModuloOp*
 AST::new_BinaryOp<ModuloOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template ModuloOp*
-AST::new_BinaryOp<ModuloOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<ModuloOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template BAndOp*
 AST::new_BinaryOp<BAndOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template BAndOp*
-AST::new_BinaryOp<BAndOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<BAndOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template BOrOp*
 AST::new_BinaryOp<BOrOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template BOrOp*
-AST::new_BinaryOp<BOrOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<BOrOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template BXorOp*
 AST::new_BinaryOp<BXorOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template BXorOp*
-AST::new_BinaryOp<BXorOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<BXorOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 template BNorOp*
 AST::new_BinaryOp<BNorOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
 template BNorOp*
-AST::new_BinaryOp<BNorOp>(Value* op1, Value* op2, const Locator* loc);
+AST::new_BinaryOp<BNorOp>(Operator* op1, Operator* op2, const Locator* loc);
 
 // Boolean Operators
 template NotOp*
-AST::new_UnaryOp<NotOp>(const Type* Ty, Value* op1, const Locator* loc);
-template NotOp*
-AST::new_UnaryOp<NotOp>(Value* op1, const Locator* loc);
+AST::new_UnaryOp<NotOp>(const Type* Ty, Operator* op1, const Locator* loc);
+template<> NotOp*
+AST::new_UnaryOp<NotOp>(Operator* op1, const Locator* loc)
+{
+  return AST::new_UnaryOp<NotOp>(getPrimitiveType(BooleanTypeID),op1,loc);
+}
 
 template AndOp*
 AST::new_BinaryOp<AndOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
-template AndOp*
-AST::new_BinaryOp<AndOp>(Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
+template<> AndOp*
+AST::new_BinaryOp<AndOp>(Operator* op1, Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<AndOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template OrOp*
 AST::new_BinaryOp<OrOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
-template OrOp*
-AST::new_BinaryOp<OrOp>(Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
+template<> OrOp*
+AST::new_BinaryOp<OrOp>(Operator* op1, Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<OrOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template NorOp*
 AST::new_BinaryOp<NorOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
-template NorOp*
-AST::new_BinaryOp<NorOp>(Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
+template<> NorOp*
+AST::new_BinaryOp<NorOp>(Operator* op1, Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<NorOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template XorOp*
 AST::new_BinaryOp<XorOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
-template XorOp*
-AST::new_BinaryOp<XorOp>(Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
+template<> XorOp*
+AST::new_BinaryOp<XorOp>(Operator* op1, Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<XorOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template LessThanOp*
 AST::new_BinaryOp<LessThanOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
-template LessThanOp*
-AST::new_BinaryOp<LessThanOp>(Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
+template<> LessThanOp*
+AST::new_BinaryOp<LessThanOp>(Operator* op1, Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<LessThanOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template GreaterThanOp* 
 AST::new_BinaryOp<GreaterThanOp>(
-    const Type* Ty, Value* op1, Value* op2,const Locator* loc);
-template GreaterThanOp* 
-AST::new_BinaryOp<GreaterThanOp>(Value* op1, Value* op2,const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2,const Locator* loc);
+template<> GreaterThanOp* 
+AST::new_BinaryOp<GreaterThanOp>(Operator* op1, Operator* op2,const Locator* loc)
+{
+  return AST::new_BinaryOp<GreaterThanOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template LessEqualOp* 
 AST::new_BinaryOp<LessEqualOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
-template LessEqualOp* 
-AST::new_BinaryOp<LessEqualOp>(Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
+template<> LessEqualOp* 
+AST::new_BinaryOp<LessEqualOp>(Operator* op1, Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<LessEqualOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template GreaterEqualOp* 
 AST::new_BinaryOp<GreaterEqualOp>(
-    const Type* Ty, Value* op1,Value* op2, const Locator* loc);
-template GreaterEqualOp* 
-AST::new_BinaryOp<GreaterEqualOp>(Value* op1,Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1,Operator* op2, const Locator* loc);
+template<> GreaterEqualOp* 
+AST::new_BinaryOp<GreaterEqualOp>(Operator* op1,Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<GreaterEqualOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template EqualityOp*
 AST::new_BinaryOp<EqualityOp>(
-    const Type* Ty, Value* op1, Value* op2, const Locator* loc);
-template EqualityOp*
-AST::new_BinaryOp<EqualityOp>(Value* op1, Value* op2, const Locator* loc);
+    const Type* Ty, Operator* op1, Operator* op2, const Locator* loc);
+template<> EqualityOp*
+AST::new_BinaryOp<EqualityOp>(Operator* op1, Operator* op2, const Locator* loc)
+{
+  return AST::new_BinaryOp<EqualityOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
 
 template InequalityOp*
 AST::new_BinaryOp<InequalityOp>(
-    const Type* Ty, Value* op1,Value* op2,const Locator* loc);
-template InequalityOp*
-AST::new_BinaryOp<InequalityOp>(Value* op1,Value* op2,const Locator* loc);
+    const Type* Ty, Operator* op1,Operator* op2,const Locator* loc);
+template<> InequalityOp*
+AST::new_BinaryOp<InequalityOp>(Operator* op1,Operator* op2,const Locator* loc)
+{
+  return AST::new_BinaryOp<InequalityOp>(getPrimitiveType(BooleanTypeID),op1,op2,loc);
+}
+
 
 // Control Flow Operators
 template Block* 
 AST::new_MultiOp<Block>(
-    const Type* Ty, const std::vector<Value*>& ops, const Locator*loc);
+    const Type* Ty, const std::vector<Operator*>& ops, const Locator*loc);
 template Block* 
-AST::new_MultiOp<Block>(const std::vector<Value*>& ops, const Locator*loc);
+AST::new_MultiOp<Block>(const std::vector<Operator*>& ops, const Locator*loc);
 
 template NoOperator* 
 AST::new_NilaryOp<NoOperator>(const Type* Ty, const Locator*loc);
@@ -938,18 +995,18 @@
 
 template SelectOp*
 AST::new_TernaryOp<SelectOp>(
-    const Type* Ty, Value*op1,Value*op2,Value*op3,const Locator* loc);
+    const Type* Ty, Operator*op1,Operator*op2,Operator*op3,const Locator* loc);
 template<> SelectOp*
-AST::new_TernaryOp<SelectOp>(Value*op1,Value*op2,Value*op3,const Locator* loc)
+AST::new_TernaryOp<SelectOp>(Operator*op1,Operator*op2,Operator*op3,const Locator* loc)
 {
   return new_TernaryOp<SelectOp>(op2->getType(),op1,op2,op3,loc);
 }
 
 template LoopOp*
-AST::new_TernaryOp<LoopOp>(const Type* Ty, Value*op1,Value*op2,Value*op3,const Locator* loc);
+AST::new_TernaryOp<LoopOp>(const Type* Ty, Operator*op1,Operator*op2,Operator*op3,const Locator* loc);
 
 template<> LoopOp*
-AST::new_TernaryOp<LoopOp>(Value*op1,Value*op2,Value*op3,const Locator* loc)
+AST::new_TernaryOp<LoopOp>(Operator*op1,Operator*op2,Operator*op3,const Locator* loc)
 {
   const Type* Ty = op2->getType();
   if (llvm::isa<Block>(Ty))
@@ -959,9 +1016,9 @@
 
 template SwitchOp*
 AST::new_MultiOp<SwitchOp>(
-    const Type* Ty, const std::vector<Value*>& ops, const Locator* loc);
+    const Type* Ty, const std::vector<Operator*>& ops, const Locator* loc);
 template<> SwitchOp*
-AST::new_MultiOp<SwitchOp>(const std::vector<Value*>& ops, const Locator* loc)
+AST::new_MultiOp<SwitchOp>(const std::vector<Operator*>& ops, const Locator* loc)
 {
   hlvmAssert(ops.size() >= 2 && "Too few operands for SwitchOp");
   const Type* Ty = ops[1]->getType();
@@ -981,23 +1038,23 @@
 AST::new_NilaryOp<ContinueOp>(const Locator*loc);
 
 template ReturnOp* 
-AST::new_UnaryOp<ReturnOp>(const Type*Ty, Value*op1,const Locator*loc);
+AST::new_UnaryOp<ReturnOp>(const Type*Ty, Operator*op1,const Locator*loc);
 template ReturnOp* 
-AST::new_UnaryOp<ReturnOp>(Value*op1,const Locator*loc);
+AST::new_UnaryOp<ReturnOp>(Operator*op1,const Locator*loc);
 
 // Memory Operators
 template StoreOp*  
-AST::new_BinaryOp<StoreOp>(const Type*, Value*op1,Value*op2,const Locator*loc);
+AST::new_BinaryOp<StoreOp>(const Type*, Operator*op1,Operator*op2,const Locator*loc);
 template<> StoreOp*  
-AST::new_BinaryOp<StoreOp>(Value*op1,Value*op2,const Locator*loc)
+AST::new_BinaryOp<StoreOp>(Operator*op1,Operator*op2,const Locator*loc)
 {
   return new_BinaryOp<StoreOp>(getPrimitiveType(VoidTypeID),op1,op2,loc);
 }
 
 template LoadOp*   
-AST::new_UnaryOp<LoadOp>(const Type* Ty, Value*op1,const Locator*loc);
+AST::new_UnaryOp<LoadOp>(const Type* Ty, Operator*op1,const Locator*loc);
 template<> LoadOp*   
-AST::new_UnaryOp<LoadOp>(Value*op1,const Locator*loc)
+AST::new_UnaryOp<LoadOp>(Operator*op1,const Locator*loc)
 {
   hlvmAssert(llvm::isa<PointerType>(op1->getType()) && 
       "LoadOp Requires PointerType operand");
@@ -1007,26 +1064,26 @@
 
 // Input/Output Operators
 template OpenOp* 
-AST::new_UnaryOp<OpenOp>(const Type* Ty, Value*op1,const Locator*loc);
+AST::new_UnaryOp<OpenOp>(const Type* Ty, Operator*op1,const Locator*loc);
 template<> OpenOp* 
-AST::new_UnaryOp<OpenOp>(Value*op1,const Locator*loc)
+AST::new_UnaryOp<OpenOp>(Operator*op1,const Locator*loc)
 {
   return new_UnaryOp<OpenOp>(getPrimitiveType(StreamTypeID),op1,loc);
 }
 
 template WriteOp* 
 AST::new_BinaryOp<WriteOp>(
-  const Type* Ty, Value*op1,Value*op2, const Locator*loc);
+  const Type* Ty, Operator*op1,Operator*op2, const Locator*loc);
 template<> WriteOp* 
-AST::new_BinaryOp<WriteOp>(Value*op1,Value*op2,const Locator*loc)
+AST::new_BinaryOp<WriteOp>(Operator*op1,Operator*op2,const Locator*loc)
 {
   return new_BinaryOp<WriteOp>(getPrimitiveType(UInt64TypeID),op1,op2,loc);
 }
 
 template CloseOp* 
-AST::new_UnaryOp<CloseOp>(const Type* Ty, Value*op1,const Locator*loc);
+AST::new_UnaryOp<CloseOp>(const Type* Ty, Operator*op1,const Locator*loc);
 template<> CloseOp* 
-AST::new_UnaryOp<CloseOp>(Value*op1,const Locator*loc)
+AST::new_UnaryOp<CloseOp>(Operator*op1,const Locator*loc)
 {
   return new_UnaryOp<CloseOp>(getPrimitiveType(VoidTypeID),op1,loc);
 }
@@ -1043,6 +1100,12 @@
         ast->AnyTypeSingleton->setName("any");
       }
       return ast->AnyTypeSingleton;
+    case StringTypeID:
+      if (!ast->StringTypeSingleton) {
+        ast->StringTypeSingleton = new StringType();
+        ast->StringTypeSingleton->setName("string");
+      }
+      return ast->StringTypeSingleton;
     case VoidTypeID:
       if (!ast->VoidSingleton) {
         ast->VoidSingleton = new VoidType();
@@ -1099,32 +1162,32 @@
       return ast->UInt128Singleton;
     case SInt8TypeID:
       if (!ast->SInt8Singleton) {
-        ast->SInt8Singleton = new IntegerType(SInt8TypeID,8,false);
-        ast->SInt8Singleton->setName("i8");
+        ast->SInt8Singleton = new IntegerType(SInt8TypeID,8,true);
+        ast->SInt8Singleton->setName("s8");
       }
       return ast->SInt8Singleton;
     case SInt16TypeID:
       if (!ast->SInt16Singleton) {
-        ast->SInt16Singleton = new IntegerType(SInt16TypeID,16,false);
-        ast->SInt16Singleton->setName("i16");
+        ast->SInt16Singleton = new IntegerType(SInt16TypeID,16,true);
+        ast->SInt16Singleton->setName("s16");
       }
       return ast->SInt16Singleton;
     case SInt32TypeID:
       if (!ast->SInt32Singleton) {
-        ast->SInt32Singleton = new IntegerType(SInt32TypeID,32,false);
-        ast->SInt32Singleton->setName("i32");
+        ast->SInt32Singleton = new IntegerType(SInt32TypeID,32,true);
+        ast->SInt32Singleton->setName("s32");
       }
       return ast->SInt32Singleton;
     case SInt64TypeID:
       if (!ast->SInt64Singleton) {
-        ast->SInt64Singleton = new IntegerType(SInt64TypeID,64,false);
-        ast->SInt64Singleton->setName("i64");
+        ast->SInt64Singleton = new IntegerType(SInt64TypeID,64,true);
+        ast->SInt64Singleton->setName("s64");
       }
       return ast->SInt64Singleton;
     case SInt128TypeID:
       if (!ast->SInt128Singleton) {
-        ast->SInt128Singleton = new IntegerType(SInt128TypeID,128,false);
-        ast->SInt128Singleton->setName("i128");
+        ast->SInt128Singleton = new IntegerType(SInt128TypeID,128,true);
+        ast->SInt128Singleton->setName("s128");
       }
       return ast->SInt128Singleton;
     case Float32TypeID:

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

==============================================================================
--- hlvm/trunk/hlvm/AST/AST.h (original)
+++ hlvm/trunk/hlvm/AST/AST.h Sat Jul  7 19:01:45 2007
@@ -34,7 +34,7 @@
 #include <hlvm/AST/Type.h>
 #include <hlvm/AST/ContainerType.h>
 #include <hlvm/AST/RuntimeType.h>
-#include <hlvm/AST/Constant.h>
+#include <hlvm/AST/Constants.h>
 #include <string>
 #include <vector>
 
@@ -55,11 +55,13 @@
 class ConstantBoolean;
 class ConstantInteger;
 class ConstantReal;
-class ConstantText;
-class ConstantZero;
+class ConstantString;
 class Pool;
+class Operator;
 class AutoVarOp;
 class ReferenceOp;
+class ConstantReferenceOp;
+class URI;
 
 /// This class is used to hold or contain an Abstract Syntax Tree. It forms the
 /// root node of a multi-way tree of other nodes. As such, its parent node is
@@ -137,6 +139,11 @@
   /// @name Factories
   /// @{
   public:
+    /// Create a new URI object. URIs indicate the source file from which the
+    /// AST is being constructued. They are used by locators and bundles to
+    /// identify source locations.
+    URI* new_URI(const std::string& uri);
+
     /// 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
@@ -193,8 +200,8 @@
     /// integer types. By default it creates a signed 32-bit integer.
     IntegerType* new_IntegerType(
       const std::string& id,  ///< The name of the type
-      uint64_t bits = 32,     ///< The number of bits
-      bool isSigned = true,    ///< The signedness
+      uint16_t bits = 32,     ///< The number of bits
+      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
@@ -227,6 +234,12 @@
       const std::string& id, ///< The name of the type
       const Locator* loc = 0  ///< The source locator 
     );
+    /// Create a new StringType node. A StringType node is a type that holds a
+    /// sequence of UTF-8 encoded characters.
+    StringType* new_StringType(
+      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(
@@ -418,25 +431,21 @@
       bool t_or_f,            ///< The value for the constant
       const Locator* loc = 0  ///< The source locator
     );
-    /// Create a new ConstantZero node
-    ConstantZero* new_ConstantZero(
-      const Type* Ty,         ///< The type for the constant zero
-      const Locator* loc = 0  ///< The source locator
-    );
     /// Create a new ConstantInteger node.
     ConstantInteger* new_ConstantInteger(
-      uint64_t value,         ///< The value of the ConstantInteger
-      Type* Ty,               ///< The type of the integer
+      const std::string& val, ///< The value of the ConstantInteger
+      uint16_t base,          ///< The numeric base the value is encoded in
+      const Type* Ty,         ///< The type of the integer
       const Locator* loc = 0  ///< The source locator
     );
     /// Create a new ConstantInteger node.
     ConstantReal* new_ConstantReal(
-      double value,           ///< The value of the ConstantReal
-      Type* Ty,               ///< The type of the real
+      const std::string& val, ///< The value of the ConstantReal
+      const Type* Ty,         ///< The type of the real
       const Locator* loc = 0  ///< The source locator
     );
     /// Create a new ConstantText node.
-    ConstantText* new_ConstantText(
+    ConstantString* new_ConstantString(
       const std::string& value, ///< The value of the ConstantText
       const Locator* loc = 0    ///< The source locator
     );
@@ -470,87 +479,91 @@
       const Locator* loc       ///< The source locator
     );
 
+    /// Create a new ReferenceOp.
     ReferenceOp* new_ReferenceOp(
-      const Value* V,       ///< The value being referred to
+      const Value* V,       ///< The value being referenced
       const Locator*loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a nilary operator
+    /// Create a new ReferenceOp.
+    ConstantReferenceOp* new_ConstantReferenceOp(
+      const Constant* C,     ///< The constant being referenced
+      const Locator* loc = 0 ///< The source locator
+    );
+
+    /// Provide a template function for creating standard nilary operators
     template<class OpClass>
     OpClass* new_NilaryOp(
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a unary operator
+    /// Provide a template function for creating standard unary operators
     template<class OpClass>
     OpClass* new_UnaryOp(
-      Value* oprnd1,         ///< The first operand
+      Operator* oprnd1,         ///< The first operand
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a binary operator
+    /// Provide a template function for creating standard binary operators
     template<class OpClass>
     OpClass* new_BinaryOp(
-      Value* oprnd1,         ///< The first operand
-      Value* oprnd2,         ///< The second operand
+      Operator* oprnd1,         ///< The first operand
+      Operator* oprnd2,         ///< The second operand
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a ternary operator
+    /// Provide a template function for creating standard ternary operators
     template<class OpClass>
     OpClass* new_TernaryOp(
-      Value* oprnd1,         ///< The first operand
-      Value* oprnd2,         ///< The second operand
-      Value* oprnd3,         ///< The third operand
+      Operator* oprnd1,         ///< The first operand
+      Operator* oprnd2,         ///< The second operand
+      Operator* oprnd3,         ///< The third operand
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a multi-operand operator
+    /// Provide a template function for creating standard multi-operand
+    /// operators
     template<class OpClass>
     OpClass* new_MultiOp(
-      const std::vector<Value*>& o, ///< The list of operands
+      const std::vector<Operator*>& o, ///< The list of operands
       const Locator* loc = 0
     );
+
   protected:
-    /// Provide a template function for creating a nilary operator
     template<class OpClass>
     OpClass* new_NilaryOp(
       const Type* Ty,        ///< Result type of the operator
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a unary operator
     template<class OpClass>
     OpClass* new_UnaryOp(
       const Type* Ty,        ///< Result type of the operator
-      Value* oprnd1,         ///< The first operand
+      Operator* oprnd1,         ///< The first operand
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a binary operator
     template<class OpClass>
     OpClass* new_BinaryOp(
       const Type* Ty,        ///< Result type of the operator
-      Value* oprnd1,         ///< The first operand
-      Value* oprnd2,         ///< The second operand
+      Operator* oprnd1,         ///< The first operand
+      Operator* oprnd2,         ///< The second operand
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a ternary operator
     template<class OpClass>
     OpClass* new_TernaryOp(
       const Type* Ty,        ///< Result type of the operator
-      Value* oprnd1,         ///< The first operand
-      Value* oprnd2,         ///< The second operand
-      Value* oprnd3,         ///< The third operand
+      Operator* oprnd1,         ///< The first operand
+      Operator* oprnd2,         ///< The second operand
+      Operator* oprnd3,         ///< The third operand
       const Locator* loc = 0 ///< The source locator
     );
 
-    /// Provide a template function for creating a multi-operand operator
     template<class OpClass>
     OpClass* new_MultiOp(
       const Type* Ty,         ///< Result type of the operator
-      const std::vector<Value*>& o, ///< The list of operands
+      const std::vector<Operator*>& o, ///< The list of operands
       const Locator* loc = 0
     );
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Block.cpp (original)
+++ hlvm/trunk/hlvm/AST/Block.cpp Sat Jul  7 19:01:45 2007
@@ -70,4 +70,16 @@
   return I->second;
 }
 
+Block* 
+Block::getParentBlock() const
+{
+  Node* p = getParent();
+  while (p) {
+    if (llvm::isa<Block>(p))
+      return llvm::cast<Block>(p);
+    p = p->getParent();
+  }
+  return 0;
+}
+
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Block.h (original)
+++ hlvm/trunk/hlvm/AST/Block.h Sat Jul  7 19:01:45 2007
@@ -49,7 +49,7 @@
 {
   /// @name Constructors
   /// @{
-  public:
+  protected:
     Block() : MultiOperator(BlockID){}
     virtual ~Block();
 
@@ -60,6 +60,7 @@
     const std::string& getLabel() const { return label; }
     AutoVarOp*   getAutoVar(const std::string& name) const; 
     const Type* getResultType() { return this->back()->getType(); }
+    Block* getParentBlock() const;
     static inline bool classof(const Block*) { return true; }
     static inline bool classof(const Node* N) { return N->is(BlockID); }
 

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.cpp (original)
+++ hlvm/trunk/hlvm/AST/Bundle.cpp Sat Jul  7 19:01:45 2007
@@ -36,18 +36,7 @@
 
 namespace hlvm {
 
-Bundle*
-Bundle::create(const Locator* loc, const std::string& id)
-{
-  Bundle* result = new Bundle();
-  result->setLocator(loc);
-  result->setName(id);
-  return result;
-}
-
-Bundle::~Bundle()
-{
-}
+Bundle::~Bundle() { }
 
 void 
 Bundle::insertChild(Node* kid)
@@ -58,6 +47,8 @@
     vars.insert(cast<Variable>(kid)->getName(), kid);
   else if (kid->isFunction())
     funcs.insert(cast<Function>(kid)->getName(), kid);
+  else if (kid->isConstant()) // must be last, everything above isa<Constant>
+    consts.insert(cast<Constant>(kid)->getName(), kid);
   else
     hlvmAssert("Don't know how to insert that in a Bundle");
 }
@@ -65,7 +56,7 @@
 void
 Bundle::removeChild(Node* kid)
 {
-  hlvmAssert(isa<LinkageItem>(kid) && "Can't remove that here");
+  hlvmAssert(isa<Constant>(kid) && "Can't remove that here");
   // This is sucky slow, but we probably won't be removing nodes that much.
   if (kid->isType()) {
     types.erase(cast<Type>(kid)->getName());
@@ -73,34 +64,44 @@
     vars.erase(cast<Variable>(kid)->getName());
   } else if (kid->isFunction()) {
     funcs.erase(cast<Function>(kid)->getName());
-  }
-  hlvmAssert(!"That node isn't my child");
+  } else if (kid->isConstant()) {
+    consts.erase(cast<Constant>(kid)->getName());
+  } else 
+    hlvmAssert(!"That node isn't my child");
 }
 
 Type*  
-Bundle::type_find(const std::string& name) const
+Bundle::find_type(const std::string& name) const
 {
   if (Node* result = types.lookup(name))
     return llvm::cast<Type>(result);
   return 0;
 }
 
-Function*  
-Bundle::func_find(const std::string& name) const
+Constant*  
+Bundle::find_const(const std::string& name) const
 {
-  if (Node* result = funcs.lookup(name))
-    return llvm::cast<Function>(result);
+  if (Node* result = consts.lookup(name))
+    return llvm::cast<Constant>(result);
   return 0;
 }
 
 Variable*  
-Bundle::var_find(const std::string& name) const
+Bundle::find_var(const std::string& name) const
 {
   if (Node* result = vars.lookup(name))
     return llvm::cast<Variable>(result);
   return 0;
 }
 
+Function*  
+Bundle::find_func(const std::string& name) const
+{
+  if (Node* result = funcs.lookup(name))
+    return llvm::cast<Function>(result);
+  return 0;
+}
+
 Import::~Import()
 {
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.h (original)
+++ hlvm/trunk/hlvm/AST/Bundle.h Sat Jul  7 19:01:45 2007
@@ -31,6 +31,7 @@
 #define HLVM_AST_BUNDLE_H
 
 #include <hlvm/AST/Node.h>
+#include <hlvm/AST/Constants.h>
 #include <hlvm/AST/SymbolTable.h>
 
 namespace hlvm 
@@ -66,12 +67,13 @@
     typedef VarList::iterator var_iterator;
     typedef VarList::const_iterator var_const_iterator;
 
+    typedef SymbolTable ConstList;
+    typedef ConstList::iterator constant_iterator;
+    typedef ConstList::const_iterator constant_const_iterator;
+
   /// @}
   /// @name Constructors
   /// @{
-  public:
-    static Bundle* create(const Locator* location, const std::string& pubid);
-
   protected:
     Bundle() : Documentable(BundleID), name(), types(), vars(), funcs() {}
     virtual ~Bundle();
@@ -96,14 +98,16 @@
   /// @name Finders
   /// @{
   public:
-    Type*     type_find(const std::string& n) const;
-    Function* func_find(const std::string& n) const;
-    Variable*  var_find(const std::string& n) const;
+    Type*     find_type(const std::string& n) const;
+    Constant* find_const(const std::string& n) const;
+    Variable* find_var(const std::string& n) const;
+    Function* find_func(const std::string& n) const;
 
   /// @}
   /// @name Iterators
   /// @{
   public:
+    /// Type iteration
     type_iterator           type_begin()       { return types.begin(); }
     type_const_iterator     type_begin() const { return types.begin(); }
     type_iterator           type_end  ()       { return types.end(); }
@@ -111,27 +115,40 @@
     size_t                  type_size () const { return types.size(); }
     bool                    type_empty() const { return types.empty(); }
 
-    func_iterator           func_begin()       { return funcs.begin(); }
-    func_const_iterator     func_begin() const { return funcs.begin(); }
-    func_iterator           func_end  ()       { return funcs.end(); }
-    func_const_iterator     func_end  () const { return funcs.end(); }
-    size_t                  func_size () const { return funcs.size(); }
-    bool                    func_empty() const { return funcs.empty(); }
+    /// Constant iteration
+    constant_iterator       const_begin()       { return consts.begin(); }
+    constant_const_iterator const_begin() const { return consts.begin(); }
+    constant_iterator       const_end  ()       { return consts.end(); }
+    constant_const_iterator const_end  () const { return consts.end(); }
+    size_t                  const_size () const { return consts.size(); }
+    bool                    const_empty() const { return consts.empty(); }
 
+    /// Variable iteration
     var_iterator            var_begin()       { return vars.begin(); }
     var_const_iterator      var_begin() const { return vars.begin(); }
     var_iterator            var_end  ()       { return vars.end(); }
     var_const_iterator      var_end  () const { return vars.end(); }
     size_t                  var_size () const { return vars.size(); }
     bool                    var_empty() const { return vars.empty(); }
+
+    /// Function iteration
+    func_iterator           func_begin()       { return funcs.begin(); }
+    func_const_iterator     func_begin() const { return funcs.begin(); }
+    func_iterator           func_end  ()       { return funcs.end(); }
+    func_const_iterator     func_end  () const { return funcs.end(); }
+    size_t                  func_size () const { return funcs.size(); }
+    bool                    func_empty() const { return funcs.empty(); }
+
   /// @}
   /// @name Data
   /// @{
   protected:
     std::string name;   ///< The name for this bundle
     TypeList    types;  ///< The list of types
+    ConstList   consts; ///< The list of constants
     VarList     vars;   ///< The list of variables
     FuncList    funcs;  ///< The list of functions
+
   /// @}
   friend class AST;
 };
@@ -150,8 +167,6 @@
   /// @{
   protected:
     Import() : Documentable(ImportID) {}
-
-  public:
     virtual ~Import();
 
   /// @}

Removed: hlvm/trunk/hlvm/AST/Constant.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Constant.cpp?rev=38262&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/Constant.cpp (original)
+++ hlvm/trunk/hlvm/AST/Constant.cpp (removed)
@@ -1,38 +0,0 @@
-//===-- AST Constant Node ---------------------------------------*- 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/Constant.cpp
-/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
-/// @date 2006/06/02
-/// @since 0.1.0
-/// @brief Implements the functions of class hlvm::Constant.
-//===----------------------------------------------------------------------===//
-
-#include <hlvm/AST/Constant.h>
-
-namespace hlvm {
-
-Constant::~Constant()
-{
-}
-
-}

Removed: hlvm/trunk/hlvm/AST/Constant.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Constant.h?rev=38262&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/Constant.h (original)
+++ hlvm/trunk/hlvm/AST/Constant.h (removed)
@@ -1,72 +0,0 @@
-//===-- AST Constant Abstract Class -----------------------------*- C++ -*-===//
-//
-//                      High Level Virtual Machine (HLVM)
-//
-// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
-//
-// This software is free software; you can redistribute it and/or modify it 
-// under the terms of the GNU Lesser General Public License as published by 
-// the Free Software Foundation; either version 2.1 of the License, or (at 
-// your option) any later version.
-//
-// This software is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
-// more details.
-//
-// You should have received a copy of the GNU Lesser General Public License 
-// along with this library in the file named LICENSE.txt; if not, write to the 
-// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
-// MA 02110-1301 USA
-//
-//===----------------------------------------------------------------------===//
-/// @file hlvm/AST/Constant.h
-/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
-/// @date 2006/05/25
-/// @since 0.1.0
-/// @brief Declares the AST Constant Class
-//===----------------------------------------------------------------------===//
-
-#ifndef HLVM_AST_CONSTANT_H
-#define HLVM_AST_CONSTANT_H
-
-#include <hlvm/AST/Node.h>
-
-namespace hlvm 
-{
-
-/// This abstract base class represents a constant value in the HLVM Abstract 
-/// Syntax Tree.  All Constants are immutable values of a specific type. 
-/// Constants do not have a storage location nor an address nor do they
-/// participate in linking.  However, as they are values they may be used as 
-/// the operand of instructions or as the initializers of variables. Constants
-/// do not participate in linking and are always internal to the bundle in which
-/// they appear. To create a linkable constant, declare a variable that is 
-/// constant and initialize it with a Constant.  There are many kinds of 
-/// constants including simple literal values (numbers an text), complex 
-/// constant expressions (constant computations), and aggregate constants that
-/// represent constant arrays, vectors, pointers and structures.
-/// @see hlvm/AST/Constants.h
-/// @brief AST Abstract Constant Node
-class Constant : public Value
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    Constant(NodeIDs id) : Value(id) {}
-  public:
-    virtual ~Constant();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    static inline bool classof(const Constant*) { return true; }
-    static inline bool classof(const Node* N) { return N->isConstant(); }
-
-  /// @}
-  friend class AST;
-};
-
-} // end hlvm namespace
-#endif

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Constants.cpp (original)
+++ hlvm/trunk/hlvm/AST/Constants.cpp Sat Jul  7 19:01:45 2007
@@ -32,13 +32,10 @@
 
 namespace hlvm {
 
+Constant::~Constant() { }
 ConstantBoolean::~ConstantBoolean() { }
 ConstantInteger::~ConstantInteger() { }
-
 ConstantReal::~ConstantReal() { }
-
-ConstantText::~ConstantText() { }
-
-ConstantZero::~ConstantZero() { }
+ConstantString::~ConstantString() { }
 
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Constants.h (original)
+++ hlvm/trunk/hlvm/AST/Constants.h Sat Jul  7 19:01:45 2007
@@ -30,11 +30,56 @@
 #ifndef HLVM_AST_CONSTANTS_H
 #define HLVM_AST_CONSTANTS_H
 
-#include <hlvm/AST/Constant.h>
+#include <hlvm/AST/Node.h>
 
 namespace hlvm 
 {
 
+/// This abstract base class represents a constant value in the HLVM Abstract 
+/// Syntax Tree.  All Constants are immutable values of a specific type. 
+/// Constants do not have a storage location nor an address nor do they
+/// participate in linking.  However, as they are values they may be used as 
+/// the operand of instructions or as the initializers of variables. Constants
+/// do not participate in linking and are always internal to the bundle in which
+/// they appear. To create a linkable constant, declare a variable that is 
+/// constant and initialize it with a Constant.  There are many kinds of 
+/// constants including simple literal values (numbers an text), complex 
+/// constant expressions (constant computations), and aggregate constants that
+/// represent constant arrays, vectors, pointers and structures.
+/// @see hlvm/AST/Constants.h
+/// @brief AST Abstract Constant Node
+class Constant : public Value
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    Constant(NodeIDs id) : Value(id), name()  {}
+    virtual ~Constant();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    // Get the type of the value
+    inline const std::string& getName() const { return name; }
+    static inline bool classof(const Constant*) { return true; }
+    static inline bool classof(const Node* N) { return N->isConstant(); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+  public:
+    void setName(const std::string& n) { name = n; }
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    std::string name; ///< The name of this Value.
+  /// @}
+  friend class AST;
+};
+
 /// This class provides an Abstract Syntax Tree node that yields a 
 /// constant boolean value. 
 /// @brief AST Constant Boolean Node
@@ -51,7 +96,7 @@
   /// @name Accessors
   /// @{
   public:
-    bool getValue() { return flags != 0; }
+    bool getValue() const { return flags != 0; }
     static inline bool classof(const ConstantBoolean*) { return true; }
     static inline bool classof(const Node* N) 
       { return N->is(ConstantBooleanID); }
@@ -70,15 +115,15 @@
   /// @name Constructors
   /// @{
   protected:
-    ConstantInteger() : Constant(ConstantIntegerID) {}
+    ConstantInteger(uint16_t base) : Constant(ConstantIntegerID) {}
     virtual ~ConstantInteger();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
-    uint64_t getValue(int) const { return value.u; }
-    int64_t  getValue()    const { return value.s; }
+    const std::string& getValue() const { return value; }
+    uint16_t getBase() const { return flags; }
     static inline bool classof(const ConstantInteger*) { return true; }
     static inline bool classof(const Node* N) 
       { return N->is(ConstantIntegerID); }
@@ -87,17 +132,14 @@
   /// @name Mutators
   /// @{
   public:
-    void setValue(uint64_t v) { value.u = v; }
-    void setValue(int64_t v)  { value.s = v; }
+    void setValue(const std::string& v) { value = v; }
+    void setBase(uint16_t base) { flags = base; }
 
   /// @}
   /// @name Data
   /// @{
   public:
-    union {
-      uint64_t u;
-      int64_t  s;
-    } value;
+    std::string value;
   /// @}
   friend class AST;
 };
@@ -119,7 +161,7 @@
   /// @name Accessors
   /// @{
   public:
-    double getValue() const { return value; }
+    const std::string& getValue() const { return value; }
     static inline bool classof(const ConstantReal*) { return true; }
     static inline bool classof(const Node* N) 
       { return N->is(ConstantRealID); }
@@ -128,42 +170,37 @@
   /// @name Accessors
   /// @{
   public:
-    void setValue(double v ) { value = v; }
+    void setValue(const std::string& v ) { value = v; }
 
   /// @}
   /// @name Data
   /// @{
   public:
-    double value;
+    std::string value;
   /// @}
   friend class AST;
 };
 
 /// This class provides an Abstract Syntax Tree node that yields a constant 
-/// text value. The constant value is encoded in UTF-8 but may be converted 
-/// to other encodings depending on how it is used. For example, when used to
-/// initialize a TextType Variable that is using UTF-16 encoding, the conversion
-/// will occur whenever the Variable is loaded. UTF-8 encoding is used for
-/// constant text values to reduce storage requirements and for compatibility
-/// with older non-Unicode systems.
-/// @see TextType
-/// @brief AST Constant Text Node
-class ConstantText : public Constant
+/// string value. The constant value is encoded in UTF-8 with a null terminator.
+/// @see StringType
+/// @brief AST Constant String Node
+class ConstantString : public Constant
 {
   /// @name Constructors
   /// @{
   protected:
-    ConstantText() : Constant(ConstantTextID)  {}
-    virtual ~ConstantText();
+    ConstantString() : Constant(ConstantStringID)  {}
+    virtual ~ConstantString();
 
   /// @}
   /// @name Accessors
   /// @{
   public:
     const std::string&  getValue() const{ return value; }
-    static inline bool classof(const ConstantText*) { return true; }
+    static inline bool classof(const ConstantString*) { return true; }
     static inline bool classof(const Node* N) 
-      { return N->is(ConstantTextID); }
+      { return N->is(ConstantStringID); }
 
   /// @}
   /// @name Accessors
@@ -180,33 +217,6 @@
   friend class AST;
 };
 
-/// This class provides an Abstract Syntax Tree node that yields a zero value
-/// for any type. In essence, this is a short-cut. Zero value constants are very
-/// common and defining them explicitly for each type of constant makes use of
-/// the AST constants cumbersome. The way to think about this node is that it
-/// represents a constant value of any type such that all the bits of that type
-/// are zero.
-/// @brief AST Constant Zero Node
-class ConstantZero : public Constant
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    ConstantZero() : Constant(ConstantZeroID)  {}
-    virtual ~ConstantZero();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    static inline bool classof(const ConstantZero*) { return true; }
-    static inline bool classof(const Node* N) 
-      { return N->is(ConstantZeroID); }
-
-  /// @}
-  friend class AST;
-};
-
 /// This class provides an Abstract Syntax Tree node that yields a constant
 /// aggregate. This can be used to specify constant values of aggregate types
 /// such as arrays, vectors, structures and continuations. It simply contains 
@@ -221,6 +231,7 @@
     typedef ElementsList::iterator iterator;
     typedef ElementsList::const_iterator const_iterator;
 
+  /// @}
   /// @name Constructors
   /// @{
   protected:

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

==============================================================================
--- hlvm/trunk/hlvm/AST/ContainerType.h (original)
+++ hlvm/trunk/hlvm/AST/ContainerType.h Sat Jul  7 19:01:45 2007
@@ -304,8 +304,7 @@
   /// @name Constructors
   /// @{
   protected:
-    StructureType(NodeIDs id = StructureTypeID ) : 
-      DisparateContainerType(id) {}
+    StructureType(NodeIDs id = StructureTypeID ) : DisparateContainerType(id) {}
     virtual ~StructureType();
 
   /// @}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Documentation.cpp (original)
+++ hlvm/trunk/hlvm/AST/Documentation.cpp Sat Jul  7 19:01:45 2007
@@ -31,8 +31,4 @@
 
 namespace hlvm {
 
-Documentation::~Documentation()
-{
-}
-
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Documentation.h (original)
+++ hlvm/trunk/hlvm/AST/Documentation.h Sat Jul  7 19:01:45 2007
@@ -35,58 +35,5 @@
 namespace hlvm 
 {
 
-/// This class provides an Abstract Syntax Tree node that represents program
-/// documentation. Documentation nodes may be attached to any Documentable which
-/// is an abstract base class of nearly every type of AST node. This construct
-/// permits documentation (not just comments) to be included directly into the
-/// nodes of the Abstract Syntax Tree as first class objects, not just addenda.
-/// Each Documentation node simply contains a block of text that provides the
-/// documentation for the Documentable to which the Documentation is attached.
-/// The intended use is that the text contain XHTML markup. In this way, an 
-/// automated documentation facility can translate the AST into XHTML 
-/// documentation with great accuracy in associating documentation with the
-/// nodes of the AST. Since the documentation node can be associated with 
-/// nearly any kind of node, this affords a complete system for documenting 
-/// HLVM programs with XHTML markup. There is, however, no firm requirement 
-/// that XHTML be used for the documentation. Any kind of documentation that is
-/// expressible in UTF-8 notation can be accommodated including other markup
-/// languages or simple ASCII text.
-/// @see Documentable
-/// @brief AST Documentation Node
-class Documentation : public Node
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    Documentation() : Node(DocumentationID) {}
-
-  public:
-    virtual ~Documentation();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    const std::string& getDoc() const { return doc; }
-    static inline bool classof(const Documentation*) { return true; }
-    static inline bool classof(const Node* N) 
-    { return N->is(DocumentationID); }
-
-  /// @}
-  /// @name Mutators
-  /// @{
-  public:
-    void setDoc(const std::string& d) { doc = d; }
-    void addDoc(const std::string& d) { doc += d; }
-
-  /// @}
-  /// @name Data
-  /// @{
-  protected:
-    std::string doc;
-  /// @}
-  friend class AST;
-};
-
 } // hlvm
 #endif

Removed: hlvm/trunk/hlvm/AST/LinkageItem.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItem.cpp?rev=38262&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItem.cpp (original)
+++ hlvm/trunk/hlvm/AST/LinkageItem.cpp (removed)
@@ -1,38 +0,0 @@
-//===-- hlvm/AST/LinkageItem.cpp - AST LinkageItem Class --------*- C++ -*-===//
-//
-//                      High Level Virtual Machine (HLVM)
-//
-// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
-//
-// This software is free software; you can redistribute it and/or modify it 
-// under the terms of the GNU Lesser General Public License as published by 
-// the Free Software Foundation; either version 2.1 of the License, or (at 
-// your option) any later version.
-//
-// This software is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
-// more details.
-//
-// You should have received a copy of the GNU Lesser General Public License 
-// along with this library in the file named LICENSE.txt; if not, write to the 
-// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
-// MA 02110-1301 USA
-//
-//===----------------------------------------------------------------------===//
-/// @file hlvm/AST/LinkageItem.cpp
-/// @author Reid Spencer <rspencer at reidspencer.org> (original author)
-/// @date 2006/05/18
-/// @since 0.1.0
-/// @brief Implements the functions of class hlvm::AST::LinkageItem.
-//===----------------------------------------------------------------------===//
-
-#include <hlvm/AST/LinkageItem.h>
-
-namespace hlvm {
-
-LinkageItem::~LinkageItem()
-{
-}
-
-}

Removed: hlvm/trunk/hlvm/AST/LinkageItem.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItem.h?rev=38262&view=auto

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItem.h (original)
+++ hlvm/trunk/hlvm/AST/LinkageItem.h (removed)
@@ -1,101 +0,0 @@
-//===-- AST LinkageItem Class -----------------------------------*- C++ -*-===//
-//
-//                      High Level Virtual Machine (HLVM)
-//
-// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
-//
-// This software is free software; you can redistribute it and/or modify it 
-// under the terms of the GNU Lesser General Public License as published by 
-// the Free Software Foundation; either version 2.1 of the License, or (at 
-// your option) any later version.
-//
-// This software is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
-// more details.
-//
-// You should have received a copy of the GNU Lesser General Public License 
-// along with this library in the file named LICENSE.txt; if not, write to the 
-// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
-// MA 02110-1301 USA
-//
-//===----------------------------------------------------------------------===//
-/// @file hlvm/AST/LinkageItem.h
-/// @author Reid Spencer <reid at hlvm.org> (original author)
-/// @date 2006/05/04
-/// @since 0.1.0
-/// @brief Declares the class hlvm::AST::LinkageItem
-//===----------------------------------------------------------------------===//
-
-#ifndef HLVM_AST_LINKAGEITEM_H
-#define HLVM_AST_LINKAGEITEM_H
-
-#include <hlvm/AST/Constant.h>
-
-namespace hlvm
-{
-
-/// This enumeration is used to specify the kinds of linkage that are
-/// permitted for a LinkageItem.
-/// @brief Enumeration of ways to link bundles
-enum LinkageKinds {
-  ExternalLinkage   = 1, ///< Externally visible item
-  LinkOnceLinkage   = 2, ///< Keep one copy of item when linking (inline)
-  WeakLinkage       = 3, ///< Keep one copy of item when linking (weak)
-  AppendingLinkage  = 4, ///< Append item to an array of similar items
-  InternalLinkage   = 5  ///< Rename collisions when linking (static funcs)
-};
-
-/// This class provides an Abstract Syntax Tree node that represents an item
-/// which can be linked with other Bundles. LinkageItem is an abstract base 
-/// class and cannot be instantiated. All LinkageItem's are Constant values
-/// because they represents a runtime value that is a constant address. The
-/// value pointed to by the LinkageItem may be mutable or immutable depending
-/// on its type and options.  As the name suggests, LinkageItems participate
-/// in linkage. A Bundle referring to a name in another Bundle will only link
-/// with a LinkageItem and nothing else. There are several ways in which 
-/// LinkageItems can be linked together, specified by the LinkageKinds value.
-/// @see LinkageKinds
-/// @see Bundle
-/// @see Constant
-/// @brief AST Bundle Node
-class LinkageItem : public Constant
-{
-  /// @name Constructors
-  /// @{
-  protected:
-    LinkageItem( NodeIDs id ) : Constant(id), name() {
-      setLinkageKind(InternalLinkage);
-    }
-  public:
-    virtual ~LinkageItem();
-
-  /// @}
-  /// @name Accessors
-  /// @{
-  public:
-    inline const std::string& getName() const { return name; }
-    inline LinkageKinds getLinkageKind() const { 
-      return LinkageKinds(flags & 0x0007); }
-    static inline bool classof(const LinkageItem*) { return true; }
-    static inline bool classof(const Node* N) { return N->isLinkageItem(); }
-
-  /// @}
-  /// @name Mutators
-  /// @{
-    void setName(const std::string& n) { name = n; }
-    void setLinkageKind(LinkageKinds k) { 
-      flags &= 0xFFF8; flags |= uint16_t(k); 
-    }
-
-  /// @}
-  /// @name Data
-  /// @{
-  protected:
-    std::string name;
-  /// @}
-  friend class AST;
-};
-
-} // hlvm
-#endif

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

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItems.cpp (original)
+++ hlvm/trunk/hlvm/AST/LinkageItems.cpp Sat Jul  7 19:01:45 2007
@@ -36,13 +36,10 @@
 
 namespace hlvm {
 
-Variable::~Variable()
-{
-}
-
-Function::~Function() 
-{
-}
+LinkageItem::~LinkageItem() { }
+Variable::~Variable() { }
+Function::~Function() { }
+Program::~Program() { }
 
 const SignatureType* 
 Function::getSignature() const
@@ -72,8 +69,4 @@
   }
 }
 
-Program::~Program()
-{
-}
-
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItems.h (original)
+++ hlvm/trunk/hlvm/AST/LinkageItems.h Sat Jul  7 19:01:45 2007
@@ -30,7 +30,7 @@
 #ifndef HLVM_AST_LINKAGEITEMS_H
 #define HLVM_AST_LINKAGEITEMS_H
 
-#include <hlvm/AST/LinkageItem.h>
+#include <hlvm/AST/Constants.h>
 #include <hlvm/AST/ContainerType.h>
 #include <hlvm/AST/Block.h>
 
@@ -40,6 +40,58 @@
 class Type; // Forward declare
 class Constant;
 
+/// This enumeration is used to specify the kinds of linkage that are
+/// permitted for a LinkageItem.
+/// @brief Enumeration of ways to link bundles
+enum LinkageKinds {
+  ExternalLinkage   = 1, ///< Externally visible item
+  LinkOnceLinkage   = 2, ///< Keep one copy of item when linking (inline)
+  WeakLinkage       = 3, ///< Keep one copy of item when linking (weak)
+  AppendingLinkage  = 4, ///< Append item to an array of similar items
+  InternalLinkage   = 5  ///< Rename collisions when linking (static funcs)
+};
+
+/// This class provides an Abstract Syntax Tree node that represents an item
+/// which can be linked with other Bundles. LinkageItem is an abstract base 
+/// class and cannot be instantiated. All LinkageItem's are Constant values
+/// because they represents a runtime value that is a constant address. The
+/// value pointed to by the LinkageItem may be mutable or immutable depending
+/// on its type and options.  As the name suggests, LinkageItems participate
+/// in linkage. A Bundle referring to a name in another Bundle will only link
+/// with a LinkageItem and nothing else. There are several ways in which 
+/// LinkageItems can be linked together, specified by the LinkageKinds value.
+/// @see LinkageKinds
+/// @see Bundle
+/// @see Constant
+/// @brief AST Bundle Node
+class LinkageItem : public Constant
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    LinkageItem( NodeIDs id ) : Constant(id) { setLinkageKind(InternalLinkage);}
+    virtual ~LinkageItem();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    inline LinkageKinds getLinkageKind() const { 
+      return LinkageKinds(flags & 0x0007); }
+    static inline bool classof(const LinkageItem*) { return true; }
+    static inline bool classof(const Node* N) { return N->isLinkageItem(); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+    void setLinkageKind(LinkageKinds k) { 
+      flags &= 0xFFF8; flags |= uint16_t(k); 
+    }
+
+  /// @}
+  friend class AST;
+};
+
 /// This class provides an Abstract Syntax Tree node that represents a 
 /// global Variable.  A Variable can only be declared as a component of a 
 /// Bundle. It is visible throughout the Bundle that declares it and may 
@@ -55,8 +107,7 @@
   /// @name Constructors
   /// @{
   protected:
-    Variable() : LinkageItem(VariableID) {}
-  public:
+    Variable() : LinkageItem(VariableID), init(0) {}
     virtual ~Variable();
 
   /// @}
@@ -64,7 +115,9 @@
   /// @{
   public:
     bool isConstant() const { return flags & 0x0008; }
-    Constant* getInitializer() { return init; }
+    Constant* getInitializer() const { return init; }
+    bool hasInitializer() const { return init != 0; }
+    bool isZeroInitialized() const { return init == 0; }
     static inline bool classof(const Variable*) { return true; }
     static inline bool classof(const Node* N) { return N->is(VariableID); }
 
@@ -103,10 +156,8 @@
 {
   /// @name Constructors
   /// @{
-  public:
-    Function(
-      NodeIDs id = FunctionID
-    ) : LinkageItem(id), block(0) {}
+  protected:
+    Function(NodeIDs id = FunctionID) : LinkageItem(id), block(0) {}
     virtual ~Function();
 
   /// @}
@@ -156,7 +207,6 @@
   /// @{
   protected:
     Program() : Function(ProgramID) {}
-      
     virtual ~Program();
 
   /// @}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Locator.cpp (original)
+++ hlvm/trunk/hlvm/AST/Locator.cpp Sat Jul  7 19:01:45 2007
@@ -57,6 +57,11 @@
   ref = uri->as_string();
 }
 
+uint32_t URILocator::getLine() const { return 0; }
+uint32_t URILocator::getColumn() const { return 0; }
+uint32_t URILocator::getEndLine() const { return 0; }
+uint32_t URILocator::getEndColumn() const { return 0; }
+
 void 
 LineLocator::getLocation(std::string& ref) const
 {
@@ -74,6 +79,12 @@
       this->line == static_cast<const LineLocator&>(that).line;
   return false;
 }
+
+uint32_t LineLocator::getLine() const { return line; }
+uint32_t LineLocator::getColumn() const { return 0; }
+uint32_t LineLocator::getEndLine() const { return line; }
+uint32_t LineLocator::getEndColumn() const { return 0; }
+
 void
 LineColumnLocator::getLocation(std::string& ref) const
 {
@@ -81,6 +92,11 @@
   ref += ":" + llvm::utostr(col);
 }
 
+uint32_t LineColumnLocator::getLine() const { return line; }
+uint32_t LineColumnLocator::getColumn() const { return col; }
+uint32_t LineColumnLocator::getEndLine() const { return line; }
+uint32_t LineColumnLocator::getEndColumn() const { return col; }
+
 bool
 LineColumnLocator::equals(const Locator& that) const
 {
@@ -100,6 +116,11 @@
              + llvm::utostr(line2) + ":" + llvm::utostr(col2) + ")"; 
 }
 
+uint32_t RangeLocator::getLine() const { return line; }
+uint32_t RangeLocator::getColumn() const { return col; }
+uint32_t RangeLocator::getEndLine() const { return line2; }
+uint32_t RangeLocator::getEndColumn() const { return col2; }
+
 bool
 RangeLocator::equals(const Locator& that) const
 {

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Locator.h (original)
+++ hlvm/trunk/hlvm/AST/Locator.h Sat Jul  7 19:01:45 2007
@@ -57,6 +57,10 @@
   /// @{
   public:
     virtual void getLocation(std::string& ref) const = 0;
+    virtual uint32_t getLine() const = 0;
+    virtual uint32_t getColumn() const = 0;
+    virtual uint32_t getEndLine() const = 0;
+    virtual uint32_t getEndColumn() 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; }
@@ -75,7 +79,7 @@
 {
   /// @name Constructors
   /// @{
-  public:
+  protected:
     URILocator(const URI* u) : Locator(), uri(u) { SubclassID = 1; }
     virtual ~URILocator();
 
@@ -84,6 +88,10 @@
   /// @{
   public:
     virtual void getLocation(std::string& ref) const;
+    virtual uint32_t getLine() const;
+    virtual uint32_t getColumn() const;
+    virtual uint32_t getEndLine() const;
+    virtual uint32_t getEndColumn() const;
     virtual bool equals(const Locator& that) const;
 
   /// @}
@@ -92,6 +100,7 @@
   protected:
     const URI* uri;
   /// @}
+  friend class AST;
 };
 
 /// This Locator can be used to locate a specific line within some resource. It
@@ -102,7 +111,7 @@
 {
   /// @name Constructors
   /// @{
-  public:
+  protected:
     LineLocator(const URI* u, uint32_t l) : URILocator(u), line(l) {
       SubclassID = 2; 
     }
@@ -113,6 +122,10 @@
   /// @{
   public:
     virtual void getLocation(std::string& ref) const;
+    virtual uint32_t getLine() const;
+    virtual uint32_t getColumn() const;
+    virtual uint32_t getEndLine() const;
+    virtual uint32_t getEndColumn() const;
     virtual bool equals(const Locator& that) const;
 
   /// @}
@@ -121,6 +134,7 @@
   protected:
     uint32_t line;           ///< Line number of source location
   /// @}
+  friend class AST;
 };
 
 /// This class provides a locator that specifies a specific column on a specific
@@ -130,7 +144,7 @@
 {
   /// @name Constructors
   /// @{
-  public:
+  protected:
     LineColumnLocator(const URI* u, uint32_t l, uint32_t c) 
       : LineLocator(u,l), col(c) { SubclassID = 3; }
     virtual ~LineColumnLocator();
@@ -140,6 +154,10 @@
   /// @{
   public:
     virtual void getLocation(std::string& ref) const;
+    virtual uint32_t getLine() const;
+    virtual uint32_t getColumn() const;
+    virtual uint32_t getEndLine() const;
+    virtual uint32_t getEndColumn() const;
     virtual bool equals(const Locator& that) const;
 
   /// @}
@@ -148,6 +166,7 @@
   protected:
     uint32_t col;            ///< Column number of source location
   /// @}
+  friend class AST;
 };
 
 /// This class provides a Locator that identifies a range of text in a source
@@ -160,7 +179,7 @@
 {
   /// @name Constructors
   /// @{
-  public:
+  protected:
     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; }
     virtual ~RangeLocator();
@@ -170,6 +189,10 @@
   /// @{
   public:
     virtual void getLocation(std::string& ref) const;
+    virtual uint32_t getLine() const;
+    virtual uint32_t getColumn() const;
+    virtual uint32_t getEndLine() const;
+    virtual uint32_t getEndColumn() const;
     virtual bool equals(const Locator& that) const;
 
   /// @}
@@ -179,6 +202,7 @@
     uint32_t line2;           ///< Column number of source location
     uint32_t col2;            ///< Column number of source location
   /// @}
+  friend class AST;
 };
 
 } // hlvm

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

==============================================================================
--- hlvm/trunk/hlvm/AST/MemoryOps.cpp (original)
+++ hlvm/trunk/hlvm/AST/MemoryOps.cpp Sat Jul  7 19:01:45 2007
@@ -35,6 +35,7 @@
 StoreOp::~StoreOp() {}
 AutoVarOp::~AutoVarOp() {}
 ReferenceOp::~ReferenceOp() {}
+ConstantReferenceOp::~ConstantReferenceOp() {}
 IndexOp::~IndexOp() {}
 
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/MemoryOps.h (original)
+++ hlvm/trunk/hlvm/AST/MemoryOps.h Sat Jul  7 19:01:45 2007
@@ -31,7 +31,7 @@
 #define HLVM_AST_MEMORYOPS_H
 
 #include <hlvm/AST/Operator.h>
-#include <hlvm/AST/Constant.h>
+#include <hlvm/AST/Constants.h>
 
 namespace hlvm
 {
@@ -49,8 +49,6 @@
   /// @{
   protected:
     AllocateOp() : UnaryOperator(AllocateOpID) {}
-
-  public:
     virtual ~AllocateOp();
 
   /// @}
@@ -78,8 +76,6 @@
   /// @{
   protected:
     DeallocateOp() : UnaryOperator(DeallocateOpID) {}
-
-  public:
     virtual ~DeallocateOp();
 
   /// @}
@@ -108,8 +104,6 @@
   /// @{
   protected:
     LoadOp() : UnaryOperator(LoadOpID) {}
-
-  public:
     virtual ~LoadOp();
 
   /// @}
@@ -143,8 +137,6 @@
   /// @{
   protected:
     StoreOp() : BinaryOperator(StoreOpID) {}
-
-  public:
     virtual ~StoreOp();
 
   /// @}
@@ -179,14 +171,12 @@
 /// variables may be declared to be constant in which case they must have an
 /// initializer and their value is immutable.
 /// @brief AST Automatic Variable Operator
-class AutoVarOp : public UnaryOperator
+class AutoVarOp : public NilaryOperator
 {
   /// @name Constructors
   /// @{
   protected:
-    AutoVarOp() : UnaryOperator(AutoVarOpID) {}
-
-  public:
+    AutoVarOp() : NilaryOperator(AutoVarOpID), name(), initializer(0) {}
     virtual ~AutoVarOp();
 
   /// @}
@@ -194,7 +184,9 @@
   /// @{
   public:
     const std::string& getName() const { return name; }
-    Constant* getInitializer() { return static_cast<Constant*>(getOperand());}
+    bool hasInitializer() const { return initializer != 0; }
+    Constant* getInitializer() const { return initializer; }
+    bool isZeroInitialized() const { return initializer == 0; }
     static inline bool classof(const AutoVarOp*) { return true; }
     static inline bool classof(const Node* N) { return N->is(AutoVarOpID); }
 
@@ -203,13 +195,14 @@
   /// @{
   public:
     void setName(const std::string& n) { name = n; }
-    void setInitializer(Constant* c) { setOperand(c); }
+    void setInitializer(Constant* C) { initializer = C; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
     std::string name;
+    Constant* initializer;
   /// @}
   friend class AST;
 };
@@ -229,8 +222,6 @@
   /// @{
   protected:
     ReferenceOp() : NilaryOperator(ReferenceOpID) {}
-
-  public:
     virtual ~ReferenceOp();
 
   /// @}
@@ -257,6 +248,47 @@
 };
 
 /// This class provides an Abstract Syntax Tree node that represents an operator
+/// for obtaining the value of a named constant.  The operator has no operands
+/// but has a property that is the Constant to be referenced. It is presumed 
+/// This operator bridges between non-operator Constants and Operators. The 
+/// result of this operator is the value of the constnat. Typically this 
+/// operator is used as the operand of some other operator to introduce the
+/// value of a constant.
+/// @see Reference Constant Operator Value
+/// @brief AST ConstantReference Operator
+class ConstantReferenceOp : public NilaryOperator
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    ConstantReferenceOp() : NilaryOperator(ConstantReferenceOpID) {}
+    virtual ~ConstantReferenceOp();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    const Constant* getReferent() const { return referent; }
+    static inline bool classof(const ConstantReferenceOp*) { return true; }
+    static inline bool classof(const Node* N) { 
+      return N->is(ConstantReferenceOpID); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+  public:
+    void setReferent(const Constant* ref) { referent = ref; }
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    const Constant* referent;
+  /// @}
+  friend class AST;
+};
+
+/// This class provides an Abstract Syntax Tree node that represents an operator
 /// for indexing into a ContainerType.  The Index operator can have many
 /// operands but in all cases requires at least two.  The first operand must
 /// resolve to the address of a memory location, such as returned by the
@@ -275,8 +307,6 @@
   /// @{
   protected:
     IndexOp() : MultiOperator(IndexOpID) {}
-
-  public:
     virtual ~IndexOp();
 
   /// @}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.cpp (original)
+++ hlvm/trunk/hlvm/AST/Node.cpp Sat Jul  7 19:01:45 2007
@@ -61,7 +61,6 @@
   hlvmNotImplemented("Node::insertChild");
 }
 
-
 void 
 Node::setParent(Node* p)
 {
@@ -76,12 +75,9 @@
   }
 }
 
-#ifndef _NDEBUG
-void 
-Node::dump() const 
+Documentation::~Documentation()
 {
 }
-#endif
 
 Documentable::~Documentable()
 {

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul  7 19:01:45 2007
@@ -38,7 +38,6 @@
 {
 
 class Type;
-class Documentation;
 class AST;
 
 /// This enumeration is used to identify the various kinds of Abstract Syntax
@@ -89,6 +88,7 @@
   // Simple Types (no nested classes)
   AnyTypeID,               ///< The Any Type (Union of any type)
 FirstSimpleTypeID    = AnyTypeID,
+  StringTypeID,            ///< A string of characters type
   IntegerTypeID,           ///< The Integer Type (A # of bits of integer data)
   RangeTypeID,             ///< The Range Type (A Range of Integer Values)
   EnumerationTypeID,       ///< The Enumeration Type (set of enumerated ids)
@@ -131,13 +131,12 @@
   // SUBCLASSES OF VALUE
 
   // Constants
-  ConstantZeroID,          ///< A zero-filled constant of any type
-FirstValueID = ConstantZeroID,
-FirstConstantID = ConstantZeroID,
   ConstantBooleanID,       ///< A constant boolean value
+FirstValueID = ConstantBooleanID,
+FirstConstantID = ConstantBooleanID,
   ConstantIntegerID,       ///< A constant integer value
   ConstantRealID,          ///< A constant real value
-  ConstantTextID,          ///< A constant text value
+  ConstantStringID,        ///< A constant string value
   ConstantAggregateID,     ///< A constant aggregate for arrays, structures, etc
   ConstantExpressionID,    ///< A constant expression
   SizeOfID,                ///< Size of a type
@@ -162,7 +161,8 @@
   NInfOpID,                ///< Constant Negative Infinity Real Value
   NaNOpID,                 ///< Constant Not-A-Number Real Value
   ReferenceOpID,           ///< Obtain pointer to local/global variable
-LastNilaryOperatorID = ReferenceOpID,
+  ConstantReferenceOpID,   ///< Obtain pointer to local/global variable
+LastNilaryOperatorID = ConstantReferenceOpID,
 
   // Control Flow Unary Operators
   NoOperatorID,            ///< The "do nothing" NoOp Operators
@@ -328,6 +328,9 @@
       return (id >= Float32TypeID && id <= Float128TypeID) ||
              (id == RealTypeID); }
 
+    inline bool isNumericType() const {
+      return isIntegralType() || isRealType() || id == RangeTypeID; }
+
     /// Determine if the node is a primitive type
     inline bool isPrimitiveType() const {
       return id >= FirstPrimitiveTypeID && 
@@ -410,13 +413,6 @@
   protected:
     virtual void insertChild(Node* child);
     virtual void removeChild(Node* child);
-  /// @}
-  /// @name Utilities
-  /// @{
-  public:
-#ifndef _NDEBUG
-    virtual void dump() const;
-#endif
 
   /// @}
   /// @name Data
@@ -430,6 +426,57 @@
   friend class AST;
 };
 
+/// This class provides an Abstract Syntax Tree node that represents program
+/// documentation. Documentation nodes may be attached to any Documentable which
+/// is an abstract base class of nearly every type of AST node. This construct
+/// permits documentation (not just comments) to be included directly into the
+/// nodes of the Abstract Syntax Tree as first class objects, not just addenda.
+/// Each Documentation node simply contains a block of text that provides the
+/// documentation for the Documentable to which the Documentation is attached.
+/// The intended use is that the text contain XHTML markup. In this way, an 
+/// automated documentation facility can translate the AST into XHTML 
+/// documentation with great accuracy in associating documentation with the
+/// nodes of the AST. Since the documentation node can be associated with 
+/// nearly any kind of node, this affords a complete system for documenting 
+/// HLVM programs with XHTML markup. There is, however, no firm requirement 
+/// that XHTML be used for the documentation. Any kind of documentation that is
+/// expressible in UTF-8 notation can be accommodated including other markup
+/// languages or simple ASCII text.
+/// @see Documentable
+/// @brief AST Documentation Node
+class Documentation : public Node
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    Documentation() : Node(DocumentationID) {}
+    virtual ~Documentation();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    const std::string& getDoc() const { return doc; }
+    static inline bool classof(const Documentation*) { return true; }
+    static inline bool classof(const Node* N) 
+    { return N->is(DocumentationID); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+  public:
+    void setDoc(const std::string& d) { doc = d; }
+    void addDoc(const std::string& d) { doc += d; }
+
+  /// @}
+  /// @name Data
+  /// @{
+  protected:
+    std::string doc;
+  /// @}
+  friend class AST;
+};
+
 /// This class is an abstract base class in the Abstract Syntax Tree for any 
 /// node type that can be documented. That is, it provides a facility for
 /// attaching a Documentation node. This is the base class of most definitions
@@ -507,7 +554,7 @@
   /// @name Data
   /// @{
   protected:
-    const Type* type; ///< The type of this node.
+    const Type* type; ///< The type of this value.
   /// @}
   friend class AST;
 };

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.cpp (original)
+++ hlvm/trunk/hlvm/AST/Operator.cpp Sat Jul  7 19:01:45 2007
@@ -43,7 +43,7 @@
 {
 }
 
-Value*
+Operator*
 NilaryOperator::getOperand(unsigned idx) const
 {
   hlvmAssert(!"Can't get operands from a NilaryOperator");
@@ -57,7 +57,7 @@
 }
 
 void
-NilaryOperator::setOperand(unsigned opnum, Value* operand)
+NilaryOperator::setOperand(unsigned opnum, Operator* operand)
 {
   hlvmAssert(!"Can't set operands on a NilaryOperator!");
 }
@@ -78,7 +78,7 @@
 {
 }
 
-Value*
+Operator*
 UnaryOperator::getOperand(unsigned idx) const
 {
   assert(idx == 0 && "Operand index out of range");
@@ -92,19 +92,18 @@
 }
 
 void
-UnaryOperator::setOperand(unsigned opnum, Value* operand)
+UnaryOperator::setOperand(unsigned opnum, Operator* operand)
 {
   hlvmAssert(opnum == 0 && "Operand Index out of range for UnaryOperator!");
   operand->setParent(this);
-  op1 = operand;
 }
 
 void 
 UnaryOperator::insertChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
+  hlvmAssert(isa<Operator>(child));
   if (!op1)
-    op1 = cast<Value>(child);
+    op1 = cast<Operator>(child);
   else
     hlvmAssert("UnaryOperator full");
 }
@@ -112,7 +111,7 @@
 void 
 UnaryOperator::removeChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
+  hlvmAssert(isa<Operator>(child));
   if (op1 == child) {
     op1 = 0;
   } else
@@ -123,7 +122,7 @@
 {
 }
 
-Value*
+Operator*
 BinaryOperator::getOperand(unsigned idx) const
 {
   assert(idx <= 1 && "Operand index out of range");
@@ -137,21 +136,20 @@
 }
 
 void
-BinaryOperator::setOperand(unsigned opnum, Value* operand)
+BinaryOperator::setOperand(unsigned opnum, Operator* operand)
 {
   hlvmAssert(opnum <= 1 && "Operand Index out of range for BinaryOperator!");
   operand->setParent(this);
-  ops[opnum] = operand;
 }
 
 void 
 BinaryOperator::insertChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
+  hlvmAssert(isa<Operator>(child));
   if (!ops[0])
-    ops[0] = cast<Value>(child);
+    ops[0] = cast<Operator>(child);
   else if (!ops[1])
-    ops[1] = cast<Value>(child);
+    ops[1] = cast<Operator>(child);
   else
     hlvmAssert(!"BinaryOperator full!");
 }
@@ -159,7 +157,7 @@
 void 
 BinaryOperator::removeChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
+  hlvmAssert(isa<Operator>(child));
   if (ops[0] == child)
     ops[0] = 0;
   else if (ops[1] == child)
@@ -172,7 +170,7 @@
 {
 }
 
-Value*
+Operator*
 TernaryOperator::getOperand(unsigned idx) const
 {
   assert(idx <= 2 && "Operand index out of range");
@@ -186,23 +184,22 @@
 }
 
 void
-TernaryOperator::setOperand(unsigned opnum, Value* operand)
+TernaryOperator::setOperand(unsigned opnum, Operator* operand)
 {
   hlvmAssert(opnum <= 2 && "Operand Index out of range for TernaryOperator!");
   operand->setParent(this);
-  ops[opnum] = operand;
 }
 
 void 
 TernaryOperator::insertChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
+  hlvmAssert(isa<Operator>(child));
   if (!ops[0])
-    ops[0] = cast<Value>(child);
+    ops[0] = cast<Operator>(child);
   else if (!ops[1])
-    ops[1] = cast<Value>(child);
+    ops[1] = cast<Operator>(child);
   else if (!ops[2])
-    ops[2] = cast<Value>(child);
+    ops[2] = cast<Operator>(child);
   else
     hlvmAssert(!"TernaryOperator full!");
 }
@@ -210,7 +207,7 @@
 void 
 TernaryOperator::removeChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
+  hlvmAssert(isa<Operator>(child));
   if (ops[0] == child)
     ops[0] = 0;
   else if (ops[1] == child)
@@ -225,7 +222,7 @@
 {
 }
 
-Value*
+Operator*
 MultiOperator::getOperand(unsigned idx) const
 {
   assert(idx <= ops.size() && "Operand index out of range");
@@ -239,12 +236,11 @@
 }
 
 void
-MultiOperator::setOperand(unsigned opnum, Value* operand)
+MultiOperator::setOperand(unsigned opnum, Operator* operand)
 {
   if (ops.capacity() < opnum + 1)
     ops.resize(opnum+1);
   operand->setParent(this);
-  ops[opnum] = operand;
 }
 
 void 
@@ -252,7 +248,7 @@
 {
   for (const_iterator I = oprnds.begin(), E = oprnds.end(); I != E; ++I )
   {
-    hlvmAssert(isa<Value>(*I));
+    hlvmAssert(isa<Operator>(*I));
     (*I)->setParent(this);
   }
 }
@@ -260,14 +256,14 @@
 void 
 MultiOperator::insertChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
-  ops.push_back(cast<Value>(child));
+  hlvmAssert(isa<Operator>(child));
+  ops.push_back(cast<Operator>(child));
 }
 
 void 
 MultiOperator::removeChild(Node* child)
 {
-  hlvmAssert(isa<Value>(child));
+  hlvmAssert(isa<Operator>(child));
   for (iterator I = begin(), E = end(); I != E; ++I ) {
       if (*I == child) { ops.erase(I); return; }
   }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.h (original)
+++ hlvm/trunk/hlvm/AST/Operator.h Sat Jul  7 19:01:45 2007
@@ -64,7 +64,7 @@
   public:
     /// Get a specific operand of this operator.
     virtual size_t  getNumOperands() const = 0;
-    virtual Value* getOperand(unsigned opnum) const = 0;
+    virtual Operator* getOperand(unsigned opnum) const = 0;
 
     /// Determine if this is a classof some other type.
     static inline bool classof(const Operator*) { return true; }
@@ -74,7 +74,7 @@
   /// @name Mutators
   /// @{
   public:
-    virtual void setOperand(unsigned opnum, Value* oprnd) = 0;
+    virtual void setOperand(unsigned opnum, Operator* oprnd) = 0;
 
   /// @}
   friend class AST;
@@ -96,7 +96,7 @@
   /// @{
   public:
     virtual size_t  getNumOperands() const;
-    virtual Value* getOperand(unsigned opnum) const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const NilaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isNilaryOperator(); }
 
@@ -104,7 +104,7 @@
   /// @name Mutators
   /// @{
   public:
-    virtual void setOperand(unsigned opnum, Value* oprnd);
+    virtual void setOperand(unsigned opnum, Operator* oprnd);
 
   protected:
     virtual void insertChild(Node* child);
@@ -128,9 +128,9 @@
   /// @name Accessors
   /// @{
   public:
-    Value* getOperand() const { return op1; }
+    Operator* getOperand() const { return op1; }
     virtual size_t  getNumOperands() const;
-    virtual Value* getOperand(unsigned opnum) const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const UnaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isUnaryOperator(); }
 
@@ -138,17 +138,17 @@
   /// @name Mutators
   /// @{
   public:
-    virtual void setOperand(unsigned opnum, Value* oprnd);
+    virtual void setOperand(unsigned opnum, Operator* oprnd);
   protected:
     virtual void insertChild(Node* child);
     virtual void removeChild(Node* child);
-    virtual void setOperand(Value* oprnd) { op1 = oprnd; }
+    virtual void setOperand(Operator* oprnd) { op1 = oprnd; }
 
   /// @}
   /// @name Data
   /// @{
   protected:
-    Value* op1;
+    Operator* op1;
   /// @}
   friend class AST;
 };
@@ -161,8 +161,7 @@
   /// @name Constructors
   /// @{
   protected:
-    BinaryOperator(NodeIDs opID) : Operator(opID)
-    { ops[0] = ops[1] = 0; }
+    BinaryOperator(NodeIDs opID) : Operator(opID) { ops[0] = ops[1] = 0; }
     virtual ~BinaryOperator();
 
   /// @}
@@ -170,7 +169,7 @@
   /// @{
   public:
     virtual size_t  getNumOperands() const;
-    virtual Value* getOperand(unsigned opnum) const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const BinaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isBinaryOperator(); }
 
@@ -178,7 +177,7 @@
   /// @name Mutators
   /// @{
   public:
-    virtual void setOperand(unsigned opnum, Value* oprnd);
+    virtual void setOperand(unsigned opnum, Operator* oprnd);
   protected:
     virtual void insertChild(Node* child);
     virtual void removeChild(Node* child);
@@ -187,7 +186,7 @@
   /// @name Data
   /// @{
   protected:
-    Value* ops[2];
+    Operator* ops[2];
   /// @}
   friend class AST;
 };
@@ -209,7 +208,7 @@
   /// @{
   public:
     virtual size_t  getNumOperands() const;
-    virtual Value* getOperand(unsigned opnum) const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const TernaryOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isTernaryOperator(); }
 
@@ -217,7 +216,7 @@
   /// @name Mutators
   /// @{
   public:
-    virtual void setOperand(unsigned opnum, Value* oprnd);
+    virtual void setOperand(unsigned opnum, Operator* oprnd);
   protected:
     virtual void insertChild(Node* child);
     virtual void removeChild(Node* child);
@@ -226,7 +225,7 @@
   /// @name Data
   /// @{
   protected:
-    Value* ops[3];
+    Operator* ops[3];
   /// @}
   friend class AST;
 };
@@ -243,7 +242,7 @@
   /// @name Types
   /// @{
   public:
-    typedef std::vector<Value*> OprndList;
+    typedef std::vector<Operator*> OprndList;
     typedef OprndList::iterator iterator;
     typedef OprndList::const_iterator const_iterator;
 
@@ -259,7 +258,7 @@
   /// @{
   public:
     virtual size_t  getNumOperands() const;
-    virtual Value* getOperand(unsigned opnum) const;
+    virtual Operator* getOperand(unsigned opnum) const;
     static inline bool classof(const MultiOperator*) { return true; }
     static inline bool classof(const Node* N) { return N->isMultiOperator(); }
 
@@ -267,23 +266,23 @@
   /// @name Iterators
   /// @{
   public:
-    iterator       begin()       { return ops.begin(); }
-    const_iterator begin() const { return ops.begin(); }
-    iterator       end  ()       { return ops.end(); }
-    const_iterator end  () const { return ops.end(); }
-    size_t         size () const { return ops.size(); }
-    bool           empty() const { return ops.empty(); }
-    Value*         front()       { return ops.front(); }
-    const Value*   front() const { return ops.front(); }
-    Value*         back()        { return ops.back(); }
-    const Value*   back()  const { return ops.back(); }
+    iterator        begin()       { return ops.begin(); }
+    const_iterator  begin() const { return ops.begin(); }
+    iterator        end  ()       { return ops.end(); }
+    const_iterator  end  () const { return ops.end(); }
+    size_t          size () const { return ops.size(); }
+    bool            empty() const { return ops.empty(); }
+    Operator*       front()       { return ops.front(); }
+    const Operator* front() const { return ops.front(); }
+    Operator*       back()        { return ops.back(); }
+    const Operator* back()  const { return ops.back(); }
 
   /// @}
   /// @name Mutators
   /// @{
   public:
-    virtual void setOperand(unsigned opnum, Value* oprnd);
-    void addOperand(Value* v) { v->setParent(this); }
+    virtual void setOperand(unsigned opnum, Operator* oprnd);
+    void addOperand(Operator* v) { v->setParent(this); }
     void addOperands(const OprndList& new_ops); 
   protected:
     virtual void insertChild(Node* child);

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

==============================================================================
--- hlvm/trunk/hlvm/AST/RuntimeType.h (original)
+++ hlvm/trunk/hlvm/AST/RuntimeType.h Sat Jul  7 19:01:45 2007
@@ -97,7 +97,7 @@
   /// @name Constructors
   /// @{
   protected:
-    StreamType() : RuntimeType(StreamTypeID,"hlvm_stream") {}
+    StreamType() : RuntimeType(StreamTypeID,"stream") {}
     virtual ~StreamType();
   /// @}
   /// @name Accessors
@@ -120,7 +120,7 @@
   /// @name Constructors
   /// @{
   protected:
-    BufferType() : RuntimeType(BufferTypeID,"hlvm_buffer") {}
+    BufferType() : RuntimeType(BufferTypeID,"buffer") {}
     virtual ~BufferType();
   /// @}
   /// @name Accessors

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

==============================================================================
--- hlvm/trunk/hlvm/AST/StringOps.h (original)
+++ hlvm/trunk/hlvm/AST/StringOps.h Sat Jul  7 19:01:45 2007
@@ -43,8 +43,6 @@
   /// @{
   protected:
     StrInsertOp() : TernaryOperator(StrInsertOpID) {}
-
-  public:
     virtual ~StrInsertOp();
 
   /// @}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/SymbolTable.cpp (original)
+++ hlvm/trunk/hlvm/AST/SymbolTable.cpp Sat Jul  7 19:01:45 2007
@@ -105,16 +105,3 @@
   }
   return false;
 }
-
-#ifndef _NDEBUG
-static void DumpNodes(const std::pair<const std::string, const Node*>& I ) {
-  std::cerr << "  '" << I.first << "' = ";
-  I.second->dump();
-  std::cerr << "\n";
-}
-
-void SymbolTable::dump() const {
-  std::cerr << "SymbolTable: ";
-  for_each(map_.begin(), map_.end(), DumpNodes);
-}
-#endif

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

==============================================================================
--- hlvm/trunk/hlvm/AST/SymbolTable.h (original)
+++ hlvm/trunk/hlvm/AST/SymbolTable.h Sat Jul  7 19:01:45 2007
@@ -84,11 +84,6 @@
   /// @brief The number of name/node pairs is returned.
   inline unsigned size() const { return unsigned(map_.size()); }
 
-  /// This function can be used from the debugger to display the
-  /// content of the symbol table while debugging.
-  /// @brief Print out symbol table on stderr
-  void dump() const;
-
 /// @}
 /// @name Iteration
 /// @{

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Type.cpp (original)
+++ hlvm/trunk/hlvm/AST/Type.cpp Sat Jul  7 19:01:45 2007
@@ -58,6 +58,16 @@
   return "any";
 }
 
+StringType::~StringType()
+{
+}
+
+const char*
+StringType::getPrimitiveName() const
+{
+  return "string";
+}
+
 BooleanType::~BooleanType()
 {
 }

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

==============================================================================
--- hlvm/trunk/hlvm/AST/Type.h (original)
+++ hlvm/trunk/hlvm/AST/Type.h Sat Jul  7 19:01:45 2007
@@ -54,6 +54,7 @@
   /// @{
   public:
     const std::string& getName() const { return name; }
+    bool isSized() const { return id != VoidTypeID; }
     virtual const char* getPrimitiveName() const;
     bool isPrimitive() const { return getPrimitiveName() != 0; }
 
@@ -117,6 +118,31 @@
   friend class AST;
 };
 
+/// This class provides an Abstract Syntax Tree node for describing a character
+/// string type. The StringType value is a sequence of UTF-8 encoded characters
+/// with a null terminator.
+/// @brief AST String Type
+class StringType : public Type
+{
+  /// @name Constructors
+  /// @{
+  protected:
+    StringType() : Type(StringTypeID) {}
+    virtual ~StringType();
+
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
+    virtual const char* getPrimitiveName() const;
+
+    // Methods to support type inquiry via is, cast, dyn_cast
+    static inline bool classof(const StringType*) { return true; }
+    static inline bool classof(const Node* T) { return T->is(StringTypeID); }
+  /// @}
+  friend class AST;
+};
+
 /// This class provides an Abstract Syntax Tree node to represent the boolean
 /// type. Booleans have a simple true-or-false value and could be represented by
 /// a single bit.
@@ -241,9 +267,20 @@
       setBits(bits);
       setSigned(sign); 
     }
+    virtual ~IntegerType();
 
+  /// @}
+  /// @name Constants
+  /// @{
   public:
-    virtual ~IntegerType();
+    /// The enum defines various masks and shifts to interpret the bits in
+    /// the Node's flag field.
+    enum FlagsMasks {
+      BitsMask = 0x7FFF, ///< Mask the # of bits, 10 bits
+      SignMask = 0x8000, ///< Mask the sign bit, 1 bit
+      BitsShift = 0,     ///< Bits to shift flags to get # of bits 
+      SignShift = 15     ///< Bits to shift flags to get sign bit
+    };
 
   /// @}
   /// @name Accessors
@@ -254,10 +291,10 @@
     virtual const char* getPrimitiveName() const;
 
     /// @brief Return the number of bits in this integer type
-    int16_t getBits()  const { return int16_t(flags & 0x7FFF); }
+    uint16_t getBits()  const { return uint16_t((flags & BitsMask)>>BitsShift);}
 
     /// @brief Return the signedness of this type
-    bool     isSigned() const { return flags & 0x8000; }
+    bool isSigned() const { return flags & SignMask; }
 
     /// @brief Methods to support type inquiry via isa, cast, dyn_cast
     static inline bool classof(const IntegerType*) { return true; }
@@ -267,14 +304,13 @@
   /// @name Mutators
   /// @{
   public:
-    /// An int
     /// @brief Set the number of bits for this integer type
-    void setBits(int16_t bits) { 
-      flags &= 0x8000; flags |= uint16_t(bits)&0x7FFF; }
+    void setBits(uint16_t bits) { 
+      flags &= ~BitsMask; flags |= (bits << BitsShift) & BitsMask; }
 
     /// @brief Set the signedness of the type
     void setSigned(bool isSigned) { 
-      if (isSigned) flags |= 0x8000; else flags &= 0x7FFF; }
+      if (isSigned) flags |= SignMask; else flags &= ~SignMask; }
 
   /// @}
   friend class AST;
@@ -294,7 +330,6 @@
   /// @{
   protected:
     RangeType() : Type(RangeTypeID), min(0), max(256) {}
-  public:
     virtual ~RangeType();
 
   /// @}
@@ -357,7 +392,6 @@
   /// @{
   protected:
     EnumerationType() : Type(EnumerationTypeID), enumerators() {}
-  public:
     virtual ~EnumerationType();
 
   /// @}
@@ -416,7 +450,6 @@
   protected:
     RealType(NodeIDs id, uint32_t m=52, uint32_t x=11) 
       : Type(id), mantissa(m), exponent(x) {}
-  public:
     virtual ~RealType();
 
   /// @}
@@ -471,7 +504,6 @@
   protected:
     OpaqueType(const std::string& nm) : 
       Type(OpaqueTypeID) { this->setName(nm); }
-  public:
     virtual ~OpaqueType();
 
   /// @}

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

==============================================================================
--- hlvm/trunk/hlvm/AST/URI.h (original)
+++ hlvm/trunk/hlvm/AST/URI.h Sat Jul  7 19:01:45 2007
@@ -56,111 +56,108 @@
 /// @brief HLVM Uniform Resource Identifier Class
 class URI
 {
-/// @name Constructors
-/// @{
-public:
-  /// @brief Parsing constructor builds uri by parsing the string parameter
-  static URI* create( const std::string& xmlStr, Pool* p);
+  /// @name Constructors
+  /// @{
+  protected:
+    // This is an abstract class, don't allow construction or copying
+    URI () {}
+    URI ( const URI & that ) {}
+    /// @brief Parsing constructor builds uri by parsing the string parameter
+    static URI* create( const std::string& uriStr, Pool* p);
+    virtual ~URI ( void );
 
-  virtual ~URI ( void );
+  /// @}
+  /// @name Operators
+  /// @{
+  public:
+    /// @brief Equality Operator.
+    bool operator == ( const URI & that ) const;
 
-protected:
-  // This is an abstract class, don't allow instantiation
-  URI () {}
-  URI ( const URI & that ) {}
+    /// @brief Assignment Operator.
+    URI & operator = ( const URI & that );
 
-/// @}
-/// @name Operators
-/// @{
-public:
-  /// @brief Equality Operator.
-  bool operator == ( const URI & that ) const;
+  /// @}
+  /// @name Accessors
+  /// @{
+  public:
 
-  /// @brief Assignment Operator.
-  URI & operator = ( const URI & that );
+    /// @brief Return the URI as a string (escaped). Caller must
+    /// free the returned string.
+    virtual std::string as_string( void ) const = 0;
 
-/// @}
-/// @name Accessors
-/// @{
-public:
+    /// @brief Set a string to the value of the URI with escapes.
+    virtual void get_string( std::string& str_to_fill ) const = 0;
 
-  /// @brief Return the URI as a string (escaped). Caller must
-  /// free the returned string.
-  virtual std::string as_string( void ) const = 0;
+    /// @brief Return the scheme of the URI
+    virtual const char* const scheme() const = 0;
 
-  /// @brief Set a string to the value of the URI with escapes.
-  virtual void get_string( std::string& str_to_fill ) const = 0;
+    /// @brief Return the password part of the URI
+    virtual const char* const password() const = 0;
 
-  /// @brief Return the scheme of the URI
-  virtual const char* const scheme() const = 0;
+    /// @brief Return the user part of the URI
+    virtual const char* const user() const = 0;
 
-  /// @brief Return the password part of the URI
-  virtual const char* const password() const = 0;
+    /// @brief Return the host name from the URI
+    virtual const char* const hostname() const = 0;
 
-  /// @brief Return the user part of the URI
-  virtual const char* const user() const = 0;
+    /// @brief Return the combined [user[:password]\@host:port/ part of the URI
+    virtual const char* const hostinfo() const = 0;
 
-  /// @brief Return the host name from the URI
-  virtual const char* const hostname() const = 0;
+    /// @brief Return the port part of the URI
+    virtual uint32_t port() const = 0;
 
-  /// @brief Return the combined [user[:password]\@host:port/ part of the URI
-  virtual const char* const hostinfo() const = 0;
+    /// @brief Return the path part of the URI
+    virtual const char* const path() const = 0;
 
-  /// @brief Return the port part of the URI
-  virtual uint32_t port() const = 0;
+    /// @brief Return the query part of the URI
+    virtual const char* const query() const = 0;
 
-  /// @brief Return the path part of the URI
-  virtual const char* const path() const = 0;
+    /// @brief Return the fragment identifier part of the URI
+    virtual const char* const fragment() const = 0;
 
-  /// @brief Return the query part of the URI
-  virtual const char* const query() const = 0;
+    /// @brief Determines if two URIs are equal
+    virtual bool equals( const URI& that ) const = 0;
 
-  /// @brief Return the fragment identifier part of the URI
-  virtual const char* const fragment() const = 0;
+    virtual std::string resolveToFile() const = 0;
+  /// @}
+  /// @name Mutators
+  /// @{
+  public:
+    /// @brief Assignment of one URI to another
+    virtual URI& assign( const URI& that ) = 0;
 
-  /// @brief Determines if two URIs are equal
-  virtual bool equals( const URI& that ) const = 0;
+    /// @brief Assignment of an std::string to a URI. 
+    virtual void assign( const std::string& that ) = 0;
 
-  virtual std::string resolveToFile() const = 0;
-/// @}
-/// @name Mutators
-/// @{
-public:
-  /// @brief Assignment of one URI to another
-  virtual URI& assign( const URI& that ) = 0;
+    /// @brief Clears the URI, releases memory.
+    virtual void clear( void ) = 0;
 
-  /// @brief Assignment of an std::string to a URI. 
-  virtual void assign( const std::string& that ) = 0;
+    /// @brief Sets the scheme
+    virtual void scheme( const char* const scheme ) = 0;
 
-  /// @brief Clears the URI, releases memory.
-  virtual void clear( void ) = 0;
+    /// @brief Set the opaque part of the URI
+    virtual void opaque( const char* const opaque ) = 0;
 
-  /// @brief Sets the scheme
-  virtual void scheme( const char* const scheme ) = 0;
+    /// @brief Sets the authority.
+    virtual void authority( const char* const authority ) = 0;
 
-  /// @brief Set the opaque part of the URI
-  virtual void opaque( const char* const opaque ) = 0;
+    /// @brief Sets the user.
+    virtual void user( const char* const user ) = 0;
 
-  /// @brief Sets the authority.
-  virtual void authority( const char* const authority ) = 0;
+    /// @brief Sets the server.
+    virtual void server( const char* const server ) = 0;
 
-  /// @brief Sets the user.
-  virtual void user( const char* const user ) = 0;
+    /// @brief Sets the port.
+    virtual void port( uint32_t portnum ) = 0;
 
-  /// @brief Sets the server.
-  virtual void server( const char* const server ) = 0;
-
-  /// @brief Sets the port.
-  virtual void port( uint32_t portnum ) = 0;
-
-/// @}
-/// @name Functions
-/// @{
-public:
-  static uint32_t port_for_scheme( const char* scheme );
-
-/// @}
+  /// @}
+  /// @name Functions
+  /// @{
+  public:
+    static uint32_t port_for_scheme( const char* scheme );
+  /// @}
 
+  friend class AST;
 };
 
 inline URI & 

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

==============================================================================
--- hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp (original)
+++ hlvm/trunk/hlvm/CodeGen/LLVMGenerator.cpp Sat Jul  7 19:01:45 2007
@@ -108,6 +108,7 @@
   llvm::Function*     hlvm_stream_read;   ///< Function for stream_read
   llvm::Function*     hlvm_stream_write_buffer; ///< Write buffer to stream
   llvm::Function*     hlvm_stream_write_text;   ///< Write text to stream
+  llvm::Function*     hlvm_stream_write_string; ///< Write string to stream
   llvm::Function*     hlvm_stream_close;  ///< Function for stream_close
   llvm::FunctionType* hlvm_program_signature; ///< The llvm type for programs
 
@@ -123,6 +124,7 @@
       hlvm_stream(0),
       hlvm_stream_open(0), hlvm_stream_read(0),
       hlvm_stream_write_buffer(0), hlvm_stream_write_text(0), 
+      hlvm_stream_write_string(0),
       hlvm_stream_close(0), hlvm_program_signature(0)
       { }
     ~LLVMGeneratorPass() { }
@@ -137,6 +139,7 @@
   inline llvm::Value* getInteger(llvm::Value* op);
   inline llvm::Value* toBoolean(llvm::Value* op);
   inline llvm::Value* ptr2Value(llvm::Value* op);
+  inline llvm::Value* coerce(llvm::Value* op);
 
   /// Accessors for HLVM Runtime Library things
   inline llvm::Type*         get_hlvm_size();
@@ -152,6 +155,7 @@
   inline llvm::Function*     get_hlvm_stream_read();
   inline llvm::Function*     get_hlvm_stream_write_buffer();
   inline llvm::Function*     get_hlvm_stream_write_text();
+  inline llvm::Function*     get_hlvm_stream_write_string();
   inline llvm::Function*     get_hlvm_stream_close();
   inline llvm::FunctionType* get_hlvm_program_signature();
 
@@ -161,7 +165,7 @@
 
   void genProgramLinkage();
 
-  virtual void handleInitialize();
+  virtual void handleInitialize(AST* tree);
   virtual void handle(Node* n,Pass::TraversalKinds mode);
   virtual void handleTerminate();
 
@@ -296,7 +300,7 @@
   if (!hlvm_stream_open) {
     llvm::Type* result = get_hlvm_stream();
     std::vector<const llvm::Type*> arg_types;
-    arg_types.push_back(get_hlvm_text());
+    arg_types.push_back(llvm::PointerType::get(llvm::Type::SByteTy));
     llvm::FunctionType* FT = llvm::FunctionType::get(result,arg_types,false);
     lmod->addTypeName("hlvm_stream_open_signature",FT);
     hlvm_stream_open = 
@@ -342,6 +346,23 @@
 }
 
 llvm::Function*
+LLVMGeneratorPass::get_hlvm_stream_write_string()
+{
+  if (!hlvm_stream_write_string) {
+    llvm::Type* result = get_hlvm_size();
+    std::vector<const llvm::Type*> arg_types;
+    arg_types.push_back(get_hlvm_stream());
+    arg_types.push_back(llvm::PointerType::get(llvm::Type::SByteTy));
+    llvm::FunctionType* FT = llvm::FunctionType::get(result,arg_types,false);
+    lmod->addTypeName("hlvm_stream_write_string_signature",FT);
+    hlvm_stream_write_string = 
+      new llvm::Function(FT, llvm::GlobalValue::ExternalLinkage,
+      "hlvm_stream_write_string", lmod);
+  }
+  return hlvm_stream_write_string;
+}
+
+llvm::Function*
 LLVMGeneratorPass::get_hlvm_stream_write_text()
 {
   if (!hlvm_stream_write_text) {
@@ -428,6 +449,9 @@
     case AnyTypeID:
       hlvmNotImplemented("Any Type");
       break;
+    case StringTypeID:              
+      result = llvm::PointerType::get(llvm::Type::SByteTy);
+      break;
     case IntegerTypeID:
       hlvmNotImplemented("arbitrary precision integer");
       break;
@@ -509,8 +533,7 @@
 llvm::Constant*
 LLVMGeneratorPass::getConstant(const hlvm::Constant* C)
 {
-  if (C == 0)
-    return 0;
+  hlvmAssert(C!=0);
 
   // First, lets see if its cached already
   ConstantDictionary::iterator I = consts.find(const_cast<hlvm::Constant*>(C));
@@ -522,33 +545,39 @@
   llvm::Constant* result = 0;
   switch (C->getID()) 
   {
-    case ConstantIntegerID:
+    case ConstantBooleanID:
     {
-      const ConstantInteger* CI = llvm::cast<const ConstantInteger>(C);
-      if (llvm::cast<IntegerType>(hType)->isSigned())
-        result = llvm::ConstantSInt::get(lType,CI->getValue());
-      else
-        result = llvm::ConstantUInt::get(lType,CI->getValue(0));
+      const ConstantBoolean* CI = llvm::cast<const ConstantBoolean>(C);
+      result = llvm::ConstantBool::get(CI->getValue());
       break;
     }
-    case ConstantRealID:
+    case ConstantIntegerID:
     {
-      result = llvm::ConstantFP::get(lType,
-        llvm::cast<ConstantReal>(C)->getValue());
+      const ConstantInteger* CI = llvm::cast<const ConstantInteger>(C);
+      const IntegerType* iType = llvm::cast<IntegerType>(hType);
+      if (iType->isSigned()) {
+        int64_t val = strtoll(CI->getValue().c_str(),0,CI->getBase());
+        result = llvm::ConstantSInt::get(lType,val);
+      }
+      else {
+        uint64_t val = strtoull(CI->getValue().c_str(),0,CI->getBase());
+        result = llvm::ConstantUInt::get(lType,val);
+      }
       break;
     }
-    case ConstantTextID:
+    case ConstantRealID:
     {
-      llvm::Constant* CA = llvm::ConstantArray::get(
-        llvm::cast<ConstantText>(C)->getValue(),true);
-      llvm::GlobalVariable* GV = new llvm::GlobalVariable(
-        CA->getType(), true, llvm::GlobalValue::InternalLinkage, CA, "", lmod);
-      result = llvm::ConstantExpr::getPtrPtrFromArrayPtr(GV);
+      const ConstantReal* CR = llvm::cast<const ConstantReal>(C);
+      double  val = strtod(CR->getValue().c_str(),0);
+      result = llvm::ConstantFP::get(lType, val);
       break;
     }
-    case ConstantZeroID:
+    case ConstantStringID:
     {
-      result = llvm::Constant::getNullValue(lType);
+      const ConstantString* CT = llvm::cast<ConstantString>(C);
+      llvm::Constant* CA = llvm::ConstantArray::get(CT->getValue(), true);
+      result = new llvm::GlobalVariable(CA->getType(), true, 
+          llvm::GlobalValue::InternalLinkage, CA, C->getName(), lmod);
       break;
     }
     default:
@@ -627,6 +656,12 @@
   lmod->addTypeName(t->getName(), getType(t));
 }
 
+template<> void 
+LLVMGeneratorPass::gen<StringType>(StringType* s)
+{
+  lmod->addTypeName(s->getName(), getType(s));
+}
+
 template<> void
 LLVMGeneratorPass::gen<BooleanType>(BooleanType* t)
 {
@@ -715,31 +750,24 @@
 LLVMGeneratorPass::gen<ConstantInteger>(ConstantInteger* i)
 {
   llvm::Constant* C = getConstant(i);
-  lops.push_back(C);
 }
 
 template<> void
-LLVMGeneratorPass::gen<ConstantReal>(ConstantReal* r)
+LLVMGeneratorPass::gen<ConstantBoolean>(ConstantBoolean* b)
 {
-  llvm::Constant* C = getConstant(r);
-  lops.push_back(C);
+  getConstant(b);
 }
 
 template<> void
-LLVMGeneratorPass::gen<ConstantZero>(ConstantZero* z)
+LLVMGeneratorPass::gen<ConstantReal>(ConstantReal* r)
 {
-  llvm::Constant* C = getConstant(z);
-  lops.push_back(C);
+  getConstant(r);
 }
 
 template<> void
-LLVMGeneratorPass::gen<ConstantText>(ConstantText* t)
+LLVMGeneratorPass::gen<ConstantString>(ConstantString* t)
 {
-  llvm::Constant* C = getConstant(t);
-  std::vector<llvm::Value*> args;
-  args.push_back(C);
-  llvm::CallInst* CI = new llvm::CallInst(get_hlvm_text_create(),args,"",lblk);
-  lops.push_back(CI);
+  getConstant(t);
 }
 
 template<> void
@@ -748,15 +776,18 @@
   assert(lblk  != 0 && "Not in block context");
   // emit a stack variable
   const llvm::Type* elemType = getType(av->getType());
-  llvm::Value* init = lops.back(); lops.pop_back();
   llvm::Value* alloca = new llvm::AllocaInst(
       /*Ty=*/ elemType,
       /*ArraySize=*/ llvm::ConstantUInt::get(llvm::Type::UIntTy,1),
       /*Name=*/ av->getName(),
       /*InsertAtEnd=*/ lblk
   );
-  // FIXME: Handle initializer
-  llvm::Constant* C = getConstant(av->getInitializer());
+  llvm::Constant* C = 0;
+  if (av->hasInitializer())
+    C = getConstant(av->getInitializer());
+  else
+    C = llvm::Constant::getNullValue(elemType);
+
   if (C) {
     const llvm::Type* CType = C->getType();
     if (CType != elemType) {
@@ -792,7 +823,11 @@
 template<> void
 LLVMGeneratorPass::gen<Variable>(Variable* v)
 {
-  llvm::Constant* Initializer = getConstant(v->getInitializer());
+  llvm::Constant* Initializer = 0;
+  if (v->hasInitializer())
+    Initializer = getConstant(v->getInitializer());
+  else
+    Initializer = llvm::Constant::getNullValue(getType(v->getType()));
   llvm::Value* gv = new llvm::GlobalVariable(
     /*Ty=*/ getType(v->getType()),
     /*isConstant=*/ false,
@@ -992,7 +1027,7 @@
   op1 = ptr2Value(op1);
   op2 = ptr2Value(op2);
   llvm::BinaryOperator* Xor = llvm::BinaryOperator::create(
-    llvm::Instruction::Xor, op1, op2, "bor", lblk);
+    llvm::Instruction::Xor, op1, op2, "bxor", lblk);
   lops.push_back(Xor);
 }
 
@@ -1005,8 +1040,8 @@
   op1 = ptr2Value(op1);
   op2 = ptr2Value(op2);
   llvm::BinaryOperator* bor = llvm::BinaryOperator::create(
-    llvm::Instruction::Or, op1, op2, "bor", lblk);
-  llvm::BinaryOperator* nor = llvm::BinaryOperator::createNot(bor,"bor",lblk);
+    llvm::Instruction::Or, op1, op2, "bnor", lblk);
+  llvm::BinaryOperator* nor = llvm::BinaryOperator::createNot(bor,"bnor",lblk);
   lops.push_back(nor);
 }
 
@@ -1235,6 +1270,14 @@
 }
 
 template<> void
+LLVMGeneratorPass::gen<ConstantReferenceOp>(ConstantReferenceOp* r)
+{
+  hlvm::Constant* referent = const_cast<hlvm::Constant*>(r->getReferent());
+  llvm::Constant* C = getConstant(referent);
+  hlvmAssert(C && "Can't generate constant?");
+  lops.push_back(C);
+}
+template<> void
 LLVMGeneratorPass::gen<IndexOp>(IndexOp* r)
 {
   hlvmAssert(lops.size() >= 2 && "Too few operands for IndexOp");
@@ -1244,8 +1287,26 @@
 LLVMGeneratorPass::gen<OpenOp>(OpenOp* o)
 {
   hlvmAssert(lops.size() >= 1 && "Too few operands for OpenOp");
+  llvm::Value* strm = lops.back(); lops.pop_back();
   std::vector<llvm::Value*> args;
-  args.push_back(lops.back()); lops.pop_back();
+  if (const llvm::PointerType* PT = 
+      llvm::dyn_cast<llvm::PointerType>(strm->getType())) {
+    const llvm::Type* Ty = PT->getElementType();
+    if (Ty == llvm::Type::SByteTy) {
+      args.push_back(strm);
+    } else if (llvm::isa<llvm::ArrayType>(Ty) && 
+               llvm::cast<llvm::ArrayType>(Ty)->getElementType() == 
+               llvm::Type::SByteTy) {
+      std::vector<llvm::Value*> indices;
+      indices.push_back(llvm::Constant::getNullValue(llvm::Type::UIntTy));
+      indices.push_back(llvm::Constant::getNullValue(llvm::Type::UIntTy));
+      llvm::GetElementPtrInst* gep = 
+        new llvm::GetElementPtrInst(strm,indices,"",lblk);
+      args.push_back(gep);
+    } else
+      hlvmAssert(!"Array element type is not SByteTy");
+  } else
+    hlvmAssert(!"OpenOp parameter is not a pointer");
   llvm::CallInst* ci = new 
     llvm::CallInst(get_hlvm_stream_open(), args, "", lblk);
   lops.push_back(ci);
@@ -1255,15 +1316,20 @@
 LLVMGeneratorPass::gen<WriteOp>(WriteOp* o)
 {
   hlvmAssert(lops.size() >= 2 && "Too few operands for WriteOp");
-  std::vector<llvm::Value*> args;
   llvm::Value* arg2 = lops.back(); lops.pop_back();
   llvm::Value* strm = lops.back(); lops.pop_back();
+  std::vector<llvm::Value*> args;
   args.push_back(strm);
   args.push_back(arg2);
+  if (llvm::isa<llvm::PointerType>(arg2->getType()))
+    if (llvm::cast<llvm::PointerType>(arg2->getType())->getElementType() ==
+        llvm::Type::SByteTy)
+      lops.push_back(
+        new llvm::CallInst(get_hlvm_stream_write_string(), args, "", lblk));
   if (arg2->getType() == get_hlvm_text())
     lops.push_back(
       new llvm::CallInst(get_hlvm_stream_write_text(), args, "", lblk));
-  else
+  else if (arg2->getType() == get_hlvm_buffer())
     lops.push_back(
       new llvm::CallInst(get_hlvm_stream_write_buffer(), args, "",lblk));
 }
@@ -1392,7 +1458,7 @@
 }
 
 void
-LLVMGeneratorPass::handleInitialize()
+LLVMGeneratorPass::handleInitialize(AST* tree)
 {
   // Nothing to do
 }
@@ -1418,6 +1484,7 @@
     {
     case AliasTypeID:             gen(llvm::cast<AliasType>(n)); break;
     case AnyTypeID:               gen(llvm::cast<AnyType>(n)); break;
+    case StringTypeID:            gen(llvm::cast<StringType>(n)); break;
     case BooleanTypeID:           gen(llvm::cast<BooleanType>(n)); break;
     case CharacterTypeID:         gen(llvm::cast<CharacterType>(n)); break;
     case IntegerTypeID:           gen(llvm::cast<IntegerType>(n)); break;
@@ -1432,10 +1499,10 @@
     case StructureTypeID:         gen(llvm::cast<StructureType>(n)); break;
     case SignatureTypeID:         gen(llvm::cast<SignatureType>(n)); break;
     case OpaqueTypeID:            gen(llvm::cast<hlvm::OpaqueType>(n)); break;
-    case ConstantZeroID:          gen(llvm::cast<ConstantZero>(n));break;
+    case ConstantBooleanID:       gen(llvm::cast<ConstantBoolean>(n));break;
     case ConstantIntegerID:       gen(llvm::cast<ConstantInteger>(n));break;
     case ConstantRealID:          gen(llvm::cast<ConstantReal>(n));break;
-    case ConstantTextID:          gen(llvm::cast<ConstantText>(n));break;
+    case ConstantStringID:        gen(llvm::cast<ConstantString>(n));break;
     case VariableID:              gen(llvm::cast<Variable>(n)); break;
     case NegateOpID:              gen(llvm::cast<NegateOp>(n)); break;
     case ComplementOpID:          gen(llvm::cast<ComplementOp>(n)); break;
@@ -1473,6 +1540,8 @@
     case LoadOpID:                gen(llvm::cast<LoadOp>(n)); break;
     case StoreOpID:               gen(llvm::cast<StoreOp>(n)); break;
     case ReferenceOpID:           gen(llvm::cast<ReferenceOp>(n)); break;
+    case ConstantReferenceOpID:   gen(llvm::cast<ConstantReferenceOp>(n)); 
+                                  break;
     case AutoVarOpID:             gen(llvm::cast<AutoVarOp>(n)); break;
     case OpenOpID:                gen(llvm::cast<OpenOp>(n)); break;
     case CloseOpID:               gen(llvm::cast<CloseOp>(n)); break;

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

==============================================================================
--- hlvm/trunk/hlvm/Pass/Pass.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Pass.cpp Sat Jul  7 19:01:45 2007
@@ -44,7 +44,8 @@
 public:
   PassManagerImpl() : PassManager(), pre(), post() {}
   void addPass(Pass* p);
-  void runOn(AST* tree);
+  virtual void runOn(AST* tree);
+  virtual void runOn(AST* tree, Node* startAt);
 
   inline void runIfInterested(Pass* p, Node* n, Pass::TraversalKinds m);
   inline void runPreOrder(Node* n);
@@ -123,7 +124,9 @@
   runPreOrder(op);
   size_t limit = op->getNumOperands();
   for (size_t i = 0; i < limit; ++i) {
-    runOn(op->getOperand(i));
+    // Skip non-operator operands as they've been handled elsewhere
+    if (isa<Operator>(op))
+      runOn(op->getOperand(i));
   }
   runPostOrder(op);
 }
@@ -167,6 +170,12 @@
     runPreOrder(const_cast<Node*>(TI->second));
     runPostOrder(const_cast<Node*>(TI->second));
   }
+  for (Bundle::constant_iterator CI = b->const_begin(), CE = b->const_end();
+      CI != CE; ++CI)
+  {
+    runPreOrder(const_cast<Node*>(CI->second));
+    runPostOrder(const_cast<Node*>(CI->second));
+  }
   for (Bundle::var_iterator VI = b->var_begin(), VE = b->var_end(); 
        VI != VE; ++VI) {
     runPreOrder(const_cast<Node*>(VI->second));
@@ -200,6 +209,28 @@
   while (PI != PE) { (*PI)->handleTerminate(); ++PI; }
 }
 
+void 
+PassManagerImpl::runOn(AST* tree, Node* startAt)
+{
+  // Check to make sure startAt is in tree
+  hlvmAssert(tree != 0 && "Can't run passes on null tree");
+  hlvmAssert(startAt != 0 && "Can't run passes from null start");
+  Node* parent = startAt;
+  while (parent->getParent() != 0) parent = parent->getParent();
+  hlvmAssert(parent == tree && "Can't run passes on node that isn't in tree");
+
+  if (isa<Bundle>(startAt))
+    runOn(cast<Bundle>(startAt));
+  else if (isa<Block>(startAt))
+    runOn(cast<Block>(startAt));
+  else if (isa<Operator>(startAt))
+    runOn(cast<Operator>(startAt));
+  else if (isa<Constant>(startAt))
+    runOn(cast<Constant>(startAt));
+  else if (isa<Value>(startAt))
+    runOn(cast<Value>(startAt));
+}
+
 } // anonymous namespace
 
 Pass::~Pass()

Modified: hlvm/trunk/hlvm/Pass/Pass.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Pass/Pass.h?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Pass/Pass.h (original)
+++ hlvm/trunk/hlvm/Pass/Pass.h Sat Jul  7 19:01:45 2007
@@ -126,6 +126,7 @@
     static  PassManager* create();
     virtual void addPass(Pass* p) = 0;
     virtual void runOn(AST* tree) = 0;
+    virtual void runOn(AST* tree, Node* startAt) = 0;
 };
 
 bool validate(AST* tree);

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

==============================================================================
--- hlvm/trunk/hlvm/Pass/Validate.cpp (original)
+++ hlvm/trunk/hlvm/Pass/Validate.cpp Sat Jul  7 19:01:45 2007
@@ -54,13 +54,14 @@
     virtual void handleInitialize(AST* tree) { ast = tree; }
     virtual void handle(Node* b,Pass::TraversalKinds k);
     inline void error(Node*n, const char* msg);
-    inline bool checkNonPointer(Value*n);
+    inline void warning(Node*n, const char* msg);
     inline bool checkNode(Node*);
     inline bool checkType(Type*,NodeIDs id);
     inline bool checkValue(Value*,NodeIDs id);
     inline bool checkConstant(Constant*,NodeIDs id);
     inline bool checkOperator(
         Operator*,NodeIDs id,unsigned numOps, bool exact = true);
+    inline bool checkTerminator(Operator* op);
     inline bool checkUniformContainer(UniformContainerType* T, NodeIDs id);
     inline bool checkDisparateContainer(DisparateContainerType* T, NodeIDs id);
     inline bool checkLinkageItem(LinkageItem* LI, NodeIDs id);
@@ -69,19 +70,38 @@
     inline void validate(NodeClass* C);
 };
 
-bool
-ValidateImpl::checkNonPointer(Value* n)
+void 
+ValidateImpl::warning(Node* n, const char* msg)
 {
-  const Type* Ty = n->getType();
-  if (Ty) {
-    if (isa<PointerType>(Ty)) {
-      error(n,"Expecting a non-pointer value");
-      return false;
-    }
+  if (n) {
+    const Locator* loc = n->getLocator();
+    if (loc) {
+      std::string location;
+      loc->getLocation(location);
+      std::cerr << location << ": ";
+    } else
+      std::cerr << "Unknown Location: ";
   }
-  return true;
+  std::cerr << msg << "\n";
 }
 
+void 
+ValidateImpl::error(Node* n, const char* msg)
+{
+  if (n) {
+    const Locator* loc = n->getLocator();
+    if (loc) {
+      std::string location;
+      loc->getLocation(location);
+      std::cerr << location << ": ";
+    } else
+      std::cerr << "Unknown Location: ";
+  }
+  std::cerr << msg << "\n";
+  passed_ = false;
+}
+
+
 bool
 ValidateImpl::checkNode(Node* n)
 {
@@ -154,6 +174,21 @@
   return result;
 }
 
+bool
+ValidateImpl::checkTerminator(Operator *n)
+{
+  if (Block* b = llvm::dyn_cast<Block>(n->getParent())) {
+    if (b->back() != n) {
+      error(n,"Terminating operator is not last operator in block");
+      return false;
+    }
+  } else {
+    error(n,"Operator not in block!");
+    return false;
+  }
+  return true;
+}
+
 bool 
 ValidateImpl::checkUniformContainer(UniformContainerType* n, NodeIDs id)
 {
@@ -207,23 +242,6 @@
   return result;
 }
 
-void 
-ValidateImpl::error(Node* n, const char* msg)
-{
-  if (n) {
-    const Locator* loc = n->getLocator();
-    if (loc) {
-      std::string msg;
-      loc->getLocation(msg);
-      std::cerr << msg << " ";
-    } else
-      std::cerr << "Unknown Location: ";
-    std::cerr << "Node(" << n << "): ";
-  }
-  std::cerr << msg << "\n";
-  passed_ = false;
-}
-
 template<> inline void
 ValidateImpl::validate(VoidType* n)
 {
@@ -415,60 +433,98 @@
 template<> inline void
 ValidateImpl::validate(ReturnOp* n)
 {
-  checkOperator(n,ReturnOpID,1);
+  if (checkOperator(n,ReturnOpID,1))
+    checkTerminator(n);
 }
 
 template<> inline void
 ValidateImpl::validate(BreakOp* n)
 {
-  checkOperator(n,BreakOpID,0);
+  if (checkOperator(n,BreakOpID,0))
+    checkTerminator(n);
 }
 
 template<> inline void
 ValidateImpl::validate(ContinueOp* n)
 {
-  checkOperator(n,ContinueOpID,0);
+  if (checkOperator(n,ContinueOpID,0))
+    checkTerminator(n);
 }
 
 template<> inline void
 ValidateImpl::validate(SelectOp* n)
 {
-  checkOperator(n,SelectOpID,3);
+  if (checkOperator(n,SelectOpID,3)) {
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!isa<BooleanType>(Ty))
+      error(n,"SelectOp expects first operand to be type boolean");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(LoopOp* n)
 {
-  checkOperator(n,LoopOpID,3);
+  if (checkOperator(n,LoopOpID,3)) {
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!isa<BooleanType>(Ty) && !isa<VoidType>(Ty))
+      error(n,"LoopOp expects first operand to be type boolean or void");
+    Ty = n->getOperand(2)->getType();
+    if (!isa<BooleanType>(Ty) && !isa<VoidType>(Ty))
+      error(n,"LoopOp expects third operand to be type boolean or void");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(SwitchOp* n)
 {
-  checkOperator(n,SwitchOpID,2,false);
+  if (checkOperator(n,SwitchOpID,2,false)) {
+    if (n->getNumOperands() == 2)
+      warning(n,"Why not just use a SelectOp?");
+    if (n->getNumOperands() % 2 != 0)
+      error(n,"SwitchOp requires even number of operands");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(AllocateOp* n)
 {
-  checkOperator(n,AllocateOpID,2);
+  if (checkOperator(n,AllocateOpID,2)) {
+    if (const PointerType* PT = llvm::dyn_cast<PointerType>(n->getType())) {
+      if (const Type* Ty = PT->getElementType()) {
+        if (!Ty->isSized())
+          error(n,"Can't allocate an unsized type");
+      } else 
+        error(n,"AllocateOp's pointer type has no element type!");
+    } else
+      error(n,"AllocateOp's type must be a pointer type");
+    if (!llvm::isa<IntegerType>(n->getType())) 
+      error(n,"AllocateOp's operand must be of integer type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(DeallocateOp* n)
 {
-  checkOperator(n,DeallocateOpID,1);
+  if (checkOperator(n,DeallocateOpID,1)) {
+    if (const PointerType* PT = llvm::dyn_cast<PointerType>(n->getType())) {
+      if (const Type* Ty = PT->getElementType()) {
+        if (!Ty->isSized())
+          error(n,"Can't deallocate an unsized type");
+      } else 
+        error(n,"DeallocateOp's pointer type has no element type!");
+    } else
+      error(n,"DeallocateOp expects its first operand to be a pointer type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(LoadOp* n)
 {
   if (checkOperator(n,LoadOpID,1)) {
-    Value* oprnd = n->getOperand(0);
-    if (!isa<PointerType>(oprnd->getType()))
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!isa<PointerType>(Ty))
       error(n,"LoadOp expects a pointer type operand");
-    else if (n->getType() != 
-             cast<PointerType>(oprnd->getType())->getElementType())
+    else if (n->getType() != cast<PointerType>(Ty)->getElementType())
       error(n,"LoadOp type and operand type do not agree");
   }
 }
@@ -477,12 +533,11 @@
 ValidateImpl::validate(StoreOp* n)
 {
   if (checkOperator(n,StoreOpID,2)) {
-    Value* op1 = n->getOperand(0);
-    Value* op2 = n->getOperand(1);
-    if (!isa<PointerType>(op1->getType()))
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!isa<PointerType>(Ty1))
       error(n,"StoreOp expects first operand to be pointer type");
-    else if (cast<PointerType>(op1->getType())->getElementType() != 
-             op2->getType())
+    else if (cast<PointerType>(Ty1)->getElementType() != Ty2)
       error(n,"StoreOp operands do not agree in type");
   }
 }
@@ -490,148 +545,250 @@
 template<> inline void
 ValidateImpl::validate(AutoVarOp* n)
 {
-  if (checkOperator(n,AutoVarOpID,0,false))
-    ;
+  if (checkOperator(n,AutoVarOpID,0,false)) {
+    if (n->hasInitializer()) {
+      if (n->getType() != n->getInitializer()->getType()) {
+        error(n,"AutoVarOp's type does not agree with type of its Initializer");
+      } 
+    }
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(NegateOp* n)
 {
-  if (checkOperator(n,NegateOpID,1))
-    ;
+  if (checkOperator(n,NegateOpID,1)) {
+    const Type* Ty = n->getType();
+    if (!Ty->isNumericType())
+      error(n,"You can only negate objects of numeric type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(ComplementOp* n)
 {
-  if (checkOperator(n,ComplementOpID,1))
-    checkNonPointer(n->getOperand(0));
+  if (checkOperator(n,ComplementOpID,1)) {
+    const Type* Ty = n->getType();
+    if (!Ty->isIntegralType())
+      error(n,"You can only complement objects of integral type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(PreIncrOp* n)
 {
-  if (checkOperator(n,PreIncrOpID,1))
-    ;
+  if (checkOperator(n,PreIncrOpID,1)) {
+    if (ReferenceOp* oprnd = llvm::dyn_cast<ReferenceOp>(n->getOperand(0))) {
+      const Value* V = oprnd->getReferent();
+      if (V && (isa<AutoVarOp>(V) || isa<Variable>(V))) {
+        if (!V->getType()->isNumericType())
+          error(n,"Target of PostIncrOp is not numeric type");
+      } else
+        ; // Handled elsewhere
+    } else 
+      error(n,"Operand of PostIncrOp must be a ReferenceOp");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(PostIncrOp* n)
 {
-  if (checkOperator(n,PostIncrOpID,1))
-    ;
+  if (checkOperator(n,PostIncrOpID,1)) {
+    if (ReferenceOp* oprnd = llvm::dyn_cast<ReferenceOp>(n->getOperand(0))) {
+      const Value* V = oprnd->getReferent();
+      if (V && (isa<AutoVarOp>(V) || isa<Variable>(V))) {
+        if (!V->getType()->isNumericType())
+          error(n,"Target of PostIncrOp is not numeric type");
+      } else
+        ; // Handled elsewhere
+    } else 
+      error(n,"Operand of PostIncrOp must be a ReferenceOp");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(PreDecrOp* n)
 {
-  if (checkOperator(n,PreDecrOpID,1))
-    ;
+  if (checkOperator(n,PreDecrOpID,1)){
+    if (ReferenceOp* oprnd = llvm::dyn_cast<ReferenceOp>(n->getOperand(0))) {
+      const Value* V = oprnd->getReferent();
+      if (V && (isa<AutoVarOp>(V) || isa<Variable>(V))) {
+        if (!V->getType()->isNumericType())
+          error(n,"Target of PreDecrOp is not numeric type");
+      } else
+        ; // Handled elsewhere
+    } else 
+      error(n,"Operand of PreDecrOp must be a ReferenceOp");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(PostDecrOp* n)
 {
-  if (checkOperator(n,PostDecrOpID,1))
-    ;
+  if (checkOperator(n,PostDecrOpID,1)) {
+    if (ReferenceOp* oprnd = llvm::dyn_cast<ReferenceOp>(n->getOperand(0))) {
+      const Value* V = oprnd->getReferent();
+      if (V && (isa<AutoVarOp>(V) || isa<Variable>(V))) {
+        if (!V->getType()->isNumericType())
+          error(n,"Target of PostDecrOp is not numeric type");
+      } else
+        ; // Handled elsewhere
+    } else 
+      error(n,"Operand of PostDecrOp must be a ReferenceOp");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(AddOp* n)
 {
-  if (checkOperator(n,AddOpID,2))
-    ;
+  if (checkOperator(n,AddOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isNumericType() || !Ty2->isNumericType())
+      error(n,"You can only add objects of numeric type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(SubtractOp* n)
 {
-  if (checkOperator(n,SubtractOpID,2))
-    ;
+  if (checkOperator(n,SubtractOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isNumericType() || !Ty2->isNumericType())
+      error(n,"You can only subtract objects of numeric type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(MultiplyOp* n)
 {
-  if (checkOperator(n,MultiplyOpID,2))
-    ;
+  if (checkOperator(n,MultiplyOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isNumericType() || !Ty2->isNumericType())
+      error(n,"You can only multiply objects of numeric type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(DivideOp* n)
 {
-  if (checkOperator(n,DivideOpID,2))
-    ;
+  if (checkOperator(n,DivideOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isNumericType() || !Ty2->isNumericType())
+      error(n,"You can only multiply objects of numeric type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(ModuloOp* n)
 {
-  if (checkOperator(n,ModuloOpID,2))
-    ;
+  if (checkOperator(n,ModuloOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isNumericType() || !Ty2->isNumericType())
+      error(n,"You can only multiply objects of numeric type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(BAndOp* n)
 {
-  if (checkOperator(n,BAndOpID,2))
-    ;
+  if (checkOperator(n,BAndOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isIntegerType() || !Ty2->isIntegerType())
+      error(n,"You can only bitwise and objects of integer type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(BOrOp* n)
 {
-  if (checkOperator(n,BOrOpID,2))
-    ;
+  if (checkOperator(n,BOrOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isIntegerType() || !Ty2->isIntegerType())
+      error(n,"You can only bitwise or objects of integer type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(BXorOp* n)
 {
-  if (checkOperator(n,BXorOpID,2))
-    ;
+  if (checkOperator(n,BXorOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isIntegerType() || !Ty2->isIntegerType())
+      error(n,"You can only bitwise xor objects of integer type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(BNorOp* n)
 {
-  if (checkOperator(n,BNorOpID,2))
-    ;
+  if (checkOperator(n,BNorOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->isIntegerType() || !Ty2->isIntegerType())
+      error(n,"You can only bitwise nor objects of integer type");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(NotOp* n)
 {
-  if (checkOperator(n,NotOpID,1))
-    ;
+  if (checkOperator(n,NotOpID,1)) {
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!Ty->is(BooleanTypeID))
+      error(n,"NotOp expects boolean typed operand");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(AndOp* n)
 {
-  if (checkOperator(n,AndOpID,2))
-    ;
+  if (checkOperator(n,AndOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->is(BooleanTypeID) || !Ty2->is(BooleanTypeID))
+      error(n,"AndOp expects two boolean typed operands");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(OrOp* n)
 {
-  if (checkOperator(n,OrOpID,2))
-    ;
+  if (checkOperator(n,OrOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->is(BooleanTypeID) || !Ty2->is(BooleanTypeID))
+      error(n,"OrOp expects two boolean typed operands");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(NorOp* n)
 {
-  if (checkOperator(n,NorOpID,2))
-    ;
+  if (checkOperator(n,NorOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->is(BooleanTypeID) || !Ty2->is(BooleanTypeID))
+      error(n,"NorOp expects two boolean typed operands");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(XorOp* n)
 {
-  if (checkOperator(n,XorOpID,2))
-    ;
+  if (checkOperator(n,XorOpID,2)) {
+    const Type* Ty1 = n->getOperand(0)->getType();
+    const Type* Ty2 = n->getOperand(1)->getType();
+    if (!Ty1->is(BooleanTypeID) || !Ty2->is(BooleanTypeID))
+      error(n,"XorOp expects two boolean typed operands");
+  }
 }
 
 template<> inline void
@@ -799,29 +956,54 @@
 template<> inline void
 ValidateImpl::validate(OpenOp* n)
 {
-  if (checkOperator(n,OpenOpID,1))
-    ;
+  if (checkOperator(n,OpenOpID,1)) {
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!isa<StringType>(Ty))
+      error(n,"OpenOp expects first operand to be a string");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(CloseOp* n)
 {
-  if (checkOperator(n,CloseOpID,1))
-    ;
+  if (checkOperator(n,CloseOpID,1)) {
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!isa<StreamType>(Ty))
+      error(n,"CloseOp expects first operand to be a stream");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(ReadOp* n)
 {
-  if (checkOperator(n,ReadOpID,2))
-    ;
+  if (checkOperator(n,ReadOpID,2)) {
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!isa<StreamType>(Ty))
+      error(n,"ReadOp expects first operand to be a stream");
+    Ty = n->getOperand(1)->getType();
+    if (!isa<BufferType>(Ty))
+      error(n,"ReadOp expects second operand to be a buffer");
+  }
 }
 
 template<> inline void
 ValidateImpl::validate(WriteOp* n)
 {
-  if (checkOperator(n,WriteOpID,2))
-    ;
+  if (checkOperator(n,WriteOpID,2)) {
+    const Type* Ty = n->getOperand(0)->getType();
+    if (!isa<StreamType>(Ty))
+      error(n,"WriteOp expects first operand to be a stream");
+    Ty = n->getOperand(1)->getType();
+    switch (Ty->getID()) {
+      case BufferTypeID:
+      case TextTypeID:
+      case StringTypeID:
+        break;
+      default:
+        error(n,"WriteOp expects second operand to be a writable type");
+        break;
+    }
+  }
 }
 
 template<> inline void
@@ -840,12 +1022,7 @@
 }
 
 template<> inline void
-ValidateImpl::validate(ConstantText* n)
-{
-}
-
-template<> inline void
-ValidateImpl::validate(ConstantZero* n)
+ValidateImpl::validate(ConstantString* n)
 {
 }
 
@@ -927,6 +1104,8 @@
     case DeallocateOpID:         validate(cast<DeallocateOp>(n)); break;
     case ReallocateOpID:         /*validate(cast<ReallocateOp>(n));*/ break;
     case ReferenceOpID:          /*validate(cast<ReferenceOp>(n));*/ break;
+    case ConstantReferenceOpID:  /*validate(cast<ConstantReferenceOp>(n));*/ 
+                                                                     break;
     case AutoVarOpID:            validate(cast<AutoVarOp>(n)); break;
     case NegateOpID:             validate(cast<NegateOp>(n)); break;
     case ComplementOpID:         validate(cast<ComplementOp>(n)); break;
@@ -983,8 +1162,7 @@
     case ConstantBooleanID:      validate(cast<ConstantBoolean>(n)); break;
     case ConstantIntegerID:      validate(cast<ConstantInteger>(n)); break;
     case ConstantRealID:         validate(cast<ConstantReal>(n)); break;
-    case ConstantTextID:         validate(cast<ConstantText>(n)); break;
-    case ConstantZeroID:         validate(cast<ConstantZero>(n)); break;
+    case ConstantStringID:       validate(cast<ConstantString>(n)); break;
     case ConstantAggregateID:    validate(cast<ConstantAggregate>(n)); break;
     case ConstantExpressionID:   validate(cast<ConstantExpression>(n)); break;
       break; // Not implemented yet

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

==============================================================================
--- hlvm/trunk/hlvm/Reader/HLVM.rng (original)
+++ hlvm/trunk/hlvm/Reader/HLVM.rng Sat Jul  7 19:01:45 2007
@@ -79,19 +79,82 @@
       <data type="boolean"/>
       <value>TRUE</value>
       <value>True</value>
-      <value>yes</value>
-      <value>Yes</value>
+      <value>true</value>
       <value>YES</value>
+      <value>Yes</value>
+      <value>yes</value>
       <value>1</value>
       <value>FALSE</value>
       <value>False</value>
-      <value>no</value>
-      <value>No</value>
+      <value>false</value>
       <value>NO</value>
+      <value>No</value>
+      <value>no</value>
       <value>0</value>
     </choice>
   </define>
 
+  <define name="Binary.type">
+    <data type="string">
+      <param name="minLength">1</param>
+      <param name="maxLength">1024</param>
+      <param name="pattern">[01]+</param>
+    </data>
+  </define>
+
+  <define name="Octal.type" >
+    <data type="string">
+      <param name="minLength">1</param>
+      <param name="maxLength">1024</param>
+      <param name="pattern">[0-7]+</param>
+    </data>
+  </define>
+
+  <define name="Decimal.type">
+    <data type="string">
+      <param name="minLength">1</param>
+      <param name="maxLength">1024</param>
+      <param name="pattern">[+\-]?\d+</param>
+    </data>
+  </define>
+
+  <define name="Hexadecimal.type">
+    <data type="string">
+      <param name="minLength">1</param>
+      <param name="maxLength">1024</param>
+      <param name="pattern">([0-9A-Fa-f][0-9A-Fa-f])+</param>
+    </data>
+  </define>
+
+  <define name="Integer.type">
+    <choice>
+      <ref name="Binary.type"/>
+      <ref name="Octal.type"/>
+      <ref name="Decimal.type"/>
+      <ref name="Hexadecimal.type"/>
+    </choice>
+  </define>
+
+  <define name="Real.type">
+    <data type="string">
+      <param name="minLength">1</param>
+      <param name="maxLength">1024</param>
+      <param name="pattern">ninf|pinf|nan|signan|zero|nzero|[+\-]?0x[0-9A-Fa-f](\.[0-9A-Fa-f]+)?p[-+][0-9]+|#[0-9A-Fa-f]{16}|#[0-9a-fA-F]{8}|[+\-]?\d+\.\d*([Ee][+\-]?\d+)?</param>
+    </data>
+  </define>
+
+  <define name="Character.type">
+    <choice>
+      <data type="string">
+        <param name="length">1</param>
+      </data>
+      <data type="string">
+        <param name="length">5</param>
+        <param name="pattern">[#][0-9A-Fa-f]{4,4}</param>
+      </data>
+    </choice>
+  </define>
+
   <!-- DOCUMENTATION OF HLVM AST PROGRAMS -->
 
   <define name="Documentation.pat">
@@ -179,6 +242,7 @@
           <ref name="signature.elem"/>
           <ref name="vector.elem"/>
           <ref name="opaque.elem"/>
+          <ref name="constant.elem"/>
           <ref name="variable.elem"/>
           <ref name="function.elem"/>
           <ref name="program.elem"/>
@@ -282,7 +346,7 @@
       <value>s64</value>
       <value>s128</value>
       <value>stream</value>
-      <value>text</value>
+      <value>string</value>
       <value>u8</value>
       <value>u16</value>
       <value>u32</value>
@@ -364,159 +428,17 @@
     </element>
   </define>
 
-  <!--PATTERNS FOR VARIABLES-->
+  <!-- PATTERNS FOR CONSTANTS -->
 
-  <define name="variable.elem">
-    <element name="variable">
+  <define name="constant.elem">
+    <element name="constant">
       <ref name="Named_Typed_Element.pat"/>
-      <optional>
-        <attribute name="const"><data type="boolean"/></attribute>
-      </optional>
-      <optional>
-        <choice>
-          <element name="init">
-            <ref name="Constant.pat"/>
-          </element>
-          <element name="zero">
-            <empty/>
-          </element>
-        </choice>
-      </optional>
-      <optional>
-        <attribute name="linkage">
-          <ref name="Linkage.type"/>
-        </attribute>
-      </optional>
-    </element>
-  </define>
-
-  <define name="Linkage.type">
-    <choice>
-      <value>appending</value>
-      <value>external</value>
-      <value>internal</value>
-      <value>linkonce</value>
-      <value>weak</value>
-    </choice>
-  </define>
-
-  <!--PATTERNS FOR FUNCTIONS -->
-
-  <define name="function.elem">
-    <element name="function">
-      <ref name="Named_Typed_Element.pat"/>
-      <optional>
-        <attribute name="linkage"><ref name="Linkage.type"/></attribute>
-      </optional>
-      <choice>
-        <element name="as"><ref name="C_Identifier.type"/></element>
-        <zeroOrMore>
-          <ref name="block.elem"/>
-        </zeroOrMore>
-      </choice>
-    </element>
-  </define>
-
-  <define name="program.elem">
-    <element name="program">
-      <ref name="Named_Element.pat"/>
-      <optional>
-        <attribute name="linkage"><ref name="Linkage.type"/></attribute>
-      </optional>
-      <zeroOrMore>
-        <ref name="block.elem"/>
-      </zeroOrMore>
-    </element>
-  </define>
-
-  <define name="Block.pat">
-    <oneOrMore>
-      <choice>
-        <ref name="Operators.pat"/>
-        <ref name="block.elem"/>
-      </choice>
-    </oneOrMore>
-  </define>
-
-  <define name="block.elem">
-    <element name="block">
-      <optional>
-        <attribute name="label"><ref name="Identifier.type"/></attribute>
-      </optional>
-      <ref name="Block.pat"/>
-    </element>
-  </define>
-
-  <!-- PATTERNS FOR DEFINING CONSTANTS -->
-
-  <define name="Constant.pat">
-    <choice>
       <ref name="Literal.pat"/>
-      <!-- 
-      FIXME: This is hacked out right now because it causes infinite recursion
-      in libxml2 function xmlRelaxNGGetElements. Debugging it didn't help me
-      find out why.
-      <ref name="ConstantExpression.pat"/>
-      -->
-    </choice>
-  </define>
-
-  <define name="ref.elem">
-    <element name="ref">
-      <ref name="Named_Element.pat"/>
     </element>
   </define>
 
-  <define name="ConstantExpression.pat">
-    <choice>
-      <ref name="index.elem"/>
-      <ref name="cast.elem"/>
-      <ref name="select.elem"/>
-      <ref name="sizeof.elem"/>
-      <ref name="addrof.elem"/>
-      <ref name="extract.elem"/>
-      <ref name="insert.elem"/>
-      <ref name="shuffle.elem"/>
-      <ref name="BooleanOperators.pat"/>
-      <ref name="UnaryArithmeticOperators.pat"/>
-      <ref name="BinaryArithmeticOperators.pat"/>
-    </choice>
-  </define>
-
   <!-- PATTERNS FOR LITERAL CONSTANTS -->
 
-  <define name="Literal.pat">
-    <choice>
-      <ref name="IntegerLiteral.pat"/>
-      <ref name="Boolean_Literal.elem"/>
-      <ref name="Character_Literal.elem"/>
-      <ref name="Real_Literal.elem"/>
-      <ref name="Text_Literal.elem"/>
-      <ref name="Null_Literal.elem"/>
-      <ref name="Array_Literal.elem"/>
-      <ref name="Vector_Literal.elem"/>
-      <ref name="Structure_Literal.elem"/>
-    </choice>
-  </define>
-
-  <define name="IntegerLiteral.pat">
-    <choice>
-      <ref name="Binary_Literal.elem"/>
-      <ref name="Octal_Literal.elem"/>
-      <ref name="Decimal_Literal.elem"/>
-      <ref name="Hexadecimal_Literal.elem"/>
-    </choice>
-  </define>
-
-  <define name="Integer.type">
-    <choice>
-      <ref name="Binary.type"/>
-      <ref name="Octal.type"/>
-      <ref name="Decimal.type"/>
-      <ref name="Hexadecimal.type"/>
-    </choice>
-  </define>
-
   <define name="Typed_Literal.pat">
     <optional>
       <attribute name="type">
@@ -525,67 +447,23 @@
     </optional>
   </define>
 
-  <define name="Binary_Literal.elem">
-    <element name="bin">
-      <ref name="Typed_Literal.pat"/>
-      <ref name="Binary.type"/>
-    </element>
-  </define>
-
-  <define name="Binary.type">
-    <data type="string">
-      <param name="minLength">1</param>
-      <param name="maxLength">1024</param>
-      <param name="pattern">[01]+</param>
-    </data>
-  </define>
-
-  <define name="Octal_Literal.elem">
-    <element name="oct">
-      <ref name="Typed_Literal.pat"/>
-      <ref name="Octal.type"/>
-    </element>
-  </define>
-
-  <define name="Octal.type" >
-    <data type="string">
-      <param name="minLength">1</param>
-      <param name="maxLength">1024</param>
-      <param name="pattern">[0-7]+</param>
-    </data>
-  </define>
-
-  <define name="Decimal_Literal.elem">
-    <element name="dec">
-      <ref name="Typed_Literal.pat"/>
-      <ref name="Decimal.type"/>
-    </element>
-  </define>
-
-  <define name="Decimal.type">
-    <data type="string">
-      <param name="minLength">1</param>
-      <param name="maxLength">1024</param>
-      <param name="pattern">[+\-]?\d+</param>
-    </data>
-  </define>
-
-  <define name="Hexadecimal_Literal.elem">
-    <element name="hex">
-      <ref name="Typed_Literal.pat"/>
-      <ref name="Hexadecimal.type"/>
-    </element>
-  </define>
-
-  <define name="Hexadecimal.type">
-    <data type="string">
-      <param name="minLength">1</param>
-      <param name="maxLength">1024</param>
-      <param name="pattern">([0-9A-Fa-f][0-9A-Fa-f])+</param>
-    </data>
+  <define name="Literal.pat">
+    <choice>
+      <ref name="Boolean_Literal.pat"/>
+      <ref name="Integer_Literal.pat"/>
+      <ref name="Real_Literal.pat"/>
+      <ref name="char.elem"/>
+      <ref name="string.elem"/>
+      <ref name="null.elem"/>
+      <ref name="ptr.elem"/>
+      <ref name="arr.elem"/>
+      <ref name="vect.elem"/>
+      <ref name="struct.elem"/>
+      <ref name="cont.elem"/>
+    </choice>
   </define>
 
-  <define name="Boolean_Literal.elem">
+  <define name="Boolean_Literal.pat">
     <choice>
       <element name="true">
         <empty/>
@@ -593,34 +471,36 @@
       <element name="false">
         <empty/>
       </element>
+      <element name="bool">
+        <ref name="Typed_Literal.pat"/>
+        <ref name="Boolean.type"/>
+      </element>
     </choice>
   </define>
 
-  <define name="Character_Literal.elem">
-    <element name="char">
-      <ref name="Character.type"/>
-    </element>
-  </define>
-
-  <define name="Text_Literal.elem">
-    <element name="text">
-      <text/>
-    </element>
-  </define>
 
-  <define name="Character.type">
+  <define name="Integer_Literal.pat">
     <choice>
-      <data type="string">
-        <param name="length">1</param>
-      </data>
-      <data type="string">
-        <param name="length">5</param>
-        <param name="pattern">[#][0-9A-Fa-f]{4,4}</param>
-      </data>
+      <element name="bin">
+        <ref name="Typed_Literal.pat"/>
+        <ref name="Binary.type"/>
+      </element>
+      <element name="oct">
+        <ref name="Typed_Literal.pat"/>
+        <ref name="Octal.type"/>
+      </element>
+      <element name="dec">
+        <ref name="Typed_Literal.pat"/>
+        <ref name="Decimal.type"/>
+      </element>
+      <element name="hex">
+        <ref name="Typed_Literal.pat"/>
+        <ref name="Hexadecimal.type"/>
+      </element>
     </choice>
   </define>
 
-  <define name="Real_Literal.elem">
+  <define name="Real_Literal.pat">
     <choice>
       <element name="flt">
         <ref name="Real.type"/>
@@ -628,68 +508,158 @@
       <element name="dbl">
         <ref name="Real.type"/>
       </element>
+      <element name="real">
+        <ref name="Typed_Literal.pat"/>
+        <ref name="Real.type"/>
+      </element>
     </choice>
   </define>
 
-  <define name="Real.type">
-    <data type="string">
-      <param name="minLength">1</param>
-      <param name="maxLength">1024</param>
-      <param name="pattern">ninf|pinf|nan|signan|zero|nzero|[+\-]?0x[0-9A-Fa-f](\.[0-9A-Fa-f]+)?p[-+][0-9]+|#[0-9A-Fa-f]{16}|#[0-9a-fA-F]{8}|[+\-]?\d+\.\d*([Ee][+\-]?\d+)?</param>
-    </data>
+  <define name="char.elem">
+    <element name="char">
+      <ref name="Typed_Literal.pat"/>
+      <ref name="Character.type"/>
+    </element>
+  </define>
+
+  <define name="string.elem">
+    <element name="string">
+      <ref name="Typed_Literal.pat"/>
+      <text/>
+    </element>
   </define>
 
-  <define name="Null_Literal.elem">
+  <define name="null.elem">
     <element name="null">
+      <ref name="Typed_Literal.pat"/>
       <empty/>
     </element>
   </define>
 
-  <define name="Array_Literal.elem">
+  <define name="ptr.elem">
+    <element name="ptr">
+      <ref name="Typed_Literal.pat"/>
+      <ref name="Literal.pat"/>
+    </element>
+  </define>
+
+  <define name="arr.elem">
     <element name="arr">
-      <ref name="Typed_Element.pat"/>
+      <ref name="Typed_Literal.pat"/>
       <oneOrMore>
-        <ref name="Constant.pat"/>
+        <ref name="Literal.pat"/>
       </oneOrMore>
     </element>
   </define>
 
-  <define name="Vector_Literal.elem">
+  <define name="vect.elem">
     <element name="vect">
-      <ref name="Typed_Element.pat"/>
+      <ref name="Typed_Literal.pat"/>
       <oneOrMore>
-        <ref name="Constant.pat"/>
+        <ref name="Literal.pat"/>
       </oneOrMore>
     </element>
   </define>
 
-  <define name="Structure_Literal.elem">
+  <define name="struct.elem">
     <element name="struct">
-      <ref name="Typed_Element.pat"/>
+      <ref name="Typed_Literal.pat"/>
       <oneOrMore>
-        <ref name="Constant.pat"/>
+        <ref name="Literal.pat"/>
       </oneOrMore>
     </element>
   </define>
 
-  <!-- PATTERNS FOR OPERATORS -->
+  <define name="cont.elem">
+    <element name="cont">
+      <ref name="Typed_Literal.pat"/>
+      <oneOrMore>
+        <ref name="Literal.pat"/>
+      </oneOrMore>
+    </element>
+  </define>
+
+  <!-- PATTERNS FOR VARIABLES-->
 
-  <define name="Value.pat">
+  <define name="variable.elem">
+    <element name="variable">
+      <ref name="Named_Typed_Element.pat"/>
+      <optional>
+        <attribute name="const"><data type="boolean"/></attribute>
+        <attribute name="linkage">
+          <ref name="Linkage.type"/>
+        </attribute>
+        <attribute name="init">
+          <ref name="Identifier.type"/>
+        </attribute>
+      </optional>
+    </element>
+  </define>
+
+  <define name="Linkage.type">
     <choice>
-      <ref name="Operators.pat"/>
-      <ref name="Constant.pat"/>
+      <value>appending</value>
+      <value>external</value>
+      <value>internal</value>
+      <value>linkonce</value>
+      <value>weak</value>
     </choice>
   </define>
 
-  <define name="Location.pat">
+  <!--PATTERNS FOR FUNCTIONS -->
+
+  <define name="function.elem">
+    <element name="function">
+      <ref name="Named_Typed_Element.pat"/>
+      <optional>
+        <attribute name="linkage"><ref name="Linkage.type"/></attribute>
+      </optional>
+      <choice>
+        <element name="as"><ref name="C_Identifier.type"/></element>
+        <zeroOrMore>
+          <ref name="block.elem"/>
+        </zeroOrMore>
+      </choice>
+    </element>
+  </define>
+
+  <define name="program.elem">
+    <element name="program">
+      <ref name="Named_Element.pat"/>
+      <optional>
+        <attribute name="linkage"><ref name="Linkage.type"/></attribute>
+      </optional>
+      <zeroOrMore>
+        <ref name="block.elem"/>
+      </zeroOrMore>
+    </element>
+  </define>
+
+
+  <!-- PATTERNS FOR DEFINING CONSTANTS -->
+
+  <define name="ConstantExpression.pat">
     <choice>
-      <ref name="ref.elem"/>
       <ref name="index.elem"/>
+      <ref name="cast.elem"/>
+      <ref name="select.elem"/>
+      <ref name="sizeof.elem"/>
+      <ref name="addrof.elem"/>
+      <ref name="extract.elem"/>
+      <ref name="insert.elem"/>
+      <ref name="shuffle.elem"/>
+      <ref name="BooleanOperators.pat"/>
+      <ref name="UnaryArithmeticOperators.pat"/>
+      <ref name="BinaryArithmeticOperators.pat"/>
     </choice>
   </define>
 
+  <!-- PATTERNS FOR OPERATORS -->
+
   <define name="Operators.pat">
     <choice>
+      <ref name="block.elem"/>
+      <ref name="cref.elem"/>
       <ref name="noop.elem"/>
       <ref name="BooleanOperators.pat"/>
       <ref name="UnaryArithmeticOperators.pat"/>
@@ -697,27 +667,51 @@
       <ref name="MemoryOps.pat"/>
       <ref name="InputOutputOps.pat"/>
       <ref name="ControlFlowOps.pat"/>
-      <ref name="Literal.pat"/>
     </choice>
   </define>
 
   <define name="UnaryOperator.pat">
     <ref name="Documentation.pat"/>
-    <ref name="Value.pat"/>
+    <ref name="Operators.pat"/>
   </define>
 
 
   <define name="BinaryOperator.pat">
     <ref name="Documentation.pat"/>
-    <ref name="Value.pat"/>
-    <ref name="Value.pat"/>
+    <ref name="Operators.pat"/>
+    <ref name="Operators.pat"/>
   </define>
 
   <define name="TernaryOperator.pat">
     <ref name="Documentation.pat"/>
-    <ref name="Value.pat"/>
-    <ref name="Value.pat"/>
-    <ref name="Value.pat"/>
+    <ref name="Operators.pat"/>
+    <ref name="Operators.pat"/>
+    <ref name="Operators.pat"/>
+  </define>
+
+  <define name="Location.pat">
+    <choice>
+      <ref name="ref.elem"/>
+      <ref name="index.elem"/>
+    </choice>
+  </define>
+
+  <define name="block.elem">
+    <element name="block">
+      <optional>
+        <attribute name="label"><ref name="Identifier.type"/></attribute>
+      </optional>
+      <oneOrMore>
+        <ref name="Operators.pat"/>
+      </oneOrMore>
+    </element>
+  </define>
+
+  <define name="cref.elem">
+    <element name="cref">
+      <ref name="Named_Element.pat"/>
+      <empty/>
+    </element>
   </define>
 
   <define name="noop.elem">
@@ -735,7 +729,7 @@
   </define>
 
   <define name="addrof.elem">
-    <ref name="Value.pat"/>
+    <ref name="Operators.pat"/>
   </define>
 
   <define name="extract.elem">
@@ -762,6 +756,12 @@
     </choice>
   </define>
 
+  <define name="ref.elem">
+    <element name="ref">
+      <ref name="Named_Element.pat"/>
+    </element>
+  </define>
+
   <define name="load.elem">
     <element name="load">
       <ref name="Documentation.pat"/>
@@ -773,16 +773,16 @@
     <element name="store">
       <ref name="Documentation.pat"/>
       <ref name="Location.pat"/>
-      <ref name="Value.pat"/>
+      <ref name="Operators.pat"/>
     </element>
   </define>
 
   <define name="index.elem">
     <element name="index">
       <ref name="Documentation.pat"/>
-      <ref name="Value.pat"/>
+      <ref name="Operators.pat"/>
       <oneOrMore>
-        <ref name="Value.pat"/>
+        <ref name="Operators.pat"/>
       </oneOrMore>
     </element>
   </define>
@@ -797,12 +797,11 @@
   <define name="autovar.elem">
     <element name="autovar">
       <ref name="Named_Typed_Element.pat"/>
-      <choice>
-        <ref name="Constant.pat"/>
-        <element name="zero">
-          <empty/>
-        </element>
-      </choice>
+      <optional>
+        <attribute name="init">
+          <ref name="Identifier.type"/>
+        </attribute>
+      </optional>
     </element>
   </define>
 
@@ -823,30 +822,30 @@
   <define name="open.elem">
     <element name="open">
       <ref name="Documentation.pat"/>
-      <ref name="Value.pat"/>
+      <ref name="Operators.pat"/>
     </element>
   </define>
 
   <define name="close.elem">
     <element name="close">
       <ref name="Documentation.pat"/>
-      <ref name="Value.pat"/>
+      <ref name="Operators.pat"/>
     </element>
   </define>
 
   <define name="write.elem">
     <element name="write">
       <ref name="Documentation.pat"/>
-      <ref name="Value.pat"/>
-      <ref name="Value.pat"/>
+      <ref name="Operators.pat"/>
+      <ref name="Operators.pat"/>
     </element>
   </define>
 
   <define name="read.elem">
     <element name="read">
       <ref name="Documentation.pat"/>
-      <ref name="Value.pat"/>
-      <ref name="Value.pat"/>
+      <ref name="Operators.pat"/>
+      <ref name="Operators.pat"/>
     </element>
   </define>
 
@@ -877,25 +876,25 @@
 
   <define name="preinc.elem">
     <element name="preinc">
-      <ref name="UnaryOperator.pat"/>
+      <ref name="ref.elem"/>
     </element>
   </define>
 
   <define name="predec.elem">
     <element name="predec">
-      <ref name="UnaryOperator.pat"/>
+      <ref name="ref.elem"/>
     </element>
   </define>
 
   <define name="postinc.elem">
     <element name="postinc">
-      <ref name="UnaryOperator.pat"/>
+      <ref name="ref.elem"/>
     </element>
   </define>
 
   <define name="postdec.elem">
     <element name="postdec">
-      <ref name="UnaryOperator.pat"/>
+      <ref name="ref.elem"/>
     </element>
   </define>
 
@@ -1067,7 +1066,7 @@
   <define name="select.elem">
     <element name="select">
       <ref name="Documentation.pat"/>
-      <ref name="Value.pat"/>
+      <ref name="Operators.pat"/>
       <ref name="Operators.pat"/>
       <ref name="Operators.pat"/>
     </element>
@@ -1076,7 +1075,7 @@
   <define name="switch.elem">
     <element name="switch">
       <ref name="Documentation.pat"/>
-      <ref name="Value.pat"/>       <!-- Control Expression -->
+      <ref name="Operators.pat"/>       <!-- Control Expression -->
       <ref name="Operators.pat"/>   <!-- Default Case -->
       <zeroOrMore>
         <ref name="Operators.pat"/> <!-- Case Expression -->

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

==============================================================================
--- hlvm/trunk/hlvm/Reader/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XMLReader.cpp Sat Jul  7 19:01:45 2007
@@ -44,6 +44,7 @@
 #include <hlvm/AST/BooleanOps.h>
 #include <hlvm/AST/RealMath.h>
 #include <hlvm/Base/Assert.h>
+#include <llvm/ADT/StringExtras.h>
 #include <libxml/parser.h>
 #include <libxml/relaxng.h>
 #include <vector>
@@ -68,13 +69,14 @@
   Block* block;
   Function* func;
   Bundle* bundle;
+  bool isError;
 public:
   XMLReaderImpl(const std::string& p)
-    : path(p), ast(0), loc(0), uri(0), block(0), func(0), bundle(0)
+    : path(p), ast(0), loc(0), uri(0), block(0), func(0), bundle(0), isError(0)
   {
     ast = AST::create();
     ast->setSystemID(p);
-    uri = URI::create(p,ast->getPool());
+    uri = ast->new_URI(p);
   }
 
   virtual ~XMLReaderImpl() 
@@ -86,10 +88,6 @@
   virtual void read();
   virtual AST* get();
 
-  void error(const std::string& msg) {
-    std::cerr << msg << "\n";
-  }
-
   std::string lookupToken(int32_t token) const
   {
     return HLVMTokenizer::lookup(token);
@@ -97,11 +95,10 @@
 
   Locator* getLocator(xmlNodePtr& cur) {
     if (loc) {
-      LineLocator tmp(uri,cur->line);
-      if (*loc == tmp)
+      if (loc->getLine() == cur->line)
         return loc;
     }
-    return loc = new LineLocator(uri,cur->line);
+    return loc = ast->new_Locator(uri,cur->line);
   }
 
   inline Type* getType(const std::string& name );
@@ -110,29 +107,16 @@
   inline void handleParseError(xmlErrorPtr error);
   inline void handleValidationError(xmlErrorPtr error);
 
-  inline ConstantInteger* parseBinary(xmlNodePtr& cur);
-  inline ConstantInteger* parseOctal(xmlNodePtr& cur);
-  inline ConstantInteger* parseDecimal(xmlNodePtr& cur);
-  inline ConstantInteger* parseHexadecimal(xmlNodePtr& cur);
-  inline ConstantReal*    parseFloat(xmlNodePtr& cur);
-  inline ConstantReal*    parseDouble(xmlNodePtr& cur);
-  inline ConstantText*    parseText(xmlNodePtr& cur);
-  inline ConstantZero*    parseZero(xmlNodePtr& cur,const Type* Ty);
+  inline void error(Locator* loc, const std::string& msg);
 
   inline xmlNodePtr   checkDoc(xmlNodePtr cur, Documentable* node);
-  inline Value*  getValue(xmlNodePtr&);
 
+  Constant*      parseLiteralConstant(xmlNodePtr& cur, const std::string& name,
+    const Type* Ty);
+  Constant*      parseConstant      (xmlNodePtr& cur);
+  Operator*      parseOperator      (xmlNodePtr& cur);
   void           parseTree          ();
-
   Type*          parseAtom          (xmlNodePtr& cur);
-  Constant*      parseConstant      (xmlNodePtr& cur, const Type* Ty);
-  Constant*      parseConstant      (xmlNodePtr& cur, const Type* Ty, int tkn);
-  Operator*      parseOperator      (xmlNodePtr& cur);
-  Operator*      parseOperator      (xmlNodePtr& cur, int token);
-  Value*         parseValue         (xmlNodePtr& cur);
-  Value*         parseValue         (xmlNodePtr& cur, int token);
-  StoreOp*       parseStoreOp       (xmlNodePtr& cur);
-  LoadOp*        parseLoadOp        (xmlNodePtr& cur);
 
   template<class OpClass>
   OpClass*       parse(xmlNodePtr& cur);
@@ -148,6 +132,11 @@
   template<class OpClass>
   OpClass* parseMultiOp(xmlNodePtr& cur);
 
+  inline const char* 
+  getAttribute(xmlNodePtr cur,const char*name,bool required = true);
+  inline void getTextContent(xmlNodePtr cur, std::string& buffer);
+  inline void getNameType(xmlNodePtr& cur, std::string& name,std::string& type);
+
 private:
 };
 
@@ -246,22 +235,25 @@
   return ::atoll(str);
 }
 
-
 inline bool 
-recognize_boolean(const std::string& str)
+recognize_boolean(const char* str)
 {
-  switch (str[0])
+  switch (getToken(str))
   {
-    case 'F': if (str == "FALSE") return false; break;
-    case 'N': if (str == "NO")    return false; break;
-    case 'T': if (str == "TRUE")  return true; break;
-    case 'Y': if (str == "YES")   return true; break;
-    case 'f': if (str == "false") return false; break;
-    case 'n': if (str == "no")    return false; break;
-    case 't': if (str == "true")  return true; break;
-    case 'y': if (str == "yes")   return true; break;
-    case '0': if (str == "0")     return false; break;
-    case '1': if (str == "1")     return true; break;
+    case TKN_FALSE: return false;
+    case TKN_False: return false;
+    case TKN_false: return false;
+    case TKN_NO: return false;
+    case TKN_No: return false;
+    case TKN_no: return false;
+    case TKN_0: return false;
+    case TKN_TRUE: return true;
+    case TKN_True: return true;
+    case TKN_true: return true;
+    case TKN_YES: return true;
+    case TKN_Yes: return true;
+    case TKN_yes: return true;
+    case TKN_1: return true;
     default: break;
   }
   hlvmDeadCode("Invalid boolean value");
@@ -290,7 +282,7 @@
     case TKN_s64:    result = ast->getPrimitiveType(SInt64TypeID); break;
     case TKN_s8:     result = ast->getPrimitiveType(SInt8TypeID); break;
     case TKN_stream: result = ast->getPrimitiveType(StreamTypeID); break;
-    case TKN_text:   result = ast->getPrimitiveType(TextTypeID); break;
+    case TKN_string: result = ast->getPrimitiveType(StringTypeID); break;
     case TKN_u128:   result = ast->getPrimitiveType(UInt128TypeID); break;
     case TKN_u16:    result = ast->getPrimitiveType(UInt16TypeID); break;
     case TKN_u32:    result = ast->getPrimitiveType(UInt32TypeID); break;
@@ -329,7 +321,7 @@
     case TKN_s64:     result = ast->new_s64(name,loc); break;
     case TKN_s8:      result = ast->new_s8(name,loc); break;
     case TKN_stream:  result = ast->new_StreamType(name,loc); break;
-    case TKN_text:    result = ast->new_TextType(name,loc); break;
+    case TKN_string:  result = ast->new_StringType(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;
@@ -342,23 +334,48 @@
 }
 
 inline const char* 
-getAttribute(xmlNodePtr cur,const char*name,bool required = true)
+XMLReaderImpl::getAttribute(xmlNodePtr cur,const char*name,bool required )
 {
   const char* result = reinterpret_cast<const char*>(
    xmlGetNoNsProp(cur,reinterpret_cast<const xmlChar*>(name)));
   if (!result && required) {
-    hlvmAssert(!"Missing Attribute");
+    error(getLocator(cur),std::string("Requred Attribute '") + name + 
+          "' is missing.");
   }
   return result;
 }
 
+inline void
+XMLReaderImpl::getTextContent(xmlNodePtr cur, std::string& buffer)
+{
+  buffer.clear();
+  if (cur) skipBlanks(cur,false);
+  while (cur && cur->type == XML_TEXT_NODE) {
+    buffer += reinterpret_cast<const char*>(cur->content);
+    cur = cur->next;
+  }
+  if (cur) skipBlanks(cur);
+}
+
 inline void 
-getNameType(xmlNodePtr& cur, std::string& name, std::string& type)
+XMLReaderImpl::getNameType(xmlNodePtr& cur, std::string& name,std::string& type)
 {
   name = getAttribute(cur,"id");
   type = getAttribute(cur,"type");
 }
 
+inline void
+XMLReaderImpl::error(Locator* loc, const std::string& msg)
+{
+  std::string location;
+  if (loc)
+    loc->getLocation(location);
+  else
+    location = "Unknown Location";
+  std::cerr << location << ": " << msg << "\n";
+  isError = true;
+}
+
 Type* 
 XMLReaderImpl::getType(const std::string& name )
 {
@@ -370,178 +387,125 @@
   return Ty;
 }
 
-inline ConstantInteger*
-XMLReaderImpl::parseBinary(xmlNodePtr& cur)
-{
-  uint64_t value = 0;
-  xmlNodePtr child = cur->children;
-  if (child) skipBlanks(child,false);
-  while (child && child->type == XML_TEXT_NODE) {
-    const xmlChar* p = child->content;
-    while (*p != 0) {
-      value <<= 1;
-      hlvmAssert(*p == '1' || *p == '0');
-      value |= (*p++ == '1' ? 1 : 0);
-    }
-    child = child->next;
+Constant*
+XMLReaderImpl::parseLiteralConstant(
+    xmlNodePtr& cur, 
+    const std::string& name,
+    const Type* Ty)
+{
+  if (!name.empty() && bundle->find_const(name) != 0) {
+    error(getLocator(cur),std::string("Constant '") + name 
+          + "' already exists.");
+    return 0;
   }
-  if (child) skipBlanks(child);
-  hlvmAssert(!child && "Illegal chlldren of <bin> element");
-  ConstantInteger* result = ast->new_ConstantInteger(value,
-      ast->getPrimitiveType(UInt64TypeID),
-      getLocator(cur));
-  return result;
-}
 
-inline ConstantInteger*
-XMLReaderImpl::parseOctal(xmlNodePtr& cur)
-{
-  uint64_t value = 0;
-  xmlNodePtr child = cur->children;
-  if (child) skipBlanks(child,false);
-  while (child && child->type == XML_TEXT_NODE) {
-    const xmlChar* p = cur->content;
-    while (*p != 0) {
-      value <<= 3;
-      hlvmAssert(*p >= '0' || *p == '7');
-      value += *p++ - '0';
-    }
-    child = child->next;
-  }
-  if (child) skipBlanks(child);
-  hlvmAssert(!child && "Illegal chlldren of <oct> element");
-  ConstantInteger* result = ast->new_ConstantInteger(value,
-      ast->getPrimitiveType(UInt64TypeID),
-      getLocator(cur));
-  return result;
-}
+  // skip over blank text to find next element
+  skipBlanks(cur);
 
-inline ConstantInteger*
-XMLReaderImpl::parseDecimal(xmlNodePtr& cur)
-{
-  uint64_t value = 0;
-  xmlNodePtr child = cur->children;
-  if (child) skipBlanks(child,false);
-  while (child && child->type == XML_TEXT_NODE) {
-    const xmlChar* p = child->content;
-    while (*p != 0) {
-      value *= 10;
-      hlvmAssert(*p >= '0' || *p <= '9');
-      value += *p++ - '0';
+  Constant* C = 0;
+  const char* prefix = 0;
+  std::string actualName(name);
+  int token = getToken(cur->name);
+  switch (token) {
+    case TKN_false:   
+    {
+      C = ast->new_ConstantBoolean(false, getLocator(cur)); 
+      if (actualName.empty())
+        C->setName("bool_false");
+      else
+        C->setName(actualName);
+      break;
     }
-    child = child->next;
-  }
-  if (child) skipBlanks(child);
-  hlvmAssert(!child && "Illegal chlldren of <dec> element");
-  ConstantInteger* result = ast->new_ConstantInteger(value,
-      ast->getPrimitiveType(UInt64TypeID),
-      getLocator(cur));
-  return result;
-}
-
-inline ConstantInteger*
-XMLReaderImpl::parseHexadecimal(xmlNodePtr& cur)
-{
-  uint64_t value = 0;
-  xmlNodePtr child = cur->children;
-  if (child) skipBlanks(child,false);
-  while (child && child->type == XML_TEXT_NODE) {
-    const xmlChar* p = cur->content;
-    while (*p != 0) {
-      value <<= 4;
-      switch (*p) {
-        case '0': break;
-        case '1': value += 1; break;
-        case '2': value += 2; break;
-        case '3': value += 3; break;
-        case '4': value += 4; break;
-        case '5': value += 5; break;
-        case '6': value += 6; break;
-        case '7': value += 7; break;
-        case '8': value += 8; break;
-        case '9': value += 9; break;
-        case 'a': case 'A': value += 10; break;
-        case 'b': case 'B': value += 11; break;
-        case 'c': case 'C': value += 12; break;
-        case 'd': case 'D': value += 13; break;
-        case 'e': case 'E': value += 14; break;
-        case 'f': case 'F': value += 15; break;
-        default:
-          hlvmAssert("Invalid hex digit");
-          break;
-      }
-      p++;
+    case TKN_true:
+    {
+      C = ast->new_ConstantBoolean(true, getLocator(cur));
+      if (actualName.empty())
+        C->setName("bool_true");
+      else
+        C->setName(actualName);
+      break;
     }
-    child = child->next;
-  }
-  if (child) skipBlanks(child);
-  hlvmAssert(!child && "Illegal chlldren of <hex> element");
-  ConstantInteger* result = ast->new_ConstantInteger(value,
-      ast->getPrimitiveType(UInt64TypeID),
-      getLocator(cur));
-  return result;
-}
-
-inline ConstantReal*
-XMLReaderImpl::parseFloat(xmlNodePtr& cur)
-{
-  double value = 0;
-  std::string buffer;
-  xmlNodePtr child = cur->children;
-  if (child) skipBlanks(child,false);
-  while (child && child->type == XML_TEXT_NODE) {
-    buffer += reinterpret_cast<const char*>(cur->content);
-    child = child->next;
-  }
-  if (child) skipBlanks(child);
-  hlvmAssert(!child && "Illegal chlldren of <flt> element");
-  value = atof(buffer.c_str());
-  ConstantReal* result = ast->new_ConstantReal(value,
-    ast->getPrimitiveType(UInt64TypeID),getLocator(cur));
-  return result;
-}
-
-inline ConstantReal*
-XMLReaderImpl::parseDouble(xmlNodePtr& cur)
-{
-  double value = 0;
-  std::string buffer;
-  xmlNodePtr child = cur->children;
-  if (child) skipBlanks(child,false);
-  while (child && child->type == XML_TEXT_NODE) {
-    buffer += reinterpret_cast<const char*>(cur->content);
-    child = child->next;
+    case TKN_bool:
+    {
+      hlvmAssert(Ty->is(BooleanTypeID));
+      std::string buffer;
+      xmlNodePtr child = cur->children;
+      getTextContent(child,buffer);
+      bool value = recognize_boolean( buffer.c_str() );
+      C = ast->new_ConstantBoolean(value, getLocator(cur));
+      if (actualName.empty())
+        C->setName(std::string("bool_") + (value?"true":"false"));
+      else
+        C->setName(actualName);
+      break;
+    }
+    case TKN_bin:
+    case TKN_oct:
+    case TKN_dec:
+    case TKN_hex:
+    {
+      hlvmAssert(Ty->isIntegerType());
+      std::string value;
+      xmlNodePtr child = cur->children;
+      getTextContent(child,value);
+      uint16_t base = (token == TKN_dec ? 10 : (token == TKN_hex ? 16 : 
+                      (token == TKN_oct ? 8 : (token == TKN_bin ? 2 : 10))));
+      C = ast->new_ConstantInteger(value, base, Ty, getLocator(cur));
+      if (actualName.empty())
+        C->setName(std::string("int_") + value);
+      else
+        C->setName(actualName);
+      break;
+    }
+    case TKN_flt:
+    case TKN_dbl:
+    case TKN_real:
+    {
+      hlvmAssert(Ty->isRealType());
+      std::string value;
+      xmlNodePtr child = cur->children;
+      getTextContent(child,value);
+      C = ast->new_ConstantReal(value, Ty, getLocator(cur));
+      if (actualName.empty())
+        C->setName(std::string("real_") + value);
+      else
+        C->setName(actualName);
+      break;
+    }
+    case TKN_string:
+    {
+      hlvmAssert(Ty->is(StringTypeID));
+      std::string value;
+      xmlNodePtr child = cur->children;
+      getTextContent(child,value);
+      C =  ast->new_ConstantString(value,getLocator(cur));
+      if (actualName.empty())
+        C->setName(std::string("str_") + value);
+      else
+        C->setName(actualName);
+      break;
+    }
+    default:
+      hlvmAssert(!"Invalid kind of constant");
+      break;
   }
-  if (child) skipBlanks(child);
-  hlvmAssert(!child && "Illegal chlldren of <dbl> element");
-  value = atof(buffer.c_str());
-  ConstantReal* result = ast->new_ConstantReal(value,
-    ast->getPrimitiveType(UInt64TypeID), getLocator(cur));
-  return result;
+  hlvmAssert(C && C->getType() == Ty && "Constant/Type mismatch");
+  if (C)
+    C->setParent(bundle);
+  return C;
 }
 
-inline ConstantText*
-XMLReaderImpl::parseText(xmlNodePtr& cur)
+inline Constant*
+XMLReaderImpl::parseConstant(xmlNodePtr& cur)
 {
-  std::string buffer;
+  hlvmAssert(getToken(cur->name) == TKN_constant);
+  std::string name;
+  std::string type;
+  getNameType(cur,name,type);
+  Type* Ty = getType(type);
   xmlNodePtr child = cur->children;
-  if (child) skipBlanks(child,false);
-  while (child && child->type == XML_TEXT_NODE) {
-    buffer += reinterpret_cast<const char*>(child->content);
-    child = child->next;
-  }
-  if (child) skipBlanks(child);
-  hlvmAssert(!child && "Illegal chlldren of <text> element");
-  return ast->new_ConstantText(buffer,getLocator(cur));
-}
-
-inline ConstantZero*
-XMLReaderImpl::parseZero(xmlNodePtr& cur, const Type* Ty)
-{
-  hlvmAssert(cur->children == 0);
-  if (Ty == 0)
-    Ty = ast->new_s32("zero",getLocator(cur));
-  return ast->new_ConstantZero(Ty,getLocator(cur));
+  Constant* C = parseLiteralConstant(child,name,Ty);
+  return C;
 }
 
 template<> Documentation*
@@ -578,27 +542,14 @@
   return child;
 }
 
-inline Value*
-XMLReaderImpl::getValue(xmlNodePtr& cur)
-{
-  if (cur && skipBlanks(cur) && cur->type == XML_ELEMENT_NODE) {
-    Value* result = parseValue(cur);
-    cur = cur->next;
-    return result;
-  }
-  else if (cur != 0)
-    hlvmDeadCode("Expecting a value");
-  return 0;
-}
-
 template<> AliasType*
 XMLReaderImpl::parse<AliasType>(xmlNodePtr& cur)
 {
   hlvmAssert(getToken(cur->name)==TKN_alias);
-  std::string name = getAttribute(cur,"id");
-  std::string type = getAttribute(cur,"renames");
+  std::string id = getAttribute(cur,"id");
+  std::string renames = getAttribute(cur,"renames");
   AliasType* alias = 
-    ast->new_AliasType(name,getType(type),getLocator(cur));
+    ast->new_AliasType(id,getType(renames),getLocator(cur));
   checkDoc(cur,alias);
   return alias;
 }
@@ -728,35 +679,43 @@
   getNameType(cur, name, type);
   const char* cnst = getAttribute(cur, "const", false);
   const char* lnkg = getAttribute(cur, "linkage", false);
+  const char* init = getAttribute(cur, "init", false);
   const Type* Ty = getType(type);
   Variable* var = ast->new_Variable(name,Ty,loc);
   if (cnst)
     var->setIsConstant(recognize_boolean(cnst));
   if (lnkg)
     var->setLinkageKind(recognize_LinkageKinds(lnkg));
-  xmlNodePtr child = checkDoc(cur,var);
-  if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
-    Constant* C = parseConstant(child,Ty);
-    var->setInitializer(C);
+  if (init) {
+    Constant* initializer = bundle->find_const(init);
+    if (initializer)
+      var->setInitializer(initializer);
+    else 
+      error(loc,std::string("Constant '") + init + 
+            "' not found in initializer."); 
   }
+  checkDoc(cur,var);
   return var;
 }
 
 template<> AutoVarOp*
 XMLReaderImpl::parse<AutoVarOp>(xmlNodePtr& cur)
 {
+  Locator* loc = getLocator(cur);
   std::string name, type;
   getNameType(cur, name, type);
-  Locator* loc = getLocator(cur);
   const Type* Ty = getType(type);
-  xmlNodePtr child = cur->children;
-  Constant* C = 0;
-  if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
-    C = parseConstant(child,Ty);
-  } else {
-    C = ast->new_ConstantZero(Ty,loc);
-  }
-  return ast->AST::new_AutoVarOp(name,Ty,C,loc);
+  const char* init = getAttribute(cur,"init",false);
+  Constant *initializer = 0;
+  if (init) {
+    initializer = bundle->find_const(init);
+    if (!initializer)
+      error(loc,std::string("Constant '") + init + 
+            "' not found in initializer.");
+  }
+  AutoVarOp* autovar = ast->AST::new_AutoVarOp(name,Ty,initializer,loc);
+  checkDoc(cur,autovar);
+  return autovar;
 }
 
 template<> ReferenceOp*
@@ -774,38 +733,32 @@
         referent = av;
         break;
       }
-    if (blk->getParent() && llvm::isa<Block>(blk->getParent()))
-      blk = llvm::cast<Block>(blk->getParent());
-    else
-      blk = 0;
+    blk = blk->getParentBlock();
   }
 
   // Didn't find an autovar, try a global variable
   if (!referent) {
-    referent = bundle->var_find(id);
-    hlvmAssert(referent && "Variable not found");
+    referent = bundle->find_var(id);
+    if (!referent) {
+      error(loc,std::string("Variable '") + id + "' not found");
+    }
   }
 
   return ast->AST::new_ReferenceOp(referent, loc);
 }
 
-StoreOp*
-XMLReaderImpl::parseStoreOp(xmlNodePtr& cur)
+template<> ConstantReferenceOp*
+XMLReaderImpl::parse<ConstantReferenceOp>(xmlNodePtr& cur)
 {
-  xmlNodePtr child = cur->children;
-  Value* oprnd1 = getValue(child);
-  Value* oprnd2 = getValue(child);
-  Locator* loc = getLocator(cur);
-  return ast->AST::new_BinaryOp<StoreOp>(oprnd1,oprnd2,loc);
-}
-
-LoadOp*
-XMLReaderImpl::parseLoadOp(xmlNodePtr& cur)
-{
-  xmlNodePtr child = cur->children;
-  Value* oprnd1 = getValue(child);
+  std::string id = getAttribute(cur,"id");
   Locator* loc = getLocator(cur);
-  return ast->AST::new_UnaryOp<LoadOp>(oprnd1,loc);
+  Constant* referent = bundle->find_const(id);
+  if (!referent) {
+    error(loc,std::string("Constant '") + id + 
+          "' not found. Substituting false.");
+    referent = ast->new_ConstantBoolean(false, getLocator(cur)); 
+  }
+  return ast->AST::new_ConstantReferenceOp(referent, loc);
 }
 
 template<class OpClass>
@@ -821,33 +774,68 @@
 OpClass*
 XMLReaderImpl::parseUnaryOp(xmlNodePtr& cur)
 {
-  xmlNodePtr child = cur->children;
-  Value* oprnd1 = getValue(child);
   Locator* loc = getLocator(cur);
-  return ast->AST::new_UnaryOp<OpClass>(oprnd1,loc);
+  xmlNodePtr child = cur->children;
+  if (child && skipBlanks(child)) {
+    Operator* oprnd1 = parseOperator(child);
+    return ast->AST::new_UnaryOp<OpClass>(oprnd1,loc);
+  } else
+    error(loc,std::string("Operator '") + 
+      reinterpret_cast<const char*>(cur->name) + "' requires one operand.");
+  return 0;
 }
 
 template<class OpClass>
 OpClass*
 XMLReaderImpl::parseBinaryOp(xmlNodePtr& cur)
 {
-  xmlNodePtr child = cur->children;
-  Value* oprnd1 = getValue(child);
-  Value* oprnd2 = getValue(child);
   Locator* loc = getLocator(cur);
-  return ast->AST::new_BinaryOp<OpClass>(oprnd1,oprnd2,loc);
+  xmlNodePtr child = cur->children;
+  if (child && skipBlanks(child)) {
+    Operator* oprnd1 = parseOperator(child);
+    child = child->next;
+    if (child && skipBlanks(child)) {
+      Operator* oprnd2 = parseOperator(child);
+      return ast->AST::new_BinaryOp<OpClass>(oprnd1,oprnd2,loc);
+    } else {
+      error(loc,std::string("Operator '") + 
+            reinterpret_cast<const char*>(cur->name) + 
+            "' needs a second operand.");
+    }
+  } else {
+    error(loc,std::string("Operator '") + 
+          reinterpret_cast<const char*>(cur->name) + "' requires 2 operands.");
+  }
+  return 0;
 }
 
 template<class OpClass>
 OpClass*
 XMLReaderImpl::parseTernaryOp(xmlNodePtr& cur)
 {
-  xmlNodePtr child = cur->children;
-  Value* oprnd1 = getValue(child);
-  Value* oprnd2 = getValue(child);
-  Value* oprnd3 = getValue(child);
   Locator* loc = getLocator(cur);
-  return ast->AST::new_TernaryOp<OpClass>(oprnd1,oprnd2,oprnd3,loc);
+  xmlNodePtr child = cur->children;
+  if (child && skipBlanks(child)) {
+    Operator* oprnd1 = parseOperator(child);
+    child = child->next;
+    if (child && skipBlanks(child)) {
+      Operator* oprnd2 = parseOperator(child);
+      child = child->next;
+      if (child && skipBlanks(child)) {
+        Operator* oprnd3 = parseOperator(child);
+        return ast->AST::new_TernaryOp<OpClass>(oprnd1,oprnd2,oprnd3,loc);
+      } else
+        error(loc,std::string("Operator '") + 
+              reinterpret_cast<const char*>(cur->name) +
+              "' needs a third operand.");
+    } else
+      error(loc,std::string("Operator '") + 
+            reinterpret_cast<const char*>(cur->name) + 
+            "' needs a second operand.");
+  } else
+    error(loc,std::string("Operator '") + 
+          reinterpret_cast<const char*>(cur->name) + "' requires 3 operands.");
+  return 0;
 }
 
 template<class OpClass>
@@ -856,11 +844,14 @@
 {
   Locator* loc = getLocator(cur);
   xmlNodePtr child = cur->children;
-  Value* operand = getValue(child);
   MultiOperator::OprndList ol;
-  while (operand != 0) {
-    ol.push_back(operand);
-    operand = getValue(child);
+  while (child != 0 && skipBlanks(child)) {
+    Operator* operand = parseOperator(child);
+    if (operand)
+      ol.push_back(operand);
+    else
+      break;
+    child = child->next;
   }
   return ast->AST::new_MultiOp<OpClass>(ol,loc);
 }
@@ -960,6 +951,7 @@
       case TKN_structure   : { n = parse<StructureType>(child); break; }
       case TKN_signature   : { n = parse<SignatureType>(child); break; }
       case TKN_opaque      : { n = parse<OpaqueType>(child); break; }
+      case TKN_constant    : { n = parseConstant(child); break; }
       case TKN_variable    : { n = parse<Variable>(child); break; }
       case TKN_program     : { n = parse<Program>(child); break; }
       case TKN_function    : { n = parse<Function>(child); break; }
@@ -991,10 +983,9 @@
     switch (tkn) {
       case TKN_intrinsic: {
         const char* is = getAttribute(child,"is");
-        if (!is)
-          hlvmAssert(!"intrinsic element requires 'is' attribute");
         result = create_builtin_type(ast,is,name,loc);
-        hlvmAssert(result && "Invalid intrinsic kind");
+        if (!result)
+          error(loc,"Invalid intrinsic kind");
         break;
       }
       case TKN_signed: {
@@ -1002,9 +993,7 @@
         if (bits) {
           uint64_t numBits = recognize_nonNegativeInteger(bits);
           result = ast->new_IntegerType(name,numBits,/*signed=*/true,loc);
-          break;
         }
-        hlvmAssert(!"Missing 'bits' attribute");
         break;
       }
       case TKN_unsigned: {
@@ -1012,9 +1001,7 @@
         if (bits) {
           uint64_t numBits = recognize_nonNegativeInteger(bits);
           result = ast->new_IntegerType(name,numBits,/*signed=*/false,loc);
-          break;
         }
-        hlvmAssert(!"Missing 'bits' attribute");
         break;
       }      
       case TKN_range: {
@@ -1024,9 +1011,7 @@
           int64_t minVal = recognize_Integer(min);
           int64_t maxVal = recognize_Integer(max);
           result = ast->new_RangeType(name,minVal,maxVal,loc);
-          break;
         }
-        hlvmAssert(!"Missing 'min' or 'max' attribute");
         break;
       }
       case TKN_real: {
@@ -1040,7 +1025,7 @@
         break;
       }
       default:
-        hlvmAssert(!"Invalid content for atom");
+        error(loc, "Invalid content for atom");
         break;
     }
     if (result) {
@@ -1049,178 +1034,66 @@
       return result;
     }
   }
-  hlvmAssert(!"Atom definition element expected");
+  error(loc,"Atom definition element expected");
   return 0;
 }
 
-inline Constant*
-XMLReaderImpl::parseConstant(xmlNodePtr& cur,const Type* Ty)
-{
-  return parseConstant(cur, Ty, getToken(cur->name));
-}
-
-Constant*
-XMLReaderImpl::parseConstant(xmlNodePtr& cur, const Type* Ty, int tkn)
-{
-  Constant* C = 0;
-  switch (tkn) {
-    case TKN_bin:          C = parseBinary(cur); break;
-    case TKN_oct:          C = parseOctal(cur); break;
-    case TKN_dec:          C = parseDecimal(cur); break;
-    case TKN_hex:          C = parseHexadecimal(cur); break;
-    case TKN_flt:          C = parseFloat(cur); break;
-    case TKN_dbl:          C = parseDouble(cur); break;
-    case TKN_text:         C = parseText(cur); break;
-    case TKN_false:        C = ast->new_ConstantBoolean(false); break;
-    case TKN_true:         C = ast->new_ConstantBoolean(true); break;
-    case TKN_zero:         C = parseZero(cur,Ty); break;
-    default:
-      hlvmAssert(!"Invalid kind of constant");
-      break;
-  }
-  return C;
-}
-
-
-inline Operator*
-XMLReaderImpl::parseOperator(xmlNodePtr& cur)
-{
-  return parseOperator(cur, getToken(cur->name));
-}
-
 Operator*
-XMLReaderImpl::parseOperator(xmlNodePtr& cur, int tkn)
-{
-  Operator* op = 0;
-  switch (tkn) {
-    case TKN_neg:          op = parseUnaryOp<NegateOp>(cur); break;
-    case TKN_cmpl:         op = parseUnaryOp<ComplementOp>(cur); break;
-    case TKN_preinc:       op = parseUnaryOp<PreIncrOp>(cur); break;
-    case TKN_predec:       op = parseUnaryOp<PreDecrOp>(cur); break;
-    case TKN_postinc:      op = parseUnaryOp<PostIncrOp>(cur); break;
-    case TKN_postdec:      op = parseUnaryOp<PostDecrOp>(cur); break;
-    case TKN_add:          op = parseBinaryOp<AddOp>(cur); break;
-    case TKN_sub:          op = parseBinaryOp<SubtractOp>(cur); break;
-    case TKN_mul:          op = parseBinaryOp<MultiplyOp>(cur); break;
-    case TKN_div:          op = parseBinaryOp<DivideOp>(cur); break;
-    case TKN_mod:          op = parseBinaryOp<ModuloOp>(cur); break;
-    case TKN_band:         op = parseBinaryOp<BAndOp>(cur); break;
-    case TKN_bor:          op = parseBinaryOp<BOrOp>(cur); break;
-    case TKN_bxor:         op = parseBinaryOp<BXorOp>(cur); break;
-    case TKN_bnor:         op = parseBinaryOp<BNorOp>(cur); break;
-    case TKN_noop:         op = parseNilaryOp<NoOperator>(cur); break;
-    case TKN_not:          op = parseUnaryOp<NotOp>(cur); break;
-    case TKN_and:          op = parseBinaryOp<AndOp>(cur); break;
-    case TKN_or:           op = parseBinaryOp<OrOp>(cur); break;
-    case TKN_nor:          op = parseBinaryOp<NorOp>(cur); break;
-    case TKN_xor:          op = parseBinaryOp<XorOp>(cur); break;
-    case TKN_eq:           op = parseBinaryOp<EqualityOp>(cur); break;
-    case TKN_ne:           op = parseBinaryOp<InequalityOp>(cur); break;
-    case TKN_lt:           op = parseBinaryOp<LessThanOp>(cur); break;
-    case TKN_gt:           op = parseBinaryOp<GreaterThanOp>(cur); break;
-    case TKN_ge:           op = parseBinaryOp<GreaterEqualOp>(cur); break;
-    case TKN_le:           op = parseBinaryOp<LessEqualOp>(cur); break;
-    case TKN_select:       op = parseTernaryOp<SelectOp>(cur); break;
-    case TKN_switch:       op = parseMultiOp<SwitchOp>(cur); break;
-    case TKN_loop:         op = parseTernaryOp<LoopOp>(cur); break;
-    case TKN_break:        op = parseNilaryOp<BreakOp>(cur); break;
-    case TKN_continue:     op = parseNilaryOp<ContinueOp>(cur); break;
-    case TKN_ret:          op = parseUnaryOp<ReturnOp>(cur); break;
-    case TKN_block:        op = parse<Block>(cur); break;
-    case TKN_store:        op = parseStoreOp(cur); break;
-    case TKN_load:         op = parseLoadOp(cur); break;
-    case TKN_open:         op = parseUnaryOp<OpenOp>(cur); break;
-    case TKN_write:        op = parseBinaryOp<WriteOp>(cur); break;
-    case TKN_close:        op = parseUnaryOp<CloseOp>(cur); break;
-    case TKN_ref:          op = parse<ReferenceOp>(cur); break;
-    case TKN_autovar:      op = parse<AutoVarOp>(cur); break;
-    default:
-      hlvmDeadCode("Unrecognized operator");
-      break;
-  }
-  return op;
-}
-
-inline Value*
-XMLReaderImpl::parseValue(xmlNodePtr& cur)
-{
-  return parseValue(cur,getToken(cur->name));
-}
-
-Value*
-XMLReaderImpl::parseValue(xmlNodePtr& cur, int tkn)
+XMLReaderImpl::parseOperator(xmlNodePtr& cur)
 {
-  Value* v = 0;
-  switch (tkn) {
-    case TKN_bin:
-    case TKN_oct:
-    case TKN_dec:
-    case TKN_hex:
-    case TKN_flt:
-    case TKN_dbl:
-    case TKN_text:
-    case TKN_zero:
-    case TKN_false:
-    case TKN_true:
-      v = parseConstant(cur,0,tkn);
-      break;
-    case TKN_noop:
-    case TKN_neg:
-    case TKN_cmpl:   
-    case TKN_preinc: 
-    case TKN_predec: 
-    case TKN_postinc:
-    case TKN_postdec:
-    case TKN_add:    
-    case TKN_sub:   
-    case TKN_mul:  
-    case TKN_div: 
-    case TKN_mod:
-    case TKN_band:       
-    case TKN_bor:       
-    case TKN_bxor:     
-    case TKN_bnor:    
-    case TKN_not:   
-    case TKN_and:  
-    case TKN_or:  
-    case TKN_nor:
-    case TKN_xor:
-    case TKN_eq: 
-    case TKN_ne: 
-    case TKN_lt: 
-    case TKN_gt: 
-    case TKN_ge:     
-    case TKN_le:      
-    case TKN_select: 
-    case TKN_switch: 
-    case TKN_loop:   
-    case TKN_break:  
-    case TKN_continue:
-    case TKN_ret:    
-    case TKN_store:  
-    case TKN_load:   
-    case TKN_open:   
-    case TKN_write:  
-    case TKN_close:  
-    case TKN_ref:    
-    case TKN_autovar: 
-    case TKN_block:  
-      v = parseOperator(cur,tkn);
-      break;
-    case TKN_program:
-      v = parse<Program>(cur);
-      break;
-    case TKN_function:
-      v = parse<Function>(cur);
-      break;
-    case TKN_variable:
-      v = parse<Variable>(cur);
-      break;
-    default:
-      hlvmDeadCode("Unrecognized operator");
-      break;
-  }
-  return v;
+  if (cur && skipBlanks(cur) && cur->type == XML_ELEMENT_NODE) {
+    Operator* op = 0;
+    switch (getToken(cur->name)) {
+      case TKN_neg:          op = parseUnaryOp<NegateOp>(cur); break;
+      case TKN_cmpl:         op = parseUnaryOp<ComplementOp>(cur); break;
+      case TKN_preinc:       op = parseUnaryOp<PreIncrOp>(cur); break;
+      case TKN_predec:       op = parseUnaryOp<PreDecrOp>(cur); break;
+      case TKN_postinc:      op = parseUnaryOp<PostIncrOp>(cur); break;
+      case TKN_postdec:      op = parseUnaryOp<PostDecrOp>(cur); break;
+      case TKN_add:          op = parseBinaryOp<AddOp>(cur); break;
+      case TKN_sub:          op = parseBinaryOp<SubtractOp>(cur); break;
+      case TKN_mul:          op = parseBinaryOp<MultiplyOp>(cur); break;
+      case TKN_div:          op = parseBinaryOp<DivideOp>(cur); break;
+      case TKN_mod:          op = parseBinaryOp<ModuloOp>(cur); break;
+      case TKN_band:         op = parseBinaryOp<BAndOp>(cur); break;
+      case TKN_bor:          op = parseBinaryOp<BOrOp>(cur); break;
+      case TKN_bxor:         op = parseBinaryOp<BXorOp>(cur); break;
+      case TKN_bnor:         op = parseBinaryOp<BNorOp>(cur); break;
+      case TKN_noop:         op = parseNilaryOp<NoOperator>(cur); break;
+      case TKN_not:          op = parseUnaryOp<NotOp>(cur); break;
+      case TKN_and:          op = parseBinaryOp<AndOp>(cur); break;
+      case TKN_or:           op = parseBinaryOp<OrOp>(cur); break;
+      case TKN_nor:          op = parseBinaryOp<NorOp>(cur); break;
+      case TKN_xor:          op = parseBinaryOp<XorOp>(cur); break;
+      case TKN_eq:           op = parseBinaryOp<EqualityOp>(cur); break;
+      case TKN_ne:           op = parseBinaryOp<InequalityOp>(cur); break;
+      case TKN_lt:           op = parseBinaryOp<LessThanOp>(cur); break;
+      case TKN_gt:           op = parseBinaryOp<GreaterThanOp>(cur); break;
+      case TKN_ge:           op = parseBinaryOp<GreaterEqualOp>(cur); break;
+      case TKN_le:           op = parseBinaryOp<LessEqualOp>(cur); break;
+      case TKN_select:       op = parseTernaryOp<SelectOp>(cur); break;
+      case TKN_switch:       op = parseMultiOp<SwitchOp>(cur); break;
+      case TKN_loop:         op = parseTernaryOp<LoopOp>(cur); break;
+      case TKN_break:        op = parseNilaryOp<BreakOp>(cur); break;
+      case TKN_continue:     op = parseNilaryOp<ContinueOp>(cur); break;
+      case TKN_ret:          op = parseUnaryOp<ReturnOp>(cur); break;
+      case TKN_store:        op = parseBinaryOp<StoreOp>(cur); break;
+      case TKN_load:         op = parseUnaryOp<LoadOp>(cur); break;
+      case TKN_open:         op = parseUnaryOp<OpenOp>(cur); break;
+      case TKN_write:        op = parseBinaryOp<WriteOp>(cur); break;
+      case TKN_close:        op = parseUnaryOp<CloseOp>(cur); break;
+      case TKN_ref:          op = parse<ReferenceOp>(cur); break;
+      case TKN_cref:         op = parse<ConstantReferenceOp>(cur); break;
+      case TKN_autovar:      op = parse<AutoVarOp>(cur); break;
+      case TKN_block:        op = parse<Block>(cur); break;
+      default:
+        hlvmDeadCode("Unrecognized operator");
+        break;
+    }
+    return op;
+  } else if (cur != 0)
+    hlvmDeadCode("Expecting a value");
+  return 0;
 }
 
 void
@@ -1228,7 +1101,7 @@
 {
   xmlNodePtr cur = xmlDocGetRootElement(doc);
   if (!cur) {
-    error("No root node");
+    error(0,"No root node");
     return;
   }
   hlvmAssert(getToken(cur->name) == TKN_hlvm && "Expecting hlvm element");
@@ -1250,7 +1123,7 @@
   xmlRelaxNGParserCtxtPtr rngparser =
     xmlRelaxNGNewMemParserCtxt(HLVMGrammar, sizeof(HLVMGrammar));
   if (!rngparser) {
-    error("Failed to allocate RNG Parser Context");
+    error(0,"Failed to allocate RNG Parser Context");
     return;
   }
 
@@ -1260,7 +1133,7 @@
   // Parse the schema and build an internal structure for it
   xmlRelaxNGPtr schema = xmlRelaxNGParse(rngparser);
   if (!schema) {
-    error("Failed to parse the RNG Schema");
+    error(0,"Failed to parse the RNG Schema");
     xmlRelaxNGFreeParserCtxt(rngparser);
     return;
   }
@@ -1268,7 +1141,7 @@
   // create a document parser context
   xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
   if (!ctxt) {
-    error("Failed to allocate document parser context");
+    error(0,"Failed to allocate document parser context");
     xmlRelaxNGFreeParserCtxt(rngparser);
     xmlRelaxNGFree(schema);
     return;
@@ -1277,7 +1150,7 @@
   // Parse the file, creating a Document tree
   doc = xmlCtxtReadFile(ctxt, path.c_str(), 0, 0);
   if (!doc) {
-    error("Failed to parse the document");
+    error(0,"Failed to parse the document");
     xmlRelaxNGFreeParserCtxt(rngparser);
     xmlRelaxNGFree(schema);
     xmlFreeParserCtxt(ctxt);
@@ -1287,7 +1160,7 @@
   // Create a validation context
   xmlRelaxNGValidCtxtPtr validation = xmlRelaxNGNewValidCtxt(schema);
   if (!validation) {
-    error("Failed to create the validation context");
+    error(0,"Failed to create the validation context");
     xmlRelaxNGFreeParserCtxt(rngparser);
     xmlRelaxNGFree(schema);
     xmlFreeParserCtxt(ctxt);
@@ -1301,7 +1174,7 @@
 
   // Validate the document with the schema
   if (xmlRelaxNGValidateDoc(validation, doc)) {
-    error("Document didn't pass RNG schema validation");
+    error(0,"Document didn't pass RNG schema validation");
     xmlRelaxNGFreeParserCtxt(rngparser);
     xmlRelaxNGFree(schema);
     xmlFreeParserCtxt(ctxt);

Modified: hlvm/trunk/hlvm/Runtime/Stream.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Runtime/Stream.cpp?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Runtime/Stream.cpp (original)
+++ hlvm/trunk/hlvm/Runtime/Stream.cpp Sat Jul  7 19:01:45 2007
@@ -62,17 +62,22 @@
       HLVM_APR(apr_file_write(this->fp, data, &nbytes),"writing a stream");
       return nbytes;
     }
+    hlvm_size write(const char* string) {
+      apr_size_t nbytes = strlen(string);
+      HLVM_APR(apr_file_write(this->fp, string, &nbytes),"writing a stream");
+      return nbytes;
+    }
   };
 }
 
 extern "C" {
 
 hlvm_stream
-hlvm_stream_open(hlvm_text uri)
+hlvm_stream_open(const char* uri)
 {
-  hlvm_assert(uri && uri->str);
+  hlvm_assert(uri);
   Stream* result = new Stream();
-  return result->open(uri->str);
+  return result->open(uri);
 }
 
 void 
@@ -101,4 +106,13 @@
   return strm->write(txt->str,txt->len);
 }
 
+hlvm_size 
+hlvm_stream_write_string(hlvm_stream stream, const char* string)
+{
+  hlvm_assert(stream);
+  hlvm_assert(string);
+  Stream* strm = static_cast<Stream*>(stream);
+  return strm->write(string);
+}
+
 }

Modified: hlvm/trunk/hlvm/Runtime/Stream.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Runtime/Stream.h?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Runtime/Stream.h (original)
+++ hlvm/trunk/hlvm/Runtime/Stream.h Sat Jul  7 19:01:45 2007
@@ -36,10 +36,13 @@
 typedef struct hlvm_buffer_obj* hlvm_buffer;
 
 extern hlvm_stream 
-hlvm_stream_open(hlvm_text uri);
+hlvm_stream_open(const char* uri);
 
 extern hlvm_size 
-hlvm_stream_write(hlvm_stream str, hlvm_buffer data, hlvm_size len);
+hlvm_stream_write_buffer(hlvm_stream str, hlvm_buffer data, hlvm_size len);
+
+extern hlvm_size 
+hlvm_stream_write_string(hlvm_stream str, const char* string);
 
 extern void 
 hlvm_op_file_close(hlvm_stream file);

Modified: hlvm/trunk/hlvm/Writer/Writer.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/Writer.h?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Writer/Writer.h (original)
+++ hlvm/trunk/hlvm/Writer/Writer.h Sat Jul  7 19:01:45 2007
@@ -33,6 +33,7 @@
 namespace hlvm {
 
 class AST;
+class Node;
 
 class Writer
 {
@@ -43,5 +44,9 @@
   virtual void write(AST* source) = 0;
 };
 
+#ifdef HLVM_DEBUG
+void dump(Node*);
+#endif
+
 }
 #endif

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

==============================================================================
--- hlvm/trunk/hlvm/Writer/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XMLWriter.cpp Sat Jul  7 19:01:45 2007
@@ -45,7 +45,6 @@
 #include <hlvm/Pass/Pass.h>
 #include <llvm/ADT/StringExtras.h>
 #include <libxml/xmlwriter.h>
-//#include <libxml/entities.h>
 #include <iostream>
 
 using namespace hlvm;
@@ -95,7 +94,7 @@
       { xmlTextWriterWriteElement(writer,
           reinterpret_cast<const xmlChar*>(elem),
           reinterpret_cast<const xmlChar*>(body)); }
-    inline void writeString(const std::string& text) ;
+    inline void writeString(const std::string& str) ;
 
     inline void putHeader();
     inline void putFooter();
@@ -132,10 +131,10 @@
 }
 
 void 
-XMLWriterImpl::WriterPass::writeString(const std::string& text)
+XMLWriterImpl::WriterPass::writeString(const std::string& str)
 { 
   const xmlChar* str_to_write = // xmlEncodeSpecialChars(
-      reinterpret_cast<const xmlChar*>(text.c_str()); // ); 
+      reinterpret_cast<const xmlChar*>(str.c_str()); // ); 
   xmlTextWriterWriteString(writer, str_to_write);
   // xmlMemFree(str_to_write);
 }
@@ -195,6 +194,17 @@
   endElement();
 }
 
+template<> void 
+XMLWriterImpl::WriterPass::put(StringType* t)
+{
+  startElement("atom");
+  writeAttribute("id",t->getName());
+  putDoc(t);
+  startElement("intrinsic");
+  writeAttribute("is","string");
+  endElement();
+}
+
 template<>void
 XMLWriterImpl::WriterPass::put(BooleanType* t)
 {
@@ -377,40 +387,52 @@
 template<> void 
 XMLWriterImpl::WriterPass::put<ConstantBoolean>(ConstantBoolean* i)
 {
+  startElement("constant");
+  writeAttribute("id",i->getName());
+  writeAttribute("type",i->getType()->getName());
   if (i->getValue())
     startElement("true");
   else
     startElement("false");
+  endElement();
 }
 
 template<> void 
 XMLWriterImpl::WriterPass::put<ConstantInteger>(ConstantInteger* i)
 {
-  startElement("dec");
-  if (cast<IntegerType>(i->getType())->isSigned())
-    writeString(llvm::itostr(i->getValue()));
-  else
-    writeString(llvm::utostr(i->getValue(0)));
+  startElement("constant");
+  writeAttribute("id",i->getName());
+  writeAttribute("type",i->getType()->getName());
+  switch (i->getBase()) {
+    case 2: startElement("bin"); break;
+    case 8: startElement("oct"); break;
+    case 16: startElement("hex"); break;
+    default: startElement("dec"); break;
+  }
+  writeString(i->getValue());
+  endElement();
 }
 
 template<> void
 XMLWriterImpl::WriterPass::put<ConstantReal>(ConstantReal* r)
 {
+  startElement("constant");
+  writeAttribute("id",r->getName());
+  writeAttribute("type",r->getType()->getName());
   startElement("dbl");
-  writeString(llvm::ftostr(r->getValue()));
+  writeString(r->getValue());
+  endElement();
 }
 
 template<> void
-XMLWriterImpl::WriterPass::put<ConstantText>(ConstantText* t)
+XMLWriterImpl::WriterPass::put<ConstantString>(ConstantString* t)
 {
-  startElement("text");
+  startElement("constant");
+  writeAttribute("id",t->getName());
+  writeAttribute("type",t->getType()->getName());
+  startElement("string");
   writeString(t->getValue());
-}
-
-template<> void
-XMLWriterImpl::WriterPass::put<ConstantZero>(ConstantZero* t)
-{
-  startElement("zero");
+  endElement();
 }
 
 template<> void
@@ -419,6 +441,10 @@
   startElement("variable");
   writeAttribute("id",v->getName());
   writeAttribute("type",v->getType()->getName());
+  if (v->hasInitializer()) {
+    Constant* C = llvm::cast<Constant>(v->getInitializer());
+    writeAttribute("id",C->getName());
+  }
   putDoc(v);
 }
 
@@ -455,6 +481,10 @@
   startElement("autovar");
   writeAttribute("id",av->getName());
   writeAttribute("type",av->getType()->getName());
+  if (av->hasInitializer()) {
+    Constant* C = llvm::cast<Constant>(av->getInitializer());
+    writeAttribute("init",C->getName());
+  }
   putDoc(av);
 }
 
@@ -703,6 +733,13 @@
   putDoc(r);
 }
 
+template<> void
+XMLWriterImpl::WriterPass::put(ConstantReferenceOp* cr)
+{
+  startElement("cref");
+  writeAttribute("id",cr->getReferent()->getName());
+}
+
 template<> void 
 XMLWriterImpl::WriterPass::put(ReferenceOp* r)
 {
@@ -752,6 +789,7 @@
     {
       case AliasTypeID:          put(cast<AliasType>(n)); break;
       case AnyTypeID:            put(cast<AnyType>(n)); break;
+      case StringTypeID:         put(cast<StringType>(n)); break;
       case BooleanTypeID:        put(cast<BooleanType>(n)); break;
       case BundleID:             put(cast<Bundle>(n)); break;
       case CharacterTypeID:      put(cast<CharacterType>(n)); break;
@@ -770,8 +808,7 @@
       case ConstantBooleanID:    put(cast<ConstantBoolean>(n)); break;
       case ConstantIntegerID:    put(cast<ConstantInteger>(n)); break;
       case ConstantRealID:       put(cast<ConstantReal>(n)); break;
-      case ConstantTextID:       put(cast<ConstantText>(n)); break;
-      case ConstantZeroID:       put(cast<ConstantZero>(n)); break;
+      case ConstantStringID:     put(cast<ConstantString>(n)); break;
       case VariableID:           put(cast<Variable>(n)); break;
       case FunctionID:           put(cast<Function>(n)); break;
       case ProgramID:            put(cast<Program>(n)); break;
@@ -812,6 +849,7 @@
       case ReturnOpID:           put(cast<ReturnOp>(n)); break;
       case StoreOpID:            put(cast<StoreOp>(n)); break;
       case LoadOpID:             put(cast<LoadOp>(n)); break;
+      case ConstantReferenceOpID:put(cast<ConstantReferenceOp>(n)); break;
       case ReferenceOpID:        put(cast<ReferenceOp>(n)); break;
       case OpenOpID:             put(cast<OpenOp>(n)); break;
       case CloseOpID:            put(cast<CloseOp>(n)); break;
@@ -844,3 +882,8 @@
 {
   return new XMLWriterImpl(fname);
 }
+
+void 
+hlvm::dump(Node*)
+{
+}

Added: hlvm/trunk/test/return0/arithmetic.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/arithmetic.hlx?rev=38263&view=auto

==============================================================================
--- hlvm/trunk/test/return0/arithmetic.hlx (added)
+++ hlvm/trunk/test/return0/arithmetic.hlx Sat Jul  7 19:01:45 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/arithmetic.hlx">
+  <bundle id="arithmetic">
+    <constant id="42" type="s32"><dec>42</dec></constant>
+    <constant id="7" type="s32"><dec>7</dec></constant>
+    <constant id="1" type="s32"><dec>1</dec></constant>
+    <constant id="2" type="s32"><dec>2</dec></constant>
+    <constant id="8" type="s32"><dec>8</dec></constant>
+    <program id="arithmetic">
+      <block>
+        <ret>
+          <sub>
+            <add>
+              <mul>
+                <div>
+                  <cref id="42"/>
+                  <cref id="7"/>
+                </div>
+                <cref id="1"/>
+              </mul>
+              <cref id="2"/>
+            </add>
+            <cref id="8"/>
+          </sub>
+        </ret>
+      </block>
+    </program>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/return0/bitwise.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/bitwise.hlx?rev=38263&view=auto

==============================================================================
--- hlvm/trunk/test/return0/bitwise.hlx (added)
+++ hlvm/trunk/test/return0/bitwise.hlx Sat Jul  7 19:01:45 2007
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/bitwise.hlx">
+  <bundle id="bitwise">
+    <constant id="0f0f0f0f" type="u32"><hex>0f0f0f0f</hex></constant>
+    <constant id="08080808" type="u32"><hex>08080808</hex></constant>
+    <constant id="04040404" type="u32"><hex>04040404</hex></constant>
+    <constant id="00000000" type="u32"><hex>00000000</hex></constant>
+    <program id="bitwise">
+      <block>
+        <ret>
+          <band>
+            <bnor>
+              <bor>
+                <bxor>
+                  <cref id="0f0f0f0f"/>
+                  <cref id="08080808"/>
+                </bxor>
+                <cref id="04040404"/>
+              </bor>
+              <cref id="0f0f0f0f"/>
+            </bnor>
+            <cref id="00000000"/>
+          </band>
+        </ret>
+      </block>
+    </program>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/return0/boolean.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/boolean.hlx?rev=38263&view=auto

==============================================================================
--- hlvm/trunk/test/return0/boolean.hlx (added)
+++ hlvm/trunk/test/return0/boolean.hlx Sat Jul  7 19:01:45 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/boolean.hlx">
+  <bundle id="boolean">
+    <constant id="true" type="bool"><true/></constant>
+    <constant id="false" type="bool"><false/></constant>
+    <program id="boolean">
+      <block>
+        <ret>
+          <and>
+            <nor>
+              <or>
+                <xor>
+                  <cref id="true"/>
+                  <cref id="false"/>
+                </xor>
+                <cref id="false"/>
+              </or>
+              <cref id="true"/>
+            </nor>
+            <cref id="false"/>
+          </and>
+        </ret>
+      </block>
+    </program>
+  </bundle>
+</hlvm>

Modified: hlvm/trunk/test/return0/complement.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/complement.hlx?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/test/return0/complement.hlx (original)
+++ hlvm/trunk/test/return0/complement.hlx Sat Jul  7 19:01:45 2007
@@ -3,9 +3,15 @@
   <bundle id="complement">
     <program id="complement">
       <block>
-        <autovar id="v" type="s32"><zero/></autovar>
+        <autovar id="v" type="s32"/>
         <ret>
-          <cmpl><cmpl><load><ref id="v"/></load></cmpl></cmpl>
+          <cmpl>
+            <cmpl>
+              <load>
+                <ref id="v"/>
+              </load>
+            </cmpl>
+          </cmpl>
         </ret>
       </block>
     </program>

Modified: hlvm/trunk/test/return0/helloworld.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/helloworld.hlx?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/test/return0/helloworld.hlx (original)
+++ hlvm/trunk/test/return0/helloworld.hlx Sat Jul  7 19:01:45 2007
@@ -1,23 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng"
-      pubid="http://hlvm.org/src/hlvm/test/xml2xml/helloworld.hlx">
+      pubid="http://hlvm.org/src/hlvm/test/return0/helloworld.hlx">
   <bundle id="helloworld">
+    <constant id="hw" type="string">
+      <string>Hello, World
</string>
+    </constant>
+    <constant id="stdout" type="string">
+      <string>hlvm:std:out</string>
+    </constant>
+    <constant id="zero" type="s32">
+      <dec>0</dec>
+    </constant>
     <program id="helloworld">
       <block>
-        <autovar id="stdout" type="stream"><zero/></autovar>
+        <autovar id="stdout" type="stream"></autovar>
         <store>
           <ref id="stdout"/>
-          <open><text>hlvm:std:out</text></open>
+          <open><cref id="stdout"/></open>
         </store>
         <write>
           <load><ref id="stdout"/></load>
-          <text>Hello, World
</text>
+          <cref id="hw"/>
         </write>
         <close>
           <load><ref id="stdout"/></load>
         </close>
         <ret>
-          <dec>0</dec>
+          <cref id="zero"/>
         </ret>
       </block>
     </program>

Modified: hlvm/trunk/test/return0/return0.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/return0/return0.hlx?rev=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/test/return0/return0.hlx (original)
+++ hlvm/trunk/test/return0/return0.hlx Sat Jul  7 19:01:45 2007
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/return0.hlx">
   <bundle id="return0">
+    <constant id="zero" type="s32"><dec>0</dec></constant>
     <program id="return0">
       <block>
         <ret>
-          <dec>0</dec>
+          <cref id="zero"/>
         </ret>
       </block>
     </program>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/arithmetic.hlx (original)
+++ hlvm/trunk/test/xml2xml/arithmetic.hlx Sat Jul  7 19:01:45 2007
@@ -1,33 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/unaryarithmetic.hlx">
   <bundle id="unaryarithmetic">
+    <constant id="one" type="u32">
+      <dec>1</dec>
+    </constant>
     <program id="unaryarithmetic">
       <block>
-        <autovar id="v1" type="u32">
-          <zero/>
-        </autovar>
-        <autovar id="v2" type="u32">
-          <zero/>
-        </autovar>
+        <autovar id="v1" type="u32"/>
+        <autovar id="v2" type="u32"/>
         <preinc>
-          <load>
-            <ref id="v1"/>
-          </load>
+          <ref id="v1"/>
         </preinc>
         <postinc>
-          <load>
-            <ref id="v1"/>
-          </load>
+          <ref id="v1"/>
         </postinc>
         <postdec>
-          <load>
-            <ref id="v2"/>
-          </load>
+          <ref id="v2"/>
         </postdec>
         <predec>
-          <load>
-            <ref id="v2"/>
-          </load>
+          <ref id="v2"/>
         </predec>
         <neg>
           <load>
@@ -43,13 +34,13 @@
           <load>
             <ref id="v1"/>
           </load>
-          <dec>1</dec>
+          <cref id="one"/>
         </add>
         <sub>
           <load>
             <ref id="v1"/>
           </load>
-          <dec>1</dec>
+          <cref id="one"/>
         </sub>
         <mul>
           <load>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/autovar.hlx (original)
+++ hlvm/trunk/test/xml2xml/autovar.hlx Sat Jul  7 19:01:45 2007
@@ -3,9 +3,7 @@
   <bundle id="autovar">
     <program id="autovar">
       <block>
-        <autovar id="v1" type="u32">
-          <zero/>
-        </autovar>
+        <autovar id="v1" type="u32"/>
       </block>
     </program>
   </bundle>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/booleanops.hlx (original)
+++ hlvm/trunk/test/xml2xml/booleanops.hlx Sat Jul  7 19:01:45 2007
@@ -1,14 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/unaryarithmetic.hlx">
-  <bundle id="unaryarithmetic">
-    <program id="unaryarithmetic">
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/booleanops.hlx">
+  <bundle id="booleanops">
+    <constant id="false" type="bool">
+      <false/>
+    </constant>
+    <constant id="true" type="bool">
+      <true/>
+    </constant>
+    <program id="booleanops">
       <block>
-        <autovar id="v1" type="bool">
-          <true/>
-        </autovar>
-        <autovar id="v2" type="bool">
-          <false/>
-        </autovar>
+        <autovar id="v1" type="bool" init="true"/>
+        <autovar id="v2" type="bool" init="false"/>
         <not>
           <load>
             <ref id="v1"/>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/helloworld.hlx (original)
+++ hlvm/trunk/test/xml2xml/helloworld.hlx Sat Jul  7 19:01:45 2007
@@ -1,22 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/helloworld.hlx">
   <bundle id="helloworld">
+    <constant id="0" type="s32">
+      <dec>0</dec>
+    </constant>
+    <constant id="hw" type="string">
+      <string>Hello, World</string>
+    </constant>
+    <constant id="stdout" type="string">
+      <string>hlvm:std:out</string>
+    </constant>
     <program id="helloworld">
       <block>
-        <autovar id="stdout" type="stream">
-          <zero/>
-        </autovar>
+        <autovar id="stdout" type="stream"/>
         <store>
           <ref id="stdout"/>
           <open>
-            <text>hlvm:std:out</text>
+            <cref id="stdout"/>
           </open>
         </store>
         <write>
           <load>
             <ref id="stdout"/>
           </load>
-          <text>Hello, World</text>
+          <cref id="hw"/>
         </write>
         <close>
           <load>
@@ -24,7 +31,7 @@
           </load>
         </close>
         <ret>
-          <dec>0</dec>
+          <cref id="0"/>
         </ret>
       </block>
     </program>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/loop.hlx (original)
+++ hlvm/trunk/test/xml2xml/loop.hlx Sat Jul  7 19:01:45 2007
@@ -1,12 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/return.hlx">
   <bundle id="return">
+    <constant id="0" type="s32">
+      <dec>0</dec>
+    </constant>
+    <constant id="1" type="s32">
+      <dec>1</dec>
+    </constant>
     <program id="return">
       <block>
         <ret>
           <loop>
-            <dec>1</dec>
-            <dec>0</dec>
+            <ne>
+              <cref id="1"/>
+              <cref id="0"/>
+            </ne>
+            <cref id="0"/>
             <noop/>
           </loop>
         </ret>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/return.hlx (original)
+++ hlvm/trunk/test/xml2xml/return.hlx Sat Jul  7 19:01:45 2007
@@ -1,10 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/return.hlx">
   <bundle id="return">
+    <constant id="42" type="s32">
+      <dec>42</dec>
+    </constant>
     <program id="return">
       <block>
         <ret>
-          <dec>42</dec>
+          <cref id="42"/>
         </ret>
       </block>
     </program>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/select.hlx (original)
+++ hlvm/trunk/test/xml2xml/select.hlx Sat Jul  7 19:01:45 2007
@@ -1,13 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/return.hlx">
   <bundle id="return">
+    <constant id="0" type="s32">
+      <dec>0</dec>
+    </constant>
+    <constant id="21" type="s32">
+      <dec>21</dec>
+    </constant>
+    <constant id="42" type="s32">
+      <dec>42</dec>
+    </constant>
     <program id="return">
       <block>
         <ret>
           <select>
-            <dec>0</dec>
-            <dec>42</dec>
-            <dec>21</dec>
+            <ne>
+              <cref id="0"/>
+              <cref id="21"/>
+            </ne>
+            <cref id="42"/>
+            <cref id="21"/>
           </select>
         </ret>
       </block>

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

==============================================================================
--- hlvm/trunk/test/xml2xml/switch.hlx (original)
+++ hlvm/trunk/test/xml2xml/switch.hlx Sat Jul  7 19:01:45 2007
@@ -1,24 +1,48 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/xml2xml/return.hlx">
   <bundle id="return">
+    <constant id="0" type="s32">
+      <dec>0</dec>
+    </constant>
+    <constant id="1" type="s32">
+      <dec>1</dec>
+    </constant>
+    <constant id="2" type="s32">
+      <dec>2</dec>
+    </constant>
+    <constant id="21" type="s32">
+      <dec>21</dec>
+    </constant>
+    <constant id="3" type="s32">
+      <dec>3</dec>
+    </constant>
+    <constant id="4" type="s32">
+      <dec>4</dec>
+    </constant>
+    <constant id="42" type="s32">
+      <dec>42</dec>
+    </constant>
+    <constant id="5" type="s32">
+      <dec>5</dec>
+    </constant>
     <program id="return">
       <block>
         <ret>
           <switch>
-            <dec>6</dec>
-            <dec>0</dec>
-            <dec>1</dec>
-            <dec>1</dec>
-            <dec>2</dec>
-            <dec>2</dec>
-            <dec>3</dec>
-            <dec>3</dec>
-            <dec>4</dec>
-            <dec>4</dec>
-            <dec>5</dec>
-            <dec>5</dec>
-            <dec>42</dec>
-            <dec>21</dec>
+            <cref id="42"/>
+            <cref id="42"/>
+            <cref id="1"/>
+            <cref id="1"/>
+            <cref id="2"/>
+            <cref id="2"/>
+            <cref id="3"/>
+            <cref id="3"/>
+            <cref id="4"/>
+            <cref id="4"/>
+            <cref id="5"/>
+            <cref id="5"/>
+            <cref id="42"/>
+            <cref id="21"/>
           </switch>
         </ret>
       </block>

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=38263&r1=38262&r2=38263&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp (original)
+++ hlvm/trunk/tools/hlvm-compiler/hlvm-compiler.cpp Sat Jul  7 19:01:45 2007
@@ -114,12 +114,8 @@
     rdr->read();
     AST* node = rdr->get();
     if (node && Validate) {
-      PassManager* PM = PassManager::create();
-      Pass* pass = Pass::new_ValidatePass(); 
-      PM->addPass( pass );
-      PM->runOn(node);
-      delete PM;
-      delete pass;
+      if (!validate(node))
+        return 3;
     }
     if (WhatToGenerate == GenLLVMBytecode) {
       generateBytecode(node,*Out);

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

==============================================================================
--- hlvm/trunk/tools/hlvm-config/hlvm-config.cpp (original)
+++ hlvm/trunk/tools/hlvm-config/hlvm-config.cpp Sat Jul  7 19:01:45 2007
@@ -65,6 +65,7 @@
   "Float80Type",
   "Float128Type",
   "AnyType",
+  "StringType",
   "IntegerType",
   "RangeType",
   "EnumerationType",
@@ -88,7 +89,7 @@
   "ConstantBoolean",
   "ConstantInteger",
   "ConstantReal",
-  "ConstantText",
+  "ConstantString",
   "ConstantAggregate",
   "ConstantExpression",
   "SizeOf",





More information about the llvm-commits mailing list