diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-11 23:37:46 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-14 06:16:14 +0800 |
commit | c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae (patch) | |
tree | 695fbc92111b1853fdee6500c92e55555666759f /Types.h | |
parent | 86e1d671cc4ed9b89576c80e16e58a8019115068 (diff) | |
download | dexon-solidity-c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae.tar.gz dexon-solidity-c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae.tar.zst dexon-solidity-c3a9ae0b0657861c8cc27f60358b0bfe99ed05ae.zip |
Introducing EnumType and some Parser tests
Diffstat (limited to 'Types.h')
-rw-r--r-- | Types.h | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -76,10 +76,9 @@ class Type: private boost::noncopyable, public std::enable_shared_from_this<Type public: enum class Category { - Integer, IntegerConstant, Bool, Real, String, - ByteArray, Mapping, - Contract, Struct, Function, - Void, TypeType, Modifier, Magic + Integer, IntegerConstant, Bool, Real, ByteArray, + String, Contract, Struct, Function, Enum, + Mapping, Void, TypeType, Modifier, Magic }; ///@{ @@ -369,6 +368,27 @@ private: }; /** + * The type of an enum instance, there is one distinct type per enum definition. + */ +class EnumType: public Type +{ +public: + virtual Category getCategory() const override { return Category::Enum; } + explicit EnumType(EnumDefinition const& _enum): m_enum(_enum) {} + virtual TypePointer unaryOperatorResult(Token::Value _operator) const override; + virtual bool operator==(Type const& _other) const override; + virtual unsigned getSizeOnStack() const override { return 1; /*@todo*/ } + virtual std::string toString() const override; + + virtual MemberList const& getMembers() const override; + +private: + EnumDefinition const& m_enum; + /// List of member types, will be lazy-initialized because of recursive references. + mutable std::unique_ptr<MemberList> m_members; +}; + +/** * The type of a function, identified by its (return) parameter types. * @todo the return parameters should also have names, i.e. return parameters should be a struct * type. |