diff options
author | Christian <c@ethdev.com> | 2015-01-07 02:08:24 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-01-09 22:09:10 +0800 |
commit | be1e89da42e0ed9828dd2fb5939fd7bd48140be7 (patch) | |
tree | 977979fe84ea56786984dafe99be7952eb111c2a /Types.h | |
parent | dcda38cf3806c1d4205136c55d17f1e73eda48c1 (diff) | |
download | dexon-solidity-be1e89da42e0ed9828dd2fb5939fd7bd48140be7.tar dexon-solidity-be1e89da42e0ed9828dd2fb5939fd7bd48140be7.tar.gz dexon-solidity-be1e89da42e0ed9828dd2fb5939fd7bd48140be7.tar.bz2 dexon-solidity-be1e89da42e0ed9828dd2fb5939fd7bd48140be7.tar.lz dexon-solidity-be1e89da42e0ed9828dd2fb5939fd7bd48140be7.tar.xz dexon-solidity-be1e89da42e0ed9828dd2fb5939fd7bd48140be7.tar.zst dexon-solidity-be1e89da42e0ed9828dd2fb5939fd7bd48140be7.zip |
Possibility for unary operators to change type.
Diffstat (limited to 'Types.h')
-rw-r--r-- | Types.h | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -99,7 +99,10 @@ public: { return isImplicitlyConvertibleTo(_convertTo); } - virtual bool acceptsUnaryOperator(Token::Value) const { return false; } + /// @returns the resulting type of applying the given unary operator or an empty pointer if + /// this is not possible. + /// The default implementation does not allow any unary operator. + virtual TypePointer unaryOperatorResult(Token::Value) const { return TypePointer(); } /// @returns the resulting type of applying the given binary operator or an empty pointer if /// this is not possible. /// The default implementation allows comparison operators if a common type exists @@ -163,7 +166,7 @@ public: virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const override; virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const override; - virtual bool acceptsUnaryOperator(Token::Value _operator) const override; + virtual TypePointer unaryOperatorResult(Token::Value _operator) const override; virtual TypePointer binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const override; virtual bool operator==(Type const& _other) const override; @@ -225,9 +228,9 @@ public: BoolType() {} virtual Category getCategory() const { return Category::BOOL; } virtual bool isExplicitlyConvertibleTo(Type const& _convertTo) const override; - virtual bool acceptsUnaryOperator(Token::Value _operator) const override + virtual TypePointer unaryOperatorResult(Token::Value _operator) const override { - return _operator == Token::NOT || _operator == Token::DELETE; + return (_operator == Token::NOT || _operator == Token::DELETE) ? shared_from_this() : TypePointer(); } virtual TypePointer binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const override; @@ -277,7 +280,10 @@ class StructType: public Type public: virtual Category getCategory() const override { return Category::STRUCT; } StructType(StructDefinition const& _struct): m_struct(_struct) {} - virtual bool acceptsUnaryOperator(Token::Value _operator) const override { return _operator == Token::DELETE; } + virtual TypePointer unaryOperatorResult(Token::Value _operator) const override + { + return _operator == Token::DELETE ? shared_from_this() : TypePointer(); + } virtual bool operator==(Type const& _other) const override; virtual u256 getStorageSize() const override; |