[llvm-commits] [hlvm] r38067 - in /hlvm/trunk: hlvm/AST/ hlvm/Reader/ hlvm/Reader/XML/ hlvm/Writer/ hlvm/Writer/XML/ tools/hlvm-xml2xml/
Reid Spencer
reid at x10sys.com
Sat Jul 7 16:59:31 PDT 2007
Author: reid
Date: Sat Jul 7 18:59:30 2007
New Revision: 38067
URL: http://llvm.org/viewvc/llvm-project?rev=38067&view=rev
Log:
Two stylistic changes:
1. Don't use double namespaces, hlvm is sufficient.
2. Don't indent inside namespaces, it just wastes horizontal space.
Modified:
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/Conditionable.h
hlvm/trunk/hlvm/AST/ContainerType.cpp
hlvm/trunk/hlvm/AST/ContainerType.h
hlvm/trunk/hlvm/AST/Documentation.cpp
hlvm/trunk/hlvm/AST/Documentation.h
hlvm/trunk/hlvm/AST/Function.cpp
hlvm/trunk/hlvm/AST/Function.h
hlvm/trunk/hlvm/AST/Import.cpp
hlvm/trunk/hlvm/AST/Import.h
hlvm/trunk/hlvm/AST/LinkageItem.cpp
hlvm/trunk/hlvm/AST/LinkageItem.h
hlvm/trunk/hlvm/AST/Locator.h
hlvm/trunk/hlvm/AST/Node.cpp
hlvm/trunk/hlvm/AST/Node.h
hlvm/trunk/hlvm/AST/Operator.cpp
hlvm/trunk/hlvm/AST/Operator.h
hlvm/trunk/hlvm/AST/Program.cpp
hlvm/trunk/hlvm/AST/Program.h
hlvm/trunk/hlvm/AST/SymbolTable.cpp
hlvm/trunk/hlvm/AST/SymbolTable.h
hlvm/trunk/hlvm/AST/Type.cpp
hlvm/trunk/hlvm/AST/Type.h
hlvm/trunk/hlvm/AST/Variable.cpp
hlvm/trunk/hlvm/AST/Variable.h
hlvm/trunk/hlvm/Reader/Reader.h
hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
hlvm/trunk/hlvm/Reader/XML/XMLReader.h
hlvm/trunk/hlvm/Writer/Writer.h
hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
hlvm/trunk/hlvm/Writer/XML/XMLWriter.h
hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
Modified: hlvm/trunk/hlvm/AST/AST.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/AST.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/AST.cpp (original)
+++ hlvm/trunk/hlvm/AST/AST.cpp Sat Jul 7 18:59:30 2007
@@ -36,7 +36,7 @@
#include <hlvm/AST/Variable.h>
#include <hlvm/AST/SymbolTable.h>
-using namespace hlvm::AST;
+using namespace hlvm;
namespace {
class ASTImpl : public AST
@@ -90,7 +90,6 @@
}
namespace hlvm {
-namespace AST {
AST*
AST::create()
@@ -351,4 +350,4 @@
return result;
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/AST.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/AST.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/AST.h (original)
+++ hlvm/trunk/hlvm/AST/AST.h Sat Jul 7 18:59:30 2007
@@ -37,182 +37,179 @@
/// elsewhere.
namespace hlvm
{
-/// This namespace contains all the AST (Abstract Syntax Tree) module code. All
-/// node types of the AST are declared in this namespace.
-namespace AST
+
+class Bundle;
+class Documentation;
+class Function;
+class Import;
+class Locator;
+class SignatureType;
+class Type;
+class Variable;
+class AnyType;
+class BooleanType;
+class CharacterType;
+class OctetType;
+class VoidType;
+class IntegerType;
+class RangeType;
+class RealType;
+class PointerType;
+class VectorType;
+class ArrayType;
+class AliasType;
+class StructureType;
+class SignatureType;
+class OpaqueType;
+class EnumerationType;
+
+/// This class is used to hold or contain an Abstract Syntax Tree. It provides
+/// those aspects of the tree that are not part of the tree itself.
+/// @brief AST Container Class
+class AST
{
- class Bundle;
- class Documentation;
- class Function;
- class Import;
- class Locator;
- class SignatureType;
- class Type;
- class Variable;
- class AnyType;
- class BooleanType;
- class CharacterType;
- class OctetType;
- class VoidType;
- class IntegerType;
- class RangeType;
- class RealType;
- class PointerType;
- class VectorType;
- class ArrayType;
- class AliasType;
- class StructureType;
- class SignatureType;
- class OpaqueType;
- class EnumerationType;
-
- /// This class is used to hold or contain an Abstract Syntax Tree. It provides
- /// those aspects of the tree that are not part of the tree itself.
- /// @brief AST Container Class
- class AST
- {
- /// @name Constructors
- /// @{
- public:
- static AST* create();
- static void destroy(AST* ast);
-
- protected:
- AST() : sysid(), pubid(), root(0) {}
- ~AST();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- const std::string& getSystemID() { return sysid; }
- const std::string& getPublicID() { return pubid; }
- Bundle* getRoot() { return root; }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- void setSystemID(const std::string& id) { sysid = id; }
- void setPublicID(const std::string& id) { pubid = id; }
- void setRoot(Bundle* top) { root = top; }
-
- /// @}
- /// @name Lookup
- /// @{
- public:
- Type* resolveType(const std::string& name);
-
- /// @}
- /// @name Factories
- /// @{
- public:
- Bundle* new_Bundle(const Locator& loc, const std::string& id);
- Function* new_Function(const Locator& loc, const std::string& id);
- Import* new_Import(const Locator& loc, const std::string& id);
- Variable* new_Variable(const Locator& loc, const std::string& id);
- IntegerType* new_IntegerType(
- const Locator&loc, ///< The locator of the declaration
- const std::string& id, ///< The name of the atom
- uint64_t bits = 32, ///< The number of bits
- bool isSigned = true ///< The signedness
- );
- RangeType* new_RangeType(
- const Locator&loc, ///< The locator of the declaration
- const std::string& id, ///< The name of the atom
- int64_t min, ///< The minimum value accepted in range
- int64_t max ///< The maximum value accepted in range
- );
- EnumerationType* new_EnumerationType(
- const Locator&loc, ///< The locator of the declaration
- const std::string& id ///< The name of the atom
- );
- RealType* new_RealType(
- const Locator&loc, ///< The locator of the declaration
- const std::string& id, ///< The name of the atom
- uint32_t mantissa = 52, ///< The bits in the mantissa (fraction)
- uint32_t exponent = 11 ///< The bits in the exponent
- );
- AnyType* new_AnyType(const Locator&loc, const std::string& id);
- BooleanType*
- new_BooleanType(const Locator&loc, const std::string& id);
- CharacterType*
- new_CharacterType(const Locator&loc, const std::string& id);
- OctetType*
- new_OctetType(const Locator&loc, const std::string& id);
- VoidType* new_VoidType(const Locator&loc, const std::string& id);
- PointerType* new_PointerType(
- const Locator& loc,
- const std::string& id,
- Type* target
- );
- ArrayType* new_ArrayType(
- const Locator& loc,
- const std::string& id,
- Type* elemType,
- uint64_t maxSize
- );
- VectorType* new_VectorType(
- const Locator& loc,
- const std::string& id,
- Type* elemType,
- uint64_t size
- );
- AliasType* new_AliasType(
- const Locator& loc,
- const std::string& id,
- Type* referrant
- );
- StructureType*
- new_StructureType(const Locator& l, const std::string& id);
- SignatureType* new_SignatureType(
- const Locator& loc,
- const std::string& id,
- Type *resultType
- );
- OpaqueType* new_OpaqueType(const std::string& id);
- RealType* new_f128(const Locator& l, const std::string& id)
- { return new_RealType(l,id,112,15); }
- RealType* new_f80(const Locator& l, const std::string& id)
- { return new_RealType(l,id,64,15); }
- RealType* new_f64(const Locator& l, const std::string& id)
- { return new_RealType(l,id,52,11); }
- RealType* new_f43(const Locator& l, const std::string& id)
- { return new_RealType(l,id,32,11); }
- RealType* new_f32(const Locator& l, const std::string& id)
- { return new_RealType(l,id,23,8); }
- IntegerType* new_s128(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,128,true); }
- IntegerType* new_s64(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,64,true); }
- IntegerType* new_s32(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,32,true); }
- IntegerType* new_s16(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,16,true); }
- IntegerType* new_s8(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,8,true); }
- IntegerType* new_u128(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,128,false); }
- IntegerType* new_u64(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,64,false); }
- IntegerType* new_u32(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,32,false); }
- IntegerType* new_u16(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,16,false); }
- IntegerType* new_u8(const Locator& l, const std::string& id)
- { return new_IntegerType(l,id,8,false); }
-
- Documentation* new_Documentation(const Locator& loc);
-
- /// @}
- /// @name Data
- /// @{
- protected:
- std::string sysid;
- std::string pubid;
- Bundle* root;
- /// @}
- };
-} // AST
+ /// @name Constructors
+ /// @{
+ public:
+ static AST* create();
+ static void destroy(AST* ast);
+
+ protected:
+ AST() : sysid(), pubid(), root(0) {}
+ ~AST();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ const std::string& getSystemID() { return sysid; }
+ const std::string& getPublicID() { return pubid; }
+ Bundle* getRoot() { return root; }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ void setSystemID(const std::string& id) { sysid = id; }
+ void setPublicID(const std::string& id) { pubid = id; }
+ void setRoot(Bundle* top) { root = top; }
+
+ /// @}
+ /// @name Lookup
+ /// @{
+ public:
+ Type* resolveType(const std::string& name);
+
+ /// @}
+ /// @name Factories
+ /// @{
+ public:
+ Bundle* new_Bundle(const Locator& loc, const std::string& id);
+ Function* new_Function(const Locator& loc, const std::string& id);
+ Import* new_Import(const Locator& loc, const std::string& id);
+ Variable* new_Variable(const Locator& loc, const std::string& id);
+ IntegerType* new_IntegerType(
+ const Locator&loc, ///< The locator of the declaration
+ const std::string& id, ///< The name of the atom
+ uint64_t bits = 32, ///< The number of bits
+ bool isSigned = true ///< The signedness
+ );
+ RangeType* new_RangeType(
+ const Locator&loc, ///< The locator of the declaration
+ const std::string& id, ///< The name of the atom
+ int64_t min, ///< The minimum value accepted in range
+ int64_t max ///< The maximum value accepted in range
+ );
+ EnumerationType* new_EnumerationType(
+ const Locator&loc, ///< The locator of the declaration
+ const std::string& id ///< The name of the atom
+ );
+ RealType* new_RealType(
+ const Locator&loc, ///< The locator of the declaration
+ const std::string& id, ///< The name of the atom
+ uint32_t mantissa = 52, ///< The bits in the mantissa (fraction)
+ uint32_t exponent = 11 ///< The bits in the exponent
+ );
+ AnyType* new_AnyType(const Locator&loc, const std::string& id);
+ BooleanType*
+ new_BooleanType(const Locator&loc, const std::string& id);
+ CharacterType*
+ new_CharacterType(const Locator&loc, const std::string& id);
+ OctetType*
+ new_OctetType(const Locator&loc, const std::string& id);
+ VoidType* new_VoidType(const Locator&loc, const std::string& id);
+ PointerType* new_PointerType(
+ const Locator& loc,
+ const std::string& id,
+ Type* target
+ );
+ ArrayType* new_ArrayType(
+ const Locator& loc,
+ const std::string& id,
+ Type* elemType,
+ uint64_t maxSize
+ );
+ VectorType* new_VectorType(
+ const Locator& loc,
+ const std::string& id,
+ Type* elemType,
+ uint64_t size
+ );
+ AliasType* new_AliasType(
+ const Locator& loc,
+ const std::string& id,
+ Type* referrant
+ );
+ StructureType*
+ new_StructureType(const Locator& l, const std::string& id);
+ SignatureType* new_SignatureType(
+ const Locator& loc,
+ const std::string& id,
+ Type *resultType
+ );
+ OpaqueType* new_OpaqueType(const std::string& id);
+ RealType* new_f128(const Locator& l, const std::string& id)
+ { return new_RealType(l,id,112,15); }
+ RealType* new_f80(const Locator& l, const std::string& id)
+ { return new_RealType(l,id,64,15); }
+ RealType* new_f64(const Locator& l, const std::string& id)
+ { return new_RealType(l,id,52,11); }
+ RealType* new_f43(const Locator& l, const std::string& id)
+ { return new_RealType(l,id,32,11); }
+ RealType* new_f32(const Locator& l, const std::string& id)
+ { return new_RealType(l,id,23,8); }
+ IntegerType* new_s128(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,128,true); }
+ IntegerType* new_s64(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,64,true); }
+ IntegerType* new_s32(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,32,true); }
+ IntegerType* new_s16(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,16,true); }
+ IntegerType* new_s8(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,8,true); }
+ IntegerType* new_u128(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,128,false); }
+ IntegerType* new_u64(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,64,false); }
+ IntegerType* new_u32(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,32,false); }
+ IntegerType* new_u16(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,16,false); }
+ IntegerType* new_u8(const Locator& l, const std::string& id)
+ { return new_IntegerType(l,id,8,false); }
+
+ Documentation* new_Documentation(const Locator& loc);
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::string sysid;
+ std::string pubid;
+ Bundle* root;
+ /// @}
+};
+
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Block.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Block.cpp (original)
+++ hlvm/trunk/hlvm/AST/Block.cpp Sat Jul 7 18:59:30 2007
@@ -30,9 +30,9 @@
#include <hlvm/AST/Block.h>
namespace hlvm {
-namespace AST {
Block::~Block()
{
}
-}}
+
+}
Modified: hlvm/trunk/hlvm/AST/Block.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Block.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Block.h (original)
+++ hlvm/trunk/hlvm/AST/Block.h Sat Jul 7 18:59:30 2007
@@ -32,63 +32,63 @@
#include <hlvm/AST/Node.h>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
- class Operator; // Forward declare
+class Operator; // Forward declare
+
+/// This class represents an Variable in the HLVM Abstract Syntax Tree.
+/// A Variable is a storage location of a specific type. It can either be
+/// global or local, depending on its parent. Global variables are always
+/// contained in a Bundle. Local variables are always contained in a
+/// Function.
+/// @brief HLVM AST Variable Node
+class Block : public Node
+{
+ /// @name Types
+ /// @{
+ public:
+ typedef std::vector<Operator*> NodeList;
+ typedef NodeList::iterator iterator;
+ typedef NodeList::const_iterator const_iterator;
+
+ /// @}
+ /// @name Constructors
+ /// @{
+ public:
+ Block() : Node(BlockID), ops() {}
+ virtual ~Block();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ static inline bool classof(const Block*) { return true; }
+ static inline bool classof(const Node* N) { return N->isBlock(); }
+
+ /// @}
+ /// @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(); }
+ 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 Data
+ /// @{
+ protected:
+ std::vector<Operator*> ops; ///< The operators the Block contains
+ /// @}
+ friend class AST;
+};
- /// This class represents an Variable in the HLVM Abstract Syntax Tree.
- /// A Variable is a storage location of a specific type. It can either be
- /// global or local, depending on its parent. Global variables are always
- /// contained in a Bundle. Local variables are always contained in a
- /// Function.
- /// @brief HLVM AST Variable Node
- class Block : public Node
- {
- /// @name Types
- /// @{
- public:
- typedef std::vector<Operator*> NodeList;
- typedef NodeList::iterator iterator;
- typedef NodeList::const_iterator const_iterator;
-
- /// @}
- /// @name Constructors
- /// @{
- public:
- Block() : Node(BlockID), ops() {}
- virtual ~Block();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- static inline bool classof(const Block*) { return true; }
- static inline bool classof(const Node* N) { return N->isBlock(); }
-
- /// @}
- /// @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(); }
- 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 Data
- /// @{
- protected:
- std::vector<Operator*> ops; ///< The operators the Block contains
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Bundle.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Bundle.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.cpp (original)
+++ hlvm/trunk/hlvm/AST/Bundle.cpp Sat Jul 7 18:59:30 2007
@@ -32,7 +32,7 @@
using namespace llvm;
-namespace hlvm { namespace AST {
+namespace hlvm {
Bundle*
Bundle::create(const Locator& loc, const std::string& id)
@@ -65,4 +65,4 @@
assert(!"That node isn't my child");
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/Bundle.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Bundle.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Bundle.h (original)
+++ hlvm/trunk/hlvm/AST/Bundle.h Sat Jul 7 18:59:30 2007
@@ -32,72 +32,73 @@
#include <hlvm/AST/Node.h>
-namespace hlvm { namespace AST {
+namespace hlvm
+{
- class LinkageItem;
+class LinkageItem;
+
+/// This class represents an HLVM Bundle. A Bundle is simply a collection of
+/// declarations and definitions. It is the root of the AST tree and also
+/// the grouping and namespace construct in HLVM. Every compilation unit is
+/// a Bundle. Bundles can also be nested in other Bundles. All programming
+/// constructs are defined as child nodes of some Bundle.
+/// @brief HLVM AST Bundle Node
+class Bundle : public NamedNode
+{
+ /// @name Types
+ /// @{
+ public:
+ typedef std::vector<LinkageItem*> NodeList;
+ typedef NodeList::iterator iterator;
+ typedef NodeList::const_iterator const_iterator;
+
+ /// @}
+ /// @name Constructors
+ /// @{
+ public:
+ static Bundle* create(const Locator& location, const std::string& pubid);
+
+ protected:
+ Bundle() : NamedNode(BundleID) {}
+ virtual ~Bundle();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ static inline bool classof(const Bundle*) { return true; }
+ static inline bool classof(const Node* N) { return N->isBundle(); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ virtual void insertChild(Node* kid);
+ virtual void removeChild(Node* kid);
+
+ /// @}
+ /// @name Iterators
+ /// @{
+ public:
+ iterator begin() { return kids.begin(); }
+ const_iterator begin() const { return kids.begin(); }
+ iterator end () { return kids.end(); }
+ const_iterator end () const { return kids.end(); }
+ size_t size () const { return kids.size(); }
+ bool empty() const { return kids.empty(); }
+ LinkageItem* front() { return kids.front(); }
+ const LinkageItem* front() const { return kids.front(); }
+ LinkageItem* back() { return kids.back(); }
+ const LinkageItem* back() const { return kids.back(); }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ NodeList kids; ///< The vector of children nodes.
+ /// @}
+ friend class AST;
+};
- /// This class represents an HLVM Bundle. A Bundle is simply a collection of
- /// declarations and definitions. It is the root of the AST tree and also
- /// the grouping and namespace construct in HLVM. Every compilation unit is
- /// a Bundle. Bundles can also be nested in other Bundles. All programming
- /// constructs are defined as child nodes of some Bundle.
- /// @brief HLVM AST Bundle Node
- class Bundle : public NamedNode
- {
- /// @name Types
- /// @{
- public:
- typedef std::vector<LinkageItem*> NodeList;
- typedef NodeList::iterator iterator;
- typedef NodeList::const_iterator const_iterator;
-
- /// @}
- /// @name Constructors
- /// @{
- public:
- static Bundle* create(const Locator& location, const std::string& pubid);
-
- protected:
- Bundle() : NamedNode(BundleID) {}
- virtual ~Bundle();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- static inline bool classof(const Bundle*) { return true; }
- static inline bool classof(const Node* N) { return N->isBundle(); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- virtual void insertChild(Node* kid);
- virtual void removeChild(Node* kid);
-
- /// @}
- /// @name Iterators
- /// @{
- public:
- iterator begin() { return kids.begin(); }
- const_iterator begin() const { return kids.begin(); }
- iterator end () { return kids.end(); }
- const_iterator end () const { return kids.end(); }
- size_t size () const { return kids.size(); }
- bool empty() const { return kids.empty(); }
- LinkageItem* front() { return kids.front(); }
- const LinkageItem* front() const { return kids.front(); }
- LinkageItem* back() { return kids.back(); }
- const LinkageItem* back() const { return kids.back(); }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- NodeList kids; ///< The vector of children nodes.
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Conditionable.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Conditionable.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Conditionable.h (original)
+++ hlvm/trunk/hlvm/AST/Conditionable.h Sat Jul 7 18:59:30 2007
@@ -32,36 +32,36 @@
#include <hlvm/AST/Node.h>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
- /// This class represents an HLVM Bundle. A Bundle is simply a collection of
- /// declarations and definitions. It is the root of the AST tree and also
- /// the grouping and namespace construct in HLVM. Every compilation unit is
- /// a Bundle. Bundles can also be nested in other Bundles. All programming
- /// constructs are defined as child nodes of some Bundle.
- /// @brief HLVM AST Bundle Node
- class Conditionable : public Node
- {
- /// @name Constructors
- /// @{
- public:
- Conditionable(
- NodeIDs id,
- Node* parent,
- const std::string& name,
- const std::string& condition_name)
- : Node(id,parent,name), cond_name_(condition_name) {}
- virtual ~Conditionable();
+/// This class represents an HLVM Bundle. A Bundle is simply a collection of
+/// declarations and definitions. It is the root of the AST tree and also
+/// the grouping and namespace construct in HLVM. Every compilation unit is
+/// a Bundle. Bundles can also be nested in other Bundles. All programming
+/// constructs are defined as child nodes of some Bundle.
+/// @brief HLVM AST Bundle Node
+class Conditionable : public Node
+{
+ /// @name Constructors
+ /// @{
+ public:
+ Conditionable(
+ NodeIDs id,
+ Node* parent,
+ const std::string& name,
+ const std::string& condition_name)
+ : Node(id,parent,name), cond_name_(condition_name) {}
+ virtual ~Conditionable();
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::string cond_name_;
+ /// @}
+ friend class AST;
+};
- /// @}
- /// @name Data
- /// @{
- protected:
- std::string cond_name_;
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/ContainerType.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/ContainerType.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/ContainerType.cpp (original)
+++ hlvm/trunk/hlvm/AST/ContainerType.cpp Sat Jul 7 18:59:30 2007
@@ -31,7 +31,7 @@
using namespace llvm;
-namespace hlvm { namespace AST {
+namespace hlvm {
ContainerType::~ContainerType()
{
@@ -83,4 +83,4 @@
types.push_back(cast<AliasType>(n));
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/ContainerType.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/ContainerType.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/ContainerType.h (original)
+++ hlvm/trunk/hlvm/AST/ContainerType.h Sat Jul 7 18:59:30 2007
@@ -32,142 +32,143 @@
#include <hlvm/AST/Type.h>
-namespace hlvm {
-namespace AST {
- /// This class represents a Type in the HLVM Abstract Syntax Tree.
- /// A Type defines the format of storage.
- /// @brief HLVM AST Type Node
- class ContainerType : public Type
- {
- /// @name Types
- /// @{
- public:
- typedef std::vector<Type*> TypeList;
- typedef TypeList::iterator iterator;
- typedef TypeList::const_iterator const_iterator;
-
- /// @}
- /// @name Constructors
- /// @{
- public:
- ContainerType(
- NodeIDs id ///< The node id of the subclass
- ) : Type(id), types() {}
- virtual ~ContainerType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const ContainerType*) { return true; }
- static inline bool classof(const Type* T) { return T->isContainerType(); }
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual void insertChild(Node* n);
- virtual void removeChild(Node* n);
-
- /// @}
- /// @name Iterators
- /// @{
- public:
- iterator begin() { return types.begin(); }
- const_iterator begin() const { return types.begin(); }
- iterator end () { return types.end(); }
- const_iterator end () const { return types.end(); }
- size_t size () const { return types.size(); }
- bool empty() const { return types.empty(); }
- Type* front() { return types.front(); }
- const Type* front() const { return types.front(); }
- Type* back() { return types.back(); }
- const Type* back() const { return types.back(); }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- std::vector<Type*> types; ///< The contained types
- /// @}
- };
-
- /// This class represents an HLVM type that is a sequence of data fields
- /// of varying type.
- class StructureType : public ContainerType
- {
- /// @name Constructors
- /// @{
- public:
- StructureType() : ContainerType(StructureTypeID) {}
- virtual ~StructureType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const StructureType*) { return true; }
- static inline bool classof(const Type* T) { return T->isStructureType(); }
- static inline bool classof(const Node* T)
- { return T->is(StructureTypeID); }
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual void insertChild(Node* n);
-
- /// @}
- /// @name Data
- /// @{
- protected:
- /// @}
- };
-
- /// This class represents an HLVM type that is a sequence of data fields
- /// of varying type.
- class SignatureType : public ContainerType
- {
- /// @name Constructors
- /// @{
- public:
- SignatureType()
- : ContainerType(SignatureTypeID), result(0), varargs(false) {}
- virtual ~SignatureType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- Type* getResultType() const { return result; }
- bool isVarArgs() const { return varargs; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const SignatureType*) { return true; }
- static inline bool classof(const Type* T) { return T->isSignatureType(); }
- static inline bool classof(const Node* T)
- { return T->is(SignatureTypeID); }
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- void setResultType(Type* ty) { result = ty; }
- void setIsVarArgs(bool is) { varargs = is; }
- virtual void insertChild(Node* n);
-
- /// @}
- /// @name Data
- /// @{
- protected:
- Type* result; ///< The result type of the function signature
- bool varargs; ///< Indicates variable arguments function
- /// @}
- friend class AST;
- };
-} // AST
+namespace hlvm
+{
+
+/// This class represents a Type in the HLVM Abstract Syntax Tree.
+/// A Type defines the format of storage.
+/// @brief HLVM AST Type Node
+class ContainerType : public Type
+{
+ /// @name Types
+ /// @{
+ public:
+ typedef std::vector<Type*> TypeList;
+ typedef TypeList::iterator iterator;
+ typedef TypeList::const_iterator const_iterator;
+
+ /// @}
+ /// @name Constructors
+ /// @{
+ public:
+ ContainerType(
+ NodeIDs id ///< The node id of the subclass
+ ) : Type(id), types() {}
+ virtual ~ContainerType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const ContainerType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isContainerType(); }
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual void insertChild(Node* n);
+ virtual void removeChild(Node* n);
+
+ /// @}
+ /// @name Iterators
+ /// @{
+ public:
+ iterator begin() { return types.begin(); }
+ const_iterator begin() const { return types.begin(); }
+ iterator end () { return types.end(); }
+ const_iterator end () const { return types.end(); }
+ size_t size () const { return types.size(); }
+ bool empty() const { return types.empty(); }
+ Type* front() { return types.front(); }
+ const Type* front() const { return types.front(); }
+ Type* back() { return types.back(); }
+ const Type* back() const { return types.back(); }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::vector<Type*> types; ///< The contained types
+ /// @}
+};
+
+/// This class represents an HLVM type that is a sequence of data fields
+/// of varying type.
+class StructureType : public ContainerType
+{
+ /// @name Constructors
+ /// @{
+ public:
+ StructureType() : ContainerType(StructureTypeID) {}
+ virtual ~StructureType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const StructureType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isStructureType(); }
+ static inline bool classof(const Node* T)
+ { return T->is(StructureTypeID); }
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual void insertChild(Node* n);
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ /// @}
+};
+
+/// This class represents an HLVM type that is a sequence of data fields
+/// of varying type.
+class SignatureType : public ContainerType
+{
+ /// @name Constructors
+ /// @{
+ public:
+ SignatureType()
+ : ContainerType(SignatureTypeID), result(0), varargs(false) {}
+ virtual ~SignatureType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ Type* getResultType() const { return result; }
+ bool isVarArgs() const { return varargs; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const SignatureType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isSignatureType(); }
+ static inline bool classof(const Node* T)
+ { return T->is(SignatureTypeID); }
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ void setResultType(Type* ty) { result = ty; }
+ void setIsVarArgs(bool is) { varargs = is; }
+ virtual void insertChild(Node* n);
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Type* result; ///< The result type of the function signature
+ bool varargs; ///< Indicates variable arguments function
+ /// @}
+ friend class AST;
+};
+
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Documentation.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Documentation.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Documentation.cpp (original)
+++ hlvm/trunk/hlvm/AST/Documentation.cpp Sat Jul 7 18:59:30 2007
@@ -29,10 +29,10 @@
#include <hlvm/AST/Documentation.h>
-namespace hlvm { namespace AST {
+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=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Documentation.h (original)
+++ hlvm/trunk/hlvm/AST/Documentation.h Sat Jul 7 18:59:30 2007
@@ -32,52 +32,53 @@
#include <hlvm/AST/Node.h>
-namespace hlvm { namespace AST {
+namespace hlvm
+{
+
+/// The HLVM AST permits documentation (not just comments) to be included into
+/// the nodes of the AST. Each such block of documentation is represented by
+/// a Documentation node, implemented by this class. The content of a
+/// documentation node is simply a block of text. 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 perfect
+/// precision. Since the documentation node can be associated with any kind
+/// of node, this affords a complete system for documenting HLVM programs
+/// with XHTML markup.
+/// @brief HLVM AST Function 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;
+};
- /// The HLVM AST permits documentation (not just comments) to be included into
- /// the nodes of the AST. Each such block of documentation is represented by
- /// a Documentation node, implemented by this class. The content of a
- /// documentation node is simply a block of text. 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 perfect
- /// precision. Since the documentation node can be associated with any kind
- /// of node, this affords a complete system for documenting HLVM programs
- /// with XHTML markup.
- /// @brief HLVM AST Function 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;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Function.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Function.cpp (original)
+++ hlvm/trunk/hlvm/AST/Function.cpp Sat Jul 7 18:59:30 2007
@@ -31,7 +31,7 @@
using namespace llvm;
-namespace hlvm { namespace AST {
+namespace hlvm {
Function::~Function()
{
@@ -62,4 +62,5 @@
assert(!"Can't insert one of those here");
}
}
-}}
+
+}
Modified: hlvm/trunk/hlvm/AST/Function.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Function.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Function.h (original)
+++ hlvm/trunk/hlvm/AST/Function.h Sat Jul 7 18:59:30 2007
@@ -34,50 +34,51 @@
#include <hlvm/AST/ContainerType.h>
#include <hlvm/AST/Block.h>
-namespace hlvm { namespace AST {
+namespace hlvm
+{
- /// This class represents a Function in the HLVM Abstract Syntax Tree.
- /// A Function is a callable block of code that accepts parameters and
- /// returns a result. This is the basic unit of code in HLVM. A Function
- /// has a name, a set of formal arguments, a return type, and a block of
- /// code to execute.
- /// @brief HLVM AST Function Node
- class Function : public LinkageItem
- {
- /// @name Constructors
- /// @{
- public:
- Function(
- NodeIDs id = FunctionID
- ) : LinkageItem(id), block(0), signature(0) {}
- virtual ~Function();
+/// This class represents a Function in the HLVM Abstract Syntax Tree.
+/// A Function is a callable block of code that accepts parameters and
+/// returns a result. This is the basic unit of code in HLVM. A Function
+/// has a name, a set of formal arguments, a return type, and a block of
+/// code to execute.
+/// @brief HLVM AST Function Node
+class Function : public LinkageItem
+{
+ /// @name Constructors
+ /// @{
+ public:
+ Function(
+ NodeIDs id = FunctionID
+ ) : LinkageItem(id), block(0), signature(0) {}
+ virtual ~Function();
- /// @}
- /// @name Accessors
- /// @{
- public:
- Block* getBlock() { return block; }
- SignatureType* getSignature() { return signature; }
- static inline bool classof(const Function*) { return true; }
- static inline bool classof(const Node* N) { return N->isFunction(); }
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ Block* getBlock() { return block; }
+ SignatureType* getSignature() { return signature; }
+ static inline bool classof(const Function*) { return true; }
+ static inline bool classof(const Node* N) { return N->isFunction(); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ virtual void insertChild(Node* kid);
+ virtual void removeChild(Node* kid);
+ //void setSignature(SignatureType* sig) { sig->Node::setParent(this); }
+ //void setBlock(Block* blk) { blk->Node::setParent(this); }
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Block * block; ///< The code block to be executed
+ SignatureType* signature; ///< The function signature.
+ /// @}
+ friend class AST;
+};
- /// @}
- /// @name Mutators
- /// @{
- public:
- virtual void insertChild(Node* kid);
- virtual void removeChild(Node* kid);
- //void setSignature(SignatureType* sig) { sig->Node::setParent(this); }
- //void setBlock(Block* blk) { blk->Node::setParent(this); }
- /// @}
- /// @name Data
- /// @{
- protected:
- Block * block; ///< The code block to be executed
- SignatureType* signature; ///< The function signature.
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Import.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Import.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Import.cpp (original)
+++ hlvm/trunk/hlvm/AST/Import.cpp Sat Jul 7 18:59:30 2007
@@ -29,10 +29,10 @@
#include <hlvm/AST/Import.h>
-namespace hlvm { namespace AST {
+namespace hlvm {
Import::~Import()
{
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/Import.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Import.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Import.h (original)
+++ hlvm/trunk/hlvm/AST/Import.h Sat Jul 7 18:59:30 2007
@@ -32,45 +32,46 @@
#include <hlvm/AST/LinkageItem.h>
-namespace hlvm { namespace AST {
+namespace hlvm
+{
+
+/// This class represents a Import in the HLVM Abstract Syntax Tree.
+/// A Function is a callable block of code that accepts parameters and
+/// returns a result. This is the basic unit of code in HLVM. A Function
+/// has a name, a set of formal arguments, a return type, and a block of
+/// code to execute.
+/// @brief HLVM AST Function Node
+class Import : public LinkageItem
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ Import() : LinkageItem(ImportID) {}
+
+ public:
+ virtual ~Import();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ static inline bool classof(const Import*) { return true; }
+ static inline bool classof(const Node* N) { return N->is(ImportID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ void setPrefix(const std::string& pfx) { prefix = pfx; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::string prefix;
+ /// @}
+ friend class AST;
+};
- /// This class represents a Import in the HLVM Abstract Syntax Tree.
- /// A Function is a callable block of code that accepts parameters and
- /// returns a result. This is the basic unit of code in HLVM. A Function
- /// has a name, a set of formal arguments, a return type, and a block of
- /// code to execute.
- /// @brief HLVM AST Function Node
- class Import : public LinkageItem
- {
- /// @name Constructors
- /// @{
- protected:
- Import() : LinkageItem(ImportID) {}
-
- public:
- virtual ~Import();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- static inline bool classof(const Import*) { return true; }
- static inline bool classof(const Node* N) { return N->is(ImportID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- void setPrefix(const std::string& pfx) { prefix = pfx; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- std::string prefix;
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/LinkageItem.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItem.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItem.cpp (original)
+++ hlvm/trunk/hlvm/AST/LinkageItem.cpp Sat Jul 7 18:59:30 2007
@@ -29,10 +29,10 @@
#include <hlvm/AST/LinkageItem.h>
-namespace hlvm { namespace AST {
+namespace hlvm {
LinkageItem::~LinkageItem()
{
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/LinkageItem.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/LinkageItem.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/LinkageItem.h (original)
+++ hlvm/trunk/hlvm/AST/LinkageItem.h Sat Jul 7 18:59:30 2007
@@ -34,52 +34,51 @@
namespace hlvm
{
-namespace AST
+
+/// This enumeration is used to specify the kinds of linkage that are
+/// permitted for a LinkageItem.
+enum LinkageTypes {
+ ExternalLinkage, ///< Externally visible item
+ InternalLinkage, ///< Rename collisions when linking (static funcs)
+ LinkOnceLinkage, ///< Keep one copy of item when linking (inline)
+ WeakLinkage, ///< Keep one copy of item when linking (weak)
+ AppendingLinkage ///< Append item to an array of similar items
+};
+
+/// This class represents an LinkageItem in the HLVM Abstract Syntax Tree.
+/// A LinkageItem is any construct that can be linked; that is, referred to
+/// elsewhere and linked into another bundle to resolve the reference. The
+/// LinkageItem declares what kind of linkage is to be performed.
+/// @brief HLVM AST Bundle Node
+class LinkageItem : public NamedNode
{
- /// This enumeration is used to specify the kinds of linkage that are
- /// permitted for a LinkageItem.
- enum LinkageTypes {
- ExternalLinkage, ///< Externally visible item
- InternalLinkage, ///< Rename collisions when linking (static funcs)
- LinkOnceLinkage, ///< Keep one copy of item when linking (inline)
- WeakLinkage, ///< Keep one copy of item when linking (weak)
- AppendingLinkage ///< Append item to an array of similar items
- };
-
- /// This class represents an LinkageItem in the HLVM Abstract Syntax Tree.
- /// A LinkageItem is any construct that can be linked; that is, referred to
- /// elsewhere and linked into another bundle to resolve the reference. The
- /// LinkageItem declares what kind of linkage is to be performed.
- /// @brief HLVM AST Bundle Node
- class LinkageItem : public NamedNode
- {
- /// @name Constructors
- /// @{
- protected:
- LinkageItem(
- NodeIDs id ///< Subclass's node identifier
- ) : NamedNode(id) {}
- public:
- virtual ~LinkageItem();
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- static inline bool classof(const LinkageItem*) { return true; }
- static inline bool classof(const Node* N) { return N->isLinkageItem(); }
- /// @}
- /// @name Mutators
- /// @{
-
- /// @}
- /// @name Data
- /// @{
- protected:
- LinkageTypes type_; ///< The type of linkage to perform for this item
- /// @}
- friend class AST;
- };
-} // AST
+ /// @name Constructors
+ /// @{
+ protected:
+ LinkageItem(
+ NodeIDs id ///< Subclass's node identifier
+ ) : NamedNode(id) {}
+ public:
+ virtual ~LinkageItem();
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ static inline bool classof(const LinkageItem*) { return true; }
+ static inline bool classof(const Node* N) { return N->isLinkageItem(); }
+ /// @}
+ /// @name Mutators
+ /// @{
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ LinkageTypes type_; ///< The type of linkage to perform for this item
+ /// @}
+ friend class AST;
+};
+
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Locator.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Locator.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Locator.h (original)
+++ hlvm/trunk/hlvm/AST/Locator.h Sat Jul 7 18:59:30 2007
@@ -32,36 +32,36 @@
#include <string>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
+
+/// This class is used to hold a source code location as a filename, line
+/// number and column number. This is used for generating error messages and
+/// for debugging support.
+/// @brief Source location holder class.
+class Locator
+{
+ /// @name Constructors
+ /// @{
+ public:
+ Locator(uint32_t line, uint32_t col, const std::string* fname)
+ : line_(line), col_(col), fname_(fname) {}
+ Locator() : line_(0), col_(0), fname_(0) {}
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ uint32_t line_; ///< Line number of source location
+ uint32_t col_; ///< Column number of source location
+ const std::string* fname_;///< File name of source location
+ /// @}
+};
- /// This class is used to hold a source code location as a filename, line
- /// number and column number. This is used for generating error messages and
- /// for debugging support.
- /// @brief Source location holder class.
- class Locator
- {
- /// @name Constructors
- /// @{
- public:
- Locator(uint32_t line, uint32_t col, const std::string* fname)
- : line_(line), col_(col), fname_(fname) {}
- Locator() : line_(0), col_(0), fname_(0) {}
-
- /// @}
- /// @name Accessors
- /// @{
- public:
-
- /// @}
- /// @name Data
- /// @{
- protected:
- uint32_t line_; ///< Line number of source location
- uint32_t col_; ///< Column number of source location
- const std::string* fname_;///< File name of source location
- /// @}
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Node.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Node.cpp (original)
+++ hlvm/trunk/hlvm/AST/Node.cpp Sat Jul 7 18:59:30 2007
@@ -29,7 +29,7 @@
#include <hlvm/AST/Node.h>
-namespace hlvm { namespace AST {
+namespace hlvm {
Node::~Node()
{
@@ -89,4 +89,4 @@
{
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/Node.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Node.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Node.h (original)
+++ hlvm/trunk/hlvm/AST/Node.h Sat Jul 7 18:59:30 2007
@@ -34,335 +34,335 @@
#include <hlvm/AST/Locator.h>
#include <vector>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
- class Documentation;
+class Documentation;
- /// This enumeration is used to identify a specific type. Its organization is
- /// very specific and dependent on the class hierarchy. In order to use these
- /// values as ranges for class identification (classof methods), we need to
- /// group things by inheritance rather than by function.
- enum NodeIDs {
- NoTypeID = 0, ///< Use this for an invalid type ID.
- // Primitive Types (no child nodes)
- VoidTypeID = 1, ///< The Void Type (The Null Type)
- AnyTypeID, ///< The Any Type (Union of any type)
- BooleanTypeID, ///< The Boolean Type (A simple on/off boolean value)
- CharacterTypeID, ///< The Character Type (UTF-16 encoded character)
- OctetTypeID, ///< The Octet Type (8 bits uninterpreted)
- IntegerTypeID, ///< The Integer Type (A number of bits of integer data)
- RangeTypeID, ///< The Range Type (A Range of Integer Values)
- EnumerationTypeID, ///< The Enumeration Type (set of enumerated ids)
- RealTypeID, ///< The Real Number Type (Any Real Number)
- RationalTypeID, ///< The Rational Number Type (p/q type number)
- StringTypeID, ///< The String Type (Array of UTF-16 chars + length)
-
- // Container Types
- AliasTypeID, ///< A new name for an existing type
- PointerTypeID, ///< The Pointer Type (Pointer To storage of other Type)
- ArrayTypeID, ///< The Array Type (Linear array of some type)
- VectorTypeID, ///< The Vector Type (Packed Fixed Size Vector)
- StructureTypeID, ///< The Structure Type (Sequence of various types)
- SignatureTypeID, ///< The Function Signature Type
- ContinuationTypeID, ///< A Continuation Type (data passing to continuations)
- OpaqueTypeID, ///< A placeholder for unresolved types
-
- // Class Constructs (TBD)
- InterfaceID, ///< The Interface Type (set of Signatures)
- ClassID, ///< The Class Type (Object Oriented Class Definition)
- MethodID, ///< The Method Node (define a method)
- ImplementsID, ///< Specifies set of Interfaces implemented by class
-
- // Linkage Items
- VariableID, ///< The Variable Node (a storage location)
- FunctionID, ///< The Function Node (a callable function)
- ProgramID, ///< The Program Node (a program starting point)
-
- // Container
- BundleID, ///< The Bundle Node (a group of other declarations)
- BlockID, ///< A Block Of Code Nodes
- ImportID, ///< A bundle's Import declaration
-
- // Control Flow And Invocation Operators
- CallOpID, ///< The Call Operator
- InvokeOpID, ///< The Invoke Operator
- DispatchOpID, ///< The Object Method Dispatch Operator
- CreateContOpID, ///< The Create Continutation Operator
- CallWithContOpID, ///< The Call with Continuation Operator
- ReturnOpID, ///< The Return A Value Operator
- ThrowOpID, ///< The Throw And Exception Operator
- JumpToOpID, ///< The Jump To Labelled Block Operator
- BreakOpID, ///< The Break Out Of Block Operator
- IfOpID, ///< The If-Then-Else Operator
- LoopOpID, ///< The General Purpose Loop Operator
- SelectOpID, ///< The Select An Alternate Operator
-
- // Scoping Operators
- WithOpID, ///< Create a shorthand for a Bundle (like using/import)
-
- // Memory Operators
- LoadOpID, ///< The Load Operator (load a value from a location)
- StoreOpID, ///< The Store Operator (store a value to a location)
- AllocateOpID, ///< The Allocate Memory Operator (get some heap memory)
- FreeOpID, ///< The Free Memory Operator (free some heap memory)
- ReallocateOpID, ///< The Reallocate Memory Operator (realloc heap mem)
- StackAllocOpID, ///< The Stack Allocation Operator (get some stack mem)
- ReferenceOpID, ///< The Reference A Memory Object Operator (for GC)
- DereferenceOpID, ///< The Dereference A Memory Object Operator (for GC)
-
- // Arithmetic Operators
- NegateOpID, ///< The Negation Unary Integer Operator
- ComplementOpID, ///< The Bitwise Complement Unary Integer Operator
- PreIncrOpID, ///< The Pre-Increment Unary Integer Operator
- PostIncrOpID, ///< The Post-Increment Unary Integer Operator
- PreDecrOpID, ///< The Pre-Decrement Unary Integer Operator
- PostDecrOpID, ///< The Post-Decrement Unary Integer Operator
- AddOpID, ///< The Addition Binary Integer Operator
- SubtractOpID, ///< The Subtraction Binary Integer Operator
- MultiplyOpID, ///< The Multiplcation Binary Integer Operator
- DivideOpID, ///< The Division Binary Integer Operator
- ModulusOpID, ///< The Modulus Binary Integer Operator
- BAndOpID, ///< The Bitwise And Binary Integer Operator
- BOrOpID, ///< The Bitwise Or Binary Integer Operator
- BXOrOpID, ///< The Bitwise XOr Binary Integer Operator
-
- // Boolean Operators
- AndOpID, ///< The And Binary Boolean Operator
- OrOpID, ///< The Or Binary Boolean Operator
- NorOpID, ///< The Nor Binary Boolean Operator
- XorOpID, ///< The Xor Binary Boolean Operator
- NotOpID, ///< The Not Unary Boolean Operator
- LTOpID, ///< The less-than Binary Boolean Operator
- GTOpID, ///< The greater-than Binary Boolean Operator
- LEOpID, ///< The less-than-or-equal Binary Boolean Operator
- GEOpID, ///< The greather-than-or-equal Binary Boolean Operator
- EQOpID, ///< The esual Binary Boolean Operator
- NEOpID, ///< The not-equal Binary Comparison Operator
-
- // Real Arithmetic Operators
- IsPInfOpID, ///< Real Number Positive Infinity Test Operator
- IsNInfOpID, ///< Real Number Negative Infinity Test Operator
- IsNaNOpID, ///< Real Number Not-A-Number Test Operator
- TruncOpID, ///< Real Number Truncation Operator
- RoundOpID, ///< Real Number Rounding Operator
- FloorOpID, ///< Real Number Floor Operator
- CeilingOpID, ///< Real Number Ceiling Operator
- PowerOpID, ///< Real Number Power Operator
- LogEOpID, ///< Real Number Base e (Euler's Number) logarithm
- Log2OpID, ///< Real Number Base 2 logarithm Operator
- Log10OpID, ///< Real Number Base 10 logarithm Operator
- SqRootOpID, ///< Real Number Square Root Operator
- RootOpID, ///< Real Number Arbitrary Root Operator
- FactorialOpID, ///< Real Number Factorial Operator
- GCDOpID, ///< Real Number Greatest Common Divisor Operator
- LCMOpID, ///< Real Number Least Common Multiplicator Operator
-
- // Character And String Operators
- MungeOpID, ///< General Purpose String Editing Operator
- LengthOpID, ///< Extract Length of a String Operator
-
- // Input/Output Operators
- MapFileOpID, ///< Map a file to memory (mmap)
- OpenOpID, ///< Open a stream from a URL
- CloseOpID, ///< Close a stream previously opened.
- ReadOpID, ///< Read from a stream
- WriteOpID, ///< Write to a stream
- PositionOpID, ///< Position a stream
-
- // Constant Value Operators
- IntOpID, ///< Constant Integer Value
- RealOpID, ///< Constant Real Value
- PInfOpID, ///< Constant Positive Infinity Real Value
- NInfOpID, ///< Constant Negative Infinity Real Value
- NaNOpID, ///< Constant Not-A-Number Real Value
- StringOpID, ///< Constant String Value
- ArrayOpID, ///< Constant Array Value
- VectorOpID, ///< Constant Vector Value
- StructureOpID, ///< Constant Structure Value
-
- // Miscellaneous Nodes
- DocumentationID, ///< XHTML Documentation Node
-
- // Enumeration Ranges and Limits
- NumNodeIDs, ///< The number of node identifiers in the enum
- FirstPrimitiveTypeID = VoidTypeID, ///< First Primitive Type
- LastPrimitiveTypeID = StringTypeID, ///< Last Primitive Type
- FirstContainerTypeID = PointerTypeID, ///< First Container Type
- LastContainerTypeID = ContinuationTypeID, ///< Last Container Type
- FirstOperatorID = CallOpID, ///< First Operator
- LastOperatorID = StructureOpID, ///< Last Operator
- FirstTypeID = VoidTypeID,
- LastTypeID = OpaqueTypeID
- };
-
- class ParentNode;
-
- /// This class is the base class of HLVM Abstract Syntax Tree (AST). All
- /// other AST nodes are subclasses of this class.
- /// @brief Abstract base class of all HLVM AST node classes
- class Node
- {
- /// @name Constructors
- /// @{
- protected:
- Node(NodeIDs ID) : id(ID), parent(0), loc() {}
- public:
- virtual ~Node();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- /// Get the type of node
- inline NodeIDs getID() const { return NodeIDs(id); }
-
- /// Get the parent node
- inline Node* getParent() const { return parent; }
-
- /// Get the flags
- inline unsigned getFlags() const { return flags; }
-
- /// Get the Locator
- inline const Locator& getLocator() const { return loc; }
-
- /// Determine if the node is a specific kind
- inline bool is(NodeIDs kind) const { return id == unsigned(kind); }
-
- /// Determine if the node is a Type
- inline bool isType() const {
- return id >= FirstTypeID && id <= LastTypeID;
- }
- /// Determine if the node is any of the Operators
- inline bool isOperator() const {
- return id >= FirstOperatorID && id <= LastOperatorID;
- }
-
- /// Determine if the node is a NamedNode
- bool isNamedNode() const ;
-
- /// Determine if the node is a Documentable Node
- bool isDocumentable() const;
-
- /// Determine if the node is a LinkageItem
- bool isLinkageItem() const;
-
- /// Determine if the node is a Block
- inline bool isBlock() const { return id == BlockID; }
- /// Determine if the node is a Bundle
- inline bool isBundle() const { return id == BundleID; }
- /// Determine if the node is a Function
- inline bool isFunction() const { return id == FunctionID; }
- /// Determine if the node is a Program
- inline bool isProgram() const { return id == ProgramID; }
- /// Determine if the node is a Variable
- inline bool isVariable() const { return id == VariableID; }
-
- /// Provide support for isa<X> and friends
- static inline bool classof(const Node*) { return true; }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- void setLocator(const Locator& l) { loc = l; }
- void setFlags(unsigned f) {
- assert(f < 1 << 24 && "Flags out of range");
- flags = f;
- }
- virtual void setParent(Node* parent);
-
- protected:
- virtual void insertChild(Node* child);
- virtual void removeChild(Node* child);
- /// @}
- /// @name Utilities
- /// @{
- public:
+/// This enumeration is used to identify a specific type. Its organization is
+/// very specific and dependent on the class hierarchy. In order to use these
+/// values as ranges for class identification (classof methods), we need to
+/// group things by inheritance rather than by function.
+enum NodeIDs {
+ NoTypeID = 0, ///< Use this for an invalid type ID.
+ // Primitive Types (no child nodes)
+ VoidTypeID = 1, ///< The Void Type (The Null Type)
+ AnyTypeID, ///< The Any Type (Union of any type)
+ BooleanTypeID, ///< The Boolean Type (A simple on/off boolean value)
+ CharacterTypeID, ///< The Character Type (UTF-16 encoded character)
+ OctetTypeID, ///< The Octet Type (8 bits uninterpreted)
+ IntegerTypeID, ///< The Integer Type (A number of bits of integer data)
+ RangeTypeID, ///< The Range Type (A Range of Integer Values)
+ EnumerationTypeID, ///< The Enumeration Type (set of enumerated ids)
+ RealTypeID, ///< The Real Number Type (Any Real Number)
+ RationalTypeID, ///< The Rational Number Type (p/q type number)
+ StringTypeID, ///< The String Type (Array of UTF-16 chars + length)
+
+ // Container Types
+ AliasTypeID, ///< A new name for an existing type
+ PointerTypeID, ///< The Pointer Type (Pointer To storage of other Type)
+ ArrayTypeID, ///< The Array Type (Linear array of some type)
+ VectorTypeID, ///< The Vector Type (Packed Fixed Size Vector)
+ StructureTypeID, ///< The Structure Type (Sequence of various types)
+ SignatureTypeID, ///< The Function Signature Type
+ ContinuationTypeID, ///< A Continuation Type (data passing to continuations)
+ OpaqueTypeID, ///< A placeholder for unresolved types
+
+ // Class Constructs (TBD)
+ InterfaceID, ///< The Interface Type (set of Signatures)
+ ClassID, ///< The Class Type (Object Oriented Class Definition)
+ MethodID, ///< The Method Node (define a method)
+ ImplementsID, ///< Specifies set of Interfaces implemented by class
+
+ // Linkage Items
+ VariableID, ///< The Variable Node (a storage location)
+ FunctionID, ///< The Function Node (a callable function)
+ ProgramID, ///< The Program Node (a program starting point)
+
+ // Container
+ BundleID, ///< The Bundle Node (a group of other declarations)
+ BlockID, ///< A Block Of Code Nodes
+ ImportID, ///< A bundle's Import declaration
+
+ // Control Flow And Invocation Operators
+ CallOpID, ///< The Call Operator
+ InvokeOpID, ///< The Invoke Operator
+ DispatchOpID, ///< The Object Method Dispatch Operator
+ CreateContOpID, ///< The Create Continutation Operator
+ CallWithContOpID, ///< The Call with Continuation Operator
+ ReturnOpID, ///< The Return A Value Operator
+ ThrowOpID, ///< The Throw And Exception Operator
+ JumpToOpID, ///< The Jump To Labelled Block Operator
+ BreakOpID, ///< The Break Out Of Block Operator
+ IfOpID, ///< The If-Then-Else Operator
+ LoopOpID, ///< The General Purpose Loop Operator
+ SelectOpID, ///< The Select An Alternate Operator
+
+ // Scoping Operators
+ WithOpID, ///< Create a shorthand for a Bundle (like using/import)
+
+ // Memory Operators
+ LoadOpID, ///< The Load Operator (load a value from a location)
+ StoreOpID, ///< The Store Operator (store a value to a location)
+ AllocateOpID, ///< The Allocate Memory Operator (get some heap memory)
+ FreeOpID, ///< The Free Memory Operator (free some heap memory)
+ ReallocateOpID, ///< The Reallocate Memory Operator (realloc heap mem)
+ StackAllocOpID, ///< The Stack Allocation Operator (get some stack mem)
+ ReferenceOpID, ///< The Reference A Memory Object Operator (for GC)
+ DereferenceOpID, ///< The Dereference A Memory Object Operator (for GC)
+
+ // Arithmetic Operators
+ NegateOpID, ///< The Negation Unary Integer Operator
+ ComplementOpID, ///< The Bitwise Complement Unary Integer Operator
+ PreIncrOpID, ///< The Pre-Increment Unary Integer Operator
+ PostIncrOpID, ///< The Post-Increment Unary Integer Operator
+ PreDecrOpID, ///< The Pre-Decrement Unary Integer Operator
+ PostDecrOpID, ///< The Post-Decrement Unary Integer Operator
+ AddOpID, ///< The Addition Binary Integer Operator
+ SubtractOpID, ///< The Subtraction Binary Integer Operator
+ MultiplyOpID, ///< The Multiplcation Binary Integer Operator
+ DivideOpID, ///< The Division Binary Integer Operator
+ ModulusOpID, ///< The Modulus Binary Integer Operator
+ BAndOpID, ///< The Bitwise And Binary Integer Operator
+ BOrOpID, ///< The Bitwise Or Binary Integer Operator
+ BXOrOpID, ///< The Bitwise XOr Binary Integer Operator
+
+ // Boolean Operators
+ AndOpID, ///< The And Binary Boolean Operator
+ OrOpID, ///< The Or Binary Boolean Operator
+ NorOpID, ///< The Nor Binary Boolean Operator
+ XorOpID, ///< The Xor Binary Boolean Operator
+ NotOpID, ///< The Not Unary Boolean Operator
+ LTOpID, ///< The less-than Binary Boolean Operator
+ GTOpID, ///< The greater-than Binary Boolean Operator
+ LEOpID, ///< The less-than-or-equal Binary Boolean Operator
+ GEOpID, ///< The greather-than-or-equal Binary Boolean Operator
+ EQOpID, ///< The esual Binary Boolean Operator
+ NEOpID, ///< The not-equal Binary Comparison Operator
+
+ // Real Arithmetic Operators
+ IsPInfOpID, ///< Real Number Positive Infinity Test Operator
+ IsNInfOpID, ///< Real Number Negative Infinity Test Operator
+ IsNaNOpID, ///< Real Number Not-A-Number Test Operator
+ TruncOpID, ///< Real Number Truncation Operator
+ RoundOpID, ///< Real Number Rounding Operator
+ FloorOpID, ///< Real Number Floor Operator
+ CeilingOpID, ///< Real Number Ceiling Operator
+ PowerOpID, ///< Real Number Power Operator
+ LogEOpID, ///< Real Number Base e (Euler's Number) logarithm
+ Log2OpID, ///< Real Number Base 2 logarithm Operator
+ Log10OpID, ///< Real Number Base 10 logarithm Operator
+ SqRootOpID, ///< Real Number Square Root Operator
+ RootOpID, ///< Real Number Arbitrary Root Operator
+ FactorialOpID, ///< Real Number Factorial Operator
+ GCDOpID, ///< Real Number Greatest Common Divisor Operator
+ LCMOpID, ///< Real Number Least Common Multiplicator Operator
+
+ // Character And String Operators
+ MungeOpID, ///< General Purpose String Editing Operator
+ LengthOpID, ///< Extract Length of a String Operator
+
+ // Input/Output Operators
+ MapFileOpID, ///< Map a file to memory (mmap)
+ OpenOpID, ///< Open a stream from a URL
+ CloseOpID, ///< Close a stream previously opened.
+ ReadOpID, ///< Read from a stream
+ WriteOpID, ///< Write to a stream
+ PositionOpID, ///< Position a stream
+
+ // Constant Value Operators
+ IntOpID, ///< Constant Integer Value
+ RealOpID, ///< Constant Real Value
+ PInfOpID, ///< Constant Positive Infinity Real Value
+ NInfOpID, ///< Constant Negative Infinity Real Value
+ NaNOpID, ///< Constant Not-A-Number Real Value
+ StringOpID, ///< Constant String Value
+ ArrayOpID, ///< Constant Array Value
+ VectorOpID, ///< Constant Vector Value
+ StructureOpID, ///< Constant Structure Value
+
+ // Miscellaneous Nodes
+ DocumentationID, ///< XHTML Documentation Node
+
+ // Enumeration Ranges and Limits
+ NumNodeIDs, ///< The number of node identifiers in the enum
+ FirstPrimitiveTypeID = VoidTypeID, ///< First Primitive Type
+ LastPrimitiveTypeID = StringTypeID, ///< Last Primitive Type
+ FirstContainerTypeID = PointerTypeID, ///< First Container Type
+ LastContainerTypeID = ContinuationTypeID, ///< Last Container Type
+ FirstOperatorID = CallOpID, ///< First Operator
+ LastOperatorID = StructureOpID, ///< Last Operator
+ FirstTypeID = VoidTypeID,
+ LastTypeID = OpaqueTypeID
+};
+
+class ParentNode;
+
+/// This class is the base class of HLVM Abstract Syntax Tree (AST). All
+/// other AST nodes are subclasses of this class.
+/// @brief Abstract base class of all HLVM AST node classes
+class Node
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ Node(NodeIDs ID) : id(ID), parent(0), loc() {}
+ public:
+ virtual ~Node();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ /// Get the type of node
+ inline NodeIDs getID() const { return NodeIDs(id); }
+
+ /// Get the parent node
+ inline Node* getParent() const { return parent; }
+
+ /// Get the flags
+ inline unsigned getFlags() const { return flags; }
+
+ /// Get the Locator
+ inline const Locator& getLocator() const { return loc; }
+
+ /// Determine if the node is a specific kind
+ inline bool is(NodeIDs kind) const { return id == unsigned(kind); }
+
+ /// Determine if the node is a Type
+ inline bool isType() const {
+ return id >= FirstTypeID && id <= LastTypeID;
+ }
+ /// Determine if the node is any of the Operators
+ inline bool isOperator() const {
+ return id >= FirstOperatorID && id <= LastOperatorID;
+ }
+
+ /// Determine if the node is a NamedNode
+ bool isNamedNode() const ;
+
+ /// Determine if the node is a Documentable Node
+ bool isDocumentable() const;
+
+ /// Determine if the node is a LinkageItem
+ bool isLinkageItem() const;
+
+ /// Determine if the node is a Block
+ inline bool isBlock() const { return id == BlockID; }
+ /// Determine if the node is a Bundle
+ inline bool isBundle() const { return id == BundleID; }
+ /// Determine if the node is a Function
+ inline bool isFunction() const { return id == FunctionID; }
+ /// Determine if the node is a Program
+ inline bool isProgram() const { return id == ProgramID; }
+ /// Determine if the node is a Variable
+ inline bool isVariable() const { return id == VariableID; }
+
+ /// Provide support for isa<X> and friends
+ static inline bool classof(const Node*) { return true; }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ void setLocator(const Locator& l) { loc = l; }
+ void setFlags(unsigned f) {
+ assert(f < 1 << 24 && "Flags out of range");
+ flags = f;
+ }
+ virtual void setParent(Node* parent);
+
+ protected:
+ virtual void insertChild(Node* child);
+ virtual void removeChild(Node* child);
+ /// @}
+ /// @name Utilities
+ /// @{
+ public:
#ifndef _NDEBUG
- virtual void dump() const;
+ virtual void dump() const;
#endif
- /// @}
- /// @name Data
- /// @{
- protected:
- unsigned id : 8; ///< Really a value in NodeIDs
- unsigned flags : 24; ///< 24 boolean flags, subclass dependent interp.
- Node* parent; ///< The node that owns this node.
- Locator loc; ///< The source location corresponding to node.
- /// @}
- friend class AST;
- };
-
- class Documentable : public Node
- {
- /// @name Constructors
- /// @{
- protected:
- Documentable(NodeIDs id) : Node(id), doc(0) {}
- public:
- virtual ~Documentable();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- /// Get the name of the node
- inline Documentation* getDoc() { return doc; }
-
- static inline bool classof(const Documentable*) { return true; }
- static inline bool classof(const Node* N) { return N->isDocumentable(); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- void setDoc(Documentation* d) { doc = d; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- Documentation* doc;///< All named nodes can have documentation
- /// @}
- friend class AST;
- };
-
- class NamedNode : public Documentable
- {
- /// @name Constructors
- /// @{
- protected:
- NamedNode(NodeIDs id) : Documentable(id), name() {}
- public:
- virtual ~NamedNode();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- /// Get the name of the node
- inline const std::string& getName() { return name; }
-
- static inline bool classof(const NamedNode*) { return true; }
- static inline bool classof(const Node* N) { return N->isNamedNode(); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- void setName(const std::string& n) { name = n; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- std::string name; ///< The name of this node.
- Documentation* doc;///< All named nodes can have documentation
- /// @}
- friend class AST;
- };
-} // AST
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ unsigned id : 8; ///< Really a value in NodeIDs
+ unsigned flags : 24; ///< 24 boolean flags, subclass dependent interp.
+ Node* parent; ///< The node that owns this node.
+ Locator loc; ///< The source location corresponding to node.
+ /// @}
+ friend class AST;
+};
+
+class Documentable : public Node
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ Documentable(NodeIDs id) : Node(id), doc(0) {}
+ public:
+ virtual ~Documentable();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ /// Get the name of the node
+ inline Documentation* getDoc() { return doc; }
+
+ static inline bool classof(const Documentable*) { return true; }
+ static inline bool classof(const Node* N) { return N->isDocumentable(); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ void setDoc(Documentation* d) { doc = d; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Documentation* doc;///< All named nodes can have documentation
+ /// @}
+ friend class AST;
+};
+
+class NamedNode : public Documentable
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ NamedNode(NodeIDs id) : Documentable(id), name() {}
+ public:
+ virtual ~NamedNode();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ /// Get the name of the node
+ inline const std::string& getName() { return name; }
+
+ static inline bool classof(const NamedNode*) { return true; }
+ static inline bool classof(const Node* N) { return N->isNamedNode(); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ void setName(const std::string& n) { name = n; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::string name; ///< The name of this node.
+ Documentation* doc;///< All named nodes can have documentation
+ /// @}
+ friend class AST;
+};
+
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Operator.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.cpp (original)
+++ hlvm/trunk/hlvm/AST/Operator.cpp Sat Jul 7 18:59:30 2007
@@ -30,10 +30,9 @@
#include <hlvm/AST/Operator.h>
namespace hlvm {
-namespace AST {
Operator::~Operator()
{
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/Operator.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Operator.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Operator.h (original)
+++ hlvm/trunk/hlvm/AST/Operator.h Sat Jul 7 18:59:30 2007
@@ -32,46 +32,46 @@
#include <hlvm/AST/Node.h>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
- class Type; // Forward declare
+class Type; // Forward declare
+
+/// This class represents an Variable in the HLVM Abstract Syntax Tree.
+/// A Variable is a storage location of a specific type. It can either be
+/// global or local, depending on its parent. Global variables are always
+/// contained in a Bundle. Local variables are always contained in a
+/// Function.
+/// @brief HLVM AST Variable Node
+class Operator : public Node
+{
+ /// @name Constructors
+ /// @{
+ public:
+ Operator(
+ NodeIDs opID ///< The Operator ID for this operator kind
+ ) : Node(opID), Operands() {}
+ virtual ~Operator();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ bool isNilaryOperator();
+ bool isUnaryOperator();
+ bool isBinaryOperator();
+ bool isTernaryOperator();
+ static inline bool classof(const Operator*) { return true; }
+ static inline bool classof(const Node* N) { return N->isOperator(); }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ std::vector<Operator*> Operands; ///< The list of Operands
+ /// @}
+ friend class AST;
+};
- /// This class represents an Variable in the HLVM Abstract Syntax Tree.
- /// A Variable is a storage location of a specific type. It can either be
- /// global or local, depending on its parent. Global variables are always
- /// contained in a Bundle. Local variables are always contained in a
- /// Function.
- /// @brief HLVM AST Variable Node
- class Operator : public Node
- {
- /// @name Constructors
- /// @{
- public:
- Operator(
- NodeIDs opID ///< The Operator ID for this operator kind
- ) : Node(opID), Operands() {}
- virtual ~Operator();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- bool isNilaryOperator();
- bool isUnaryOperator();
- bool isBinaryOperator();
- bool isTernaryOperator();
- static inline bool classof(const Operator*) { return true; }
- static inline bool classof(const Node* N) { return N->isOperator(); }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- std::vector<Operator*> Operands; ///< The list of Operands
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Program.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Program.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Program.cpp (original)
+++ hlvm/trunk/hlvm/AST/Program.cpp Sat Jul 7 18:59:30 2007
@@ -31,7 +31,6 @@
#include <hlvm/AST/ContainerType.h>
namespace hlvm {
-namespace AST {
SignatureType* Program::initSignature() {
SignatureType* result = new SignatureType();
@@ -44,4 +43,4 @@
{
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/Program.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Program.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Program.h (original)
+++ hlvm/trunk/hlvm/AST/Program.h Sat Jul 7 18:59:30 2007
@@ -32,43 +32,43 @@
#include <hlvm/AST/Function.h>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
- class Block; // Forward declare
- class SignatureType; // Forward declare
+class Block; // Forward declare
+class SignatureType; // Forward declare
+
+/// This class represents a Program in the HLVM Abstract Syntax Tree.
+/// A Program is a function with a specific set of arguments. It represents
+/// a starting point for any execution. To be executable, a Bundle must have
+/// at least one Program node in it. The Program node is simply introduced
+/// to ensure the signature of the function is correct and to serve as a way
+/// to identify Program's quickly.
+/// @brief HLVM AST Function Node
+class Program : public Function
+{
+ /// @name Constructors
+ /// @{
+ public:
+ Program() : Function(ProgramID) {}
+ virtual ~Program();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ static inline bool classof(const Program*) { return true; }
+ static inline bool classof(const Node* N) { return N->isProgram(); }
+
+ /// @}
+ /// @name Data
+ /// @{
+ private:
+ static SignatureType* SignatureTy; ///< The signature for programs
+ static SignatureType* initSignature();
+ /// @}
+ friend class AST;
+};
- /// This class represents a Program in the HLVM Abstract Syntax Tree.
- /// A Program is a function with a specific set of arguments. It represents
- /// a starting point for any execution. To be executable, a Bundle must have
- /// at least one Program node in it. The Program node is simply introduced
- /// to ensure the signature of the function is correct and to serve as a way
- /// to identify Program's quickly.
- /// @brief HLVM AST Function Node
- class Program : public Function
- {
- /// @name Constructors
- /// @{
- public:
- Program() : Function(ProgramID) {}
- virtual ~Program();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- static inline bool classof(const Program*) { return true; }
- static inline bool classof(const Node* N) { return N->isProgram(); }
-
- /// @}
- /// @name Data
- /// @{
- private:
- static SignatureType* SignatureTy; ///< The signature for programs
- static SignatureType* initSignature();
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/SymbolTable.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/SymbolTable.cpp (original)
+++ hlvm/trunk/hlvm/AST/SymbolTable.cpp Sat Jul 7 18:59:30 2007
@@ -33,7 +33,7 @@
#include <algorithm>
#include <cassert>
-using namespace hlvm::AST;
+using namespace hlvm;
std::string
SymbolTable::getUniqueName(const std::string &base_name) const {
Modified: hlvm/trunk/hlvm/AST/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/SymbolTable.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/SymbolTable.h (original)
+++ hlvm/trunk/hlvm/AST/SymbolTable.h Sat Jul 7 18:59:30 2007
@@ -33,110 +33,110 @@
#include <hlvm/AST/Node.h>
#include <map>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
+
+/// This class provides a symbol table of name/node pairs with operations to
+/// support constructing, searching and iterating over the symbol table.
+class SymbolTable
+{
+/// @name Types
+/// @{
+public:
+ /// @brief A mapping of names to nodes.
+ typedef std::map<const std::string, const Node*> NodeMap;
+
+ /// @brief An iterator over the NodeMap.
+ typedef NodeMap::iterator iterator;
+
+ /// @brief A const_iterator over the NodeMap.
+ typedef NodeMap::const_iterator const_iterator;
+
+/// @}
+/// @name Constructors
+/// @{
+public:
+ SymbolTable() {}
+ ~SymbolTable() {}
+
+/// @}
+/// @name Accessors
+/// @{
+public:
+ /// Generates a unique name for a node based on the \p BaseName by
+ /// incrementing an integer and appending it to the name, if necessary
+ /// @returns the unique name
+ /// @brief Get a unique name for a node
+ std::string getUniqueName(const std::string &BaseName) const;
+
+ /// This method finds the node with the given \p name in the node map
+ /// and returns it.
+ /// @returns null if the name is not found, otherwise the Node
+ /// associated with the \p name.
+ /// @brief Lookup a node by name.
+ Node* lookup(const std::string& name) const;
+
+ /// @returns true iff the symbol table is empty.
+ /// @brief Determine if the symbol table is empty
+ inline bool empty() const { return map_.empty(); }
+
+ /// @returns the size of the symbol table
+ /// @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
+/// @{
+public:
+ /// Get an iterator to the start of the symbol table
+ inline iterator begin() { return map_.begin(); }
+
+ /// @brief Get a const_iterator to the start of the symbol table
+ inline const_iterator begin() const { return map_.begin(); }
+
+ /// Get an iterator to the end of the symbol talbe.
+ inline iterator end() { return map_.end(); }
+
+ /// Get a const_iterator to the end of the symbol table.
+ inline const_iterator end() const { return map_.end(); }
+
+/// @}
+/// @name Mutators
+/// @{
+public:
+ /// Inserts a node into the symbol table with the specified name. There can
+ /// be a many-to-one mapping between names and nodes. This method allows a
+ /// node with an existing entry in the symbol table to get a new name.
+ /// @brief Insert a node under a new name.
+ void insert(const std::string &Name, const Node *N);
+
+ /// Remove a node at the specified position in the symbol table.
+ /// @returns the removed Node.
+ /// @returns the Node that was erased from the symbol table.
+ Node* erase(iterator TI);
+
+ /// Remove a specific Node from the symbol table. This isn't fast, linear
+ /// search, O(n), algorithm.
+ /// @returns true if the erase was successful (TI was found)
+ bool erase(Node* TI);
+
+ /// Rename a node. This ain't fast, we have to linearly search for it first.
+ /// @returns true if the rename was successful (node was found)
+ bool rename(Node* T, const std::string& new_name);
+
+/// @}
+/// @name Internal Data
+/// @{
+private:
+ NodeMap map_; ///< This is the mapping of names to types.
+ mutable unsigned long last_unique_; ///< Counter for tracking unique names
+/// @}
+};
- /// This class provides a symbol table of name/node pairs with operations to
- /// support constructing, searching and iterating over the symbol table.
- class SymbolTable
- {
- /// @name Types
- /// @{
- public:
- /// @brief A mapping of names to nodes.
- typedef std::map<const std::string, const Node*> NodeMap;
-
- /// @brief An iterator over the NodeMap.
- typedef NodeMap::iterator iterator;
-
- /// @brief A const_iterator over the NodeMap.
- typedef NodeMap::const_iterator const_iterator;
-
- /// @}
- /// @name Constructors
- /// @{
- public:
- SymbolTable() {}
- ~SymbolTable() {}
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- /// Generates a unique name for a node based on the \p BaseName by
- /// incrementing an integer and appending it to the name, if necessary
- /// @returns the unique name
- /// @brief Get a unique name for a node
- std::string getUniqueName(const std::string &BaseName) const;
-
- /// This method finds the node with the given \p name in the node map
- /// and returns it.
- /// @returns null if the name is not found, otherwise the Node
- /// associated with the \p name.
- /// @brief Lookup a node by name.
- Node* lookup(const std::string& name) const;
-
- /// @returns true iff the symbol table is empty.
- /// @brief Determine if the symbol table is empty
- inline bool empty() const { return map_.empty(); }
-
- /// @returns the size of the symbol table
- /// @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
- /// @{
- public:
- /// Get an iterator to the start of the symbol table
- inline iterator begin() { return map_.begin(); }
-
- /// @brief Get a const_iterator to the start of the symbol table
- inline const_iterator begin() const { return map_.begin(); }
-
- /// Get an iterator to the end of the symbol talbe.
- inline iterator end() { return map_.end(); }
-
- /// Get a const_iterator to the end of the symbol table.
- inline const_iterator end() const { return map_.end(); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- /// Inserts a node into the symbol table with the specified name. There can
- /// be a many-to-one mapping between names and nodes. This method allows a
- /// node with an existing entry in the symbol table to get a new name.
- /// @brief Insert a node under a new name.
- void insert(const std::string &Name, const Node *N);
-
- /// Remove a node at the specified position in the symbol table.
- /// @returns the removed Node.
- /// @returns the Node that was erased from the symbol table.
- Node* erase(iterator TI);
-
- /// Remove a specific Node from the symbol table. This isn't fast, linear
- /// search, O(n), algorithm.
- /// @returns true if the erase was successful (TI was found)
- bool erase(Node* TI);
-
- /// Rename a node. This ain't fast, we have to linearly search for it first.
- /// @returns true if the rename was successful (node was found)
- bool rename(Node* T, const std::string& new_name);
-
- /// @}
- /// @name Internal Data
- /// @{
- private:
- NodeMap map_; ///< This is the mapping of names to types.
- mutable unsigned long last_unique_; ///< Counter for tracking unique names
- /// @}
- };
-} // End AST namespace
} // End hlvm namespace
#endif
Modified: hlvm/trunk/hlvm/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Type.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Type.cpp (original)
+++ hlvm/trunk/hlvm/AST/Type.cpp Sat Jul 7 18:59:30 2007
@@ -30,7 +30,6 @@
#include <hlvm/AST/Type.h>
namespace hlvm {
-namespace AST {
Type::~Type()
{
@@ -241,4 +240,4 @@
{
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Type.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Type.h (original)
+++ hlvm/trunk/hlvm/AST/Type.h Sat Jul 7 18:59:30 2007
@@ -32,595 +32,594 @@
#include <hlvm/AST/LinkageItem.h>
-namespace hlvm {
-namespace AST {
+namespace hlvm
+{
- class IntrinsicType;
+class IntrinsicType;
- /// This class represents a Type in the HLVM Abstract Syntax Tree.
- /// A Type defines the format of storage.
- /// @brief HLVM AST Type Node
- class Type : public LinkageItem
- {
- /// @name Constructors
- /// @{
- protected:
- Type(
- NodeIDs id ///< The Type identifier
- ) : LinkageItem(id) {}
- virtual ~Type();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- bool isPrimitive() const { return getPrimitiveName() != 0; }
-
- /// @}
- /// @name Type Identification
- /// @{
- public:
- inline bool isPrimitiveType() const { return id <= LastPrimitiveTypeID; }
- inline bool isIntegralType() const {
- return id == IntegerTypeID || id == RangeTypeID;
- }
- inline bool isContainerType() const {
- return id >= FirstContainerTypeID;
- }
- inline bool isAnyType() const { return id == AnyTypeID; }
- inline bool isBooleanType() const { return id == BooleanTypeID; }
- inline bool isCharacterType() const { return id == CharacterTypeID; }
- inline bool isOctetType() const { return id == OctetTypeID; }
- inline bool isIntegerType() const { return id == IntegerTypeID; }
- inline bool isRangeType() const { return id == RangeTypeID; }
- inline bool isRealType() const { return id == RealTypeID; }
- inline bool isRationalType() const { return id == RationalTypeID; }
- inline bool isPointerType() const { return id == PointerTypeID; }
- inline bool isArrayType() const { return id == ArrayTypeID; }
- inline bool isVectorType() const { return id == VectorTypeID; }
- inline bool isStructureType() const { return id == StructureTypeID; }
- inline bool isSignatureType() const { return id == SignatureTypeID; }
- inline bool isVoidType() const { return id == VoidTypeID; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const Type*) { return true; }
- static inline bool classof(const Node* n) { return n->isType(); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- // We override receiveChild generically here to produce an error. Most
- // Type subclasses can't receive children. Those that do, can override
- // again.
- virtual void insertChild(Node* n);
-
- /// @}
- /// @name Data
- /// @{
- protected:
- /// @}
- friend class AST;
- };
-
- class AnyType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- AnyType() : Type(AnyTypeID) {}
- virtual ~AnyType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const AnyType*) { return true; }
- static inline bool classof(const Type* T) { return T->isAnyType(); }
- static inline bool classof(const Node* T) { return T->is(AnyTypeID); }
- /// @}
- friend class AST;
- };
-
- class BooleanType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- BooleanType() : Type(BooleanTypeID) {}
- virtual ~BooleanType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const BooleanType*) { return true; }
- static inline bool classof(const Type* T) { return T->isBooleanType(); }
- static inline bool classof(const Node* T) { return T->is(BooleanTypeID); }
- /// @}
- friend class AST;
- };
-
- class CharacterType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- CharacterType() : Type(CharacterTypeID) {}
- virtual ~CharacterType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const CharacterType*) { return true; }
- static inline bool classof(const Type* T) { return T->isCharacterType(); }
- static inline bool classof(const Node* T)
- { return T->is(CharacterTypeID); }
- /// @}
- friend class AST;
- };
-
- class OctetType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- OctetType() : Type(OctetTypeID) {}
- virtual ~OctetType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const OctetType*) { return true; }
- static inline bool classof(const Type* T) { return T->isOctetType(); }
- static inline bool classof(const Node* T) { return T->is(OctetTypeID); }
- /// @}
- friend class AST;
- };
-
- class VoidType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- VoidType() : Type(VoidTypeID) {}
- virtual ~VoidType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const VoidType*) { return true; }
- static inline bool classof(const Type* T) { return T->isVoidType(); }
- static inline bool classof(const Node* T) { return T->is(VoidTypeID); }
- /// @}
- friend class AST;
- };
-
- /// This class represents all HLVM integer types. An integer type declares the
- /// the minimum number of bits that are required to store the integer type.
- /// HLVM will convert this specification to the most appropriate sized
- /// machine type for computation. If the number of bits is specified as zero
- /// it implies infinite precision integer arithmetic.
- class IntegerType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- IntegerType() : Type(IntegerTypeID), numBits(32), signedness(true) {}
- public:
- virtual ~IntegerType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
-
- /// Return the number of bits
- uint64_t getBits() const { return numBits; }
-
- /// Return the signedness of the type
- bool isSigned() const { return signedness ; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const IntegerType*) { return true; }
- static inline bool classof(const Type* T) { return T->isIntegerType(); }
- static inline bool classof(const Node* T) { return T->is(IntegerTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- /// Set the number of bits for this integer type
- void setBits(uint64_t bits) { numBits = bits; }
-
- /// Set the signedness of the type
- void setSigned(bool isSigned) { signedness = isSigned; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- uint32_t numBits; ///< Minimum number of bits
- bool signedness; ///< Whether the integer type is signed or not
-
- /// @}
- friend class AST;
- };
-
- /// A RangeType is an IntegerType that allows the range of values to be
- /// constricted. The use of RangeType implies range checking whenever the
- /// value of a RangeType variable is assigned.
- class RangeType: public Type
- {
- /// @name Constructors
- /// @{
- protected:
- RangeType() : Type(RangeTypeID), min(0), max(256) {}
- public:
- virtual ~RangeType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- /// Get min value of range
- int64_t getMin() { return min; }
-
- /// Get max value of range
- int64_t getMax() { return max; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const RangeType*) { return true; }
- static inline bool classof(const Type* T) { return T->isRangeType(); }
- static inline bool classof(const Node* T) { return T->is(RangeTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- /// Set min value of range
- void setMin(int64_t val) { min = val; }
-
- /// Set max value of range
- void setMax(int64_t val) { max = val; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- int64_t min; ///< Lowest value accepted
- int64_t max; ///< Highest value accepted
- /// @}
- friend class AST;
- };
-
- /// This class represents an enumeration of things. Although represented by
- /// an integer type, enumerations have no value. They only have a collation
- /// order.
- class EnumerationType : public Type
- {
- /// @name Types
- /// @{
- public:
- typedef std::vector<std::string> EnumeratorList;
- typedef EnumeratorList::iterator iterator;
- typedef EnumeratorList::const_iterator const_iterator;
-
- /// @}
- /// @name Constructors
- /// @{
- protected:
- EnumerationType() : Type(EnumerationTypeID), enumerators() {}
- public:
- virtual ~EnumerationType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const EnumerationType*) { return true; }
- static inline bool classof(const Type* T)
- { return T->is(EnumerationTypeID); }
- static inline bool classof(const Node* T)
- { return T->is(EnumerationTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- void addEnumerator(const std::string& en) { enumerators.push_back(en); }
-
- /// @}
- /// @name Iterators
- /// @{
- public:
- iterator begin() { return enumerators.begin(); }
- const_iterator begin() const { return enumerators.begin(); }
- iterator end () { return enumerators.end(); }
- const_iterator end () const { return enumerators.end(); }
- size_t size () const { return enumerators.size(); }
- bool empty() const { return enumerators.empty(); }
- std::string front() { return enumerators.front(); }
- const std::string front() const { return enumerators.front(); }
- std::string back() { return enumerators.back(); }
- const std::string back() const { return enumerators.back(); }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- EnumeratorList enumerators; ///< The list of the enumerators
- /// @}
- friend class AST;
- };
-
- /// This class represents all HLVM real number types. The precision and
- /// mantissa are specified as a number of decimal digits to be provided as a
- /// minimum. HLVM will use the machine's natural floating point
- /// representation for those real types that can fit within the requested
- /// precision and mantissa lengths. If not, infinite precision floating point
- /// arithmetic will be utilized.
- class RealType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- RealType() : Type(RealTypeID), mantissa(52), exponent(11) {}
- public:
- virtual ~RealType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- /// Get the mantissa bits
- uint32_t getMantissa() { return mantissa; }
-
- /// Get the exponent bits
- uint32_t getExponent() { return exponent; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const RealType*) { return true; }
- static inline bool classof(const Type* T) { return T->isRealType(); }
- static inline bool classof(const Node* T) { return T->is(RealTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- /// Set the mantissa bits
- void setMantissa(uint32_t bits) { mantissa = bits; }
-
- /// Set the exponent bits
- void setExponent(uint32_t bits) { exponent = bits; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- uint32_t mantissa; ///< Number of decimal digits in mantissa
- uint32_t exponent; ///< Number of decimal digits of precision
- /// @}
- friend class AST;
- };
-
- /// This class represents a storage location that is a pointer to another
- /// type.
- class PointerType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- PointerType() : Type(PointerTypeID) {}
- virtual ~PointerType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- // Get the target type
- Type* getTargetType() { return type; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const PointerType*) { return true; }
- static inline bool classof(const Type* T) { return T->isPointerType(); }
- static inline bool classof(const Node* T) { return T->is(PointerTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- void setTargetType(Type* t) { type = t; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- Type* type;
- /// @}
- friend class AST;
- };
-
- /// This class represents a resizeable, aligned array of some other type. The
- /// Array references a Type that specifies the type of elements in the array.
- class ArrayType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- ArrayType() : Type(ArrayTypeID), type(0), maxSize(0) {}
- public:
- virtual ~ArrayType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- /// Get the type of the array's elements.
- Type* getElementType() const { return type; }
-
- /// Get the maximum size the array can grow to.
- uint64_t getMaxSize() const { return maxSize; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const ArrayType*) { return true; }
- static inline bool classof(const Type* T) { return T->isArrayType(); }
- static inline bool classof(const Node* T) { return T->is(ArrayTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- /// Set the type of the array's elements.
- void setElementType(Type* t) { type = t; }
-
- /// Set the maximum size the array can grow to.
- void setMaxSize(uint64_t max) { maxSize = max; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- Type* type; ///< The type of the elements of the array
- uint64_t maxSize; ///< The maximum number of elements in the array
- /// @}
- friend class AST;
- };
-
- /// This class represents a fixed size, packed vector of some other type.
- /// Where possible, HLVM will attempt to generate code that makes use of a
- /// machines vector instructions to process such types. If not possible, HLVM
- /// will treat the vector the same as an Array.
- class VectorType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- VectorType() : Type(VectorTypeID), type(0), size(0) {}
- virtual ~VectorType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- /// Get the type of the array's elements.
- Type* getElementType() const { return type; }
-
- /// Get the maximum size the array can grow to.
- uint64_t getSize() const { return size; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const VectorType*) { return true; }
- static inline bool classof(const Type* T) { return T->isVectorType(); }
- static inline bool classof(const Node* T) { return T->is(VectorTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- /// Set the type of the vector's elements.
- void setElementType(Type* t) { type = t; }
-
- /// Set the size of the vector.
- void setSize(uint64_t max) { size = max; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- Type* type; ///< The type of the vector's elements.
- uint64_t size; ///< The (fixed) size of the vector
- /// @}
- friend class AST;
- };
-
- /// This class is type that combines a name with an arbitrary type. This
- /// construct is used any where a named and typed object is needed such as
- /// the parameter to a function or the field of a structure.
- class AliasType : public Type
- {
- /// @name Constructors
- /// @{
- public:
- AliasType() : Type(AliasTypeID) {}
- virtual ~AliasType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- virtual const char* getPrimitiveName() const;
- // Get the name for the type
- const std::string& getName() const { return name; }
-
- // Get the type for the name
- Type * getType() const { return type; }
-
- // Methods to support type inquiry via is, cast, dyn_cast
- static inline bool classof(const AliasType*) { return true; }
- static inline bool classof(const Node* T) { return T->is(AliasTypeID); }
-
- /// @}
- /// @name Mutators
- /// @{
- public:
- // Set the name for the type
- void setName(const std::string& n) { name = n; }
-
- // Set the type for the name
- void setType(Type * t) { type = t; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- Type* type;
- std::string name;
- /// @}
- };
-
- class OpaqueType : public Type
- {
- /// @name Constructors
- /// @{
- protected:
- OpaqueType(const std::string& nm) :
- Type(OpaqueTypeID) { this->setName(nm); }
- public:
- virtual ~OpaqueType();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- static inline bool classof(const OpaqueType*) { return true; }
- static inline bool classof(const Node* N)
- { return N->is(OpaqueTypeID); }
-
- /// @}
- friend class AST;
- };
+/// This class represents a Type in the HLVM Abstract Syntax Tree.
+/// A Type defines the format of storage.
+/// @brief HLVM AST Type Node
+class Type : public LinkageItem
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ Type(
+ NodeIDs id ///< The Type identifier
+ ) : LinkageItem(id) {}
+ virtual ~Type();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ bool isPrimitive() const { return getPrimitiveName() != 0; }
+
+ /// @}
+ /// @name Type Identification
+ /// @{
+ public:
+ inline bool isPrimitiveType() const { return id <= LastPrimitiveTypeID; }
+ inline bool isIntegralType() const {
+ return id == IntegerTypeID || id == RangeTypeID;
+ }
+ inline bool isContainerType() const {
+ return id >= FirstContainerTypeID;
+ }
+ inline bool isAnyType() const { return id == AnyTypeID; }
+ inline bool isBooleanType() const { return id == BooleanTypeID; }
+ inline bool isCharacterType() const { return id == CharacterTypeID; }
+ inline bool isOctetType() const { return id == OctetTypeID; }
+ inline bool isIntegerType() const { return id == IntegerTypeID; }
+ inline bool isRangeType() const { return id == RangeTypeID; }
+ inline bool isRealType() const { return id == RealTypeID; }
+ inline bool isRationalType() const { return id == RationalTypeID; }
+ inline bool isPointerType() const { return id == PointerTypeID; }
+ inline bool isArrayType() const { return id == ArrayTypeID; }
+ inline bool isVectorType() const { return id == VectorTypeID; }
+ inline bool isStructureType() const { return id == StructureTypeID; }
+ inline bool isSignatureType() const { return id == SignatureTypeID; }
+ inline bool isVoidType() const { return id == VoidTypeID; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const Type*) { return true; }
+ static inline bool classof(const Node* n) { return n->isType(); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ // We override receiveChild generically here to produce an error. Most
+ // Type subclasses can't receive children. Those that do, can override
+ // again.
+ virtual void insertChild(Node* n);
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ /// @}
+ friend class AST;
+};
+
+class AnyType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ AnyType() : Type(AnyTypeID) {}
+ virtual ~AnyType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const AnyType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isAnyType(); }
+ static inline bool classof(const Node* T) { return T->is(AnyTypeID); }
+ /// @}
+ friend class AST;
+};
+
+class BooleanType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ BooleanType() : Type(BooleanTypeID) {}
+ virtual ~BooleanType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const BooleanType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isBooleanType(); }
+ static inline bool classof(const Node* T) { return T->is(BooleanTypeID); }
+ /// @}
+ friend class AST;
+};
+
+class CharacterType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ CharacterType() : Type(CharacterTypeID) {}
+ virtual ~CharacterType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const CharacterType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isCharacterType(); }
+ static inline bool classof(const Node* T)
+ { return T->is(CharacterTypeID); }
+ /// @}
+ friend class AST;
+};
+
+class OctetType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ OctetType() : Type(OctetTypeID) {}
+ virtual ~OctetType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const OctetType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isOctetType(); }
+ static inline bool classof(const Node* T) { return T->is(OctetTypeID); }
+ /// @}
+ friend class AST;
+};
+
+class VoidType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ VoidType() : Type(VoidTypeID) {}
+ virtual ~VoidType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const VoidType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isVoidType(); }
+ static inline bool classof(const Node* T) { return T->is(VoidTypeID); }
+ /// @}
+ friend class AST;
+};
+
+/// This class represents all HLVM integer types. An integer type declares the
+/// the minimum number of bits that are required to store the integer type.
+/// HLVM will convert this specification to the most appropriate sized
+/// machine type for computation. If the number of bits is specified as zero
+/// it implies infinite precision integer arithmetic.
+class IntegerType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ IntegerType() : Type(IntegerTypeID), numBits(32), signedness(true) {}
+ public:
+ virtual ~IntegerType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+
+ /// Return the number of bits
+ uint64_t getBits() const { return numBits; }
+
+ /// Return the signedness of the type
+ bool isSigned() const { return signedness ; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const IntegerType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isIntegerType(); }
+ static inline bool classof(const Node* T) { return T->is(IntegerTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ /// Set the number of bits for this integer type
+ void setBits(uint64_t bits) { numBits = bits; }
+
+ /// Set the signedness of the type
+ void setSigned(bool isSigned) { signedness = isSigned; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ uint32_t numBits; ///< Minimum number of bits
+ bool signedness; ///< Whether the integer type is signed or not
+
+ /// @}
+ friend class AST;
+};
+
+/// A RangeType is an IntegerType that allows the range of values to be
+/// constricted. The use of RangeType implies range checking whenever the
+/// value of a RangeType variable is assigned.
+class RangeType: public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ RangeType() : Type(RangeTypeID), min(0), max(256) {}
+ public:
+ virtual ~RangeType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ /// Get min value of range
+ int64_t getMin() { return min; }
+
+ /// Get max value of range
+ int64_t getMax() { return max; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const RangeType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isRangeType(); }
+ static inline bool classof(const Node* T) { return T->is(RangeTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ /// Set min value of range
+ void setMin(int64_t val) { min = val; }
+
+ /// Set max value of range
+ void setMax(int64_t val) { max = val; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ int64_t min; ///< Lowest value accepted
+ int64_t max; ///< Highest value accepted
+ /// @}
+ friend class AST;
+};
+
+/// This class represents an enumeration of things. Although represented by
+/// an integer type, enumerations have no value. They only have a collation
+/// order.
+class EnumerationType : public Type
+{
+ /// @name Types
+ /// @{
+ public:
+ typedef std::vector<std::string> EnumeratorList;
+ typedef EnumeratorList::iterator iterator;
+ typedef EnumeratorList::const_iterator const_iterator;
+
+ /// @}
+ /// @name Constructors
+ /// @{
+ protected:
+ EnumerationType() : Type(EnumerationTypeID), enumerators() {}
+ public:
+ virtual ~EnumerationType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const EnumerationType*) { return true; }
+ static inline bool classof(const Type* T)
+ { return T->is(EnumerationTypeID); }
+ static inline bool classof(const Node* T)
+ { return T->is(EnumerationTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ void addEnumerator(const std::string& en) { enumerators.push_back(en); }
+
+ /// @}
+ /// @name Iterators
+ /// @{
+ public:
+ iterator begin() { return enumerators.begin(); }
+ const_iterator begin() const { return enumerators.begin(); }
+ iterator end () { return enumerators.end(); }
+ const_iterator end () const { return enumerators.end(); }
+ size_t size () const { return enumerators.size(); }
+ bool empty() const { return enumerators.empty(); }
+ std::string front() { return enumerators.front(); }
+ const std::string front() const { return enumerators.front(); }
+ std::string back() { return enumerators.back(); }
+ const std::string back() const { return enumerators.back(); }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ EnumeratorList enumerators; ///< The list of the enumerators
+ /// @}
+ friend class AST;
+};
+
+/// This class represents all HLVM real number types. The precision and
+/// mantissa are specified as a number of decimal digits to be provided as a
+/// minimum. HLVM will use the machine's natural floating point
+/// representation for those real types that can fit within the requested
+/// precision and mantissa lengths. If not, infinite precision floating point
+/// arithmetic will be utilized.
+class RealType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ RealType() : Type(RealTypeID), mantissa(52), exponent(11) {}
+ public:
+ virtual ~RealType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ /// Get the mantissa bits
+ uint32_t getMantissa() { return mantissa; }
+
+ /// Get the exponent bits
+ uint32_t getExponent() { return exponent; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const RealType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isRealType(); }
+ static inline bool classof(const Node* T) { return T->is(RealTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ /// Set the mantissa bits
+ void setMantissa(uint32_t bits) { mantissa = bits; }
+
+ /// Set the exponent bits
+ void setExponent(uint32_t bits) { exponent = bits; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ uint32_t mantissa; ///< Number of decimal digits in mantissa
+ uint32_t exponent; ///< Number of decimal digits of precision
+ /// @}
+ friend class AST;
+};
+
+/// This class represents a storage location that is a pointer to another
+/// type.
+class PointerType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ PointerType() : Type(PointerTypeID) {}
+ virtual ~PointerType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ // Get the target type
+ Type* getTargetType() { return type; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const PointerType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isPointerType(); }
+ static inline bool classof(const Node* T) { return T->is(PointerTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ void setTargetType(Type* t) { type = t; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Type* type;
+ /// @}
+ friend class AST;
+};
+
+/// This class represents a resizeable, aligned array of some other type. The
+/// Array references a Type that specifies the type of elements in the array.
+class ArrayType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ ArrayType() : Type(ArrayTypeID), type(0), maxSize(0) {}
+ public:
+ virtual ~ArrayType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ /// Get the type of the array's elements.
+ Type* getElementType() const { return type; }
+
+ /// Get the maximum size the array can grow to.
+ uint64_t getMaxSize() const { return maxSize; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const ArrayType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isArrayType(); }
+ static inline bool classof(const Node* T) { return T->is(ArrayTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ /// Set the type of the array's elements.
+ void setElementType(Type* t) { type = t; }
+
+ /// Set the maximum size the array can grow to.
+ void setMaxSize(uint64_t max) { maxSize = max; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Type* type; ///< The type of the elements of the array
+ uint64_t maxSize; ///< The maximum number of elements in the array
+ /// @}
+ friend class AST;
+};
+
+/// This class represents a fixed size, packed vector of some other type.
+/// Where possible, HLVM will attempt to generate code that makes use of a
+/// machines vector instructions to process such types. If not possible, HLVM
+/// will treat the vector the same as an Array.
+class VectorType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ VectorType() : Type(VectorTypeID), type(0), size(0) {}
+ virtual ~VectorType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ /// Get the type of the array's elements.
+ Type* getElementType() const { return type; }
+
+ /// Get the maximum size the array can grow to.
+ uint64_t getSize() const { return size; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const VectorType*) { return true; }
+ static inline bool classof(const Type* T) { return T->isVectorType(); }
+ static inline bool classof(const Node* T) { return T->is(VectorTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ /// Set the type of the vector's elements.
+ void setElementType(Type* t) { type = t; }
+
+ /// Set the size of the vector.
+ void setSize(uint64_t max) { size = max; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Type* type; ///< The type of the vector's elements.
+ uint64_t size; ///< The (fixed) size of the vector
+ /// @}
+ friend class AST;
+};
+
+/// This class is type that combines a name with an arbitrary type. This
+/// construct is used any where a named and typed object is needed such as
+/// the parameter to a function or the field of a structure.
+class AliasType : public Type
+{
+ /// @name Constructors
+ /// @{
+ public:
+ AliasType() : Type(AliasTypeID) {}
+ virtual ~AliasType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ virtual const char* getPrimitiveName() const;
+ // Get the name for the type
+ const std::string& getName() const { return name; }
+
+ // Get the type for the name
+ Type * getType() const { return type; }
+
+ // Methods to support type inquiry via is, cast, dyn_cast
+ static inline bool classof(const AliasType*) { return true; }
+ static inline bool classof(const Node* T) { return T->is(AliasTypeID); }
+
+ /// @}
+ /// @name Mutators
+ /// @{
+ public:
+ // Set the name for the type
+ void setName(const std::string& n) { name = n; }
+
+ // Set the type for the name
+ void setType(Type * t) { type = t; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Type* type;
+ std::string name;
+ /// @}
+};
+
+class OpaqueType : public Type
+{
+ /// @name Constructors
+ /// @{
+ protected:
+ OpaqueType(const std::string& nm) :
+ Type(OpaqueTypeID) { this->setName(nm); }
+ public:
+ virtual ~OpaqueType();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ static inline bool classof(const OpaqueType*) { return true; }
+ static inline bool classof(const Node* N)
+ { return N->is(OpaqueTypeID); }
+
+ /// @}
+ friend class AST;
+};
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/AST/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Variable.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Variable.cpp (original)
+++ hlvm/trunk/hlvm/AST/Variable.cpp Sat Jul 7 18:59:30 2007
@@ -30,7 +30,6 @@
#include <hlvm/AST/Variable.h>
namespace hlvm {
-namespace AST {
Variable*
Variable::create(const Locator& loc, std::string name)
@@ -45,4 +44,4 @@
{
}
-}}
+}
Modified: hlvm/trunk/hlvm/AST/Variable.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/AST/Variable.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/AST/Variable.h (original)
+++ hlvm/trunk/hlvm/AST/Variable.h Sat Jul 7 18:59:30 2007
@@ -32,51 +32,50 @@
#include <hlvm/AST/LinkageItem.h>
-namespace hlvm
+namespace hlvm
{
-namespace AST
+
+class Type; // Forward declare
+
+/// This class represents an Variable in the HLVM Abstract Syntax Tree.
+/// A Variable is a storage location of a specific type. It can either be
+/// global or local, depending on its parent. Global variables are always
+/// contained in a Bundle. Local variables are always contained in a
+/// Function.
+/// @brief HLVM AST Variable Node
+class Variable : public LinkageItem
{
- class Type; // Forward declare
+ /// @name Constructors
+ /// @{
+ public:
+ static Variable* create(const Locator& loc, std::string name);
+ protected:
+ Variable() : LinkageItem(VariableID) {}
+ public:
+ virtual ~Variable();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ Type* getType() const { return type; }
+ static inline bool classof(const Variable*) { return true; }
+ static inline bool classof(const Node* N) { return N->isVariable(); }
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ void setType(Type* t) { type = t; }
+
+ /// @}
+ /// @name Data
+ /// @{
+ protected:
+ Type* type; ///< The type of the variable
+ /// @}
+ friend class AST;
+};
- /// This class represents an Variable in the HLVM Abstract Syntax Tree.
- /// A Variable is a storage location of a specific type. It can either be
- /// global or local, depending on its parent. Global variables are always
- /// contained in a Bundle. Local variables are always contained in a
- /// Function.
- /// @brief HLVM AST Variable Node
- class Variable : public LinkageItem
- {
- /// @name Constructors
- /// @{
- public:
- static Variable* create(const Locator& loc, std::string name);
- protected:
- Variable() : LinkageItem(VariableID) {}
- public:
- virtual ~Variable();
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- Type* getType() const { return type; }
- static inline bool classof(const Variable*) { return true; }
- static inline bool classof(const Node* N) { return N->isVariable(); }
-
- /// @}
- /// @name Accessors
- /// @{
- public:
- void setType(Type* t) { type = t; }
-
- /// @}
- /// @name Data
- /// @{
- protected:
- Type* type; ///< The type of the variable
- /// @}
- friend class AST;
- };
-} // AST
} // hlvm
#endif
Modified: hlvm/trunk/hlvm/Reader/Reader.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/Reader.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/Reader.h (original)
+++ hlvm/trunk/hlvm/Reader/Reader.h Sat Jul 7 18:59:30 2007
@@ -31,17 +31,19 @@
#define XPS_READER_READER_H
namespace hlvm {
-namespace AST { class AST; }
- class Reader
- {
- public:
- /// This method reads the entire content of the reader's source.
- virtual void read() = 0;
+class AST;
+
+class Reader
+{
+public:
+ /// This method reads the entire content of the reader's source.
+ virtual void read() = 0;
+
+ /// This method retrieves the construct AST that resulted from reading.
+ /// @returns 0 if nothing has been read yet
+ virtual AST* get() = 0;
+};
- /// This method retrieves the construct AST that resulted from reading.
- /// @returns 0 if nothing has been read yet
- virtual AST::AST* get() = 0;
- };
}
#endif
Modified: hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp Sat Jul 7 18:59:30 2007
@@ -55,24 +55,24 @@
class XMLReaderImpl : public XMLReader {
std::string path;
- AST::AST* ast;
+ AST* ast;
xmlDocPtr doc;
public:
XMLReaderImpl(const std::string& p)
: path(p), ast(0)
{
- ast = AST::AST::create();
+ ast = AST::create();
ast->setSystemID(p);
}
virtual ~XMLReaderImpl()
{
- if (ast) AST::AST::destroy(ast);
+ if (ast) AST::destroy(ast);
if (doc) xmlFreeDoc(doc);
}
virtual void read();
- virtual AST::AST* get();
+ virtual AST* get();
void error(const std::string& msg) {
std::cerr << msg << "\n";
@@ -87,20 +87,20 @@
inline void handleValidationError(xmlErrorPtr error);
void parseTree ();
- AST::AliasType* parseAlias (xmlNodePtr& cur);
- AST::Type* parseArray (xmlNodePtr& cur);
- AST::Type* parseAtom (xmlNodePtr& cur);
- AST::Bundle* parseBundle (xmlNodePtr& cur);
- AST::Documentation* parseDocumentation (xmlNodePtr& cur);
- AST::Type* parseEnumeration (xmlNodePtr& cur);
- AST::Function* parseFunction (xmlNodePtr& cur);
- AST::Import* parseImport (xmlNodePtr& cur);
- AST::Type* parsePointer (xmlNodePtr& cur);
- AST::Type* parseStructure (xmlNodePtr& cur);
- AST::Type* parseSignature (xmlNodePtr& cur);
- AST::Variable* parseVariable (xmlNodePtr& cur);
- AST::Type* parseVector (xmlNodePtr& cur);
- inline xmlNodePtr checkDoc(xmlNodePtr cur, AST::Documentable* node);
+ AliasType* parseAlias (xmlNodePtr& cur);
+ Type* parseArray (xmlNodePtr& cur);
+ Type* parseAtom (xmlNodePtr& cur);
+ Bundle* parseBundle (xmlNodePtr& cur);
+ Documentation* parseDocumentation (xmlNodePtr& cur);
+ Type* parseEnumeration (xmlNodePtr& cur);
+ Function* parseFunction (xmlNodePtr& cur);
+ Import* parseImport (xmlNodePtr& cur);
+ Type* parsePointer (xmlNodePtr& cur);
+ Type* parseStructure (xmlNodePtr& cur);
+ Type* parseSignature (xmlNodePtr& cur);
+ Variable* parseVariable (xmlNodePtr& cur);
+ Type* parseVector (xmlNodePtr& cur);
+ inline xmlNodePtr checkDoc(xmlNodePtr cur, Documentable* node);
private:
};
@@ -208,20 +208,20 @@
type = getAttribute(cur,"type");
}
-AST::Documentation*
+Documentation*
XMLReaderImpl::parseDocumentation(xmlNodePtr& cur)
{
// Documentation is always optional so don't error out if the
// node is not a TKN_doc
if (cur && skipBlanks(cur) && getToken(cur->name) == TKN_doc) {
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
xmlBufferPtr buffer = xmlBufferCreate();
xmlNodeDump(buffer,doc,cur,0,0);
int length = xmlBufferLength(buffer);
std::string str(reinterpret_cast<const char*>(xmlBufferContent(buffer)));
str.erase(0,5); // Zap the <doc> at the start
str.erase(str.length()-6); // Zap the </doc> at the end
- AST::Documentation* progDoc = ast->new_Documentation(loc);
+ Documentation* progDoc = ast->new_Documentation(loc);
progDoc->setDoc(str);
xmlBufferFree(buffer);
return progDoc;
@@ -231,10 +231,10 @@
}
inline xmlNodePtr
-XMLReaderImpl::checkDoc(xmlNodePtr cur, AST::Documentable* node)
+XMLReaderImpl::checkDoc(xmlNodePtr cur, Documentable* node)
{
xmlNodePtr child = cur->children;
- AST::Documentation* theDoc = parseDocumentation(child);
+ Documentation* theDoc = parseDocumentation(child);
if (theDoc) {
node->setDoc(theDoc);
return child->next;
@@ -242,51 +242,51 @@
return child;
}
-AST::Function*
+Function*
XMLReaderImpl::parseFunction(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_function);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name, type;
getNameType(cur, name, type);
- AST::Function* func = ast->new_Function(loc,name);
+ Function* func = ast->new_Function(loc,name);
checkDoc(cur,func);
return func;
}
-AST::Import*
+Import*
XMLReaderImpl::parseImport(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_import);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string pfx = getAttribute(cur,"prefix");
- AST::Import* imp = ast->new_Import(loc,pfx);
+ Import* imp = ast->new_Import(loc,pfx);
checkDoc(cur,imp);
return imp;
}
-AST::AliasType*
+AliasType*
XMLReaderImpl::parseAlias(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_alias);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"renames");
- AST::AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
+ AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
checkDoc(cur,alias);
return alias;
}
-AST::Type*
+Type*
XMLReaderImpl::parseAtom(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_atom);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
xmlNodePtr child = cur->children;
- AST::Documentation* theDoc = parseDocumentation(child);
+ Documentation* theDoc = parseDocumentation(child);
child = (theDoc==0 ? child : child->next );
- AST::Type* result = 0;
+ Type* result = 0;
if (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
int tkn = getToken(child->name);
switch (tkn) {
@@ -376,13 +376,13 @@
assert(!"Atom definition element expected");
}
-AST::Type*
+Type*
XMLReaderImpl::parseEnumeration(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_enumeration);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
- AST::EnumerationType* en = ast->new_EnumerationType(loc,name);
+ EnumerationType* en = ast->new_EnumerationType(loc,name);
xmlNodePtr child = checkDoc(cur,en);
while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
assert(getToken(child->name) == TKN_enumerator);
@@ -393,61 +393,61 @@
return en;
}
-AST::Type*
+Type*
XMLReaderImpl::parsePointer(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_pointer);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"to");
- AST::PointerType* result =
+ PointerType* result =
ast->new_PointerType(loc,name,ast->resolveType(type));
checkDoc(cur,result);
return result;
}
-AST::Type*
+Type*
XMLReaderImpl::parseArray(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_array);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"of");
const char* len = getAttribute(cur,"length");
- AST::ArrayType* result = ast->new_ArrayType(
+ ArrayType* result = ast->new_ArrayType(
loc, name, ast->resolveType(type), recognize_nonNegativeInteger(len));
checkDoc(cur,result);
return result;
}
-AST::Type*
+Type*
XMLReaderImpl::parseVector(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_vector);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string type = getAttribute(cur,"of");
const char* len = getAttribute(cur,"length");
- AST::VectorType* result =
+ VectorType* result =
ast->new_VectorType(
loc,name,ast->resolveType(type), recognize_nonNegativeInteger(len));
checkDoc(cur,result);
return result;
}
-AST::Type*
+Type*
XMLReaderImpl::parseStructure(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_structure);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
- AST::StructureType* struc = ast->new_StructureType(loc,name);
+ StructureType* struc = ast->new_StructureType(loc,name);
xmlNodePtr child = checkDoc(cur,struc);
while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE) {
assert(getToken(child->name) == TKN_field && "Structure only has fields");
std::string name = getAttribute(child,"name");
std::string type = getAttribute(child,"type");
- AST::AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
+ AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
alias->setParent(struc);
checkDoc(child,alias);
child = child->next;
@@ -455,15 +455,15 @@
return struc;
}
-AST::Type*
+Type*
XMLReaderImpl::parseSignature(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_signature);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name = getAttribute(cur,"name");
std::string result = getAttribute(cur,"result");
const char* varargs = getAttribute(cur,"varargs",false);
- AST::SignatureType* sig =
+ SignatureType* sig =
ast->new_SignatureType(loc,name,ast->resolveType(result));
if (varargs)
sig->setIsVarArgs(recognize_boolean(varargs));
@@ -472,7 +472,7 @@
assert(getToken(child->name) == TKN_arg && "Signature only has args");
std::string name = getAttribute(child,"name");
std::string type = getAttribute(child,"type");
- AST::AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
+ AliasType* alias = ast->new_AliasType(loc,name,ast->resolveType(type));
alias->setParent(sig);
checkDoc(child,alias);
child = child->next;
@@ -480,34 +480,34 @@
return sig;
}
-AST::Variable*
+Variable*
XMLReaderImpl::parseVariable(xmlNodePtr& cur)
{
assert(getToken(cur->name)==TKN_var);
- AST::Locator loc(cur->line,0,&ast->getSystemID());
+ Locator loc(cur->line,0,&ast->getSystemID());
std::string name, type;
getNameType(cur, name, type);
- AST::Variable* var = ast->new_Variable(loc,name);
+ Variable* var = ast->new_Variable(loc,name);
var->setType(ast->resolveType(type));
checkDoc(cur,var);
return var;
}
-AST::Bundle*
+Bundle*
XMLReaderImpl::parseBundle(xmlNodePtr& cur)
{
assert(getToken(cur->name) == TKN_bundle && "Expecting bundle element");
std::string pubid(getAttribute(cur, "pubid"));
- AST::Locator loc(cur->line,0,&ast->getSystemID());
- AST::Bundle* bundle = ast->new_Bundle(loc,pubid);
+ Locator loc(cur->line,0,&ast->getSystemID());
+ Bundle* bundle = ast->new_Bundle(loc,pubid);
xmlNodePtr child = cur->children;
while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE)
{
int tkn = getToken(child->name);
- AST::Node* n = 0;
+ Node* n = 0;
switch (tkn) {
case TKN_doc :
- AST::Documentation* theDoc = parseDocumentation(child);
+ Documentation* theDoc = parseDocumentation(child);
if (theDoc)
bundle->setDoc(theDoc);
break;
@@ -546,7 +546,7 @@
assert(tkn == TKN_hlvm && "Expecting hlvm element");
cur = cur->children;
if (skipBlanks(cur)) {
- AST::Bundle* bundle = parseBundle(cur);
+ Bundle* bundle = parseBundle(cur);
ast->setRoot(bundle);
}
}
@@ -631,7 +631,7 @@
doc = 0;
}
-AST::AST*
+AST*
XMLReaderImpl::get()
{
return ast;
Modified: hlvm/trunk/hlvm/Reader/XML/XMLReader.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/XMLReader.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.h (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.h Sat Jul 7 18:59:30 2007
@@ -35,17 +35,16 @@
namespace hlvm {
- class AST::AST;
+class XMLReader : public Reader
+{
+public:
+ /// This method instantiates an XMLReader that is prepared to read from
+ /// the path provided.
+ /// @brief Create a new XmlReader
+ static XMLReader* create(const std::string& path);
- class XMLReader : public Reader
- {
- public:
- /// This method instantiates an XMLReader that is prepared to read from
- /// the path provided.
- /// @brief Create a new XmlReader
- static XMLReader* create(const std::string& path);
+ virtual ~XMLReader() {}
+};
- virtual ~XMLReader() {}
- };
}
#endif
Modified: hlvm/trunk/hlvm/Writer/Writer.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/Writer.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Writer/Writer.h (original)
+++ hlvm/trunk/hlvm/Writer/Writer.h Sat Jul 7 18:59:30 2007
@@ -31,14 +31,16 @@
#define XPS_WRITER_WRITER_H
namespace hlvm {
-namespace AST { class AST; }
- class Writer
- {
- public:
- /// This method writes the entire content of the AST to the writer's
- /// destination
- virtual void write(AST::AST* source) = 0;
- };
+class AST;
+
+class Writer
+{
+public:
+ /// This method writes the entire content of the AST to the writer's
+ /// destination
+ virtual void write(AST* source) = 0;
+};
+
}
#endif
Modified: hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp (original)
+++ hlvm/trunk/hlvm/Writer/XML/XMLWriter.cpp Sat Jul 7 18:59:30 2007
@@ -47,7 +47,7 @@
class XMLWriterImpl : public XMLWriter {
xmlTextWriterPtr writer;
- AST::AST* node;
+ AST* node;
public:
XMLWriterImpl(const char* fname)
: writer(0), node(0)
@@ -63,7 +63,7 @@
xmlFreeTextWriter(writer);
}
- virtual void write(AST::AST* node);
+ virtual void write(AST* node);
private:
inline void writeComment(const char* cmt)
@@ -80,7 +80,7 @@
reinterpret_cast<const xmlChar*>(val)); }
inline void writeAttribute(const char* name, const std::string& val)
{ writeAttribute(name, val.c_str()); }
- inline void writeAttribute(const char* name, AST::Type* t)
+ inline void writeAttribute(const char* name, Type* t)
{ writeAttribute(name, t->getName()); }
inline void writeAttribute(const char* name, uint64_t val)
{ writeAttribute(name, llvm::utostr(val)); }
@@ -91,32 +91,32 @@
inline void putHeader();
inline void putFooter();
- inline void putDoc(AST::Documentable* node);
- inline void put(AST::Bundle* b);
- inline void put(AST::Documentation* b);
- inline void put(AST::Variable* v);
- inline void put(AST::Function* f);
- inline void put(AST::AliasType* t);
- inline void put(AST::AnyType* t);
- inline void put(AST::BooleanType* t);
- inline void put(AST::CharacterType* t);
- inline void put(AST::IntegerType* t);
- inline void put(AST::RangeType* t);
- inline void put(AST::EnumerationType* t);
- inline void put(AST::RealType* t);
- inline void put(AST::OctetType* t);
- inline void put(AST::VoidType* t);
- inline void put(AST::PointerType* t);
- inline void put(AST::ArrayType* t);
- inline void put(AST::VectorType* t);
- inline void put(AST::StructureType* t);
- inline void put(AST::SignatureType* t);
+ inline void putDoc(Documentable* node);
+ inline void put(Bundle* b);
+ inline void put(Documentation* b);
+ inline void put(Variable* v);
+ inline void put(Function* f);
+ inline void put(AliasType* t);
+ inline void put(AnyType* t);
+ inline void put(BooleanType* t);
+ inline void put(CharacterType* t);
+ inline void put(IntegerType* t);
+ inline void put(RangeType* t);
+ inline void put(EnumerationType* t);
+ inline void put(RealType* t);
+ inline void put(OctetType* t);
+ inline void put(VoidType* t);
+ inline void put(PointerType* t);
+ inline void put(ArrayType* t);
+ inline void put(VectorType* t);
+ inline void put(StructureType* t);
+ inline void put(SignatureType* t);
};
inline void
-XMLWriterImpl::putDoc(AST::Documentable* node)
+XMLWriterImpl::putDoc(Documentable* node)
{
- AST::Documentation* theDoc = node->getDoc();
+ Documentation* theDoc = node->getDoc();
if (theDoc) {
this->put(theDoc);
}
@@ -138,12 +138,12 @@
}
void
-XMLWriterImpl::put(AST::Function* f)
+XMLWriterImpl::put(Function* f)
{
}
void
-XMLWriterImpl::put(AST::Documentation* b)
+XMLWriterImpl::put(Documentation* b)
{
startElement("doc");
const std::string& data = b->getDoc();
@@ -153,7 +153,7 @@
}
void
-XMLWriterImpl::put(AST::AliasType* t)
+XMLWriterImpl::put(AliasType* t)
{
startElement("alias");
writeAttribute("name",t->getName());
@@ -162,7 +162,7 @@
endElement();
}
void
-XMLWriterImpl::put(AST::AnyType* t)
+XMLWriterImpl::put(AnyType* t)
{
startElement("atom");
writeAttribute("name",t->getName());
@@ -174,7 +174,7 @@
}
void
-XMLWriterImpl::put(AST::BooleanType* t)
+XMLWriterImpl::put(BooleanType* t)
{
startElement("atom");
writeAttribute("name",t->getName().c_str());
@@ -186,7 +186,7 @@
}
void
-XMLWriterImpl::put(AST::CharacterType* t)
+XMLWriterImpl::put(CharacterType* t)
{
startElement("atom");
writeAttribute("name",t->getName().c_str());
@@ -198,7 +198,7 @@
}
void
-XMLWriterImpl::put(AST::IntegerType* t)
+XMLWriterImpl::put(IntegerType* t)
{
startElement("atom");
writeAttribute("name",t->getName().c_str());
@@ -219,7 +219,7 @@
}
void
-XMLWriterImpl::put(AST::RangeType* t)
+XMLWriterImpl::put(RangeType* t)
{
startElement("range");
writeAttribute("name",t->getName());
@@ -230,12 +230,12 @@
}
void
-XMLWriterImpl::put(AST::EnumerationType* t)
+XMLWriterImpl::put(EnumerationType* t)
{
startElement("enumeration");
writeAttribute("name",t->getName());
putDoc(t);
- for (AST::EnumerationType::const_iterator I = t->begin(), E = t->end();
+ for (EnumerationType::const_iterator I = t->begin(), E = t->end();
I != E; ++I)
{
startElement("enumerator");
@@ -246,7 +246,7 @@
}
void
-XMLWriterImpl::put(AST::RealType* t)
+XMLWriterImpl::put(RealType* t)
{
startElement("atom");
writeAttribute("name",t->getName().c_str());
@@ -266,7 +266,7 @@
}
void
-XMLWriterImpl::put(AST::OctetType* t)
+XMLWriterImpl::put(OctetType* t)
{
startElement("atom");
writeAttribute("name",t->getName().c_str());
@@ -278,7 +278,7 @@
}
void
-XMLWriterImpl::put(AST::VoidType* t)
+XMLWriterImpl::put(VoidType* t)
{
startElement("atom");
writeAttribute("name",t->getName());
@@ -290,7 +290,7 @@
}
void
-XMLWriterImpl::put(AST::PointerType* t)
+XMLWriterImpl::put(PointerType* t)
{
startElement("pointer");
writeAttribute("name", t->getName());
@@ -300,7 +300,7 @@
}
void
-XMLWriterImpl::put(AST::ArrayType* t)
+XMLWriterImpl::put(ArrayType* t)
{
startElement("array");
writeAttribute("name", t->getName());
@@ -311,7 +311,7 @@
}
void
-XMLWriterImpl::put(AST::VectorType* t)
+XMLWriterImpl::put(VectorType* t)
{
startElement("vector");
writeAttribute("name", t->getName());
@@ -322,14 +322,14 @@
}
void
-XMLWriterImpl::put(AST::StructureType* t)
+XMLWriterImpl::put(StructureType* t)
{
startElement("structure");
writeAttribute("name",t->getName());
putDoc(t);
- for (AST::StructureType::iterator I = t->begin(), E = t->end(); I != E; ++I) {
+ for (StructureType::iterator I = t->begin(), E = t->end(); I != E; ++I) {
startElement("field");
- AST::AliasType* alias = cast<AST::AliasType>(*I);
+ AliasType* alias = cast<AliasType>(*I);
writeAttribute("name",alias->getName());
writeAttribute("type",alias->getType());
putDoc(alias);
@@ -339,16 +339,16 @@
}
void
-XMLWriterImpl::put(AST::SignatureType* t)
+XMLWriterImpl::put(SignatureType* t)
{
startElement("signature");
writeAttribute("name",t->getName());
writeAttribute("result",t->getResultType());
writeAttribute("varargs",t->isVarArgs() ? "true" : "false");
putDoc(t);
- for (AST::SignatureType::iterator I = t->begin(), E = t->end(); I != E; ++I) {
+ for (SignatureType::iterator I = t->begin(), E = t->end(); I != E; ++I) {
startElement("arg");
- AST::AliasType* alias = cast<AST::AliasType>(*I);
+ AliasType* alias = cast<AliasType>(*I);
writeAttribute("name",alias->getName());
writeAttribute("type",alias->getType());
putDoc(alias);
@@ -358,7 +358,7 @@
}
void
-XMLWriterImpl::put(AST::Variable* v)
+XMLWriterImpl::put(Variable* v)
{
startElement("var");
writeAttribute("name",v->getName().c_str());
@@ -368,33 +368,33 @@
}
void
-XMLWriterImpl::put(AST::Bundle* b)
+XMLWriterImpl::put(Bundle* b)
{
startElement("bundle");
writeAttribute("pubid",b->getName().c_str());
putDoc(b);
- for (AST::Bundle::const_iterator I = b->begin(),E = b->end(); I != E; ++I)
+ for (Bundle::const_iterator I = b->begin(),E = b->end(); I != E; ++I)
{
switch ((*I)->getID())
{
- case AST::DocumentationID: put(cast<AST::Documentation>(*I)); break;
- case AST::VariableID: put(cast<AST::Variable>(*I)); break;
- case AST::FunctionID: put(cast<AST::Function>(*I)); break;
- case AST::AliasTypeID: put(cast<AST::AliasType>(*I)); break;
- case AST::AnyTypeID: put(cast<AST::AnyType>(*I)); break;
- case AST::BooleanTypeID: put(cast<AST::BooleanType>(*I)); break;
- case AST::CharacterTypeID: put(cast<AST::CharacterType>(*I)); break;
- case AST::IntegerTypeID: put(cast<AST::IntegerType>(*I)); break;
- case AST::RangeTypeID: put(cast<AST::RangeType>(*I)); break;
- case AST::EnumerationTypeID: put(cast<AST::EnumerationType>(*I)); break;
- case AST::RealTypeID: put(cast<AST::RealType>(*I)); break;
- case AST::OctetTypeID: put(cast<AST::OctetType>(*I)); break;
- case AST::VoidTypeID: put(cast<AST::VoidType>(*I)); break;
- case AST::PointerTypeID: put(cast<AST::PointerType>(*I)); break;
- case AST::ArrayTypeID: put(cast<AST::ArrayType>(*I)); break;
- case AST::VectorTypeID: put(cast<AST::VectorType>(*I)); break;
- case AST::StructureTypeID: put(cast<AST::StructureType>(*I)); break;
- case AST::SignatureTypeID: put(cast<AST::SignatureType>(*I)); break;
+ case DocumentationID: put(cast<Documentation>(*I)); break;
+ case VariableID: put(cast<Variable>(*I)); break;
+ case FunctionID: put(cast<Function>(*I)); break;
+ case AliasTypeID: put(cast<AliasType>(*I)); break;
+ case AnyTypeID: put(cast<AnyType>(*I)); break;
+ case BooleanTypeID: put(cast<BooleanType>(*I)); break;
+ case CharacterTypeID: put(cast<CharacterType>(*I)); break;
+ case IntegerTypeID: put(cast<IntegerType>(*I)); break;
+ case RangeTypeID: put(cast<RangeType>(*I)); break;
+ case EnumerationTypeID: put(cast<EnumerationType>(*I)); break;
+ case RealTypeID: put(cast<RealType>(*I)); break;
+ case OctetTypeID: put(cast<OctetType>(*I)); break;
+ case VoidTypeID: put(cast<VoidType>(*I)); break;
+ case PointerTypeID: put(cast<PointerType>(*I)); break;
+ case ArrayTypeID: put(cast<ArrayType>(*I)); break;
+ case VectorTypeID: put(cast<VectorType>(*I)); break;
+ case StructureTypeID: put(cast<StructureType>(*I)); break;
+ case SignatureTypeID: put(cast<SignatureType>(*I)); break;
default:
assert(!"Invalid bundle content");
}
@@ -403,7 +403,7 @@
}
void
-XMLWriterImpl::write(AST::AST* ast)
+XMLWriterImpl::write(AST* ast)
{
node = ast;
putHeader();
Modified: hlvm/trunk/hlvm/Writer/XML/XMLWriter.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Writer/XML/XMLWriter.h?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Writer/XML/XMLWriter.h (original)
+++ hlvm/trunk/hlvm/Writer/XML/XMLWriter.h Sat Jul 7 18:59:30 2007
@@ -35,15 +35,16 @@
namespace hlvm {
- class XMLWriter: public Writer
- {
- public:
- /// This method instantiates an XMLReader that is prepared to read from
- /// the path provided.
- /// @brief Create a new XmlReader
- static XMLWriter* create(const char* fname);
+class XMLWriter: public Writer
+{
+public:
+ /// This method instantiates an XMLReader that is prepared to read from
+ /// the path provided.
+ /// @brief Create a new XmlReader
+ static XMLWriter* create(const char* fname);
+
+ virtual ~XMLWriter() {}
+};
- virtual ~XMLWriter() {}
- };
}
#endif
Modified: hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp?rev=38067&r1=38066&r2=38067&view=diff
==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp (original)
+++ hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp Sat Jul 7 18:59:30 2007
@@ -91,7 +91,7 @@
XMLReader* rdr = XMLReader::create(InputFilename);
XMLWriter* wrtr = XMLWriter::create(OutputFilename.c_str());
rdr->read();
- AST::AST* node = rdr->get();
+ AST* node = rdr->get();
if (node) {
wrtr->write(node);
}
More information about the llvm-commits
mailing list