diff options
-rwxr-xr-x | AST.h | 6 | ||||
-rw-r--r-- | Parser.cpp | 6 | ||||
-rw-r--r-- | Parser.h | 2 |
3 files changed, 8 insertions, 6 deletions
@@ -430,8 +430,8 @@ class VariableDeclaration: public Declaration { public: VariableDeclaration(Location const& _location, ASTPointer<TypeName> const& _type, - ASTPointer<ASTString> const& _name, bool _isPublic): - Declaration(_location, _name), m_typeName(_type), m_isPublic(_isPublic) {} + ASTPointer<ASTString> 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<FunctionDefinition const*>(getScope()); } bool isPublic() const { return m_isPublic; } + bool isStateVariable() const { return m_isStateVariable; } private: ASTPointer<TypeName> 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<Type const> m_type; ///< derived type, initially empty }; @@ -150,7 +150,7 @@ ASTPointer<ContractDefinition> 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<StructDefinition> Parser::parseStructDefinition() return nodeFactory.createNode<StructDefinition>(name, members); } -ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(bool _allowVar, bool _isPublic) +ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(bool _allowVar, bool _isPublic, bool _isStateVariable) { ASTNodeFactory nodeFactory(*this); ASTPointer<TypeName> type = parseTypeName(_allowVar); nodeFactory.markEndPosition(); - return nodeFactory.createNode<VariableDeclaration>(type, expectIdentifierToken(), _isPublic); + return nodeFactory.createNode<VariableDeclaration>(type, expectIdentifierToken(), _isPublic, _isStateVariable); } ASTPointer<ModifierDefinition> Parser::parseModifierDefinition() @@ -52,7 +52,7 @@ private: ASTPointer<InheritanceSpecifier> parseInheritanceSpecifier(); ASTPointer<FunctionDefinition> parseFunctionDefinition(bool _isPublic, ASTString const* _contractName); ASTPointer<StructDefinition> parseStructDefinition(); - ASTPointer<VariableDeclaration> parseVariableDeclaration(bool _allowVar, bool _isPublic = false); + ASTPointer<VariableDeclaration> parseVariableDeclaration(bool _allowVar, bool _isPublic = false, bool _isStateVar = false); ASTPointer<ModifierDefinition> parseModifierDefinition(); ASTPointer<ModifierInvocation> parseModifierInvocation(); ASTPointer<Identifier> parseIdentifier(); |