Add support for enums.

This commit is contained in:
Matt Pharr
2011-07-17 16:43:05 +02:00
parent 17e5c8b7c2
commit f0f876c3ec
23 changed files with 1031 additions and 251 deletions

48
type.h
View File

@@ -205,7 +205,7 @@ public:
LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
/** This enumerant records the basic types that AtomicTypes can be
/** This enumerator records the basic types that AtomicTypes can be
built from. */
enum BasicType {
TYPE_VOID,
@@ -243,6 +243,52 @@ private:
};
/** @brief Type implementation for enumerated types
*/
class EnumType : public Type {
public:
/** Constructor for anonymous enumerated types */
EnumType(SourcePos pos);
/** Constructor for named enumerated types */
EnumType(const char *name, SourcePos pos);
bool IsUniformType() const;
bool IsBoolType() const;
bool IsFloatType() const;
bool IsIntType() const;
bool IsUnsignedType() const;
bool IsConstType() const;
const EnumType *GetBaseType() const;
const EnumType *GetAsVaryingType() const;
const EnumType *GetAsUniformType() const;
const Type *GetSOAType(int width) const;
const EnumType *GetAsConstType() const;
const EnumType *GetAsNonConstType() const;
std::string GetString() const;
std::string Mangle() const;
std::string GetCDeclaration(const std::string &name) const;
LLVM_TYPE_CONST llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
/** Provides the enumerators defined in the enum definition. */
void SetEnumerators(const std::vector<Symbol *> &enumerators);
/** Returns the total number of enuemrators in this enum type. */
int GetEnumeratorCount() const;
/** Returns the symbol for the given enumerator number. */
const Symbol *GetEnumerator(int i) const;
const SourcePos pos;
private:
const std::string name;
bool isUniform, isConst;
std::vector<Symbol *> enumerators;
};
/** @brief Abstract base class for types that represent collections of
other types.