diff options
-rw-r--r-- | AST.cpp | 10 | ||||
-rw-r--r-- | AST.h | 5 | ||||
-rw-r--r-- | ASTPrinter.cpp | 2 | ||||
-rw-r--r-- | ASTVisitor.h | 4 | ||||
-rw-r--r-- | AST_accept.h | 24 | ||||
-rw-r--r-- | Parser.cpp | 2 | ||||
-rw-r--r-- | Token.h | 2 |
7 files changed, 39 insertions, 10 deletions
@@ -206,6 +206,12 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::getIn return *m_interfaceFunctionList; } +TypePointer EnumDeclaration::getType(ContractDefinition const*) const +{ + // LTODO + return nullptr; +} + void InheritanceSpecifier::checkTypeRequirements() { m_baseName->checkTypeRequirements(); @@ -268,7 +274,9 @@ void EnumDefinition::checkValidityOfMembers() const TypePointer EnumDefinition::getType(ContractDefinition const*) const { - return make_shared<TypeType>(make_shared<EnumType>(*this)); + //LTODO: + return nullptr; + // return make_shared<TypeType>(make_shared<EnumType>(*this)); } TypePointer FunctionDefinition::getType(ContractDefinition const*) const @@ -170,10 +170,13 @@ private: */ class EnumDeclaration : public Declaration { + public: EnumDeclaration(Location const& _location, ASTPointer<ASTString> const& _name): Declaration(_location, _name) {} + virtual void accept(ASTVisitor& _visitor) override; + virtual void accept(ASTConstVisitor& _visitor) const override; TypePointer getType(ContractDefinition const*) const; }; @@ -717,7 +720,7 @@ public: Expression const& getCondition() const { return *m_condition; } Statement const& getTrueStatement() const { return *m_trueBody; } - /// @returns the "else" part of the if statement or nullptr if there is no "else" part. + /// @returns the "else" part of the if statement or nullptr if there is no "else" part. Statement const* getFalseStatement() const { return m_falseBody.get(); } private: diff --git a/ASTPrinter.cpp b/ASTPrinter.cpp index 34cd12a9..b655d309 100644 --- a/ASTPrinter.cpp +++ b/ASTPrinter.cpp @@ -77,7 +77,7 @@ bool ASTPrinter::visit(EnumDefinition const& _node) return goDeeper(); } -bool ASTPrinter::visit(EnuumDeclaration const& _node) +bool ASTPrinter::visit(EnumDeclaration const& _node) { writeLine("EnumValue \"" + _node.getName() + "\""); return goDeeper(); diff --git a/ASTVisitor.h b/ASTVisitor.h index b05ec658..10882757 100644 --- a/ASTVisitor.h +++ b/ASTVisitor.h @@ -48,6 +48,7 @@ public: virtual bool visit(InheritanceSpecifier&) { return true; } virtual bool visit(StructDefinition&) { return true; } virtual bool visit(EnumDefinition&) { return true; } + virtual bool visit(EnumDeclaration&) { return true; } virtual bool visit(ParameterList&) { return true; } virtual bool visit(FunctionDefinition&) { return true; } virtual bool visit(VariableDeclaration&) { return true; } @@ -90,6 +91,7 @@ public: virtual void endVisit(InheritanceSpecifier&) { } virtual void endVisit(StructDefinition&) { } virtual void endVisit(EnumDefinition&) { } + virtual void endVisit(EnumDeclaration&) { } virtual void endVisit(ParameterList&) { } virtual void endVisit(FunctionDefinition&) { } virtual void endVisit(VariableDeclaration&) { } @@ -136,6 +138,7 @@ public: virtual bool visit(InheritanceSpecifier const&) { return true; } virtual bool visit(StructDefinition const&) { return true; } virtual bool visit(EnumDefinition const&) { return true; } + virtual bool visit(EnumDeclaration const&) { return true; } virtual bool visit(ParameterList const&) { return true; } virtual bool visit(FunctionDefinition const&) { return true; } virtual bool visit(VariableDeclaration const&) { return true; } @@ -178,6 +181,7 @@ public: virtual void endVisit(InheritanceSpecifier const&) { } virtual void endVisit(StructDefinition const&) { } virtual void endVisit(EnumDefinition const&) { } + virtual void endVisit(EnumDeclaration const&) { } virtual void endVisit(ParameterList const&) { } virtual void endVisit(FunctionDefinition const&) { } virtual void endVisit(VariableDeclaration const&) { } diff --git a/AST_accept.h b/AST_accept.h index 15f6b7ee..9568da5b 100644 --- a/AST_accept.h +++ b/AST_accept.h @@ -105,22 +105,36 @@ void InheritanceSpecifier::accept(ASTConstVisitor& _visitor) const _visitor.endVisit(*this); } -void StructDefinition::accept(ASTVisitor& _visitor) +void EnumDefinition::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) listAccept(m_members, _visitor); _visitor.endVisit(*this); } -void EnumDefinition::accept(ASTVisitor& _visitor) +void EnumDefinition::accept(ASTConstVisitor& _visitor) const { - _visitor.visit(*this) + if (_visitor.visit(*this)) + listAccept(m_members, _visitor); _visitor.endVisit(*this); } -void EnumDefinition::accept(ASTConstVisitor& _visitor) const +void EnumDeclaration::accept(ASTVisitor& _visitor) +{ + _visitor.visit(*this); + _visitor.endVisit(*this); +} + +void EnumDeclaration::accept(ASTConstVisitor& _visitor) const +{ + _visitor.visit(*this); + _visitor.endVisit(*this); +} + +void StructDefinition::accept(ASTVisitor& _visitor) { - _visitor.visit(*this) + if (_visitor.visit(*this)) + listAccept(m_members, _visitor); _visitor.endVisit(*this); } @@ -279,7 +279,7 @@ ASTPointer<EnumDefinition> Parser::parseEnumDefinition() ASTNodeFactory nodeFactory(*this); expectToken(Token::Enum); ASTPointer<ASTString> name = expectIdentifierToken(); - vector<ASTPointer<Declaration>> members; + vector<ASTPointer<EnumDeclaration>> members; expectToken(Token::LBrace); while (m_scanner->getCurrentToken() == Token::Identifier) @@ -168,7 +168,7 @@ namespace solidity K(Switch, "switch", 0) \ K(Var, "var", 0) \ K(While, "while", 0) \ - \ + K(Enum, "enum", 0) \ \ /* Ether subdenominations */ \ K(SubWei, "wei", 0) \ |