diff options
author | chriseth <c@ethdev.com> | 2015-10-10 01:35:41 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-10 01:35:41 +0800 |
commit | a5d12b876180088904a026c472da23201a35d59c (patch) | |
tree | 277c5e2da4bc1ea04f10b3369f96c5f087fb01db /libsolidity/Types.h | |
parent | c54a033bf036d16651fb992689adfcffb2f3a951 (diff) | |
download | dexon-solidity-a5d12b876180088904a026c472da23201a35d59c.tar.gz dexon-solidity-a5d12b876180088904a026c472da23201a35d59c.tar.zst dexon-solidity-a5d12b876180088904a026c472da23201a35d59c.zip |
Introduced tuple type and added multi variable declarations to type
checker.
Diffstat (limited to 'libsolidity/Types.h')
-rw-r--r-- | libsolidity/Types.h | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/libsolidity/Types.h b/libsolidity/Types.h index 7a65ca92..e73cd3cd 100644 --- a/libsolidity/Types.h +++ b/libsolidity/Types.h @@ -132,8 +132,8 @@ public: enum class Category { Integer, IntegerConstant, StringLiteral, Bool, Real, Array, - FixedBytes, Contract, Struct, Function, Enum, - Mapping, Void, TypeType, Modifier, Magic + FixedBytes, Contract, Struct, Function, Enum, Tuple, + Mapping, TypeType, Modifier, Magic }; /// @{ @@ -683,6 +683,28 @@ private: }; /** + * Type that can hold a finite sequence of values of different types. + */ +class TupleType: public Type +{ +public: + virtual Category category() const override { return Category::Tuple; } + explicit TupleType(std::vector<TypePointer> const& _types = std::vector<TypePointer>()): m_components(_types) {} + virtual bool operator==(Type const& _other) const override; + virtual TypePointer binaryOperatorResult(Token::Value, TypePointer const&) const override { return TypePointer(); } + virtual std::string toString(bool) const override; + virtual bool canBeStored() const override { return false; } + virtual u256 storageSize() const override; + virtual bool canLiveOutsideStorage() const override { return false; } + virtual unsigned sizeOnStack() const override; + + std::vector<TypePointer> const& components() const { return m_components; } + +private: + std::vector<TypePointer> const m_components; +}; + +/** * 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. @@ -875,24 +897,6 @@ private: }; /** - * The void type, can only be implicitly used as the type that is returned by functions without - * return parameters. - */ -class VoidType: public Type -{ -public: - virtual Category category() const override { return Category::Void; } - VoidType() {} - - virtual TypePointer binaryOperatorResult(Token::Value, TypePointer const&) const override { return TypePointer(); } - virtual std::string toString(bool) const override { return "void"; } - virtual bool canBeStored() const override { return false; } - virtual u256 storageSize() const override; - virtual bool canLiveOutsideStorage() const override { return false; } - virtual unsigned sizeOnStack() const override { return 0; } -}; - -/** * The type of a type reference. The type of "uint32" when used in "a = uint32(2)" is an example * of a TypeType. * For super contracts or libraries, this has members directly. |