From 190b7a0e5d45367230795ac0bdf6fc2f248ba9e1 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Tue, 21 Mar 2017 17:03:38 +0000 Subject: changed type layout to have all necessary information --- c_compiler/include/type.hpp | 86 ++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 28 deletions(-) (limited to 'c_compiler/include/type.hpp') diff --git a/c_compiler/include/type.hpp b/c_compiler/include/type.hpp index 9b9bbba..bd9fd4b 100644 --- a/c_compiler/include/type.hpp +++ b/c_compiler/include/type.hpp @@ -8,71 +8,101 @@ #include class Type; - typedef std::shared_ptr TypePtr; - -class Type : public Node { +class Type : public Node +{ public: virtual void print() const; virtual void printXml() const; virtual VariableStackBindings printAsm(VariableStackBindings bindings, unsigned& label_count) const; virtual std::string getType() const = 0; -}; + virtual TypePtr type(); + virtual TypePtr type(Type* type_ptr); + virtual TypePtr type(TypePtr type_ptr); + virtual void setSigned(bool _signed); + virtual void setExtern(bool _extern); + virtual void setStatic(bool _static); + virtual void setConst(bool _const); + virtual void setSize(int size); +}; -class Specifier : public Type { +class Array : public Type +{ public: - virtual std::string getType() const = 0; + Array(); + virtual std::string getType() const; }; - -class Pointer : public Type { -protected: - TypePtr pointer_type_; - +class Pointer : public Type +{ public: - Pointer(Type* pointer_type); - + Pointer(); virtual std::string getType() const; }; - -class Array : public Type { +class TypeContainer : public Type +{ protected: - TypePtr array_type_; - unsigned size_; + TypePtr type_; + int size_; + bool extern_; + bool static_; + bool const_; + bool signed_; public: - Array(Type* array_type, unsigned size = 0); - + TypeContainer(); + virtual std::string getType() const; + virtual TypePtr type(); + virtual TypePtr type(Type* type_ptr); + virtual TypePtr type(TypePtr type_ptr); + virtual void setSigned(bool _signed); + virtual void setExtern(bool _extern); + virtual void setStatic(bool _static); + virtual void setConst(bool _const); + virtual void setSize(int size); }; - -class Void : public Specifier { +class Specifier : public Type +{ public: - Void(); - - virtual std::string getType() const; + virtual std::string getType() const = 0; }; - -class Int : public Specifier { +class Int : public Specifier +{ public: Int(); virtual std::string getType() const; }; +class Void : public Specifier +{ +public: + Void(); + + virtual std::string getType() const; +}; -class Char : public Specifier { +class Char : public Specifier +{ public: Char(); - virtual std::string getType() const; + virtual std::string getType() const; }; +class Float : public Specifier +{ +public: + Float(); + + virtual std::string getType() const; +}; #endif -- cgit