mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
some more style fixes
This commit is contained in:
parent
3871e77946
commit
162d021c3f
@ -44,14 +44,14 @@ class NameAndTypeResolver: private boost::noncopyable
|
||||
public:
|
||||
NameAndTypeResolver(std::vector<Declaration const*> const& _globals, ErrorList& _errors);
|
||||
/// Registers all declarations found in the source unit.
|
||||
/// @returns false in case of type error.
|
||||
/// @returns false in case of error.
|
||||
bool registerDeclarations(SourceUnit& _sourceUnit);
|
||||
/// Resolves all names and types referenced from the given contract.
|
||||
/// @returns false in case of type error.
|
||||
/// @returns false in case of error.
|
||||
bool resolveNamesAndTypes(ContractDefinition& _contract);
|
||||
/// Updates the given global declaration (used for "this"). Not to be used with declarations
|
||||
/// that create their own scope.
|
||||
/// @returns false in case of type error.
|
||||
/// @returns false in case of error.
|
||||
bool updateDeclaration(Declaration const& _declaration);
|
||||
|
||||
/// Resolves the given @a _name inside the scope @a _scope. If @a _scope is omitted,
|
||||
|
@ -66,7 +66,8 @@ private:
|
||||
|
||||
ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner)
|
||||
{
|
||||
try{
|
||||
try
|
||||
{
|
||||
m_scanner = _scanner;
|
||||
ASTNodeFactory nodeFactory(*this);
|
||||
vector<ASTPointer<ASTNode>> nodes;
|
||||
|
@ -34,8 +34,7 @@ class Scanner;
|
||||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(ErrorList& errors):
|
||||
m_errors(errors){};
|
||||
Parser(ErrorList& errors): m_errors(errors){};
|
||||
|
||||
ASTPointer<SourceUnit> parse(std::shared_ptr<Scanner> const& _scanner);
|
||||
std::shared_ptr<std::string const> const& sourceName() const;
|
||||
|
@ -43,19 +43,7 @@ bool TypeChecker::checkTypeRequirements(const ContractDefinition& _contract)
|
||||
if (m_errors.empty())
|
||||
throw; // Something is weird here, rather throw again.
|
||||
}
|
||||
|
||||
return Error::containsOnlyWarnings(m_errors);
|
||||
// bool success = true;
|
||||
// for (auto const& it: m_errors)
|
||||
// {
|
||||
// auto e = dynamic_cast<Error const*>(it.get());
|
||||
// if (e->type() != Error::Type::Warning)
|
||||
// {
|
||||
// success = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return success;
|
||||
return Error::containsOnlyWarnings(m_errors);
|
||||
}
|
||||
|
||||
TypePointer const& TypeChecker::type(Expression const& _expression) const
|
||||
@ -72,7 +60,6 @@ TypePointer const& TypeChecker::type(VariableDeclaration const& _variable) const
|
||||
|
||||
bool TypeChecker::visit(ContractDefinition const& _contract)
|
||||
{
|
||||
|
||||
// We force our own visiting order here.
|
||||
ASTNode::listAccept(_contract.definedStructs(), *this);
|
||||
ASTNode::listAccept(_contract.baseContracts(), *this);
|
||||
|
@ -42,7 +42,7 @@ namespace solidity
|
||||
class TypeChecker: private ASTConstVisitor
|
||||
{
|
||||
public:
|
||||
/// @_errors the reference to the list of errors and warnings to add them found during type checking.
|
||||
/// @param _errors the reference to the list of errors and warnings to add them found during type checking.
|
||||
TypeChecker(ErrorList& _errors): m_errors(_errors) {}
|
||||
|
||||
/// Performs type checking on the given contract and all of its sub-nodes.
|
||||
|
@ -42,7 +42,7 @@ namespace
|
||||
ASTPointer<ContractDefinition> parseText(std::string const& _source, ErrorList& _errors)
|
||||
{
|
||||
ASTPointer<SourceUnit> sourceUnit = Parser(_errors).parse(std::make_shared<Scanner>(CharStream(_source)));
|
||||
if(!sourceUnit)
|
||||
if (!sourceUnit)
|
||||
return ASTPointer<ContractDefinition>();
|
||||
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
||||
if (ASTPointer<ContractDefinition> contract = dynamic_pointer_cast<ContractDefinition>(node))
|
||||
@ -57,7 +57,7 @@ bool successParse(std::string const& _source)
|
||||
try
|
||||
{
|
||||
auto sourceUnit = parseText(_source, errors);
|
||||
if(!sourceUnit)
|
||||
if (!sourceUnit)
|
||||
return false;
|
||||
}
|
||||
catch (FatalError const& _exception)
|
||||
@ -68,6 +68,7 @@ bool successParse(std::string const& _source)
|
||||
if (Error::containsErrorOfType(errors, Error::Type::ParserError))
|
||||
return false;
|
||||
|
||||
BOOST_CHECK(Error::containsOnlyWarnings(errors));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -168,7 +169,6 @@ BOOST_AUTO_TEST_CASE(two_exact_functions)
|
||||
// with support of overloaded functions, during parsing,
|
||||
// we can't determine whether they match exactly, however
|
||||
// it will throw DeclarationError in following stage.
|
||||
// TODO add test to the SolidityNameAndTypeDeclaration
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
@ -848,7 +848,7 @@ BOOST_AUTO_TEST_CASE(external_variable)
|
||||
BOOST_CHECK(!successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(arrays_in_storagze)
|
||||
BOOST_AUTO_TEST_CASE(arrays_in_storage)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract c {
|
||||
|
@ -77,12 +77,12 @@ public:
|
||||
m_compiler.compile(m_optimize, m_optimizeRuns);
|
||||
BOOST_REQUIRE(Error::containsErrorOfType(m_compiler.errors(), _type));
|
||||
}
|
||||
catch(Error const& _e)
|
||||
catch (Error const& _e)
|
||||
{
|
||||
BOOST_REQUIRE(_e.type() == _type);
|
||||
foundError = true;
|
||||
}
|
||||
catch(Exception const& _exception)
|
||||
catch (Exception const& _exception)
|
||||
{
|
||||
BOOST_REQUIRE(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user