From f4d1acc563a972ee4f5a44c690cd3fdd1783ae97 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 5 Jun 2015 11:07:50 +0200 Subject: Ability to specify the storage location of a reference type. --- AST.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'AST.h') diff --git a/AST.h b/AST.h index be5c9a6c..d7534712 100644 --- a/AST.h +++ b/AST.h @@ -474,22 +474,26 @@ private: class VariableDeclaration: public Declaration { public: + enum Location { Default, Storage, Memory }; + VariableDeclaration( - SourceLocation const& _location, + SourceLocation const& _sourceLocation, ASTPointer const& _type, ASTPointer const& _name, ASTPointer _value, Visibility _visibility, bool _isStateVar = false, bool _isIndexed = false, - bool _isConstant = false + bool _isConstant = false, + Location _referenceLocation = Location::Default ): - Declaration(_location, _name, _visibility), + Declaration(_sourceLocation, _name, _visibility), m_typeName(_type), m_value(_value), m_isStateVariable(_isStateVar), m_isIndexed(_isIndexed), - m_isConstant(_isConstant){} + m_isConstant(_isConstant), + m_location(_referenceLocation) {} virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTConstVisitor& _visitor) const override; @@ -507,10 +511,14 @@ public: void checkTypeRequirements(); bool isLocalVariable() const { return !!dynamic_cast(getScope()); } + /// @returns true if this variable is a parameter or return parameter of a function. + bool isFunctionParameter() const; + /// @returns true if this variable is a parameter (not return parameter) of an external function. bool isExternalFunctionParameter() const; bool isStateVariable() const { return m_isStateVariable; } bool isIndexed() const { return m_isIndexed; } bool isConstant() const { return m_isConstant; } + Location referenceLocation() const { return m_location; } protected: Visibility getDefaultVisibility() const override { return Visibility::Internal; } @@ -521,6 +529,7 @@ private: bool m_isStateVariable; ///< Whether or not this is a contract state variable bool m_isIndexed; ///< Whether this is an indexed variable (used by events). bool m_isConstant; ///< Whether the variable is a compile-time constant. + Location m_location; ///< Location of the variable if it is of reference type. std::shared_ptr m_type; ///< derived type, initially empty }; -- cgit