#ifndef PCC_TYPEIDENTIFIER_HH #define PCC_TYPEIDENTIFIER_HH #include #include "Context.hh" #include "Type.hh" #include "VariableList.hh" namespace pcc { // since TypeIdentifier returns std::shared_ptr instead of llvm::Value*, // we won't use CodeGen() override. class TypeIdentifier { public: TypeIdentifier(Context* context, std::shared_ptr type = nullptr); virtual std::shared_ptr GetType() = 0; protected: Context* context_; std::shared_ptr type_; }; class TrivialTypeIdentifier : public TypeIdentifier { public: TrivialTypeIdentifier(Context* context, std::shared_ptr type); virtual std::shared_ptr GetType() override; }; class AliasTypeIdentifier : public TypeIdentifier { public: AliasTypeIdentifier(Context* context, std::string&& alias); virtual std::shared_ptr GetType() override; protected: std::string alias_; }; // for pointers and arrays, so that we can create pointers to other alias type class PointerTypeIdentifier : public TypeIdentifier { public: PointerTypeIdentifier(Context* context, std::shared_ptr ElementType); virtual std::shared_ptr GetType() override; protected: std::shared_ptr ElementType_; }; class ArrayTypeIdentifier : public TypeIdentifier { public: ArrayTypeIdentifier(Context* context, std::shared_ptr ElementType, std::shared_ptr start, std::shared_ptr end); virtual std::shared_ptr GetType() override; protected: std::shared_ptr ElementType_; std::shared_ptr start_; std::shared_ptr end_; }; class RecordTypeIdentifier : public TypeIdentifier { public: RecordTypeIdentifier(Context* context, std::list&& members); virtual std::shared_ptr GetType() override; protected: std::list members_; }; } // namespace pcc #endif // !PCC_TYPEIDENTIFIER_HH