diff --git a/libsolidity/AST.h b/libsolidity/AST.h index d9a95e506..d769aa225 100755 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -430,8 +430,8 @@ class VariableDeclaration: public Declaration { public: VariableDeclaration(Location const& _location, ASTPointer const& _type, - ASTPointer const& _name, bool _isPublic): - Declaration(_location, _name), m_typeName(_type), m_isPublic(_isPublic) {} + ASTPointer const& _name, bool _isPublic, bool _isStateVar = false): + Declaration(_location, _name), m_typeName(_type), m_isPublic(_isPublic), m_isStateVariable(_isStateVar) {} virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTConstVisitor& _visitor) const override; @@ -445,11 +445,13 @@ public: virtual LValueType getLValueType() const override; bool isLocalVariable() const { return !!dynamic_cast(getScope()); } bool isPublic() const { return m_isPublic; } + bool isStateVariable() const { return m_isStateVariable; } private: ASTPointer m_typeName; ///< can be empty ("var") bool m_isPublic; ///< Whether there is an accessor for it or not + bool m_isStateVariable; ///< Whether or not this is a contract state variable std::shared_ptr m_type; ///< derived type, initially empty }; diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 1c61aab12..5cfc8f462 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -150,7 +150,7 @@ ASTPointer Parser::parseContractDefinition() Token::isElementaryTypeName(currentToken)) { bool const allowVar = false; - stateVariables.push_back(parseVariableDeclaration(allowVar, visibilityIsPublic)); + stateVariables.push_back(parseVariableDeclaration(allowVar, visibilityIsPublic, true)); expectToken(Token::SEMICOLON); } else if (currentToken == Token::MODIFIER) @@ -245,12 +245,12 @@ ASTPointer Parser::parseStructDefinition() return nodeFactory.createNode(name, members); } -ASTPointer Parser::parseVariableDeclaration(bool _allowVar, bool _isPublic) +ASTPointer Parser::parseVariableDeclaration(bool _allowVar, bool _isPublic, bool _isStateVariable) { ASTNodeFactory nodeFactory(*this); ASTPointer type = parseTypeName(_allowVar); nodeFactory.markEndPosition(); - return nodeFactory.createNode(type, expectIdentifierToken(), _isPublic); + return nodeFactory.createNode(type, expectIdentifierToken(), _isPublic, _isStateVariable); } ASTPointer Parser::parseModifierDefinition() diff --git a/libsolidity/Parser.h b/libsolidity/Parser.h index a8f97c6e3..d3bff67e5 100644 --- a/libsolidity/Parser.h +++ b/libsolidity/Parser.h @@ -52,7 +52,7 @@ private: ASTPointer parseInheritanceSpecifier(); ASTPointer parseFunctionDefinition(bool _isPublic, ASTString const* _contractName); ASTPointer parseStructDefinition(); - ASTPointer parseVariableDeclaration(bool _allowVar, bool _isPublic = false); + ASTPointer parseVariableDeclaration(bool _allowVar, bool _isPublic = false, bool _isStateVar = false); ASTPointer parseModifierDefinition(); ASTPointer parseModifierInvocation(); ASTPointer parseIdentifier();