mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Enums NameAndTypeResolution - WIP
- Also adding an EndToEnd enum test
This commit is contained in:
parent
931e96838a
commit
a989f6f97a
@ -63,6 +63,7 @@ void ContractDefinition::accept(ASTVisitor& _visitor)
|
||||
{
|
||||
listAccept(m_baseContracts, _visitor);
|
||||
listAccept(m_definedStructs, _visitor);
|
||||
listAccept(m_definedEnums, _visitor);
|
||||
listAccept(m_stateVariables, _visitor);
|
||||
listAccept(m_events, _visitor);
|
||||
listAccept(m_functionModifiers, _visitor);
|
||||
@ -77,6 +78,7 @@ void ContractDefinition::accept(ASTConstVisitor& _visitor) const
|
||||
{
|
||||
listAccept(m_baseContracts, _visitor);
|
||||
listAccept(m_definedStructs, _visitor);
|
||||
listAccept(m_definedEnums, _visitor);
|
||||
listAccept(m_stateVariables, _visitor);
|
||||
listAccept(m_events, _visitor);
|
||||
listAccept(m_functionModifiers, _visitor);
|
||||
|
@ -58,6 +58,8 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
|
||||
|
||||
for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs())
|
||||
ReferencesResolver resolver(*structDef, *this, &_contract, nullptr);
|
||||
for (ASTPointer<EnumDefinition> const& enumDef: _contract.getDefinedEnums())
|
||||
ReferencesResolver resolver(*enumDef, *this, &_contract, nullptr);
|
||||
for (ASTPointer<VariableDeclaration> const& variable: _contract.getStateVariables())
|
||||
ReferencesResolver resolver(*variable, *this, &_contract, nullptr);
|
||||
for (ASTPointer<EventDefinition> const& event: _contract.getEvents())
|
||||
@ -79,6 +81,8 @@ void NameAndTypeResolver::checkTypeRequirements(ContractDefinition& _contract)
|
||||
{
|
||||
for (ASTPointer<StructDefinition> const& structDef: _contract.getDefinedStructs())
|
||||
structDef->checkValidityOfMembers();
|
||||
for (ASTPointer<EnumDefinition> const& enumDef: _contract.getDefinedEnums())
|
||||
enumDef->checkValidityOfMembers();
|
||||
_contract.checkTypeRequirements();
|
||||
}
|
||||
|
||||
@ -221,6 +225,17 @@ void DeclarationRegistrationHelper::endVisit(StructDefinition&)
|
||||
closeCurrentScope();
|
||||
}
|
||||
|
||||
bool DeclarationRegistrationHelper::visit(EnumDefinition& _enum)
|
||||
{
|
||||
registerDeclaration(_enum, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeclarationRegistrationHelper::endVisit(EnumDefinition&)
|
||||
{
|
||||
closeCurrentScope();
|
||||
}
|
||||
|
||||
bool DeclarationRegistrationHelper::visit(FunctionDefinition& _function)
|
||||
{
|
||||
registerDeclaration(_function, true);
|
||||
|
@ -98,6 +98,8 @@ private:
|
||||
void endVisit(ContractDefinition& _contract) override;
|
||||
bool visit(StructDefinition& _struct) override;
|
||||
void endVisit(StructDefinition& _struct) override;
|
||||
bool visit(EnumDefinition& _enum) override;
|
||||
void endVisit(EnumDefinition& _enum) override;
|
||||
bool visit(FunctionDefinition& _function) override;
|
||||
void endVisit(FunctionDefinition& _function) override;
|
||||
bool visit(ModifierDefinition& _modifier) override;
|
||||
|
@ -74,6 +74,8 @@ TypePointer Type::fromUserDefinedTypeName(UserDefinedTypeName const& _typeName)
|
||||
Declaration const* declaration = _typeName.getReferencedDeclaration();
|
||||
if (StructDefinition const* structDef = dynamic_cast<StructDefinition const*>(declaration))
|
||||
return make_shared<StructType>(*structDef);
|
||||
else if (EnumDefinition const* enumDef = dynamic_cast<EnumDefinition const*>(declaration))
|
||||
return make_shared<EnumType>(*enumDef);
|
||||
else if (FunctionDefinition const* function = dynamic_cast<FunctionDefinition const*>(declaration))
|
||||
return make_shared<FunctionType>(*function);
|
||||
else if (ContractDefinition const* contract = dynamic_cast<ContractDefinition const*>(declaration))
|
||||
|
Loading…
Reference in New Issue
Block a user