#ifndef TYPE_H #define TYPE_H #ifndef NULL #define NULL ((void*)0) #endif #include #include #include //Circular dependency class ASTData; #include "ASTData.h" #include "util.h" enum ValueType {none, template_type, template_type_type, void_type, boolean, character, integer, floating, double_percision, function_type }; class Type { public: Type(); Type(ValueType typeIn, int indirectionIn = 0); Type(ValueType typeIn, std::set traitsIn); //Mostly for template type type's Type(NodeTree* typeDefinitionIn, int indirectionIn = 0); Type(NodeTree* typeDefinitionIn, std::set traitsIn); Type(ValueType typeIn, NodeTree* typeDefinitionIn, int indirectionIn, bool referenceIn, std::set traitsIn); Type(ValueType typeIn, NodeTree* typeDefinitionIn, int indirectionIn, bool referenceIn, std::set traitsIn, std::vector parameterTypesIn, Type* returnTypeIn); Type(std::vector parameterTypesIn, Type* returnTypeIn, bool referenceIn = false); Type(ValueType typeIn, NodeTree* templateDefinitionIn, std::set traitsIn = std::set()); ~Type(); const bool test_equality(const Type &other, bool care_about_references) const; bool const operator==(const Type &other)const; bool const operator!=(const Type &other)const; bool const operator<(const Type &other)const; Type* clone(); std::string toString(bool showTraits = true); int getIndirection(); void setIndirection(int indirectionIn); void increaseIndirection(); void decreaseIndirection(); void modifyIndirection(int mod); Type withIncreasedIndirection(); Type withReference(); Type *withReferencePtr(); Type *withIncreasedIndirectionPtr(); Type withDecreasedIndirection(); Type* withoutReference(); ValueType baseType; NodeTree* typeDefinition; NodeTree* templateDefinition; std::map templateTypeReplacement; bool templateInstantiated; std::set traits; std::vector parameterTypes; Type *returnType; bool is_reference; private: int indirection; }; #endif