diff options
author | Christian <c@ethdev.com> | 2014-10-20 20:00:37 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-20 22:23:49 +0800 |
commit | be885dc3cf3da61278a22493b6c7510c6121e0a9 (patch) | |
tree | 1e602ffa535b058692d480fe1942a2139dcc6bbb /Types.h | |
parent | f0c334670dfef7c1b1d1ae610cf19ae9ad2822ca (diff) | |
download | dexon-solidity-be885dc3cf3da61278a22493b6c7510c6121e0a9.tar.gz dexon-solidity-be885dc3cf3da61278a22493b6c7510c6121e0a9.tar.zst dexon-solidity-be885dc3cf3da61278a22493b6c7510c6121e0a9.zip |
Pointer type cleanup: Use ASTPointer only for AST nodes and shared_ptr for type
pointer.
Diffstat (limited to 'Types.h')
-rw-r--r-- | Types.h | 35 |
1 files changed, 14 insertions, 21 deletions
@@ -26,7 +26,7 @@ #include <string> #include <boost/noncopyable.hpp> #include <boost/assert.hpp> - +#include <libsolidity/ASTForward.h> #include <libsolidity/Token.h> namespace dev @@ -34,18 +34,6 @@ namespace dev namespace solidity { -// AST forward declarations -class ContractDefinition; -class FunctionDefinition; -class StructDefinition; -class Literal; -class ElementaryTypeName; -class UserDefinedTypeName; -class Mapping; - -template <typename T> -using ptr = std::shared_ptr<T>; - // @todo realMxN, string<N>, mapping class Type: private boost::noncopyable @@ -57,11 +45,11 @@ public: }; //! factory functions that convert an AST TypeName to a Type. - static ptr<Type> fromElementaryTypeName(Token::Value _typeToken); - static ptr<Type> fromUserDefinedTypeName(UserDefinedTypeName const& _typeName); - static ptr<Type> fromMapping(Mapping const& _typeName); + static std::shared_ptr<Type> fromElementaryTypeName(Token::Value _typeToken); + static std::shared_ptr<Type> fromUserDefinedTypeName(UserDefinedTypeName const& _typeName); + static std::shared_ptr<Type> fromMapping(Mapping const& _typeName); - static ptr<Type> forLiteral(Literal const& _literal); + static std::shared_ptr<Type> forLiteral(Literal const& _literal); virtual Category getCategory() const = 0; virtual bool isImplicitlyConvertibleTo(Type const&) const { return false; } @@ -82,7 +70,7 @@ public: }; virtual Category getCategory() const { return Category::INTEGER; } - static ptr<IntegerType> smallestTypeForLiteral(std::string const& _literal); + static std::shared_ptr<IntegerType> smallestTypeForLiteral(std::string const& _literal); explicit IntegerType(int _bits, Modifier _modifier = Modifier::UNSIGNED); @@ -95,6 +83,7 @@ public: bool isHash() const { return m_modifier == Modifier::HASH || m_modifier == Modifier::ADDRESS; } bool isAddress() const { return m_modifier == Modifier::ADDRESS; } int isSigned() const { return m_modifier == Modifier::SIGNED; } + private: int m_bits; Modifier m_modifier; @@ -125,6 +114,7 @@ public: virtual Category getCategory() const { return Category::CONTRACT; } ContractType(ContractDefinition const& _contract): m_contract(_contract) {} virtual bool isImplicitlyConvertibleTo(Type const& _convertTo) const; + private: ContractDefinition const& m_contract; }; @@ -139,6 +129,7 @@ public: { return _operator == Token::DELETE; } + private: StructDefinition const& m_struct; }; @@ -150,6 +141,7 @@ public: FunctionType(FunctionDefinition const& _function): m_function(_function) {} FunctionDefinition const& getFunction() const { return m_function; } + private: FunctionDefinition const& m_function; }; @@ -175,11 +167,12 @@ class TypeType: public Type { public: virtual Category getCategory() const { return Category::TYPE; } - TypeType(ptr<Type> const& _actualType): m_actualType(_actualType) {} + TypeType(std::shared_ptr<Type const> const& _actualType): m_actualType(_actualType) {} + + std::shared_ptr<Type const> const& getActualType() const { return m_actualType; } - ptr<Type> const& getActualType() { return m_actualType; } private: - ptr<Type> m_actualType; + std::shared_ptr<Type const> m_actualType; }; |