Browse Source

Moving contract fullyImplemented check to TypeRequirements

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
4e234b30ed
  1. 4
      libsolidity/AST.cpp
  2. 10
      libsolidity/AST.h
  3. 6
      libsolidity/Parser.cpp

4
libsolidity/AST.cpp

@ -60,6 +60,7 @@ void ContractDefinition::checkTypeRequirements()
FunctionDefinition const* fallbackFunction = nullptr; FunctionDefinition const* fallbackFunction = nullptr;
for (ASTPointer<FunctionDefinition> const& function: getDefinedFunctions()) for (ASTPointer<FunctionDefinition> const& function: getDefinedFunctions())
{
if (function->getName().empty()) if (function->getName().empty())
{ {
if (fallbackFunction) if (fallbackFunction)
@ -71,6 +72,9 @@ void ContractDefinition::checkTypeRequirements()
BOOST_THROW_EXCEPTION(fallbackFunction->getParameterList().createTypeError("Fallback function cannot take parameters.")); BOOST_THROW_EXCEPTION(fallbackFunction->getParameterList().createTypeError("Fallback function cannot take parameters."));
} }
} }
if (!function->isFullyImplemented())
setFullyImplemented(false);
}
for (ASTPointer<ModifierDefinition> const& modifier: getFunctionModifiers()) for (ASTPointer<ModifierDefinition> const& modifier: getFunctionModifiers())
modifier->checkTypeRequirements(); modifier->checkTypeRequirements();

10
libsolidity/AST.h

@ -206,6 +206,7 @@ public:
/// @return whether this node is fully implemented or not /// @return whether this node is fully implemented or not
bool isFullyImplemented() const { return m_implemented; } bool isFullyImplemented() const { return m_implemented; }
void setFullyImplemented(bool _implemented) { m_implemented = _implemented; }
protected: protected:
bool m_implemented; bool m_implemented;
@ -231,12 +232,11 @@ public:
std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables, std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables,
std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions, std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions,
std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers, std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers,
std::vector<ASTPointer<EventDefinition>> const& _events, std::vector<ASTPointer<EventDefinition>> const& _events
bool _isFullyImplemented
): ):
Declaration(_location, _name), Declaration(_location, _name),
Documented(_documentation), Documented(_documentation),
ImplementationOptional(_isFullyImplemented), ImplementationOptional(true),
m_baseContracts(_baseContracts), m_baseContracts(_baseContracts),
m_definedStructs(_definedStructs), m_definedStructs(_definedStructs),
m_definedEnums(_definedEnums), m_definedEnums(_definedEnums),
@ -244,7 +244,7 @@ public:
m_definedFunctions(_definedFunctions), m_definedFunctions(_definedFunctions),
m_functionModifiers(_functionModifiers), m_functionModifiers(_functionModifiers),
m_events(_events) m_events(_events)
{} {}
virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override; virtual void accept(ASTConstVisitor& _visitor) const override;
@ -421,7 +421,7 @@ public:
m_functionModifiers(_modifiers), m_functionModifiers(_modifiers),
m_returnParameters(_returnParameters), m_returnParameters(_returnParameters),
m_body(_body) m_body(_body)
{} {}
virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override; virtual void accept(ASTConstVisitor& _visitor) const override;

6
libsolidity/Parser.cpp

@ -116,7 +116,6 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
{ {
ASTNodeFactory nodeFactory(*this); ASTNodeFactory nodeFactory(*this);
ASTPointer<ASTString> docString; ASTPointer<ASTString> docString;
bool contractFullyImplemented = true;
if (m_scanner->getCurrentCommentLiteral() != "") if (m_scanner->getCurrentCommentLiteral() != "")
docString = make_shared<ASTString>(m_scanner->getCurrentCommentLiteral()); docString = make_shared<ASTString>(m_scanner->getCurrentCommentLiteral());
expectToken(Token::Contract); expectToken(Token::Contract);
@ -145,8 +144,6 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
{ {
ASTPointer<FunctionDefinition> func = parseFunctionDefinition(name.get()); ASTPointer<FunctionDefinition> func = parseFunctionDefinition(name.get());
functions.push_back(func); functions.push_back(func);
if (!func->isFullyImplemented())
contractFullyImplemented = false;
} }
else if (currentToken == Token::Struct) else if (currentToken == Token::Struct)
structs.push_back(parseStructDefinition()); structs.push_back(parseStructDefinition());
@ -179,8 +176,7 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition()
stateVariables, stateVariables,
functions, functions,
modifiers, modifiers,
events, events
contractFullyImplemented
); );
} }

Loading…
Cancel
Save