From a8ca96cd3ec0b2ed1017f5463676e88e5ae15ad7 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Tue, 17 Dec 2019 14:56:06 +0000 Subject: [PATCH 01/57] Refactor PostTypeChecker into multiple classes per usecase --- libsolidity/analysis/PostTypeChecker.cpp | 199 +++++++++++++++-------- libsolidity/analysis/PostTypeChecker.h | 40 ++++- 2 files changed, 159 insertions(+), 80 deletions(-) diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index 40c4f22d8..0647a0c64 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -31,106 +31,163 @@ using namespace dev; using namespace langutil; using namespace dev::solidity; - bool PostTypeChecker::check(ASTNode const& _astRoot) { _astRoot.accept(*this); return Error::containsOnlyWarnings(m_errorReporter.errors()); } -bool PostTypeChecker::visit(ContractDefinition const&) +bool PostTypeChecker::visit(ContractDefinition const& _contractDefinition) { - solAssert(!m_currentConstVariable, ""); - solAssert(m_constVariableDependencies.empty(), ""); - return true; + return callVisit(_contractDefinition); } -void PostTypeChecker::endVisit(ContractDefinition const&) +void PostTypeChecker::endVisit(ContractDefinition const& _contractDefinition) { - solAssert(!m_currentConstVariable, ""); - for (auto declaration: m_constVariables) - if (auto identifier = findCycle(*declaration)) - m_errorReporter.typeError( - declaration->location(), - "The value of the constant " + declaration->name() + - " has a cyclic dependency via " + identifier->name() + "." - ); - - m_constVariables.clear(); - m_constVariableDependencies.clear(); + callEndVisit(_contractDefinition); } void PostTypeChecker::endVisit(OverrideSpecifier const& _overrideSpecifier) { - for (ASTPointer const& override: _overrideSpecifier.overrides()) - { - Declaration const* decl = override->annotation().referencedDeclaration; - solAssert(decl, "Expected declaration to be resolved."); - - if (dynamic_cast(decl)) - continue; - - TypeType const* actualTypeType = dynamic_cast(decl->type()); - - m_errorReporter.typeError( - override->location(), - "Expected contract but got " + - actualTypeType->actualType()->toString(true) + - "." - ); - } + callEndVisit(_overrideSpecifier); } bool PostTypeChecker::visit(VariableDeclaration const& _variable) { - solAssert(!m_currentConstVariable, ""); - if (_variable.isConstant()) - { - m_currentConstVariable = &_variable; - m_constVariables.push_back(&_variable); - } - return true; + return callVisit(_variable); } void PostTypeChecker::endVisit(VariableDeclaration const& _variable) { - if (_variable.isConstant()) - { - solAssert(m_currentConstVariable == &_variable, ""); - m_currentConstVariable = nullptr; - } + callEndVisit(_variable); } bool PostTypeChecker::visit(Identifier const& _identifier) { - if (m_currentConstVariable) - if (auto var = dynamic_cast(_identifier.annotation().referencedDeclaration)) - if (var->isConstant()) - m_constVariableDependencies[m_currentConstVariable].insert(var); - return true; + return callVisit(_identifier); } -VariableDeclaration const* PostTypeChecker::findCycle(VariableDeclaration const& _startingFrom) + +namespace { - auto visitor = [&](VariableDeclaration const& _variable, CycleDetector& _cycleDetector, size_t _depth) - { - if (_depth >= 256) - m_errorReporter.fatalDeclarationError(_variable.location(), "Variable definition exhausting cyclic dependency validator."); +struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker +{ + ConstStateVarCircularReferenceChecker(ErrorReporter& _errorReporter): + Checker(_errorReporter) {} - // Iterating through the dependencies needs to be deterministic and thus cannot - // depend on the memory layout. - // Because of that, we sort by AST node id. - vector dependencies( - m_constVariableDependencies[&_variable].begin(), - m_constVariableDependencies[&_variable].end() - ); - sort(dependencies.begin(), dependencies.end(), [](VariableDeclaration const* _a, VariableDeclaration const* _b) -> bool + bool visit(ContractDefinition const&) override + { + solAssert(!m_currentConstVariable, ""); + solAssert(m_constVariableDependencies.empty(), ""); + return true; + } + + void endVisit(ContractDefinition const&) override + { + solAssert(!m_currentConstVariable, ""); + for (auto declaration: m_constVariables) + if (auto identifier = findCycle(*declaration)) + m_errorReporter.typeError( + declaration->location(), + "The value of the constant " + declaration->name() + + " has a cyclic dependency via " + identifier->name() + "." + ); + + m_constVariables.clear(); + m_constVariableDependencies.clear(); + } + + bool visit(VariableDeclaration const& _variable) override + { + solAssert(!m_currentConstVariable, ""); + if (_variable.isConstant()) { - return _a->id() < _b->id(); - }); - for (auto v: dependencies) - if (_cycleDetector.run(*v)) - return; - }; - return CycleDetector(visitor).run(_startingFrom); + m_currentConstVariable = &_variable; + m_constVariables.push_back(&_variable); + } + return true; + } + + void endVisit(VariableDeclaration const& _variable) override + { + if (_variable.isConstant()) + { + solAssert(m_currentConstVariable == &_variable, ""); + m_currentConstVariable = nullptr; + } + } + + bool visit(Identifier const& _identifier) override + { + if (m_currentConstVariable) + if (auto var = dynamic_cast(_identifier.annotation().referencedDeclaration)) + if (var->isConstant()) + m_constVariableDependencies[m_currentConstVariable].insert(var); + return true; + } + + VariableDeclaration const* findCycle(VariableDeclaration const& _startingFrom) + { + auto visitor = [&](VariableDeclaration const& _variable, CycleDetector& _cycleDetector, size_t _depth) + { + if (_depth >= 256) + m_errorReporter.fatalDeclarationError(_variable.location(), "Variable definition exhausting cyclic dependency validator."); + + // Iterating through the dependencies needs to be deterministic and thus cannot + // depend on the memory layout. + // Because of that, we sort by AST node id. + vector dependencies( + m_constVariableDependencies[&_variable].begin(), + m_constVariableDependencies[&_variable].end() + ); + sort(dependencies.begin(), dependencies.end(), [](VariableDeclaration const* _a, VariableDeclaration const* _b) -> bool + { + return _a->id() < _b->id(); + }); + for (auto v: dependencies) + if (_cycleDetector.run(*v)) + return; + }; + return CycleDetector(visitor).run(_startingFrom); + } + +private: + VariableDeclaration const* m_currentConstVariable = nullptr; + std::map> m_constVariableDependencies; + std::vector m_constVariables; ///< Required for determinism. +}; + +struct OverrideSpecifierChecker: public PostTypeChecker::Checker +{ + OverrideSpecifierChecker(ErrorReporter& _errorReporter): + Checker(_errorReporter) {} + + void endVisit(OverrideSpecifier const& _overrideSpecifier) override + { + for (ASTPointer const& override: _overrideSpecifier.overrides()) + { + Declaration const* decl = override->annotation().referencedDeclaration; + solAssert(decl, "Expected declaration to be resolved."); + + if (dynamic_cast(decl)) + continue; + + TypeType const* actualTypeType = dynamic_cast(decl->type()); + + m_errorReporter.typeError( + override->location(), + "Expected contract but got " + + actualTypeType->actualType()->toString(true) + + "." + ); + } + } +}; +} + + +PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) +{ + m_checkers.push_back(make_shared(_errorReporter)); + m_checkers.push_back(make_shared(_errorReporter)); } diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index b4441b395..d89885ade 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -38,20 +38,30 @@ namespace solidity * This module performs analyses on the AST that are done after type checking and assignments of types: * - whether there are circular references in constant state variables * - whether override specifiers are actually contracts - * @TODO factor out each use-case into an individual class (but do the traversal only once) + * + * When adding a new checker, make sure a visitor that forwards calls that your + * checker uses exists in PostTypeChecker. Add missing ones. + * + * The return value for the visit function of a checker is ignored, all nodes + * will always be visited. */ class PostTypeChecker: private ASTConstVisitor { public: + struct Checker: public ASTConstVisitor + { + Checker(langutil::ErrorReporter& _errorReporter): + m_errorReporter(_errorReporter) {} + protected: + langutil::ErrorReporter& m_errorReporter; + }; + /// @param _errorReporter provides the error logging functionality. - PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {} + PostTypeChecker(langutil::ErrorReporter& _errorReporter); bool check(ASTNode const& _astRoot); private: - /// Adds a new error to the list of errors. - void typeError(langutil::SourceLocation const& _location, std::string const& _description); - bool visit(ContractDefinition const& _contract) override; void endVisit(ContractDefinition const& _contract) override; void endVisit(OverrideSpecifier const& _overrideSpecifier) override; @@ -61,13 +71,25 @@ private: bool visit(Identifier const& _identifier) override; - VariableDeclaration const* findCycle(VariableDeclaration const& _startingFrom); + template + bool callVisit(T const& _node) + { + for (auto& checker: m_checkers) + checker->visit(_node); + + return true; + } + + template + void callEndVisit(T const& _node) + { + for (auto& checker: m_checkers) + checker->endVisit(_node); + } langutil::ErrorReporter& m_errorReporter; - VariableDeclaration const* m_currentConstVariable = nullptr; - std::vector m_constVariables; ///< Required for determinism. - std::map> m_constVariableDependencies; + std::vector> m_checkers; }; } From 7db88cfedde49cff2977550a326a587b96c8c40e Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 19 Dec 2019 23:22:19 +0100 Subject: [PATCH 02/57] Remove `yul::Instruction`. --- libsolidity/analysis/ViewPureChecker.cpp | 4 ---- libyul/AsmAnalysis.cpp | 10 ---------- libyul/AsmAnalysis.h | 1 - libyul/AsmData.h | 6 ------ libyul/AsmParser.h | 4 +++- libyul/backends/evm/AbstractAssembly.h | 1 - libyul/backends/evm/EVMCodeTransform.cpp | 10 ---------- libyul/backends/evm/EVMCodeTransform.h | 1 - 8 files changed, 3 insertions(+), 34 deletions(-) diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index aa97ae7bb..4da77ead7 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -43,10 +43,6 @@ public: m_dialect(_dialect), m_reportMutability(_reportMutability) {} - void operator()(yul::Instruction const& _instruction) - { - checkInstruction(_instruction.location, _instruction.instruction); - } void operator()(yul::Literal const&) {} void operator()(yul::Identifier const&) {} void operator()(yul::ExpressionStatement const& _expr) diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 64b1ad4c5..e03ef7cb0 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -86,16 +86,6 @@ AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(Dialect const& _dialect, return analysisInfo; } -bool AsmAnalyzer::operator()(yul::Instruction const& _instruction) -{ - yulAssert(false, "The use of non-functional instructions is disallowed. Please use functional notation instead."); - auto const& info = instructionInfo(_instruction.instruction); - m_stackHeight += info.ret - info.args; - m_info.stackHeightInfo[&_instruction] = m_stackHeight; - warnOnInstructions(_instruction.instruction, _instruction.location); - return true; -} - bool AsmAnalyzer::operator()(Literal const& _literal) { expectValidType(_literal.type.str(), _literal.location); diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index 2ee77f71b..b16e2bfed 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -77,7 +77,6 @@ public: /// Asserts on failure. static AsmAnalysisInfo analyzeStrictAssertCorrect(Dialect const& _dialect, Object const& _object); - bool operator()(Instruction const&); bool operator()(Literal const& _literal); bool operator()(Identifier const&); bool operator()(ExpressionStatement const&); diff --git a/libyul/AsmData.h b/libyul/AsmData.h index c80fa7cfa..5c7a058b5 100644 --- a/libyul/AsmData.h +++ b/libyul/AsmData.h @@ -25,12 +25,8 @@ #include #include -#include #include -#include - -#include #include namespace yul @@ -41,8 +37,6 @@ using Type = YulString; struct TypedName { langutil::SourceLocation location; YulString name; Type type; }; using TypedNameList = std::vector; -/// Direct EVM instruction (except PUSHi and JUMPDEST) -struct Instruction { langutil::SourceLocation location; dev::eth::Instruction instruction; }; /// Literal number or string (up to 32 bytes) enum class LiteralKind { Number, Boolean, String }; struct Literal { langutil::SourceLocation location; LiteralKind kind; YulString value; Type type; }; diff --git a/libyul/AsmParser.h b/libyul/AsmParser.h index 5438494cd..0967828f3 100644 --- a/libyul/AsmParser.h +++ b/libyul/AsmParser.h @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -56,7 +58,7 @@ public: static std::map const& instructions(); protected: - using ElementaryOperation = std::variant; + using ElementaryOperation = std::variant; /// Creates an inline assembly node with the given source location. template T createWithLocation(langutil::SourceLocation const& _loc = {}) const diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 0d9a558df..ad4a757e2 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -43,7 +43,6 @@ enum class Instruction: uint8_t; namespace yul { -struct Instruction; struct Identifier; /// diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 51b31aae5..ba2561e0b 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -350,16 +350,6 @@ void CodeTransform::operator()(Literal const& _literal) checkStackHeight(&_literal); } -void CodeTransform::operator()(yul::Instruction const& _instruction) -{ - yulAssert(!m_allowStackOpt, ""); - yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMP, "Bare JUMP instruction used for EVM1.5"); - yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMPI, "Bare JUMPI instruction used for EVM1.5"); - m_assembly.setSourceLocation(_instruction.location); - m_assembly.appendInstruction(_instruction.instruction); - checkStackHeight(&_instruction); -} - void CodeTransform::operator()(If const& _if) { visitExpression(*_if.condition); diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index 6cf6bb307..d0615faf1 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -170,7 +170,6 @@ protected: void deleteVariable(Scope::Variable const& _var); public: - void operator()(Instruction const& _instruction); void operator()(Literal const& _literal); void operator()(Identifier const& _identifier); void operator()(FunctionCall const&); From bc71f6146772b5b239f7791801177237a9c3b48a Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Thu, 19 Dec 2019 18:01:43 -0500 Subject: [PATCH 03/57] Add ScopableAnnotation --- libsolidity/ast/ASTAnnotations.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 6d3c89092..268532976 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -75,6 +75,13 @@ struct SourceUnitAnnotation: ASTAnnotation std::set experimentalFeatures; }; +struct ScopableAnnotation +{ + /// The scope this declaration resides in. Can be nullptr if it is the global scope. + /// Available only after name and type resolution step. + ASTNode const* scope = nullptr; +}; + struct ImportAnnotation: ASTAnnotation { /// The absolute path of the source unit to import. From be14d5f28d0cc71f5e6a12c4c3bd81678f49a252 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Thu, 19 Dec 2019 18:04:46 -0500 Subject: [PATCH 04/57] Add DeclarationAnnotation --- libsolidity/ast/AST.cpp | 7 +++++++ libsolidity/ast/AST.h | 2 ++ libsolidity/ast/ASTAnnotations.h | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 140fe7a99..cd8a66ad7 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -449,6 +449,13 @@ string Scopable::sourceUnitName() const return sourceUnit().annotation().path; } +DeclarationAnnotation& Declaration::annotation() const +{ + if (!m_annotation) + m_annotation = make_unique(); + return dynamic_cast(*m_annotation); +} + bool VariableDeclaration::isLValue() const { // Constant declared variables are Read-Only diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index f761fe7af..871760a41 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -231,6 +231,8 @@ public: /// @returns null when it is not accessible as a function. virtual FunctionTypePointer functionType(bool /*_internal*/) const { return {}; } + DeclarationAnnotation& annotation() const override; + protected: virtual Visibility defaultVisibility() const { return Visibility::Public; } diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 268532976..8fa02a3fe 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -82,6 +82,10 @@ struct ScopableAnnotation ASTNode const* scope = nullptr; }; +struct DeclarationAnnotation: ASTAnnotation, ScopableAnnotation +{ +}; + struct ImportAnnotation: ASTAnnotation { /// The absolute path of the source unit to import. From 30b1b39901befd2f7e911ee9083c27f6b52eb07e Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Thu, 19 Dec 2019 18:14:53 -0500 Subject: [PATCH 05/57] Have other annotations subclass DeclarationAnnotation --- libsolidity/ast/ASTAnnotations.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 8fa02a3fe..107da87f5 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -86,7 +86,7 @@ struct DeclarationAnnotation: ASTAnnotation, ScopableAnnotation { }; -struct ImportAnnotation: ASTAnnotation +struct ImportAnnotation: DeclarationAnnotation { /// The absolute path of the source unit to import. std::string absolutePath; @@ -94,7 +94,7 @@ struct ImportAnnotation: ASTAnnotation SourceUnit const* sourceUnit = nullptr; }; -struct TypeDeclarationAnnotation: ASTAnnotation +struct TypeDeclarationAnnotation: DeclarationAnnotation { /// The name of this type, prefixed by proper namespaces if globally accessible. std::string canonicalName; @@ -115,7 +115,7 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, DocumentedAnnota std::map baseConstructorArguments; }; -struct CallableDeclarationAnnotation: ASTAnnotation +struct CallableDeclarationAnnotation: DeclarationAnnotation { /// The set of functions/modifiers/events this callable overrides. std::set baseFunctions; @@ -135,7 +135,7 @@ struct ModifierDefinitionAnnotation: CallableDeclarationAnnotation, DocumentedAn { }; -struct VariableDeclarationAnnotation: ASTAnnotation +struct VariableDeclarationAnnotation: DeclarationAnnotation { /// Type of variable (type of identifier referencing this variable). TypePointer type = nullptr; From 69fd185903e86e55fef1740395417d763887afdc Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Thu, 19 Dec 2019 20:20:27 -0500 Subject: [PATCH 06/57] Add new annotations for Scopables --- libsolidity/ast/AST.cpp | 21 +++++++++++++++++++++ libsolidity/ast/AST.h | 6 ++++++ libsolidity/ast/ASTAnnotations.h | 12 ++++++++++++ 3 files changed, 39 insertions(+) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index cd8a66ad7..a7d5e73ca 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -660,6 +660,27 @@ InlineAssemblyAnnotation& InlineAssembly::annotation() const return dynamic_cast(*m_annotation); } +BlockAnnotation& Block::annotation() const +{ + if (!m_annotation) + m_annotation = make_unique(); + return dynamic_cast(*m_annotation); +} + +TryCatchClauseAnnotation& TryCatchClause::annotation() const +{ + if (!m_annotation) + m_annotation = make_unique(); + return dynamic_cast(*m_annotation); +} + +ForStatementAnnotation& ForStatement::annotation() const +{ + if (!m_annotation) + m_annotation = make_unique(); + return dynamic_cast(*m_annotation); +} + ReturnAnnotation& Return::annotation() const { if (!m_annotation) diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 871760a41..4abaf93e3 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -1171,6 +1171,8 @@ public: std::vector> const& statements() const { return m_statements; } + BlockAnnotation& annotation() const override; + private: std::vector> m_statements; }; @@ -1250,6 +1252,8 @@ public: ParameterList const* parameters() const { return m_parameters.get(); } Block const& block() const { return *m_block; } + TryCatchClauseAnnotation& annotation() const override; + private: ASTPointer m_errorName; ASTPointer m_parameters; @@ -1359,6 +1363,8 @@ public: ExpressionStatement const* loopExpression() const { return m_loopExpression.get(); } Statement const& body() const { return *m_body; } + ForStatementAnnotation& annotation() const override; + private: /// For statement's initialization expression. for (XXX; ; ). Can be empty ASTPointer m_initExpression; diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 107da87f5..0f11b1c5a 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -163,6 +163,18 @@ struct InlineAssemblyAnnotation: StatementAnnotation std::shared_ptr analysisInfo; }; +struct BlockAnnotation: StatementAnnotation, ScopableAnnotation +{ +}; + +struct TryCatchClauseAnnotation: ASTAnnotation, ScopableAnnotation +{ +}; + +struct ForStatementAnnotation: StatementAnnotation, ScopableAnnotation +{ +}; + struct ReturnAnnotation: StatementAnnotation { /// Reference to the return parameters of the function. From 6679f92c8afbf1f0361702320b0123dc59addff1 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Thu, 19 Dec 2019 20:49:43 -0500 Subject: [PATCH 07/57] Move all references to scope into annotation --- libsolidity/analysis/NameAndTypeResolver.cpp | 8 ++++---- libsolidity/ast/AST.h | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 21f8a5d19..6881e14d6 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -639,7 +639,7 @@ void DeclarationRegistrationHelper::endVisit(FunctionDefinition&) bool DeclarationRegistrationHelper::visit(TryCatchClause& _tryCatchClause) { - _tryCatchClause.setScope(m_currentScope); + _tryCatchClause.annotation().scope = m_currentScope; enterNewSubScope(_tryCatchClause); return true; } @@ -675,7 +675,7 @@ void DeclarationRegistrationHelper::endVisit(FunctionTypeName&) bool DeclarationRegistrationHelper::visit(Block& _block) { - _block.setScope(m_currentScope); + _block.annotation().scope = m_currentScope; enterNewSubScope(_block); return true; } @@ -687,7 +687,7 @@ void DeclarationRegistrationHelper::endVisit(Block&) bool DeclarationRegistrationHelper::visit(ForStatement& _for) { - _for.setScope(m_currentScope); + _for.annotation().scope = m_currentScope; enterNewSubScope(_for); return true; } @@ -761,7 +761,7 @@ void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaratio registerDeclaration(*m_scopes[m_currentScope], _declaration, nullptr, nullptr, warnAboutShadowing, inactive, m_errorReporter); - _declaration.setScope(m_currentScope); + _declaration.annotation().scope = m_currentScope; if (_opensScope) enterNewSubScope(_declaration); } diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 4abaf93e3..f687f20c9 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -159,8 +159,7 @@ public: virtual ~Scopable() = default; /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope. /// Available only after name and type resolution step. - ASTNode const* scope() const { return m_scope; } - void setScope(ASTNode const* _scope) { m_scope = _scope; } + ASTNode const* scope() const { return annotation().scope; } /// @returns the source unit this scopable is present in. SourceUnit const& sourceUnit() const; @@ -172,8 +171,7 @@ public: /// Can be combined with annotation().canonicalName (if present) to form a globally unique name. std::string sourceUnitName() const; -protected: - ASTNode const* m_scope = nullptr; + virtual ScopableAnnotation& annotation() const = 0; }; /** From c44916cbd5897416a1aaef6aeadce2dc728ffe9c Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 20 Dec 2019 08:29:25 +0100 Subject: [PATCH 08/57] Changelog entry for try/catch. --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 9b4d81ff7..817ee9180 100644 --- a/Changelog.md +++ b/Changelog.md @@ -45,6 +45,7 @@ Language Features: * Allow global enums and structs. * Allow public variables to override external functions. * Allow underscores as delimiters in hex strings. + * Allow to react on failing external calls using ``try`` and ``catch``. * Introduce syntax for array slices and implement them for dynamic calldata arrays. * Introduce ``push()`` for dynamic storage arrays. It returns a reference to the newly allocated element, if applicable. * Introduce ``virtual`` and ``override`` keywords. From 4d791b2679283d173896d118730c8b598bd2b7f6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 13 Dec 2019 14:46:28 +0000 Subject: [PATCH 09/57] Issue warning if codesize exceeds EIP-170 limits --- Changelog.md | 2 +- libsolidity/interface/CompilerStack.cpp | 15 +++++++++++++++ .../syntaxTests/bytecode_too_large.sol | 10 ++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/syntaxTests/bytecode_too_large.sol diff --git a/Changelog.md b/Changelog.md index 817ee9180..9b795d50d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,7 +4,7 @@ Language Features: Compiler Features: - + * General: Raise warning if runtime bytecode exceeds 24576 bytes (a limit introduced in Spurious Dragon). Bugfixes: diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 73824297e..396b7d2f8 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -1046,6 +1046,21 @@ void CompilerStack::compileContract( solAssert(false, "Assembly exception for deployed bytecode"); } + // Throw a warning if EIP-170 limits are exceeded: + // If contract creation initialization returns data with length of more than 0x6000 (214 + 213) bytes, + // contract creation fails with an out of gas error. + if ( + m_evmVersion >= langutil::EVMVersion::spuriousDragon() && + compiledContract.runtimeObject.bytecode.size() > 0x6000 + ) + m_errorReporter.warning( + _contract.location(), + "Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). " + "This contract may not be deployable on mainnet. " + "Consider enabling the optimizer (with a low \"runs\" value!), " + "turning off revert strings, or using libraries." + ); + _otherCompilers[compiledContract.contract] = compiler; } diff --git a/test/libsolidity/syntaxTests/bytecode_too_large.sol b/test/libsolidity/syntaxTests/bytecode_too_large.sol new file mode 100644 index 000000000..ea8831e13 --- /dev/null +++ b/test/libsolidity/syntaxTests/bytecode_too_large.sol @@ -0,0 +1,10 @@ +contract test { + function f() public pure returns (string memory ret) { + // 27000 bytes long data + ret = "........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................"; + } +} +// ==== +// EVMVersion: >=spuriousDragon +// ---- +// Warning: (0-27133): Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries. From aab8b9bc36ddf10ae45ab458f2136392959e1266 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 14:21:23 +0100 Subject: [PATCH 10/57] Fix redundant assignment removal in combination with break / continue. --- .../optimiser/RedundantAssignEliminator.cpp | 31 +++++++++---------- libyul/optimiser/RedundantAssignEliminator.h | 2 -- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/RedundantAssignEliminator.cpp index aca44d0b3..38c7881a0 100644 --- a/libyul/optimiser/RedundantAssignEliminator.cpp +++ b/libyul/optimiser/RedundantAssignEliminator.cpp @@ -280,29 +280,28 @@ void RedundantAssignEliminator::changeUndecidedTo(YulString _variable, Redundant void RedundantAssignEliminator::finalize(YulString _variable, RedundantAssignEliminator::State _finalState) { - finalize(m_assignments, _variable, _finalState); - for (auto& assignments: m_forLoopInfo.pendingBreakStmts) - finalize(assignments, _variable, _finalState); - for (auto& assignments: m_forLoopInfo.pendingContinueStmts) - finalize(assignments, _variable, _finalState); -} + std::map assignments; + joinMap(assignments, std::move(m_assignments[_variable]), State::join); + m_assignments.erase(_variable); -void RedundantAssignEliminator::finalize( - TrackedAssignments& _assignments, - YulString _variable, - RedundantAssignEliminator::State _finalState -) -{ - for (auto const& assignment: _assignments[_variable]) + for (auto& breakAssignments: m_forLoopInfo.pendingBreakStmts) + { + joinMap(assignments, std::move(breakAssignments[_variable]), State::join); + breakAssignments.erase(_variable); + } + for (auto& continueAssignments: m_forLoopInfo.pendingContinueStmts) + { + joinMap(assignments, std::move(continueAssignments[_variable]), State::join); + continueAssignments.erase(_variable); + } + + for (auto const& assignment: assignments) { State const state = assignment.second == State::Undecided ? _finalState : assignment.second; if (state == State::Unused && SideEffectsCollector{*m_dialect, *assignment.first->value}.movable()) - // TODO the only point where we actually need this - // to be a set is for the for loop m_pendingRemovals.insert(assignment.first); } - _assignments.erase(_variable); } void AssignmentRemover::operator()(Block& _block) diff --git a/libyul/optimiser/RedundantAssignEliminator.h b/libyul/optimiser/RedundantAssignEliminator.h index fec6a2714..7849708d6 100644 --- a/libyul/optimiser/RedundantAssignEliminator.h +++ b/libyul/optimiser/RedundantAssignEliminator.h @@ -161,8 +161,6 @@ private: /// assignments to the final state. In this case, this also applies to pending /// break and continue TrackedAssignments. void finalize(YulString _variable, State _finalState); - /// Helper function for the above. - void finalize(TrackedAssignments& _assignments, YulString _variable, State _finalState); Dialect const* m_dialect; std::set m_declaredVariables; From 3994c9135f84a7f7b9b93286d313f67773c6e193 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 15:16:54 +0100 Subject: [PATCH 11/57] Tests. --- .../remove_break.yul | 26 ++++++++++++++++++ .../remove_continue.yul | 27 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul create mode 100644 test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul new file mode 100644 index 000000000..8e75d82ed --- /dev/null +++ b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul @@ -0,0 +1,26 @@ +{ + let i := 0 + for {} lt(i, 2) { i := add(i, 1) } + { + let x + x := 1337 + if lt(i,1) { + x := 42 + break + } + mstore(0, x) + } +} +// ==== +// step: redundantAssignEliminator +// ---- +// { +// let i := 0 +// for { } lt(i, 2) { i := add(i, 1) } +// { +// let x +// x := 1337 +// if lt(i, 1) { break } +// mstore(0, x) +// } +// } diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul new file mode 100644 index 000000000..f5a29382b --- /dev/null +++ b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul @@ -0,0 +1,27 @@ +{ + let i := 0 + for {} lt(i, 2) { i := add(i, 1) } + { + let x + x := 1337 + if lt(i,1) { + x := 42 + continue + } + mstore(0, x) + } +} + +// ==== +// step: redundantAssignEliminator +// ---- +// { +// let i := 0 +// for { } lt(i, 2) { i := add(i, 1) } +// { +// let x +// x := 1337 +// if lt(i, 1) { continue } +// mstore(0, x) +// } +// } From c3f43fd1e6f16e9d3b57eec863e6c4660b73d8c5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 15:14:43 +0100 Subject: [PATCH 12/57] Changelog entry. --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 9b4d81ff7..8b05393c2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ Compiler Features: Bugfixes: + * Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements. From 1e50fc61e46eb81c607cb9d649c93decfd99cbad Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 14:21:23 +0100 Subject: [PATCH 13/57] Fix redundant assignment removal in combination with break / continue. --- .../optimiser/RedundantAssignEliminator.cpp | 31 +++++++++---------- libyul/optimiser/RedundantAssignEliminator.h | 2 -- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/RedundantAssignEliminator.cpp index 477814e22..3c619ad45 100644 --- a/libyul/optimiser/RedundantAssignEliminator.cpp +++ b/libyul/optimiser/RedundantAssignEliminator.cpp @@ -268,29 +268,28 @@ void RedundantAssignEliminator::changeUndecidedTo(YulString _variable, Redundant void RedundantAssignEliminator::finalize(YulString _variable, RedundantAssignEliminator::State _finalState) { - finalize(m_assignments, _variable, _finalState); - for (auto& assignments: m_forLoopInfo.pendingBreakStmts) - finalize(assignments, _variable, _finalState); - for (auto& assignments: m_forLoopInfo.pendingContinueStmts) - finalize(assignments, _variable, _finalState); -} + std::map assignments; + joinMap(assignments, std::move(m_assignments[_variable]), State::join); + m_assignments.erase(_variable); -void RedundantAssignEliminator::finalize( - TrackedAssignments& _assignments, - YulString _variable, - RedundantAssignEliminator::State _finalState -) -{ - for (auto const& assignment: _assignments[_variable]) + for (auto& breakAssignments: m_forLoopInfo.pendingBreakStmts) + { + joinMap(assignments, std::move(breakAssignments[_variable]), State::join); + breakAssignments.erase(_variable); + } + for (auto& continueAssignments: m_forLoopInfo.pendingContinueStmts) + { + joinMap(assignments, std::move(continueAssignments[_variable]), State::join); + continueAssignments.erase(_variable); + } + + for (auto const& assignment: assignments) { State const state = assignment.second == State::Undecided ? _finalState : assignment.second; if (state == State::Unused && SideEffectsCollector{*m_dialect, *assignment.first->value}.movable()) - // TODO the only point where we actually need this - // to be a set is for the for loop m_pendingRemovals.insert(assignment.first); } - _assignments.erase(_variable); } void AssignmentRemover::operator()(Block& _block) diff --git a/libyul/optimiser/RedundantAssignEliminator.h b/libyul/optimiser/RedundantAssignEliminator.h index 65ddc19ae..0b68c1094 100644 --- a/libyul/optimiser/RedundantAssignEliminator.h +++ b/libyul/optimiser/RedundantAssignEliminator.h @@ -158,8 +158,6 @@ private: /// assignments to the final state. In this case, this also applies to pending /// break and continue TrackedAssignments. void finalize(YulString _variable, State _finalState); - /// Helper function for the above. - void finalize(TrackedAssignments& _assignments, YulString _variable, State _finalState); Dialect const* m_dialect; std::set m_declaredVariables; From 92c3511f47158ecaf1bba717eded84410f55132f Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 15:16:54 +0100 Subject: [PATCH 14/57] Tests. --- .../remove_break.yul | 26 ++++++++++++++++++ .../remove_continue.yul | 27 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul create mode 100644 test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul new file mode 100644 index 000000000..8e75d82ed --- /dev/null +++ b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_break.yul @@ -0,0 +1,26 @@ +{ + let i := 0 + for {} lt(i, 2) { i := add(i, 1) } + { + let x + x := 1337 + if lt(i,1) { + x := 42 + break + } + mstore(0, x) + } +} +// ==== +// step: redundantAssignEliminator +// ---- +// { +// let i := 0 +// for { } lt(i, 2) { i := add(i, 1) } +// { +// let x +// x := 1337 +// if lt(i, 1) { break } +// mstore(0, x) +// } +// } diff --git a/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul new file mode 100644 index 000000000..f5a29382b --- /dev/null +++ b/test/libyul/yulOptimizerTests/redundantAssignEliminator/remove_continue.yul @@ -0,0 +1,27 @@ +{ + let i := 0 + for {} lt(i, 2) { i := add(i, 1) } + { + let x + x := 1337 + if lt(i,1) { + x := 42 + continue + } + mstore(0, x) + } +} + +// ==== +// step: redundantAssignEliminator +// ---- +// { +// let i := 0 +// for { } lt(i, 2) { i := add(i, 1) } +// { +// let x +// x := 1337 +// if lt(i, 1) { continue } +// mstore(0, x) +// } +// } From 29c0b73dff95a471738fc316931fbaf7fa30fc18 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 15:51:27 +0100 Subject: [PATCH 15/57] Bug list entry. --- docs/bugs.json | 11 +++++++++++ docs/bugs_by_version.json | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/bugs.json b/docs/bugs.json index 5d94131a1..2bb6a4848 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -1,4 +1,15 @@ [ + { + "name": "YulOptimizerRedundantAssignmentBreakContinue", + "summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.", + "description": "The Yul optimizer has a stage that remove assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.", + "introduced": "0.6.0", + "fixed": "0.6.1", + "severity": "medium", + "conditions": { + "yulOptimizer": true + } + }, { "name": "ABIEncoderV2LoopYulOptimizer", "summary": "If both the experimental ABIEncoderV2 and the experimental Yul optimizer are activated, one component of the Yul optimizer may reuse data in memory that has been changed in the meantime.", diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 0fa1e1076..26524d9a4 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -856,7 +856,9 @@ "released": "2019-05-28" }, "0.6.0": { - "bugs": [], + "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue" + ], "released": "2019-12-17" } } \ No newline at end of file From 27727a7af32d43d648a126a7574eb8bbee7a19c1 Mon Sep 17 00:00:00 2001 From: elenadimitrova Date: Thu, 2 Jan 2020 12:39:10 +0200 Subject: [PATCH 16/57] Rename solium to ethlint --- docs/resources.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources.rst b/docs/resources.rst index 4335c3deb..3a9e3c0c2 100644 --- a/docs/resources.rst +++ b/docs/resources.rst @@ -33,7 +33,7 @@ Solidity Integrations * `Solidity IDE `_ Browser-based IDE with integrated compiler, Ganache and local file system support. - * `Solium `_ + * `Ethlint `_ Linter to identify and fix style and security issues in Solidity. * `Superblocks Lab `_ @@ -48,7 +48,7 @@ Solidity Integrations Plugin for the Atom editor that provides Solidity linting. * `Atom Solium Linter `_ - Configurable Solidty linter for Atom using Solium as a base. + Configurable Solidity linter for Atom using Solium (now Ethlint) as a base. * Eclipse: From d972a10b4f438d17f6aabd71500d94b41309a064 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Thu, 2 Jan 2020 12:43:56 +0100 Subject: [PATCH 17/57] Review 1 --- docs/bugs.json | 2 +- test/libsolidity/SolidityEndToEndTest.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/bugs.json b/docs/bugs.json index 2bb6a4848..1f0f34de5 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -2,7 +2,7 @@ { "name": "YulOptimizerRedundantAssignmentBreakContinue", "summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.", - "description": "The Yul optimizer has a stage that remove assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.", + "description": "The Yul optimizer has a stage that removes assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.", "introduced": "0.6.0", "fixed": "0.6.1", "severity": "medium", diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 72772f048..c1ed1d67e 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -14319,8 +14319,6 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name) )"; compileAndRun(sourceCode, 0, "ClientReceipt", bytes()); compileAndRun(sourceCode, 0, "Test", bytes(), map{{"ClientReceipt", m_contractAddress}}); - u256 value(18); - u256 id(0x1234); callContractFunction("f()"); BOOST_REQUIRE_EQUAL(numLogs(), 1); From 1c2096a360f1590e41cd535524201d1f7f346297 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 15:14:43 +0100 Subject: [PATCH 18/57] Changelog entry. --- Changelog.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index f09fb0355..72461f021 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,9 +1,14 @@ +### 0.5.16 (2020-01-02) + +Bugfixes: + * Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements. + + ### 0.5.15 (2019-12-17) Bugfixes: * Yul Optimizer: Fix incorrect redundant load optimization crossing user-defined functions that contain for-loops with memory / storage writes. - ### 0.5.14 (2019-12-09) Language Features: From 8328f826a1c3aca400c463b58cd7f43d71f87f97 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Dec 2019 15:51:27 +0100 Subject: [PATCH 19/57] Bug list entry. --- docs/bugs.json | 11 +++++++++++ docs/bugs_by_version.json | 24 ++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/docs/bugs.json b/docs/bugs.json index 5d94131a1..52b062c8a 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -1,4 +1,15 @@ [ + { + "name": "YulOptimizerRedundantAssignmentBreakContinue0.5", + "summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.", + "description": "The Yul optimizer has a stage that remove assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to varibales declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.", + "introduced": "0.5.8", + "fixed": "0.5.16", + "severity": "low", + "conditions": { + "yulOptimizer": true + } + }, { "name": "ABIEncoderV2LoopYulOptimizer", "summary": "If both the experimental ABIEncoderV2 and the experimental Yul optimizer are activated, one component of the Yul optimizer may reuse data in memory that has been changed in the meantime.", diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 1a0e99749..a9ce0be92 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -742,32 +742,46 @@ }, "0.5.10": { "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5", "ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers" ], "released": "2019-06-25" }, "0.5.11": { - "bugs": [], + "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5" + ], "released": "2019-08-12" }, "0.5.12": { - "bugs": [], + "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5" + ], "released": "2019-10-01" }, "0.5.13": { - "bugs": [], + "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5" + ], "released": "2019-11-14" }, "0.5.14": { "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5", "ABIEncoderV2LoopYulOptimizer" ], "released": "2019-12-09" }, "0.5.15": { - "bugs": [], + "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5" + ], "released": "2019-12-17" }, + "0.5.16": { + "bugs": [], + "released": "2020-01-02" + }, "0.5.2": { "bugs": [ "SignedArrayStorageCopy", @@ -840,6 +854,7 @@ }, "0.5.8": { "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5", "ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers", "SignedArrayStorageCopy", "ABIEncoderV2StorageArrayWithMultiSlotElement", @@ -849,6 +864,7 @@ }, "0.5.9": { "bugs": [ + "YulOptimizerRedundantAssignmentBreakContinue0.5", "ABIEncoderV2CalldataStructsWithStaticallySizedAndDynamicallyEncodedMembers", "SignedArrayStorageCopy", "ABIEncoderV2StorageArrayWithMultiSlotElement" From 026f7c37af8e75b7ae7cbebd8e30eba032b6ef0f Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Thu, 2 Jan 2020 12:54:52 +0100 Subject: [PATCH 20/57] Review 1 --- docs/bugs.json | 2 +- test/libsolidity/SolidityEndToEndTest.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/bugs.json b/docs/bugs.json index 52b062c8a..bbb9e93fa 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -2,7 +2,7 @@ { "name": "YulOptimizerRedundantAssignmentBreakContinue0.5", "summary": "The Yul optimizer can remove essential assignments to variables declared inside for loops when Yul's continue or break statement is used. You are unlikely to be affected if you do not use inline assembly with for loops and continue and break statements.", - "description": "The Yul optimizer has a stage that remove assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to varibales declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.", + "description": "The Yul optimizer has a stage that removes assignments to variables that are overwritten again or are not used in all following control-flow branches. This logic incorrectly removes such assignments to variables declared inside a for loop if they can be removed in a control-flow branch that ends with ``break`` or ``continue`` even though they cannot be removed in other control-flow branches. Variables declared outside of the respective for loop are not affected.", "introduced": "0.5.8", "fixed": "0.5.16", "severity": "low", diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index bc03c2ef8..dfe135db9 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -14718,8 +14718,6 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name) )"; compileAndRun(sourceCode, 0, "ClientReceipt", bytes()); compileAndRun(sourceCode, 0, "Test", bytes(), map{{"ClientReceipt", m_contractAddress}}); - u256 value(18); - u256 id(0x1234); callContractFunction("f()"); BOOST_REQUIRE_EQUAL(numLogs(), 1); From 9c3226ce7558bfa639ca06ddd7214ae9bf4e1fc9 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 2 Jan 2020 19:52:34 +0100 Subject: [PATCH 21/57] Set version to 0.5.16. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10b830a6c..0c84c6d15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.5.15") +set(PROJECT_VERSION "0.5.16") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) include(TestBigEndian) From bdd9f215cb541f36bca17d284ab71c5b9af738c7 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 2 Jan 2020 23:01:50 +0100 Subject: [PATCH 22/57] Update the yul switch to the 0.6.0 behaviour. --- docs/using-the-compiler.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 9921c1c1b..f323d0c61 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -220,8 +220,11 @@ Input Description "cse": false, // Optimize representation of literal numbers and strings in code. "constantOptimizer": false, - // The new Yul optimizer. Mostly operates on the code of ABIEncoderV2. - // It can only be activated through the details here. + // The new Yul optimizer. Mostly operates on the code of ABIEncoderV2 + // and inline assembly. + // It is activated together with the global optimizer setting + // and can be deactivated here. + // Before Solidity 0.6.0 it had to be activated through this switch. "yul": false, // Tuning options for the Yul optimizer. "yulDetails": { From 385e1bf70a0389009af0da2f2f6054cd5b246619 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 2 Jan 2020 19:48:43 +0100 Subject: [PATCH 23/57] Set release date. --- Changelog.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Changelog.md b/Changelog.md index cee949e69..4487b30e4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,16 +1,9 @@ -### 0.6.1 (unreleased) - -Language Features: - - -Compiler Features: - +### 0.6.1 (2020-01-02) Bugfixes: * Yul Optimizer: Fix bug in redundant assignment remover in combination with break and continue statements. - ### 0.6.0 (2019-12-17) Breaking changes: From 30a2d712c09cdce7254c19b294c5e39e78d85191 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 2 Jan 2020 23:51:49 +0100 Subject: [PATCH 24/57] Bug list entry. --- docs/bugs_by_version.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 3b8422053..4c9a01c64 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -876,5 +876,9 @@ "YulOptimizerRedundantAssignmentBreakContinue" ], "released": "2019-12-17" + }, + "0.6.1": { + "bugs": [], + "released": "2020-01-02" } } \ No newline at end of file From b269eef7215cb6d74bd07cc73d8df94959a0e0dc Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 3 Jan 2020 13:38:17 +0100 Subject: [PATCH 25/57] Set version to 0.6.2. --- CMakeLists.txt | 2 +- Changelog.md | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb8c1a49c..2dfd023f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.6.1") +set(PROJECT_VERSION "0.6.2") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) include(TestBigEndian) diff --git a/Changelog.md b/Changelog.md index 4487b30e4..7b9b82437 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,15 @@ +### 0.6.2 (unreleased) + +Language Features: + + +Compiler Features: + + +Bugfixes: + + + ### 0.6.1 (2020-01-02) Bugfixes: From f4f83690f3b22cdfef409253453d4dd00baaa72f Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Sat, 4 Jan 2020 21:45:21 +0100 Subject: [PATCH 26/57] Replace some shared_ptr by unique_ptr or raw pointers --- libsolidity/formal/BMC.cpp | 6 ++--- libsolidity/formal/BMC.h | 6 ++--- libsolidity/formal/CHC.cpp | 26 +++++++++------------- libsolidity/formal/CHC.h | 2 +- libsolidity/formal/CHCSmtLib2Interface.cpp | 2 +- libsolidity/formal/CHCSmtLib2Interface.h | 5 ++--- libsolidity/formal/EncodingContext.h | 6 ++--- libsolidity/formal/Z3CHCInterface.cpp | 2 +- libsolidity/formal/Z3CHCInterface.h | 4 ++-- 9 files changed, 25 insertions(+), 34 deletions(-) diff --git a/libsolidity/formal/BMC.cpp b/libsolidity/formal/BMC.cpp index dc1be1035..f8fa347f0 100644 --- a/libsolidity/formal/BMC.cpp +++ b/libsolidity/formal/BMC.cpp @@ -35,8 +35,8 @@ BMC::BMC( smt::SMTSolverChoice _enabledSolvers ): SMTEncoder(_context), - m_outerErrorReporter(_errorReporter), - m_interface(make_shared(_smtlib2Responses, _smtCallback, _enabledSolvers)) + m_interface(make_unique(_smtlib2Responses, _smtCallback, _enabledSolvers)), + m_outerErrorReporter(_errorReporter) { #if defined (HAVE_Z3) || defined (HAVE_CVC4) if (_enabledSolvers.some()) @@ -55,7 +55,7 @@ void BMC::analyze(SourceUnit const& _source, set _safeAsserti solAssert(_source.annotation().experimentalFeatures.count(ExperimentalFeature::SMTChecker), ""); m_safeAssertions += move(_safeAssertions); - m_context.setSolver(m_interface); + m_context.setSolver(m_interface.get()); m_context.clear(); m_context.setAssertionAccumulation(true); m_variableUsage.setFunctionInlining(true); diff --git a/libsolidity/formal/BMC.h b/libsolidity/formal/BMC.h index 473b5dfee..972ee88ce 100644 --- a/libsolidity/formal/BMC.h +++ b/libsolidity/formal/BMC.h @@ -71,8 +71,6 @@ public: /// @returns true if _funCall should be inlined, otherwise false. static bool shouldInlineFunctionCall(FunctionCall const& _funCall); - std::shared_ptr solver() { return m_interface; } - private: /// AST visitors. /// Only nodes that lead to verification targets being built @@ -172,6 +170,8 @@ private: smt::CheckResult checkSatisfiable(); //@} + std::unique_ptr m_interface; + /// Flags used for better warning messages. bool m_loopExecutionHappened = false; bool m_externalFunctionCallHappened = false; @@ -183,8 +183,6 @@ private: /// Assertions that are known to be safe. std::set m_safeAssertions; - - std::shared_ptr m_interface; }; } diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index e911ce8d4..bc4e355f5 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -37,24 +37,18 @@ CHC::CHC( ErrorReporter& _errorReporter, map const& _smtlib2Responses, ReadCallback::Callback const& _smtCallback, - smt::SMTSolverChoice _enabledSolvers + [[maybe_unused]] smt::SMTSolverChoice _enabledSolvers ): SMTEncoder(_context), -#ifdef HAVE_Z3 - m_interface( - _enabledSolvers.z3 ? - dynamic_pointer_cast(make_shared()) : - dynamic_pointer_cast(make_shared(_smtlib2Responses, _smtCallback)) - ), -#else - m_interface(make_shared(_smtlib2Responses, _smtCallback)), -#endif m_outerErrorReporter(_errorReporter), m_enabledSolvers(_enabledSolvers) { - (void)_smtlib2Responses; - (void)_enabledSolvers; - (void)_smtCallback; +#ifdef HAVE_Z3 + if (_enabledSolvers.z3) + m_interface = make_unique(); +#endif + if (!m_interface) + m_interface = make_unique(_smtlib2Responses, _smtCallback); } void CHC::analyze(SourceUnit const& _source) @@ -66,14 +60,14 @@ void CHC::analyze(SourceUnit const& _source) usesZ3 = m_enabledSolvers.z3; if (usesZ3) { - auto z3Interface = dynamic_pointer_cast(m_interface); + auto z3Interface = dynamic_cast(m_interface.get()); solAssert(z3Interface, ""); m_context.setSolver(z3Interface->z3Interface()); } #endif if (!usesZ3) { - auto smtlib2Interface = dynamic_pointer_cast(m_interface); + auto smtlib2Interface = dynamic_cast(m_interface.get()); solAssert(smtlib2Interface, ""); m_context.setSolver(smtlib2Interface->smtlib2Interface()); } @@ -95,7 +89,7 @@ void CHC::analyze(SourceUnit const& _source) vector CHC::unhandledQueries() const { - if (auto smtlib2 = dynamic_pointer_cast(m_interface)) + if (auto smtlib2 = dynamic_cast(m_interface.get())) return smtlib2->unhandledQueries(); return {}; diff --git a/libsolidity/formal/CHC.h b/libsolidity/formal/CHC.h index 664ae98bc..6e281d5ef 100644 --- a/libsolidity/formal/CHC.h +++ b/libsolidity/formal/CHC.h @@ -207,7 +207,7 @@ private: //@} /// CHC solver. - std::shared_ptr m_interface; + std::unique_ptr m_interface; /// ErrorReporter that comes from CompilerStack. langutil::ErrorReporter& m_outerErrorReporter; diff --git a/libsolidity/formal/CHCSmtLib2Interface.cpp b/libsolidity/formal/CHCSmtLib2Interface.cpp index ceb12bbac..11aa87608 100644 --- a/libsolidity/formal/CHCSmtLib2Interface.cpp +++ b/libsolidity/formal/CHCSmtLib2Interface.cpp @@ -38,7 +38,7 @@ CHCSmtLib2Interface::CHCSmtLib2Interface( map const& _queryResponses, ReadCallback::Callback const& _smtCallback ): - m_smtlib2(make_shared(_queryResponses, _smtCallback)), + m_smtlib2(make_unique(_queryResponses, _smtCallback)), m_queryResponses(_queryResponses), m_smtCallback(_smtCallback) { diff --git a/libsolidity/formal/CHCSmtLib2Interface.h b/libsolidity/formal/CHCSmtLib2Interface.h index 8aebdd8b2..24e69a15d 100644 --- a/libsolidity/formal/CHCSmtLib2Interface.h +++ b/libsolidity/formal/CHCSmtLib2Interface.h @@ -52,7 +52,7 @@ public: std::vector unhandledQueries() const { return m_unhandledQueries; } - std::shared_ptr smtlib2Interface() { return m_smtlib2; } + SMTLib2Interface* smtlib2Interface() const { return m_smtlib2.get(); } private: void declareFunction(std::string const& _name, SortPointer const& _sort); @@ -63,8 +63,7 @@ private: std::string querySolver(std::string const& _input); /// Used to access toSmtLibSort, SExpr, and handle variables. - /// Needs to be a shared_ptr since it's also passed to EncodingContext. - std::shared_ptr m_smtlib2; + std::unique_ptr m_smtlib2; std::string m_accumulatedOutput; std::set m_variables; diff --git a/libsolidity/formal/EncodingContext.h b/libsolidity/formal/EncodingContext.h index 4e1e15658..f2c9d0e31 100644 --- a/libsolidity/formal/EncodingContext.h +++ b/libsolidity/formal/EncodingContext.h @@ -48,7 +48,7 @@ public: /// Sets the current solver used by the current engine for /// SMT variable declaration. - void setSolver(std::shared_ptr _solver) + void setSolver(SolverInterface* _solver) { solAssert(_solver, ""); m_solver = _solver; @@ -144,7 +144,7 @@ public: void pushSolver(); void popSolver(); void addAssertion(Expression const& _e); - std::shared_ptr solver() + SolverInterface* solver() { solAssert(m_solver, ""); return m_solver; @@ -177,7 +177,7 @@ private: /// Solver related. //@{ /// Solver can be SMT solver or Horn solver in the future. - std::shared_ptr m_solver; + SolverInterface* m_solver = nullptr; /// Assertion stack. std::vector m_assertions; diff --git a/libsolidity/formal/Z3CHCInterface.cpp b/libsolidity/formal/Z3CHCInterface.cpp index d4c53f850..017fb1a58 100644 --- a/libsolidity/formal/Z3CHCInterface.cpp +++ b/libsolidity/formal/Z3CHCInterface.cpp @@ -25,7 +25,7 @@ using namespace dev; using namespace dev::solidity::smt; Z3CHCInterface::Z3CHCInterface(): - m_z3Interface(make_shared()), + m_z3Interface(make_unique()), m_context(m_z3Interface->context()), m_solver(*m_context) { diff --git a/libsolidity/formal/Z3CHCInterface.h b/libsolidity/formal/Z3CHCInterface.h index 858e4f40f..20373c244 100644 --- a/libsolidity/formal/Z3CHCInterface.h +++ b/libsolidity/formal/Z3CHCInterface.h @@ -45,11 +45,11 @@ public: std::pair> query(Expression const& _expr) override; - std::shared_ptr z3Interface() { return m_z3Interface; } + Z3Interface* z3Interface() const { return m_z3Interface.get(); } private: // Used to handle variables. - std::shared_ptr m_z3Interface; + std::unique_ptr m_z3Interface; z3::context* m_context; // Horn solver. From 3e714913a0c2ec1935f9d5027800f6b0114e2465 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 6 Jan 2020 15:28:20 +0100 Subject: [PATCH 27/57] Disallow positional arguments for (i)soltest instead of ignoring --- test/Common.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/Common.cpp b/test/Common.cpp index 48966d9a3..10a0ed3e8 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -117,9 +117,20 @@ bool CommonOptions::parse(int argc, char const* const* argv) po::command_line_parser cmdLineParser(argc, argv); cmdLineParser.options(options); - po::store(cmdLineParser.run(), arguments); + auto parsedOptions = cmdLineParser.run(); + po::store(parsedOptions, arguments); po::notify(arguments); + for (auto const& parsedOption: parsedOptions.options) + if (parsedOption.position_key >= 0) + { + std::stringstream errorMessage; + errorMessage << "Unrecognized option: "; + for (auto const& token: parsedOption.original_tokens) + errorMessage << token; + throw std::runtime_error(errorMessage.str()); + } + return true; } From 49aec64cafd06bde9b0f3c46517bee3778531115 Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Thu, 12 Dec 2019 18:33:36 +0100 Subject: [PATCH 28/57] abiv2 proto converter: Do not resize dynamic storage arrays by writing to the length field as it is now read only --- test/tools/ossfuzz/protoToAbiV2.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/tools/ossfuzz/protoToAbiV2.cpp b/test/tools/ossfuzz/protoToAbiV2.cpp index b980a6f93..c7ac06c22 100644 --- a/test/tools/ossfuzz/protoToAbiV2.cpp +++ b/test/tools/ossfuzz/protoToAbiV2.cpp @@ -810,13 +810,16 @@ pair AssignCheckVisitor::visit(ArrayType const& _type) length = getDynArrayLengthFromFuzz(_type.length(), counter()); lengthStr = to_string(length); if (m_stateVar) - resizeBuffer = assignAndCheckStringPair( - m_varName + ".length", - m_paramName + ".length", - lengthStr, - lengthStr, - DataType::VALUE - ); + { + // Dynamic storage arrays are resized via the empty push() operation + resizeBuffer.first = Whiskers(R"(for (uint i = 0; i < ; i++) .push();)") + ("indentation", indentation()) + ("length", lengthStr) + ("arrayRef", m_varName) + .render() + "\n"; + // Add a dynamic check on the resized length + resizeBuffer.second = checkString(m_paramName + ".length", lengthStr, DataType::VALUE); + } else { // Resizing memory arrays via the new operator From 6d068b63313b7ad409d7e3ddfe1d9ec0dc53d565 Mon Sep 17 00:00:00 2001 From: William Entriken Date: Tue, 3 Dec 2019 20:39:24 -0500 Subject: [PATCH 29/57] Reduce usage of the word "kill" --- docs/contracts/function-modifiers.rst | 2 +- docs/contracts/inheritance.rst | 56 ++++++++++++------------- docs/examples/micropayment.rst | 2 +- docs/metadata.rst | 4 +- docs/style-guide.rst | 4 +- docs/using-the-compiler.rst | 4 +- test/contracts/Wallet.cpp | 2 +- test/tools/ossfuzz/config/solidity.dict | 1 + 8 files changed, 38 insertions(+), 37 deletions(-) diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index ad2804302..785be74e9 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -39,7 +39,7 @@ if they are marked ``virtual``. For details, please see } } - contract mortal is owned { + contract retrievable is owned { // This contract inherits the `onlyOwner` modifier from // `owned` and applies it to the `close` function, which // causes that calls to `close` only have an effect if diff --git a/docs/contracts/inheritance.rst b/docs/contracts/inheritance.rst index ee766e474..cc5534a06 100644 --- a/docs/contracts/inheritance.rst +++ b/docs/contracts/inheritance.rst @@ -51,10 +51,10 @@ Details are given in the following example. // contracts can access all non-private members including // internal functions and state variables. These cannot be // accessed externally via `this`, though. - contract Mortal is Owned { + contract Temporary is Owned { // The keyword `virtual` means that the function can change // its behaviour in derived classes ("overriding"). - function kill() virtual public { + function shutdown() virtual public { if (msg.sender == owner) selfdestruct(owner); } } @@ -76,9 +76,9 @@ Details are given in the following example. // Multiple inheritance is possible. Note that `owned` is - // also a base class of `mortal`, yet there is only a single + // also a base class of `Temporary`, yet there is only a single // instance of `owned` (as for virtual inheritance in C++). - contract Named is Owned, Mortal { + contract Named is Owned, Temporary { constructor(bytes32 name) public { Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970); NameReg(config.lookup(1)).register(name); @@ -92,13 +92,13 @@ Details are given in the following example. // If you want the function to override, you need to use the // `override` keyword. You need to specify the `virtual` keyword again // if you want this function to be overridden again. - function kill() public virtual override { + function shutdown() public virtual override { if (msg.sender == owner) { Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970); NameReg(config.lookup(1)).unregister(); // It is still possible to call a specific // overridden function. - Mortal.kill(); + Temporary.shutdown(); } } } @@ -107,21 +107,21 @@ Details are given in the following example. // If a constructor takes an argument, it needs to be // provided in the header (or modifier-invocation-style at // the constructor of the derived contract (see below)). - contract PriceFeed is Owned, Mortal, Named("GoldFeed") { + contract PriceFeed is Owned, Temporary, Named("GoldFeed") { function updateInfo(uint newInfo) public { if (msg.sender == owner) info = newInfo; } // Here, we only specify `override` and not `virtual`. // This means that contracts deriving from `PriceFeed` - // cannot change the behaviour of `kill` anymore. - function kill() public override(Mortal, Named) { Named.kill(); } + // cannot change the behaviour of `shutdown` anymore. + function shutdown() public override(Temporary, Named) { Named.shutdown(); } function get() public view returns(uint r) { return info; } uint info; } -Note that above, we call ``mortal.kill()`` to "forward" the +Note that above, we call ``Temporary.shutdown()`` to "forward" the destruction request. The way this is done is problematic, as seen in the following example:: @@ -132,27 +132,27 @@ seen in the following example:: address payable owner; } - contract mortal is owned { - function kill() public virtual { + contract Temporary is owned { + function shutdown() public virtual { if (msg.sender == owner) selfdestruct(owner); } } - contract Base1 is mortal { - function kill() public virtual override { /* do cleanup 1 */ mortal.kill(); } + contract Base1 is Temporary { + function shutdown() public virtual override { /* do cleanup 1 */ Temporary.shutdown(); } } - contract Base2 is mortal { - function kill() public virtual override { /* do cleanup 2 */ mortal.kill(); } + contract Base2 is Temporary { + function shutdown() public virtual override { /* do cleanup 2 */ Temporary.shutdown(); } } contract Final is Base1, Base2 { - function kill() public override(Base1, Base2) { Base2.kill(); } + function shutdown() public override(Base1, Base2) { Base2.shutdown(); } } -A call to ``Final.kill()`` will call ``Base2.kill`` because we specify it +A call to ``Final.shutdown()`` will call ``Base2.shutdown`` because we specify it explicitly in the final override, but this function will bypass -``Base1.kill``. The way around this is to use ``super``:: +``Base1.shutdown``. The way around this is to use ``super``:: pragma solidity >=0.4.22 <0.7.0; @@ -161,31 +161,31 @@ explicitly in the final override, but this function will bypass address payable owner; } - contract mortal is owned { - function kill() virtual public { + contract Temporary is owned { + function shutdown() virtual public { if (msg.sender == owner) selfdestruct(owner); } } - contract Base1 is mortal { - function kill() public virtual override { /* do cleanup 1 */ super.kill(); } + contract Base1 is Temporary { + function shutdown() public virtual override { /* do cleanup 1 */ super.shutdown(); } } - contract Base2 is mortal { - function kill() public virtual override { /* do cleanup 2 */ super.kill(); } + contract Base2 is Temporary { + function shutdown() public virtual override { /* do cleanup 2 */ super.shutdown(); } } contract Final is Base1, Base2 { - function kill() public override(Base1, Base2) { super.kill(); } + function shutdown() public override(Base1, Base2) { super.shutdown(); } } If ``Base2`` calls a function of ``super``, it does not simply call this function on one of its base contracts. Rather, it calls this function on the next base contract in the final -inheritance graph, so it will call ``Base1.kill()`` (note that +inheritance graph, so it will call ``Base1.shutdown()`` (note that the final inheritance sequence is -- starting with the most -derived contract: Final, Base2, Base1, mortal, owned). +derived contract: Final, Base2, Base1, Temporary, owned). The actual function that is called when using super is not known in the context of the class where it is used, although its type is known. This is similar for ordinary diff --git a/docs/examples/micropayment.rst b/docs/examples/micropayment.rst index f675586dd..fe310f37a 100644 --- a/docs/examples/micropayment.rst +++ b/docs/examples/micropayment.rst @@ -164,7 +164,7 @@ The full contract } /// destroy the contract and reclaim the leftover funds. - function kill() public { + function shutdown() public { require(msg.sender == owner); selfdestruct(msg.sender); } diff --git a/docs/metadata.rst b/docs/metadata.rst index f7d16b23a..3660ce69a 100644 --- a/docs/metadata.rst +++ b/docs/metadata.rst @@ -56,11 +56,11 @@ explanatory purposes. // Swarm URL is recommended "urls": [ "bzzr://56ab..." ] }, - "mortal": { + "retrievable": { // Required: keccak256 hash of the source file "keccak256": "0x234...", // Required (unless "url" is used): literal contents of the source file - "content": "contract mortal is owned { function kill() { if (msg.sender == owner) selfdestruct(owner); } }" + "content": "contract retrievable is owned { function shutdown() { if (msg.sender == owner) selfdestruct(owner); } }" } }, // Required: Compiler settings diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 84602542f..11ddaef07 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -584,7 +584,7 @@ Yes:: return balanceOf[from]; } - function kill() public onlyowner { + function shutdown() public onlyowner { selfdestruct(owner); } @@ -594,7 +594,7 @@ No:: return balanceOf[from]; } - function kill() onlyowner public { + function shutdown() onlyowner public { selfdestruct(owner); } diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index f323d0c61..30b00bae0 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -180,12 +180,12 @@ Input Description // `--allow-paths `. ] }, - "mortal": + "retrievable": { // Optional: keccak256 hash of the source file "keccak256": "0x234...", // Required (unless "urls" is used): literal contents of the source file - "content": "contract mortal is owned { function kill() { if (msg.sender == owner) selfdestruct(owner); } }" + "content": "contract retrievable is owned { function shutdown() { if (msg.sender == owner) selfdestruct(owner); } }" } }, // Optional diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index 25b81d4d9..b71e6555c 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -378,7 +378,7 @@ contract Wallet is multisig, multiowned, daylimit { multiowned.changeOwner(_from, _to); } // destroys the contract sending everything to `_to`. - function kill(address payable _to) onlymanyowners(keccak256(msg.data)) external { + function shutdown(address payable _to) onlymanyowners(keccak256(msg.data)) external { selfdestruct(_to); } diff --git a/test/tools/ossfuzz/config/solidity.dict b/test/tools/ossfuzz/config/solidity.dict index 5ff5318e4..9fe773870 100644 --- a/test/tools/ossfuzz/config/solidity.dict +++ b/test/tools/ossfuzz/config/solidity.dict @@ -41,6 +41,7 @@ ".delegatecall(" ".gas(" ".kill(" +".shutdown(" ".length" ".pop();" ".push(" From 529405deb69a378f5cd4e5326f9109b99a0b94b8 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Tue, 7 Jan 2020 09:11:29 -0500 Subject: [PATCH 30/57] Move ContractKind from ContractDefinition to file-scope --- libsolidity/analysis/ContractLevelChecker.cpp | 8 ++++---- libsolidity/analysis/TypeChecker.cpp | 8 ++++---- libsolidity/analysis/ViewPureChecker.cpp | 2 +- libsolidity/ast/AST.cpp | 2 +- libsolidity/ast/AST.h | 4 +--- libsolidity/ast/ASTEnums.h | 2 ++ libsolidity/ast/ASTJsonConverter.cpp | 8 ++++---- libsolidity/ast/ASTJsonConverter.h | 2 +- libsolidity/parsing/Parser.cpp | 12 ++++++------ libsolidity/parsing/Parser.h | 4 ++-- test/libsolidity/SolidityTypes.cpp | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index 069bd4d94..47eededb4 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -208,18 +208,18 @@ void ContractLevelChecker::checkAbstractFunctions(ContractDefinition const& _con if (_contract.abstract()) { - if (_contract.contractKind() == ContractDefinition::ContractKind::Interface) + if (_contract.contractKind() == ContractKind::Interface) m_errorReporter.typeError(_contract.location(), "Interfaces do not need the \"abstract\" keyword, they are abstract implicitly."); - else if (_contract.contractKind() == ContractDefinition::ContractKind::Library) + else if (_contract.contractKind() == ContractKind::Library) m_errorReporter.typeError(_contract.location(), "Libraries cannot be abstract."); else - solAssert(_contract.contractKind() == ContractDefinition::ContractKind::Contract, ""); + solAssert(_contract.contractKind() == ContractKind::Contract, ""); } // For libraries, we emit errors on function-level, so this is fine as long as we do // not have inheritance for libraries. if ( - _contract.contractKind() == ContractDefinition::ContractKind::Contract && + _contract.contractKind() == ContractKind::Contract && !_contract.abstract() && !_contract.annotation().unimplementedFunctions.empty() ) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 26f473ee1..fc4e76dcc 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -326,7 +326,7 @@ bool TypeChecker::visit(StructDefinition const& _struct) bool TypeChecker::visit(FunctionDefinition const& _function) { - bool isLibraryFunction = _function.inContractKind() == ContractDefinition::ContractKind::Library; + bool isLibraryFunction = _function.inContractKind() == ContractKind::Library; if (_function.markedVirtual()) { @@ -425,7 +425,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function) if (_function.isConstructor()) m_errorReporter.typeError(_function.location(), "Constructor cannot be defined in interfaces."); } - else if (m_scope->contractKind() == ContractDefinition::ContractKind::Library) + else if (m_scope->contractKind() == ContractKind::Library) if (_function.isConstructor()) m_errorReporter.typeError(_function.location(), "Constructor cannot be defined in libraries."); if (_function.isImplemented()) @@ -1733,7 +1733,7 @@ void TypeChecker::typeCheckFallbackFunction(FunctionDefinition const& _function) { solAssert(_function.isFallback(), ""); - if (_function.inContractKind() == ContractDefinition::ContractKind::Library) + if (_function.inContractKind() == ContractKind::Library) m_errorReporter.typeError(_function.location(), "Libraries cannot have fallback functions."); if (_function.stateMutability() != StateMutability::NonPayable && _function.stateMutability() != StateMutability::Payable) m_errorReporter.typeError( @@ -1759,7 +1759,7 @@ void TypeChecker::typeCheckReceiveFunction(FunctionDefinition const& _function) { solAssert(_function.isReceive(), ""); - if (_function.inContractKind() == ContractDefinition::ContractKind::Library) + if (_function.inContractKind() == ContractKind::Library) m_errorReporter.typeError(_function.location(), "Libraries cannot have receive ether functions."); if (_function.stateMutability() != StateMutability::Payable) diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 4da77ead7..b58863c54 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -272,7 +272,7 @@ void ViewPureChecker::reportMutability( { // We do not warn for library functions because they cannot be payable anyway. // Also internal functions should be allowed to use `msg.value`. - if (m_currentFunction->isPublic() && m_currentFunction->inContractKind() != ContractDefinition::ContractKind::Library) + if (m_currentFunction->isPublic() && m_currentFunction->inContractKind() != ContractKind::Library) { if (_nestedLocation) m_errorReporter.typeError( diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index a7d5e73ca..6d7ea76fd 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -305,7 +305,7 @@ TypeDeclarationAnnotation& EnumDefinition::annotation() const return dynamic_cast(*m_annotation); } -ContractDefinition::ContractKind FunctionDefinition::inContractKind() const +ContractKind FunctionDefinition::inContractKind() const { auto contractDef = dynamic_cast(scope()); solAssert(contractDef, "Enclosing Scope of FunctionDefinition was not set."); diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index f687f20c9..9100d1dfc 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -378,8 +378,6 @@ protected: class ContractDefinition: public Declaration, public Documented { public: - enum class ContractKind { Interface, Contract, Library }; - ContractDefinition( SourceLocation const& _location, ASTPointer const& _name, @@ -711,7 +709,7 @@ public: /// @returns the external identifier of this function (the hash of the signature) as a hex string. std::string externalIdentifierHex() const; - ContractDefinition::ContractKind inContractKind() const; + ContractKind inContractKind() const; TypePointer type() const override; diff --git a/libsolidity/ast/ASTEnums.h b/libsolidity/ast/ASTEnums.h index 3ad329498..cbb8f9cd7 100644 --- a/libsolidity/ast/ASTEnums.h +++ b/libsolidity/ast/ASTEnums.h @@ -69,5 +69,7 @@ struct FuncCallArguments bool hasNamedArguments() const { return !names.empty(); } }; +enum class ContractKind { Interface, Contract, Library }; + } } diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index b7b8e9cbc..bfaeacf41 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -834,15 +834,15 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location) return {}; } -string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind) +string ASTJsonConverter::contractKind(ContractKind _kind) { switch (_kind) { - case ContractDefinition::ContractKind::Interface: + case ContractKind::Interface: return "interface"; - case ContractDefinition::ContractKind::Contract: + case ContractKind::Contract: return "contract"; - case ContractDefinition::ContractKind::Library: + case ContractKind::Library: return "library"; } diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index 10cc5581d..55abc32cd 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -147,7 +147,7 @@ private: } Json::Value inlineAssemblyIdentifierToJson(std::pair _info) const; static std::string location(VariableDeclaration::Location _location); - static std::string contractKind(ContractDefinition::ContractKind _kind); + static std::string contractKind(ContractKind _kind); static std::string functionCallKind(FunctionCallKind _kind); static std::string literalTokenKind(Token _token); static std::string type(Expression const& _expression); diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 881bd3cab..335b09f61 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -245,9 +245,9 @@ ASTPointer Parser::parseImportDirective() return nodeFactory.createNode(path, unitAlias, move(symbolAliases)); } -std::pair Parser::parseContractKind() +std::pair Parser::parseContractKind() { - ContractDefinition::ContractKind kind; + ContractKind kind; bool abstract = false; if (m_scanner->currentToken() == Token::Abstract) { @@ -257,13 +257,13 @@ std::pair Parser::parseContractKind() switch (m_scanner->currentToken()) { case Token::Interface: - kind = ContractDefinition::ContractKind::Interface; + kind = ContractKind::Interface; break; case Token::Contract: - kind = ContractDefinition::ContractKind::Contract; + kind = ContractKind::Contract; break; case Token::Library: - kind = ContractDefinition::ContractKind::Library; + kind = ContractKind::Library; break; default: solAssert(false, "Invalid contract kind."); @@ -280,7 +280,7 @@ ASTPointer Parser::parseContractDefinition() ASTPointer docString; vector> baseContracts; vector> subNodes; - std::pair contractKind{}; + std::pair contractKind{}; try { if (m_scanner->currentCommentLiteral() != "") diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index f9b6197b4..fe8085659 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -84,9 +84,9 @@ private: void parsePragmaVersion(langutil::SourceLocation const& _location, std::vector const& _tokens, std::vector const& _literals); ASTPointer parsePragmaDirective(); ASTPointer parseImportDirective(); - /// @returns an std::pair, where + /// @returns an std::pair, where /// result.second is set to true, if an abstract contract was parsed, false otherwise. - std::pair parseContractKind(); + std::pair parseContractKind(); ASTPointer parseContractDefinition(); ASTPointer parseInheritanceSpecifier(); Visibility parseVisibilitySpecifier(); diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp index 419ac5606..b50ae00fc 100644 --- a/test/libsolidity/SolidityTypes.cpp +++ b/test/libsolidity/SolidityTypes.cpp @@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(type_identifiers) TypePointer multiArray = TypeProvider::array(DataLocation::Storage, stringArray); BOOST_CHECK_EQUAL(multiArray->identifier(), "t_array$_t_array$_t_string_storage_$20_storage_$dyn_storage_ptr"); - ContractDefinition c(SourceLocation{}, make_shared("MyContract$"), {}, {}, {}, ContractDefinition::ContractKind::Contract); + ContractDefinition c(SourceLocation{}, make_shared("MyContract$"), {}, {}, {}, ContractKind::Contract); BOOST_CHECK_EQUAL(c.type()->identifier(), "t_type$_t_contract$_MyContract$$$_$2_$"); BOOST_CHECK_EQUAL(ContractType(c, true).identifier(), "t_super$_MyContract$$$_$2"); From 6b23412faec31ea5f0b0f2fe0db79b0adaaa0279 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 11 Dec 2019 17:31:36 +0100 Subject: [PATCH 31/57] C++ namespace cleanup (except tests). --- libdevcore/Algorithms.h | 2 +- libdevcore/AnsiColorized.h | 2 +- libdevcore/Assertions.h | 4 +- libdevcore/Common.h | 6 +- libdevcore/CommonData.cpp | 23 ++-- libdevcore/CommonData.h | 2 +- libdevcore/CommonIO.cpp | 12 +- libdevcore/CommonIO.h | 2 +- libdevcore/Exceptions.cpp | 2 +- libdevcore/Exceptions.h | 4 +- libdevcore/FixedHash.h | 4 +- libdevcore/IndentedWriter.cpp | 2 +- libdevcore/IndentedWriter.h | 2 +- libdevcore/IpfsHash.cpp | 7 +- libdevcore/IpfsHash.h | 2 +- libdevcore/JSON.cpp | 4 +- libdevcore/JSON.h | 2 +- libdevcore/Keccak256.cpp | 3 +- libdevcore/Keccak256.h | 2 +- libdevcore/Result.h | 2 +- libdevcore/StringUtils.cpp | 10 +- libdevcore/StringUtils.h | 2 +- libdevcore/SwarmHash.cpp | 7 +- libdevcore/SwarmHash.h | 2 +- libdevcore/UTF8.cpp | 2 +- libdevcore/UTF8.h | 2 +- libdevcore/Visitor.h | 2 +- libdevcore/Whiskers.cpp | 2 +- libdevcore/Whiskers.h | 2 +- libdevcore/vector_ref.h | 2 +- libevmasm/Assembly.cpp | 29 ++--- libevmasm/Assembly.h | 19 ++- libevmasm/AssemblyItem.cpp | 26 ++-- libevmasm/AssemblyItem.h | 15 +-- libevmasm/BlockDeduplicator.cpp | 4 +- libevmasm/BlockDeduplicator.h | 5 +- libevmasm/CommonSubexpressionEliminator.cpp | 6 +- libevmasm/CommonSubexpressionEliminator.h | 5 +- libevmasm/ConstantOptimiser.cpp | 16 +-- libevmasm/ConstantOptimiser.h | 5 +- libevmasm/ControlFlowGraph.cpp | 4 +- libevmasm/ControlFlowGraph.h | 5 +- libevmasm/Exceptions.h | 7 +- libevmasm/ExpressionClasses.cpp | 6 +- libevmasm/ExpressionClasses.h | 7 +- libevmasm/GasMeter.cpp | 5 +- libevmasm/GasMeter.h | 5 +- libevmasm/Instruction.cpp | 15 +-- libevmasm/Instruction.h | 5 +- libevmasm/JumpdestRemover.cpp | 6 +- libevmasm/JumpdestRemover.h | 5 +- libevmasm/KnownState.cpp | 10 +- libevmasm/KnownState.h | 7 +- libevmasm/LinkerObject.cpp | 7 +- libevmasm/LinkerObject.h | 11 +- libevmasm/PathGasMeter.cpp | 4 +- libevmasm/PathGasMeter.h | 5 +- libevmasm/PeepholeOptimiser.cpp | 6 +- libevmasm/PeepholeOptimiser.h | 5 +- libevmasm/RuleList.h | 5 +- libevmasm/SemanticInformation.cpp | 8 +- libevmasm/SemanticInformation.h | 5 +- libevmasm/SimplificationRule.h | 5 +- libevmasm/SimplificationRules.cpp | 6 +- libevmasm/SimplificationRules.h | 9 +- liblangutil/CharStream.cpp | 3 +- liblangutil/CharStream.h | 2 +- liblangutil/Common.h | 2 +- liblangutil/EVMVersion.cpp | 5 +- liblangutil/EVMVersion.h | 4 +- liblangutil/ErrorReporter.cpp | 12 +- liblangutil/ErrorReporter.h | 4 +- liblangutil/Exceptions.cpp | 8 +- liblangutil/Exceptions.h | 16 +-- liblangutil/ParserBase.cpp | 3 +- liblangutil/ParserBase.h | 2 +- liblangutil/Scanner.cpp | 14 +-- liblangutil/Scanner.h | 2 +- liblangutil/SemVerHandler.cpp | 4 +- liblangutil/SemVerHandler.h | 4 +- liblangutil/SourceLocation.h | 4 +- liblangutil/SourceReferenceExtractor.cpp | 8 +- liblangutil/SourceReferenceExtractor.h | 6 +- liblangutil/SourceReferenceFormatter.cpp | 7 +- liblangutil/SourceReferenceFormatter.h | 8 +- liblangutil/SourceReferenceFormatterHuman.cpp | 7 +- liblangutil/SourceReferenceFormatterHuman.h | 20 ++-- liblangutil/Token.cpp | 3 +- liblangutil/Token.h | 2 +- liblll/CodeFragment.cpp | 4 +- liblll/CodeFragment.h | 4 +- libsolc/libsolc.cpp | 7 +- libsolidity/analysis/ConstantEvaluator.cpp | 4 +- libsolidity/analysis/ConstantEvaluator.h | 7 +- libsolidity/analysis/ContractLevelChecker.cpp | 10 +- libsolidity/analysis/ContractLevelChecker.h | 7 +- libsolidity/analysis/ControlFlowAnalyzer.cpp | 8 +- libsolidity/analysis/ControlFlowAnalyzer.h | 5 +- libsolidity/analysis/ControlFlowBuilder.cpp | 4 +- libsolidity/analysis/ControlFlowBuilder.h | 4 +- libsolidity/analysis/ControlFlowGraph.cpp | 4 +- libsolidity/analysis/ControlFlowGraph.h | 5 +- libsolidity/analysis/DeclarationContainer.cpp | 10 +- libsolidity/analysis/DeclarationContainer.h | 5 +- libsolidity/analysis/DocStringAnalyser.cpp | 6 +- libsolidity/analysis/DocStringAnalyser.h | 7 +- libsolidity/analysis/GlobalContext.cpp | 5 +- libsolidity/analysis/GlobalContext.h | 5 +- libsolidity/analysis/NameAndTypeResolver.cpp | 11 +- libsolidity/analysis/NameAndTypeResolver.h | 7 +- libsolidity/analysis/OverrideChecker.cpp | 10 +- libsolidity/analysis/OverrideChecker.h | 7 +- libsolidity/analysis/PostTypeChecker.cpp | 10 +- libsolidity/analysis/PostTypeChecker.h | 7 +- libsolidity/analysis/ReferencesResolver.cpp | 9 +- libsolidity/analysis/ReferencesResolver.h | 7 +- libsolidity/analysis/StaticAnalyzer.cpp | 8 +- libsolidity/analysis/StaticAnalyzer.h | 7 +- libsolidity/analysis/SyntaxChecker.cpp | 6 +- libsolidity/analysis/SyntaxChecker.h | 7 +- libsolidity/analysis/TypeChecker.cpp | 7 +- libsolidity/analysis/TypeChecker.h | 7 +- libsolidity/analysis/ViewPureChecker.cpp | 12 +- libsolidity/analysis/ViewPureChecker.h | 7 +- libsolidity/ast/AST.cpp | 18 +-- libsolidity/ast/AST.h | 14 +-- libsolidity/ast/ASTAnnotations.cpp | 4 +- libsolidity/ast/ASTAnnotations.h | 7 +- libsolidity/ast/ASTEnums.h | 5 +- libsolidity/ast/ASTForward.h | 7 +- libsolidity/ast/ASTJsonConverter.cpp | 23 ++-- libsolidity/ast/ASTJsonConverter.h | 7 +- libsolidity/ast/ASTUtils.cpp | 5 +- libsolidity/ast/ASTUtils.h | 7 +- libsolidity/ast/ASTVisitor.h | 5 +- libsolidity/ast/AST_accept.h | 5 +- libsolidity/ast/ExperimentalFeatures.h | 5 +- libsolidity/ast/TypeProvider.cpp | 3 +- libsolidity/ast/TypeProvider.h | 7 +- libsolidity/ast/Types.cpp | 54 ++++----- libsolidity/ast/Types.h | 15 +-- libsolidity/codegen/ABIFunctions.cpp | 5 +- libsolidity/codegen/ABIFunctions.h | 5 +- libsolidity/codegen/ArrayUtils.cpp | 48 ++++---- libsolidity/codegen/ArrayUtils.h | 5 +- libsolidity/codegen/Compiler.cpp | 8 +- libsolidity/codegen/Compiler.h | 20 ++-- libsolidity/codegen/CompilerContext.cpp | 46 +++---- libsolidity/codegen/CompilerContext.h | 64 +++++----- libsolidity/codegen/CompilerUtils.cpp | 20 ++-- libsolidity/codegen/CompilerUtils.h | 6 +- libsolidity/codegen/ContractCompiler.cpp | 64 +++++----- libsolidity/codegen/ContractCompiler.h | 18 ++- libsolidity/codegen/ExpressionCompiler.cpp | 39 +++--- libsolidity/codegen/ExpressionCompiler.h | 7 +- libsolidity/codegen/LValue.cpp | 9 +- libsolidity/codegen/LValue.h | 5 +- .../codegen/MultiUseYulFunctionCollector.cpp | 4 +- .../codegen/MultiUseYulFunctionCollector.h | 5 +- libsolidity/codegen/YulUtilFunctions.cpp | 7 +- libsolidity/codegen/YulUtilFunctions.h | 5 +- .../codegen/ir/IRGenerationContext.cpp | 5 +- libsolidity/codegen/ir/IRGenerationContext.h | 5 +- libsolidity/codegen/ir/IRGenerator.cpp | 5 +- libsolidity/codegen/ir/IRGenerator.h | 5 +- .../codegen/ir/IRGeneratorForStatements.cpp | 20 ++-- .../codegen/ir/IRGeneratorForStatements.h | 5 +- libsolidity/codegen/ir/IRLValue.cpp | 6 +- libsolidity/codegen/ir/IRLValue.h | 5 +- libsolidity/formal/BMC.cpp | 7 +- libsolidity/formal/BMC.h | 9 +- libsolidity/formal/CHC.cpp | 8 +- libsolidity/formal/CHC.h | 7 +- libsolidity/formal/CHCSmtLib2Interface.cpp | 9 +- libsolidity/formal/CHCSmtLib2Interface.h | 12 +- libsolidity/formal/CHCSolverInterface.h | 8 +- libsolidity/formal/CVC4Interface.cpp | 5 +- libsolidity/formal/CVC4Interface.h | 8 +- libsolidity/formal/EncodingContext.cpp | 33 +++--- libsolidity/formal/EncodingContext.h | 42 +++---- libsolidity/formal/ModelChecker.cpp | 7 +- libsolidity/formal/ModelChecker.h | 7 +- libsolidity/formal/SMTEncoder.cpp | 7 +- libsolidity/formal/SMTEncoder.h | 7 +- libsolidity/formal/SMTLib2Interface.cpp | 9 +- libsolidity/formal/SMTLib2Interface.h | 12 +- libsolidity/formal/SMTPortfolio.cpp | 7 +- libsolidity/formal/SMTPortfolio.h | 10 +- libsolidity/formal/SSAVariable.cpp | 3 +- libsolidity/formal/SSAVariable.h | 8 +- libsolidity/formal/SolverInterface.h | 12 +- libsolidity/formal/SymbolicTypes.cpp | 112 +++++++++--------- libsolidity/formal/SymbolicTypes.h | 62 +++++----- libsolidity/formal/SymbolicVariables.cpp | 61 +++++----- libsolidity/formal/SymbolicVariables.h | 46 ++++--- libsolidity/formal/VariableUsage.cpp | 7 +- libsolidity/formal/VariableUsage.h | 8 +- libsolidity/formal/Z3CHCInterface.cpp | 4 +- libsolidity/formal/Z3CHCInterface.h | 8 +- libsolidity/formal/Z3Interface.cpp | 5 +- libsolidity/formal/Z3Interface.h | 8 +- libsolidity/interface/ABI.cpp | 4 +- libsolidity/interface/ABI.h | 5 +- libsolidity/interface/CompilerStack.cpp | 71 +++++------ libsolidity/interface/CompilerStack.h | 43 ++++--- libsolidity/interface/DebugSettings.h | 5 +- libsolidity/interface/GasEstimator.cpp | 10 +- libsolidity/interface/GasEstimator.h | 13 +- libsolidity/interface/Natspec.cpp | 4 +- libsolidity/interface/Natspec.h | 7 +- libsolidity/interface/OptimiserSettings.h | 5 +- libsolidity/interface/ReadFile.h | 6 +- libsolidity/interface/StandardCompiler.cpp | 42 +++---- libsolidity/interface/StandardCompiler.h | 10 +- libsolidity/interface/StorageLayout.cpp | 4 +- libsolidity/interface/StorageLayout.h | 5 +- libsolidity/interface/Version.cpp | 16 ++- libsolidity/interface/Version.h | 5 +- libsolidity/parsing/DocStringParser.cpp | 6 +- libsolidity/parsing/DocStringParser.h | 9 +- libsolidity/parsing/Parser.cpp | 7 +- libsolidity/parsing/Parser.h | 7 +- libsolidity/parsing/Token.h | 11 +- libyul/AsmAnalysis.cpp | 36 +++--- libyul/AsmAnalysis.h | 6 +- libyul/AsmAnalysisInfo.h | 2 +- libyul/AsmData.h | 2 +- libyul/AsmDataForward.h | 2 +- libyul/AsmJsonConverter.cpp | 4 +- libyul/AsmJsonConverter.h | 2 +- libyul/AsmParser.cpp | 25 ++-- libyul/AsmParser.h | 6 +- libyul/AsmPrinter.cpp | 5 +- libyul/AsmPrinter.h | 2 +- libyul/AsmScope.cpp | 5 +- libyul/AsmScope.h | 2 +- libyul/AsmScopeFiller.cpp | 7 +- libyul/AsmScopeFiller.h | 4 +- libyul/AssemblyStack.cpp | 13 +- libyul/AssemblyStack.h | 12 +- libyul/CompilabilityChecker.cpp | 5 +- libyul/CompilabilityChecker.h | 2 +- libyul/Dialect.h | 2 +- libyul/Exceptions.h | 6 +- libyul/Object.cpp | 7 +- libyul/Object.h | 6 +- libyul/ObjectParser.cpp | 8 +- libyul/ObjectParser.h | 4 +- libyul/SideEffects.h | 2 +- libyul/Utilities.cpp | 13 +- libyul/Utilities.h | 10 +- libyul/YulString.h | 2 +- libyul/backends/evm/AbstractAssembly.h | 15 +-- libyul/backends/evm/AsmCodeGen.cpp | 29 ++--- libyul/backends/evm/AsmCodeGen.h | 23 ++-- libyul/backends/evm/ConstantOptimiser.cpp | 27 +++-- libyul/backends/evm/ConstantOptimiser.h | 14 +-- libyul/backends/evm/EVMAssembly.cpp | 36 +++--- libyul/backends/evm/EVMAssembly.h | 16 +-- libyul/backends/evm/EVMCodeTransform.cpp | 41 +++---- libyul/backends/evm/EVMCodeTransform.h | 4 +- libyul/backends/evm/EVMDialect.cpp | 33 +++--- libyul/backends/evm/EVMDialect.h | 6 +- libyul/backends/evm/EVMMetrics.cpp | 27 +++-- libyul/backends/evm/EVMMetrics.h | 8 +- libyul/backends/evm/EVMObjectCompiler.cpp | 2 +- libyul/backends/evm/EVMObjectCompiler.h | 2 +- libyul/backends/evm/NoOutputAssembly.cpp | 27 +++-- libyul/backends/evm/NoOutputAssembly.h | 10 +- libyul/backends/wasm/BinaryTransform.cpp | 7 +- libyul/backends/wasm/BinaryTransform.h | 60 +++++----- libyul/backends/wasm/EVMToEwasmTranslator.cpp | 7 +- libyul/backends/wasm/EVMToEwasmTranslator.h | 2 +- libyul/backends/wasm/TextTransform.cpp | 7 +- libyul/backends/wasm/TextTransform.h | 6 +- libyul/backends/wasm/WasmAST.h | 5 +- libyul/backends/wasm/WasmCodeTransform.cpp | 5 +- libyul/backends/wasm/WasmCodeTransform.h | 2 +- libyul/backends/wasm/WasmDialect.cpp | 2 +- libyul/backends/wasm/WasmDialect.h | 2 +- libyul/backends/wasm/WasmObjectCompiler.cpp | 5 +- libyul/backends/wasm/WasmObjectCompiler.h | 10 +- libyul/backends/wasm/WordSizeTransform.cpp | 5 +- libyul/backends/wasm/WordSizeTransform.h | 2 +- libyul/optimiser/ASTCopier.cpp | 5 +- libyul/optimiser/ASTCopier.h | 2 +- libyul/optimiser/ASTWalker.cpp | 5 +- libyul/optimiser/ASTWalker.h | 2 +- libyul/optimiser/BlockFlattener.cpp | 5 +- libyul/optimiser/BlockFlattener.h | 2 +- libyul/optimiser/BlockHasher.cpp | 5 +- libyul/optimiser/BlockHasher.h | 2 +- libyul/optimiser/CallGraphGenerator.cpp | 5 +- libyul/optimiser/CallGraphGenerator.h | 2 +- .../CommonSubexpressionEliminator.cpp | 5 +- .../optimiser/CommonSubexpressionEliminator.h | 2 +- libyul/optimiser/ConditionalSimplifier.cpp | 5 +- libyul/optimiser/ConditionalSimplifier.h | 2 +- libyul/optimiser/ConditionalUnsimplifier.cpp | 5 +- libyul/optimiser/ConditionalUnsimplifier.h | 2 +- libyul/optimiser/ControlFlowSimplifier.cpp | 5 +- libyul/optimiser/ControlFlowSimplifier.h | 2 +- libyul/optimiser/DataFlowAnalyzer.cpp | 15 +-- libyul/optimiser/DataFlowAnalyzer.h | 4 +- libyul/optimiser/DeadCodeEliminator.cpp | 6 +- libyul/optimiser/DeadCodeEliminator.h | 2 +- libyul/optimiser/Disambiguator.cpp | 5 +- libyul/optimiser/Disambiguator.h | 2 +- .../optimiser/EquivalentFunctionCombiner.cpp | 4 +- libyul/optimiser/EquivalentFunctionCombiner.h | 2 +- .../optimiser/EquivalentFunctionDetector.cpp | 4 +- libyul/optimiser/EquivalentFunctionDetector.h | 2 +- libyul/optimiser/ExpressionInliner.cpp | 4 +- libyul/optimiser/ExpressionInliner.h | 2 +- libyul/optimiser/ExpressionJoiner.cpp | 4 +- libyul/optimiser/ExpressionJoiner.h | 2 +- libyul/optimiser/ExpressionSimplifier.cpp | 4 +- libyul/optimiser/ExpressionSimplifier.h | 2 +- libyul/optimiser/ExpressionSplitter.cpp | 7 +- libyul/optimiser/ExpressionSplitter.h | 2 +- libyul/optimiser/ForLoopConditionIntoBody.cpp | 8 +- libyul/optimiser/ForLoopConditionIntoBody.h | 2 +- .../optimiser/ForLoopConditionOutOfBody.cpp | 6 +- libyul/optimiser/ForLoopConditionOutOfBody.h | 2 +- libyul/optimiser/ForLoopInitRewriter.cpp | 6 +- libyul/optimiser/ForLoopInitRewriter.h | 2 +- libyul/optimiser/FullInliner.cpp | 18 +-- libyul/optimiser/FullInliner.h | 2 +- libyul/optimiser/FunctionGrouper.cpp | 4 +- libyul/optimiser/FunctionGrouper.h | 2 +- libyul/optimiser/FunctionHoister.cpp | 4 +- libyul/optimiser/FunctionHoister.h | 2 +- .../InlinableExpressionFunctionFinder.cpp | 4 +- .../InlinableExpressionFunctionFinder.h | 2 +- libyul/optimiser/KnowledgeBase.cpp | 12 +- libyul/optimiser/KnowledgeBase.h | 2 +- libyul/optimiser/LoadResolver.cpp | 10 +- libyul/optimiser/LoadResolver.h | 4 +- libyul/optimiser/LoopInvariantCodeMotion.cpp | 8 +- libyul/optimiser/LoopInvariantCodeMotion.h | 2 +- libyul/optimiser/MainFunction.cpp | 4 +- libyul/optimiser/MainFunction.h | 2 +- libyul/optimiser/Metrics.cpp | 13 +- libyul/optimiser/Metrics.h | 4 +- libyul/optimiser/NameCollector.cpp | 5 +- libyul/optimiser/NameCollector.h | 2 +- libyul/optimiser/NameDispenser.cpp | 5 +- libyul/optimiser/NameDispenser.h | 2 +- libyul/optimiser/NameDisplacer.cpp | 4 +- libyul/optimiser/NameDisplacer.h | 2 +- libyul/optimiser/OptimiserStep.h | 2 +- libyul/optimiser/OptimizerUtilities.cpp | 4 +- libyul/optimiser/OptimizerUtilities.h | 2 +- .../optimiser/RedundantAssignEliminator.cpp | 4 +- libyul/optimiser/RedundantAssignEliminator.h | 2 +- libyul/optimiser/Rematerialiser.cpp | 4 +- libyul/optimiser/Rematerialiser.h | 2 +- libyul/optimiser/SSAReverser.cpp | 12 +- libyul/optimiser/SSAReverser.h | 2 +- libyul/optimiser/SSATransform.cpp | 10 +- libyul/optimiser/SSATransform.h | 2 +- libyul/optimiser/SSAValueTracker.cpp | 4 +- libyul/optimiser/SSAValueTracker.h | 2 +- libyul/optimiser/Semantics.cpp | 12 +- libyul/optimiser/Semantics.h | 2 +- libyul/optimiser/SimplificationRules.cpp | 19 ++- libyul/optimiser/SimplificationRules.h | 34 +++--- libyul/optimiser/StackCompressor.cpp | 4 +- libyul/optimiser/StackCompressor.h | 2 +- libyul/optimiser/StructuralSimplifier.cpp | 14 +-- libyul/optimiser/StructuralSimplifier.h | 4 +- libyul/optimiser/Substitution.cpp | 4 +- libyul/optimiser/Substitution.h | 2 +- libyul/optimiser/Suite.cpp | 6 +- libyul/optimiser/Suite.h | 2 +- libyul/optimiser/SyntacticalEquality.cpp | 18 +-- libyul/optimiser/SyntacticalEquality.h | 2 +- libyul/optimiser/UnusedPruner.cpp | 4 +- libyul/optimiser/UnusedPruner.h | 2 +- libyul/optimiser/VarDeclInitializer.cpp | 10 +- libyul/optimiser/VarDeclInitializer.h | 2 +- libyul/optimiser/VarNameCleaner.cpp | 2 +- libyul/optimiser/VarNameCleaner.h | 2 +- lllc/main.cpp | 2 +- solc/CommandLineInterface.cpp | 52 ++++---- solc/CommandLineInterface.h | 13 +- solc/main.cpp | 2 +- test/EVMHost.cpp | 6 +- test/libevmasm/Assembler.cpp | 2 +- test/libevmasm/Optimiser.cpp | 20 ++-- test/libsolidity/Assembly.cpp | 2 +- test/libsolidity/GasMeter.cpp | 2 +- .../SolidityExecutionFramework.cpp | 2 +- .../SolidityExpressionCompiler.cpp | 2 +- test/libsolidity/SolidityOptimizer.cpp | 2 +- test/libyul/ObjectCompilerTest.cpp | 2 +- test/libyul/StackReuseCodegen.cpp | 2 +- test/tools/ossfuzz/abiV2FuzzerCommon.cpp | 2 +- test/tools/ossfuzz/abiV2ProtoFuzzer.cpp | 2 +- .../EVMInstructionInterpreter.cpp | 8 +- .../EVMInstructionInterpreter.h | 9 +- .../EwasmBuiltinInterpreter.cpp | 24 ++-- .../yulInterpreter/EwasmBuiltinInterpreter.h | 2 +- 403 files changed, 1656 insertions(+), 1926 deletions(-) diff --git a/libdevcore/Algorithms.h b/libdevcore/Algorithms.h index b39939928..b9028f19b 100644 --- a/libdevcore/Algorithms.h +++ b/libdevcore/Algorithms.h @@ -20,7 +20,7 @@ #include #include -namespace dev +namespace solidity::util { /** diff --git a/libdevcore/AnsiColorized.h b/libdevcore/AnsiColorized.h index 0ee54ab0a..4f7ea577b 100644 --- a/libdevcore/AnsiColorized.h +++ b/libdevcore/AnsiColorized.h @@ -20,7 +20,7 @@ #include #include -namespace dev +namespace solidity::util { namespace formatting diff --git a/libdevcore/Assertions.h b/libdevcore/Assertions.h index 4e427fc7e..f74991651 100644 --- a/libdevcore/Assertions.h +++ b/libdevcore/Assertions.h @@ -26,7 +26,7 @@ #include -namespace dev +namespace solidity::util { #if defined(_MSC_VER) @@ -46,7 +46,7 @@ namespace dev if (!(_condition)) \ ::boost::throw_exception( \ _ExceptionType() << \ - ::dev::errinfo_comment(_description) << \ + ::solidity::util::errinfo_comment(_description) << \ ::boost::throw_function(ETH_FUNC) << \ ::boost::throw_file(__FILE__) << \ ::boost::throw_line(__LINE__) \ diff --git a/libdevcore/Common.h b/libdevcore/Common.h index 3ce116da9..4075ce153 100644 --- a/libdevcore/Common.h +++ b/libdevcore/Common.h @@ -51,13 +51,13 @@ #include #include -namespace dev +namespace solidity { // Binary data types. using bytes = std::vector; -using bytesRef = vector_ref; -using bytesConstRef = vector_ref; +using bytesRef = util::vector_ref; +using bytesConstRef = util::vector_ref; // Numeric types. using bigint = boost::multiprecision::number>; diff --git a/libdevcore/CommonData.cpp b/libdevcore/CommonData.cpp index b151ba604..d6104861b 100644 --- a/libdevcore/CommonData.cpp +++ b/libdevcore/CommonData.cpp @@ -28,7 +28,8 @@ #include using namespace std; -using namespace dev; +using namespace solidity; +using namespace solidity::util; namespace { @@ -38,7 +39,7 @@ static char const* lowerHexChars = "0123456789abcdef"; } -string dev::toHex(uint8_t _data, HexCase _case) +string solidity::util::toHex(uint8_t _data, HexCase _case) { assertThrow(_case != HexCase::Mixed, BadHexCase, "Mixed case can only be used for byte arrays."); @@ -50,7 +51,7 @@ string dev::toHex(uint8_t _data, HexCase _case) }; } -string dev::toHex(bytes const& _data, HexPrefix _prefix, HexCase _case) +string solidity::util::toHex(bytes const& _data, HexPrefix _prefix, HexCase _case) { std::string ret(_data.size() * 2 + (_prefix == HexPrefix::Add ? 2 : 0), 0); @@ -78,7 +79,7 @@ string dev::toHex(bytes const& _data, HexPrefix _prefix, HexCase _case) return ret; } -int dev::fromHex(char _i, WhenError _throw) +int solidity::util::fromHex(char _i, WhenError _throw) { if (_i >= '0' && _i <= '9') return _i - '0'; @@ -92,7 +93,7 @@ int dev::fromHex(char _i, WhenError _throw) return -1; } -bytes dev::fromHex(std::string const& _s, WhenError _throw) +bytes solidity::util::fromHex(std::string const& _s, WhenError _throw) { unsigned s = (_s.size() >= 2 && _s[0] == '0' && _s[1] == 'x') ? 2 : 0; std::vector ret; @@ -119,7 +120,7 @@ bytes dev::fromHex(std::string const& _s, WhenError _throw) } -bool dev::passesAddressChecksum(string const& _str, bool _strict) +bool solidity::util::passesAddressChecksum(string const& _str, bool _strict) { string s = _str.substr(0, 2) == "0x" ? _str : "0x" + _str; @@ -132,10 +133,10 @@ bool dev::passesAddressChecksum(string const& _str, bool _strict) )) return true; - return s == dev::getChecksummedAddress(s); + return s == solidity::util::getChecksummedAddress(s); } -string dev::getChecksummedAddress(string const& _addr) +string solidity::util::getChecksummedAddress(string const& _addr) { string s = _addr.substr(0, 2) == "0x" ? _addr.substr(2) : _addr; assertThrow(s.length() == 40, InvalidAddress, ""); @@ -156,7 +157,7 @@ string dev::getChecksummedAddress(string const& _addr) return ret; } -bool dev::isValidHex(string const& _string) +bool solidity::util::isValidHex(string const& _string) { if (_string.substr(0, 2) != "0x") return false; @@ -165,7 +166,7 @@ bool dev::isValidHex(string const& _string) return true; } -bool dev::isValidDecimal(string const& _string) +bool solidity::util::isValidDecimal(string const& _string) { if (_string.empty()) return false; @@ -179,7 +180,7 @@ bool dev::isValidDecimal(string const& _string) return true; } -string dev::formatAsStringOrNumber(string const& _value) +string solidity::util::formatAsStringOrNumber(string const& _value) { assertThrow(_value.length() <= 32, StringTooLong, "String to be formatted longer than 32 bytes."); diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index 6128e1dd1..d9566a2fe 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -138,7 +138,7 @@ inline std::multiset& operator-=(std::multiset& _a, C const& _b) return _a; } -namespace dev +namespace solidity::util { template diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index fa236b189..ee7f5ead4 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -35,7 +35,7 @@ #endif using namespace std; -using namespace dev; +using namespace solidity::util; namespace { @@ -63,12 +63,12 @@ inline _T readFile(std::string const& _file) } -string dev::readFileAsString(string const& _file) +string solidity::util::readFileAsString(string const& _file) { return readFile(_file); } -string dev::readStandardInput() +string solidity::util::readStandardInput() { string ret; while (!cin.eof()) @@ -124,13 +124,13 @@ private: }; #endif -int dev::readStandardInputChar() +int solidity::util::readStandardInputChar() { DisableConsoleBuffering disableConsoleBuffering; return cin.get(); } -string dev::absolutePath(string const& _path, string const& _reference) +string solidity::util::absolutePath(string const& _path, string const& _reference) { boost::filesystem::path p(_path); // Anything that does not start with `.` is an absolute path. @@ -146,6 +146,6 @@ string dev::absolutePath(string const& _path, string const& _reference) return result.generic_string(); } -string dev::sanitizePath(string const& _path) { +string solidity::util::sanitizePath(string const& _path) { return boost::filesystem::path(_path).generic_string(); } diff --git a/libdevcore/CommonIO.h b/libdevcore/CommonIO.h index 61fa230aa..52232be14 100644 --- a/libdevcore/CommonIO.h +++ b/libdevcore/CommonIO.h @@ -28,7 +28,7 @@ #include #include -namespace dev +namespace solidity::util { /// Retrieve and returns the contents of the given file as a std::string. diff --git a/libdevcore/Exceptions.cpp b/libdevcore/Exceptions.cpp index cff5abf4e..e0e0c4bd8 100644 --- a/libdevcore/Exceptions.cpp +++ b/libdevcore/Exceptions.cpp @@ -18,7 +18,7 @@ #include using namespace std; -using namespace dev; +using namespace solidity::util; char const* Exception::what() const noexcept { diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index 851be4ea1..971b9306f 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -25,7 +25,7 @@ #include #include -namespace dev +namespace solidity::util { /// Base class for all exceptions. @@ -42,7 +42,7 @@ struct Exception: virtual std::exception, virtual boost::exception private: }; -#define DEV_SIMPLE_EXCEPTION(X) struct X: virtual Exception { const char* what() const noexcept override { return #X; } } +#define DEV_SIMPLE_EXCEPTION(X) struct X: virtual ::solidity::util::Exception { const char* what() const noexcept override { return #X; } } DEV_SIMPLE_EXCEPTION(InvalidAddress); DEV_SIMPLE_EXCEPTION(BadHexCharacter); diff --git a/libdevcore/FixedHash.h b/libdevcore/FixedHash.h index 9245d7269..3a9ebdcc8 100644 --- a/libdevcore/FixedHash.h +++ b/libdevcore/FixedHash.h @@ -32,7 +32,7 @@ #include #include -namespace dev +namespace solidity::util { /// Fixed-size raw-byte array container type, with an API optimised for storing hashes. @@ -73,7 +73,7 @@ public: explicit FixedHash(bytesConstRef _b, ConstructFromHashType _t = FailIfDifferent) { if (_b.size() == N) memcpy(m_data.data(), _b.data(), std::min(_b.size(), N)); else { m_data.fill(0); if (_t != FailIfDifferent) { auto c = std::min(_b.size(), N); for (unsigned i = 0; i < c; ++i) m_data[_t == AlignRight ? N - 1 - i : i] = _b[_t == AlignRight ? _b.size() - 1 - i : i]; } } } /// Explicitly construct, copying from a string. - explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : dev::asBytes(_s), _ht) {} + explicit FixedHash(std::string const& _s, ConstructFromStringType _t = FromHex, ConstructFromHashType _ht = FailIfDifferent): FixedHash(_t == FromHex ? fromHex(_s, WhenError::Throw) : solidity::util::asBytes(_s), _ht) {} /// Convert to arithmetic type. operator Arith() const { return fromBigEndian(m_data); } diff --git a/libdevcore/IndentedWriter.cpp b/libdevcore/IndentedWriter.cpp index 1a85957bd..11bf869eb 100644 --- a/libdevcore/IndentedWriter.cpp +++ b/libdevcore/IndentedWriter.cpp @@ -23,7 +23,7 @@ #include using namespace std; -using namespace dev; +using namespace solidity::util; string IndentedWriter::format() const { diff --git a/libdevcore/IndentedWriter.h b/libdevcore/IndentedWriter.h index 563c4c96d..1f56ce8a3 100644 --- a/libdevcore/IndentedWriter.h +++ b/libdevcore/IndentedWriter.h @@ -26,7 +26,7 @@ #include -namespace dev +namespace solidity::util { DEV_SIMPLE_EXCEPTION(IndentedWriterError); diff --git a/libdevcore/IpfsHash.cpp b/libdevcore/IpfsHash.cpp index 22ad7100c..246854038 100644 --- a/libdevcore/IpfsHash.cpp +++ b/libdevcore/IpfsHash.cpp @@ -23,7 +23,8 @@ #include using namespace std; -using namespace dev; +using namespace solidity; +using namespace solidity::util; namespace { @@ -54,7 +55,7 @@ string base58Encode(bytes const& _data) } } -bytes dev::ipfsHash(string _data) +bytes solidity::util::ipfsHash(string _data) { assertThrow(_data.length() < 1024 * 256, DataTooLong, "IPFS hash for large (chunked) files not yet implemented."); @@ -84,7 +85,7 @@ bytes dev::ipfsHash(string _data) return hash; } -string dev::ipfsHashBase58(string _data) +string solidity::util::ipfsHashBase58(string _data) { return base58Encode(ipfsHash(std::move(_data))); } diff --git a/libdevcore/IpfsHash.h b/libdevcore/IpfsHash.h index e7d92c79b..1a9638005 100644 --- a/libdevcore/IpfsHash.h +++ b/libdevcore/IpfsHash.h @@ -21,7 +21,7 @@ #include -namespace dev +namespace solidity::util { /// Compute the "ipfs hash" of a file with the content @a _data. diff --git a/libdevcore/JSON.cpp b/libdevcore/JSON.cpp index 5d1ea831d..0fdbcd411 100644 --- a/libdevcore/JSON.cpp +++ b/libdevcore/JSON.cpp @@ -36,7 +36,7 @@ static_assert( "Unexpected jsoncpp version: " JSONCPP_VERSION_STRING ". Expecting 1.9.2." ); -namespace dev +namespace solidity::util { namespace @@ -111,4 +111,4 @@ bool jsonParseStrict(string const& _input, Json::Value& _json, string* _errs /* return parse(readerBuilder, _input, _json, _errs); } -} // namespace dev +} // namespace solidity::util diff --git a/libdevcore/JSON.h b/libdevcore/JSON.h index 2390d55f2..17633ea07 100644 --- a/libdevcore/JSON.h +++ b/libdevcore/JSON.h @@ -26,7 +26,7 @@ #include -namespace dev { +namespace solidity::util { /// Serialise the JSON object (@a _input) with indentation std::string jsonPrettyPrint(Json::Value const& _input); diff --git a/libdevcore/Keccak256.cpp b/libdevcore/Keccak256.cpp index 752973822..e0df05cd6 100644 --- a/libdevcore/Keccak256.cpp +++ b/libdevcore/Keccak256.cpp @@ -27,9 +27,8 @@ #include using namespace std; -using namespace dev; -namespace dev +namespace solidity::util { namespace diff --git a/libdevcore/Keccak256.h b/libdevcore/Keccak256.h index 0d5f69bb7..eeba453c9 100644 --- a/libdevcore/Keccak256.h +++ b/libdevcore/Keccak256.h @@ -27,7 +27,7 @@ #include -namespace dev +namespace solidity::util { /// Calculate Keccak-256 hash of the given input, returning as a 256-bit hash. diff --git a/libdevcore/Result.h b/libdevcore/Result.h index ebc0db0e1..a8150a825 100644 --- a/libdevcore/Result.h +++ b/libdevcore/Result.h @@ -18,7 +18,7 @@ #include -namespace dev +namespace solidity::util { /// Simple generic result that holds a value and an optional error message. diff --git a/libdevcore/StringUtils.cpp b/libdevcore/StringUtils.cpp index fd6cad339..004e9cdb2 100644 --- a/libdevcore/StringUtils.cpp +++ b/libdevcore/StringUtils.cpp @@ -27,9 +27,9 @@ #include using namespace std; -using namespace dev; +using namespace solidity::util; -bool dev::stringWithinDistance(string const& _str1, string const& _str2, size_t _maxDistance, size_t _lenThreshold) +bool solidity::util::stringWithinDistance(string const& _str1, string const& _str2, size_t _maxDistance, size_t _lenThreshold) { if (_str1 == _str2) return true; @@ -46,7 +46,7 @@ bool dev::stringWithinDistance(string const& _str1, string const& _str2, size_t return distance <= _maxDistance && distance < n1 && distance < n2; } -size_t dev::stringDistance(string const& _str1, string const& _str2) +size_t solidity::util::stringDistance(string const& _str1, string const& _str2) { size_t n1 = _str1.size(); size_t n2 = _str2.size(); @@ -86,7 +86,7 @@ size_t dev::stringDistance(string const& _str1, string const& _str2) return dp[(n1 % 3) + n2 * 3]; } -string dev::quotedAlternativesList(vector const& suggestions) +string solidity::util::quotedAlternativesList(vector const& suggestions) { vector quotedSuggestions; @@ -96,7 +96,7 @@ string dev::quotedAlternativesList(vector const& suggestions) return joinHumanReadable(quotedSuggestions, ", ", " or "); } -string dev::suffixedVariableNameList(string const& _baseName, size_t _startSuffix, size_t _endSuffix) +string solidity::util::suffixedVariableNameList(string const& _baseName, size_t _startSuffix, size_t _endSuffix) { string result; if (_startSuffix < _endSuffix) diff --git a/libdevcore/StringUtils.h b/libdevcore/StringUtils.h index b6deba790..72668031a 100644 --- a/libdevcore/StringUtils.h +++ b/libdevcore/StringUtils.h @@ -28,7 +28,7 @@ #include -namespace dev +namespace solidity::util { // Calculates the Damerau–Levenshtein distance between _str1 and _str2 and returns true if that distance is not greater than _maxDistance diff --git a/libdevcore/SwarmHash.cpp b/libdevcore/SwarmHash.cpp index b317ff59a..388bb8f0d 100644 --- a/libdevcore/SwarmHash.cpp +++ b/libdevcore/SwarmHash.cpp @@ -22,7 +22,8 @@ #include using namespace std; -using namespace dev; +using namespace solidity; +using namespace solidity::util; namespace { @@ -102,13 +103,13 @@ h256 chunkHash(bytesConstRef const _data, bool _forceHigherLevel = false) } -h256 dev::bzzr0Hash(string const& _input) +h256 solidity::util::bzzr0Hash(string const& _input) { return swarmHashIntermediate(_input, 0, _input.size()); } -h256 dev::bzzr1Hash(bytes const& _input) +h256 solidity::util::bzzr1Hash(bytes const& _input) { if (_input.empty()) return h256{}; diff --git a/libdevcore/SwarmHash.h b/libdevcore/SwarmHash.h index 0d1d2622f..52c779811 100644 --- a/libdevcore/SwarmHash.h +++ b/libdevcore/SwarmHash.h @@ -23,7 +23,7 @@ #include -namespace dev +namespace solidity::util { /// Compute the "swarm hash" of @a _input (OLD 0x1000-section version) diff --git a/libdevcore/UTF8.cpp b/libdevcore/UTF8.cpp index a9fcf0ce3..98ee8904c 100644 --- a/libdevcore/UTF8.cpp +++ b/libdevcore/UTF8.cpp @@ -23,7 +23,7 @@ #include -namespace dev +namespace solidity::util { namespace { diff --git a/libdevcore/UTF8.h b/libdevcore/UTF8.h index 1f755e70e..cd84c3982 100644 --- a/libdevcore/UTF8.h +++ b/libdevcore/UTF8.h @@ -25,7 +25,7 @@ #include -namespace dev +namespace solidity::util { /// Validate an input for UTF8 encoding diff --git a/libdevcore/Visitor.h b/libdevcore/Visitor.h index 3d79e03e8..6d771cd86 100644 --- a/libdevcore/Visitor.h +++ b/libdevcore/Visitor.h @@ -20,7 +20,7 @@ #pragma once -namespace dev +namespace solidity::util { /** diff --git a/libdevcore/Whiskers.cpp b/libdevcore/Whiskers.cpp index 09415960d..a40398086 100644 --- a/libdevcore/Whiskers.cpp +++ b/libdevcore/Whiskers.cpp @@ -28,7 +28,7 @@ #include using namespace std; -using namespace dev; +using namespace solidity::util; Whiskers::Whiskers(string _template): m_template(move(_template)) diff --git a/libdevcore/Whiskers.h b/libdevcore/Whiskers.h index 5d326bf02..04020d6ff 100644 --- a/libdevcore/Whiskers.h +++ b/libdevcore/Whiskers.h @@ -29,7 +29,7 @@ #include #include -namespace dev +namespace solidity::util { DEV_SIMPLE_EXCEPTION(WhiskersError); diff --git a/libdevcore/vector_ref.h b/libdevcore/vector_ref.h index a866f6628..2c98bce25 100644 --- a/libdevcore/vector_ref.h +++ b/libdevcore/vector_ref.h @@ -10,7 +10,7 @@ #pragma warning(disable:597) // will not be called for implicit or explicit conversions #endif -namespace dev +namespace solidity::util { /** diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 062ad672d..ad4263869 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -33,9 +33,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::langutil; +using namespace solidity::util; void Assembly::append(Assembly const& _a) { @@ -105,7 +106,7 @@ unsigned Assembly::bytesRequired(unsigned subTagSize) const for (AssemblyItem const& i: m_items) ret += i.bytesRequired(tagSize); - if (dev::bytesRequired(ret) <= tagSize) + if (util::bytesRequired(ret) <= tagSize) return ret; } } @@ -290,15 +291,15 @@ Json::Value Assembly::assemblyJSON(StringMap const& _sourceCodes) const createJsonValue("PUSH [ErrorTag]", i.location().start, i.location().end, "")); else collection.append( - createJsonValue("PUSH [tag]", i.location().start, i.location().end, dev::toString(i.data()))); + createJsonValue("PUSH [tag]", i.location().start, i.location().end, toString(i.data()))); break; case PushSub: collection.append( - createJsonValue("PUSH [$]", i.location().start, i.location().end, dev::toString(h256(i.data())))); + createJsonValue("PUSH [$]", i.location().start, i.location().end, toString(h256(i.data())))); break; case PushSubSize: collection.append( - createJsonValue("PUSH #[$]", i.location().start, i.location().end, dev::toString(h256(i.data())))); + createJsonValue("PUSH #[$]", i.location().start, i.location().end, toString(h256(i.data())))); break; case PushProgramSize: collection.append( @@ -316,7 +317,7 @@ Json::Value Assembly::assemblyJSON(StringMap const& _sourceCodes) const break; case Tag: collection.append( - createJsonValue("tag", i.location().start, i.location().end, dev::toString(i.data()))); + createJsonValue("tag", i.location().start, i.location().end, toString(i.data()))); collection.append( createJsonValue("JUMPDEST", i.location().start, i.location().end)); break; @@ -359,7 +360,7 @@ AssemblyItem Assembly::namedTag(string const& _name) AssemblyItem Assembly::newPushLibraryAddress(string const& _identifier) { - h256 h(dev::keccak256(_identifier)); + h256 h(util::keccak256(_identifier)); m_libraries[h] = _identifier; return AssemblyItem{PushLibraryAddress, h}; } @@ -543,14 +544,14 @@ LinkerObject const& Assembly::assemble() const multimap dataRef; multimap subRef; vector sizeRef; ///< Pointers to code locations where the size of the program is inserted - unsigned bytesPerTag = dev::bytesRequired(bytesRequiredForCode); + unsigned bytesPerTag = util::bytesRequired(bytesRequiredForCode); uint8_t tagPush = (uint8_t)Instruction::PUSH1 - 1 + bytesPerTag; unsigned bytesRequiredIncludingData = bytesRequiredForCode + 1 + m_auxiliaryData.size(); for (auto const& sub: m_subs) bytesRequiredIncludingData += sub->assemble().bytecode.size(); - unsigned bytesPerDataRef = dev::bytesRequired(bytesRequiredIncludingData); + unsigned bytesPerDataRef = util::bytesRequired(bytesRequiredIncludingData); uint8_t dataRefPush = (uint8_t)Instruction::PUSH1 - 1 + bytesPerDataRef; ret.bytecode.reserve(bytesRequiredIncludingData); @@ -580,7 +581,7 @@ LinkerObject const& Assembly::assemble() const } case Push: { - uint8_t b = max(1, dev::bytesRequired(i.data())); + uint8_t b = max(1, util::bytesRequired(i.data())); ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b); ret.bytecode.resize(ret.bytecode.size() + b); bytesRef byr(&ret.bytecode.back() + 1 - b, b); @@ -610,7 +611,7 @@ LinkerObject const& Assembly::assemble() const assertThrow(i.data() <= size_t(-1), AssemblyException, ""); auto s = m_subs.at(size_t(i.data()))->assemble().bytecode.size(); i.setPushedValue(u256(s)); - uint8_t b = max(1, dev::bytesRequired(s)); + uint8_t b = max(1, util::bytesRequired(s)); ret.bytecode.push_back((uint8_t)Instruction::PUSH1 - 1 + b); ret.bytecode.resize(ret.bytecode.size() + b); bytesRef byr(&ret.bytecode.back() + 1 - b, b); @@ -675,7 +676,7 @@ LinkerObject const& Assembly::assemble() const assertThrow(tagId < tagPositions.size(), AssemblyException, "Reference to non-existing tag."); size_t pos = tagPositions[tagId]; assertThrow(pos != size_t(-1), AssemblyException, "Reference to tag without position."); - assertThrow(dev::bytesRequired(pos) <= bytesPerTag, AssemblyException, "Tag too large for reserved space."); + assertThrow(util::bytesRequired(pos) <= bytesPerTag, AssemblyException, "Tag too large for reserved space."); bytesRef r(ret.bytecode.data() + i.first, bytesPerTag); toBigEndian(pos, r); } diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index f79da0e7f..de5f46465 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -35,9 +35,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { using AssemblyPointer = std::shared_ptr; @@ -49,8 +47,8 @@ public: AssemblyItem newPushTag() { assertThrow(m_usedTags < 0xffffffff, AssemblyException, ""); return AssemblyItem(PushTag, m_usedTags++); } /// Returns a tag identified by the given name. Creates it if it does not yet exist. AssemblyItem namedTag(std::string const& _name); - AssemblyItem newData(bytes const& _data) { h256 h(dev::keccak256(asString(_data))); m_data[h] = _data; return AssemblyItem(PushData, h); } - bytes const& data(h256 const& _i) const { return m_data.at(_i); } + AssemblyItem newData(bytes const& _data) { util::h256 h(util::keccak256(util::asString(_data))); m_data[h] = _data; return AssemblyItem(PushData, h); } + bytes const& data(util::h256 const& _i) const { return m_data.at(_i); } AssemblyItem newSub(AssemblyPointer const& _sub) { m_subs.push_back(_sub); return AssemblyItem(PushSub, m_subs.size() - 1); } Assembly const& sub(size_t _sub) const { return *m_subs.at(_sub); } Assembly& sub(size_t _sub) { return *m_subs.at(_sub); } @@ -141,7 +139,7 @@ public: public: // These features are only used by LLL - AssemblyItem newPushString(std::string const& _data) { h256 h(dev::keccak256(_data)); m_strings[h] = _data; return AssemblyItem(PushString, h); } + AssemblyItem newPushString(std::string const& _data) { util::h256 h(util::keccak256(_data)); m_strings[h] = _data; return AssemblyItem(PushString, h); } void append(Assembly const& _a); void append(Assembly const& _a, int _deposit); @@ -149,7 +147,7 @@ public: void injectStart(AssemblyItem const& _i); AssemblyItem const& back() const { return m_items.back(); } - std::string backString() const { return m_items.size() && m_items.back().type() == PushString ? m_strings.at((h256)m_items.back().data()) : std::string(); } + std::string backString() const { return m_items.size() && m_items.back().type() == PushString ? m_strings.at((util::h256)m_items.back().data()) : std::string(); } protected: /// Does the same operations as @a optimise, but should only be applied to a sub and @@ -168,12 +166,12 @@ protected: unsigned m_usedTags = 1; std::map m_namedTags; AssemblyItems m_items; - std::map m_data; + std::map m_data; /// Data that is appended to the very end of the contract. bytes m_auxiliaryData; std::vector> m_subs; - std::map m_strings; - std::map m_libraries; ///< Identifiers of libraries to be linked. + std::map m_strings; + std::map m_libraries; ///< Identifiers of libraries to be linked. mutable LinkerObject m_assembledObject; mutable std::vector m_tagPositionsInBytecode; @@ -192,4 +190,3 @@ inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a) } } -} diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 53d4b79a0..a2104a576 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -23,15 +23,15 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::evmasm; static_assert(sizeof(size_t) <= 8, "size_t must be at most 64-bits wide"); AssemblyItem AssemblyItem::toSubAssemblyTag(size_t _subId) const { - assertThrow(data() < (u256(1) << 64), Exception, "Tag already has subassembly set."); - assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); + assertThrow(data() < (u256(1) << 64), util::Exception, "Tag already has subassembly set."); + assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); size_t tag = size_t(u256(data()) & 0xffffffffffffffffULL); AssemblyItem r = *this; r.m_type = PushTag; @@ -41,7 +41,7 @@ AssemblyItem AssemblyItem::toSubAssemblyTag(size_t _subId) const pair AssemblyItem::splitForeignPushTag() const { - assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); + assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); u256 combined = u256(data()); size_t subId = size_t((combined >> 64) - 1); size_t tag = size_t(combined & 0xffffffffffffffffULL); @@ -50,7 +50,7 @@ pair AssemblyItem::splitForeignPushTag() const void AssemblyItem::setPushTagSubIdAndTag(size_t _subId, size_t _tag) { - assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); + assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); u256 data = _tag; if (_subId != size_t(-1)) data |= (u256(_subId) + 1) << 64; @@ -67,7 +67,7 @@ unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const case PushString: return 1 + 32; case Push: - return 1 + max(1, dev::bytesRequired(data())); + return 1 + max(1, util::bytesRequired(data())); case PushSubSize: case PushProgramSize: return 1 + 4; // worst case: a 16MB program @@ -170,10 +170,10 @@ string AssemblyItem::toAssemblyText() const break; } case Push: - text = toHex(toCompactBigEndian(data(), 1), HexPrefix::Add); + text = toHex(util::toCompactBigEndian(data(), 1), util::HexPrefix::Add); break; case PushString: - text = string("data_") + toHex(data()); + text = string("data_") + util::toHex(data()); break; case PushTag: { @@ -191,7 +191,7 @@ string AssemblyItem::toAssemblyText() const text = string("tag_") + to_string(size_t(data())) + ":"; break; case PushData: - text = string("data_") + toHex(data()); + text = string("data_") + util::toHex(data()); break; case PushSub: text = string("dataOffset(sub_") + to_string(size_t(data())) + ")"; @@ -203,7 +203,7 @@ string AssemblyItem::toAssemblyText() const text = string("bytecodeSize"); break; case PushLibraryAddress: - text = string("linkerSymbol(\"") + toHex(data()) + string("\")"); + text = string("linkerSymbol(\"") + util::toHex(data()) + string("\")"); break; case PushDeployTimeAddress: text = string("deployTimeAddress()"); @@ -225,7 +225,7 @@ string AssemblyItem::toAssemblyText() const return text; } -ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item) +ostream& solidity::evmasm::operator<<(ostream& _out, AssemblyItem const& _item) { switch (_item.type()) { @@ -266,7 +266,7 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item) break; case PushLibraryAddress: { - string hash(h256((_item.data())).hex()); + string hash(util::h256((_item.data())).hex()); _out << " PushLibraryAddress " << hash.substr(0, 8) + "..." + hash.substr(hash.length() - 8); break; } diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h index c1d079bb1..b860a3657 100644 --- a/libevmasm/AssemblyItem.h +++ b/libevmasm/AssemblyItem.h @@ -29,9 +29,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { enum AssemblyItemType { @@ -77,8 +75,8 @@ public: AssemblyItem& operator=(AssemblyItem const&) = default; AssemblyItem& operator=(AssemblyItem&&) = default; - AssemblyItem tag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(Tag, data()); } - AssemblyItem pushTag() const { assertThrow(m_type == PushTag || m_type == Tag, Exception, ""); return AssemblyItem(PushTag, data()); } + AssemblyItem tag() const { assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); return AssemblyItem(Tag, data()); } + AssemblyItem pushTag() const { assertThrow(m_type == PushTag || m_type == Tag, util::Exception, ""); return AssemblyItem(PushTag, data()); } /// Converts the tag to a subassembly tag. This has to be called in order to move a tag across assemblies. /// @param _subId the identifier of the subassembly the tag is taken from. AssemblyItem toSubAssemblyTag(size_t _subId) const; @@ -89,11 +87,11 @@ public: void setPushTagSubIdAndTag(size_t _subId, size_t _tag); AssemblyItemType type() const { return m_type; } - u256 const& data() const { assertThrow(m_type != Operation, Exception, ""); return *m_data; } - void setData(u256 const& _data) { assertThrow(m_type != Operation, Exception, ""); m_data = std::make_shared(_data); } + u256 const& data() const { assertThrow(m_type != Operation, util::Exception, ""); return *m_data; } + void setData(u256 const& _data) { assertThrow(m_type != Operation, util::Exception, ""); m_data = std::make_shared(_data); } /// @returns the instruction of this item (only valid if type() == Operation) - Instruction instruction() const { assertThrow(m_type == Operation, Exception, ""); return m_instruction; } + Instruction instruction() const { assertThrow(m_type == Operation, util::Exception, ""); return m_instruction; } /// @returns true if the type and data of the items are equal. bool operator==(AssemblyItem const& _other) const @@ -178,4 +176,3 @@ inline std::ostream& operator<<(std::ostream& _out, AssemblyItems const& _items) } } -} diff --git a/libevmasm/BlockDeduplicator.cpp b/libevmasm/BlockDeduplicator.cpp index ca439925c..9a26db8ca 100644 --- a/libevmasm/BlockDeduplicator.cpp +++ b/libevmasm/BlockDeduplicator.cpp @@ -30,8 +30,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::evmasm; bool BlockDeduplicator::deduplicate() diff --git a/libevmasm/BlockDeduplicator.h b/libevmasm/BlockDeduplicator.h index 5640984b3..ecb4bc797 100644 --- a/libevmasm/BlockDeduplicator.h +++ b/libevmasm/BlockDeduplicator.h @@ -30,9 +30,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class AssemblyItem; @@ -90,4 +88,3 @@ private: }; } -} diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index c8e2f9210..945768120 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -28,9 +28,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::langutil; vector CommonSubexpressionEliminator::getOptimizedItems() { diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h index cddc928aa..1b7a7e168 100644 --- a/libevmasm/CommonSubexpressionEliminator.h +++ b/libevmasm/CommonSubexpressionEliminator.h @@ -39,9 +39,7 @@ namespace langutil struct SourceLocation; } -namespace dev -{ -namespace eth +namespace solidity::evmasm { class AssemblyItem; @@ -187,4 +185,3 @@ _AssemblyItemIterator CommonSubexpressionEliminator::feedItems( } } -} diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index 36cb2d656..b6b746231 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -22,9 +22,11 @@ #include #include #include +#include + using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::evmasm; unsigned ConstantOptimisationMethod::optimiseConstants( bool _isCreation, @@ -101,7 +103,7 @@ bigint ConstantOptimisationMethod::dataGas(bytes const& _data) const size_t ConstantOptimisationMethod::bytesRequired(AssemblyItems const& _items) { - return eth::bytesRequired(_items, 3); // assume 3 byte addresses + return evmasm::bytesRequired(_items, 3); // assume 3 byte addresses } void ConstantOptimisationMethod::replaceConstants( @@ -131,7 +133,7 @@ bigint LiteralMethod::gasNeeded() const return combineGas( simpleRunGas({Instruction::PUSH1}), // PUSHX plus data - (m_params.isCreation ? GasCosts::txDataNonZeroGas(m_params.evmVersion) : GasCosts::createDataGas) + dataGas(toCompactBigEndian(m_value, 1)), + (m_params.isCreation ? GasCosts::txDataNonZeroGas(m_params.evmVersion) : GasCosts::createDataGas) + dataGas(util::toCompactBigEndian(m_value, 1)), 0 ); } @@ -144,13 +146,13 @@ bigint CodeCopyMethod::gasNeeded() const // Data gas for copy routines: Some bytes are zero, but we ignore them. bytesRequired(copyRoutine()) * (m_params.isCreation ? GasCosts::txDataNonZeroGas(m_params.evmVersion) : GasCosts::createDataGas), // Data gas for data itself - dataGas(toBigEndian(m_value)) + dataGas(util::toBigEndian(m_value)) ); } AssemblyItems CodeCopyMethod::execute(Assembly& _assembly) const { - bytes data = toBigEndian(m_value); + bytes data = util::toBigEndian(m_value); assertThrow(data.size() == 32, OptimizerException, "Invalid number encoding."); AssemblyItems actualCopyRoutine = copyRoutine(); actualCopyRoutine[4] = _assembly.newData(data); @@ -190,7 +192,7 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value) if (_value < 0x10000) // Very small value, not worth computing return AssemblyItems{_value}; - else if (dev::bytesRequired(~_value) < dev::bytesRequired(_value)) + else if (util::bytesRequired(~_value) < util::bytesRequired(_value)) // Negated is shorter to represent return findRepresentation(~_value) + AssemblyItems{Instruction::NOT}; else diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h index be1628c71..b46b1936d 100644 --- a/libevmasm/ConstantOptimiser.h +++ b/libevmasm/ConstantOptimiser.h @@ -31,9 +31,7 @@ #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class AssemblyItem; @@ -164,4 +162,3 @@ protected: }; } -} diff --git a/libevmasm/ControlFlowGraph.cpp b/libevmasm/ControlFlowGraph.cpp index e82c2903f..4c9d59c8b 100644 --- a/libevmasm/ControlFlowGraph.cpp +++ b/libevmasm/ControlFlowGraph.cpp @@ -31,8 +31,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::evmasm; BlockId::BlockId(u256 const& _id): m_id(unsigned(_id)) diff --git a/libevmasm/ControlFlowGraph.h b/libevmasm/ControlFlowGraph.h index f0c9356c6..f5bf487c5 100644 --- a/libevmasm/ControlFlowGraph.h +++ b/libevmasm/ControlFlowGraph.h @@ -29,9 +29,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class KnownState; @@ -127,4 +125,3 @@ private: } -} diff --git a/libevmasm/Exceptions.h b/libevmasm/Exceptions.h index d6557d399..f4d4cfa93 100644 --- a/libevmasm/Exceptions.h +++ b/libevmasm/Exceptions.h @@ -23,12 +23,10 @@ #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { -struct AssemblyException: virtual Exception {}; +struct AssemblyException: virtual util::Exception {}; struct OptimizerException: virtual AssemblyException {}; struct StackTooDeepException: virtual OptimizerException {}; struct ItemNotAvailableException: virtual OptimizerException {}; @@ -37,4 +35,3 @@ DEV_SIMPLE_EXCEPTION(InvalidDeposit); DEV_SIMPLE_EXCEPTION(InvalidOpcode); } -} diff --git a/libevmasm/ExpressionClasses.cpp b/libevmasm/ExpressionClasses.cpp index 41cf8990e..644f4a274 100644 --- a/libevmasm/ExpressionClasses.cpp +++ b/libevmasm/ExpressionClasses.cpp @@ -32,9 +32,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::langutil; bool ExpressionClasses::Expression::operator<(ExpressionClasses::Expression const& _other) const { diff --git a/libevmasm/ExpressionClasses.h b/libevmasm/ExpressionClasses.h index a34844c54..7014cc46d 100644 --- a/libevmasm/ExpressionClasses.h +++ b/libevmasm/ExpressionClasses.h @@ -31,14 +31,12 @@ #include #include -namespace langutil +namespace solidity::langutil { struct SourceLocation; } -namespace dev -{ -namespace eth +namespace solidity::evmasm { class Pattern; @@ -128,4 +126,3 @@ private: }; } -} diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index ca8d7fbd4..cd781b71d 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -22,8 +22,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::evmasm; GasMeter::GasConsumption& GasMeter::GasConsumption::operator+=(GasConsumption const& _other) { diff --git a/libevmasm/GasMeter.h b/libevmasm/GasMeter.h index 38ab4aa6f..64b772c6e 100644 --- a/libevmasm/GasMeter.h +++ b/libevmasm/GasMeter.h @@ -29,9 +29,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class KnownState; @@ -180,4 +178,3 @@ inline std::ostream& operator<<(std::ostream& _str, GasMeter::GasConsumption con } -} diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index 8c0a45308..47930fb4e 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -27,10 +27,11 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::evmasm; -std::map const dev::eth::c_instructions = +std::map const solidity::evmasm::c_instructions = { { "STOP", Instruction::STOP }, { "ADD", Instruction::ADD }, @@ -322,7 +323,7 @@ static std::map const c_instructionInfo = { Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Special } } }; -void dev::eth::eachInstruction( +void solidity::evmasm::eachInstruction( bytes const& _mem, function const& _onInstruction ) @@ -351,7 +352,7 @@ void dev::eth::eachInstruction( } } -string dev::eth::disassemble(bytes const& _mem) +string solidity::evmasm::disassemble(bytes const& _mem) { stringstream ret; eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) { @@ -368,7 +369,7 @@ string dev::eth::disassemble(bytes const& _mem) return ret.str(); } -InstructionInfo dev::eth::instructionInfo(Instruction _inst) +InstructionInfo solidity::evmasm::instructionInfo(Instruction _inst) { try { @@ -380,7 +381,7 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst) } } -bool dev::eth::isValidInstruction(Instruction _inst) +bool solidity::evmasm::isValidInstruction(Instruction _inst) { return !!c_instructionInfo.count(_inst); } diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index c93fbf158..78146c1e9 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -26,9 +26,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { /// Virtual machine bytecode instruction. @@ -318,4 +316,3 @@ void eachInstruction(bytes const& _mem, std::function using namespace std; -using namespace dev::eth; -using namespace dev; - +using namespace solidity; +using namespace solidity::util; +using namespace solidity::evmasm; bool JumpdestRemover::optimise(set const& _tagsReferencedFromOutside) { diff --git a/libevmasm/JumpdestRemover.h b/libevmasm/JumpdestRemover.h index 2dad09272..80b546d79 100644 --- a/libevmasm/JumpdestRemover.h +++ b/libevmasm/JumpdestRemover.h @@ -24,9 +24,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class AssemblyItem; using AssemblyItems = std::vector; @@ -47,4 +45,3 @@ private: }; } -} diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index 3d7c476fd..e8838afa4 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -28,9 +28,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::langutil; ostream& KnownState::stream(ostream& _out) const { @@ -383,9 +383,9 @@ KnownState::Id KnownState::applyKeccak256( { bytes data; for (Id a: arguments) - data += toBigEndian(*m_expressionClasses->knownConstant(a)); + data += util::toBigEndian(*m_expressionClasses->knownConstant(a)); data.resize(size_t(*l)); - v = m_expressionClasses->find(AssemblyItem(u256(dev::keccak256(data)), _location)); + v = m_expressionClasses->find(AssemblyItem(u256(util::keccak256(data)), _location)); } else v = m_expressionClasses->find(keccak256Item, {_start, _length}, true, m_sequenceNumber); diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h index 3b5e9e7af..7a9efa13d 100644 --- a/libevmasm/KnownState.h +++ b/libevmasm/KnownState.h @@ -46,14 +46,12 @@ #include #include -namespace langutil +namespace solidity::langutil { struct SourceLocation; } -namespace dev -{ -namespace eth +namespace solidity::evmasm { class AssemblyItem; @@ -182,4 +180,3 @@ private: }; } -} diff --git a/libevmasm/LinkerObject.cpp b/libevmasm/LinkerObject.cpp index 6eec54ea5..2906c9abf 100644 --- a/libevmasm/LinkerObject.cpp +++ b/libevmasm/LinkerObject.cpp @@ -23,9 +23,10 @@ #include #include -using namespace dev; -using namespace dev::eth; using namespace std; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::evmasm; void LinkerObject::append(LinkerObject const& _other) { @@ -47,7 +48,7 @@ void LinkerObject::link(map const& _libraryAddresses) string LinkerObject::toHex() const { - string hex = dev::toHex(bytecode); + string hex = solidity::util::toHex(bytecode); for (auto const& ref: linkReferences) { size_t pos = ref.first * 2; diff --git a/libevmasm/LinkerObject.h b/libevmasm/LinkerObject.h index 3630365e0..85439485d 100644 --- a/libevmasm/LinkerObject.h +++ b/libevmasm/LinkerObject.h @@ -24,9 +24,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { /** @@ -46,7 +44,7 @@ struct LinkerObject void append(LinkerObject const& _other); /// Links the given libraries by replacing their uses in the code and removes them from the references. - void link(std::map const& _libraryAddresses); + void link(std::map const& _libraryAddresses); /// @returns a hex representation of the bytecode of the given object, replacing unlinked /// addresses by placeholders. This output is lowercase. @@ -58,11 +56,10 @@ struct LinkerObject static std::string libraryPlaceholder(std::string const& _libraryName); private: - static h160 const* matchLibrary( + static util::h160 const* matchLibrary( std::string const& _linkRefName, - std::map const& _libraryAddresses + std::map const& _libraryAddresses ); }; } -} diff --git a/libevmasm/PathGasMeter.cpp b/libevmasm/PathGasMeter.cpp index 9d14ac947..749cc7bb1 100644 --- a/libevmasm/PathGasMeter.cpp +++ b/libevmasm/PathGasMeter.cpp @@ -24,8 +24,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::evmasm; PathGasMeter::PathGasMeter(AssemblyItems const& _items, langutil::EVMVersion _evmVersion): m_items(_items), m_evmVersion(_evmVersion) diff --git a/libevmasm/PathGasMeter.h b/libevmasm/PathGasMeter.h index 67b607c42..38a197973 100644 --- a/libevmasm/PathGasMeter.h +++ b/libevmasm/PathGasMeter.h @@ -29,9 +29,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class KnownState; @@ -85,4 +83,3 @@ private: }; } -} diff --git a/libevmasm/PeepholeOptimiser.cpp b/libevmasm/PeepholeOptimiser.cpp index 3e2c45b6f..e05abd3e4 100644 --- a/libevmasm/PeepholeOptimiser.cpp +++ b/libevmasm/PeepholeOptimiser.cpp @@ -25,8 +25,8 @@ #include using namespace std; -using namespace dev::eth; -using namespace dev; +using namespace solidity; +using namespace solidity::evmasm; // TODO: Extend this to use the tools from ExpressionClasses.cpp @@ -362,7 +362,7 @@ bool PeepholeOptimiser::optimise() ); if (m_optimisedItems.size() < m_items.size() || ( m_optimisedItems.size() == m_items.size() && ( - eth::bytesRequired(m_optimisedItems, 3) < eth::bytesRequired(m_items, 3) || + evmasm::bytesRequired(m_optimisedItems, 3) < evmasm::bytesRequired(m_items, 3) || numberOfPops(m_optimisedItems) > numberOfPops(m_items) ) )) diff --git a/libevmasm/PeepholeOptimiser.h b/libevmasm/PeepholeOptimiser.h index a651143dd..a260d3148 100644 --- a/libevmasm/PeepholeOptimiser.h +++ b/libevmasm/PeepholeOptimiser.h @@ -24,9 +24,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class AssemblyItem; using AssemblyItems = std::vector; @@ -53,4 +51,3 @@ private: }; } -} diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index 01b2fa963..f2daa88ea 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -32,9 +32,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { template S divWorkaround(S const& _a, S const& _b) @@ -674,4 +672,3 @@ std::vector> simplificationRuleList( } } -} diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index 8932d4351..b7fa069d2 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -25,8 +25,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::evmasm; bool SemanticInformation::breaksCSEAnalysisBlock(AssemblyItem const& _item, bool _msizeImportant) { @@ -96,14 +96,14 @@ bool SemanticInformation::isDupInstruction(AssemblyItem const& _item) { if (_item.type() != Operation) return false; - return dev::eth::isDupInstruction(_item.instruction()); + return evmasm::isDupInstruction(_item.instruction()); } bool SemanticInformation::isSwapInstruction(AssemblyItem const& _item) { if (_item.type() != Operation) return false; - return dev::eth::isSwapInstruction(_item.instruction()); + return evmasm::isSwapInstruction(_item.instruction()); } bool SemanticInformation::isJumpInstruction(AssemblyItem const& _item) diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index 5f2d3b056..f08c3d73d 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -25,9 +25,7 @@ #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class AssemblyItem; @@ -75,4 +73,3 @@ struct SemanticInformation }; } -} diff --git a/libevmasm/SimplificationRule.h b/libevmasm/SimplificationRule.h index f12b859cd..f50090ce4 100644 --- a/libevmasm/SimplificationRule.h +++ b/libevmasm/SimplificationRule.h @@ -24,9 +24,7 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { /** @@ -158,4 +156,3 @@ struct EVMBuiltins }; } -} diff --git a/libevmasm/SimplificationRules.cpp b/libevmasm/SimplificationRules.cpp index 28b64078a..542e650b8 100644 --- a/libevmasm/SimplificationRules.cpp +++ b/libevmasm/SimplificationRules.cpp @@ -36,9 +36,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::langutil; SimplificationRule const* Rules::findFirstMatch( Expression const& _expr, diff --git a/libevmasm/SimplificationRules.h b/libevmasm/SimplificationRules.h index a01507411..0d02aa15a 100644 --- a/libevmasm/SimplificationRules.h +++ b/libevmasm/SimplificationRules.h @@ -33,14 +33,12 @@ #include #include -namespace langutil +namespace solidity::langutil { struct SourceLocation; } -namespace dev -{ -namespace eth +namespace solidity::evmasm { class Pattern; @@ -89,7 +87,7 @@ public: using Expression = ExpressionClasses::Expression; using Id = ExpressionClasses::Id; - using Builtins = dev::eth::EVMBuiltins; + using Builtins = evmasm::EVMBuiltins; static constexpr size_t WordSize = 256; using Word = u256; @@ -159,4 +157,3 @@ struct ExpressionTemplate }; } -} diff --git a/liblangutil/CharStream.cpp b/liblangutil/CharStream.cpp index 58edced3b..be236893f 100644 --- a/liblangutil/CharStream.cpp +++ b/liblangutil/CharStream.cpp @@ -54,7 +54,8 @@ #include using namespace std; -using namespace langutil; +using namespace solidity; +using namespace solidity::langutil; char CharStream::advanceAndGet(size_t _chars) { diff --git a/liblangutil/CharStream.h b/liblangutil/CharStream.h index 504c39da5..eb9b1f12b 100644 --- a/liblangutil/CharStream.h +++ b/liblangutil/CharStream.h @@ -56,7 +56,7 @@ #include #include -namespace langutil +namespace solidity::langutil { /** diff --git a/liblangutil/Common.h b/liblangutil/Common.h index a8d935270..d0f68a941 100644 --- a/liblangutil/Common.h +++ b/liblangutil/Common.h @@ -14,7 +14,7 @@ #pragma once -namespace langutil +namespace solidity::langutil { inline bool isDecimalDigit(char c) diff --git a/liblangutil/EVMVersion.cpp b/liblangutil/EVMVersion.cpp index 3d546a9e4..fa100c091 100644 --- a/liblangutil/EVMVersion.cpp +++ b/liblangutil/EVMVersion.cpp @@ -20,8 +20,9 @@ #include -using namespace langutil; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::langutil; bool EVMVersion::hasOpcode(Instruction _opcode) const { diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h index 5151d85a9..2c9e87ef3 100644 --- a/liblangutil/EVMVersion.h +++ b/liblangutil/EVMVersion.h @@ -28,7 +28,7 @@ #include -namespace langutil +namespace solidity::langutil { /** @@ -87,7 +87,7 @@ public: bool hasChainID() const { return *this >= istanbul(); } bool hasSelfBalance() const { return *this >= istanbul(); } - bool hasOpcode(dev::eth::Instruction _opcode) const; + bool hasOpcode(evmasm::Instruction _opcode) const; /// Whether we have to retain the costs for the call opcode itself (false), /// or whether we can just forward easily all remaining gas (true). diff --git a/liblangutil/ErrorReporter.cpp b/liblangutil/ErrorReporter.cpp index 7f8a77f1a..312f159c0 100644 --- a/liblangutil/ErrorReporter.cpp +++ b/liblangutil/ErrorReporter.cpp @@ -25,8 +25,8 @@ #include using namespace std; -using namespace dev; -using namespace langutil; +using namespace solidity; +using namespace solidity::langutil; ErrorReporter& ErrorReporter::operator=(ErrorReporter const& _errorReporter) { @@ -67,7 +67,7 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, st auto err = make_shared(_type); *err << errinfo_sourceLocation(_location) << - errinfo_comment(_description); + util::errinfo_comment(_description); m_errorList.push_back(err); } @@ -81,7 +81,7 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, Se *err << errinfo_sourceLocation(_location) << errinfo_secondarySourceLocation(_secondaryLocation) << - errinfo_comment(_description); + util::errinfo_comment(_description); m_errorList.push_back(err); } @@ -100,7 +100,7 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type) if (m_warningCount == c_maxWarningsAllowed) { auto err = make_shared(Error::Type::Warning); - *err << errinfo_comment("There are more than 256 warnings. Ignoring the rest."); + *err << util::errinfo_comment("There are more than 256 warnings. Ignoring the rest."); m_errorList.push_back(err); } @@ -114,7 +114,7 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type) if (m_errorCount > c_maxErrorsAllowed) { auto err = make_shared(Error::Type::Warning); - *err << errinfo_comment("There are more than 256 errors. Aborting."); + *err << util::errinfo_comment("There are more than 256 errors. Aborting."); m_errorList.push_back(err); BOOST_THROW_EXCEPTION(FatalError()); } diff --git a/liblangutil/ErrorReporter.h b/liblangutil/ErrorReporter.h index 6d6b4ef41..d4147e050 100644 --- a/liblangutil/ErrorReporter.h +++ b/liblangutil/ErrorReporter.h @@ -30,7 +30,7 @@ #include -namespace langutil +namespace solidity::langutil { class ErrorReporter @@ -98,7 +98,7 @@ public: auto filterEmpty = boost::adaptors::filtered([](std::string const& _s) { return !_s.empty(); }); - std::string errorStr = dev::joinHumanReadable(descs | filterEmpty, " "); + std::string errorStr = util::joinHumanReadable(descs | filterEmpty, " "); error(Error::Type::TypeError, _location, errorStr); } diff --git a/liblangutil/Exceptions.cpp b/liblangutil/Exceptions.cpp index 4fd411b6e..59d81b6e6 100644 --- a/liblangutil/Exceptions.cpp +++ b/liblangutil/Exceptions.cpp @@ -23,8 +23,8 @@ #include using namespace std; -using namespace dev; -using namespace langutil; +using namespace solidity; +using namespace solidity::langutil; Error::Error(Type _type, SourceLocation const& _location, string const& _description): m_type(_type) @@ -54,7 +54,7 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip if (!_location.isEmpty()) *this << errinfo_sourceLocation(_location); if (!_description.empty()) - *this << errinfo_comment(_description); + *this << util::errinfo_comment(_description); } Error::Error(Error::Type _type, std::string const& _description, SourceLocation const& _location): @@ -62,5 +62,5 @@ Error::Error(Error::Type _type, std::string const& _description, SourceLocation { if (!_location.isEmpty()) *this << errinfo_sourceLocation(_location); - *this << errinfo_comment(_description); + *this << util::errinfo_comment(_description); } diff --git a/liblangutil/Exceptions.h b/liblangutil/Exceptions.h index bffb256e6..93096ad75 100644 --- a/liblangutil/Exceptions.h +++ b/liblangutil/Exceptions.h @@ -31,27 +31,27 @@ #include #include -namespace langutil +namespace solidity::langutil { class Error; using ErrorList = std::vector>; -struct CompilerError: virtual dev::Exception {}; -struct InternalCompilerError: virtual dev::Exception {}; -struct FatalError: virtual dev::Exception {}; -struct UnimplementedFeatureError: virtual dev::Exception {}; +struct CompilerError: virtual util::Exception {}; +struct InternalCompilerError: virtual util::Exception {}; +struct FatalError: virtual util::Exception {}; +struct UnimplementedFeatureError: virtual util::Exception {}; /// Assertion that throws an InternalCompilerError containing the given description if it is not met. #define solAssert(CONDITION, DESCRIPTION) \ - assertThrow(CONDITION, ::langutil::InternalCompilerError, DESCRIPTION) + assertThrow(CONDITION, ::solidity::langutil::InternalCompilerError, DESCRIPTION) #define solUnimplementedAssert(CONDITION, DESCRIPTION) \ - assertThrow(CONDITION, ::langutil::UnimplementedFeatureError, DESCRIPTION) + assertThrow(CONDITION, ::solidity::langutil::UnimplementedFeatureError, DESCRIPTION) #define solUnimplemented(DESCRIPTION) \ solUnimplementedAssert(false, DESCRIPTION) -class Error: virtual public dev::Exception +class Error: virtual public util::Exception { public: enum class Type diff --git a/liblangutil/ParserBase.cpp b/liblangutil/ParserBase.cpp index 4ceb9358f..3c0fe0b89 100644 --- a/liblangutil/ParserBase.cpp +++ b/liblangutil/ParserBase.cpp @@ -25,7 +25,8 @@ #include using namespace std; -using namespace langutil; +using namespace solidity; +using namespace solidity::langutil; int ParserBase::position() const { diff --git a/liblangutil/ParserBase.h b/liblangutil/ParserBase.h index 98123b813..08f2a9dad 100644 --- a/liblangutil/ParserBase.h +++ b/liblangutil/ParserBase.h @@ -27,7 +27,7 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; diff --git a/liblangutil/Scanner.cpp b/liblangutil/Scanner.cpp index 4d5b34b9f..2db12225a 100644 --- a/liblangutil/Scanner.cpp +++ b/liblangutil/Scanner.cpp @@ -60,9 +60,10 @@ #include using namespace std; -using namespace langutil; -string langutil::to_string(ScannerError _errorCode) +namespace solidity::langutil { + +string to_string(ScannerError _errorCode) { switch (_errorCode) { @@ -84,14 +85,11 @@ string langutil::to_string(ScannerError _errorCode) } -ostream& langutil::operator<<(ostream& os, ScannerError _errorCode) +ostream& operator<<(ostream& os, ScannerError _errorCode) { return os << to_string(_errorCode); } -namespace langutil -{ - /// Scoped helper for literal recording. Automatically drops the literal /// if aborting the scanning before it's complete. enum LiteralType @@ -132,8 +130,6 @@ private: bool m_complete; }; -} - void Scanner::reset(CharStream _source) { m_source = make_shared(std::move(_source)); @@ -933,3 +929,5 @@ tuple Scanner::scanIdentifierOrKeyword() literal.complete(); return TokenTraits::fromIdentifierOrKeyword(m_nextToken.literal); } + +} // namespace solidity::langutil diff --git a/liblangutil/Scanner.h b/liblangutil/Scanner.h index f5b535cce..8dda74bfc 100644 --- a/liblangutil/Scanner.h +++ b/liblangutil/Scanner.h @@ -61,7 +61,7 @@ #include #include -namespace langutil +namespace solidity::langutil { class AstRawString; diff --git a/liblangutil/SemVerHandler.cpp b/liblangutil/SemVerHandler.cpp index cc414b1d7..04b81206e 100644 --- a/liblangutil/SemVerHandler.cpp +++ b/liblangutil/SemVerHandler.cpp @@ -25,8 +25,8 @@ #include using namespace std; -using namespace dev; -using namespace langutil; +using namespace solidity; +using namespace solidity::langutil; SemVerVersion::SemVerVersion(string const& _versionString) { diff --git a/liblangutil/SemVerHandler.h b/liblangutil/SemVerHandler.h index 09e6c6f4a..f5cdf860d 100644 --- a/liblangutil/SemVerHandler.h +++ b/liblangutil/SemVerHandler.h @@ -26,10 +26,10 @@ #include #include -namespace langutil +namespace solidity::langutil { -class SemVerError: dev::Exception +class SemVerError: util::Exception { }; diff --git a/liblangutil/SourceLocation.h b/liblangutil/SourceLocation.h index 7aafd03da..5f3d637e3 100644 --- a/liblangutil/SourceLocation.h +++ b/liblangutil/SourceLocation.h @@ -31,9 +31,9 @@ #include #include -namespace langutil +namespace solidity::langutil { -struct SourceLocationError: virtual dev::Exception {}; +struct SourceLocationError: virtual util::Exception {}; /** * Representation of an interval of source positions. diff --git a/liblangutil/SourceReferenceExtractor.cpp b/liblangutil/SourceReferenceExtractor.cpp index 1a6dbdb31..ff045a198 100644 --- a/liblangutil/SourceReferenceExtractor.cpp +++ b/liblangutil/SourceReferenceExtractor.cpp @@ -22,14 +22,14 @@ #include using namespace std; -using namespace dev; -using namespace langutil; +using namespace solidity; +using namespace solidity::langutil; -SourceReferenceExtractor::Message SourceReferenceExtractor::extract(Exception const& _exception, string _category) +SourceReferenceExtractor::Message SourceReferenceExtractor::extract(util::Exception const& _exception, string _category) { SourceLocation const* location = boost::get_error_info(_exception); - string const* message = boost::get_error_info(_exception); + string const* message = boost::get_error_info(_exception); SourceReference primary = extract(location, message ? *message : ""); std::vector secondary; diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h index bcbc50bc8..12f608409 100644 --- a/liblangutil/SourceReferenceExtractor.h +++ b/liblangutil/SourceReferenceExtractor.h @@ -21,12 +21,12 @@ #include #include -namespace dev +namespace solidity::util { struct Exception; } -namespace langutil +namespace solidity::langutil { struct LineColumn @@ -68,7 +68,7 @@ namespace SourceReferenceExtractor std::vector secondary; }; - Message extract(dev::Exception const& _exception, std::string _category); + Message extract(util::Exception const& _exception, std::string _category); SourceReference extract(SourceLocation const* _location, std::string message = ""); } diff --git a/liblangutil/SourceReferenceFormatter.cpp b/liblangutil/SourceReferenceFormatter.cpp index 01c1dd5ff..588733d27 100644 --- a/liblangutil/SourceReferenceFormatter.cpp +++ b/liblangutil/SourceReferenceFormatter.cpp @@ -25,8 +25,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; void SourceReferenceFormatter::printSourceLocation(SourceLocation const* _location) { @@ -70,7 +71,7 @@ void SourceReferenceFormatter::printSourceName(SourceReference const& _ref) m_stream << _ref.sourceName << ":" << (_ref.position.line + 1) << ":" << (_ref.position.column + 1) << ": "; } -void SourceReferenceFormatter::printExceptionInformation(dev::Exception const& _exception, std::string const& _category) +void SourceReferenceFormatter::printExceptionInformation(util::Exception const& _exception, std::string const& _category) { printExceptionInformation(SourceReferenceExtractor::extract(_exception, _category)); } diff --git a/liblangutil/SourceReferenceFormatter.h b/liblangutil/SourceReferenceFormatter.h index fee223088..439fe177c 100644 --- a/liblangutil/SourceReferenceFormatter.h +++ b/liblangutil/SourceReferenceFormatter.h @@ -28,12 +28,12 @@ #include #include -namespace dev +namespace solidity::util { struct Exception; // forward } -namespace langutil +namespace solidity::langutil { struct SourceLocation; class Scanner; @@ -52,7 +52,7 @@ public: virtual void printExceptionInformation(SourceReferenceExtractor::Message const& _msg); virtual void printSourceLocation(SourceLocation const* _location); - virtual void printExceptionInformation(dev::Exception const& _exception, std::string const& _category); + virtual void printExceptionInformation(util::Exception const& _exception, std::string const& _category); virtual void printErrorInformation(Error const& _error); static std::string formatErrorInformation(Error const& _error) @@ -64,7 +64,7 @@ public: } static std::string formatExceptionInformation( - dev::Exception const& _exception, + util::Exception const& _exception, std::string const& _name ) { diff --git a/liblangutil/SourceReferenceFormatterHuman.cpp b/liblangutil/SourceReferenceFormatterHuman.cpp index de288df91..6cd5620fb 100644 --- a/liblangutil/SourceReferenceFormatterHuman.cpp +++ b/liblangutil/SourceReferenceFormatterHuman.cpp @@ -25,9 +25,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::formatting; -using namespace langutil; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::util; +using namespace solidity::util::formatting; AnsiColorized SourceReferenceFormatterHuman::normalColored() const { diff --git a/liblangutil/SourceReferenceFormatterHuman.h b/liblangutil/SourceReferenceFormatterHuman.h index a5e803894..a04344a8b 100644 --- a/liblangutil/SourceReferenceFormatterHuman.h +++ b/liblangutil/SourceReferenceFormatterHuman.h @@ -29,12 +29,12 @@ #include #include -namespace dev +namespace solidity::util { struct Exception; // forward } -namespace langutil +namespace solidity::langutil { struct SourceLocation; @@ -52,7 +52,7 @@ public: using SourceReferenceFormatter::printExceptionInformation; static std::string formatExceptionInformation( - dev::Exception const& _exception, + util::Exception const& _exception, std::string const& _name, bool colored = false ) @@ -65,13 +65,13 @@ public: } private: - dev::AnsiColorized normalColored() const; - dev::AnsiColorized frameColored() const; - dev::AnsiColorized errorColored() const; - dev::AnsiColorized messageColored() const; - dev::AnsiColorized secondaryColored() const; - dev::AnsiColorized highlightColored() const; - dev::AnsiColorized diagColored() const; + util::AnsiColorized normalColored() const; + util::AnsiColorized frameColored() const; + util::AnsiColorized errorColored() const; + util::AnsiColorized messageColored() const; + util::AnsiColorized secondaryColored() const; + util::AnsiColorized highlightColored() const; + util::AnsiColorized diagColored() const; private: bool m_colored; diff --git a/liblangutil/Token.cpp b/liblangutil/Token.cpp index 4ac548cf3..e051bb552 100644 --- a/liblangutil/Token.cpp +++ b/liblangutil/Token.cpp @@ -46,7 +46,7 @@ using namespace std; -namespace langutil +namespace solidity::langutil { void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second) @@ -82,7 +82,6 @@ void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _fi namespace TokenTraits { - char const* toString(Token tok) { switch (tok) diff --git a/liblangutil/Token.h b/liblangutil/Token.h index 98d832fe3..ee76605fe 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -50,7 +50,7 @@ #include #include -namespace langutil +namespace solidity::langutil { // TOKEN_LIST takes a list of 3 macros M, all of which satisfy the diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 714515d96..36f282feb 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -608,7 +608,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) int targetDeposit = hasDefault ? code[code.size() - 1].m_asm.deposit() : 0; // The conditions - eth::AssemblyItems jumpTags; + evmasm::AssemblyItems jumpTags; for (unsigned i = 0; i < code.size() - 1; i += 2) { requireDeposit(i, 1); @@ -675,7 +675,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) requireMaxSize(3); requireDeposit(1, 1); - auto subPush = m_asm.appendSubroutine(make_shared(code[0].assembly(ns))); + auto subPush = m_asm.appendSubroutine(make_shared(code[0].assembly(ns))); m_asm.append(Instruction::DUP1); if (code.size() == 3) { diff --git a/liblll/CodeFragment.h b/liblll/CodeFragment.h index cbdf86766..cd6ad6f3e 100644 --- a/liblll/CodeFragment.h +++ b/liblll/CodeFragment.h @@ -47,7 +47,7 @@ public: static CodeFragment compile(std::string _src, CompilerState& _s, ReadCallback const& _readFile); /// Consolidates data and compiles code. - eth::Assembly& assembly(CompilerState const& _cs) { finalise(_cs); return m_asm; } + evmasm::Assembly& assembly(CompilerState const& _cs) { finalise(_cs); return m_asm; } private: void finalise(CompilerState const& _cs); @@ -61,7 +61,7 @@ private: void constructOperation(sp::utree const& _t, CompilerState& _s); bool m_finalised = false; - eth::Assembly m_asm; + evmasm::Assembly m_asm; ReadCallback m_readFile; }; diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp index 23b9fb899..8e8afe899 100644 --- a/libsolc/libsolc.cpp +++ b/libsolc/libsolc.cpp @@ -34,8 +34,11 @@ #include "license.h" using namespace std; -using namespace dev; using namespace solidity; +using namespace solidity::util; + +using solidity::frontend::ReadCallback; +using solidity::frontend::StandardCompiler; namespace { @@ -122,7 +125,7 @@ extern char const* solidity_license() noexcept extern char const* solidity_version() noexcept { - return VersionString.c_str(); + return frontend::VersionString.c_str(); } extern char* solidity_compile(char const* _input, CStyleReadFileCallback _readCallback, void* _readContext) noexcept diff --git a/libsolidity/analysis/ConstantEvaluator.cpp b/libsolidity/analysis/ConstantEvaluator.cpp index c63d1b127..d48d640ce 100644 --- a/libsolidity/analysis/ConstantEvaluator.cpp +++ b/libsolidity/analysis/ConstantEvaluator.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; void ConstantEvaluator::endVisit(UnaryOperation const& _operation) { diff --git a/libsolidity/analysis/ConstantEvaluator.h b/libsolidity/analysis/ConstantEvaluator.h index 23ca36286..0f2dd558e 100644 --- a/libsolidity/analysis/ConstantEvaluator.h +++ b/libsolidity/analysis/ConstantEvaluator.h @@ -24,14 +24,12 @@ #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class TypeChecker; @@ -72,4 +70,3 @@ private: }; } -} diff --git a/libsolidity/analysis/ContractLevelChecker.cpp b/libsolidity/analysis/ContractLevelChecker.cpp index 069bd4d94..9cbe21894 100644 --- a/libsolidity/analysis/ContractLevelChecker.cpp +++ b/libsolidity/analysis/ContractLevelChecker.cpp @@ -30,9 +30,9 @@ using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; namespace { @@ -361,10 +361,10 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contract) { - set> hashes; + set> hashes; for (auto const& it: _contract.interfaceFunctionList()) { - FixedHash<4> const& hash = it.first; + util::FixedHash<4> const& hash = it.first; if (hashes.count(hash)) m_errorReporter.typeError( _contract.location(), diff --git a/libsolidity/analysis/ContractLevelChecker.h b/libsolidity/analysis/ContractLevelChecker.h index b9ac5b7a9..919c35c07 100644 --- a/libsolidity/analysis/ContractLevelChecker.h +++ b/libsolidity/analysis/ContractLevelChecker.h @@ -28,14 +28,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -90,4 +88,3 @@ private: }; } -} diff --git a/libsolidity/analysis/ControlFlowAnalyzer.cpp b/libsolidity/analysis/ControlFlowAnalyzer.cpp index e12a3b1b6..84088cc42 100644 --- a/libsolidity/analysis/ControlFlowAnalyzer.cpp +++ b/libsolidity/analysis/ControlFlowAnalyzer.cpp @@ -22,8 +22,8 @@ #include using namespace std; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; bool ControlFlowAnalyzer::analyze(ASTNode const& _astRoot) { @@ -151,7 +151,7 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const* _exit, CFGNode const* _revert) const { // collect all nodes reachable from the entry point - std::set reachable = BreadthFirstSearch{{_entry}}.run( + std::set reachable = util::BreadthFirstSearch{{_entry}}.run( [](CFGNode const* _node, auto&& _addChild) { for (CFGNode const* exit: _node->exits) _addChild(exit); @@ -161,7 +161,7 @@ void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const* // traverse all paths backwards from exit and revert // and extract (valid) source locations of unreachable nodes into sorted set std::set unreachable; - BreadthFirstSearch{{_exit, _revert}}.run( + util::BreadthFirstSearch{{_exit, _revert}}.run( [&](CFGNode const* _node, auto&& _addChild) { if (!reachable.count(_node) && !_node->location.isEmpty()) unreachable.insert(_node->location); diff --git a/libsolidity/analysis/ControlFlowAnalyzer.h b/libsolidity/analysis/ControlFlowAnalyzer.h index e1585740c..24af990ab 100644 --- a/libsolidity/analysis/ControlFlowAnalyzer.h +++ b/libsolidity/analysis/ControlFlowAnalyzer.h @@ -20,9 +20,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ControlFlowAnalyzer: private ASTConstVisitor @@ -47,4 +45,3 @@ private: }; } -} diff --git a/libsolidity/analysis/ControlFlowBuilder.cpp b/libsolidity/analysis/ControlFlowBuilder.cpp index 235118604..c7504897b 100644 --- a/libsolidity/analysis/ControlFlowBuilder.cpp +++ b/libsolidity/analysis/ControlFlowBuilder.cpp @@ -17,9 +17,9 @@ #include -using namespace dev; -using namespace langutil; using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; using namespace std; ControlFlowBuilder::ControlFlowBuilder(CFG::NodeContainer& _nodeContainer, FunctionFlow const& _functionFlow): diff --git a/libsolidity/analysis/ControlFlowBuilder.h b/libsolidity/analysis/ControlFlowBuilder.h index 91b112eb5..ecdedfbfe 100644 --- a/libsolidity/analysis/ControlFlowBuilder.h +++ b/libsolidity/analysis/ControlFlowBuilder.h @@ -24,8 +24,7 @@ #include #include -namespace dev { -namespace solidity { +namespace solidity::frontend { /** Helper class that builds the control flow of a function or modifier. * Modifiers are not yet applied to the functions. This is done in a second @@ -161,4 +160,3 @@ private: }; } -} diff --git a/libsolidity/analysis/ControlFlowGraph.cpp b/libsolidity/analysis/ControlFlowGraph.cpp index 8960166a0..244321abc 100644 --- a/libsolidity/analysis/ControlFlowGraph.cpp +++ b/libsolidity/analysis/ControlFlowGraph.cpp @@ -22,8 +22,8 @@ #include using namespace std; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; bool CFG::constructFlow(ASTNode const& _astRoot) { diff --git a/libsolidity/analysis/ControlFlowGraph.h b/libsolidity/analysis/ControlFlowGraph.h index 506cce03f..e40bb7623 100644 --- a/libsolidity/analysis/ControlFlowGraph.h +++ b/libsolidity/analysis/ControlFlowGraph.h @@ -27,9 +27,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -154,4 +152,3 @@ private: }; } -} diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index 463510436..036511d33 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; Declaration const* DeclarationContainer::conflictingDeclaration( Declaration const& _declaration, @@ -118,7 +118,7 @@ bool DeclarationContainer::registerDeclaration( return false; vector& decls = _invisible ? m_invisibleDeclarations[*_name] : m_declarations[*_name]; - if (!contains(decls, &_declaration)) + if (!util::contains(decls, &_declaration)) decls.push_back(&_declaration); return true; } @@ -148,13 +148,13 @@ vector DeclarationContainer::similarNames(ASTString const& _name) con for (auto const& declaration: m_declarations) { string const& declarationName = declaration.first; - if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD)) + if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD)) similar.push_back(declarationName); } for (auto const& declaration: m_invisibleDeclarations) { string const& declarationName = declaration.first; - if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD)) + if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD)) similar.push_back(declarationName); } diff --git a/libsolidity/analysis/DeclarationContainer.h b/libsolidity/analysis/DeclarationContainer.h index 9ef5e1c43..4b4df9339 100644 --- a/libsolidity/analysis/DeclarationContainer.h +++ b/libsolidity/analysis/DeclarationContainer.h @@ -27,9 +27,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -76,4 +74,3 @@ private: }; } -} diff --git a/libsolidity/analysis/DocStringAnalyser.cpp b/libsolidity/analysis/DocStringAnalyser.cpp index 3bcc87660..1b3bd598b 100644 --- a/libsolidity/analysis/DocStringAnalyser.cpp +++ b/libsolidity/analysis/DocStringAnalyser.cpp @@ -28,9 +28,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit) { diff --git a/libsolidity/analysis/DocStringAnalyser.h b/libsolidity/analysis/DocStringAnalyser.h index 8d3658ac8..653413346 100644 --- a/libsolidity/analysis/DocStringAnalyser.h +++ b/libsolidity/analysis/DocStringAnalyser.h @@ -25,14 +25,12 @@ #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -82,4 +80,3 @@ private: }; } -} diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index 15c29d37e..2a4ce374b 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -30,9 +30,7 @@ using namespace std; -namespace dev -{ -namespace solidity +namespace solidity::frontend { inline vector> constructMagicVariables() @@ -112,4 +110,3 @@ MagicVariableDeclaration const* GlobalContext::currentSuper() const } } -} diff --git a/libsolidity/analysis/GlobalContext.h b/libsolidity/analysis/GlobalContext.h index 09611c41f..81ffa2109 100644 --- a/libsolidity/analysis/GlobalContext.h +++ b/libsolidity/analysis/GlobalContext.h @@ -29,9 +29,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class Type; // forward @@ -61,4 +59,3 @@ private: }; } -} diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 6881e14d6..7995ae6c9 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -29,11 +29,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity +namespace solidity::frontend { NameAndTypeResolver::NameAndTypeResolver( @@ -244,7 +242,7 @@ vector NameAndTypeResolver::cleanedDeclarations( void NameAndTypeResolver::warnVariablesNamedLikeInstructions() { - for (auto const& instruction: dev::eth::c_instructions) + for (auto const& instruction: evmasm::c_instructions) { string const instructionName{boost::algorithm::to_lower_copy(instruction.first)}; auto declarations = nameFromCurrentScope(instructionName, true); @@ -460,7 +458,7 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list>& _toMer string NameAndTypeResolver::similarNameSuggestions(ASTString const& _name) const { - return quotedAlternativesList(m_currentScope->similarNames(_name)); + return util::quotedAlternativesList(m_currentScope->similarNames(_name)); } DeclarationRegistrationHelper::DeclarationRegistrationHelper( @@ -786,4 +784,3 @@ string DeclarationRegistrationHelper::currentCanonicalName() const } } -} diff --git a/libsolidity/analysis/NameAndTypeResolver.h b/libsolidity/analysis/NameAndTypeResolver.h index 4499071bc..b8ae2fefb 100644 --- a/libsolidity/analysis/NameAndTypeResolver.h +++ b/libsolidity/analysis/NameAndTypeResolver.h @@ -35,14 +35,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -214,4 +212,3 @@ private: }; } -} diff --git a/libsolidity/analysis/OverrideChecker.cpp b/libsolidity/analysis/OverrideChecker.cpp index addb5dd9b..f401020d1 100644 --- a/libsolidity/analysis/OverrideChecker.cpp +++ b/libsolidity/analysis/OverrideChecker.cpp @@ -32,9 +32,13 @@ using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; +using namespace solidity::langutil; + +using solidity::util::GenericVisitor; +using solidity::util::contains_if; +using solidity::util::joinHumanReadable; namespace { diff --git a/libsolidity/analysis/OverrideChecker.h b/libsolidity/analysis/OverrideChecker.h index 6ad6b0631..48fa54314 100644 --- a/libsolidity/analysis/OverrideChecker.h +++ b/libsolidity/analysis/OverrideChecker.h @@ -29,15 +29,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class FunctionType; class ModifierType; @@ -193,4 +191,3 @@ private: }; } -} diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index 0647a0c64..0c3cc4afe 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -27,9 +27,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; bool PostTypeChecker::check(ASTNode const& _astRoot) { @@ -128,7 +128,7 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker VariableDeclaration const* findCycle(VariableDeclaration const& _startingFrom) { - auto visitor = [&](VariableDeclaration const& _variable, CycleDetector& _cycleDetector, size_t _depth) + auto visitor = [&](VariableDeclaration const& _variable, util::CycleDetector& _cycleDetector, size_t _depth) { if (_depth >= 256) m_errorReporter.fatalDeclarationError(_variable.location(), "Variable definition exhausting cyclic dependency validator."); @@ -148,7 +148,7 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker if (_cycleDetector.run(*v)) return; }; - return CycleDetector(visitor).run(_startingFrom); + return util::CycleDetector(visitor).run(_startingFrom); } private: diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index d89885ade..a772643f8 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -23,15 +23,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -93,4 +91,3 @@ private: }; } -} diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 815cf184a..7c809ad83 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -40,11 +40,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity +namespace solidity::frontend { bool ReferencesResolver::resolve(ASTNode const& _root) @@ -405,7 +403,7 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable) else { errorString = "Data location must be " + - joinHumanReadable( + util::joinHumanReadable( allowedDataLocations | boost::adaptors::transformed(locationToString), ", ", " or " @@ -501,4 +499,3 @@ void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, } } -} diff --git a/libsolidity/analysis/ReferencesResolver.h b/libsolidity/analysis/ReferencesResolver.h index f1e512ab0..a368f7d39 100644 --- a/libsolidity/analysis/ReferencesResolver.h +++ b/libsolidity/analysis/ReferencesResolver.h @@ -30,15 +30,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class NameAndTypeResolver; @@ -110,4 +108,3 @@ private: }; } -} diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index bfdd3ba22..c53bc03fa 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -28,14 +28,14 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; /** * Helper class that determines whether a contract's constructor uses inline assembly. */ -class dev::solidity::ConstructorUsesAssembly +class solidity::frontend::ConstructorUsesAssembly { public: /// @returns true if and only if the contract's or any of its bases' constructors diff --git a/libsolidity/analysis/StaticAnalyzer.h b/libsolidity/analysis/StaticAnalyzer.h index 3daf83b31..f3ed30b20 100644 --- a/libsolidity/analysis/StaticAnalyzer.h +++ b/libsolidity/analysis/StaticAnalyzer.h @@ -28,14 +28,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ConstructorUsesAssembly; @@ -102,4 +100,3 @@ private: }; } -} diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index aa90d174f..666c15dc5 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -34,9 +34,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; bool SyntaxChecker::checkSyntax(ASTNode const& _astRoot) diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index bf2cf9ff6..78aa6b82f 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -23,14 +23,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -109,4 +107,3 @@ private: }; } -} diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 26f473ee1..a7f4c8762 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -42,9 +42,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend; bool TypeChecker::typeSupportedByOldABIEncoder(Type const& _type, bool _isLibraryCall) { diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 94bed89e5..ae83559d5 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -29,14 +29,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -179,4 +177,3 @@ private: }; } -} diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 4da77ead7..073e453be 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -26,9 +26,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; namespace { @@ -110,11 +110,11 @@ public: } private: - void checkInstruction(SourceLocation _location, dev::eth::Instruction _instruction) + void checkInstruction(SourceLocation _location, evmasm::Instruction _instruction) { - if (eth::SemanticInformation::invalidInViewFunctions(_instruction)) + if (evmasm::SemanticInformation::invalidInViewFunctions(_instruction)) m_reportMutability(StateMutability::NonPayable, _location); - else if (eth::SemanticInformation::invalidInPureFunctions(_instruction)) + else if (evmasm::SemanticInformation::invalidInPureFunctions(_instruction)) m_reportMutability(StateMutability::View, _location); } diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h index f49c25ca7..10e60f051 100644 --- a/libsolidity/analysis/ViewPureChecker.h +++ b/libsolidity/analysis/ViewPureChecker.h @@ -25,15 +25,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ViewPureChecker: private ASTConstVisitor @@ -82,4 +80,3 @@ private: }; } -} diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index a7d5e73ca..e8065c370 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -32,8 +32,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; class IDDispenser { @@ -114,11 +114,11 @@ vector ContractDefinition::stateVariablesIncludingIn return stateVars; } -map, FunctionTypePointer> ContractDefinition::interfaceFunctions() const +map, FunctionTypePointer> ContractDefinition::interfaceFunctions() const { auto exportedFunctionList = interfaceFunctionList(); - map, FunctionTypePointer> exportedFunctions; + map, FunctionTypePointer> exportedFunctions; for (auto const& it: exportedFunctionList) exportedFunctions.insert(it); @@ -192,12 +192,12 @@ vector const& ContractDefinition::interfaceEvents() cons return *m_interfaceEvents; } -vector, FunctionTypePointer>> const& ContractDefinition::interfaceFunctionList() const +vector, FunctionTypePointer>> const& ContractDefinition::interfaceFunctionList() const { if (!m_interfaceFunctionList) { set signaturesSeen; - m_interfaceFunctionList = make_unique, FunctionTypePointer>>>(); + m_interfaceFunctionList = make_unique, FunctionTypePointer>>>(); for (ContractDefinition const* contract: annotation().linearizedBaseContracts) { vector functions; @@ -216,7 +216,7 @@ vector, FunctionTypePointer>> const& ContractDefinition::inter if (signaturesSeen.count(functionSignature) == 0) { signaturesSeen.insert(functionSignature); - FixedHash<4> hash(dev::keccak256(functionSignature)); + util::FixedHash<4> hash(util::keccak256(functionSignature)); m_interfaceFunctionList->emplace_back(hash, fun); } } @@ -749,7 +749,7 @@ bool Literal::looksLikeAddress() const bool Literal::passesAddressChecksum() const { solAssert(isHexNumber(), "Expected hex number"); - return dev::passesAddressChecksum(valueWithoutUnderscores(), true); + return util::passesAddressChecksum(valueWithoutUnderscores(), true); } string Literal::getChecksummedAddress() const @@ -760,5 +760,5 @@ string Literal::getChecksummedAddress() const if (address.length() > 40) return string(); address.insert(address.begin(), 40 - address.size(), '0'); - return dev::getChecksummedAddress(address); + return util::getChecksummedAddress(address); } diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index f687f20c9..203914bdb 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -40,16 +40,14 @@ #include #include -namespace yul +namespace solidity::yul { // Forward-declaration to struct Block; struct Dialect; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ASTVisitor; @@ -416,8 +414,8 @@ public: /// @returns a map of canonical function signatures to FunctionDefinitions /// as intended for use by the ABI. - std::map, FunctionTypePointer> interfaceFunctions() const; - std::vector, FunctionTypePointer>> const& interfaceFunctionList() const; + std::map, FunctionTypePointer> interfaceFunctions() const; + std::vector, FunctionTypePointer>> const& interfaceFunctionList() const; /// @returns a list of the inheritable members of this contract std::vector const& inheritableMembers() const; @@ -452,7 +450,7 @@ private: ContractKind m_contractKind; bool m_abstract{false}; - mutable std::unique_ptr, FunctionTypePointer>>> m_interfaceFunctionList; + mutable std::unique_ptr, FunctionTypePointer>>> m_interfaceFunctionList; mutable std::unique_ptr> m_interfaceEvents; mutable std::unique_ptr> m_inheritableMembers; }; @@ -1905,6 +1903,4 @@ private: /// @} - -} } diff --git a/libsolidity/ast/ASTAnnotations.cpp b/libsolidity/ast/ASTAnnotations.cpp index 0f958a383..eb3caf721 100644 --- a/libsolidity/ast/ASTAnnotations.cpp +++ b/libsolidity/ast/ASTAnnotations.cpp @@ -23,6 +23,6 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 0f11b1c5a..ea7ca8590 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -32,16 +32,14 @@ #include #include -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; struct Identifier; struct Dialect; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class Type; @@ -252,4 +250,3 @@ struct FunctionCallAnnotation: ExpressionAnnotation }; } -} diff --git a/libsolidity/ast/ASTEnums.h b/libsolidity/ast/ASTEnums.h index 3ad329498..2eb6a99b0 100644 --- a/libsolidity/ast/ASTEnums.h +++ b/libsolidity/ast/ASTEnums.h @@ -26,9 +26,7 @@ #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { // How a function can mutate the EVM state. @@ -70,4 +68,3 @@ struct FuncCallArguments }; } -} diff --git a/libsolidity/ast/ASTForward.h b/libsolidity/ast/ASTForward.h index b84554563..a455f30b2 100644 --- a/libsolidity/ast/ASTForward.h +++ b/libsolidity/ast/ASTForward.h @@ -28,14 +28,12 @@ // Forward-declare all AST node types and related enums. -namespace langutil +namespace solidity::langutil { enum class Token : unsigned int; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ASTNode; @@ -107,4 +105,3 @@ using ASTPointer = std::shared_ptr; using ASTString = std::string; } -} diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index b7b8e9cbc..d42a4d8f4 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -36,11 +36,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity +namespace solidity::frontend { ASTJsonConverter::ASTJsonConverter(bool _legacy, map _sourceIndices): @@ -200,7 +198,7 @@ Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair> attributes = { make_pair(m_legacy ? "token" : "kind", literalTokenKind(_node.token())), make_pair("value", value), - make_pair(m_legacy ? "hexvalue" : "hexValue", toHex(asBytes(_node.value()))), + make_pair(m_legacy ? "hexvalue" : "hexValue", util::toHex(util::asBytes(_node.value()))), make_pair( "subdenomination", subdenomination == Token::Illegal ? @@ -869,13 +867,13 @@ string ASTJsonConverter::literalTokenKind(Token _token) { switch (_token) { - case dev::solidity::Token::Number: + case Token::Number: return "number"; - case dev::solidity::Token::StringLiteral: - case dev::solidity::Token::HexStringLiteral: + case Token::StringLiteral: + case Token::HexStringLiteral: return "string"; - case dev::solidity::Token::TrueLiteral: - case dev::solidity::Token::FalseLiteral: + case Token::TrueLiteral: + case Token::FalseLiteral: return "bool"; default: solAssert(false, "Unknown kind of literal token."); @@ -893,4 +891,3 @@ string ASTJsonConverter::type(VariableDeclaration const& _varDecl) } } -} diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index 10cc5581d..33a1be26a 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -34,14 +34,12 @@ #include #include -namespace langutil +namespace solidity::langutil { struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -194,4 +192,3 @@ private: }; } -} diff --git a/libsolidity/ast/ASTUtils.cpp b/libsolidity/ast/ASTUtils.cpp index 991083dee..d903a1b4b 100644 --- a/libsolidity/ast/ASTUtils.cpp +++ b/libsolidity/ast/ASTUtils.cpp @@ -18,9 +18,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { VariableDeclaration const* rootVariableDeclaration(VariableDeclaration const& _varDecl) @@ -39,4 +37,3 @@ VariableDeclaration const* rootVariableDeclaration(VariableDeclaration const& _v } } -} diff --git a/libsolidity/ast/ASTUtils.h b/libsolidity/ast/ASTUtils.h index 67841f1ce..7624080a9 100644 --- a/libsolidity/ast/ASTUtils.h +++ b/libsolidity/ast/ASTUtils.h @@ -17,14 +17,13 @@ #pragma once -namespace dev -{ -namespace solidity +namespace solidity::frontend { +class VariableDeclaration; + /// Find the topmost referenced variable declaration when the given variable /// declaration value is an identifier. Works only for constant variable declarations. VariableDeclaration const* rootVariableDeclaration(VariableDeclaration const& _varDecl); } -} diff --git a/libsolidity/ast/ASTVisitor.h b/libsolidity/ast/ASTVisitor.h index ed328633f..52e0db4bc 100644 --- a/libsolidity/ast/ASTVisitor.h +++ b/libsolidity/ast/ASTVisitor.h @@ -27,9 +27,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -329,4 +327,3 @@ private: }; } -} diff --git a/libsolidity/ast/AST_accept.h b/libsolidity/ast/AST_accept.h index 05adf7352..ebbce88fb 100644 --- a/libsolidity/ast/AST_accept.h +++ b/libsolidity/ast/AST_accept.h @@ -26,9 +26,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { void SourceUnit::accept(ASTVisitor& _visitor) @@ -896,4 +894,3 @@ void Literal::accept(ASTConstVisitor& _visitor) const } } -} diff --git a/libsolidity/ast/ExperimentalFeatures.h b/libsolidity/ast/ExperimentalFeatures.h index e0757564b..6fdc6897b 100644 --- a/libsolidity/ast/ExperimentalFeatures.h +++ b/libsolidity/ast/ExperimentalFeatures.h @@ -23,9 +23,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { enum class ExperimentalFeature @@ -52,4 +50,3 @@ static std::map const ExperimentalFeatureNames }; } -} diff --git a/libsolidity/ast/TypeProvider.cpp b/libsolidity/ast/TypeProvider.cpp index e36710e90..749a77655 100644 --- a/libsolidity/ast/TypeProvider.cpp +++ b/libsolidity/ast/TypeProvider.cpp @@ -21,8 +21,9 @@ #include using namespace std; -using namespace dev; using namespace solidity; +using namespace solidity::frontend; +using namespace solidity::util; BoolType const TypeProvider::m_boolean{}; InaccessibleDynamicType const TypeProvider::m_inaccessibleDynamic{}; diff --git a/libsolidity/ast/TypeProvider.h b/libsolidity/ast/TypeProvider.h index 4f33c556b..1932ae919 100644 --- a/libsolidity/ast/TypeProvider.h +++ b/libsolidity/ast/TypeProvider.h @@ -25,9 +25,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -225,5 +223,4 @@ private: std::vector> m_generalTypes{}; }; -} // namespace solidity -} // namespace dev +} diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index b8228f121..7e140e9c4 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -45,9 +45,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; namespace { @@ -131,7 +131,7 @@ bool fitsIntoBits(bigint const& _value, unsigned _bits, bool _signed) )); } -Result transformParametersToExternal(TypePointers const& _parameters, bool _inLibrary) +util::Result transformParametersToExternal(TypePointers const& _parameters, bool _inLibrary) { TypePointers transformed; @@ -140,7 +140,7 @@ Result transformParametersToExternal(TypePointers const& _paramete if (TypePointer ext = type->interfaceType(_inLibrary).get()) transformed.push_back(ext); else - return Result::err("Parameter should have external type."); + return util::Result::err("Parameter should have external type."); } return transformed; @@ -170,7 +170,7 @@ void StorageOffsets::computeOffsets(TypePointers const& _types) byteOffset = 0; } if (slotOffset >= bigint(1) << 256) - BOOST_THROW_EXCEPTION(Error(Error::Type::TypeError) << errinfo_comment("Object too large for storage.")); + BOOST_THROW_EXCEPTION(Error(Error::Type::TypeError) << util::errinfo_comment("Object too large for storage.")); offsets[i] = make_pair(u256(slotOffset), byteOffset); solAssert(type->storageSize() >= 1, "Invalid storage size."); if (type->storageSize() == 1 && byteOffset + type->storageBytes() <= 32) @@ -184,7 +184,7 @@ void StorageOffsets::computeOffsets(TypePointers const& _types) if (byteOffset > 0) ++slotOffset; if (slotOffset >= bigint(1) << 256) - BOOST_THROW_EXCEPTION(Error(Error::Type::TypeError) << errinfo_comment("Object too large for storage.")); + BOOST_THROW_EXCEPTION(Error(Error::Type::TypeError) << util::errinfo_comment("Object too large for storage.")); m_storageSize = u256(slotOffset); swap(m_offsets, offsets); } @@ -486,7 +486,7 @@ IntegerType::IntegerType(unsigned _bits, IntegerType::Modifier _modifier): { solAssert( m_bits > 0 && m_bits <= 256 && m_bits % 8 == 0, - "Invalid bit number for integer type: " + dev::toString(m_bits) + "Invalid bit number for integer type: " + util::toString(m_bits) ); } @@ -550,7 +550,7 @@ bool IntegerType::operator==(Type const& _other) const string IntegerType::toString(bool) const { string prefix = isSigned() ? "int" : "uint"; - return prefix + dev::toString(m_bits); + return prefix + util::toString(m_bits); } bigint IntegerType::minValue() const @@ -615,7 +615,7 @@ FixedPointType::FixedPointType(unsigned _totalBits, unsigned _fractionalDigits, solAssert( 8 <= m_totalBits && m_totalBits <= 256 && m_totalBits % 8 == 0 && m_fractionalDigits <= 80, "Invalid bit number(s) for fixed type: " + - dev::toString(_totalBits) + "x" + dev::toString(_fractionalDigits) + util::toString(_totalBits) + "x" + util::toString(_fractionalDigits) ); } @@ -673,7 +673,7 @@ bool FixedPointType::operator==(Type const& _other) const string FixedPointType::toString(bool) const { string prefix = isSigned() ? "fixed" : "ufixed"; - return prefix + dev::toString(m_totalBits) + "x" + dev::toString(m_fractionalDigits); + return prefix + util::toString(m_totalBits) + "x" + util::toString(m_fractionalDigits); } bigint FixedPointType::maxIntegerValue() const @@ -1134,7 +1134,7 @@ bool RationalNumberType::operator==(Type const& _other) const return m_value == other.m_value; } -string RationalNumberType::bigintToReadableString(dev::bigint const& _num) +string RationalNumberType::bigintToReadableString(bigint const& _num) { string str = _num.str(); if (str.size() > 32) @@ -1203,7 +1203,7 @@ IntegerType const* RationalNumberType::integerType() const return nullptr; else return TypeProvider::integer( - max(bytesRequired(value), 1u) * 8, + max(util::bytesRequired(value), 1u) * 8, negative ? IntegerType::Modifier::Signed : IntegerType::Modifier::Unsigned ); } @@ -1237,7 +1237,7 @@ FixedPointType const* RationalNumberType::fixedPointType() const if (v > u256(-1)) return nullptr; - unsigned totalBits = max(bytesRequired(v), 1u) * 8; + unsigned totalBits = max(util::bytesRequired(v), 1u) * 8; solAssert(totalBits <= 256, ""); return TypeProvider::fixedPoint( @@ -1273,7 +1273,7 @@ string StringLiteralType::richIdentifier() const { // Since we have to return a valid identifier and the string itself may contain // anything, we hash it. - return "t_stringliteral_" + toHex(keccak256(m_value).asBytes()); + return "t_stringliteral_" + util::toHex(util::keccak256(m_value).asBytes()); } bool StringLiteralType::operator==(Type const& _other) const @@ -1287,8 +1287,8 @@ std::string StringLiteralType::toString(bool) const { size_t invalidSequence; - if (!dev::validateUTF8(m_value, invalidSequence)) - return "literal_string (contains invalid UTF-8 sequence at position " + dev::toString(invalidSequence) + ")"; + if (!util::validateUTF8(m_value, invalidSequence)) + return "literal_string (contains invalid UTF-8 sequence at position " + util::toString(invalidSequence) + ")"; return "literal_string \"" + m_value + "\""; } @@ -1300,14 +1300,14 @@ TypePointer StringLiteralType::mobileType() const bool StringLiteralType::isValidUTF8() const { - return dev::validateUTF8(m_value); + return util::validateUTF8(m_value); } FixedBytesType::FixedBytesType(unsigned _bytes): m_bytes(_bytes) { solAssert( m_bytes > 0 && m_bytes <= 32, - "Invalid byte number for fixed bytes type: " + dev::toString(m_bytes) + "Invalid byte number for fixed bytes type: " + util::toString(m_bytes) ); } @@ -1697,7 +1697,7 @@ u256 ArrayType::storageSize() const else size = bigint(length()) * baseType()->storageSize(); if (size >= bigint(1) << 256) - BOOST_THROW_EXCEPTION(Error(Error::Type::TypeError) << errinfo_comment("Array too large for storage.")); + BOOST_THROW_EXCEPTION(Error(Error::Type::TypeError) << util::errinfo_comment("Array too large for storage.")); return max(1, u256(size)); } @@ -2145,7 +2145,7 @@ TypeResult StructType::interfaceType(bool _inLibrary) const auto visitor = [&]( StructDefinition const& _struct, - CycleDetector& _cycleDetector, + util::CycleDetector& _cycleDetector, size_t /*_depth*/ ) { @@ -2193,7 +2193,7 @@ TypeResult StructType::interfaceType(bool _inLibrary) const } }; - m_recursive = m_recursive.value() || (CycleDetector(visitor).run(structDefinition()) != nullptr); + m_recursive = m_recursive.value() || (util::CycleDetector(visitor).run(structDefinition()) != nullptr); std::string const recursiveErrMsg = "Recursive type not allowed for public or external contract functions."; @@ -2338,7 +2338,7 @@ unsigned EnumType::storageBytes() const if (elements <= 1) return 1; else - return dev::bytesRequired(elements - 1); + return util::bytesRequired(elements - 1); } string EnumType::toString(bool) const @@ -2908,13 +2908,13 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const solAssert(m_declaration, "Declaration needed to determine interface function type."); bool isLibraryFunction = kind() != Kind::Event && dynamic_cast(*m_declaration->scope()).isLibrary(); - Result paramTypes = + util::Result paramTypes = transformParametersToExternal(m_parameterTypes, isLibraryFunction); if (!paramTypes.message().empty()) return FunctionTypePointer(); - Result retParamTypes = + util::Result retParamTypes = transformParametersToExternal(m_returnParameterTypes, isLibraryFunction); if (!retParamTypes.message().empty()) @@ -3171,12 +3171,12 @@ string FunctionType::externalSignature() const u256 FunctionType::externalIdentifier() const { - return FixedHash<4>::Arith(FixedHash<4>(dev::keccak256(externalSignature()))); + return util::FixedHash<4>::Arith(util::FixedHash<4>(util::keccak256(externalSignature()))); } string FunctionType::externalIdentifierHex() const { - return FixedHash<4>(dev::keccak256(externalSignature())).hex(); + return util::FixedHash<4>(util::keccak256(externalSignature())).hex(); } bool FunctionType::isPure() const diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 3bc2aa0ae..13a9c5628 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -39,9 +39,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class TypeProvider; @@ -50,9 +48,9 @@ class FunctionType; // forward using TypePointer = Type const*; using FunctionTypePointer = FunctionType const*; using TypePointers = std::vector; -using rational = boost::rational; -using TypeResult = Result; -using BoolResult = Result; +using rational = boost::rational; +using TypeResult = util::Result; +using BoolResult = util::Result; inline rational makeRational(bigint const& _numerator, bigint const& _denominator) { @@ -539,7 +537,7 @@ private: /// @returns a truncated readable representation of the bigint keeping only /// up to 4 leading and 4 trailing digits. - static std::string bigintToReadableString(dev::bigint const& num); + static std::string bigintToReadableString(bigint const& num); }; /** @@ -599,7 +597,7 @@ public: bool leftAligned() const override { return true; } bool isValueType() const override { return true; } - std::string toString(bool) const override { return "bytes" + dev::toString(m_bytes); } + std::string toString(bool) const override { return "bytes" + util::toString(m_bytes); } MemberList::MemberMap nativeMembers(ContractDefinition const*) const override; TypePointer encodingType() const override { return this; } TypeResult interfaceType(bool) const override { return this; } @@ -1445,4 +1443,3 @@ public: }; } -} diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index 224d55449..ea7106ede 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -31,8 +31,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; string ABIFunctions::tupleEncoder( TypePointers const& _givenTypes, diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h index eba01d765..f8f09a3f3 100644 --- a/libsolidity/codegen/ABIFunctions.h +++ b/libsolidity/codegen/ABIFunctions.h @@ -32,9 +32,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class Type; @@ -258,4 +256,3 @@ private: }; } -} diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 81d1fb991..089d0f5cf 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -32,10 +32,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::langutil; void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType const& _sourceType) const { @@ -119,14 +119,14 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons _context << Instruction::SWAP3; // stack: target_ref target_data_end source_length target_data_pos source_ref - eth::AssemblyItem copyLoopEndWithoutByteOffset = _context.newTag(); + evmasm::AssemblyItem copyLoopEndWithoutByteOffset = _context.newTag(); // special case for short byte arrays: Store them together with their length. if (_targetType.isByteArray()) { // stack: target_ref target_data_end source_length target_data_pos source_ref _context << Instruction::DUP3 << u256(31) << Instruction::LT; - eth::AssemblyItem longByteArray = _context.appendConditionalJump(); + evmasm::AssemblyItem longByteArray = _context.appendConditionalJump(); // store the short byte array solAssert(_sourceType.isByteArray(), ""); if (_sourceType.location() == DataLocation::Storage) @@ -172,13 +172,13 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons if (haveByteOffsetSource) _context << u256(0); // stack: target_ref target_data_end source_data_pos target_data_pos source_data_end [target_byte_offset] [source_byte_offset] - eth::AssemblyItem copyLoopStart = _context.newTag(); + evmasm::AssemblyItem copyLoopStart = _context.newTag(); _context << copyLoopStart; // check for loop condition _context << dupInstruction(3 + byteOffsetSize) << dupInstruction(2 + byteOffsetSize) << Instruction::GT << Instruction::ISZERO; - eth::AssemblyItem copyLoopEnd = _context.appendConditionalJump(); + evmasm::AssemblyItem copyLoopEnd = _context.appendConditionalJump(); // stack: target_ref target_data_end source_data_pos target_data_pos source_data_end [target_byte_offset] [source_byte_offset] // copy if (sourceBaseType->category() == Type::Category::Array) @@ -264,7 +264,7 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons // clear elements that might be left over in the current slot in target // stack: target_ref target_data_end source_data_pos target_data_pos source_data_end target_byte_offset [source_byte_offset] _context << dupInstruction(byteOffsetSize) << Instruction::ISZERO; - eth::AssemblyItem copyCleanupLoopEnd = _context.appendConditionalJump(); + evmasm::AssemblyItem copyCleanupLoopEnd = _context.appendConditionalJump(); _context << dupInstruction(2 + byteOffsetSize) << dupInstruction(1 + byteOffsetSize); StorageItem(_context, *targetBaseType).setToZero(SourceLocation(), true); utils.incrementByteOffset(targetBaseType->storageBytes(), byteOffsetSize, byteOffsetSize + 2); @@ -375,7 +375,7 @@ void ArrayUtils::copyArrayToMemory(ArrayType const& _sourceType, bool _padToWord // stack: m_context << Instruction::SWAP1 << u256(31) << Instruction::AND; // stack: - eth::AssemblyItem skip = m_context.newTag(); + evmasm::AssemblyItem skip = m_context.newTag(); if (_sourceType.isDynamicallySized()) { m_context << Instruction::DUP1 << Instruction::ISZERO; @@ -420,13 +420,13 @@ void ArrayUtils::copyArrayToMemory(ArrayType const& _sourceType, bool _padToWord // stack here: memory_offset storage_offset length // jump to end if length is zero m_context << Instruction::DUP1 << Instruction::ISZERO; - eth::AssemblyItem loopEnd = m_context.appendConditionalJump(); + evmasm::AssemblyItem loopEnd = m_context.appendConditionalJump(); // Special case for tightly-stored byte arrays if (_sourceType.isByteArray()) { // stack here: memory_offset storage_offset length m_context << Instruction::DUP1 << u256(31) << Instruction::LT; - eth::AssemblyItem longByteArray = m_context.appendConditionalJump(); + evmasm::AssemblyItem longByteArray = m_context.appendConditionalJump(); // store the short byte array (discard lower-order byte) m_context << u256(0x100) << Instruction::DUP1; m_context << Instruction::DUP4 << Instruction::SLOAD; @@ -462,7 +462,7 @@ void ArrayUtils::copyArrayToMemory(ArrayType const& _sourceType, bool _padToWord if (haveByteOffset) m_context << u256(0) << Instruction::SWAP1; // stack here: memory_end_offset storage_data_offset [storage_byte_offset] memory_offset - eth::AssemblyItem loopStart = m_context.newTag(); + evmasm::AssemblyItem loopStart = m_context.newTag(); m_context << loopStart; // load and store if (_sourceType.isByteArray()) @@ -599,12 +599,12 @@ void ArrayUtils::clearDynamicArray(ArrayType const& _type) const // set length to zero m_context << u256(0) << Instruction::DUP3 << Instruction::SSTORE; // Special case: short byte arrays are stored togeher with their length - eth::AssemblyItem endTag = m_context.newTag(); + evmasm::AssemblyItem endTag = m_context.newTag(); if (_type.isByteArray()) { // stack: ref old_length m_context << Instruction::DUP1 << u256(31) << Instruction::LT; - eth::AssemblyItem longByteArray = m_context.appendConditionalJump(); + evmasm::AssemblyItem longByteArray = m_context.appendConditionalJump(); m_context << Instruction::POP; m_context.appendJumpTo(endTag); m_context.adjustStackOffset(1); // needed because of jump @@ -644,7 +644,7 @@ void ArrayUtils::resizeDynamicArray(ArrayType const& _typeIn) const solAssert(_type.baseType()->isValueType(), "Invalid storage size for non-value type."); unsigned stackHeightStart = _context.stackHeight(); - eth::AssemblyItem resizeEnd = _context.newTag(); + evmasm::AssemblyItem resizeEnd = _context.newTag(); // stack: ref new_length // fetch old length @@ -655,7 +655,7 @@ void ArrayUtils::resizeDynamicArray(ArrayType const& _typeIn) const // Special case for short byte arrays, they are stored together with their length if (_type.isByteArray()) { - eth::AssemblyItem regularPath = _context.newTag(); + evmasm::AssemblyItem regularPath = _context.newTag(); // We start by a large case-distinction about the old and new length of the byte array. _context << Instruction::DUP3 << Instruction::SLOAD; @@ -663,14 +663,14 @@ void ArrayUtils::resizeDynamicArray(ArrayType const& _typeIn) const solAssert(_context.stackHeight() - stackHeightStart == 4 - 2, "3"); _context << Instruction::DUP2 << u256(31) << Instruction::LT; - eth::AssemblyItem currentIsLong = _context.appendConditionalJump(); + evmasm::AssemblyItem currentIsLong = _context.appendConditionalJump(); _context << Instruction::DUP3 << u256(31) << Instruction::LT; - eth::AssemblyItem newIsLong = _context.appendConditionalJump(); + evmasm::AssemblyItem newIsLong = _context.appendConditionalJump(); // Here: short -> short // Compute 1 << (256 - 8 * new_size) - eth::AssemblyItem shortToShort = _context.newTag(); + evmasm::AssemblyItem shortToShort = _context.newTag(); _context << shortToShort; _context << Instruction::DUP3 << u256(8) << Instruction::MUL; _context << u256(0x100) << Instruction::SUB; @@ -928,11 +928,11 @@ void ArrayUtils::clearStorageLoop(TypePointer _type) const // stack: end_pos pos // jump to and return from the loop to allow for duplicate code removal - eth::AssemblyItem returnTag = _context.pushNewTag(); + evmasm::AssemblyItem returnTag = _context.pushNewTag(); _context << Instruction::SWAP2 << Instruction::SWAP1; // stack: end_pos pos - eth::AssemblyItem loopStart = _context.appendJumpToNew(); + evmasm::AssemblyItem loopStart = _context.appendJumpToNew(); _context << loopStart; // check for loop condition _context << @@ -940,7 +940,7 @@ void ArrayUtils::clearStorageLoop(TypePointer _type) const Instruction::DUP3 << Instruction::GT << Instruction::ISZERO; - eth::AssemblyItem zeroLoopEnd = _context.newTag(); + evmasm::AssemblyItem zeroLoopEnd = _context.newTag(); _context.appendConditionalJumpTo(zeroLoopEnd); // delete _context << u256(0); @@ -1082,7 +1082,7 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType, bool _doBoundsCheck, b m_context << Instruction::SWAP1; // stack: [] - eth::AssemblyItem endTag = m_context.newTag(); + evmasm::AssemblyItem endTag = m_context.newTag(); if (_arrayType.isByteArray()) { // Special case of short byte arrays. diff --git a/libsolidity/codegen/ArrayUtils.h b/libsolidity/codegen/ArrayUtils.h index 9cb5338ae..2ee087974 100644 --- a/libsolidity/codegen/ArrayUtils.h +++ b/libsolidity/codegen/ArrayUtils.h @@ -24,9 +24,7 @@ #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class CompilerContext; @@ -120,4 +118,3 @@ private: }; } -} diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index 121470e28..a6452adb2 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -26,8 +26,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; void Compiler::compileContract( ContractDefinition const& _contract, @@ -51,13 +51,13 @@ void Compiler::compileContract( m_context.optimise(m_optimiserSettings); } -std::shared_ptr Compiler::runtimeAssemblyPtr() const +std::shared_ptr Compiler::runtimeAssemblyPtr() const { solAssert(m_context.runtimeContext(), ""); return m_context.runtimeContext()->assemblyPtr(); } -eth::AssemblyItem Compiler::functionEntryLabel(FunctionDefinition const& _function) const +evmasm::AssemblyItem Compiler::functionEntryLabel(FunctionDefinition const& _function) const { return m_runtimeContext.functionEntryLabelIfExists(_function); } diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h index c93fa5df1..e4a8adc6a 100644 --- a/libsolidity/codegen/Compiler.h +++ b/libsolidity/codegen/Compiler.h @@ -30,8 +30,7 @@ #include #include -namespace dev { -namespace solidity { +namespace solidity::frontend { class Compiler { @@ -51,15 +50,15 @@ public: bytes const& _metadata ); /// @returns Entire assembly. - eth::Assembly const& assembly() const { return m_context.assembly(); } + evmasm::Assembly const& assembly() const { return m_context.assembly(); } /// @returns Entire assembly as a shared pointer to non-const. - std::shared_ptr assemblyPtr() const { return m_context.assemblyPtr(); } + std::shared_ptr assemblyPtr() const { return m_context.assemblyPtr(); } /// @returns Runtime assembly. - std::shared_ptr runtimeAssemblyPtr() const; + std::shared_ptr runtimeAssemblyPtr() const; /// @returns The entire assembled object (with constructor). - eth::LinkerObject assembledObject() const { return m_context.assembledObject(); } + evmasm::LinkerObject assembledObject() const { return m_context.assembledObject(); } /// @returns Only the runtime object (without constructor). - eth::LinkerObject runtimeObject() const { return m_context.assembledRuntimeObject(m_runtimeSub); } + evmasm::LinkerObject runtimeObject() const { return m_context.assembledRuntimeObject(m_runtimeSub); } /// @arg _sourceCodes is the map of input files to source code strings std::string assemblyString(StringMap const& _sourceCodes = StringMap()) const { @@ -71,13 +70,13 @@ public: return m_context.assemblyJSON(_sourceCodes); } /// @returns Assembly items of the normal compiler context - eth::AssemblyItems const& assemblyItems() const { return m_context.assembly().items(); } + evmasm::AssemblyItems const& assemblyItems() const { return m_context.assembly().items(); } /// @returns Assembly items of the runtime compiler context - eth::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().sub(m_runtimeSub).items(); } + evmasm::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().sub(m_runtimeSub).items(); } /// @returns the entry label of the given function. Might return an AssemblyItem of type /// UndefinedItem if it does not exist yet. - eth::AssemblyItem functionEntryLabel(FunctionDefinition const& _function) const; + evmasm::AssemblyItem functionEntryLabel(FunctionDefinition const& _function) const; private: OptimiserSettings const m_optimiserSettings; @@ -88,4 +87,3 @@ private: }; } -} diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index c5096de72..ef5534a3c 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -54,10 +54,10 @@ using namespace std; -using namespace langutil; -using namespace dev::eth; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::langutil; void CompilerContext::addStateVariable( VariableDeclaration const& _declaration, @@ -81,17 +81,17 @@ void CompilerContext::callLowLevelFunction( function const& _generator ) { - eth::AssemblyItem retTag = pushNewTag(); + evmasm::AssemblyItem retTag = pushNewTag(); CompilerUtils(*this).moveIntoStack(_inArgs); *this << lowLevelFunctionTag(_name, _inArgs, _outArgs, _generator); - appendJump(eth::AssemblyItem::JumpType::IntoFunction); + appendJump(evmasm::AssemblyItem::JumpType::IntoFunction); adjustStackOffset(int(_outArgs) - 1 - _inArgs); *this << retTag.tag(); } -eth::AssemblyItem CompilerContext::lowLevelFunctionTag( +evmasm::AssemblyItem CompilerContext::lowLevelFunctionTag( string const& _name, unsigned _inArgs, unsigned _outArgs, @@ -101,7 +101,7 @@ eth::AssemblyItem CompilerContext::lowLevelFunctionTag( auto it = m_lowLevelFunctions.find(_name); if (it == m_lowLevelFunctions.end()) { - eth::AssemblyItem tag = newTag().pushTag(); + evmasm::AssemblyItem tag = newTag().pushTag(); m_lowLevelFunctions.insert(make_pair(_name, tag)); m_lowLevelFunctionGenerationQueue.push(make_tuple(_name, _inArgs, _outArgs, _generator)); return tag; @@ -125,7 +125,7 @@ void CompilerContext::appendMissingLowLevelFunctions() *this << m_lowLevelFunctions.at(name).tag(); generator(*this); CompilerUtils(*this).moveToStackTop(outArgs); - appendJump(eth::AssemblyItem::JumpType::OutOfFunction); + appendJump(evmasm::AssemblyItem::JumpType::OutOfFunction); solAssert(stackHeight() == outArgs, "Invalid stack height in low-level function " + name + "."); } } @@ -170,14 +170,14 @@ unsigned CompilerContext::numberOfLocalVariables() const return m_localVariables.size(); } -shared_ptr CompilerContext::compiledContract(ContractDefinition const& _contract) const +shared_ptr CompilerContext::compiledContract(ContractDefinition const& _contract) const { auto ret = m_otherCompilers.find(&_contract); solAssert(ret != m_otherCompilers.end(), "Compiled contract not found."); return ret->second->assemblyPtr(); } -shared_ptr CompilerContext::compiledContractRuntime(ContractDefinition const& _contract) const +shared_ptr CompilerContext::compiledContractRuntime(ContractDefinition const& _contract) const { auto ret = m_otherCompilers.find(&_contract); solAssert(ret != m_otherCompilers.end(), "Compiled contract not found."); @@ -189,12 +189,12 @@ bool CompilerContext::isLocalVariable(Declaration const* _declaration) const return !!m_localVariables.count(_declaration); } -eth::AssemblyItem CompilerContext::functionEntryLabel(Declaration const& _declaration) +evmasm::AssemblyItem CompilerContext::functionEntryLabel(Declaration const& _declaration) { return m_functionCompilationQueue.entryLabel(_declaration, *this); } -eth::AssemblyItem CompilerContext::functionEntryLabelIfExists(Declaration const& _declaration) const +evmasm::AssemblyItem CompilerContext::functionEntryLabelIfExists(Declaration const& _declaration) const { return m_functionCompilationQueue.entryLabelIfExists(_declaration); } @@ -275,9 +275,9 @@ pair CompilerContext::storageLocationOfVariable(Declaration cons return it->second; } -CompilerContext& CompilerContext::appendJump(eth::AssemblyItem::JumpType _jumpType) +CompilerContext& CompilerContext::appendJump(evmasm::AssemblyItem::JumpType _jumpType) { - eth::AssemblyItem item(Instruction::JUMP); + evmasm::AssemblyItem item(Instruction::JUMP); item.setJumpType(_jumpType); return *this << item; } @@ -290,7 +290,7 @@ CompilerContext& CompilerContext::appendInvalid() CompilerContext& CompilerContext::appendConditionalInvalid() { *this << Instruction::ISZERO; - eth::AssemblyItem afterTag = appendConditionalJump(); + evmasm::AssemblyItem afterTag = appendConditionalJump(); *this << Instruction::INVALID; *this << afterTag; return *this; @@ -370,7 +370,7 @@ void CompilerContext::appendInlineAssembly( BOOST_THROW_EXCEPTION( CompilerError() << errinfo_sourceLocation(_identifier.location) << - errinfo_comment("Stack too deep (" + to_string(stackDiff) + "), try removing local variables.") + util::errinfo_comment("Stack too deep (" + to_string(stackDiff) + "), try removing local variables.") ); if (_context == yul::IdentifierContext::RValue) _assembly.appendInstruction(dupInstruction(stackDiff)); @@ -493,10 +493,10 @@ void CompilerContext::updateSourceLocation() m_asm->setSourceLocation(m_visitedNodes.empty() ? SourceLocation() : m_visitedNodes.top()->location()); } -eth::Assembly::OptimiserSettings CompilerContext::translateOptimiserSettings(OptimiserSettings const& _settings) +evmasm::Assembly::OptimiserSettings CompilerContext::translateOptimiserSettings(OptimiserSettings const& _settings) { // Constructing it this way so that we notice changes in the fields. - eth::Assembly::OptimiserSettings asmSettings{false, false, false, false, false, false, m_evmVersion, 0}; + evmasm::Assembly::OptimiserSettings asmSettings{false, false, false, false, false, false, m_evmVersion, 0}; asmSettings.isCreation = true; asmSettings.runJumpdestRemover = _settings.runJumpdestRemover; asmSettings.runPeephole = _settings.runPeephole; @@ -508,7 +508,7 @@ eth::Assembly::OptimiserSettings CompilerContext::translateOptimiserSettings(Opt return asmSettings; } -eth::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabel( +evmasm::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabel( Declaration const& _declaration, CompilerContext& _context ) @@ -516,7 +516,7 @@ eth::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabel( auto res = m_entryLabels.find(&_declaration); if (res == m_entryLabels.end()) { - eth::AssemblyItem tag(_context.newTag()); + evmasm::AssemblyItem tag(_context.newTag()); m_entryLabels.insert(make_pair(&_declaration, tag)); m_functionsToCompile.push(&_declaration); return tag.tag(); @@ -526,10 +526,10 @@ eth::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabel( } -eth::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabelIfExists(Declaration const& _declaration) const +evmasm::AssemblyItem CompilerContext::FunctionCompilationQueue::entryLabelIfExists(Declaration const& _declaration) const { auto res = m_entryLabels.find(&_declaration); - return res == m_entryLabels.end() ? eth::AssemblyItem(eth::UndefinedItem) : res->second.tag(); + return res == m_entryLabels.end() ? evmasm::AssemblyItem(evmasm::UndefinedItem) : res->second.tag(); } Declaration const* CompilerContext::FunctionCompilationQueue::nextFunctionToCompile() const diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index f396e59de..9abda7aa1 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -40,8 +40,7 @@ #include #include -namespace dev { -namespace solidity { +namespace solidity::frontend { class Compiler; @@ -53,7 +52,7 @@ class CompilerContext { public: explicit CompilerContext(langutil::EVMVersion _evmVersion, CompilerContext* _runtimeContext = nullptr): - m_asm(std::make_shared()), + m_asm(std::make_shared()), m_evmVersion(_evmVersion), m_runtimeContext(_runtimeContext), m_abiFunctions(m_evmVersion) @@ -78,8 +77,8 @@ public: unsigned numberOfLocalVariables() const; void setOtherCompilers(std::map> const& _otherCompilers) { m_otherCompilers = _otherCompilers; } - std::shared_ptr compiledContract(ContractDefinition const& _contract) const; - std::shared_ptr compiledContractRuntime(ContractDefinition const& _contract) const; + std::shared_ptr compiledContract(ContractDefinition const& _contract) const; + std::shared_ptr compiledContractRuntime(ContractDefinition const& _contract) const; void setStackOffset(int _offset) { m_asm->setDeposit(_offset); } void adjustStackOffset(int _adjustment) { m_asm->adjustDeposit(_adjustment); } @@ -89,10 +88,10 @@ public: bool isStateVariable(Declaration const* _declaration) const { return m_stateVariables.count(_declaration) != 0; } /// @returns the entry label of the given function and creates it if it does not exist yet. - eth::AssemblyItem functionEntryLabel(Declaration const& _declaration); + evmasm::AssemblyItem functionEntryLabel(Declaration const& _declaration); /// @returns the entry label of the given function. Might return an AssemblyItem of type /// UndefinedItem if it does not exist yet. - eth::AssemblyItem functionEntryLabelIfExists(Declaration const& _declaration) const; + evmasm::AssemblyItem functionEntryLabelIfExists(Declaration const& _declaration) const; /// @returns the entry label of the given function and takes overrides into account. FunctionDefinition const& resolveVirtualFunction(FunctionDefinition const& _function); /// @returns the function that overrides the given declaration from the most derived class just @@ -126,7 +125,7 @@ public: /// list of low-level-functions to be generated, unless it already exists. /// Note that the generator should not assume that objects are still alive when it is called, /// unless they are guaranteed to be alive for the whole run of the compiler (AST nodes, for example). - eth::AssemblyItem lowLevelFunctionTag( + evmasm::AssemblyItem lowLevelFunctionTag( std::string const& _name, unsigned _inArgs, unsigned _outArgs, @@ -149,13 +148,13 @@ public: std::pair storageLocationOfVariable(Declaration const& _declaration) const; /// Appends a JUMPI instruction to a new tag and @returns the tag - eth::AssemblyItem appendConditionalJump() { return m_asm->appendJumpI().tag(); } + evmasm::AssemblyItem appendConditionalJump() { return m_asm->appendJumpI().tag(); } /// Appends a JUMPI instruction to @a _tag - CompilerContext& appendConditionalJumpTo(eth::AssemblyItem const& _tag) { m_asm->appendJumpI(_tag); return *this; } + CompilerContext& appendConditionalJumpTo(evmasm::AssemblyItem const& _tag) { m_asm->appendJumpI(_tag); return *this; } /// Appends a JUMP to a new tag and @returns the tag - eth::AssemblyItem appendJumpToNew() { return m_asm->appendJump().tag(); } + evmasm::AssemblyItem appendJumpToNew() { return m_asm->appendJump().tag(); } /// Appends a JUMP to a tag already on the stack - CompilerContext& appendJump(eth::AssemblyItem::JumpType _jumpType = eth::AssemblyItem::JumpType::Ordinary); + CompilerContext& appendJump(evmasm::AssemblyItem::JumpType _jumpType = evmasm::AssemblyItem::JumpType::Ordinary); /// Appends an INVALID instruction CompilerContext& appendInvalid(); /// Appends a conditional INVALID instruction @@ -169,18 +168,18 @@ public: CompilerContext& appendConditionalRevert(bool _forwardReturnData = false); /// Appends a JUMP to a specific tag CompilerContext& appendJumpTo( - eth::AssemblyItem const& _tag, - eth::AssemblyItem::JumpType _jumpType = eth::AssemblyItem::JumpType::Ordinary + evmasm::AssemblyItem const& _tag, + evmasm::AssemblyItem::JumpType _jumpType = evmasm::AssemblyItem::JumpType::Ordinary ) { *m_asm << _tag.pushTag(); return appendJump(_jumpType); } /// Appends pushing of a new tag and @returns the new tag. - eth::AssemblyItem pushNewTag() { return m_asm->append(m_asm->newPushTag()).tag(); } + evmasm::AssemblyItem pushNewTag() { return m_asm->append(m_asm->newPushTag()).tag(); } /// @returns a new tag without pushing any opcodes or data - eth::AssemblyItem newTag() { return m_asm->newTag(); } + evmasm::AssemblyItem newTag() { return m_asm->newTag(); } /// @returns a new tag identified by name. - eth::AssemblyItem namedTag(std::string const& _name) { return m_asm->namedTag(_name); } + evmasm::AssemblyItem namedTag(std::string const& _name) { return m_asm->namedTag(_name); } /// Adds a subroutine to the code (in the data section) and pushes its size (via a tag) /// on the stack. @returns the pushsub assembly item. - eth::AssemblyItem addSubroutine(eth::AssemblyPointer const& _assembly) { return m_asm->appendSubroutine(_assembly); } + evmasm::AssemblyItem addSubroutine(evmasm::AssemblyPointer const& _assembly) { return m_asm->appendSubroutine(_assembly); } /// Pushes the size of the subroutine. void pushSubroutineSize(size_t _subRoutine) { m_asm->pushSubroutineSize(_subRoutine); } /// Pushes the offset of the subroutine. @@ -188,12 +187,12 @@ public: /// Pushes the size of the final program void appendProgramSize() { m_asm->appendProgramSize(); } /// Adds data to the data section, pushes a reference to the stack - eth::AssemblyItem appendData(bytes const& _data) { return m_asm->append(_data); } + evmasm::AssemblyItem appendData(bytes const& _data) { return m_asm->append(_data); } /// Appends the address (virtual, will be filled in by linker) of a library. void appendLibraryAddress(std::string const& _identifier) { m_asm->appendLibraryAddress(_identifier); } /// Appends a zero-address that can be replaced by something else at deploy time (if the /// position in bytecode is known). - void appendDeployTimeAddress() { m_asm->append(eth::PushDeployTimeAddress); } + void appendDeployTimeAddress() { m_asm->append(evmasm::PushDeployTimeAddress); } /// Resets the stack of visited nodes with a new stack having only @c _node void resetVisitedNodes(ASTNode const* _node); /// Pops the stack of visited nodes @@ -202,8 +201,8 @@ public: void pushVisitedNodes(ASTNode const* _node) { m_visitedNodes.push(_node); updateSourceLocation(); } /// Append elements to the current instruction list and adjust @a m_stackOffset. - CompilerContext& operator<<(eth::AssemblyItem const& _item) { m_asm->append(_item); return *this; } - CompilerContext& operator<<(dev::eth::Instruction _instruction) { m_asm->append(_instruction); return *this; } + CompilerContext& operator<<(evmasm::AssemblyItem const& _item) { m_asm->append(_item); return *this; } + CompilerContext& operator<<(evmasm::Instruction _instruction) { m_asm->append(_instruction); return *this; } CompilerContext& operator<<(u256 const& _value) { m_asm->append(_value); return *this; } CompilerContext& operator<<(bytes const& _data) { m_asm->append(_data); return *this; } @@ -232,10 +231,10 @@ public: size_t runtimeSub() const { return m_runtimeSub; } /// @returns a const reference to the underlying assembly. - eth::Assembly const& assembly() const { return *m_asm; } + evmasm::Assembly const& assembly() const { return *m_asm; } /// @returns a shared pointer to the assembly. /// Should be avoided except when adding sub-assemblies. - std::shared_ptr assemblyPtr() const { return m_asm; } + std::shared_ptr assemblyPtr() const { return m_asm; } /// @arg _sourceCodes is the map of input files to source code strings std::string assemblyString(StringMap const& _sourceCodes = StringMap()) const @@ -249,8 +248,8 @@ public: return m_asm->assemblyJSON(_sourceCodes); } - eth::LinkerObject const& assembledObject() const { return m_asm->assemble(); } - eth::LinkerObject const& assembledRuntimeObject(size_t _subIndex) const { return m_asm->sub(_subIndex).assemble(); } + evmasm::LinkerObject const& assembledObject() const { return m_asm->assemble(); } + evmasm::LinkerObject const& assembledRuntimeObject(size_t _subIndex) const { return m_asm->sub(_subIndex).assemble(); } /** * Helper class to pop the visited nodes stack when a scope closes @@ -276,7 +275,7 @@ private: /// Updates source location set in the assembly. void updateSourceLocation(); - eth::Assembly::OptimiserSettings translateOptimiserSettings(OptimiserSettings const& _settings); + evmasm::Assembly::OptimiserSettings translateOptimiserSettings(OptimiserSettings const& _settings); /** * Helper class that manages function labels and ensures that referenced functions are @@ -286,10 +285,10 @@ private: { /// @returns the entry label of the given function and creates it if it does not exist yet. /// @param _context compiler context used to create a new tag if needed - eth::AssemblyItem entryLabel(Declaration const& _declaration, CompilerContext& _context); + evmasm::AssemblyItem entryLabel(Declaration const& _declaration, CompilerContext& _context); /// @returns the entry label of the given function. Might return an AssemblyItem of type /// UndefinedItem if it does not exist yet. - eth::AssemblyItem entryLabelIfExists(Declaration const& _declaration) const; + evmasm::AssemblyItem entryLabelIfExists(Declaration const& _declaration) const; /// @returns the next function in the queue of functions that are still to be compiled /// (i.e. that were referenced during compilation but where we did not yet generate code for). @@ -301,7 +300,7 @@ private: void startFunction(Declaration const& _function); /// Labels pointing to the entry points of functions. - std::map m_entryLabels; + std::map m_entryLabels; /// Set of functions for which we did not yet generate code. std::set m_alreadyCompiledFunctions; /// Queue of functions that still need to be compiled (important to be a queue to maintain @@ -310,7 +309,7 @@ private: mutable std::queue m_functionsToCompile; } m_functionCompilationQueue; - eth::AssemblyPointer m_asm; + evmasm::AssemblyPointer m_asm; /// Version of the EVM to compile against. langutil::EVMVersion m_evmVersion; /// Activated experimental features. @@ -333,7 +332,7 @@ private: /// The index of the runtime subroutine. size_t m_runtimeSub = -1; /// An index of low-level function labels by name. - std::map m_lowLevelFunctions; + std::map m_lowLevelFunctions; /// Container for ABI functions to be generated. ABIFunctions m_abiFunctions; /// The queue of low-level functions to generate. @@ -341,4 +340,3 @@ private: }; } -} diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index f068b156c..8d7cfb386 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -31,10 +31,14 @@ #include using namespace std; -using namespace langutil; -using namespace dev; -using namespace dev::eth; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::langutil; + +using solidity::util::Whiskers; +using solidity::util::h256; +using solidity::util::toCompactHexWithPrefix; unsigned const CompilerUtils::dataStartOffset = 4; size_t const CompilerUtils::freeMemoryPointer = 64; @@ -86,7 +90,7 @@ void CompilerUtils::revertWithStringData(Type const& _argumentType) { solAssert(_argumentType.isImplicitlyConvertibleTo(*TypeProvider::fromElementaryTypeName("string memory")), ""); fetchFreeMemoryPointer(); - m_context << (u256(FixedHash<4>::Arith(FixedHash<4>(dev::keccak256("Error(string)")))) << (256 - 32)); + m_context << (u256(util::FixedHash<4>::Arith(util::FixedHash<4>(util::keccak256("Error(string)")))) << (256 - 32)); m_context << Instruction::DUP2 << Instruction::MSTORE; m_context << u256(4) << Instruction::ADD; // Stack: @@ -1263,7 +1267,7 @@ void CompilerUtils::moveToStackVariable(VariableDeclaration const& _variable) BOOST_THROW_EXCEPTION( CompilerError() << errinfo_sourceLocation(_variable.location()) << - errinfo_comment("Stack too deep, try removing local variables.") + util::errinfo_comment("Stack too deep, try removing local variables.") ); for (unsigned i = 0; i < size; ++i) m_context << swapInstruction(stackPosition - size + 1) << Instruction::POP; @@ -1316,7 +1320,7 @@ void CompilerUtils::popStackSlots(size_t _amount) m_context << Instruction::POP; } -void CompilerUtils::popAndJump(unsigned _toHeight, eth::AssemblyItem const& _jumpTo) +void CompilerUtils::popAndJump(unsigned _toHeight, evmasm::AssemblyItem const& _jumpTo) { solAssert(m_context.stackHeight() >= _toHeight, ""); unsigned amount = m_context.stackHeight() - _toHeight; @@ -1349,7 +1353,7 @@ void CompilerUtils::copyContractCodeToMemory(ContractDefinition const& contract, [&contract, _creation](CompilerContext& _context) { // copy the contract's code into memory - shared_ptr assembly = + shared_ptr assembly = _creation ? _context.compiledContract(contract) : _context.compiledContractRuntime(contract); diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index 90ea8a156..5cc0ac9c8 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -27,8 +27,7 @@ #include #include -namespace dev { -namespace solidity { +namespace solidity::frontend { class Type; // forward @@ -266,7 +265,7 @@ public: /// Pops slots from the stack such that its height is _toHeight. /// Adds jump to _jumpTo. /// Readjusts the stack offset to the original value. - void popAndJump(unsigned _toHeight, eth::AssemblyItem const& _jumpTo); + void popAndJump(unsigned _toHeight, evmasm::AssemblyItem const& _jumpTo); template static unsigned sizeOnStack(std::vector const& _variables); @@ -326,4 +325,3 @@ unsigned CompilerUtils::sizeOnStack(std::vector const& _variables) } } -} diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 1fe96bbac..bbe064402 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -41,10 +41,14 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::eth; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::langutil; + +using solidity::util::FixedHash; +using solidity::util::h256; +using solidity::util::errinfo_comment; namespace { @@ -158,7 +162,7 @@ size_t ContractCompiler::packIntoContractCreator(ContractDefinition const& _cont // We jump to the deploy routine because we first have to append all missing functions, // which can cause further functions to be added to the runtime context. - eth::AssemblyItem deployRoutine = m_context.appendJumpToNew(); + evmasm::AssemblyItem deployRoutine = m_context.appendJumpToNew(); // We have to include copies of functions in the construction time and runtime context // because of absolute jumps. @@ -268,9 +272,9 @@ void ContractCompiler::appendDelegatecallCheck() } void ContractCompiler::appendInternalSelector( - map, eth::AssemblyItem const> const& _entryPoints, + map, evmasm::AssemblyItem const> const& _entryPoints, vector> const& _ids, - eth::AssemblyItem const& _notFoundTag, + evmasm::AssemblyItem const& _notFoundTag, size_t _runs ) { @@ -301,17 +305,17 @@ void ContractCompiler::appendInternalSelector( bool split = false; if (_ids.size() <= 4) split = false; - else if (_runs > (17 * eth::GasCosts::createDataGas) / 6) + else if (_runs > (17 * evmasm::GasCosts::createDataGas) / 6) split = true; else - split = (_runs * 6 * (_ids.size() - 4) > 17 * eth::GasCosts::createDataGas); + split = (_runs * 6 * (_ids.size() - 4) > 17 * evmasm::GasCosts::createDataGas); if (split) { size_t pivotIndex = _ids.size() / 2; FixedHash<4> pivot{_ids.at(pivotIndex)}; m_context << dupInstruction(1) << u256(FixedHash<4>::Arith(pivot)) << Instruction::GT; - eth::AssemblyItem lessTag{m_context.appendConditionalJump()}; + evmasm::AssemblyItem lessTag{m_context.appendConditionalJump()}; // Here, we have funid >= pivot vector> larger{_ids.begin() + pivotIndex, _ids.end()}; appendInternalSelector(_entryPoints, larger, _notFoundTag, _runs); @@ -356,7 +360,7 @@ bool hasPayableFunctions(ContractDefinition const& _contract) void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contract) { map, FunctionTypePointer> interfaceFunctions = _contract.interfaceFunctions(); - map, eth::AssemblyItem const> callDataUnpackerEntryPoints; + map, evmasm::AssemblyItem const> callDataUnpackerEntryPoints; if (_contract.isLibrary()) { @@ -376,10 +380,10 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac needToAddCallvalueCheck = false; } - eth::AssemblyItem notFoundOrReceiveEther = m_context.newTag(); + evmasm::AssemblyItem notFoundOrReceiveEther = m_context.newTag(); // If there is neither a fallback nor a receive ether function, we only need one label to jump to, which // always reverts. - eth::AssemblyItem notFound = (!fallback && !etherReceiver) ? notFoundOrReceiveEther : m_context.newTag(); + evmasm::AssemblyItem notFound = (!fallback && !etherReceiver) ? notFoundOrReceiveEther : m_context.newTag(); // directly jump to fallback or ether receiver if the data is too short to contain a function selector // also guards against short data @@ -462,7 +466,7 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac appendCallValueCheck(); // Return tag is used to jump out of the function. - eth::AssemblyItem returnTag = m_context.pushNewTag(); + evmasm::AssemblyItem returnTag = m_context.pushNewTag(); if (!functionType->parameterTypes().empty()) { // Parameter for calldataUnpacker @@ -472,7 +476,7 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac } m_context.appendJumpTo( m_context.functionEntryLabel(functionType->declaration()), - eth::AssemblyItem::JumpType::IntoFunction + evmasm::AssemblyItem::JumpType::IntoFunction ); m_context << returnTag; // Return tag and input parameters get consumed. @@ -619,7 +623,7 @@ bool ContractCompiler::visit(FunctionDefinition const& _function) { solAssert(m_context.numberOfLocalVariables() == 0, ""); if (!_function.isFallback() && !_function.isReceive()) - m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction); + m_context.appendJump(evmasm::AssemblyItem::JumpType::OutOfFunction); } return false; @@ -809,14 +813,14 @@ bool ContractCompiler::visit(TryStatement const& _tryStatement) int const returnSize = static_cast(_tryStatement.externalCall().annotation().type->sizeOnStack()); // Stack: [ return values] - eth::AssemblyItem successTag = m_context.appendConditionalJump(); + evmasm::AssemblyItem successTag = m_context.appendConditionalJump(); // Catch case. m_context.adjustStackOffset(-returnSize); handleCatch(_tryStatement.clauses()); - eth::AssemblyItem endTag = m_context.appendJumpToNew(); + evmasm::AssemblyItem endTag = m_context.appendJumpToNew(); m_context << successTag; m_context.adjustStackOffset(returnSize); @@ -860,8 +864,8 @@ void ContractCompiler::handleCatch(vector> const& _ca solAssert(_catchClauses.size() == size_t(1 + (structured ? 1 : 0) + (fallback ? 1 : 0)), ""); - eth::AssemblyItem endTag = m_context.newTag(); - eth::AssemblyItem fallbackTag = m_context.newTag(); + evmasm::AssemblyItem endTag = m_context.newTag(); + evmasm::AssemblyItem fallbackTag = m_context.newTag(); if (structured) { solAssert( @@ -873,13 +877,13 @@ void ContractCompiler::handleCatch(vector> const& _ca ); solAssert(m_context.evmVersion().supportsReturndata(), ""); - string errorHash = FixedHash<4>(dev::keccak256("Error(string)")).hex(); + string errorHash = FixedHash<4>(util::keccak256("Error(string)")).hex(); // Try to decode the error message. // If this fails, leaves 0 on the stack, otherwise the pointer to the data string. m_context << u256(0); m_context.appendInlineAssembly( - Whiskers(R"({ + util::Whiskers(R"({ data := mload(0x40) mstore(data, 0) for {} 1 {} { @@ -983,8 +987,8 @@ bool ContractCompiler::visit(IfStatement const& _ifStatement) CompilerContext::LocationSetter locationSetter(m_context, _ifStatement); compileExpression(_ifStatement.condition()); m_context << Instruction::ISZERO; - eth::AssemblyItem falseTag = m_context.appendConditionalJump(); - eth::AssemblyItem endTag = falseTag; + evmasm::AssemblyItem falseTag = m_context.appendConditionalJump(); + evmasm::AssemblyItem endTag = falseTag; _ifStatement.trueStatement().accept(*this); if (_ifStatement.falseStatement()) { @@ -1003,15 +1007,15 @@ bool ContractCompiler::visit(WhileStatement const& _whileStatement) StackHeightChecker checker(m_context); CompilerContext::LocationSetter locationSetter(m_context, _whileStatement); - eth::AssemblyItem loopStart = m_context.newTag(); - eth::AssemblyItem loopEnd = m_context.newTag(); + evmasm::AssemblyItem loopStart = m_context.newTag(); + evmasm::AssemblyItem loopEnd = m_context.newTag(); m_breakTags.emplace_back(loopEnd, m_context.stackHeight()); m_context << loopStart; if (_whileStatement.isDoWhile()) { - eth::AssemblyItem condition = m_context.newTag(); + evmasm::AssemblyItem condition = m_context.newTag(); m_continueTags.emplace_back(condition, m_context.stackHeight()); _whileStatement.body().accept(*this); @@ -1045,9 +1049,9 @@ bool ContractCompiler::visit(ForStatement const& _forStatement) { StackHeightChecker checker(m_context); CompilerContext::LocationSetter locationSetter(m_context, _forStatement); - eth::AssemblyItem loopStart = m_context.newTag(); - eth::AssemblyItem loopEnd = m_context.newTag(); - eth::AssemblyItem loopNext = m_context.newTag(); + evmasm::AssemblyItem loopStart = m_context.newTag(); + evmasm::AssemblyItem loopEnd = m_context.newTag(); + evmasm::AssemblyItem loopNext = m_context.newTag(); storeStackHeight(&_forStatement); diff --git a/libsolidity/codegen/ContractCompiler.h b/libsolidity/codegen/ContractCompiler.h index 494cc3503..02fcbe4ca 100644 --- a/libsolidity/codegen/ContractCompiler.h +++ b/libsolidity/codegen/ContractCompiler.h @@ -28,10 +28,9 @@ #include #include #include +#include -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -92,9 +91,9 @@ private: /// Appends the function selector. Is called recursively to create a binary search tree. /// @a _runs the number of intended executions of the contract to tune the split point. void appendInternalSelector( - std::map, eth::AssemblyItem const> const& _entryPoints, - std::vector> const& _ids, - eth::AssemblyItem const& _notFoundTag, + std::map, evmasm::AssemblyItem const> const& _entryPoints, + std::vector> const& _ids, + evmasm::AssemblyItem const& _notFoundTag, size_t _runs ); void appendFunctionSelector(ContractDefinition const& _contract); @@ -146,12 +145,12 @@ private: ContractCompiler* m_runtimeCompiler = nullptr; CompilerContext& m_context; /// Tag to jump to for a "break" statement and the stack height after freeing the local loop variables. - std::vector> m_breakTags; + std::vector> m_breakTags; /// Tag to jump to for a "continue" statement and the stack height after freeing the local loop variables. - std::vector> m_continueTags; + std::vector> m_continueTags; /// Tag to jump to for a "return" statement and the stack height after freeing the local function or modifier variables. /// Needs to be stacked because of modifiers. - std::vector> m_returnTags; + std::vector> m_returnTags; unsigned m_modifierDepth = 0; FunctionDefinition const* m_currentFunction = nullptr; @@ -163,4 +162,3 @@ private: }; } -} diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index dddc1494d..7e460db9d 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -39,10 +39,11 @@ #include using namespace std; -using namespace langutil; -using namespace dev; -using namespace dev::eth; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::langutil; +using namespace solidity::util; void ExpressionCompiler::compile(Expression const& _expression) @@ -82,7 +83,7 @@ void ExpressionCompiler::appendConstStateVariableAccessor(VariableDeclaration co // append return m_context << dupInstruction(_varDecl.annotation().type->sizeOnStack() + 1); - m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction); + m_context.appendJump(evmasm::AssemblyItem::JumpType::OutOfFunction); } void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& _varDecl) @@ -216,16 +217,16 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const& errinfo_comment("Stack too deep.") ); m_context << dupInstruction(retSizeOnStack + 1); - m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction); + m_context.appendJump(evmasm::AssemblyItem::JumpType::OutOfFunction); } bool ExpressionCompiler::visit(Conditional const& _condition) { CompilerContext::LocationSetter locationSetter(m_context, _condition); _condition.condition().accept(*this); - eth::AssemblyItem trueTag = m_context.appendConditionalJump(); + evmasm::AssemblyItem trueTag = m_context.appendConditionalJump(); acceptAndConvert(_condition.falseExpression(), *_condition.annotation().type); - eth::AssemblyItem endTag = m_context.appendJumpToNew(); + evmasm::AssemblyItem endTag = m_context.appendJumpToNew(); m_context << trueTag; int offset = _condition.annotation().type->sizeOnStack(); m_context.adjustStackOffset(-offset); @@ -554,7 +555,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) // Calling convention: Caller pushes return address and arguments // Callee removes them and pushes return values - eth::AssemblyItem returnLabel = m_context.pushNewTag(); + evmasm::AssemblyItem returnLabel = m_context.pushNewTag(); for (unsigned i = 0; i < arguments.size(); ++i) acceptAndConvert(*arguments[i], *function.parameterTypes()[i]); @@ -593,7 +594,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) // Extract the runtime part. m_context << ((u256(1) << 32) - 1) << Instruction::AND; - m_context.appendJump(eth::AssemblyItem::JumpType::IntoFunction); + m_context.appendJump(evmasm::AssemblyItem::JumpType::IntoFunction); m_context << returnLabel; unsigned returnParametersSize = CompilerUtils::sizeOnStack(function.returnParameterTypes()); @@ -683,7 +684,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) _functionCall.expression().accept(*this); // Provide the gas stipend manually at first because we may send zero ether. // Will be zeroed if we send more than zero ether. - m_context << u256(eth::GasCosts::callStipend); + m_context << u256(evmasm::GasCosts::callStipend); acceptAndConvert(*arguments.front(), *function.parameterTypes().front(), true); // gas <- gas * !value m_context << Instruction::SWAP1 << Instruction::DUP2; @@ -819,7 +820,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) } if (!event.isAnonymous()) { - m_context << u256(h256::Arith(dev::keccak256(function.externalSignature()))); + m_context << u256(h256::Arith(keccak256(function.externalSignature()))); ++numIndexed; } solAssert(numIndexed <= 4, "Too many indexed arguments."); @@ -1109,7 +1110,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) // hash the signature if (auto const* stringType = dynamic_cast(selectorType)) { - FixedHash<4> hash(dev::keccak256(stringType->value())); + FixedHash<4> hash(keccak256(stringType->value())); m_context << (u256(FixedHash<4>::Arith(hash)) << (256 - 32)); dataOnStack = TypeProvider::fixedBytes(4); } @@ -1836,7 +1837,7 @@ void ExpressionCompiler::appendAndOrOperatorCode(BinaryOperation const& _binaryO m_context << Instruction::DUP1; if (c_op == Token::And) m_context << Instruction::ISZERO; - eth::AssemblyItem endLabel = m_context.appendConditionalJump(); + evmasm::AssemblyItem endLabel = m_context.appendConditionalJump(); m_context << Instruction::POP; _binaryOperation.rightExpression().accept(*this); m_context << endLabel; @@ -2234,11 +2235,11 @@ void ExpressionCompiler::appendExternalFunctionCall( { // send all gas except the amount needed to execute "SUB" and "CALL" // @todo this retains too much gas for now, needs to be fine-tuned. - u256 gasNeededByCaller = eth::GasCosts::callGas(m_context.evmVersion()) + 10; + u256 gasNeededByCaller = evmasm::GasCosts::callGas(m_context.evmVersion()) + 10; if (_functionType.valueSet()) - gasNeededByCaller += eth::GasCosts::callValueTransferGas; + gasNeededByCaller += evmasm::GasCosts::callValueTransferGas; if (!existenceChecked) - gasNeededByCaller += eth::GasCosts::callNewAccountGas; // we never know + gasNeededByCaller += evmasm::GasCosts::callNewAccountGas; // we never know m_context << gasNeededByCaller << Instruction::GAS << Instruction::SUB; } // Order is important here, STATICCALL might overlap with DELEGATECALL. @@ -2255,7 +2256,7 @@ void ExpressionCompiler::appendExternalFunctionCall( (_functionType.gasSet() ? 1 : 0) + (!_functionType.isBareCall() ? 1 : 0); - eth::AssemblyItem endTag = m_context.newTag(); + evmasm::AssemblyItem endTag = m_context.newTag(); if (!returnSuccessConditionAndReturndata && !_tryCall) { @@ -2326,7 +2327,7 @@ void ExpressionCompiler::appendExternalFunctionCall( solAssert(retSize > 0, ""); // Always use the actual return length, and not our calculated expected length, if returndatacopy is supported. // This ensures it can catch badly formatted input from external calls. - m_context << (haveReturndatacopy ? eth::AssemblyItem(Instruction::RETURNDATASIZE) : u256(retSize)); + m_context << (haveReturndatacopy ? evmasm::AssemblyItem(Instruction::RETURNDATASIZE) : u256(retSize)); // Stack: return_data_start return_data_size if (needToUpdateFreeMemoryPtr) m_context.appendInlineAssembly(R"({ diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index 7b2fcf6d2..2842b7e78 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -34,12 +34,12 @@ #include #include -namespace dev { -namespace eth +namespace solidity::evmasm { class AssemblyItem; // forward } -namespace solidity { + +namespace solidity::frontend { // forward declarations class CompilerContext; @@ -157,4 +157,3 @@ void ExpressionCompiler::setLValue(Expression const& _expression, _Arguments con } } -} diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index 618293419..a7eb0aaf3 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -28,10 +28,11 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace dev::solidity; -using namespace langutil; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::langutil; +using namespace solidity::util; StackVariable::StackVariable(CompilerContext& _compilerContext, VariableDeclaration const& _declaration): diff --git a/libsolidity/codegen/LValue.h b/libsolidity/codegen/LValue.h index a7352c6f6..1cd4def01 100644 --- a/libsolidity/codegen/LValue.h +++ b/libsolidity/codegen/LValue.h @@ -27,9 +27,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class Declaration; @@ -197,4 +195,3 @@ private: }; } -} diff --git a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp index 9dc66cea2..2be3d29ae 100644 --- a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp +++ b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; string MultiUseYulFunctionCollector::requestedFunctions() { diff --git a/libsolidity/codegen/MultiUseYulFunctionCollector.h b/libsolidity/codegen/MultiUseYulFunctionCollector.h index 321474f90..d839a31be 100644 --- a/libsolidity/codegen/MultiUseYulFunctionCollector.h +++ b/libsolidity/codegen/MultiUseYulFunctionCollector.h @@ -25,9 +25,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { /** @@ -53,4 +51,3 @@ private: }; } -} diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index fe319682b..0f62450c9 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -32,8 +32,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; string YulUtilFunctions::combineExternalFunctionIdFunction() { @@ -130,7 +131,7 @@ string YulUtilFunctions::requireOrAssertFunction(bool _assert, Type const* _mess int const byteSize = 8; u256 const errorHash = u256(FixedHash::Arith( - FixedHash(dev::keccak256("Error(string)")) + FixedHash(keccak256("Error(string)")) )) << (256 - hashHeaderSize * byteSize); string const encodeFunc = ABIFunctions(m_evmVersion, m_functionCollector) diff --git a/libsolidity/codegen/YulUtilFunctions.h b/libsolidity/codegen/YulUtilFunctions.h index c6a339ca9..df6292b42 100644 --- a/libsolidity/codegen/YulUtilFunctions.h +++ b/libsolidity/codegen/YulUtilFunctions.h @@ -28,9 +28,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class Type; @@ -295,4 +293,3 @@ private: }; } -} diff --git a/libsolidity/codegen/ir/IRGenerationContext.cpp b/libsolidity/codegen/ir/IRGenerationContext.cpp index 54e997e4e..3a2bdb9f0 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.cpp +++ b/libsolidity/codegen/ir/IRGenerationContext.cpp @@ -26,9 +26,10 @@ #include #include -using namespace dev; -using namespace dev::solidity; using namespace std; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; string IRGenerationContext::addLocalVariable(VariableDeclaration const& _varDecl) { diff --git a/libsolidity/codegen/ir/IRGenerationContext.h b/libsolidity/codegen/ir/IRGenerationContext.h index ed9fc5bc5..f2710e6ab 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.h +++ b/libsolidity/codegen/ir/IRGenerationContext.h @@ -32,9 +32,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ContractDefinition; @@ -107,4 +105,3 @@ private: }; } -} diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index c34a448d7..e004fc173 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -44,8 +44,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; pair IRGenerator::run(ContractDefinition const& _contract) { diff --git a/libsolidity/codegen/ir/IRGenerator.h b/libsolidity/codegen/ir/IRGenerator.h index 0da85018c..2481f08dd 100644 --- a/libsolidity/codegen/ir/IRGenerator.h +++ b/libsolidity/codegen/ir/IRGenerator.h @@ -29,9 +29,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class SourceUnit; @@ -80,4 +78,3 @@ private: }; } -} diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 0808230b3..87782a4a3 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -35,14 +35,14 @@ #include #include -#include -#include -#include -#include +#include +#include +#include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; namespace { @@ -543,7 +543,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) if (!event.isAnonymous()) { indexedArgs.emplace_back(m_context.newYulVariable()); - string signature = formatNumber(u256(h256::Arith(dev::keccak256(functionType->externalSignature())))); + string signature = formatNumber(u256(h256::Arith(keccak256(functionType->externalSignature())))); m_code << "let " << indexedArgs.back() << " := " << signature << "\n"; } for (size_t i = 0; i < event.parameters().size(); ++i) @@ -1220,11 +1220,11 @@ void IRGeneratorForStatements::appendExternalFunctionCall( { // send all gas except the amount needed to execute "SUB" and "CALL" // @todo this retains too much gas for now, needs to be fine-tuned. - u256 gasNeededByCaller = eth::GasCosts::callGas(m_context.evmVersion()) + 10; + u256 gasNeededByCaller = evmasm::GasCosts::callGas(m_context.evmVersion()) + 10; if (funType.valueSet()) - gasNeededByCaller += eth::GasCosts::callValueTransferGas; + gasNeededByCaller += evmasm::GasCosts::callValueTransferGas; if (!checkExistence) - gasNeededByCaller += eth::GasCosts::callNewAccountGas; // we never know + gasNeededByCaller += evmasm::GasCosts::callNewAccountGas; // we never know templ("gas", "sub(gas(), " + formatNumber(gasNeededByCaller) + ")"); } // Order is important here, STATICCALL might overlap with DELEGATECALL. diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.h b/libsolidity/codegen/ir/IRGeneratorForStatements.h index 74cef0b8a..a441a0410 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.h +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.h @@ -23,9 +23,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class IRGenerationContext; @@ -114,4 +112,3 @@ private: }; } -} diff --git a/libsolidity/codegen/ir/IRLValue.cpp b/libsolidity/codegen/ir/IRLValue.cpp index 6355420f7..99b0daa0c 100644 --- a/libsolidity/codegen/ir/IRLValue.cpp +++ b/libsolidity/codegen/ir/IRLValue.cpp @@ -28,8 +28,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; IRLocalVariable::IRLocalVariable( IRGenerationContext& _context, @@ -68,7 +68,7 @@ IRStorageItem::IRStorageItem( std::pair slot_offset ): IRLValue(std::move(_utils), &_type), - m_slot(toCompactHexWithPrefix(slot_offset.first)), + m_slot(util::toCompactHexWithPrefix(slot_offset.first)), m_offset(slot_offset.second) { } diff --git a/libsolidity/codegen/ir/IRLValue.h b/libsolidity/codegen/ir/IRLValue.h index 38609c387..412ad54f5 100644 --- a/libsolidity/codegen/ir/IRLValue.h +++ b/libsolidity/codegen/ir/IRLValue.h @@ -28,9 +28,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class VariableDeclaration; @@ -129,4 +127,3 @@ private: }; } -} diff --git a/libsolidity/formal/BMC.cpp b/libsolidity/formal/BMC.cpp index f8fa347f0..d56c45e3c 100644 --- a/libsolidity/formal/BMC.cpp +++ b/libsolidity/formal/BMC.cpp @@ -23,9 +23,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend; BMC::BMC( smt::EncodingContext& _context, diff --git a/libsolidity/formal/BMC.h b/libsolidity/formal/BMC.h index 972ee88ce..387e84d4a 100644 --- a/libsolidity/formal/BMC.h +++ b/libsolidity/formal/BMC.h @@ -39,15 +39,15 @@ #include #include -namespace langutil +using solidity::util::h256; + +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class BMC: public SMTEncoder @@ -186,4 +186,3 @@ private: }; } -} diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index bc4e355f5..cfe3efb8b 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -28,14 +28,14 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; CHC::CHC( smt::EncodingContext& _context, ErrorReporter& _errorReporter, - map const& _smtlib2Responses, + map const& _smtlib2Responses, ReadCallback::Callback const& _smtCallback, [[maybe_unused]] smt::SMTSolverChoice _enabledSolvers ): diff --git a/libsolidity/formal/CHC.h b/libsolidity/formal/CHC.h index 6e281d5ef..a732d2ff2 100644 --- a/libsolidity/formal/CHC.h +++ b/libsolidity/formal/CHC.h @@ -38,9 +38,7 @@ #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class CHC: public SMTEncoder @@ -49,7 +47,7 @@ public: CHC( smt::EncodingContext& _context, langutil::ErrorReporter& _errorReporter, - std::map const& _smtlib2Responses, + std::map const& _smtlib2Responses, ReadCallback::Callback const& _smtCallback, smt::SMTSolverChoice _enabledSolvers ); @@ -217,4 +215,3 @@ private: }; } -} diff --git a/libsolidity/formal/CHCSmtLib2Interface.cpp b/libsolidity/formal/CHCSmtLib2Interface.cpp index 11aa87608..b654207e4 100644 --- a/libsolidity/formal/CHCSmtLib2Interface.cpp +++ b/libsolidity/formal/CHCSmtLib2Interface.cpp @@ -30,9 +30,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; +using namespace solidity::frontend::smt; CHCSmtLib2Interface::CHCSmtLib2Interface( map const& _queryResponses, @@ -153,7 +154,7 @@ void CHCSmtLib2Interface::write(string _data) string CHCSmtLib2Interface::querySolver(string const& _input) { - h256 inputHash = dev::keccak256(_input); + util::h256 inputHash = util::keccak256(_input); if (m_queryResponses.count(inputHash)) return m_queryResponses.at(inputHash); if (m_smtCallback) diff --git a/libsolidity/formal/CHCSmtLib2Interface.h b/libsolidity/formal/CHCSmtLib2Interface.h index 24e69a15d..d184cd9a4 100644 --- a/libsolidity/formal/CHCSmtLib2Interface.h +++ b/libsolidity/formal/CHCSmtLib2Interface.h @@ -25,18 +25,14 @@ #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { class CHCSmtLib2Interface: public CHCSolverInterface { public: explicit CHCSmtLib2Interface( - std::map const& _queryResponses, + std::map const& _queryResponses, ReadCallback::Callback const& _smtCallback ); @@ -68,12 +64,10 @@ private: std::string m_accumulatedOutput; std::set m_variables; - std::map const& m_queryResponses; + std::map const& m_queryResponses; std::vector m_unhandledQueries; ReadCallback::Callback m_smtCallback; }; } -} -} diff --git a/libsolidity/formal/CHCSolverInterface.h b/libsolidity/formal/CHCSolverInterface.h index 0862adaff..91198e1a8 100644 --- a/libsolidity/formal/CHCSolverInterface.h +++ b/libsolidity/formal/CHCSolverInterface.h @@ -23,11 +23,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { class CHCSolverInterface @@ -52,5 +48,3 @@ public: }; } -} -} diff --git a/libsolidity/formal/CVC4Interface.cpp b/libsolidity/formal/CVC4Interface.cpp index 03c12cf08..c2aa8d65b 100644 --- a/libsolidity/formal/CVC4Interface.cpp +++ b/libsolidity/formal/CVC4Interface.cpp @@ -21,8 +21,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend::smt; CVC4Interface::CVC4Interface(): m_solver(&m_context) diff --git a/libsolidity/formal/CVC4Interface.h b/libsolidity/formal/CVC4Interface.h index 76318fdee..b5c2a3fd6 100644 --- a/libsolidity/formal/CVC4Interface.h +++ b/libsolidity/formal/CVC4Interface.h @@ -33,11 +33,7 @@ #undef _GLIBCXX_PERMIT_BACKWARD_HASH #endif -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { class CVC4Interface: public SolverInterface, public boost::noncopyable @@ -72,5 +68,3 @@ private: }; } -} -} diff --git a/libsolidity/formal/EncodingContext.cpp b/libsolidity/formal/EncodingContext.cpp index 6c22ec9ca..ff193d2e2 100644 --- a/libsolidity/formal/EncodingContext.cpp +++ b/libsolidity/formal/EncodingContext.cpp @@ -20,8 +20,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend::smt; EncodingContext::EncodingContext(): m_thisAddress(make_unique("this", *this)) @@ -51,13 +52,13 @@ void EncodingContext::clear() /// Variables. -shared_ptr EncodingContext::variable(solidity::VariableDeclaration const& _varDecl) +shared_ptr EncodingContext::variable(frontend::VariableDeclaration const& _varDecl) { solAssert(knownVariable(_varDecl), ""); return m_variables[&_varDecl]; } -bool EncodingContext::createVariable(solidity::VariableDeclaration const& _varDecl) +bool EncodingContext::createVariable(frontend::VariableDeclaration const& _varDecl) { solAssert(!knownVariable(_varDecl), ""); auto const& type = _varDecl.type(); @@ -66,24 +67,24 @@ bool EncodingContext::createVariable(solidity::VariableDeclaration const& _varDe return result.first; } -bool EncodingContext::knownVariable(solidity::VariableDeclaration const& _varDecl) +bool EncodingContext::knownVariable(frontend::VariableDeclaration const& _varDecl) { return m_variables.count(&_varDecl); } -void EncodingContext::resetVariable(solidity::VariableDeclaration const& _variable) +void EncodingContext::resetVariable(frontend::VariableDeclaration const& _variable) { newValue(_variable); setUnknownValue(_variable); } -void EncodingContext::resetVariables(set const& _variables) +void EncodingContext::resetVariables(set const& _variables) { for (auto const* decl: _variables) resetVariable(*decl); } -void EncodingContext::resetVariables(function const& _filter) +void EncodingContext::resetVariables(function const& _filter) { for_each(begin(m_variables), end(m_variables), [&](auto _variable) { @@ -94,16 +95,16 @@ void EncodingContext::resetVariables(functionincreaseIndex(); } -void EncodingContext::setZeroValue(solidity::VariableDeclaration const& _decl) +void EncodingContext::setZeroValue(frontend::VariableDeclaration const& _decl) { solAssert(knownVariable(_decl), ""); setZeroValue(*m_variables.at(&_decl)); @@ -114,7 +115,7 @@ void EncodingContext::setZeroValue(SymbolicVariable& _variable) setSymbolicZeroValue(_variable, *this); } -void EncodingContext::setUnknownValue(solidity::VariableDeclaration const& _decl) +void EncodingContext::setUnknownValue(frontend::VariableDeclaration const& _decl) { solAssert(knownVariable(_decl), ""); setUnknownValue(*m_variables.at(&_decl)); @@ -127,14 +128,14 @@ void EncodingContext::setUnknownValue(SymbolicVariable& _variable) /// Expressions -shared_ptr EncodingContext::expression(solidity::Expression const& _e) +shared_ptr EncodingContext::expression(frontend::Expression const& _e) { if (!knownExpression(_e)) createExpression(_e); return m_expressions.at(&_e); } -bool EncodingContext::createExpression(solidity::Expression const& _e, shared_ptr _symbVar) +bool EncodingContext::createExpression(frontend::Expression const& _e, shared_ptr _symbVar) { solAssert(_e.annotation().type, ""); if (knownExpression(_e)) @@ -155,7 +156,7 @@ bool EncodingContext::createExpression(solidity::Expression const& _e, shared_pt } } -bool EncodingContext::knownExpression(solidity::Expression const& _e) const +bool EncodingContext::knownExpression(frontend::Expression const& _e) const { return m_expressions.count(&_e); } @@ -168,7 +169,7 @@ shared_ptr EncodingContext::globalSymbol(string const& _name) return m_globalContext.at(_name); } -bool EncodingContext::createGlobalSymbol(string const& _name, solidity::Expression const& _expr) +bool EncodingContext::createGlobalSymbol(string const& _name, frontend::Expression const& _expr) { solAssert(!knownGlobalSymbol(_name), ""); auto result = newSymbolicVariable(*_expr.annotation().type, _name, *this); diff --git a/libsolidity/formal/EncodingContext.h b/libsolidity/formal/EncodingContext.h index f2c9d0e31..9b75065f6 100644 --- a/libsolidity/formal/EncodingContext.h +++ b/libsolidity/formal/EncodingContext.h @@ -23,11 +23,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { /** @@ -67,48 +63,48 @@ public: /// Variables. //@{ /// @returns the symbolic representation of a program variable. - std::shared_ptr variable(solidity::VariableDeclaration const& _varDecl); + std::shared_ptr variable(frontend::VariableDeclaration const& _varDecl); /// @returns all symbolic variables. - std::unordered_map> const& variables() const { return m_variables; } + std::unordered_map> const& variables() const { return m_variables; } /// Creates a symbolic variable and /// @returns true if a variable's type is not supported and is therefore abstract. - bool createVariable(solidity::VariableDeclaration const& _varDecl); + bool createVariable(frontend::VariableDeclaration const& _varDecl); /// @returns true if variable was created. - bool knownVariable(solidity::VariableDeclaration const& _varDecl); + bool knownVariable(frontend::VariableDeclaration const& _varDecl); /// Resets a specific variable. - void resetVariable(solidity::VariableDeclaration const& _variable); + void resetVariable(frontend::VariableDeclaration const& _variable); /// Resets a set of variables. - void resetVariables(std::set const& _variables); + void resetVariables(std::set const& _variables); /// Resets variables according to a predicate. - void resetVariables(std::function const& _filter); + void resetVariables(std::function const& _filter); ///Resets all variables. void resetAllVariables(); /// Allocates a new index for the declaration, updates the current /// index to this value and returns the expression. - Expression newValue(solidity::VariableDeclaration const& _decl); + Expression newValue(frontend::VariableDeclaration const& _decl); /// Sets the value of the declaration to zero. - void setZeroValue(solidity::VariableDeclaration const& _decl); + void setZeroValue(frontend::VariableDeclaration const& _decl); void setZeroValue(SymbolicVariable& _variable); /// Resets the variable to an unknown value (in its range). - void setUnknownValue(solidity::VariableDeclaration const& decl); + void setUnknownValue(frontend::VariableDeclaration const& decl); void setUnknownValue(SymbolicVariable& _variable); //@} /// Expressions. ////@{ /// @returns the symbolic representation of an AST node expression. - std::shared_ptr expression(solidity::Expression const& _e); + std::shared_ptr expression(frontend::Expression const& _e); /// @returns all symbolic expressions. - std::unordered_map> const& expressions() const { return m_expressions; } + std::unordered_map> const& expressions() const { return m_expressions; } /// Creates the expression (value can be arbitrary). /// @returns true if type is not supported. - bool createExpression(solidity::Expression const& _e, std::shared_ptr _symbExpr = nullptr); + bool createExpression(frontend::Expression const& _e, std::shared_ptr _symbExpr = nullptr); /// Checks if expression was created. - bool knownExpression(solidity::Expression const& _e) const; + bool knownExpression(frontend::Expression const& _e) const; //@} /// Global variables and functions. @@ -120,7 +116,7 @@ public: /// Defines a new global variable or function /// and @returns true if type was abstracted. - bool createGlobalSymbol(std::string const& _name, solidity::Expression const& _expr); + bool createGlobalSymbol(std::string const& _name, frontend::Expression const& _expr); /// Checks if special variable or function was seen. bool knownGlobalSymbol(std::string const& _var) const; //@} @@ -158,10 +154,10 @@ private: /// Symbolic expressions. //{@ /// Symbolic variables. - std::unordered_map> m_variables; + std::unordered_map> m_variables; /// Symbolic expressions. - std::unordered_map> m_expressions; + std::unordered_map> m_expressions; /// Symbolic representation of global symbols including /// variables and functions. @@ -188,5 +184,3 @@ private: }; } -} -} diff --git a/libsolidity/formal/ModelChecker.cpp b/libsolidity/formal/ModelChecker.cpp index afa06ff2c..c69849a06 100644 --- a/libsolidity/formal/ModelChecker.cpp +++ b/libsolidity/formal/ModelChecker.cpp @@ -18,9 +18,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend; ModelChecker::ModelChecker( ErrorReporter& _errorReporter, diff --git a/libsolidity/formal/ModelChecker.h b/libsolidity/formal/ModelChecker.h index d540266ff..f22ca59b8 100644 --- a/libsolidity/formal/ModelChecker.h +++ b/libsolidity/formal/ModelChecker.h @@ -30,15 +30,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ModelChecker @@ -75,4 +73,3 @@ private: }; } -} diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 70b4a6c9f..2c86eae0b 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -25,9 +25,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend; SMTEncoder::SMTEncoder(smt::EncodingContext& _context): m_errorReporter(m_smtErrors), diff --git a/libsolidity/formal/SMTEncoder.h b/libsolidity/formal/SMTEncoder.h index b39fff270..eddab0eb1 100644 --- a/libsolidity/formal/SMTEncoder.h +++ b/libsolidity/formal/SMTEncoder.h @@ -36,15 +36,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class SMTEncoder: public ASTConstVisitor @@ -274,4 +272,3 @@ protected: }; } -} diff --git a/libsolidity/formal/SMTLib2Interface.cpp b/libsolidity/formal/SMTLib2Interface.cpp index 77a44abe1..850bcee69 100644 --- a/libsolidity/formal/SMTLib2Interface.cpp +++ b/libsolidity/formal/SMTLib2Interface.cpp @@ -30,9 +30,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; +using namespace solidity::frontend::smt; SMTLib2Interface::SMTLib2Interface( map const& _queryResponses, @@ -231,7 +232,7 @@ vector SMTLib2Interface::parseValues(string::const_iterator _start, stri string SMTLib2Interface::querySolver(string const& _input) { - h256 inputHash = dev::keccak256(_input); + h256 inputHash = keccak256(_input); if (m_queryResponses.count(inputHash)) return m_queryResponses.at(inputHash); if (m_smtCallback) diff --git a/libsolidity/formal/SMTLib2Interface.h b/libsolidity/formal/SMTLib2Interface.h index f3e242f93..550b8af7c 100644 --- a/libsolidity/formal/SMTLib2Interface.h +++ b/libsolidity/formal/SMTLib2Interface.h @@ -31,18 +31,14 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { class SMTLib2Interface: public SolverInterface, public boost::noncopyable { public: explicit SMTLib2Interface( - std::map const& _queryResponses, + std::map const& _queryResponses, ReadCallback::Callback const& _smtCallback ); @@ -79,12 +75,10 @@ private: std::vector m_accumulatedOutput; std::map m_variables; - std::map const& m_queryResponses; + std::map const& m_queryResponses; std::vector m_unhandledQueries; ReadCallback::Callback m_smtCallback; }; } -} -} diff --git a/libsolidity/formal/SMTPortfolio.cpp b/libsolidity/formal/SMTPortfolio.cpp index 26d0f4b4e..9ae745b7c 100644 --- a/libsolidity/formal/SMTPortfolio.cpp +++ b/libsolidity/formal/SMTPortfolio.cpp @@ -26,9 +26,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; +using namespace solidity::frontend::smt; SMTPortfolio::SMTPortfolio( map const& _smtlib2Responses, diff --git a/libsolidity/formal/SMTPortfolio.h b/libsolidity/formal/SMTPortfolio.h index 47691dff5..1cd1e6f89 100644 --- a/libsolidity/formal/SMTPortfolio.h +++ b/libsolidity/formal/SMTPortfolio.h @@ -26,11 +26,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { /** @@ -43,7 +39,7 @@ class SMTPortfolio: public SolverInterface, public boost::noncopyable { public: SMTPortfolio( - std::map const& _smtlib2Responses, + std::map const& _smtlib2Responses, ReadCallback::Callback const& _smtCallback, SMTSolverChoice _enabledSolvers ); @@ -70,5 +66,3 @@ private: }; } -} -} diff --git a/libsolidity/formal/SSAVariable.cpp b/libsolidity/formal/SSAVariable.cpp index 7c8ecc2b4..90e77a050 100644 --- a/libsolidity/formal/SSAVariable.cpp +++ b/libsolidity/formal/SSAVariable.cpp @@ -18,7 +18,8 @@ #include using namespace std; -using namespace dev::solidity::smt; +using namespace solidity::frontend; +using namespace solidity::frontend::smt; SSAVariable::SSAVariable() { diff --git a/libsolidity/formal/SSAVariable.h b/libsolidity/formal/SSAVariable.h index b4cd59133..9c86af40b 100644 --- a/libsolidity/formal/SSAVariable.h +++ b/libsolidity/formal/SSAVariable.h @@ -19,11 +19,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { /** @@ -50,5 +46,3 @@ private: }; } -} -} diff --git a/libsolidity/formal/SolverInterface.h b/libsolidity/formal/SolverInterface.h index 81f6ea497..3afb0c468 100644 --- a/libsolidity/formal/SolverInterface.h +++ b/libsolidity/formal/SolverInterface.h @@ -29,11 +29,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { struct SMTSolverChoice @@ -145,7 +141,7 @@ struct SortSort: public Sort }; // Forward declaration. -SortPointer smtSort(solidity::Type const& _type); +SortPointer smtSort(Type const& _type); /// C++ representation of an SMTLIB2 expression. class Expression @@ -153,7 +149,7 @@ class Expression friend class SolverInterface; public: explicit Expression(bool _v): Expression(_v ? "true" : "false", Kind::Bool) {} - explicit Expression(solidity::TypePointer _type): Expression(_type->toString(), {}, std::make_shared(smtSort(*_type))) {} + explicit Expression(frontend::TypePointer _type): Expression(_type->toString(), {}, std::make_shared(smtSort(*_type))) {} Expression(size_t _number): Expression(std::to_string(_number), Kind::Int) {} Expression(u256 const& _number): Expression(_number.str(), Kind::Int) {} Expression(s256 const& _number): Expression(_number.str(), Kind::Int) {} @@ -377,5 +373,3 @@ public: }; } -} -} diff --git a/libsolidity/formal/SymbolicTypes.cpp b/libsolidity/formal/SymbolicTypes.cpp index 0fe05e723..90cf33a63 100644 --- a/libsolidity/formal/SymbolicTypes.cpp +++ b/libsolidity/formal/SymbolicTypes.cpp @@ -24,14 +24,10 @@ using namespace std; -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { -SortPointer smtSort(solidity::Type const& _type) +SortPointer smtSort(frontend::Type const& _type) { switch (smtKind(_type.category())) { @@ -41,7 +37,7 @@ SortPointer smtSort(solidity::Type const& _type) return make_shared(Kind::Bool); case Kind::Function: { - auto fType = dynamic_cast(&_type); + auto fType = dynamic_cast(&_type); solAssert(fType, ""); vector parameterSorts = smtSort(fType->parameterTypes()); auto returnTypes = fType->returnParameterTypes(); @@ -61,13 +57,13 @@ SortPointer smtSort(solidity::Type const& _type) { if (isMapping(_type.category())) { - auto mapType = dynamic_cast(&_type); + auto mapType = dynamic_cast(&_type); solAssert(mapType, ""); return make_shared(smtSortAbstractFunction(*mapType->keyType()), smtSortAbstractFunction(*mapType->valueType())); } else if (isStringLiteral(_type.category())) { - auto stringLitType = dynamic_cast(&_type); + auto stringLitType = dynamic_cast(&_type); solAssert(stringLitType, ""); auto intSort = make_shared(Kind::Int); return make_shared(intSort, intSort); @@ -75,7 +71,7 @@ SortPointer smtSort(solidity::Type const& _type) else { solAssert(isArray(_type.category()), ""); - auto arrayType = dynamic_cast(&_type); + auto arrayType = dynamic_cast(&_type); solAssert(arrayType, ""); return make_shared(make_shared(Kind::Int), smtSortAbstractFunction(*arrayType->baseType())); } @@ -86,7 +82,7 @@ SortPointer smtSort(solidity::Type const& _type) } } -vector smtSort(vector const& _types) +vector smtSort(vector const& _types) { vector sorts; for (auto const& type: _types) @@ -94,14 +90,14 @@ vector smtSort(vector const& _types) return sorts; } -SortPointer smtSortAbstractFunction(solidity::Type const& _type) +SortPointer smtSortAbstractFunction(frontend::Type const& _type) { if (isFunction(_type.category())) return make_shared(Kind::Int); return smtSort(_type); } -Kind smtKind(solidity::Type::Category _category) +Kind smtKind(frontend::Type::Category _category) { if (isNumber(_category)) return Kind::Int; @@ -115,7 +111,7 @@ Kind smtKind(solidity::Type::Category _category) return Kind::Int; } -bool isSupportedType(solidity::Type::Category _category) +bool isSupportedType(frontend::Type::Category _category) { return isNumber(_category) || isBool(_category) || @@ -124,25 +120,25 @@ bool isSupportedType(solidity::Type::Category _category) isTuple(_category); } -bool isSupportedTypeDeclaration(solidity::Type::Category _category) +bool isSupportedTypeDeclaration(frontend::Type::Category _category) { return isSupportedType(_category) || isFunction(_category); } pair> newSymbolicVariable( - solidity::Type const& _type, + frontend::Type const& _type, std::string const& _uniqueName, EncodingContext& _context ) { bool abstract = false; shared_ptr var; - solidity::TypePointer type = &_type; + frontend::TypePointer type = &_type; if (!isSupportedTypeDeclaration(_type)) { abstract = true; - var = make_shared(solidity::TypeProvider::uint256(), type, _uniqueName, _context); + var = make_shared(frontend::TypeProvider::uint256(), type, _uniqueName, _context); } else if (isBool(_type.category())) var = make_shared(type, _uniqueName, _context); @@ -155,7 +151,7 @@ pair> newSymbolicVariable( return find_if( begin(params), end(params), - [&](TypePointer _paramType) { return _paramType->category() == solidity::Type::Category::Function; } + [&](TypePointer _paramType) { return _paramType->category() == frontend::Type::Category::Function; } ); }; if ( @@ -173,7 +169,7 @@ pair> newSymbolicVariable( var = make_shared(type, type, _uniqueName, _context); else if (isFixedBytes(_type.category())) { - auto fixedBytesType = dynamic_cast(type); + auto fixedBytesType = dynamic_cast(type); solAssert(fixedBytesType, ""); var = make_shared(type, fixedBytesType->numBytes(), _uniqueName, _context); } @@ -183,10 +179,10 @@ pair> newSymbolicVariable( var = make_shared(type, _uniqueName, _context); else if (isRational(_type.category())) { - auto rational = dynamic_cast(&_type); + auto rational = dynamic_cast(&_type); solAssert(rational, ""); if (rational->isFractional()) - var = make_shared(solidity::TypeProvider::uint256(), type, _uniqueName, _context); + var = make_shared(frontend::TypeProvider::uint256(), type, _uniqueName, _context); else var = make_shared(type, type, _uniqueName, _context); } @@ -206,47 +202,47 @@ pair> newSymbolicVariable( return make_pair(abstract, var); } -bool isSupportedType(solidity::Type const& _type) +bool isSupportedType(frontend::Type const& _type) { return isSupportedType(_type.category()); } -bool isSupportedTypeDeclaration(solidity::Type const& _type) +bool isSupportedTypeDeclaration(frontend::Type const& _type) { return isSupportedTypeDeclaration(_type.category()); } -bool isInteger(solidity::Type::Category _category) +bool isInteger(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Integer; + return _category == frontend::Type::Category::Integer; } -bool isRational(solidity::Type::Category _category) +bool isRational(frontend::Type::Category _category) { - return _category == solidity::Type::Category::RationalNumber; + return _category == frontend::Type::Category::RationalNumber; } -bool isFixedBytes(solidity::Type::Category _category) +bool isFixedBytes(frontend::Type::Category _category) { - return _category == solidity::Type::Category::FixedBytes; + return _category == frontend::Type::Category::FixedBytes; } -bool isAddress(solidity::Type::Category _category) +bool isAddress(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Address; + return _category == frontend::Type::Category::Address; } -bool isContract(solidity::Type::Category _category) +bool isContract(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Contract; + return _category == frontend::Type::Category::Contract; } -bool isEnum(solidity::Type::Category _category) +bool isEnum(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Enum; + return _category == frontend::Type::Category::Enum; } -bool isNumber(solidity::Type::Category _category) +bool isNumber(frontend::Type::Category _category) { return isInteger(_category) || isRational(_category) || @@ -256,43 +252,43 @@ bool isNumber(solidity::Type::Category _category) isEnum(_category); } -bool isBool(solidity::Type::Category _category) +bool isBool(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Bool; + return _category == frontend::Type::Category::Bool; } -bool isFunction(solidity::Type::Category _category) +bool isFunction(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Function; + return _category == frontend::Type::Category::Function; } -bool isMapping(solidity::Type::Category _category) +bool isMapping(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Mapping; + return _category == frontend::Type::Category::Mapping; } -bool isArray(solidity::Type::Category _category) +bool isArray(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Array || - _category == solidity::Type::Category::StringLiteral; + return _category == frontend::Type::Category::Array || + _category == frontend::Type::Category::StringLiteral; } -bool isTuple(solidity::Type::Category _category) +bool isTuple(frontend::Type::Category _category) { - return _category == solidity::Type::Category::Tuple; + return _category == frontend::Type::Category::Tuple; } -bool isStringLiteral(solidity::Type::Category _category) +bool isStringLiteral(frontend::Type::Category _category) { - return _category == solidity::Type::Category::StringLiteral; + return _category == frontend::Type::Category::StringLiteral; } -Expression minValue(solidity::IntegerType const& _type) +Expression minValue(frontend::IntegerType const& _type) { return Expression(_type.minValue()); } -Expression maxValue(solidity::IntegerType const& _type) +Expression maxValue(frontend::IntegerType const& _type) { return Expression(_type.maxValue()); } @@ -302,13 +298,13 @@ void setSymbolicZeroValue(SymbolicVariable const& _variable, EncodingContext& _c setSymbolicZeroValue(_variable.currentValue(), _variable.type(), _context); } -void setSymbolicZeroValue(Expression _expr, solidity::TypePointer const& _type, EncodingContext& _context) +void setSymbolicZeroValue(Expression _expr, frontend::TypePointer const& _type, EncodingContext& _context) { solAssert(_type, ""); _context.addAssertion(_expr == zeroValue(_type)); } -Expression zeroValue(solidity::TypePointer const& _type) +Expression zeroValue(frontend::TypePointer const& _type) { solAssert(_type, ""); if (isSupportedType(_type->category())) @@ -336,19 +332,19 @@ void setSymbolicUnknownValue(SymbolicVariable const& _variable, EncodingContext& setSymbolicUnknownValue(_variable.currentValue(), _variable.type(), _context); } -void setSymbolicUnknownValue(Expression _expr, solidity::TypePointer const& _type, EncodingContext& _context) +void setSymbolicUnknownValue(Expression _expr, frontend::TypePointer const& _type, EncodingContext& _context) { solAssert(_type, ""); if (isEnum(_type->category())) { - auto enumType = dynamic_cast(_type); + auto enumType = dynamic_cast(_type); solAssert(enumType, ""); _context.addAssertion(_expr >= 0); _context.addAssertion(_expr < enumType->numberOfMembers()); } else if (isInteger(_type->category())) { - auto intType = dynamic_cast(_type); + auto intType = dynamic_cast(_type); solAssert(intType, ""); _context.addAssertion(_expr >= minValue(*intType)); _context.addAssertion(_expr <= maxValue(*intType)); @@ -356,5 +352,3 @@ void setSymbolicUnknownValue(Expression _expr, solidity::TypePointer const& _typ } } -} -} diff --git a/libsolidity/formal/SymbolicTypes.h b/libsolidity/formal/SymbolicTypes.h index 2db2807ac..55c88811d 100644 --- a/libsolidity/formal/SymbolicTypes.h +++ b/libsolidity/formal/SymbolicTypes.h @@ -22,57 +22,51 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { /// Returns the SMT sort that models the Solidity type _type. -SortPointer smtSort(solidity::Type const& _type); -std::vector smtSort(std::vector const& _types); +SortPointer smtSort(frontend::Type const& _type); +std::vector smtSort(std::vector const& _types); /// If _type has type Function, abstract it to Integer. /// Otherwise return smtSort(_type). -SortPointer smtSortAbstractFunction(solidity::Type const& _type); +SortPointer smtSortAbstractFunction(frontend::Type const& _type); /// Returns the SMT kind that models the Solidity type type category _category. -Kind smtKind(solidity::Type::Category _category); +Kind smtKind(frontend::Type::Category _category); /// Returns true if type is fully supported (declaration and operations). -bool isSupportedType(solidity::Type::Category _category); -bool isSupportedType(solidity::Type const& _type); +bool isSupportedType(frontend::Type::Category _category); +bool isSupportedType(frontend::Type const& _type); /// Returns true if type is partially supported (declaration). -bool isSupportedTypeDeclaration(solidity::Type::Category _category); -bool isSupportedTypeDeclaration(solidity::Type const& _type); +bool isSupportedTypeDeclaration(frontend::Type::Category _category); +bool isSupportedTypeDeclaration(frontend::Type const& _type); -bool isInteger(solidity::Type::Category _category); -bool isRational(solidity::Type::Category _category); -bool isFixedBytes(solidity::Type::Category _category); -bool isAddress(solidity::Type::Category _category); -bool isContract(solidity::Type::Category _category); -bool isEnum(solidity::Type::Category _category); -bool isNumber(solidity::Type::Category _category); -bool isBool(solidity::Type::Category _category); -bool isFunction(solidity::Type::Category _category); -bool isMapping(solidity::Type::Category _category); -bool isArray(solidity::Type::Category _category); -bool isTuple(solidity::Type::Category _category); -bool isStringLiteral(solidity::Type::Category _category); +bool isInteger(frontend::Type::Category _category); +bool isRational(frontend::Type::Category _category); +bool isFixedBytes(frontend::Type::Category _category); +bool isAddress(frontend::Type::Category _category); +bool isContract(frontend::Type::Category _category); +bool isEnum(frontend::Type::Category _category); +bool isNumber(frontend::Type::Category _category); +bool isBool(frontend::Type::Category _category); +bool isFunction(frontend::Type::Category _category); +bool isMapping(frontend::Type::Category _category); +bool isArray(frontend::Type::Category _category); +bool isTuple(frontend::Type::Category _category); +bool isStringLiteral(frontend::Type::Category _category); /// Returns a new symbolic variable, according to _type. /// Also returns whether the type is abstract or not, /// which is true for unsupported types. -std::pair> newSymbolicVariable(solidity::Type const& _type, std::string const& _uniqueName, EncodingContext& _context); +std::pair> newSymbolicVariable(frontend::Type const& _type, std::string const& _uniqueName, EncodingContext& _context); -Expression minValue(solidity::IntegerType const& _type); -Expression maxValue(solidity::IntegerType const& _type); -Expression zeroValue(solidity::TypePointer const& _type); +Expression minValue(frontend::IntegerType const& _type); +Expression maxValue(frontend::IntegerType const& _type); +Expression zeroValue(frontend::TypePointer const& _type); void setSymbolicZeroValue(SymbolicVariable const& _variable, EncodingContext& _context); -void setSymbolicZeroValue(Expression _expr, solidity::TypePointer const& _type, EncodingContext& _context); +void setSymbolicZeroValue(Expression _expr, frontend::TypePointer const& _type, EncodingContext& _context); void setSymbolicUnknownValue(SymbolicVariable const& _variable, EncodingContext& _context); -void setSymbolicUnknownValue(Expression _expr, solidity::TypePointer const& _type, EncodingContext& _context); +void setSymbolicUnknownValue(Expression _expr, frontend::TypePointer const& _type, EncodingContext& _context); } -} -} diff --git a/libsolidity/formal/SymbolicVariables.cpp b/libsolidity/formal/SymbolicVariables.cpp index d0163d381..8f285c883 100644 --- a/libsolidity/formal/SymbolicVariables.cpp +++ b/libsolidity/formal/SymbolicVariables.cpp @@ -21,12 +21,13 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::frontend; +using namespace solidity::frontend::smt; SymbolicVariable::SymbolicVariable( - solidity::TypePointer _type, - solidity::TypePointer _originalType, + TypePointer _type, + TypePointer _originalType, string _uniqueName, EncodingContext& _context ): @@ -54,7 +55,7 @@ SymbolicVariable::SymbolicVariable( solAssert(m_sort, ""); } -Expression SymbolicVariable::currentValue(solidity::TypePointer const&) const +smt::Expression SymbolicVariable::currentValue(frontend::TypePointer const&) const { return valueAtIndex(m_ssa->index()); } @@ -64,7 +65,7 @@ string SymbolicVariable::currentName() const return uniqueSymbol(m_ssa->index()); } -Expression SymbolicVariable::valueAtIndex(int _index) const +smt::Expression SymbolicVariable::valueAtIndex(int _index) const { return m_context.newVariable(uniqueSymbol(_index), m_sort); } @@ -79,31 +80,31 @@ string SymbolicVariable::uniqueSymbol(unsigned _index) const return m_uniqueName + "_" + to_string(_index); } -Expression SymbolicVariable::resetIndex() +smt::Expression SymbolicVariable::resetIndex() { m_ssa->resetIndex(); return currentValue(); } -Expression SymbolicVariable::increaseIndex() +smt::Expression SymbolicVariable::increaseIndex() { ++(*m_ssa); return currentValue(); } SymbolicBoolVariable::SymbolicBoolVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, string _uniqueName, EncodingContext& _context ): SymbolicVariable(_type, _type, move(_uniqueName), _context) { - solAssert(m_type->category() == solidity::Type::Category::Bool, ""); + solAssert(m_type->category() == frontend::Type::Category::Bool, ""); } SymbolicIntVariable::SymbolicIntVariable( - solidity::TypePointer _type, - solidity::TypePointer _originalType, + frontend::TypePointer _type, + frontend::TypePointer _originalType, string _uniqueName, EncodingContext& _context ): @@ -121,7 +122,7 @@ SymbolicAddressVariable::SymbolicAddressVariable( } SymbolicFixedBytesVariable::SymbolicFixedBytesVariable( - solidity::TypePointer _originalType, + frontend::TypePointer _originalType, unsigned _numBytes, string _uniqueName, EncodingContext& _context @@ -131,14 +132,14 @@ SymbolicFixedBytesVariable::SymbolicFixedBytesVariable( } SymbolicFunctionVariable::SymbolicFunctionVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, string _uniqueName, EncodingContext& _context ): SymbolicVariable(_type, _type, move(_uniqueName), _context), m_declaration(m_context.newVariable(currentName(), m_sort)) { - solAssert(m_type->category() == solidity::Type::Category::Function, ""); + solAssert(m_type->category() == frontend::Type::Category::Function, ""); } SymbolicFunctionVariable::SymbolicFunctionVariable( @@ -152,33 +153,33 @@ SymbolicFunctionVariable::SymbolicFunctionVariable( solAssert(m_sort->kind == Kind::Function, ""); } -Expression SymbolicFunctionVariable::currentValue(solidity::TypePointer const& _targetType) const +smt::Expression SymbolicFunctionVariable::currentValue(frontend::TypePointer const& _targetType) const { return m_abstract.currentValue(_targetType); } -Expression SymbolicFunctionVariable::currentFunctionValue() const +smt::Expression SymbolicFunctionVariable::currentFunctionValue() const { return m_declaration; } -Expression SymbolicFunctionVariable::valueAtIndex(int _index) const +smt::Expression SymbolicFunctionVariable::valueAtIndex(int _index) const { return m_abstract.valueAtIndex(_index); } -Expression SymbolicFunctionVariable::functionValueAtIndex(int _index) const +smt::Expression SymbolicFunctionVariable::functionValueAtIndex(int _index) const { return SymbolicVariable::valueAtIndex(_index); } -Expression SymbolicFunctionVariable::resetIndex() +smt::Expression SymbolicFunctionVariable::resetIndex() { SymbolicVariable::resetIndex(); return m_abstract.resetIndex(); } -Expression SymbolicFunctionVariable::increaseIndex() +smt::Expression SymbolicFunctionVariable::increaseIndex() { ++(*m_ssa); resetDeclaration(); @@ -186,7 +187,7 @@ Expression SymbolicFunctionVariable::increaseIndex() return m_abstract.currentValue(); } -Expression SymbolicFunctionVariable::operator()(vector _arguments) const +smt::Expression SymbolicFunctionVariable::operator()(vector _arguments) const { return m_declaration(_arguments); } @@ -197,7 +198,7 @@ void SymbolicFunctionVariable::resetDeclaration() } SymbolicMappingVariable::SymbolicMappingVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, string _uniqueName, EncodingContext& _context ): @@ -207,8 +208,8 @@ SymbolicMappingVariable::SymbolicMappingVariable( } SymbolicArrayVariable::SymbolicArrayVariable( - solidity::TypePointer _type, - solidity::TypePointer _originalType, + frontend::TypePointer _type, + frontend::TypePointer _originalType, string _uniqueName, EncodingContext& _context ): @@ -217,21 +218,21 @@ SymbolicArrayVariable::SymbolicArrayVariable( solAssert(isArray(m_type->category()), ""); } -Expression SymbolicArrayVariable::currentValue(solidity::TypePointer const& _targetType) const +smt::Expression SymbolicArrayVariable::currentValue(frontend::TypePointer const& _targetType) const { if (_targetType) // StringLiterals are encoded as SMT arrays in the generic case, // but they can also be compared/assigned to fixed bytes, in which // case they'd need to be encoded as numbers. if (auto strType = dynamic_cast(m_originalType)) - if (_targetType->category() == solidity::Type::Category::FixedBytes) - return smt::Expression(u256(toHex(asBytes(strType->value()), HexPrefix::Add))); + if (_targetType->category() == frontend::Type::Category::FixedBytes) + return smt::Expression(u256(toHex(util::asBytes(strType->value()), util::HexPrefix::Add))); return SymbolicVariable::currentValue(_targetType); } SymbolicEnumVariable::SymbolicEnumVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, string _uniqueName, EncodingContext& _context ): @@ -241,7 +242,7 @@ SymbolicEnumVariable::SymbolicEnumVariable( } SymbolicTupleVariable::SymbolicTupleVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, string _uniqueName, EncodingContext& _context ): diff --git a/libsolidity/formal/SymbolicVariables.h b/libsolidity/formal/SymbolicVariables.h index 4d9fcc2f7..be75931f2 100644 --- a/libsolidity/formal/SymbolicVariables.h +++ b/libsolidity/formal/SymbolicVariables.h @@ -23,11 +23,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { class EncodingContext; @@ -40,8 +36,8 @@ class SymbolicVariable { public: SymbolicVariable( - solidity::TypePointer _type, - solidity::TypePointer _originalType, + frontend::TypePointer _type, + frontend::TypePointer _originalType, std::string _uniqueName, EncodingContext& _context ); @@ -53,7 +49,7 @@ public: virtual ~SymbolicVariable() = default; - virtual Expression currentValue(solidity::TypePointer const& _targetType = TypePointer{}) const; + virtual Expression currentValue(frontend::TypePointer const& _targetType = TypePointer{}) const; std::string currentName() const; virtual Expression valueAtIndex(int _index) const; virtual std::string nameAtIndex(int _index) const; @@ -68,8 +64,8 @@ public: unsigned& index() { return m_ssa->index(); } SortPointer const& sort() const { return m_sort; } - solidity::TypePointer const& type() const { return m_type; } - solidity::TypePointer const& originalType() const { return m_originalType; } + frontend::TypePointer const& type() const { return m_type; } + frontend::TypePointer const& originalType() const { return m_originalType; } protected: std::string uniqueSymbol(unsigned _index) const; @@ -77,9 +73,9 @@ protected: /// SMT sort. SortPointer m_sort; /// Solidity type, used for size and range in number types. - solidity::TypePointer m_type; + frontend::TypePointer m_type; /// Solidity original type, used for type conversion if necessary. - solidity::TypePointer m_originalType; + frontend::TypePointer m_originalType; std::string m_uniqueName; EncodingContext& m_context; std::unique_ptr m_ssa; @@ -92,7 +88,7 @@ class SymbolicBoolVariable: public SymbolicVariable { public: SymbolicBoolVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, std::string _uniqueName, EncodingContext& _context ); @@ -105,8 +101,8 @@ class SymbolicIntVariable: public SymbolicVariable { public: SymbolicIntVariable( - solidity::TypePointer _type, - solidity::TypePointer _originalType, + frontend::TypePointer _type, + frontend::TypePointer _originalType, std::string _uniqueName, EncodingContext& _context ); @@ -131,7 +127,7 @@ class SymbolicFixedBytesVariable: public SymbolicIntVariable { public: SymbolicFixedBytesVariable( - solidity::TypePointer _originalType, + frontend::TypePointer _originalType, unsigned _numBytes, std::string _uniqueName, EncodingContext& _context @@ -150,7 +146,7 @@ class SymbolicFunctionVariable: public SymbolicVariable { public: SymbolicFunctionVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, std::string _uniqueName, EncodingContext& _context ); @@ -160,7 +156,7 @@ public: EncodingContext& _context ); - Expression currentValue(solidity::TypePointer const& _targetType = TypePointer{}) const override; + Expression currentValue(frontend::TypePointer const& _targetType = TypePointer{}) const override; // Explicit request the function declaration. Expression currentFunctionValue() const; @@ -198,7 +194,7 @@ class SymbolicMappingVariable: public SymbolicVariable { public: SymbolicMappingVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, std::string _uniqueName, EncodingContext& _context ); @@ -211,13 +207,13 @@ class SymbolicArrayVariable: public SymbolicVariable { public: SymbolicArrayVariable( - solidity::TypePointer _type, - solidity::TypePointer _originalTtype, + frontend::TypePointer _type, + frontend::TypePointer _originalTtype, std::string _uniqueName, EncodingContext& _context ); - Expression currentValue(solidity::TypePointer const& _targetType = TypePointer{}) const override; + Expression currentValue(frontend::TypePointer const& _targetType = TypePointer{}) const override; }; /** @@ -227,7 +223,7 @@ class SymbolicEnumVariable: public SymbolicVariable { public: SymbolicEnumVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, std::string _uniqueName, EncodingContext& _context ); @@ -240,7 +236,7 @@ class SymbolicTupleVariable: public SymbolicVariable { public: SymbolicTupleVariable( - solidity::TypePointer _type, + frontend::TypePointer _type, std::string _uniqueName, EncodingContext& _context ); @@ -255,5 +251,3 @@ private: }; } -} -} diff --git a/libsolidity/formal/VariableUsage.cpp b/libsolidity/formal/VariableUsage.cpp index 585072d3b..62e60e3f7 100644 --- a/libsolidity/formal/VariableUsage.cpp +++ b/libsolidity/formal/VariableUsage.cpp @@ -23,9 +23,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; +using namespace solidity::frontend::smt; set VariableUsage::touchedVariables(ASTNode const& _node, vector const& _outerCallstack) { diff --git a/libsolidity/formal/VariableUsage.h b/libsolidity/formal/VariableUsage.h index 7985655ab..7b55998d2 100644 --- a/libsolidity/formal/VariableUsage.h +++ b/libsolidity/formal/VariableUsage.h @@ -22,11 +22,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { /** @@ -61,5 +57,3 @@ private: }; } -} -} diff --git a/libsolidity/formal/Z3CHCInterface.cpp b/libsolidity/formal/Z3CHCInterface.cpp index 017fb1a58..05b0a2032 100644 --- a/libsolidity/formal/Z3CHCInterface.cpp +++ b/libsolidity/formal/Z3CHCInterface.cpp @@ -21,8 +21,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity::smt; +using namespace solidity; +using namespace solidity::frontend::smt; Z3CHCInterface::Z3CHCInterface(): m_z3Interface(make_unique()), diff --git a/libsolidity/formal/Z3CHCInterface.h b/libsolidity/formal/Z3CHCInterface.h index 20373c244..a7b7d6aeb 100644 --- a/libsolidity/formal/Z3CHCInterface.h +++ b/libsolidity/formal/Z3CHCInterface.h @@ -24,11 +24,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { class Z3CHCInterface: public CHCSolverInterface @@ -57,5 +53,3 @@ private: }; } -} -} diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 74b3cfe2b..679dda43e 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -21,8 +21,7 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity::smt; +using namespace solidity::frontend::smt; Z3Interface::Z3Interface(): m_solver(m_context) @@ -98,7 +97,7 @@ pair> Z3Interface::check(vector const& _ { z3::model m = m_solver.get_model(); for (Expression const& e: _expressionsToEvaluate) - values.push_back(toString(m.eval(toZ3Expr(e)))); + values.push_back(util::toString(m.eval(toZ3Expr(e)))); } } catch (z3::exception const&) diff --git a/libsolidity/formal/Z3Interface.h b/libsolidity/formal/Z3Interface.h index df5db8d26..a6247a541 100644 --- a/libsolidity/formal/Z3Interface.h +++ b/libsolidity/formal/Z3Interface.h @@ -21,11 +21,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace smt +namespace solidity::frontend::smt { class Z3Interface: public SolverInterface, public boost::noncopyable @@ -70,5 +66,3 @@ private: }; } -} -} diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index 359b8c976..7ab3861cd 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -23,8 +23,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; namespace { diff --git a/libsolidity/interface/ABI.h b/libsolidity/interface/ABI.h index 9e1ba294e..1dd578ceb 100644 --- a/libsolidity/interface/ABI.h +++ b/libsolidity/interface/ABI.h @@ -24,9 +24,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { // Forward declarations @@ -67,4 +65,3 @@ private: }; } -} diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 73824297e..e6d50f7e4 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -67,9 +67,12 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; + +using solidity::util::errinfo_comment; +using solidity::util::toHex; static int g_compilerStackCounts = 0; @@ -136,7 +139,7 @@ void CompilerStack::setSMTSolverChoice(smt::SMTSolverChoice _enabledSMTSolvers) m_enabledSMTSolvers = _enabledSMTSolvers; } -void CompilerStack::setLibraries(std::map const& _libraries) +void CompilerStack::setLibraries(std::map const& _libraries) { if (m_stackState >= ParsingPerformed) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Must set libraries before parsing.")); @@ -506,7 +509,7 @@ string const CompilerStack::lastContractName() const return contractName; } -eth::AssemblyItems const* CompilerStack::assemblyItems(string const& _contractName) const +evmasm::AssemblyItems const* CompilerStack::assemblyItems(string const& _contractName) const { if (m_stackState != CompilationSuccessful) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); @@ -515,7 +518,7 @@ eth::AssemblyItems const* CompilerStack::assemblyItems(string const& _contractNa return currentContract.compiler ? &contract(_contractName).compiler->assemblyItems() : nullptr; } -eth::AssemblyItems const* CompilerStack::runtimeAssemblyItems(string const& _contractName) const +evmasm::AssemblyItems const* CompilerStack::runtimeAssemblyItems(string const& _contractName) const { if (m_stackState != CompilationSuccessful) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); @@ -600,7 +603,7 @@ string const& CompilerStack::ewasm(string const& _contractName) const return contract(_contractName).ewasm; } -eth::LinkerObject const& CompilerStack::ewasmObject(string const& _contractName) const +evmasm::LinkerObject const& CompilerStack::ewasmObject(string const& _contractName) const { if (m_stackState != CompilationSuccessful) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); @@ -608,7 +611,7 @@ eth::LinkerObject const& CompilerStack::ewasmObject(string const& _contractName) return contract(_contractName).ewasmObject; } -eth::LinkerObject const& CompilerStack::object(string const& _contractName) const +evmasm::LinkerObject const& CompilerStack::object(string const& _contractName) const { if (m_stackState != CompilationSuccessful) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); @@ -616,7 +619,7 @@ eth::LinkerObject const& CompilerStack::object(string const& _contractName) cons return contract(_contractName).object; } -eth::LinkerObject const& CompilerStack::runtimeObject(string const& _contractName) const +evmasm::LinkerObject const& CompilerStack::runtimeObject(string const& _contractName) const { if (m_stackState != CompilationSuccessful) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); @@ -825,12 +828,12 @@ size_t CompilerStack::functionEntryPoint( shared_ptr const& compiler = contract(_contractName).compiler; if (!compiler) return 0; - eth::AssemblyItem tag = compiler->functionEntryLabel(_function); - if (tag.type() == eth::UndefinedItem) + evmasm::AssemblyItem tag = compiler->functionEntryLabel(_function); + if (tag.type() == evmasm::UndefinedItem) return 0; - eth::AssemblyItems const& items = compiler->runtimeAssemblyItems(); + evmasm::AssemblyItems const& items = compiler->runtimeAssemblyItems(); for (size_t i = 0; i < items.size(); ++i) - if (items.at(i).type() == eth::Tag && items.at(i).data() == tag.data()) + if (items.at(i).type() == evmasm::Tag && items.at(i).data() == tag.data()) return i; return 0; } @@ -851,14 +854,14 @@ tuple CompilerStack::positionFromSourceLocation(SourceLocati h256 const& CompilerStack::Source::keccak256() const { if (keccak256HashCached == h256{}) - keccak256HashCached = dev::keccak256(scanner->source()); + keccak256HashCached = util::keccak256(scanner->source()); return keccak256HashCached; } h256 const& CompilerStack::Source::swarmHash() const { if (swarmHashCached == h256{}) - swarmHashCached = dev::bzzr1Hash(scanner->source()); + swarmHashCached = util::bzzr1Hash(scanner->source()); return swarmHashCached; } @@ -866,7 +869,7 @@ string const& CompilerStack::Source::ipfsUrl() const { if (ipfsUrlCached.empty()) if (scanner->source().size() < 1024 * 256) - ipfsUrlCached = "dweb:/ipfs/" + dev::ipfsHashBase58(scanner->source()); + ipfsUrlCached = "dweb:/ipfs/" + util::ipfsHashBase58(scanner->source()); return ipfsUrlCached; } @@ -879,7 +882,7 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string { solAssert(!import->path().empty(), "Import path cannot be empty."); - string importPath = dev::absolutePath(import->path(), _sourcePath); + string importPath = util::absolutePath(import->path(), _sourcePath); // The current value of `path` is the absolute path as seen from this source file. // We first have to apply remappings before we can store the actual absolute path // as seen globally. @@ -923,8 +926,8 @@ string CompilerStack::applyRemapping(string const& _path, string const& _context for (auto const& redir: m_remappings) { - string context = dev::sanitizePath(redir.context); - string prefix = dev::sanitizePath(redir.prefix); + string context = util::sanitizePath(redir.context); + string prefix = util::sanitizePath(redir.prefix); // Skip if current context is closer if (context.length() < longestContext) @@ -941,7 +944,7 @@ string CompilerStack::applyRemapping(string const& _path, string const& _context longestContext = context.length(); longestPrefix = prefix.length(); - bestMatchTarget = dev::sanitizePath(redir.target); + bestMatchTarget = util::sanitizePath(redir.target); } string path = bestMatchTarget; path.append(_path.begin() + longestPrefix, _path.end()); @@ -1021,7 +1024,7 @@ void CompilerStack::compileContract( // Run optimiser and compile the contract. compiler->compileContract(_contract, _otherCompilers, cborEncodedMetadata); } - catch(eth::OptimizerException const&) + catch(evmasm::OptimizerException const&) { solAssert(false, "Optimizer exception during compilation"); } @@ -1031,7 +1034,7 @@ void CompilerStack::compileContract( // Assemble deployment (incl. runtime) object. compiledContract.object = compiler->assembledObject(); } - catch(eth::AssemblyException const&) + catch(evmasm::AssemblyException const&) { solAssert(false, "Assembly exception for bytecode"); } @@ -1041,7 +1044,7 @@ void CompilerStack::compileContract( // Assemble runtime object. compiledContract.runtimeObject = compiler->runtimeObject(); } - catch(eth::AssemblyException const&) + catch(evmasm::AssemblyException const&) { solAssert(false, "Assembly exception for deployed bytecode"); } @@ -1227,7 +1230,7 @@ string CompilerStack::createMetadata(Contract const& _contract) const meta["output"]["userdoc"] = natspecUser(_contract); meta["output"]["devdoc"] = natspecDev(_contract); - return jsonCompactPrint(meta); + return util::jsonCompactPrint(meta); } class MetadataCBOREncoder @@ -1265,7 +1268,7 @@ public: // The already encoded key-value pairs ret += m_data; // 16-bit big endian length - ret += toCompactBigEndian(size, 2); + ret += util::toCompactBigEndian(size, 2); return ret; } @@ -1320,10 +1323,10 @@ bytes CompilerStack::createCBORMetadata(string const& _metadata, bool _experimen if (m_metadataHash == MetadataHash::IPFS) { solAssert(_metadata.length() < 1024 * 256, "Metadata too large."); - encoder.pushBytes("ipfs", dev::ipfsHash(_metadata)); + encoder.pushBytes("ipfs", util::ipfsHash(_metadata)); } else if (m_metadataHash == MetadataHash::Bzzr1) - encoder.pushBytes("bzzr1", dev::bzzr1Hash(_metadata).asBytes()); + encoder.pushBytes("bzzr1", util::bzzr1Hash(_metadata).asBytes()); else solAssert(m_metadataHash == MetadataHash::None, "Invalid metadata hash"); @@ -1336,7 +1339,7 @@ bytes CompilerStack::createCBORMetadata(string const& _metadata, bool _experimen return encoder.serialise(); } -string CompilerStack::computeSourceMapping(eth::AssemblyItems const& _items) const +string CompilerStack::computeSourceMapping(evmasm::AssemblyItems const& _items) const { if (m_stackState != CompilationSuccessful) BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful.")); @@ -1360,9 +1363,9 @@ string CompilerStack::computeSourceMapping(eth::AssemblyItems const& _items) con sourceIndicesMap.at(location.source->name()) : -1; char jump = '-'; - if (item.getJumpType() == eth::AssemblyItem::JumpType::IntoFunction) + if (item.getJumpType() == evmasm::AssemblyItem::JumpType::IntoFunction) jump = 'i'; - else if (item.getJumpType() == eth::AssemblyItem::JumpType::OutOfFunction) + else if (item.getJumpType() == evmasm::AssemblyItem::JumpType::OutOfFunction) jump = 'o'; size_t modifierDepth = item.m_modifierDepth; @@ -1433,7 +1436,7 @@ Json::Value gasToJson(GasEstimator::GasConsumption const& _gas) if (_gas.isInfinite) return Json::Value("infinite"); else - return Json::Value(toString(_gas.value)); + return Json::Value(util::toString(_gas.value)); } } @@ -1450,10 +1453,10 @@ Json::Value CompilerStack::gasEstimates(string const& _contractName) const GasEstimator gasEstimator(m_evmVersion); Json::Value output(Json::objectValue); - if (eth::AssemblyItems const* items = assemblyItems(_contractName)) + if (evmasm::AssemblyItems const* items = assemblyItems(_contractName)) { Gas executionGas = gasEstimator.functionalEstimation(*items); - Gas codeDepositGas{eth::GasMeter::dataGas(runtimeObject(_contractName).bytecode, false, m_evmVersion)}; + Gas codeDepositGas{evmasm::GasMeter::dataGas(runtimeObject(_contractName).bytecode, false, m_evmVersion)}; Json::Value creation(Json::objectValue); creation["codeDepositCost"] = gasToJson(codeDepositGas); @@ -1464,7 +1467,7 @@ Json::Value CompilerStack::gasEstimates(string const& _contractName) const output["creation"] = creation; } - if (eth::AssemblyItems const* items = runtimeAssemblyItems(_contractName)) + if (evmasm::AssemblyItems const* items = runtimeAssemblyItems(_contractName)) { /// External functions ContractDefinition const& contract = contractDefinition(_contractName); diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 9f4f42348..80249ec5c 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -48,22 +48,20 @@ #include #include -namespace langutil +namespace solidity::langutil { class Scanner; } -namespace dev -{ -namespace eth +namespace solidity::evmasm { class Assembly; class AssemblyItem; using AssemblyItems = std::vector; } -namespace solidity +namespace solidity::frontend { // forward declarations @@ -137,7 +135,7 @@ public: /// Sets library addresses. Addresses are cleared iff @a _libraries is missing. /// Must be set before parsing. - void setLibraries(std::map const& _libraries = std::map{}); + void setLibraries(std::map const& _libraries = {}); /// Changes the optimiser settings. /// Must be set before parsing. @@ -195,7 +193,7 @@ public: /// Adds a response to an SMTLib2 query (identified by the hash of the query input). /// Must be set before parsing. - void addSMTLib2Response(h256 const& _hash, std::string const& _response); + void addSMTLib2Response(util::h256 const& _hash, std::string const& _response); /// Parses all source units that were added /// @returns false on error. @@ -255,19 +253,19 @@ public: std::string const& ewasm(std::string const& _contractName) const; /// @returns the Ewasm representation of a contract. - eth::LinkerObject const& ewasmObject(std::string const& _contractName) const; + evmasm::LinkerObject const& ewasmObject(std::string const& _contractName) const; /// @returns the assembled object for a contract. - eth::LinkerObject const& object(std::string const& _contractName) const; + evmasm::LinkerObject const& object(std::string const& _contractName) const; /// @returns the runtime object for the contract. - eth::LinkerObject const& runtimeObject(std::string const& _contractName) const; + evmasm::LinkerObject const& runtimeObject(std::string const& _contractName) const; /// @returns normal contract assembly items - eth::AssemblyItems const* assemblyItems(std::string const& _contractName) const; + evmasm::AssemblyItems const* assemblyItems(std::string const& _contractName) const; /// @returns runtime contract assembly items - eth::AssemblyItems const* runtimeAssemblyItems(std::string const& _contractName) const; + evmasm::AssemblyItems const* runtimeAssemblyItems(std::string const& _contractName) const; /// @returns the string that provides a mapping between bytecode and sourcecode or a nullptr /// if the contract does not (yet) have bytecode. @@ -320,12 +318,12 @@ private: { std::shared_ptr scanner; std::shared_ptr ast; - h256 mutable keccak256HashCached; - h256 mutable swarmHashCached; + util::h256 mutable keccak256HashCached; + util::h256 mutable swarmHashCached; std::string mutable ipfsUrlCached; void reset() { *this = Source(); } - h256 const& keccak256() const; - h256 const& swarmHash() const; + util::h256 const& keccak256() const; + util::h256 const& swarmHash() const; std::string const& ipfsUrl() const; }; @@ -334,12 +332,12 @@ private: { ContractDefinition const* contract = nullptr; std::shared_ptr compiler; - eth::LinkerObject object; ///< Deployment object (includes the runtime sub-object). - eth::LinkerObject runtimeObject; ///< Runtime object. + evmasm::LinkerObject object; ///< Deployment object (includes the runtime sub-object). + evmasm::LinkerObject runtimeObject; ///< Runtime object. std::string yulIR; ///< Experimental Yul IR code. std::string yulIROptimized; ///< Optimized experimental Yul IR code. std::string ewasm; ///< Experimental Ewasm text representation - eth::LinkerObject ewasmObject; ///< Experimental Ewasm code + evmasm::LinkerObject ewasmObject; ///< Experimental Ewasm code mutable std::unique_ptr metadata; ///< The metadata json that will be hashed into the chain. mutable std::unique_ptr abi; mutable std::unique_ptr storageLayout; @@ -400,7 +398,7 @@ private: bytes createCBORMetadata(std::string const& _metadata, bool _experimentalMode); /// @returns the computer source mapping string. - std::string computeSourceMapping(eth::AssemblyItems const& _items) const; + std::string computeSourceMapping(evmasm::AssemblyItems const& _items) const; /// @returns the contract ABI as a JSON object. /// This will generate the JSON object and store it in the Contract object if it is not present yet. @@ -437,13 +435,13 @@ private: std::map> m_requestedContractNames; bool m_generateIR; bool m_generateEwasm; - std::map m_libraries; + std::map m_libraries; /// list of path prefix remappings, e.g. mylibrary: github.com/ethereum = /usr/local/ethereum /// "context:prefix=target" std::vector m_remappings; std::map m_sources; std::vector m_unhandledSMTLib2Queries; - std::map m_smtlib2Responses; + std::map m_smtlib2Responses; std::shared_ptr m_globalContext; std::vector m_sourceOrder; /// This is updated during compilation. @@ -462,4 +460,3 @@ private: }; } -} diff --git a/libsolidity/interface/DebugSettings.h b/libsolidity/interface/DebugSettings.h index 5b3e00850..67c6d8810 100644 --- a/libsolidity/interface/DebugSettings.h +++ b/libsolidity/interface/DebugSettings.h @@ -24,9 +24,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { enum class RevertStrings @@ -60,4 +58,3 @@ inline std::optional revertStringsFromString(std::string const& _ } } -} diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp index 8ffcf9513..8e6827ed0 100644 --- a/libsolidity/interface/GasEstimator.cpp +++ b/libsolidity/interface/GasEstimator.cpp @@ -36,10 +36,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::langutil; GasEstimator::ASTGasConsumptionSelfAccumulated GasEstimator::structuralEstimation( AssemblyItems const& _items, @@ -140,7 +140,7 @@ GasEstimator::GasConsumption GasEstimator::functionalEstimation( ExpressionClasses& classes = state->expressionClasses(); using Id = ExpressionClasses::Id; using Ids = vector; - Id hashValue = classes.find(u256(FixedHash<4>::Arith(FixedHash<4>(dev::keccak256(_signature))))); + Id hashValue = classes.find(u256(util::FixedHash<4>::Arith(util::FixedHash<4>(util::keccak256(_signature))))); Id calldata = classes.find(Instruction::CALLDATALOAD, Ids{classes.find(u256(0))}); if (!m_evmVersion.hasBitwiseShifting()) // div(calldataload(0), 1 << 224) equals to hashValue diff --git a/libsolidity/interface/GasEstimator.h b/libsolidity/interface/GasEstimator.h index 784fada2f..1cfcec9a7 100644 --- a/libsolidity/interface/GasEstimator.h +++ b/libsolidity/interface/GasEstimator.h @@ -31,9 +31,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class ASTNode; @@ -42,7 +40,7 @@ class FunctionDefinition; struct GasEstimator { public: - using GasConsumption = eth::GasMeter::GasConsumption; + using GasConsumption = evmasm::GasMeter::GasConsumption; using ASTGasConsumption = std::map; using ASTGasConsumptionSelfAccumulated = std::map>; @@ -53,7 +51,7 @@ public: /// it by source location. /// @returns a mapping from each AST node to a pair of its particular and syntactically accumulated gas costs. ASTGasConsumptionSelfAccumulated structuralEstimation( - eth::AssemblyItems const& _items, + evmasm::AssemblyItems const& _items, std::vector const& _ast ) const; /// @returns a mapping from nodes with non-overlapping source locations to gas consumptions such that @@ -68,7 +66,7 @@ public: /// @returns the estimated gas consumption by the (public or external) function with the /// given signature. If no signature is given, estimates the maximum gas usage. GasConsumption functionalEstimation( - eth::AssemblyItems const& _items, + evmasm::AssemblyItems const& _items, std::string const& _signature = "" ) const; @@ -76,7 +74,7 @@ public: /// offset into the list of assembly items. /// @note this does not work correctly for recursive functions. GasConsumption functionalEstimation( - eth::AssemblyItems const& _items, + evmasm::AssemblyItems const& _items, size_t const& _offset, FunctionDefinition const& _function ) const; @@ -88,4 +86,3 @@ private: }; } -} diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 2c8c68694..b78e46081 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -29,8 +29,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) { diff --git a/libsolidity/interface/Natspec.h b/libsolidity/interface/Natspec.h index c37a4ac0e..fc13519e4 100644 --- a/libsolidity/interface/Natspec.h +++ b/libsolidity/interface/Natspec.h @@ -30,9 +30,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { // Forward declarations @@ -70,5 +68,4 @@ private: static Json::Value extractReturnParameterDocs(std::multimap const& _tags, FunctionDefinition const& _functionDef); }; -} //solidity NS -} // dev NS +} diff --git a/libsolidity/interface/OptimiserSettings.h b/libsolidity/interface/OptimiserSettings.h index 0b1880516..16aae9493 100644 --- a/libsolidity/interface/OptimiserSettings.h +++ b/libsolidity/interface/OptimiserSettings.h @@ -24,9 +24,7 @@ #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { struct OptimiserSettings @@ -103,4 +101,3 @@ struct OptimiserSettings }; } -} diff --git a/libsolidity/interface/ReadFile.h b/libsolidity/interface/ReadFile.h index 05fd2c5a2..232d39be4 100644 --- a/libsolidity/interface/ReadFile.h +++ b/libsolidity/interface/ReadFile.h @@ -23,10 +23,7 @@ #include #include -namespace dev -{ - -namespace solidity +namespace solidity::frontend { class ReadCallback: boost::noncopyable @@ -63,4 +60,3 @@ public: }; } -} diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index a7162348c..a942c74be 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -37,10 +37,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::frontend; +using namespace solidity::langutil; namespace { @@ -105,7 +105,7 @@ Json::Value formatSecondarySourceLocation(SecondarySourceLocation const* _second } Json::Value formatErrorWithException( - Exception const& _exception, + util::Exception const& _exception, bool const& _warning, string const& _type, string const& _component, @@ -115,7 +115,7 @@ Json::Value formatErrorWithException( string message; string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _type); - if (string const* description = boost::get_error_info(_exception)) + if (string const* description = boost::get_error_info(_exception)) message = ((_message.length() > 0) ? (_message + ":") : "") + *description; else message = _message; @@ -151,9 +151,9 @@ bool hashMatchesContent(string const& _hash, string const& _content) { try { - return dev::h256(_hash) == dev::keccak256(_content); + return util::h256(_hash) == util::keccak256(_content); } - catch (dev::BadHexCharacter const&) + catch (util::BadHexCharacter const&) { return false; } @@ -309,11 +309,11 @@ Json::Value formatLinkReferences(std::map const& linkRefere return ret; } -Json::Value collectEVMObject(eth::LinkerObject const& _object, string const* _sourceMap) +Json::Value collectEVMObject(evmasm::LinkerObject const& _object, string const* _sourceMap) { Json::Value output = Json::objectValue; output["object"] = _object.toHex(); - output["opcodes"] = dev::eth::disassemble(_object.bytecode); + output["opcodes"] = evmasm::disassemble(_object.bytecode); output["sourceMap"] = _sourceMap ? *_sourceMap : ""; output["linkReferences"] = formatLinkReferences(_object.linkReferences); return output; @@ -606,12 +606,12 @@ boost::variant StandardCompile for (auto const& hashString: smtlib2Responses.getMemberNames()) { - h256 hash; + util::h256 hash; try { - hash = h256(hashString); + hash = util::h256(hashString); } - catch (dev::BadHexCharacter const&) + catch (util::BadHexCharacter const&) { return formatFatalError("JSONError", "Invalid hex encoding of SMTLib2 auxiliary input."); } @@ -721,9 +721,9 @@ boost::variant StandardCompile try { // @TODO use libraries only for the given source - ret.libraries[library] = h160(address); + ret.libraries[library] = util::h160(address); } - catch (dev::BadHexCharacter const&) + catch (util::BadHexCharacter const&) { return formatFatalError( "JSONError", @@ -867,7 +867,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting "Yul exception" )); } - catch (Exception const& _exception) + catch (util::Exception const& _exception) { errors.append(formatError( false, @@ -912,7 +912,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting if (!compilerStack.unhandledSMTLib2Queries().empty()) for (string const& query: compilerStack.unhandledSMTLib2Queries()) - output["auxiliaryInputRequested"]["smtlib2queries"]["0x" + keccak256(query).hex()] = query; + output["auxiliaryInputRequested"]["smtlib2queries"]["0x" + util::keccak256(query).hex()] = query; bool const wildcardMatchesExperimental = false; @@ -1117,7 +1117,7 @@ Json::Value StandardCompiler::compile(Json::Value const& _input) noexcept { return formatFatalError("InternalCompilerError", string("JSON runtime exception: ") + _exception.what()); } - catch (Exception const& _exception) + catch (util::Exception const& _exception) { return formatFatalError("InternalCompilerError", "Internal exception in StandardCompiler::compile: " + boost::diagnostic_information(_exception)); } @@ -1133,8 +1133,8 @@ string StandardCompiler::compile(string const& _input) noexcept string errors; try { - if (!jsonParseStrict(_input, input, &errors)) - return jsonCompactPrint(formatFatalError("JSONError", errors)); + if (!util::jsonParseStrict(_input, input, &errors)) + return util::jsonCompactPrint(formatFatalError("JSONError", errors)); } catch (...) { @@ -1147,7 +1147,7 @@ string StandardCompiler::compile(string const& _input) noexcept try { - return jsonCompactPrint(output); + return util::jsonCompactPrint(output); } catch (...) { diff --git a/libsolidity/interface/StandardCompiler.h b/libsolidity/interface/StandardCompiler.h index 346ef7dcd..b37025576 100644 --- a/libsolidity/interface/StandardCompiler.h +++ b/libsolidity/interface/StandardCompiler.h @@ -27,10 +27,7 @@ #include #include -namespace dev -{ - -namespace solidity +namespace solidity::frontend { /** @@ -62,12 +59,12 @@ private: Json::Value errors; bool parserErrorRecovery = false; std::map sources; - std::map smtLib2Responses; + std::map smtLib2Responses; langutil::EVMVersion evmVersion; std::vector remappings; RevertStrings revertStrings = RevertStrings::Default; OptimiserSettings optimiserSettings = OptimiserSettings::minimal(); - std::map libraries; + std::map libraries; bool metadataLiteralSources = false; CompilerStack::MetadataHash metadataHash = CompilerStack::MetadataHash::IPFS; Json::Value outputSelection; @@ -84,4 +81,3 @@ private: }; } -} diff --git a/libsolidity/interface/StorageLayout.cpp b/libsolidity/interface/StorageLayout.cpp index e987d4de2..8e6915085 100644 --- a/libsolidity/interface/StorageLayout.cpp +++ b/libsolidity/interface/StorageLayout.cpp @@ -20,8 +20,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::frontend; Json::Value StorageLayout::generate(ContractDefinition const& _contractDef) { diff --git a/libsolidity/interface/StorageLayout.h b/libsolidity/interface/StorageLayout.h index 1f7b3c1fd..331a85d46 100644 --- a/libsolidity/interface/StorageLayout.h +++ b/libsolidity/interface/StorageLayout.h @@ -25,9 +25,7 @@ #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { class StorageLayout @@ -55,4 +53,3 @@ private: }; } -} diff --git a/libsolidity/interface/Version.cpp b/libsolidity/interface/Version.cpp index efb653d71..f00192861 100644 --- a/libsolidity/interface/Version.cpp +++ b/libsolidity/interface/Version.cpp @@ -28,26 +28,24 @@ #include #include -using namespace dev; -using namespace dev::solidity; using namespace std; -char const* dev::solidity::VersionNumber = ETH_PROJECT_VERSION; +char const* solidity::frontend::VersionNumber = ETH_PROJECT_VERSION; -string const dev::solidity::VersionString = - string(dev::solidity::VersionNumber) + +string const solidity::frontend::VersionString = + string(solidity::frontend::VersionNumber) + (string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) + (string(SOL_VERSION_BUILDINFO).empty() ? "" : "+" + string(SOL_VERSION_BUILDINFO)); -string const dev::solidity::VersionStringStrict = - string(dev::solidity::VersionNumber) + +string const solidity::frontend::VersionStringStrict = + string(solidity::frontend::VersionNumber) + (string(SOL_VERSION_PRERELEASE).empty() ? "" : "-" + string(SOL_VERSION_PRERELEASE)) + (string(SOL_VERSION_COMMIT).empty() ? "" : "+" + string(SOL_VERSION_COMMIT)); -bytes const dev::solidity::VersionCompactBytes = { +solidity::bytes const solidity::frontend::VersionCompactBytes = { ETH_PROJECT_VERSION_MAJOR, ETH_PROJECT_VERSION_MINOR, ETH_PROJECT_VERSION_PATCH }; -bool const dev::solidity::VersionIsRelease = string(SOL_VERSION_PRERELEASE).empty(); +bool const solidity::frontend::VersionIsRelease = string(SOL_VERSION_PRERELEASE).empty(); diff --git a/libsolidity/interface/Version.h b/libsolidity/interface/Version.h index 14564c686..60d624a3c 100644 --- a/libsolidity/interface/Version.h +++ b/libsolidity/interface/Version.h @@ -25,9 +25,7 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { extern char const* VersionNumber; @@ -37,4 +35,3 @@ extern bytes const VersionCompactBytes; extern bool const VersionIsRelease; } -} diff --git a/libsolidity/parsing/DocStringParser.cpp b/libsolidity/parsing/DocStringParser.cpp index 0ff69f344..fb1468197 100644 --- a/libsolidity/parsing/DocStringParser.cpp +++ b/libsolidity/parsing/DocStringParser.cpp @@ -25,9 +25,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; namespace { diff --git a/libsolidity/parsing/DocStringParser.h b/libsolidity/parsing/DocStringParser.h index 671a2f34a..dc9c5194c 100644 --- a/libsolidity/parsing/DocStringParser.h +++ b/libsolidity/parsing/DocStringParser.h @@ -25,14 +25,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class DocStringParser @@ -70,5 +68,4 @@ private: bool m_errorsOccurred = false; }; -} //solidity NS -} // dev NS +} diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 881bd3cab..96c70e293 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -34,11 +34,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity +namespace solidity::frontend { /// AST node factory that also tracks the begin and end position of an AST node @@ -2088,4 +2086,3 @@ ASTPointer Parser::getLiteralAndAdvance() } } -} diff --git a/libsolidity/parsing/Parser.h b/libsolidity/parsing/Parser.h index f9b6197b4..ae004058a 100644 --- a/libsolidity/parsing/Parser.h +++ b/libsolidity/parsing/Parser.h @@ -26,14 +26,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class Scanner; } -namespace dev -{ -namespace solidity +namespace solidity::frontend { class Parser: public langutil::ParserBase @@ -203,4 +201,3 @@ private: }; } -} diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h index abb717f2d..0e8f1f85b 100644 --- a/libsolidity/parsing/Token.h +++ b/libsolidity/parsing/Token.h @@ -24,13 +24,10 @@ #include -namespace dev +namespace solidity::frontend { -namespace solidity -{ -namespace TokenTraits = ::langutil::TokenTraits; +namespace TokenTraits = langutil::TokenTraits; -using ::langutil::Token; -using ::langutil::ElementaryTypeNameToken; -} +using langutil::Token; +using langutil::ElementaryTypeNameToken; } diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index e03ef7cb0..3f82b169f 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -38,10 +38,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace yul; -using namespace dev; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; namespace { @@ -651,7 +651,7 @@ bool AsmAnalyzer::warnOnInstructions(std::string const& _instructionIdentifier, return false; } -bool AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocation const& _location) +bool AsmAnalyzer::warnOnInstructions(evmasm::Instruction _instr, SourceLocation const& _location) { // We assume that returndatacopy, returndatasize and staticcall are either all available // or all not available. @@ -675,44 +675,44 @@ bool AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocatio }; if (( - _instr == dev::eth::Instruction::RETURNDATACOPY || - _instr == dev::eth::Instruction::RETURNDATASIZE + _instr == evmasm::Instruction::RETURNDATACOPY || + _instr == evmasm::Instruction::RETURNDATASIZE ) && !m_evmVersion.supportsReturndata()) { errorForVM("only available for Byzantium-compatible"); } - else if (_instr == dev::eth::Instruction::STATICCALL && !m_evmVersion.hasStaticCall()) + else if (_instr == evmasm::Instruction::STATICCALL && !m_evmVersion.hasStaticCall()) { errorForVM("only available for Byzantium-compatible"); } else if (( - _instr == dev::eth::Instruction::SHL || - _instr == dev::eth::Instruction::SHR || - _instr == dev::eth::Instruction::SAR + _instr == evmasm::Instruction::SHL || + _instr == evmasm::Instruction::SHR || + _instr == evmasm::Instruction::SAR ) && !m_evmVersion.hasBitwiseShifting()) { errorForVM("only available for Constantinople-compatible"); } - else if (_instr == dev::eth::Instruction::CREATE2 && !m_evmVersion.hasCreate2()) + else if (_instr == evmasm::Instruction::CREATE2 && !m_evmVersion.hasCreate2()) { errorForVM("only available for Constantinople-compatible"); } - else if (_instr == dev::eth::Instruction::EXTCODEHASH && !m_evmVersion.hasExtCodeHash()) + else if (_instr == evmasm::Instruction::EXTCODEHASH && !m_evmVersion.hasExtCodeHash()) { errorForVM("only available for Constantinople-compatible"); } - else if (_instr == dev::eth::Instruction::CHAINID && !m_evmVersion.hasChainID()) + else if (_instr == evmasm::Instruction::CHAINID && !m_evmVersion.hasChainID()) { errorForVM("only available for Istanbul-compatible"); } - else if (_instr == dev::eth::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance()) + else if (_instr == evmasm::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance()) { errorForVM("only available for Istanbul-compatible"); } else if ( - _instr == dev::eth::Instruction::JUMP || - _instr == dev::eth::Instruction::JUMPI || - _instr == dev::eth::Instruction::JUMPDEST + _instr == evmasm::Instruction::JUMP || + _instr == evmasm::Instruction::JUMPI || + _instr == evmasm::Instruction::JUMPDEST ) { m_errorReporter.error( diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index b16e2bfed..9bd9fc1b1 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -35,13 +35,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; @@ -103,7 +103,7 @@ private: Scope& scope(Block const* _block); void expectValidType(std::string const& type, langutil::SourceLocation const& _location); - bool warnOnInstructions(dev::eth::Instruction _instr, langutil::SourceLocation const& _location); + bool warnOnInstructions(evmasm::Instruction _instr, langutil::SourceLocation const& _location); bool warnOnInstructions(std::string const& _instrIdentifier, langutil::SourceLocation const& _location); int m_stackHeight = 0; diff --git a/libyul/AsmAnalysisInfo.h b/libyul/AsmAnalysisInfo.h index 1201399a2..8110608f9 100644 --- a/libyul/AsmAnalysisInfo.h +++ b/libyul/AsmAnalysisInfo.h @@ -26,7 +26,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Scope; diff --git a/libyul/AsmData.h b/libyul/AsmData.h index 5c7a058b5..f870536af 100644 --- a/libyul/AsmData.h +++ b/libyul/AsmData.h @@ -29,7 +29,7 @@ #include -namespace yul +namespace solidity::yul { using Type = YulString; diff --git a/libyul/AsmDataForward.h b/libyul/AsmDataForward.h index b1357462a..b21f46f82 100644 --- a/libyul/AsmDataForward.h +++ b/libyul/AsmDataForward.h @@ -24,7 +24,7 @@ #include -namespace yul +namespace solidity::yul { struct Literal; diff --git a/libyul/AsmJsonConverter.cpp b/libyul/AsmJsonConverter.cpp index 429da10fd..d71e57254 100644 --- a/libyul/AsmJsonConverter.cpp +++ b/libyul/AsmJsonConverter.cpp @@ -26,7 +26,7 @@ using namespace std; -namespace yul +namespace solidity::yul { Json::Value AsmJsonConverter::operator()(Block const& _node) const @@ -52,7 +52,7 @@ Json::Value AsmJsonConverter::operator()(Literal const& _node) const { case LiteralKind::Number: solAssert( - dev::isValidDecimal(_node.value.str()) || dev::isValidHex(_node.value.str()), + util::isValidDecimal(_node.value.str()) || util::isValidHex(_node.value.str()), "Invalid number literal" ); ret["kind"] = "number"; diff --git a/libyul/AsmJsonConverter.h b/libyul/AsmJsonConverter.h index 85d17c78d..360fa6a36 100644 --- a/libyul/AsmJsonConverter.h +++ b/libyul/AsmJsonConverter.h @@ -26,7 +26,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index 1123487e5..839c5c0df 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -32,9 +32,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; shared_ptr Parser::parse(std::shared_ptr const& _scanner, bool _reuseScanner) { @@ -59,17 +60,17 @@ shared_ptr Parser::parse(std::shared_ptr const& _scanner, bool _ return nullptr; } -std::map const& Parser::instructions() +std::map const& Parser::instructions() { // Allowed instructions, lowercase names. - static map s_instructions; + static map s_instructions; if (s_instructions.empty()) { - for (auto const& instruction: dev::eth::c_instructions) + for (auto const& instruction: evmasm::c_instructions) { if ( - instruction.second == dev::eth::Instruction::JUMPDEST || - dev::eth::isPushInstruction(instruction.second) + instruction.second == evmasm::Instruction::JUMPDEST || + evmasm::isPushInstruction(instruction.second) ) continue; string name = instruction.first; @@ -298,16 +299,16 @@ Expression Parser::parseExpression() } } -std::map const& Parser::instructionNames() +std::map const& Parser::instructionNames() { - static map s_instructionNames; + static map s_instructionNames; if (s_instructionNames.empty()) { for (auto const& instr: instructions()) s_instructionNames[instr.second] = instr.first; // set the ambiguous instructions to a clear default - s_instructionNames[dev::eth::Instruction::SELFDESTRUCT] = "selfdestruct"; - s_instructionNames[dev::eth::Instruction::KECCAK256] = "keccak256"; + s_instructionNames[evmasm::Instruction::SELFDESTRUCT] = "selfdestruct"; + s_instructionNames[evmasm::Instruction::KECCAK256] = "keccak256"; } return s_instructionNames; } diff --git a/libyul/AsmParser.h b/libyul/AsmParser.h index 0967828f3..8583550e7 100644 --- a/libyul/AsmParser.h +++ b/libyul/AsmParser.h @@ -35,7 +35,7 @@ #include #include -namespace yul +namespace solidity::yul { class Parser: public langutil::ParserBase @@ -55,7 +55,7 @@ public: std::shared_ptr parse(std::shared_ptr const& _scanner, bool _reuseScanner); /// @returns a map of all EVM instructions available to assembly. - static std::map const& instructions(); + static std::map const& instructions(); protected: using ElementaryOperation = std::variant; @@ -82,7 +82,7 @@ protected: ForLoop parseForLoop(); /// Parses a functional expression that has to push exactly one stack element Expression parseExpression(); - static std::map const& instructionNames(); + static std::map const& instructionNames(); /// Parses an elementary operation, i.e. a literal, identifier, instruction or /// builtin functian call (only the name). ElementaryOperation parseElementaryOperation(); diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 6297ad695..718dfc15d 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -34,8 +34,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::yul; //@TODO source locations diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h index 204b893de..331b502fa 100644 --- a/libyul/AsmPrinter.h +++ b/libyul/AsmPrinter.h @@ -26,7 +26,7 @@ #include -namespace yul +namespace solidity::yul { class AsmPrinter diff --git a/libyul/AsmScope.cpp b/libyul/AsmScope.cpp index b10130e57..ae39fc10d 100644 --- a/libyul/AsmScope.cpp +++ b/libyul/AsmScope.cpp @@ -21,8 +21,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; bool Scope::registerLabel(YulString _name) { diff --git a/libyul/AsmScope.h b/libyul/AsmScope.h index 9e3a74d03..adb0fba98 100644 --- a/libyul/AsmScope.h +++ b/libyul/AsmScope.h @@ -31,7 +31,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Scope diff --git a/libyul/AsmScopeFiller.cpp b/libyul/AsmScopeFiller.cpp index b131e988a..46b868d91 100644 --- a/libyul/AsmScopeFiller.cpp +++ b/libyul/AsmScopeFiller.cpp @@ -35,9 +35,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; ScopeFiller::ScopeFiller(AsmAnalysisInfo& _info, ErrorReporter& _errorReporter): m_info(_info), m_errorReporter(_errorReporter) diff --git a/libyul/AsmScopeFiller.h b/libyul/AsmScopeFiller.h index 80030f375..f3b7a1b8f 100644 --- a/libyul/AsmScopeFiller.h +++ b/libyul/AsmScopeFiller.h @@ -25,13 +25,13 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; struct SourceLocation; } -namespace yul +namespace solidity::yul { struct TypedName; diff --git a/libyul/AssemblyStack.cpp b/libyul/AssemblyStack.cpp index 4b6d71692..35bcdf65c 100644 --- a/libyul/AssemblyStack.cpp +++ b/libyul/AssemblyStack.cpp @@ -45,8 +45,9 @@ #include using namespace std; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::langutil; namespace { @@ -198,10 +199,10 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const case Machine::EVM: { MachineAssemblyObject object; - dev::eth::Assembly assembly; + evmasm::Assembly assembly; EthAssemblyAdapter adapter(assembly); compileEVM(adapter, false, m_optimiserSettings.optimizeStackAllocation); - object.bytecode = make_shared(assembly.assemble()); + object.bytecode = make_shared(assembly.assemble()); object.assembly = assembly.assemblyString(); return object; } @@ -210,7 +211,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const MachineAssemblyObject object; EVMAssembly assembly(true); compileEVM(assembly, true, m_optimiserSettings.optimizeStackAllocation); - object.bytecode = make_shared(assembly.finalize()); + object.bytecode = make_shared(assembly.finalize()); /// TODO: fill out text representation return object; } @@ -222,7 +223,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const MachineAssemblyObject object; auto result = WasmObjectCompiler::compile(*m_parserResult, dialect); object.assembly = std::move(result.first); - object.bytecode = make_shared(); + object.bytecode = make_shared(); object.bytecode->bytecode = std::move(result.second); return object; } diff --git a/libyul/AssemblyStack.h b/libyul/AssemblyStack.h index 6c3549331..1104d6b05 100644 --- a/libyul/AssemblyStack.h +++ b/libyul/AssemblyStack.h @@ -34,19 +34,19 @@ #include #include -namespace langutil +namespace solidity::langutil { class Scanner; } -namespace yul +namespace solidity::yul { class AbstractAssembly; struct MachineAssemblyObject { - std::shared_ptr bytecode; + std::shared_ptr bytecode; std::string assembly; }; @@ -61,9 +61,9 @@ public: enum class Machine { EVM, EVM15, Ewasm }; AssemblyStack(): - AssemblyStack(langutil::EVMVersion{}, Language::Assembly, dev::solidity::OptimiserSettings::none()) + AssemblyStack(langutil::EVMVersion{}, Language::Assembly, solidity::frontend::OptimiserSettings::none()) {} - AssemblyStack(langutil::EVMVersion _evmVersion, Language _language, dev::solidity::OptimiserSettings _optimiserSettings): + AssemblyStack(langutil::EVMVersion _evmVersion, Language _language, solidity::frontend::OptimiserSettings _optimiserSettings): m_language(_language), m_evmVersion(_evmVersion), m_optimiserSettings(std::move(_optimiserSettings)), @@ -106,7 +106,7 @@ private: Language m_language = Language::Assembly; langutil::EVMVersion m_evmVersion; - dev::solidity::OptimiserSettings m_optimiserSettings; + solidity::frontend::OptimiserSettings m_optimiserSettings; std::shared_ptr m_scanner; diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 228515b9b..bb61c7d97 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -29,8 +29,9 @@ #include using namespace std; -using namespace yul; -using namespace dev; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; map CompilabilityChecker::run( Dialect const& _dialect, diff --git a/libyul/CompilabilityChecker.h b/libyul/CompilabilityChecker.h index b13d19d88..d92f1977e 100644 --- a/libyul/CompilabilityChecker.h +++ b/libyul/CompilabilityChecker.h @@ -27,7 +27,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/Dialect.h b/libyul/Dialect.h index 5be5b812f..c0a7d7581 100644 --- a/libyul/Dialect.h +++ b/libyul/Dialect.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { class YulString; diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h index 7ce1a8066..a627610fb 100644 --- a/libyul/Exceptions.h +++ b/libyul/Exceptions.h @@ -23,16 +23,16 @@ #include #include -namespace yul +namespace solidity::yul { -struct YulException: virtual dev::Exception {}; +struct YulException: virtual util::Exception {}; struct OptimizerException: virtual YulException {}; struct CodegenException: virtual YulException {}; struct YulAssertion: virtual YulException {}; /// Assertion that throws an YulAssertion containing the given description if it is not met. #define yulAssert(CONDITION, DESCRIPTION) \ - assertThrow(CONDITION, ::yul::YulAssertion, DESCRIPTION) + assertThrow(CONDITION, ::solidity::yul::YulAssertion, DESCRIPTION) } diff --git a/libyul/Object.cpp b/libyul/Object.cpp index ea2707c77..64408230e 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -28,9 +28,10 @@ #include -using namespace dev; -using namespace yul; using namespace std; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; namespace { @@ -46,7 +47,7 @@ string indent(std::string const& _input) string Data::toString(bool) const { - return "data \"" + name.str() + "\" hex\"" + dev::toHex(data) + "\""; + return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\""; } string Object::toString(bool _yul) const diff --git a/libyul/Object.h b/libyul/Object.h index 5232a3cdf..7bcb70921 100644 --- a/libyul/Object.h +++ b/libyul/Object.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; @@ -49,10 +49,10 @@ struct ObjectNode */ struct Data: ObjectNode { - Data(YulString _name, dev::bytes _data): data(std::move(_data)) { name = _name; } + Data(YulString _name, bytes _data): data(std::move(_data)) { name = _name; } std::string toString(bool _yul) const override; - dev::bytes data; + bytes data; }; /** diff --git a/libyul/ObjectParser.cpp b/libyul/ObjectParser.cpp index 683b8022b..74c339f18 100644 --- a/libyul/ObjectParser.cpp +++ b/libyul/ObjectParser.cpp @@ -25,11 +25,11 @@ #include -using namespace dev; -using namespace langutil; -using namespace yul; using namespace std; - +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; shared_ptr ObjectParser::parse(shared_ptr const& _scanner, bool _reuseScanner) { diff --git a/libyul/ObjectParser.h b/libyul/ObjectParser.h index 2b5ebbb3c..14ce80f07 100644 --- a/libyul/ObjectParser.h +++ b/libyul/ObjectParser.h @@ -31,12 +31,12 @@ #include -namespace langutil +namespace solidity::langutil { class Scanner; } -namespace yul +namespace solidity::yul { /** diff --git a/libyul/SideEffects.h b/libyul/SideEffects.h index 0a8e1595e..2a0232973 100644 --- a/libyul/SideEffects.h +++ b/libyul/SideEffects.h @@ -19,7 +19,7 @@ #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/Utilities.cpp b/libyul/Utilities.cpp index a9958716f..b6951decb 100644 --- a/libyul/Utilities.cpp +++ b/libyul/Utilities.cpp @@ -34,13 +34,14 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; using boost::split; using boost::is_any_of; -string yul::reindent(string const& _code) +string solidity::yul::reindent(string const& _code) { int constexpr indentationWidth = 4; @@ -82,7 +83,7 @@ string yul::reindent(string const& _code) return out.str(); } -u256 yul::valueOfNumberLiteral(Literal const& _literal) +u256 solidity::yul::valueOfNumberLiteral(Literal const& _literal) { yulAssert(_literal.kind == LiteralKind::Number, "Expected number literal!"); @@ -91,7 +92,7 @@ u256 yul::valueOfNumberLiteral(Literal const& _literal) return u256(literalString); } -u256 yul::valueOfStringLiteral(Literal const& _literal) +u256 solidity::yul::valueOfStringLiteral(Literal const& _literal) { yulAssert(_literal.kind == LiteralKind::String, "Expected string literal!"); yulAssert(_literal.value.str().size() <= 32, "Literal string too long!"); @@ -111,7 +112,7 @@ u256 yul::valueOfBoolLiteral(Literal const& _literal) yulAssert(false, "Unexpected bool literal value!"); } -u256 yul::valueOfLiteral(Literal const& _literal) +u256 solidity::yul::valueOfLiteral(Literal const& _literal) { switch (_literal.kind) { diff --git a/libyul/Utilities.h b/libyul/Utilities.h index 092dc90c3..9198e46ca 100644 --- a/libyul/Utilities.h +++ b/libyul/Utilities.h @@ -23,15 +23,15 @@ #include #include -namespace yul +namespace solidity::yul { std::string reindent(std::string const& _code); -dev::u256 valueOfNumberLiteral(Literal const& _literal); -dev::u256 valueOfStringLiteral(Literal const& _literal); -dev::u256 valueOfBoolLiteral(Literal const& _literal); -dev::u256 valueOfLiteral(Literal const& _literal); +u256 valueOfNumberLiteral(Literal const& _literal); +u256 valueOfStringLiteral(Literal const& _literal); +u256 valueOfBoolLiteral(Literal const& _literal); +u256 valueOfLiteral(Literal const& _literal); /** * Linear order on Yul AST nodes. diff --git a/libyul/YulString.h b/libyul/YulString.h index ae35d3ecd..9166cff3d 100644 --- a/libyul/YulString.h +++ b/libyul/YulString.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { /// Repository for YulStrings. diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index ad4a757e2..de83a1e9a 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -28,20 +28,17 @@ #include #include -namespace langutil +namespace solidity::langutil { struct SourceLocation; } -namespace dev -{ -namespace eth +namespace solidity::evmasm { enum class Instruction: uint8_t; } -} -namespace yul +namespace solidity::yul { struct Identifier; @@ -63,9 +60,9 @@ public: virtual int stackHeight() const = 0; virtual void setStackHeight(int height) = 0; /// Append an EVM instruction. - virtual void appendInstruction(dev::eth::Instruction _instruction) = 0; + virtual void appendInstruction(evmasm::Instruction _instruction) = 0; /// Append a constant. - virtual void appendConstant(dev::u256 const& _constant) = 0; + virtual void appendConstant(u256 const& _constant) = 0; /// Append a label. virtual void appendLabel(LabelID _labelId) = 0; /// Append a label reference. @@ -107,7 +104,7 @@ public: /// Appends the size of the given sub-assembly or data. virtual void appendDataSize(SubID _sub) = 0; /// Appends the given data to the assembly and returns its ID. - virtual SubID appendData(dev::bytes const& _data) = 0; + virtual SubID appendData(bytes const& _data) = 0; }; enum class IdentifierContext { LValue, RValue, VariableDeclaration }; diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 9022dadad..94c4fad64 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -38,11 +38,12 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; -EthAssemblyAdapter::EthAssemblyAdapter(eth::Assembly& _assembly): +EthAssemblyAdapter::EthAssemblyAdapter(evmasm::Assembly& _assembly): m_assembly(_assembly) { } @@ -62,7 +63,7 @@ void EthAssemblyAdapter::setStackHeight(int height) m_assembly.setDeposit(height); } -void EthAssemblyAdapter::appendInstruction(dev::eth::Instruction _instruction) +void EthAssemblyAdapter::appendInstruction(evmasm::Instruction _instruction) { m_assembly.append(_instruction); } @@ -74,12 +75,12 @@ void EthAssemblyAdapter::appendConstant(u256 const& _constant) void EthAssemblyAdapter::appendLabel(LabelID _labelId) { - m_assembly.append(eth::AssemblyItem(eth::Tag, _labelId)); + m_assembly.append(evmasm::AssemblyItem(evmasm::Tag, _labelId)); } void EthAssemblyAdapter::appendLabelReference(LabelID _labelId) { - m_assembly.append(eth::AssemblyItem(eth::PushTag, _labelId)); + m_assembly.append(evmasm::AssemblyItem(evmasm::PushTag, _labelId)); } size_t EthAssemblyAdapter::newLabelId() @@ -99,7 +100,7 @@ void EthAssemblyAdapter::appendLinkerSymbol(std::string const& _linkerSymbol) void EthAssemblyAdapter::appendJump(int _stackDiffAfter) { - appendInstruction(dev::eth::Instruction::JUMP); + appendInstruction(evmasm::Instruction::JUMP); m_assembly.adjustDeposit(_stackDiffAfter); } @@ -112,7 +113,7 @@ void EthAssemblyAdapter::appendJumpTo(LabelID _labelId, int _stackDiffAfter) void EthAssemblyAdapter::appendJumpToIf(LabelID _labelId) { appendLabelReference(_labelId); - appendInstruction(dev::eth::Instruction::JUMPI); + appendInstruction(evmasm::Instruction::JUMPI); } void EthAssemblyAdapter::appendBeginsub(LabelID, int) @@ -140,7 +141,7 @@ void EthAssemblyAdapter::appendAssemblySize() pair, AbstractAssembly::SubID> EthAssemblyAdapter::createSubAssembly() { - shared_ptr assembly{make_shared()}; + shared_ptr assembly{make_shared()}; auto sub = m_assembly.newSub(assembly); return {make_shared(*assembly), size_t(sub.data())}; } @@ -151,7 +152,7 @@ void EthAssemblyAdapter::appendDataOffset(AbstractAssembly::SubID _sub) if (it == m_dataHashBySubId.end()) m_assembly.pushSubroutineOffset(size_t(_sub)); else - m_assembly << eth::AssemblyItem(eth::PushData, it->second); + m_assembly << evmasm::AssemblyItem(evmasm::PushData, it->second); } void EthAssemblyAdapter::appendDataSize(AbstractAssembly::SubID _sub) @@ -165,13 +166,13 @@ void EthAssemblyAdapter::appendDataSize(AbstractAssembly::SubID _sub) AbstractAssembly::SubID EthAssemblyAdapter::appendData(bytes const& _data) { - eth::AssemblyItem pushData = m_assembly.newData(_data); + evmasm::AssemblyItem pushData = m_assembly.newData(_data); SubID subID = m_nextDataCounter++; m_dataHashBySubId[subID] = pushData.data(); return subID; } -EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(eth::AssemblyItem const& _tag) +EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag) { u256 id = _tag.data(); yulAssert(id <= std::numeric_limits::max(), "Tag id too large."); @@ -181,7 +182,7 @@ EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(eth::Ass void CodeGenerator::assemble( Block const& _parsedData, AsmAnalysisInfo& _analysisInfo, - eth::Assembly& _assembly, + evmasm::Assembly& _assembly, langutil::EVMVersion _evmVersion, ExternalIdentifierAccess const& _identifierAccess, bool _useNamedLabelsForFunctions, diff --git a/libyul/backends/evm/AsmCodeGen.h b/libyul/backends/evm/AsmCodeGen.h index ffaea6221..baab37b4c 100644 --- a/libyul/backends/evm/AsmCodeGen.h +++ b/libyul/backends/evm/AsmCodeGen.h @@ -25,28 +25,25 @@ #include #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { class Assembly; class AssemblyItem; } -} -namespace yul +namespace solidity::yul { struct Block; class EthAssemblyAdapter: public AbstractAssembly { public: - explicit EthAssemblyAdapter(dev::eth::Assembly& _assembly); + explicit EthAssemblyAdapter(evmasm::Assembly& _assembly); void setSourceLocation(langutil::SourceLocation const& _location) override; int stackHeight() const override; void setStackHeight(int height) override; - void appendInstruction(dev::eth::Instruction _instruction) override; - void appendConstant(dev::u256 const& _constant) override; + void appendInstruction(evmasm::Instruction _instruction) override; + void appendConstant(u256 const& _constant) override; void appendLabel(LabelID _labelId) override; void appendLabelReference(LabelID _labelId) override; size_t newLabelId() override; @@ -62,13 +59,13 @@ public: std::pair, SubID> createSubAssembly() override; void appendDataOffset(SubID _sub) override; void appendDataSize(SubID _sub) override; - SubID appendData(dev::bytes const& _data) override; + SubID appendData(bytes const& _data) override; private: - static LabelID assemblyTagToIdentifier(dev::eth::AssemblyItem const& _tag); + static LabelID assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag); - dev::eth::Assembly& m_assembly; - std::map m_dataHashBySubId; + evmasm::Assembly& m_assembly; + std::map m_dataHashBySubId; size_t m_nextDataCounter = std::numeric_limits::max() / 2; }; @@ -79,7 +76,7 @@ public: static void assemble( Block const& _parsedData, AsmAnalysisInfo& _analysisInfo, - dev::eth::Assembly& _assembly, + evmasm::Assembly& _assembly, langutil::EVMVersion _evmVersion, ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(), bool _useNamedLabelsForFunctions = false, diff --git a/libyul/backends/evm/ConstantOptimiser.cpp b/libyul/backends/evm/ConstantOptimiser.cpp index 8d535e24a..83003144f 100644 --- a/libyul/backends/evm/ConstantOptimiser.cpp +++ b/libyul/backends/evm/ConstantOptimiser.cpp @@ -30,8 +30,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; using Representation = ConstantOptimiser::Representation; @@ -46,24 +47,24 @@ struct MiniEVMInterpreter return std::visit(*this, _expr); } - u256 eval(dev::eth::Instruction _instr, vector const& _arguments) + u256 eval(evmasm::Instruction _instr, vector const& _arguments) { vector args; for (auto const& arg: _arguments) args.emplace_back(eval(arg)); switch (_instr) { - case eth::Instruction::ADD: + case evmasm::Instruction::ADD: return args.at(0) + args.at(1); - case eth::Instruction::SUB: + case evmasm::Instruction::SUB: return args.at(0) - args.at(1); - case eth::Instruction::MUL: + case evmasm::Instruction::MUL: return args.at(0) * args.at(1); - case eth::Instruction::EXP: + case evmasm::Instruction::EXP: return exp256(args.at(0), args.at(1)); - case eth::Instruction::SHL: + case evmasm::Instruction::SHL: return args.at(0) > 255 ? 0 : (args.at(1) << unsigned(args.at(0))); - case eth::Instruction::NOT: + case evmasm::Instruction::NOT: return ~args.at(0); default: yulAssert(false, "Invalid operation generated in constant optimizer."); @@ -107,7 +108,7 @@ void ConstantOptimiser::visit(Expression& _e) ASTModifier::visit(_e); } -Expression const* RepresentationFinder::tryFindRepresentation(dev::u256 const& _value) +Expression const* RepresentationFinder::tryFindRepresentation(u256 const& _value) { if (_value < 0x10000) return nullptr; @@ -119,14 +120,14 @@ Expression const* RepresentationFinder::tryFindRepresentation(dev::u256 const& _ return repr.expression.get(); } -Representation const& RepresentationFinder::findRepresentation(dev::u256 const& _value) +Representation const& RepresentationFinder::findRepresentation(u256 const& _value) { if (m_cache.count(_value)) return m_cache.at(_value); Representation routine = represent(_value); - if (dev::bytesRequired(~_value) < dev::bytesRequired(_value)) + if (bytesRequired(~_value) < bytesRequired(_value)) // Negated is shorter to represent routine = min(move(routine), represent("not"_yulstring, findRepresentation(~_value))); @@ -175,7 +176,7 @@ Representation const& RepresentationFinder::findRepresentation(dev::u256 const& return m_cache[_value] = move(routine); } -Representation RepresentationFinder::represent(dev::u256 const& _value) const +Representation RepresentationFinder::represent(u256 const& _value) const { Representation repr; repr.expression = make_unique(Literal{m_location, LiteralKind::Number, YulString{formatNumber(_value)}, {}}); diff --git a/libyul/backends/evm/ConstantOptimiser.h b/libyul/backends/evm/ConstantOptimiser.h index 0383943e9..97ce9879f 100644 --- a/libyul/backends/evm/ConstantOptimiser.h +++ b/libyul/backends/evm/ConstantOptimiser.h @@ -34,7 +34,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; class GasMeter; @@ -63,7 +63,7 @@ public: private: EVMDialect const& m_dialect; GasMeter const& m_meter; - std::map m_cache; + std::map m_cache; }; class RepresentationFinder @@ -74,7 +74,7 @@ public: EVMDialect const& _dialect, GasMeter const& _meter, langutil::SourceLocation _location, - std::map& _cache + std::map& _cache ): m_dialect(_dialect), m_meter(_meter), @@ -84,14 +84,14 @@ public: /// @returns a cheaper representation for the number than its representation /// as a literal or nullptr otherwise. - Expression const* tryFindRepresentation(dev::u256 const& _value); + Expression const* tryFindRepresentation(u256 const& _value); private: /// Recursively try to find the cheapest representation of the given number, /// literal if necessary. - Representation const& findRepresentation(dev::u256 const& _value); + Representation const& findRepresentation(u256 const& _value); - Representation represent(dev::u256 const& _value) const; + Representation represent(u256 const& _value) const; Representation represent(YulString _instruction, Representation const& _arg) const; Representation represent(YulString _instruction, Representation const& _arg1, Representation const& _arg2) const; @@ -102,7 +102,7 @@ private: langutil::SourceLocation m_location; /// Counter for the complexity of optimization, will stop when it reaches zero. size_t m_maxSteps = 10000; - std::map& m_cache; + std::map& m_cache; }; } diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index 6b268e67d..70711ffd6 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -24,10 +24,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; namespace { @@ -43,7 +43,7 @@ void EVMAssembly::setSourceLocation(SourceLocation const&) // Ignored for now; } -void EVMAssembly::appendInstruction(dev::eth::Instruction _instr) +void EVMAssembly::appendInstruction(evmasm::Instruction _instr) { m_bytecode.push_back(uint8_t(_instr)); m_stackHeight += instructionInfo(_instr).ret - instructionInfo(_instr).args; @@ -52,14 +52,14 @@ void EVMAssembly::appendInstruction(dev::eth::Instruction _instr) void EVMAssembly::appendConstant(u256 const& _constant) { bytes data = toCompactBigEndian(_constant, 1); - appendInstruction(pushInstruction(data.size())); + appendInstruction(evmasm::pushInstruction(data.size())); m_bytecode += data; } void EVMAssembly::appendLabel(LabelID _labelId) { setLabelToCurrentPosition(_labelId); - appendInstruction(dev::eth::Instruction::JUMPDEST); + appendInstruction(evmasm::Instruction::JUMPDEST); } void EVMAssembly::appendLabelReference(LabelID _labelId) @@ -67,7 +67,7 @@ void EVMAssembly::appendLabelReference(LabelID _labelId) yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); // @TODO we now always use labelReferenceSize for all labels, it could be shortened // for some of them. - appendInstruction(dev::eth::pushInstruction(labelReferenceSize)); + appendInstruction(evmasm::pushInstruction(labelReferenceSize)); m_labelReferences[m_bytecode.size()] = _labelId; m_bytecode += bytes(labelReferenceSize); } @@ -94,7 +94,7 @@ void EVMAssembly::appendLinkerSymbol(string const&) void EVMAssembly::appendJump(int _stackDiffAfter) { yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); - appendInstruction(dev::eth::Instruction::JUMP); + appendInstruction(evmasm::Instruction::JUMP); m_stackHeight += _stackDiffAfter; } @@ -102,7 +102,7 @@ void EVMAssembly::appendJumpTo(LabelID _labelId, int _stackDiffAfter) { if (m_evm15) { - m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPTO)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPTO)); appendLabelReferenceInternal(_labelId); m_stackHeight += _stackDiffAfter; } @@ -117,14 +117,14 @@ void EVMAssembly::appendJumpToIf(LabelID _labelId) { if (m_evm15) { - m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPIF)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPIF)); appendLabelReferenceInternal(_labelId); m_stackHeight--; } else { appendLabelReference(_labelId); - appendInstruction(dev::eth::Instruction::JUMPI); + appendInstruction(evmasm::Instruction::JUMPI); } } @@ -133,7 +133,7 @@ void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments) yulAssert(m_evm15, "BEGINSUB used for EVM 1.0"); yulAssert(_arguments >= 0, ""); setLabelToCurrentPosition(_labelId); - m_bytecode.push_back(uint8_t(dev::eth::Instruction::BEGINSUB)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::BEGINSUB)); m_stackHeight += _arguments; } @@ -141,7 +141,7 @@ void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns) { yulAssert(m_evm15, "JUMPSUB used for EVM 1.0"); yulAssert(_arguments >= 0 && _returns >= 0, ""); - m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPSUB)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::JUMPSUB)); appendLabelReferenceInternal(_labelId); m_stackHeight += _returns - _arguments; } @@ -150,11 +150,11 @@ void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter) { yulAssert(m_evm15, "RETURNSUB used for EVM 1.0"); yulAssert(_returns >= 0, ""); - m_bytecode.push_back(uint8_t(dev::eth::Instruction::RETURNSUB)); + m_bytecode.push_back(uint8_t(evmasm::Instruction::RETURNSUB)); m_stackHeight += _stackDiffAfter - _returns; } -eth::LinkerObject EVMAssembly::finalize() +evmasm::LinkerObject EVMAssembly::finalize() { size_t bytecodeSize = m_bytecode.size(); for (auto const& ref: m_assemblySizePositions) @@ -169,7 +169,7 @@ eth::LinkerObject EVMAssembly::finalize() updateReference(referencePos, labelReferenceSize, u256(labelPos)); } - eth::LinkerObject obj; + evmasm::LinkerObject obj; obj.bytecode = m_bytecode; return obj; } @@ -189,7 +189,7 @@ void EVMAssembly::appendLabelReferenceInternal(LabelID _labelId) void EVMAssembly::appendAssemblySize() { - appendInstruction(dev::eth::pushInstruction(assemblySizeReferenceSize)); + appendInstruction(evmasm::pushInstruction(assemblySizeReferenceSize)); m_assemblySizePositions.push_back(m_bytecode.size()); m_bytecode += bytes(assemblySizeReferenceSize); } diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h index 9b4242a2c..e4ba4979a 100644 --- a/libyul/backends/evm/EVMAssembly.h +++ b/libyul/backends/evm/EVMAssembly.h @@ -26,12 +26,12 @@ #include -namespace langutil +namespace solidity::langutil { struct SourceLocation; } -namespace yul +namespace solidity::yul { class EVMAssembly: public AbstractAssembly @@ -47,9 +47,9 @@ public: int stackHeight() const override { return m_stackHeight; } void setStackHeight(int height) override { m_stackHeight = height; } /// Append an EVM instruction. - void appendInstruction(dev::eth::Instruction _instruction) override; + void appendInstruction(evmasm::Instruction _instruction) override; /// Append a constant. - void appendConstant(dev::u256 const& _constant) override; + void appendConstant(u256 const& _constant) override; /// Append a label. void appendLabel(LabelID _labelId) override; /// Append a label reference. @@ -81,20 +81,20 @@ public: std::pair, SubID> createSubAssembly() override; void appendDataOffset(SubID _sub) override; void appendDataSize(SubID _sub) override; - SubID appendData(dev::bytes const& _data) override; + SubID appendData(bytes const& _data) override; /// Resolves references inside the bytecode and returns the linker object. - dev::eth::LinkerObject finalize(); + evmasm::LinkerObject finalize(); private: void setLabelToCurrentPosition(AbstractAssembly::LabelID _labelId); void appendLabelReferenceInternal(AbstractAssembly::LabelID _labelId); - void updateReference(size_t pos, size_t size, dev::u256 value); + void updateReference(size_t pos, size_t size, u256 value); bool m_evm15 = false; ///< if true, switch to evm1.5 mode LabelID m_nextLabelId = 0; int m_stackHeight = 0; - dev::bytes m_bytecode; + bytes m_bytecode; std::map m_namedLabels; std::map m_labelPositions; std::map m_labelReferences; diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index ba2561e0b..9f95d1257 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -32,8 +32,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void VariableReferenceCounter::operator()(Identifier const& _identifier) { @@ -158,7 +159,7 @@ void CodeTransform::freeUnusedVariables() while (m_unusedStackSlots.count(m_assembly.stackHeight() - 1)) { yulAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), ""); - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::Instruction::POP); --m_stackAdjustment; } } @@ -206,7 +207,7 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl) { m_context->variableStackHeights.erase(&var); m_assembly.setSourceLocation(_varDecl.location); - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::Instruction::POP); --m_stackAdjustment; } else @@ -221,8 +222,8 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl) m_context->variableStackHeights[&var] = slot; m_assembly.setSourceLocation(_varDecl.location); if (int heightDiff = variableHeightDiff(var, varName, true)) - m_assembly.appendInstruction(dev::eth::swapInstruction(heightDiff - 1)); - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::swapInstruction(heightDiff - 1)); + m_assembly.appendInstruction(evmasm::Instruction::POP); --m_stackAdjustment; } } @@ -231,10 +232,10 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl) void CodeTransform::stackError(StackTooDeepError _error, int _targetStackHeight) { - m_assembly.appendInstruction(dev::eth::Instruction::INVALID); + m_assembly.appendInstruction(evmasm::Instruction::INVALID); // Correct the stack. while (m_assembly.stackHeight() > _targetStackHeight) - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::Instruction::POP); while (m_assembly.stackHeight() < _targetStackHeight) m_assembly.appendConstant(u256(0)); // Store error. @@ -316,7 +317,7 @@ void CodeTransform::operator()(Identifier const& _identifier) // TODO: opportunity for optimization: Do not DUP if this is the last reference // to the top most element of the stack if (int heightDiff = variableHeightDiff(_var, _identifier.name, false)) - m_assembly.appendInstruction(dev::eth::dupInstruction(heightDiff)); + m_assembly.appendInstruction(evmasm::dupInstruction(heightDiff)); else // Store something to balance the stack m_assembly.appendConstant(u256(0)); @@ -354,7 +355,7 @@ void CodeTransform::operator()(If const& _if) { visitExpression(*_if.condition); m_assembly.setSourceLocation(_if.location); - m_assembly.appendInstruction(dev::eth::Instruction::ISZERO); + m_assembly.appendInstruction(evmasm::Instruction::ISZERO); AbstractAssembly::LabelID end = m_assembly.newLabelId(); m_assembly.appendJumpToIf(end); (*this)(_if.body); @@ -380,8 +381,8 @@ void CodeTransform::operator()(Switch const& _switch) AbstractAssembly::LabelID bodyLabel = m_assembly.newLabelId(); caseBodies[&c] = bodyLabel; yulAssert(m_assembly.stackHeight() == expressionHeight + 1, ""); - m_assembly.appendInstruction(dev::eth::dupInstruction(2)); - m_assembly.appendInstruction(dev::eth::Instruction::EQ); + m_assembly.appendInstruction(evmasm::dupInstruction(2)); + m_assembly.appendInstruction(evmasm::Instruction::EQ); m_assembly.appendJumpToIf(bodyLabel); } else @@ -407,7 +408,7 @@ void CodeTransform::operator()(Switch const& _switch) m_assembly.setSourceLocation(_switch.location); m_assembly.appendLabel(end); - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::Instruction::POP); checkStackHeight(&_switch); } @@ -516,12 +517,12 @@ void CodeTransform::operator()(FunctionDefinition const& _function) while (!stackLayout.empty() && stackLayout.back() != int(stackLayout.size() - 1)) if (stackLayout.back() < 0) { - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::Instruction::POP); stackLayout.pop_back(); } else { - m_assembly.appendInstruction(dev::eth::swapInstruction(stackLayout.size() - stackLayout.back() - 1)); + m_assembly.appendInstruction(evmasm::swapInstruction(stackLayout.size() - stackLayout.back() - 1)); swap(stackLayout[stackLayout.back()], stackLayout.back()); } for (int i = 0; size_t(i) < stackLayout.size(); ++i) @@ -555,7 +556,7 @@ void CodeTransform::operator()(ForLoop const& _forLoop) visitExpression(*_forLoop.condition); m_assembly.setSourceLocation(_forLoop.location); - m_assembly.appendInstruction(dev::eth::Instruction::ISZERO); + m_assembly.appendInstruction(evmasm::Instruction::ISZERO); m_assembly.appendJumpToIf(loopEnd); int const stackHeightBody = m_assembly.stackHeight(); @@ -581,7 +582,7 @@ int CodeTransform::appendPopUntil(int _targetDepth) { int const stackDiffAfter = m_assembly.stackHeight() - _targetDepth; for (int i = 0; i < stackDiffAfter; ++i) - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::Instruction::POP); return stackDiffAfter; } @@ -725,7 +726,7 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight m_stackAdjustment++; } else - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::Instruction::POP); } int deposit = m_assembly.stackHeight() - blockStartStackHeight; @@ -747,8 +748,8 @@ void CodeTransform::generateAssignment(Identifier const& _variableName) { Scope::Variable const& _var = std::get(*var); if (int heightDiff = variableHeightDiff(_var, _variableName.name, true)) - m_assembly.appendInstruction(dev::eth::swapInstruction(heightDiff - 1)); - m_assembly.appendInstruction(dev::eth::Instruction::POP); + m_assembly.appendInstruction(evmasm::swapInstruction(heightDiff - 1)); + m_assembly.appendInstruction(evmasm::Instruction::POP); decreaseReference(_variableName.name, _var); } else diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index d0615faf1..2c2c5991d 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -30,12 +30,12 @@ #include #include -namespace langutil +namespace solidity::langutil { class ErrorReporter; } -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; class EVMAssembly; diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 266c9f3f4..8a7a17b9a 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -35,23 +35,24 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; namespace { pair createEVMFunction( string const& _name, - dev::eth::Instruction _instruction + evmasm::Instruction _instruction ) { - eth::InstructionInfo info = dev::eth::instructionInfo(_instruction); + evmasm::InstructionInfo info = evmasm::instructionInfo(_instruction); BuiltinFunctionForEVM f; f.name = YulString{_name}; f.parameters.resize(info.args); f.returns.resize(info.ret); f.sideEffects = EVMDialect::sideEffectsOfInstruction(_instruction); - f.isMSize = _instruction == dev::eth::Instruction::MSIZE; + f.isMSize = _instruction == evmasm::Instruction::MSIZE; f.literalArguments = false; f.instruction = _instruction; f.generateCode = [_instruction]( @@ -94,10 +95,10 @@ map createBuiltins(langutil::EVMVersion _evmVe map builtins; for (auto const& instr: Parser::instructions()) if ( - !dev::eth::isDupInstruction(instr.second) && - !dev::eth::isSwapInstruction(instr.second) && - instr.second != eth::Instruction::JUMP && - instr.second != eth::Instruction::JUMPI && + !evmasm::isDupInstruction(instr.second) && + !evmasm::isSwapInstruction(instr.second) && + instr.second != evmasm::Instruction::JUMP && + instr.second != evmasm::Instruction::JUMPI && _evmVersion.hasOpcode(instr.second) ) builtins.emplace(createEVMFunction(instr.first, instr.second)); @@ -159,7 +160,7 @@ map createBuiltins(langutil::EVMVersion _evmVe std::function _visitArguments ) { _visitArguments(); - _assembly.appendInstruction(dev::eth::Instruction::CODECOPY); + _assembly.appendInstruction(evmasm::Instruction::CODECOPY); } )); } @@ -212,13 +213,13 @@ EVMDialect const& EVMDialect::yulForEVM(langutil::EVMVersion _version) return *dialects[_version]; } -SideEffects EVMDialect::sideEffectsOfInstruction(eth::Instruction _instruction) +SideEffects EVMDialect::sideEffectsOfInstruction(evmasm::Instruction _instruction) { return SideEffects{ - eth::SemanticInformation::movable(_instruction), - eth::SemanticInformation::sideEffectFree(_instruction), - eth::SemanticInformation::sideEffectFreeIfNoMSize(_instruction), - eth::SemanticInformation::invalidatesStorage(_instruction), - eth::SemanticInformation::invalidatesMemory(_instruction) + evmasm::SemanticInformation::movable(_instruction), + evmasm::SemanticInformation::sideEffectFree(_instruction), + evmasm::SemanticInformation::sideEffectFreeIfNoMSize(_instruction), + evmasm::SemanticInformation::invalidatesStorage(_instruction), + evmasm::SemanticInformation::invalidatesMemory(_instruction) }; } diff --git a/libyul/backends/evm/EVMDialect.h b/libyul/backends/evm/EVMDialect.h index 6a34520ee..58b08b486 100644 --- a/libyul/backends/evm/EVMDialect.h +++ b/libyul/backends/evm/EVMDialect.h @@ -27,7 +27,7 @@ #include -namespace yul +namespace solidity::yul { class YulString; @@ -47,7 +47,7 @@ struct BuiltinContext struct BuiltinFunctionForEVM: BuiltinFunction { - std::optional instruction; + std::optional instruction; /// Function to generate code for the given function call and append it to the abstract /// assembly. The fourth parameter is called to visit (and generate code for) the arguments /// from right to left. @@ -80,7 +80,7 @@ struct EVMDialect: public Dialect bool providesObjectAccess() const { return m_objectAccess; } - static SideEffects sideEffectsOfInstruction(dev::eth::Instruction _instruction); + static SideEffects sideEffectsOfInstruction(evmasm::Instruction _instruction); protected: bool const m_objectAccess; diff --git a/libyul/backends/evm/EVMMetrics.cpp b/libyul/backends/evm/EVMMetrics.cpp index d765bb159..43c2a3cf5 100644 --- a/libyul/backends/evm/EVMMetrics.cpp +++ b/libyul/backends/evm/EVMMetrics.cpp @@ -32,15 +32,16 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; size_t GasMeter::costs(Expression const& _expression) const { return combineCosts(GasMeterVisitor::costs(_expression, m_dialect, m_isCreation)); } -size_t GasMeter::instructionCosts(eth::Instruction _instruction) const +size_t GasMeter::instructionCosts(evmasm::Instruction _instruction) const { return combineCosts(GasMeterVisitor::instructionCosts(_instruction, m_dialect, m_isCreation)); } @@ -63,7 +64,7 @@ pair GasMeterVisitor::costs( } pair GasMeterVisitor::instructionCosts( - dev::eth::Instruction _instruction, + evmasm::Instruction _instruction, EVMDialect const& _dialect, bool _isCreation ) @@ -87,31 +88,31 @@ void GasMeterVisitor::operator()(FunctionCall const& _funCall) void GasMeterVisitor::operator()(Literal const& _lit) { - m_runGas += dev::eth::GasMeter::runGas(dev::eth::Instruction::PUSH1); + m_runGas += evmasm::GasMeter::runGas(evmasm::Instruction::PUSH1); m_dataGas += singleByteDataGas() + - size_t(dev::eth::GasMeter::dataGas(dev::toCompactBigEndian(valueOfLiteral(_lit), 1), m_isCreation, m_dialect.evmVersion())); + size_t(evmasm::GasMeter::dataGas(toCompactBigEndian(valueOfLiteral(_lit), 1), m_isCreation, m_dialect.evmVersion())); } void GasMeterVisitor::operator()(Identifier const&) { - m_runGas += dev::eth::GasMeter::runGas(dev::eth::Instruction::DUP1); + m_runGas += evmasm::GasMeter::runGas(evmasm::Instruction::DUP1); m_dataGas += singleByteDataGas(); } size_t GasMeterVisitor::singleByteDataGas() const { if (m_isCreation) - return dev::eth::GasCosts::txDataNonZeroGas(m_dialect.evmVersion()); + return evmasm::GasCosts::txDataNonZeroGas(m_dialect.evmVersion()); else - return dev::eth::GasCosts::createDataGas; + return evmasm::GasCosts::createDataGas; } -void GasMeterVisitor::instructionCostsInternal(dev::eth::Instruction _instruction) +void GasMeterVisitor::instructionCostsInternal(evmasm::Instruction _instruction) { - if (_instruction == eth::Instruction::EXP) - m_runGas += dev::eth::GasCosts::expGas + dev::eth::GasCosts::expByteGas(m_dialect.evmVersion()); + if (_instruction == evmasm::Instruction::EXP) + m_runGas += evmasm::GasCosts::expGas + evmasm::GasCosts::expByteGas(m_dialect.evmVersion()); else - m_runGas += dev::eth::GasMeter::runGas(_instruction); + m_runGas += evmasm::GasMeter::runGas(_instruction); m_dataGas += singleByteDataGas(); } diff --git a/libyul/backends/evm/EVMMetrics.h b/libyul/backends/evm/EVMMetrics.h index ff670d577..b6a23e3c8 100644 --- a/libyul/backends/evm/EVMMetrics.h +++ b/libyul/backends/evm/EVMMetrics.h @@ -24,7 +24,7 @@ #include #include -namespace yul +namespace solidity::yul { struct EVMDialect; @@ -49,7 +49,7 @@ public: size_t costs(Expression const& _expression) const; /// @returns the combined costs of deploying and running the instruction, not including /// the costs for its arguments. - size_t instructionCosts(dev::eth::Instruction _instruction) const; + size_t instructionCosts(evmasm::Instruction _instruction) const; private: size_t combineCosts(std::pair _costs) const; @@ -69,7 +69,7 @@ public: ); static std::pair instructionCosts( - dev::eth::Instruction _instruction, + evmasm::Instruction _instruction, EVMDialect const& _dialect, bool _isCreation = false ); @@ -89,7 +89,7 @@ private: /// Computes the cost of storing and executing the single instruction (excluding its arguments). /// For EXP, it assumes that the exponent is at most 255. /// Does not work particularly exact for anything apart from arithmetic. - void instructionCostsInternal(dev::eth::Instruction _instruction); + void instructionCostsInternal(evmasm::Instruction _instruction); EVMDialect const& m_dialect; bool m_isCreation = false; diff --git a/libyul/backends/evm/EVMObjectCompiler.cpp b/libyul/backends/evm/EVMObjectCompiler.cpp index c183c435a..6463b4a46 100644 --- a/libyul/backends/evm/EVMObjectCompiler.cpp +++ b/libyul/backends/evm/EVMObjectCompiler.cpp @@ -26,7 +26,7 @@ #include #include -using namespace yul; +using namespace solidity::yul; using namespace std; void EVMObjectCompiler::compile(Object& _object, AbstractAssembly& _assembly, EVMDialect const& _dialect, bool _evm15, bool _optimize) diff --git a/libyul/backends/evm/EVMObjectCompiler.h b/libyul/backends/evm/EVMObjectCompiler.h index a094ba20d..fb40ac739 100644 --- a/libyul/backends/evm/EVMObjectCompiler.h +++ b/libyul/backends/evm/EVMObjectCompiler.h @@ -20,7 +20,7 @@ #pragma once -namespace yul +namespace solidity::yul { struct Object; class AbstractAssembly; diff --git a/libyul/backends/evm/NoOutputAssembly.cpp b/libyul/backends/evm/NoOutputAssembly.cpp index e2a34ef20..b3e4feba4 100644 --- a/libyul/backends/evm/NoOutputAssembly.cpp +++ b/libyul/backends/evm/NoOutputAssembly.cpp @@ -24,30 +24,31 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; -void NoOutputAssembly::appendInstruction(dev::eth::Instruction _instr) +void NoOutputAssembly::appendInstruction(evmasm::Instruction _instr) { m_stackHeight += instructionInfo(_instr).ret - instructionInfo(_instr).args; } void NoOutputAssembly::appendConstant(u256 const&) { - appendInstruction(dev::eth::pushInstruction(1)); + appendInstruction(evmasm::pushInstruction(1)); } void NoOutputAssembly::appendLabel(LabelID) { - appendInstruction(dev::eth::Instruction::JUMPDEST); + appendInstruction(evmasm::Instruction::JUMPDEST); } void NoOutputAssembly::appendLabelReference(LabelID) { yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); - appendInstruction(dev::eth::pushInstruction(1)); + appendInstruction(evmasm::pushInstruction(1)); } NoOutputAssembly::LabelID NoOutputAssembly::newLabelId() @@ -68,7 +69,7 @@ void NoOutputAssembly::appendLinkerSymbol(string const&) void NoOutputAssembly::appendJump(int _stackDiffAfter) { yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); - appendInstruction(dev::eth::Instruction::JUMP); + appendInstruction(evmasm::Instruction::JUMP); m_stackHeight += _stackDiffAfter; } @@ -90,7 +91,7 @@ void NoOutputAssembly::appendJumpToIf(LabelID _labelId) else { appendLabelReference(_labelId); - appendInstruction(dev::eth::Instruction::JUMPI); + appendInstruction(evmasm::Instruction::JUMPI); } } @@ -117,7 +118,7 @@ void NoOutputAssembly::appendReturnsub(int _returns, int _stackDiffAfter) void NoOutputAssembly::appendAssemblySize() { - appendInstruction(dev::eth::Instruction::PUSH1); + appendInstruction(evmasm::Instruction::PUSH1); } pair, AbstractAssembly::SubID> NoOutputAssembly::createSubAssembly() @@ -128,12 +129,12 @@ pair, AbstractAssembly::SubID> NoOutputAssembly::cr void NoOutputAssembly::appendDataOffset(AbstractAssembly::SubID) { - appendInstruction(dev::eth::Instruction::PUSH1); + appendInstruction(evmasm::Instruction::PUSH1); } void NoOutputAssembly::appendDataSize(AbstractAssembly::SubID) { - appendInstruction(dev::eth::Instruction::PUSH1); + appendInstruction(evmasm::Instruction::PUSH1); } AbstractAssembly::SubID NoOutputAssembly::appendData(bytes const&) @@ -152,7 +153,7 @@ NoOutputEVMDialect::NoOutputEVMDialect(EVMDialect const& _copyFrom): { _visitArguments(); for (size_t i = 0; i < parameters; i++) - _assembly.appendInstruction(dev::eth::Instruction::POP); + _assembly.appendInstruction(evmasm::Instruction::POP); for (size_t i = 0; i < returns; i++) _assembly.appendConstant(u256(0)); diff --git a/libyul/backends/evm/NoOutputAssembly.h b/libyul/backends/evm/NoOutputAssembly.h index d938a4e45..bc914f9ac 100644 --- a/libyul/backends/evm/NoOutputAssembly.h +++ b/libyul/backends/evm/NoOutputAssembly.h @@ -28,12 +28,12 @@ #include -namespace langutil +namespace solidity::langutil { struct SourceLocation; } -namespace yul +namespace solidity::yul { @@ -50,8 +50,8 @@ public: void setSourceLocation(langutil::SourceLocation const&) override {} int stackHeight() const override { return m_stackHeight; } void setStackHeight(int height) override { m_stackHeight = height; } - void appendInstruction(dev::eth::Instruction _instruction) override; - void appendConstant(dev::u256 const& _constant) override; + void appendInstruction(evmasm::Instruction _instruction) override; + void appendConstant(u256 const& _constant) override; void appendLabel(LabelID _labelId) override; void appendLabelReference(LabelID _labelId) override; LabelID newLabelId() override; @@ -69,7 +69,7 @@ public: std::pair, SubID> createSubAssembly() override; void appendDataOffset(SubID _sub) override; void appendDataSize(SubID _sub) override; - SubID appendData(dev::bytes const& _data) override; + SubID appendData(bytes const& _data) override; private: bool m_evm15 = false; ///< if true, switch to evm1.5 mode diff --git a/libyul/backends/wasm/BinaryTransform.cpp b/libyul/backends/wasm/BinaryTransform.cpp index 1dee4daee..5ea09e9e4 100644 --- a/libyul/backends/wasm/BinaryTransform.cpp +++ b/libyul/backends/wasm/BinaryTransform.cpp @@ -26,9 +26,10 @@ #include using namespace std; -using namespace yul; -using namespace dev; -using namespace yul::wasm; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::wasm; +using namespace solidity::util; namespace { diff --git a/libyul/backends/wasm/BinaryTransform.h b/libyul/backends/wasm/BinaryTransform.h index 132f38ca2..6c9128489 100644 --- a/libyul/backends/wasm/BinaryTransform.h +++ b/libyul/backends/wasm/BinaryTransform.h @@ -27,9 +27,7 @@ #include #include -namespace yul -{ -namespace wasm +namespace solidity::yul::wasm { /** @@ -38,23 +36,23 @@ namespace wasm class BinaryTransform { public: - static dev::bytes run(Module const& _module); + static bytes run(Module const& _module); - dev::bytes operator()(wasm::Literal const& _literal); - dev::bytes operator()(wasm::StringLiteral const& _literal); - dev::bytes operator()(wasm::LocalVariable const& _identifier); - dev::bytes operator()(wasm::GlobalVariable const& _identifier); - dev::bytes operator()(wasm::BuiltinCall const& _builinCall); - dev::bytes operator()(wasm::FunctionCall const& _functionCall); - dev::bytes operator()(wasm::LocalAssignment const& _assignment); - dev::bytes operator()(wasm::GlobalAssignment const& _assignment); - dev::bytes operator()(wasm::If const& _if); - dev::bytes operator()(wasm::Loop const& _loop); - dev::bytes operator()(wasm::Break const& _break); - dev::bytes operator()(wasm::BreakIf const& _break); - dev::bytes operator()(wasm::Return const& _return); - dev::bytes operator()(wasm::Block const& _block); - dev::bytes operator()(wasm::FunctionDefinition const& _function); + bytes operator()(wasm::Literal const& _literal); + bytes operator()(wasm::StringLiteral const& _literal); + bytes operator()(wasm::LocalVariable const& _identifier); + bytes operator()(wasm::GlobalVariable const& _identifier); + bytes operator()(wasm::BuiltinCall const& _builinCall); + bytes operator()(wasm::FunctionCall const& _functionCall); + bytes operator()(wasm::LocalAssignment const& _assignment); + bytes operator()(wasm::GlobalAssignment const& _assignment); + bytes operator()(wasm::If const& _if); + bytes operator()(wasm::Loop const& _loop); + bytes operator()(wasm::Break const& _break); + bytes operator()(wasm::BreakIf const& _break); + bytes operator()(wasm::Return const& _return); + bytes operator()(wasm::Block const& _block); + bytes operator()(wasm::FunctionDefinition const& _function); private: using Type = std::pair, std::vector>; @@ -63,23 +61,23 @@ private: static uint8_t encodeType(std::string const& _typeName); static std::vector encodeTypes(std::vector const& _typeNames); - dev::bytes typeSection( + bytes typeSection( std::vector const& _imports, std::vector const& _functions ); - dev::bytes importSection(std::vector const& _imports); - dev::bytes functionSection(std::vector const& _functions); - dev::bytes memorySection(); - dev::bytes globalSection(); - dev::bytes exportSection(); - dev::bytes customSection(std::string const& _name, dev::bytes _data); - dev::bytes codeSection(std::vector const& _functions); + bytes importSection(std::vector const& _imports); + bytes functionSection(std::vector const& _functions); + bytes memorySection(); + bytes globalSection(); + bytes exportSection(); + bytes customSection(std::string const& _name, bytes _data); + bytes codeSection(std::vector const& _functions); - dev::bytes visit(std::vector const& _expressions); - dev::bytes visitReversed(std::vector const& _expressions); + bytes visit(std::vector const& _expressions); + bytes visitReversed(std::vector const& _expressions); - static dev::bytes encodeName(std::string const& _name); + static bytes encodeName(std::string const& _name); std::map m_locals; std::map m_globals; @@ -89,7 +87,5 @@ private: std::map> m_subModulePosAndSize; }; - -} } diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index 20a608708..7264515df 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -41,9 +41,10 @@ #include using namespace std; -using namespace dev; -using namespace yul; -using namespace langutil; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; namespace { diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.h b/libyul/backends/wasm/EVMToEwasmTranslator.h index 73563fc05..0bd86a317 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.h +++ b/libyul/backends/wasm/EVMToEwasmTranslator.h @@ -24,7 +24,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Object; diff --git a/libyul/backends/wasm/TextTransform.cpp b/libyul/backends/wasm/TextTransform.cpp index 49e617e55..72b6d01c1 100644 --- a/libyul/backends/wasm/TextTransform.cpp +++ b/libyul/backends/wasm/TextTransform.cpp @@ -27,9 +27,10 @@ #include using namespace std; -using namespace yul; -using namespace dev; -using namespace yul::wasm; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::wasm; +using namespace solidity::util; string TextTransform::run(wasm::Module const& _module) { diff --git a/libyul/backends/wasm/TextTransform.h b/libyul/backends/wasm/TextTransform.h index 2424939a8..10f9f3fbb 100644 --- a/libyul/backends/wasm/TextTransform.h +++ b/libyul/backends/wasm/TextTransform.h @@ -24,11 +24,12 @@ #include -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; +} -namespace wasm +namespace solidity::yul::wasm { class TextTransform @@ -65,4 +66,3 @@ private: }; } -} diff --git a/libyul/backends/wasm/WasmAST.h b/libyul/backends/wasm/WasmAST.h index 6d920f50e..02862aea2 100644 --- a/libyul/backends/wasm/WasmAST.h +++ b/libyul/backends/wasm/WasmAST.h @@ -26,9 +26,7 @@ #include #include -namespace yul -{ -namespace wasm +namespace solidity::yul::wasm { struct Literal; @@ -102,4 +100,3 @@ struct Module }; } -} diff --git a/libyul/backends/wasm/WasmCodeTransform.cpp b/libyul/backends/wasm/WasmCodeTransform.cpp index 51f80af17..f3ff04cd9 100644 --- a/libyul/backends/wasm/WasmCodeTransform.cpp +++ b/libyul/backends/wasm/WasmCodeTransform.cpp @@ -33,8 +33,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; wasm::Module WasmCodeTransform::run(Dialect const& _dialect, yul::Block const& _ast) { diff --git a/libyul/backends/wasm/WasmCodeTransform.h b/libyul/backends/wasm/WasmCodeTransform.h index 1a606d5ab..2f3ba88c9 100644 --- a/libyul/backends/wasm/WasmCodeTransform.h +++ b/libyul/backends/wasm/WasmCodeTransform.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; diff --git a/libyul/backends/wasm/WasmDialect.cpp b/libyul/backends/wasm/WasmDialect.cpp index 8e0cba8f9..78f9b045c 100644 --- a/libyul/backends/wasm/WasmDialect.cpp +++ b/libyul/backends/wasm/WasmDialect.cpp @@ -21,7 +21,7 @@ #include using namespace std; -using namespace yul; +using namespace solidity::yul; WasmDialect::WasmDialect(): Dialect{AsmFlavour::Strict} diff --git a/libyul/backends/wasm/WasmDialect.h b/libyul/backends/wasm/WasmDialect.h index e77381a13..66b70864e 100644 --- a/libyul/backends/wasm/WasmDialect.h +++ b/libyul/backends/wasm/WasmDialect.h @@ -24,7 +24,7 @@ #include -namespace yul +namespace solidity::yul { class YulString; diff --git a/libyul/backends/wasm/WasmObjectCompiler.cpp b/libyul/backends/wasm/WasmObjectCompiler.cpp index b65318ae3..a6683b5ab 100644 --- a/libyul/backends/wasm/WasmObjectCompiler.cpp +++ b/libyul/backends/wasm/WasmObjectCompiler.cpp @@ -29,10 +29,11 @@ #include -using namespace yul; +using namespace solidity; +using namespace solidity::yul; using namespace std; -pair WasmObjectCompiler::compile(Object& _object, Dialect const& _dialect) +pair WasmObjectCompiler::compile(Object& _object, Dialect const& _dialect) { WasmObjectCompiler compiler(_dialect); wasm::Module module = compiler.run(_object); diff --git a/libyul/backends/wasm/WasmObjectCompiler.h b/libyul/backends/wasm/WasmObjectCompiler.h index 2805f0b06..8c93aba64 100644 --- a/libyul/backends/wasm/WasmObjectCompiler.h +++ b/libyul/backends/wasm/WasmObjectCompiler.h @@ -23,13 +23,9 @@ #include #include #include +#include // solidity::bytes -namespace dev -{ -using bytes = std::vector; -} - -namespace yul +namespace solidity::yul { struct Object; struct Dialect; @@ -42,7 +38,7 @@ class WasmObjectCompiler { public: /// Compiles the given object and returns the Wasm text and binary representation. - static std::pair compile(Object& _object, Dialect const& _dialect); + static std::pair compile(Object& _object, Dialect const& _dialect); private: WasmObjectCompiler(Dialect const& _dialect): m_dialect(_dialect) diff --git a/libyul/backends/wasm/WordSizeTransform.cpp b/libyul/backends/wasm/WordSizeTransform.cpp index 01a237c7c..d1867a2e8 100644 --- a/libyul/backends/wasm/WordSizeTransform.cpp +++ b/libyul/backends/wasm/WordSizeTransform.cpp @@ -28,8 +28,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void WordSizeTransform::operator()(FunctionDefinition& _fd) { diff --git a/libyul/backends/wasm/WordSizeTransform.h b/libyul/backends/wasm/WordSizeTransform.h index 03c4b2de1..199b01b49 100644 --- a/libyul/backends/wasm/WordSizeTransform.h +++ b/libyul/backends/wasm/WordSizeTransform.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/ASTCopier.cpp b/libyul/optimiser/ASTCopier.cpp index 908230e35..99868d27f 100644 --- a/libyul/optimiser/ASTCopier.cpp +++ b/libyul/optimiser/ASTCopier.cpp @@ -27,8 +27,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; Statement ASTCopier::operator()(ExpressionStatement const& _statement) { diff --git a/libyul/optimiser/ASTCopier.h b/libyul/optimiser/ASTCopier.h index 0a1d0f0e1..45cce07c2 100644 --- a/libyul/optimiser/ASTCopier.h +++ b/libyul/optimiser/ASTCopier.h @@ -29,7 +29,7 @@ #include #include -namespace yul +namespace solidity::yul { class ExpressionCopier diff --git a/libyul/optimiser/ASTWalker.cpp b/libyul/optimiser/ASTWalker.cpp index a30177784..728949a4e 100644 --- a/libyul/optimiser/ASTWalker.cpp +++ b/libyul/optimiser/ASTWalker.cpp @@ -25,8 +25,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void ASTWalker::operator()(FunctionCall const& _funCall) { diff --git a/libyul/optimiser/ASTWalker.h b/libyul/optimiser/ASTWalker.h index e766e8082..20f7fb9b4 100644 --- a/libyul/optimiser/ASTWalker.h +++ b/libyul/optimiser/ASTWalker.h @@ -30,7 +30,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/BlockFlattener.cpp b/libyul/optimiser/BlockFlattener.cpp index f93d6e082..804d6ea77 100644 --- a/libyul/optimiser/BlockFlattener.cpp +++ b/libyul/optimiser/BlockFlattener.cpp @@ -21,8 +21,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void BlockFlattener::operator()(Block& _block) { diff --git a/libyul/optimiser/BlockFlattener.h b/libyul/optimiser/BlockFlattener.h index 5895712e5..31d3307d1 100644 --- a/libyul/optimiser/BlockFlattener.h +++ b/libyul/optimiser/BlockFlattener.h @@ -19,7 +19,7 @@ #include #include -namespace yul +namespace solidity::yul { class BlockFlattener: public ASTModifier diff --git a/libyul/optimiser/BlockHasher.cpp b/libyul/optimiser/BlockHasher.cpp index af4ee3725..0c6c04a1c 100644 --- a/libyul/optimiser/BlockHasher.cpp +++ b/libyul/optimiser/BlockHasher.cpp @@ -24,8 +24,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; namespace { diff --git a/libyul/optimiser/BlockHasher.h b/libyul/optimiser/BlockHasher.h index 4e9ddc732..3b90f0c4d 100644 --- a/libyul/optimiser/BlockHasher.h +++ b/libyul/optimiser/BlockHasher.h @@ -24,7 +24,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/CallGraphGenerator.cpp b/libyul/optimiser/CallGraphGenerator.cpp index 6d0a0e54a..d3805e7f7 100644 --- a/libyul/optimiser/CallGraphGenerator.cpp +++ b/libyul/optimiser/CallGraphGenerator.cpp @@ -26,8 +26,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; CallGraph CallGraphGenerator::callGraph(Block const& _ast) { diff --git a/libyul/optimiser/CallGraphGenerator.h b/libyul/optimiser/CallGraphGenerator.h index 67f0615c0..89895e410 100644 --- a/libyul/optimiser/CallGraphGenerator.h +++ b/libyul/optimiser/CallGraphGenerator.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { struct CallGraph diff --git a/libyul/optimiser/CommonSubexpressionEliminator.cpp b/libyul/optimiser/CommonSubexpressionEliminator.cpp index 5baea5eb2..7528a4299 100644 --- a/libyul/optimiser/CommonSubexpressionEliminator.cpp +++ b/libyul/optimiser/CommonSubexpressionEliminator.cpp @@ -31,8 +31,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void CommonSubexpressionEliminator::run(OptimiserStepContext& _context, Block& _ast) { diff --git a/libyul/optimiser/CommonSubexpressionEliminator.h b/libyul/optimiser/CommonSubexpressionEliminator.h index 8db5e7aed..04fc36a8c 100644 --- a/libyul/optimiser/CommonSubexpressionEliminator.h +++ b/libyul/optimiser/CommonSubexpressionEliminator.h @@ -24,7 +24,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/ConditionalSimplifier.cpp b/libyul/optimiser/ConditionalSimplifier.cpp index 8d811233e..3cd92283a 100644 --- a/libyul/optimiser/ConditionalSimplifier.cpp +++ b/libyul/optimiser/ConditionalSimplifier.cpp @@ -23,8 +23,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void ConditionalSimplifier::operator()(Switch& _switch) { diff --git a/libyul/optimiser/ConditionalSimplifier.h b/libyul/optimiser/ConditionalSimplifier.h index 9b0f1cb26..9f0cd6b34 100644 --- a/libyul/optimiser/ConditionalSimplifier.h +++ b/libyul/optimiser/ConditionalSimplifier.h @@ -21,7 +21,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/ConditionalUnsimplifier.cpp b/libyul/optimiser/ConditionalUnsimplifier.cpp index a405205a3..6670034d0 100644 --- a/libyul/optimiser/ConditionalUnsimplifier.cpp +++ b/libyul/optimiser/ConditionalUnsimplifier.cpp @@ -23,8 +23,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void ConditionalUnsimplifier::operator()(Switch& _switch) { diff --git a/libyul/optimiser/ConditionalUnsimplifier.h b/libyul/optimiser/ConditionalUnsimplifier.h index 16358c9f7..0b5be9bfd 100644 --- a/libyul/optimiser/ConditionalUnsimplifier.h +++ b/libyul/optimiser/ConditionalUnsimplifier.h @@ -21,7 +21,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/ControlFlowSimplifier.cpp b/libyul/optimiser/ControlFlowSimplifier.cpp index 39eca4630..df5ead104 100644 --- a/libyul/optimiser/ControlFlowSimplifier.cpp +++ b/libyul/optimiser/ControlFlowSimplifier.cpp @@ -27,8 +27,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::yul; using OptionalStatements = std::optional>; diff --git a/libyul/optimiser/ControlFlowSimplifier.h b/libyul/optimiser/ControlFlowSimplifier.h index c8c402c5d..5713f12a1 100644 --- a/libyul/optimiser/ControlFlowSimplifier.h +++ b/libyul/optimiser/ControlFlowSimplifier.h @@ -19,7 +19,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; struct OptimiserStepContext; diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp index 5ded2de3e..e1874088d 100644 --- a/libyul/optimiser/DataFlowAnalyzer.cpp +++ b/libyul/optimiser/DataFlowAnalyzer.cpp @@ -35,13 +35,14 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::yul; void DataFlowAnalyzer::operator()(ExpressionStatement& _statement) { - if (auto vars = isSimpleStore(dev::eth::Instruction::SSTORE, _statement)) + if (auto vars = isSimpleStore(evmasm::Instruction::SSTORE, _statement)) { ASTModifier::operator()(_statement); set keysToErase; @@ -55,7 +56,7 @@ void DataFlowAnalyzer::operator()(ExpressionStatement& _statement) m_storage.eraseKey(key); m_storage.set(vars->first, vars->second); } - else if (auto vars = isSimpleStore(dev::eth::Instruction::MSTORE, _statement)) + else if (auto vars = isSimpleStore(evmasm::Instruction::MSTORE, _statement)) { ASTModifier::operator()(_statement); set keysToErase; @@ -360,13 +361,13 @@ bool DataFlowAnalyzer::inScope(YulString _variableName) const } std::optional> DataFlowAnalyzer::isSimpleStore( - dev::eth::Instruction _store, + evmasm::Instruction _store, ExpressionStatement const& _statement ) const { yulAssert( - _store == dev::eth::Instruction::MSTORE || - _store == dev::eth::Instruction::SSTORE, + _store == evmasm::Instruction::MSTORE || + _store == evmasm::Instruction::SSTORE, "" ); if (holds_alternative(_statement.expression)) diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index d8d94d09d..64de71a14 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -36,7 +36,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; struct SideEffects; @@ -133,7 +133,7 @@ protected: bool inScope(YulString _variableName) const; std::optional> isSimpleStore( - dev::eth::Instruction _store, + evmasm::Instruction _store, ExpressionStatement const& _statement ) const; diff --git a/libyul/optimiser/DeadCodeEliminator.cpp b/libyul/optimiser/DeadCodeEliminator.cpp index a2daf9452..890161bf0 100644 --- a/libyul/optimiser/DeadCodeEliminator.cpp +++ b/libyul/optimiser/DeadCodeEliminator.cpp @@ -29,9 +29,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; - +using namespace solidity; +using namespace solidity::util; +using namespace solidity::yul; void DeadCodeEliminator::run(OptimiserStepContext& _context, Block& _ast) { diff --git a/libyul/optimiser/DeadCodeEliminator.h b/libyul/optimiser/DeadCodeEliminator.h index 7be5c1d2f..d1607b49e 100644 --- a/libyul/optimiser/DeadCodeEliminator.h +++ b/libyul/optimiser/DeadCodeEliminator.h @@ -26,7 +26,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; struct OptimiserStepContext; diff --git a/libyul/optimiser/Disambiguator.cpp b/libyul/optimiser/Disambiguator.cpp index d1459bce8..50aa93599 100644 --- a/libyul/optimiser/Disambiguator.cpp +++ b/libyul/optimiser/Disambiguator.cpp @@ -26,8 +26,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; YulString Disambiguator::translateIdentifier(YulString _originalName) { diff --git a/libyul/optimiser/Disambiguator.h b/libyul/optimiser/Disambiguator.h index 14b7b7cc3..997a9cf20 100644 --- a/libyul/optimiser/Disambiguator.h +++ b/libyul/optimiser/Disambiguator.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/EquivalentFunctionCombiner.cpp b/libyul/optimiser/EquivalentFunctionCombiner.cpp index d7b3e62a6..894563678 100644 --- a/libyul/optimiser/EquivalentFunctionCombiner.cpp +++ b/libyul/optimiser/EquivalentFunctionCombiner.cpp @@ -23,8 +23,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void EquivalentFunctionCombiner::run(OptimiserStepContext&, Block& _ast) { diff --git a/libyul/optimiser/EquivalentFunctionCombiner.h b/libyul/optimiser/EquivalentFunctionCombiner.h index 0d120d679..19ddbd71f 100644 --- a/libyul/optimiser/EquivalentFunctionCombiner.h +++ b/libyul/optimiser/EquivalentFunctionCombiner.h @@ -24,7 +24,7 @@ #include #include -namespace yul +namespace solidity::yul { struct OptimiserStepContext; diff --git a/libyul/optimiser/EquivalentFunctionDetector.cpp b/libyul/optimiser/EquivalentFunctionDetector.cpp index 2b2f1a6f3..6c617a4e4 100644 --- a/libyul/optimiser/EquivalentFunctionDetector.cpp +++ b/libyul/optimiser/EquivalentFunctionDetector.cpp @@ -25,8 +25,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void EquivalentFunctionDetector::operator()(FunctionDefinition const& _fun) { diff --git a/libyul/optimiser/EquivalentFunctionDetector.h b/libyul/optimiser/EquivalentFunctionDetector.h index 5db3bdb17..62825bcfa 100644 --- a/libyul/optimiser/EquivalentFunctionDetector.h +++ b/libyul/optimiser/EquivalentFunctionDetector.h @@ -23,7 +23,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/ExpressionInliner.cpp b/libyul/optimiser/ExpressionInliner.cpp index 0288b92f2..f17b594f3 100644 --- a/libyul/optimiser/ExpressionInliner.cpp +++ b/libyul/optimiser/ExpressionInliner.cpp @@ -30,8 +30,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void ExpressionInliner::run(OptimiserStepContext& _context, Block& _ast) { diff --git a/libyul/optimiser/ExpressionInliner.h b/libyul/optimiser/ExpressionInliner.h index b08df86c0..92bdebffc 100644 --- a/libyul/optimiser/ExpressionInliner.h +++ b/libyul/optimiser/ExpressionInliner.h @@ -25,7 +25,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; struct OptimiserStepContext; diff --git a/libyul/optimiser/ExpressionJoiner.cpp b/libyul/optimiser/ExpressionJoiner.cpp index c6e4321e5..4558a1c87 100644 --- a/libyul/optimiser/ExpressionJoiner.cpp +++ b/libyul/optimiser/ExpressionJoiner.cpp @@ -31,8 +31,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void ExpressionJoiner::run(OptimiserStepContext&, Block& _ast) { diff --git a/libyul/optimiser/ExpressionJoiner.h b/libyul/optimiser/ExpressionJoiner.h index 4cc28f826..709a822e7 100644 --- a/libyul/optimiser/ExpressionJoiner.h +++ b/libyul/optimiser/ExpressionJoiner.h @@ -25,7 +25,7 @@ #include -namespace yul +namespace solidity::yul { class NameCollector; diff --git a/libyul/optimiser/ExpressionSimplifier.cpp b/libyul/optimiser/ExpressionSimplifier.cpp index ce896e649..0653eb9a7 100644 --- a/libyul/optimiser/ExpressionSimplifier.cpp +++ b/libyul/optimiser/ExpressionSimplifier.cpp @@ -28,8 +28,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void ExpressionSimplifier::run(OptimiserStepContext& _context, Block& _ast) { diff --git a/libyul/optimiser/ExpressionSimplifier.h b/libyul/optimiser/ExpressionSimplifier.h index a7dbb3b41..c11ab9bf3 100644 --- a/libyul/optimiser/ExpressionSimplifier.h +++ b/libyul/optimiser/ExpressionSimplifier.h @@ -24,7 +24,7 @@ #include -namespace yul +namespace solidity::yul { struct Dialect; struct OptimiserStepContext; diff --git a/libyul/optimiser/ExpressionSplitter.cpp b/libyul/optimiser/ExpressionSplitter.cpp index 58481b50b..94c107da9 100644 --- a/libyul/optimiser/ExpressionSplitter.cpp +++ b/libyul/optimiser/ExpressionSplitter.cpp @@ -32,9 +32,10 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; void ExpressionSplitter::run(OptimiserStepContext& _context, Block& _ast) { diff --git a/libyul/optimiser/ExpressionSplitter.h b/libyul/optimiser/ExpressionSplitter.h index aefda79ab..dfd640ac3 100644 --- a/libyul/optimiser/ExpressionSplitter.h +++ b/libyul/optimiser/ExpressionSplitter.h @@ -27,7 +27,7 @@ #include -namespace yul +namespace solidity::yul { class NameCollector; diff --git a/libyul/optimiser/ForLoopConditionIntoBody.cpp b/libyul/optimiser/ForLoopConditionIntoBody.cpp index 1807a2813..81f038cbf 100644 --- a/libyul/optimiser/ForLoopConditionIntoBody.cpp +++ b/libyul/optimiser/ForLoopConditionIntoBody.cpp @@ -21,8 +21,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void ForLoopConditionIntoBody::run(OptimiserStepContext& _context, Block& _ast) { @@ -47,10 +47,10 @@ void ForLoopConditionIntoBody::operator()(ForLoop& _forLoop) FunctionCall { loc, {loc, m_dialect.booleanNegationFunction()->name}, - make_vector(std::move(*_forLoop.condition)) + util::make_vector(std::move(*_forLoop.condition)) } ), - Block {loc, make_vector(Break{{}})} + Block {loc, util::make_vector(Break{{}})} } ); _forLoop.condition = make_unique( diff --git a/libyul/optimiser/ForLoopConditionIntoBody.h b/libyul/optimiser/ForLoopConditionIntoBody.h index e15c502c8..633403c96 100644 --- a/libyul/optimiser/ForLoopConditionIntoBody.h +++ b/libyul/optimiser/ForLoopConditionIntoBody.h @@ -19,7 +19,7 @@ #include #include -namespace yul +namespace solidity::yul { struct OptimiserStepContext; diff --git a/libyul/optimiser/ForLoopConditionOutOfBody.cpp b/libyul/optimiser/ForLoopConditionOutOfBody.cpp index e7f93b8b6..1d8291cf7 100644 --- a/libyul/optimiser/ForLoopConditionOutOfBody.cpp +++ b/libyul/optimiser/ForLoopConditionOutOfBody.cpp @@ -22,8 +22,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void ForLoopConditionOutOfBody::run(OptimiserStepContext& _context, Block& _ast) { @@ -64,7 +64,7 @@ void ForLoopConditionOutOfBody::operator()(ForLoop& _forLoop) _forLoop.condition = make_unique(FunctionCall{ location, Identifier{location, iszero}, - make_vector( + util::make_vector( std::move(*firstStatement.condition) ) }); diff --git a/libyul/optimiser/ForLoopConditionOutOfBody.h b/libyul/optimiser/ForLoopConditionOutOfBody.h index 8945bf752..b5f8c8d02 100644 --- a/libyul/optimiser/ForLoopConditionOutOfBody.h +++ b/libyul/optimiser/ForLoopConditionOutOfBody.h @@ -20,7 +20,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp index ff2786d6d..60a901e1d 100644 --- a/libyul/optimiser/ForLoopInitRewriter.cpp +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -20,12 +20,12 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void ForLoopInitRewriter::operator()(Block& _block) { - iterateReplacing( + util::iterateReplacing( _block.statements, [&](Statement& _stmt) -> std::optional> { diff --git a/libyul/optimiser/ForLoopInitRewriter.h b/libyul/optimiser/ForLoopInitRewriter.h index a36f76fdd..e2143ca61 100644 --- a/libyul/optimiser/ForLoopInitRewriter.h +++ b/libyul/optimiser/ForLoopInitRewriter.h @@ -19,7 +19,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index 02874eda1..487e16db0 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -36,8 +36,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void FullInliner::run(OptimiserStepContext& _context, Block& _ast) { @@ -154,14 +154,14 @@ void InlineModifier::operator()(Block& _block) visit(_statement); return tryInlineStatement(_statement); }; - iterateReplacing(_block.statements, f); + util::iterateReplacing(_block.statements, f); } std::optional> InlineModifier::tryInlineStatement(Statement& _statement) { // Only inline for expression statements, assignments and variable declarations. - Expression* e = std::visit(GenericVisitor{ - VisitorFallback{}, + Expression* e = std::visit(util::GenericVisitor{ + util::VisitorFallback{}, [](ExpressionStatement& _s) { return &_s.expression; }, [](Assignment& _s) { return _s.value.get(); }, [](VariableDeclaration& _s) { return _s.value.get(); } @@ -169,8 +169,8 @@ std::optional> InlineModifier::tryInlineStatement(Statement& _ if (e) { // Only inline direct function calls. - FunctionCall* funCall = std::visit(GenericVisitor{ - VisitorFallback{}, + FunctionCall* funCall = std::visit(util::GenericVisitor{ + util::VisitorFallback{}, [](FunctionCall& _e) { return &_e; } }, *e); if (funCall && m_driver.shallInline(*funCall, m_currentFunction)) @@ -210,8 +210,8 @@ vector InlineModifier::performInline(Statement& _statement, FunctionC Statement newBody = BodyCopier(m_nameDispenser, variableReplacements)(function->body); newStatements += std::move(std::get(newBody).statements); - std::visit(GenericVisitor{ - VisitorFallback<>{}, + std::visit(util::GenericVisitor{ + util::VisitorFallback<>{}, [&](Assignment& _assignment) { for (size_t i = 0; i < _assignment.variableNames.size(); ++i) diff --git a/libyul/optimiser/FullInliner.h b/libyul/optimiser/FullInliner.h index fc527b79a..788eea99b 100644 --- a/libyul/optimiser/FullInliner.h +++ b/libyul/optimiser/FullInliner.h @@ -32,7 +32,7 @@ #include #include -namespace yul +namespace solidity::yul { class NameCollector; diff --git a/libyul/optimiser/FunctionGrouper.cpp b/libyul/optimiser/FunctionGrouper.cpp index b6a79265a..60a1fa013 100644 --- a/libyul/optimiser/FunctionGrouper.cpp +++ b/libyul/optimiser/FunctionGrouper.cpp @@ -26,8 +26,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void FunctionGrouper::operator()(Block& _block) diff --git a/libyul/optimiser/FunctionGrouper.h b/libyul/optimiser/FunctionGrouper.h index 2e36c1be6..ef3619893 100644 --- a/libyul/optimiser/FunctionGrouper.h +++ b/libyul/optimiser/FunctionGrouper.h @@ -23,7 +23,7 @@ #include -namespace yul +namespace solidity::yul { struct OptimiserStepContext; diff --git a/libyul/optimiser/FunctionHoister.cpp b/libyul/optimiser/FunctionHoister.cpp index d2981691d..b3e8c32f7 100644 --- a/libyul/optimiser/FunctionHoister.cpp +++ b/libyul/optimiser/FunctionHoister.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void FunctionHoister::operator()(Block& _block) { diff --git a/libyul/optimiser/FunctionHoister.h b/libyul/optimiser/FunctionHoister.h index 4807d7625..2a88e1acf 100644 --- a/libyul/optimiser/FunctionHoister.h +++ b/libyul/optimiser/FunctionHoister.h @@ -24,7 +24,7 @@ #include #include -namespace yul +namespace solidity::yul { struct OptimiserStepContext; diff --git a/libyul/optimiser/InlinableExpressionFunctionFinder.cpp b/libyul/optimiser/InlinableExpressionFunctionFinder.cpp index 33309009e..c9a1f084b 100644 --- a/libyul/optimiser/InlinableExpressionFunctionFinder.cpp +++ b/libyul/optimiser/InlinableExpressionFunctionFinder.cpp @@ -24,8 +24,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void InlinableExpressionFunctionFinder::operator()(Identifier const& _identifier) { diff --git a/libyul/optimiser/InlinableExpressionFunctionFinder.h b/libyul/optimiser/InlinableExpressionFunctionFinder.h index afde8a2a7..0583107d1 100644 --- a/libyul/optimiser/InlinableExpressionFunctionFinder.h +++ b/libyul/optimiser/InlinableExpressionFunctionFinder.h @@ -25,7 +25,7 @@ #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/KnowledgeBase.cpp b/libyul/optimiser/KnowledgeBase.cpp index fd8a7fabd..d71e1ec25 100644 --- a/libyul/optimiser/KnowledgeBase.cpp +++ b/libyul/optimiser/KnowledgeBase.cpp @@ -30,8 +30,8 @@ #include using namespace std; -using namespace yul; -using namespace dev; +using namespace solidity; +using namespace solidity::yul; bool KnowledgeBase::knownToBeDifferent(YulString _a, YulString _b) { @@ -39,11 +39,11 @@ bool KnowledgeBase::knownToBeDifferent(YulString _a, YulString _b) // current values to turn `sub(_a, _b)` into a nonzero constant. // If that fails, try `eq(_a, _b)`. - Expression expr1 = simplify(FunctionCall{{}, {{}, "sub"_yulstring}, make_vector(Identifier{{}, _a}, Identifier{{}, _b})}); + Expression expr1 = simplify(FunctionCall{{}, {{}, "sub"_yulstring}, util::make_vector(Identifier{{}, _a}, Identifier{{}, _b})}); if (holds_alternative(expr1)) return valueOfLiteral(std::get(expr1)) != 0; - Expression expr2 = simplify(FunctionCall{{}, {{}, "eq"_yulstring}, make_vector(Identifier{{}, _a}, Identifier{{}, _b})}); + Expression expr2 = simplify(FunctionCall{{}, {{}, "eq"_yulstring}, util::make_vector(Identifier{{}, _a}, Identifier{{}, _b})}); if (holds_alternative(expr2)) return valueOfLiteral(std::get(expr2)) == 0; @@ -55,7 +55,7 @@ bool KnowledgeBase::knownToBeDifferentByAtLeast32(YulString _a, YulString _b) // Try to use the simplification rules together with the // current values to turn `sub(_a, _b)` into a constant whose absolute value is at least 32. - Expression expr1 = simplify(FunctionCall{{}, {{}, "sub"_yulstring}, make_vector(Identifier{{}, _a}, Identifier{{}, _b})}); + Expression expr1 = simplify(FunctionCall{{}, {{}, "sub"_yulstring}, util::make_vector(Identifier{{}, _a}, Identifier{{}, _b})}); if (holds_alternative(expr1)) { u256 val = valueOfLiteral(std::get(expr1)); @@ -68,7 +68,7 @@ bool KnowledgeBase::knownToBeDifferentByAtLeast32(YulString _a, YulString _b) Expression KnowledgeBase::simplify(Expression _expression) { bool startedRecursion = (m_recursionCounter == 0); - dev::ScopeGuard{[&] { if (startedRecursion) m_recursionCounter = 0; }}; + ScopeGuard{[&] { if (startedRecursion) m_recursionCounter = 0; }}; if (startedRecursion) m_recursionCounter = 100; diff --git a/libyul/optimiser/KnowledgeBase.h b/libyul/optimiser/KnowledgeBase.h index 35e2d40ee..32cffa820 100644 --- a/libyul/optimiser/KnowledgeBase.h +++ b/libyul/optimiser/KnowledgeBase.h @@ -24,7 +24,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/LoadResolver.cpp b/libyul/optimiser/LoadResolver.cpp index 4176a08f0..4d40281ec 100644 --- a/libyul/optimiser/LoadResolver.cpp +++ b/libyul/optimiser/LoadResolver.cpp @@ -28,8 +28,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void LoadResolver::run(OptimiserStepContext& _context, Block& _ast) { @@ -59,7 +59,7 @@ void LoadResolver::visit(Expression& _e) void LoadResolver::tryResolve( Expression& _e, - dev::eth::Instruction _instruction, + evmasm::Instruction _instruction, vector const& _arguments ) { @@ -68,13 +68,13 @@ void LoadResolver::tryResolve( YulString key = std::get(_arguments.at(0)).name; if ( - _instruction == dev::eth::Instruction::SLOAD && + _instruction == evmasm::Instruction::SLOAD && m_storage.values.count(key) ) _e = Identifier{locationOf(_e), m_storage.values[key]}; else if ( m_optimizeMLoad && - _instruction == dev::eth::Instruction::MLOAD && + _instruction == evmasm::Instruction::MLOAD && m_memory.values.count(key) ) _e = Identifier{locationOf(_e), m_memory.values[key]}; diff --git a/libyul/optimiser/LoadResolver.h b/libyul/optimiser/LoadResolver.h index 52ac935dd..f2d11ed2a 100644 --- a/libyul/optimiser/LoadResolver.h +++ b/libyul/optimiser/LoadResolver.h @@ -25,7 +25,7 @@ #include #include -namespace yul +namespace solidity::yul { struct EVMDialect; @@ -62,7 +62,7 @@ protected: void tryResolve( Expression& _e, - dev::eth::Instruction _instruction, + evmasm::Instruction _instruction, std::vector const& _arguments ); diff --git a/libyul/optimiser/LoopInvariantCodeMotion.cpp b/libyul/optimiser/LoopInvariantCodeMotion.cpp index 00375a71d..ed176dc8b 100644 --- a/libyul/optimiser/LoopInvariantCodeMotion.cpp +++ b/libyul/optimiser/LoopInvariantCodeMotion.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void LoopInvariantCodeMotion::run(OptimiserStepContext& _context, Block& _ast) { @@ -41,7 +41,7 @@ void LoopInvariantCodeMotion::run(OptimiserStepContext& _context, Block& _ast) void LoopInvariantCodeMotion::operator()(Block& _block) { - iterateReplacing( + util::iterateReplacing( _block.statements, [&](Statement& _s) -> optional> { @@ -85,7 +85,7 @@ optional> LoopInvariantCodeMotion::rewriteLoop(ForLoop& _for) for (Block* block: {&_for.post, &_for.body}) { set varsDefinedInScope; - iterateReplacing( + util::iterateReplacing( block->statements, [&](Statement& _s) -> optional> { diff --git a/libyul/optimiser/LoopInvariantCodeMotion.h b/libyul/optimiser/LoopInvariantCodeMotion.h index f5f250515..7b7bd6c88 100644 --- a/libyul/optimiser/LoopInvariantCodeMotion.h +++ b/libyul/optimiser/LoopInvariantCodeMotion.h @@ -20,7 +20,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/MainFunction.cpp b/libyul/optimiser/MainFunction.cpp index 770e59259..ab58fb374 100644 --- a/libyul/optimiser/MainFunction.cpp +++ b/libyul/optimiser/MainFunction.cpp @@ -29,8 +29,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void MainFunction::operator()(Block& _block) { diff --git a/libyul/optimiser/MainFunction.h b/libyul/optimiser/MainFunction.h index 03e94a51f..771624bef 100644 --- a/libyul/optimiser/MainFunction.h +++ b/libyul/optimiser/MainFunction.h @@ -23,7 +23,7 @@ #include -namespace yul +namespace solidity::yul { struct OptimiserStepContext; diff --git a/libyul/optimiser/Metrics.cpp b/libyul/optimiser/Metrics.cpp index a8f0b2825..b470a7286 100644 --- a/libyul/optimiser/Metrics.cpp +++ b/libyul/optimiser/Metrics.cpp @@ -32,8 +32,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; size_t CodeSize::codeSize(Statement const& _statement) { @@ -152,12 +153,12 @@ void CodeCost::visit(Expression const& _expression) ASTWalker::visit(_expression); } -void CodeCost::addInstructionCost(eth::Instruction _instruction) +void CodeCost::addInstructionCost(evmasm::Instruction _instruction) { - dev::eth::Tier gasPriceTier = dev::eth::instructionInfo(_instruction).gasPriceTier; - if (gasPriceTier < dev::eth::Tier::VeryLow) + evmasm::Tier gasPriceTier = evmasm::instructionInfo(_instruction).gasPriceTier; + if (gasPriceTier < evmasm::Tier::VeryLow) m_cost -= 1; - else if (gasPriceTier < dev::eth::Tier::High) + else if (gasPriceTier < evmasm::Tier::High) m_cost += 1; else m_cost += 49; diff --git a/libyul/optimiser/Metrics.h b/libyul/optimiser/Metrics.h index 8ad1208b0..0b1087de2 100644 --- a/libyul/optimiser/Metrics.h +++ b/libyul/optimiser/Metrics.h @@ -23,7 +23,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; @@ -86,7 +86,7 @@ private: void visit(Expression const& _expression) override; private: - void addInstructionCost(dev::eth::Instruction _instruction); + void addInstructionCost(evmasm::Instruction _instruction); Dialect const& m_dialect; size_t m_cost = 0; diff --git a/libyul/optimiser/NameCollector.cpp b/libyul/optimiser/NameCollector.cpp index dab2f290a..33a5b624a 100644 --- a/libyul/optimiser/NameCollector.cpp +++ b/libyul/optimiser/NameCollector.cpp @@ -23,8 +23,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; void NameCollector::operator()(VariableDeclaration const& _varDecl) { diff --git a/libyul/optimiser/NameCollector.h b/libyul/optimiser/NameCollector.h index 46debdcba..97fbd27c6 100644 --- a/libyul/optimiser/NameCollector.h +++ b/libyul/optimiser/NameCollector.h @@ -25,7 +25,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp index f5bc1314a..fb1c1dd1c 100644 --- a/libyul/optimiser/NameDispenser.cpp +++ b/libyul/optimiser/NameDispenser.cpp @@ -29,8 +29,9 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; NameDispenser::NameDispenser(Dialect const& _dialect, Block const& _ast, set _reservedNames): NameDispenser(_dialect, NameCollector(_ast).names() + std::move(_reservedNames)) diff --git a/libyul/optimiser/NameDispenser.h b/libyul/optimiser/NameDispenser.h index db871f905..372e4bd2c 100644 --- a/libyul/optimiser/NameDispenser.h +++ b/libyul/optimiser/NameDispenser.h @@ -25,7 +25,7 @@ #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/NameDisplacer.cpp b/libyul/optimiser/NameDisplacer.cpp index 2c8db2b12..052b011ef 100644 --- a/libyul/optimiser/NameDisplacer.cpp +++ b/libyul/optimiser/NameDisplacer.cpp @@ -24,8 +24,8 @@ using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void NameDisplacer::operator()(Identifier& _identifier) { diff --git a/libyul/optimiser/NameDisplacer.h b/libyul/optimiser/NameDisplacer.h index da52071fc..ba61cbf9d 100644 --- a/libyul/optimiser/NameDisplacer.h +++ b/libyul/optimiser/NameDisplacer.h @@ -26,7 +26,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/OptimiserStep.h b/libyul/optimiser/OptimiserStep.h index 485a7b422..ebad29551 100644 --- a/libyul/optimiser/OptimiserStep.h +++ b/libyul/optimiser/OptimiserStep.h @@ -22,7 +22,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/OptimizerUtilities.cpp b/libyul/optimiser/OptimizerUtilities.cpp index 47c43a285..19d6e2406 100644 --- a/libyul/optimiser/OptimizerUtilities.cpp +++ b/libyul/optimiser/OptimizerUtilities.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::util; void yul::removeEmptyBlocks(Block& _block) { diff --git a/libyul/optimiser/OptimizerUtilities.h b/libyul/optimiser/OptimizerUtilities.h index 449a1bc02..153cd7b7e 100644 --- a/libyul/optimiser/OptimizerUtilities.h +++ b/libyul/optimiser/OptimizerUtilities.h @@ -23,7 +23,7 @@ #include #include -namespace yul +namespace solidity::yul { /// Removes statements that are just empty blocks (non-recursive). diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/RedundantAssignEliminator.cpp index 38c7881a0..faa040f31 100644 --- a/libyul/optimiser/RedundantAssignEliminator.cpp +++ b/libyul/optimiser/RedundantAssignEliminator.cpp @@ -29,8 +29,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void RedundantAssignEliminator::run(OptimiserStepContext& _context, Block& _ast) { diff --git a/libyul/optimiser/RedundantAssignEliminator.h b/libyul/optimiser/RedundantAssignEliminator.h index 7849708d6..3d61e84fb 100644 --- a/libyul/optimiser/RedundantAssignEliminator.h +++ b/libyul/optimiser/RedundantAssignEliminator.h @@ -28,7 +28,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/Rematerialiser.cpp b/libyul/optimiser/Rematerialiser.cpp index 1df07c52f..5d7350d97 100644 --- a/libyul/optimiser/Rematerialiser.cpp +++ b/libyul/optimiser/Rematerialiser.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void Rematerialiser::run(Dialect const& _dialect, Block& _ast, set _varsToAlwaysRematerialize) { diff --git a/libyul/optimiser/Rematerialiser.h b/libyul/optimiser/Rematerialiser.h index acf48d669..2d70e0b0d 100644 --- a/libyul/optimiser/Rematerialiser.h +++ b/libyul/optimiser/Rematerialiser.h @@ -23,7 +23,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/SSAReverser.cpp b/libyul/optimiser/SSAReverser.cpp index bca44097b..03593c2e9 100644 --- a/libyul/optimiser/SSAReverser.cpp +++ b/libyul/optimiser/SSAReverser.cpp @@ -22,8 +22,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void SSAReverser::run(OptimiserStepContext&, Block& _block) { @@ -35,7 +35,7 @@ void SSAReverser::run(OptimiserStepContext&, Block& _block) void SSAReverser::operator()(Block& _block) { walkVector(_block.statements); - iterateReplacingWindow<2>( + util::iterateReplacingWindow<2>( _block.statements, [&](Statement& _stmt1, Statement& _stmt2) -> std::optional> { @@ -61,9 +61,9 @@ void SSAReverser::operator()(Block& _block) { // in the special case a == a_1, just remove the assignment if (assignment->variableNames.front().name == identifier->name) - return make_vector(std::move(_stmt1)); + return util::make_vector(std::move(_stmt1)); else - return make_vector( + return util::make_vector( Assignment{ std::move(assignment->location), assignment->variableNames, @@ -99,7 +99,7 @@ void SSAReverser::operator()(Block& _block) varDecl2->variables.front().location, varDecl2->variables.front().name }); - return make_vector( + return util::make_vector( VariableDeclaration{ std::move(varDecl2->location), std::move(varDecl2->variables), diff --git a/libyul/optimiser/SSAReverser.h b/libyul/optimiser/SSAReverser.h index a0425a9ea..0a6e0e1b0 100644 --- a/libyul/optimiser/SSAReverser.h +++ b/libyul/optimiser/SSAReverser.h @@ -19,7 +19,7 @@ #include #include -namespace yul +namespace solidity::yul { class AssignmentCounter; diff --git a/libyul/optimiser/SSATransform.cpp b/libyul/optimiser/SSATransform.cpp index 0b464f043..fbd3cdd10 100644 --- a/libyul/optimiser/SSATransform.cpp +++ b/libyul/optimiser/SSATransform.cpp @@ -28,9 +28,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::langutil; namespace { @@ -56,7 +56,7 @@ private: void IntroduceSSA::operator()(Block& _block) { - iterateReplacing( + util::iterateReplacing( _block.statements, [&](Statement& _s) -> std::optional> { @@ -211,7 +211,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block) set variablesDeclaredHere; set assignedVariables; - iterateReplacing( + util::iterateReplacing( _block.statements, [&](Statement& _s) -> std::optional> { diff --git a/libyul/optimiser/SSATransform.h b/libyul/optimiser/SSATransform.h index 938a23151..aa6efb821 100644 --- a/libyul/optimiser/SSATransform.h +++ b/libyul/optimiser/SSATransform.h @@ -28,7 +28,7 @@ #include -namespace yul +namespace solidity::yul { class NameDispenser; diff --git a/libyul/optimiser/SSAValueTracker.cpp b/libyul/optimiser/SSAValueTracker.cpp index 3b599644c..ec898ad3c 100644 --- a/libyul/optimiser/SSAValueTracker.cpp +++ b/libyul/optimiser/SSAValueTracker.cpp @@ -24,8 +24,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void SSAValueTracker::operator()(Assignment const& _assignment) { diff --git a/libyul/optimiser/SSAValueTracker.h b/libyul/optimiser/SSAValueTracker.h index 7eac6b6a4..24f480947 100644 --- a/libyul/optimiser/SSAValueTracker.h +++ b/libyul/optimiser/SSAValueTracker.h @@ -27,7 +27,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/Semantics.cpp b/libyul/optimiser/Semantics.cpp index 7c0ad6865..8c6cab95f 100644 --- a/libyul/optimiser/Semantics.cpp +++ b/libyul/optimiser/Semantics.cpp @@ -31,8 +31,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; SideEffectsCollector::SideEffectsCollector( @@ -116,13 +116,13 @@ map SideEffectsPropagator::sideEffects( // TODO we could shortcut the search as soon as we find a // function that has as bad side-effects as we can // ever achieve via recursion. - auto search = [&](YulString const& _functionName, CycleDetector& _cycleDetector, size_t) { + auto search = [&](YulString const& _functionName, util::CycleDetector& _cycleDetector, size_t) { for (auto const& callee: _directCallGraph.functionCalls.at(_functionName)) if (!_dialect.builtin(callee)) if (_cycleDetector.run(callee)) return; }; - if (CycleDetector(search).run(call.first)) + if (util::CycleDetector(search).run(call.first)) { ret[call.first].movable = false; ret[call.first].sideEffectFree = false; @@ -134,7 +134,7 @@ map SideEffectsPropagator::sideEffects( { YulString funName = call.first; SideEffects sideEffects; - BreadthFirstSearch{call.second, {funName}}.run( + util::BreadthFirstSearch{call.second, {funName}}.run( [&](YulString _function, auto&& _addChild) { if (sideEffects == SideEffects::worst()) return; @@ -207,6 +207,6 @@ bool TerminationFinder::isTerminatingBuiltin(ExpressionStatement const& _exprStm if (auto const* dialect = dynamic_cast(&m_dialect)) if (auto const* builtin = dialect->builtin(std::get(_exprStmnt.expression).functionName.name)) if (builtin->instruction) - return eth::SemanticInformation::terminatesControlFlow(*builtin->instruction); + return evmasm::SemanticInformation::terminatesControlFlow(*builtin->instruction); return false; } diff --git a/libyul/optimiser/Semantics.h b/libyul/optimiser/Semantics.h index f9272654c..4efc83247 100644 --- a/libyul/optimiser/Semantics.h +++ b/libyul/optimiser/Semantics.h @@ -27,7 +27,7 @@ #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp index c04c6072e..5e0edb0a8 100644 --- a/libyul/optimiser/SimplificationRules.cpp +++ b/libyul/optimiser/SimplificationRules.cpp @@ -30,11 +30,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace langutil; -using namespace yul; - +using namespace solidity; +using namespace solidity::evmasm; +using namespace solidity::langutil; +using namespace solidity::yul; SimplificationRule const* SimplificationRules::findFirstMatch( Expression const& _expr, @@ -61,10 +60,10 @@ SimplificationRule const* SimplificationRules::findFirstMatch( bool SimplificationRules::isInitialized() const { - return !m_rules[uint8_t(dev::eth::Instruction::ADD)].empty(); + return !m_rules[uint8_t(evmasm::Instruction::ADD)].empty(); } -std::optional const*>> +std::optional const*>> SimplificationRules::instructionAndArguments(Dialect const& _dialect, Expression const& _expr) { if (holds_alternative(_expr)) @@ -111,7 +110,7 @@ SimplificationRules::SimplificationRules() assertThrow(isInitialized(), OptimizerException, "Rule list not properly initialized."); } -yul::Pattern::Pattern(dev::eth::Instruction _instruction, initializer_list _arguments): +yul::Pattern::Pattern(evmasm::Instruction _instruction, initializer_list _arguments): m_kind(PatternKind::Operation), m_instruction(_instruction), m_arguments(_arguments) @@ -203,7 +202,7 @@ bool Pattern::matches( return true; } -dev::eth::Instruction Pattern::instruction() const +evmasm::Instruction Pattern::instruction() const { assertThrow(m_kind == PatternKind::Operation, OptimizerException, ""); return m_instruction; @@ -216,7 +215,7 @@ Expression Pattern::toExpression(SourceLocation const& _location) const if (m_kind == PatternKind::Constant) { assertThrow(m_data, OptimizerException, "No match group and no constant value given."); - return Literal{_location, LiteralKind::Number, YulString{formatNumber(*m_data)}, {}}; + return Literal{_location, LiteralKind::Number, YulString{util::formatNumber(*m_data)}, {}}; } else if (m_kind == PatternKind::Operation) { diff --git a/libyul/optimiser/SimplificationRules.h b/libyul/optimiser/SimplificationRules.h index d07807d89..25443e129 100644 --- a/libyul/optimiser/SimplificationRules.h +++ b/libyul/optimiser/SimplificationRules.h @@ -33,7 +33,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; class Pattern; @@ -49,7 +49,7 @@ public: /// @returns a pointer to the first matching pattern and sets the match /// groups accordingly. /// @param _ssaValues values of variables that are assigned exactly once. - static dev::eth::SimplificationRule const* findFirstMatch( + static evmasm::SimplificationRule const* findFirstMatch( Expression const& _expr, Dialect const& _dialect, std::map const& _ssaValues @@ -59,17 +59,17 @@ public: /// by the constructor, but we had some issues with static initialization. bool isInitialized() const; - static std::optional const*>> + static std::optional const*>> instructionAndArguments(Dialect const& _dialect, Expression const& _expr); private: - void addRules(std::vector> const& _rules); - void addRule(dev::eth::SimplificationRule const& _rule); + void addRules(std::vector> const& _rules); + void addRule(evmasm::SimplificationRule const& _rule); void resetMatchGroups() { m_matchGroups.clear(); } std::map m_matchGroups; - std::vector> m_rules[256]; + std::vector> m_rules[256]; }; enum class PatternKind @@ -87,20 +87,20 @@ enum class PatternKind class Pattern { public: - using Builtins = dev::eth::EVMBuiltins; + using Builtins = evmasm::EVMBuiltins; static constexpr size_t WordSize = 256; - using Word = dev::u256; + using Word = u256; /// Matches any expression. Pattern(PatternKind _kind = PatternKind::Any): m_kind(_kind) {} // Matches a specific constant value. - Pattern(unsigned _value): Pattern(dev::u256(_value)) {} - Pattern(int _value): Pattern(dev::u256(_value)) {} - Pattern(long unsigned _value): Pattern(dev::u256(_value)) {} + Pattern(unsigned _value): Pattern(u256(_value)) {} + Pattern(int _value): Pattern(u256(_value)) {} + Pattern(long unsigned _value): Pattern(u256(_value)) {} // Matches a specific constant value. - Pattern(dev::u256 const& _value): m_kind(PatternKind::Constant), m_data(std::make_shared(_value)) {} + Pattern(u256 const& _value): m_kind(PatternKind::Constant), m_data(std::make_shared(_value)) {} // Matches a given instruction with given arguments - Pattern(dev::eth::Instruction _instruction, std::initializer_list _arguments = {}); + Pattern(evmasm::Instruction _instruction, std::initializer_list _arguments = {}); /// Sets this pattern to be part of the match group with the identifier @a _group. /// Inside one rule, all patterns in the same match group have to match expressions from the /// same expression equivalence class. @@ -115,9 +115,9 @@ public: std::vector arguments() const { return m_arguments; } /// @returns the data of the matched expression if this pattern is part of a match group. - dev::u256 d() const; + u256 d() const; - dev::eth::Instruction instruction() const; + evmasm::Instruction instruction() const; /// Turns this pattern into an actual expression. Should only be called /// for patterns resulting from an action, i.e. with match groups assigned. @@ -127,8 +127,8 @@ private: Expression const& matchGroupValue() const; PatternKind m_kind = PatternKind::Any; - dev::eth::Instruction m_instruction; ///< Only valid if m_kind is Operation - std::shared_ptr m_data; ///< Only valid if m_kind is Constant + evmasm::Instruction m_instruction; ///< Only valid if m_kind is Operation + std::shared_ptr m_data; ///< Only valid if m_kind is Constant std::vector m_arguments; unsigned m_matchGroup = 0; std::map* m_matchGroups = nullptr; diff --git a/libyul/optimiser/StackCompressor.cpp b/libyul/optimiser/StackCompressor.cpp index 611883b2e..0d72bc0db 100644 --- a/libyul/optimiser/StackCompressor.cpp +++ b/libyul/optimiser/StackCompressor.cpp @@ -33,8 +33,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; namespace { diff --git a/libyul/optimiser/StackCompressor.h b/libyul/optimiser/StackCompressor.h index 6504880c4..6c9f1ff9a 100644 --- a/libyul/optimiser/StackCompressor.h +++ b/libyul/optimiser/StackCompressor.h @@ -23,7 +23,7 @@ #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp index fb97e22a8..c4dcd6bee 100644 --- a/libyul/optimiser/StructuralSimplifier.cpp +++ b/libyul/optimiser/StructuralSimplifier.cpp @@ -25,8 +25,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; using OptionalStatements = std::optional>; @@ -52,7 +52,7 @@ OptionalStatements replaceConstArgSwitch(Switch& _switchStmt, u256 const& _const matchingCaseBlock = &defaultCase->body; if (matchingCaseBlock) - return make_vector(std::move(*matchingCaseBlock)); + return util::make_vector(std::move(*matchingCaseBlock)); else return optional>{vector{}}; } @@ -71,8 +71,8 @@ void StructuralSimplifier::operator()(Block& _block) void StructuralSimplifier::simplify(std::vector& _statements) { - GenericVisitor visitor{ - VisitorFallback{}, + util::GenericVisitor visitor{ + util::VisitorFallback{}, [&](If& _ifStmt) -> OptionalStatements { if (expressionAlwaysTrue(*_ifStmt.condition)) return {std::move(_ifStmt.body.statements)}; @@ -92,7 +92,7 @@ void StructuralSimplifier::simplify(std::vector& _statements) } }; - iterateReplacing( + util::iterateReplacing( _statements, [&](Statement& _stmt) -> OptionalStatements { @@ -122,7 +122,7 @@ bool StructuralSimplifier::expressionAlwaysFalse(Expression const& _expression) return false; } -std::optional StructuralSimplifier::hasLiteralValue(Expression const& _expression) const +std::optional StructuralSimplifier::hasLiteralValue(Expression const& _expression) const { if (holds_alternative(_expression)) return valueOfLiteral(std::get(_expression)); diff --git a/libyul/optimiser/StructuralSimplifier.h b/libyul/optimiser/StructuralSimplifier.h index aa1f38a90..ab17d1b1a 100644 --- a/libyul/optimiser/StructuralSimplifier.h +++ b/libyul/optimiser/StructuralSimplifier.h @@ -21,7 +21,7 @@ #include #include -namespace yul +namespace solidity::yul { /** @@ -51,7 +51,7 @@ private: void simplify(std::vector& _statements); bool expressionAlwaysTrue(Expression const& _expression); bool expressionAlwaysFalse(Expression const& _expression); - std::optional hasLiteralValue(Expression const& _expression) const; + std::optional hasLiteralValue(Expression const& _expression) const; }; } diff --git a/libyul/optimiser/Substitution.cpp b/libyul/optimiser/Substitution.cpp index 98d71d410..6a0dc4800 100644 --- a/libyul/optimiser/Substitution.cpp +++ b/libyul/optimiser/Substitution.cpp @@ -23,8 +23,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; Expression Substitution::translate(Expression const& _expression) { diff --git a/libyul/optimiser/Substitution.h b/libyul/optimiser/Substitution.h index 41f73b923..369754fea 100644 --- a/libyul/optimiser/Substitution.h +++ b/libyul/optimiser/Substitution.h @@ -25,7 +25,7 @@ #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index 33d9a507a..ba0ca07a9 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -67,8 +67,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void OptimiserSuite::run( Dialect const& _dialect, @@ -323,7 +323,7 @@ template map> optimiserStepCollection() { map> ret; - for (unique_ptr& s: make_vector>( + for (unique_ptr& s: util::make_vector>( (make_unique>())... )) { diff --git a/libyul/optimiser/Suite.h b/libyul/optimiser/Suite.h index 8dce75f9d..299a465fb 100644 --- a/libyul/optimiser/Suite.h +++ b/libyul/optimiser/Suite.h @@ -30,7 +30,7 @@ #include #include -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; diff --git a/libyul/optimiser/SyntacticalEquality.cpp b/libyul/optimiser/SyntacticalEquality.cpp index bcf59c234..3af7ccf01 100644 --- a/libyul/optimiser/SyntacticalEquality.cpp +++ b/libyul/optimiser/SyntacticalEquality.cpp @@ -27,8 +27,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; bool SyntacticallyEqual::operator()(Expression const& _lhs, Expression const& _rhs) { @@ -50,7 +50,7 @@ bool SyntacticallyEqual::expressionEqual(FunctionCall const& _lhs, FunctionCall { return expressionEqual(_lhs.functionName, _rhs.functionName) && - containerEqual(_lhs.arguments, _rhs.arguments, [this](Expression const& _lhsExpr, Expression const& _rhsExpr) -> bool { + util::containerEqual(_lhs.arguments, _rhs.arguments, [this](Expression const& _lhsExpr, Expression const& _rhsExpr) -> bool { return (*this)(_lhsExpr, _rhsExpr); }); } @@ -79,7 +79,7 @@ bool SyntacticallyEqual::statementEqual(ExpressionStatement const& _lhs, Express } bool SyntacticallyEqual::statementEqual(Assignment const& _lhs, Assignment const& _rhs) { - return containerEqual( + return util::containerEqual( _lhs.variableNames, _rhs.variableNames, [this](Identifier const& _lhsVarName, Identifier const& _rhsVarName) -> bool { @@ -93,7 +93,7 @@ bool SyntacticallyEqual::statementEqual(VariableDeclaration const& _lhs, Variabl // first visit expression, then variable declarations if (!compareUniquePtr(_lhs.value, _rhs.value)) return false; - return containerEqual(_lhs.variables, _rhs.variables, [this](TypedName const& _lhsVarName, TypedName const& _rhsVarName) -> bool { + return util::containerEqual(_lhs.variables, _rhs.variables, [this](TypedName const& _lhsVarName, TypedName const& _rhsVarName) -> bool { return this->visitDeclaration(_lhsVarName, _rhsVarName); }); } @@ -104,9 +104,9 @@ bool SyntacticallyEqual::statementEqual(FunctionDefinition const& _lhs, Function return this->visitDeclaration(_lhsVarName, _rhsVarName); }; // first visit parameter declarations, then body - if (!containerEqual(_lhs.parameters, _rhs.parameters, compare)) + if (!util::containerEqual(_lhs.parameters, _rhs.parameters, compare)) return false; - if (!containerEqual(_lhs.returnVariables, _rhs.returnVariables, compare)) + if (!util::containerEqual(_lhs.returnVariables, _rhs.returnVariables, compare)) return false; return statementEqual(_lhs.body, _rhs.body); } @@ -128,7 +128,7 @@ bool SyntacticallyEqual::statementEqual(Switch const& _lhs, Switch const& _rhs) rhsCases.insert(&rhsCase); return compareUniquePtr(_lhs.expression, _rhs.expression) && - containerEqual(lhsCases, rhsCases, [this](Case const* _lhsCase, Case const* _rhsCase) -> bool { + util::containerEqual(lhsCases, rhsCases, [this](Case const* _lhsCase, Case const* _rhsCase) -> bool { return this->switchCaseEqual(*_lhsCase, *_rhsCase); }); } @@ -152,7 +152,7 @@ bool SyntacticallyEqual::statementEqual(ForLoop const& _lhs, ForLoop const& _rhs bool SyntacticallyEqual::statementEqual(Block const& _lhs, Block const& _rhs) { - return containerEqual(_lhs.statements, _rhs.statements, [this](Statement const& _lhsStmt, Statement const& _rhsStmt) -> bool { + return util::containerEqual(_lhs.statements, _rhs.statements, [this](Statement const& _lhsStmt, Statement const& _rhsStmt) -> bool { return (*this)(_lhsStmt, _rhsStmt); }); } diff --git a/libyul/optimiser/SyntacticalEquality.h b/libyul/optimiser/SyntacticalEquality.h index f0a4fee1e..7cf5dc24a 100644 --- a/libyul/optimiser/SyntacticalEquality.h +++ b/libyul/optimiser/SyntacticalEquality.h @@ -26,7 +26,7 @@ #include #include -namespace yul +namespace solidity::yul { diff --git a/libyul/optimiser/UnusedPruner.cpp b/libyul/optimiser/UnusedPruner.cpp index e0d5a3dbe..b7925790a 100644 --- a/libyul/optimiser/UnusedPruner.cpp +++ b/libyul/optimiser/UnusedPruner.cpp @@ -32,8 +32,8 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; UnusedPruner::UnusedPruner( Dialect const& _dialect, diff --git a/libyul/optimiser/UnusedPruner.h b/libyul/optimiser/UnusedPruner.h index d0454243d..837088059 100644 --- a/libyul/optimiser/UnusedPruner.h +++ b/libyul/optimiser/UnusedPruner.h @@ -27,7 +27,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; struct SideEffects; diff --git a/libyul/optimiser/VarDeclInitializer.cpp b/libyul/optimiser/VarDeclInitializer.cpp index abedfe069..36fe07a91 100644 --- a/libyul/optimiser/VarDeclInitializer.cpp +++ b/libyul/optimiser/VarDeclInitializer.cpp @@ -22,16 +22,16 @@ #include using namespace std; -using namespace dev; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; void VarDeclInitializer::operator()(Block& _block) { ASTModifier::operator()(_block); using OptionalStatements = std::optional>; - GenericVisitor visitor{ - VisitorFallback{}, + util::GenericVisitor visitor{ + util::VisitorFallback{}, [](VariableDeclaration& _varDecl) -> OptionalStatements { if (_varDecl.value) @@ -53,5 +53,5 @@ void VarDeclInitializer::operator()(Block& _block) } }; - iterateReplacing(_block.statements, [&](auto&& _statement) { return std::visit(visitor, _statement); }); + util::iterateReplacing(_block.statements, [&](auto&& _statement) { return std::visit(visitor, _statement); }); } diff --git a/libyul/optimiser/VarDeclInitializer.h b/libyul/optimiser/VarDeclInitializer.h index ea3ca2988..556ce081b 100644 --- a/libyul/optimiser/VarDeclInitializer.h +++ b/libyul/optimiser/VarDeclInitializer.h @@ -21,7 +21,7 @@ #include #include -namespace yul +namespace solidity::yul { /** diff --git a/libyul/optimiser/VarNameCleaner.cpp b/libyul/optimiser/VarNameCleaner.cpp index edb60a82b..2d7cae6c6 100644 --- a/libyul/optimiser/VarNameCleaner.cpp +++ b/libyul/optimiser/VarNameCleaner.cpp @@ -27,8 +27,8 @@ #include #include -using namespace yul; using namespace std; +using namespace solidity::yul; VarNameCleaner::VarNameCleaner( Block const& _ast, diff --git a/libyul/optimiser/VarNameCleaner.h b/libyul/optimiser/VarNameCleaner.h index 246152deb..97ad27250 100644 --- a/libyul/optimiser/VarNameCleaner.h +++ b/libyul/optimiser/VarNameCleaner.h @@ -27,7 +27,7 @@ #include #include -namespace yul +namespace solidity::yul { struct Dialect; diff --git a/lllc/main.cpp b/lllc/main.cpp index 10b3cdff0..fab5c65ee 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -129,7 +129,7 @@ int main(int argc, char** argv) } else if (mode == Disassemble) { - cout << dev::eth::disassemble(fromHex(src)) << endl; + cout << evmasm::disassemble(fromHex(src)) << endl; } else if (mode == Binary || mode == Hex) { diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index ab6ef0840..e81efa1d4 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -72,12 +72,13 @@ #endif using namespace std; -using namespace langutil; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; + namespace po = boost::program_options; -namespace dev -{ -namespace solidity +namespace solidity::frontend { bool g_hasOutput = false; @@ -257,7 +258,7 @@ static void version() "solc, the solidity compiler commandline interface" << endl << "Version: " << - dev::solidity::VersionString << + solidity::frontend::VersionString << endl; exit(0); } @@ -321,11 +322,11 @@ void CommandLineInterface::handleBinary(string const& _contract) void CommandLineInterface::handleOpcode(string const& _contract) { if (m_args.count(g_argOutputDir)) - createFile(m_compiler->filesystemFriendlyName(_contract) + ".opcode", dev::eth::disassemble(m_compiler->object(_contract).bytecode)); + createFile(m_compiler->filesystemFriendlyName(_contract) + ".opcode", evmasm::disassemble(m_compiler->object(_contract).bytecode)); else { sout() << "Opcodes:" << endl; - sout() << std::uppercase << dev::eth::disassemble(m_compiler->object(_contract).bytecode); + sout() << std::uppercase << evmasm::disassemble(m_compiler->object(_contract).bytecode); sout() << endl; } } @@ -406,7 +407,7 @@ void CommandLineInterface::handleABI(string const& _contract) if (!m_args.count(g_argAbi)) return; - string data = dev::jsonCompactPrint(m_compiler->contractABI(_contract)); + string data = jsonCompactPrint(m_compiler->contractABI(_contract)); if (m_args.count(g_argOutputDir)) createFile(m_compiler->filesystemFriendlyName(_contract) + ".abi", data); else @@ -434,7 +435,7 @@ void CommandLineInterface::handleNatspec(bool _natspecDev, string const& _contra if (m_args.count(argName)) { - std::string output = dev::jsonPrettyPrint( + std::string output = jsonPrettyPrint( _natspecDev ? m_compiler->natspecDev(_contract) : m_compiler->natspecUser(_contract) @@ -543,13 +544,13 @@ bool CommandLineInterface::readInputFilesAndConfigureRemappings() continue; } - m_sourceCodes[infile.generic_string()] = dev::readFileAsString(infile.string()); + m_sourceCodes[infile.generic_string()] = readFileAsString(infile.string()); path = boost::filesystem::canonical(infile).string(); } m_allowedDirectories.push_back(boost::filesystem::path(path).remove_filename()); } if (addStdin) - m_sourceCodes[g_stdinFileName] = dev::readStandardInput(); + m_sourceCodes[g_stdinFileName] = readStandardInput(); if (m_sourceCodes.size() == 0) { serr() << "No input files given. If you wish to use the standard input please specify \"-\" explicitly." << endl; @@ -606,7 +607,7 @@ bool CommandLineInterface::parseLibraryOption(string const& _input) if (!passesAddressChecksum(addrString, false)) { serr() << "Invalid checksum on address for library \"" << libName << "\": " << addrString << endl; - serr() << "The correct checksum is " << dev::getChecksummedAddress(addrString) << endl; + serr() << "The correct checksum is " << getChecksummedAddress(addrString) << endl; return false; } bytes binAddr = fromHex(addrString); @@ -896,7 +897,7 @@ bool CommandLineInterface::processInput() if (!boost::filesystem::is_regular_file(canonicalPath)) return ReadCallback::Result{false, "Not a valid file."}; - auto contents = dev::readFileAsString(canonicalPath.string()); + auto contents = readFileAsString(canonicalPath.string()); m_sourceCodes[path.generic_string()] = contents; return ReadCallback::Result{true, contents}; } @@ -928,7 +929,7 @@ bool CommandLineInterface::processInput() if (m_args.count(g_argStandardJSON)) { - string input = dev::readStandardInput(); + string input = readStandardInput(); StandardCompiler compiler(fileReader); sout() << compiler.compile(std::move(input)) << endl; return true; @@ -1159,7 +1160,7 @@ void CommandLineInterface::handleCombinedJSON() Json::Value output(Json::objectValue); - output[g_strVersion] = ::dev::solidity::VersionString; + output[g_strVersion] = frontend::VersionString; set requests; boost::split(requests, m_args[g_argCombinedJson].as(), boost::is_any_of(",")); vector contracts = m_compiler->contractNames(); @@ -1170,7 +1171,7 @@ void CommandLineInterface::handleCombinedJSON() { Json::Value& contractData = output[g_strContracts][contractName] = Json::objectValue; if (requests.count(g_strAbi)) - contractData[g_strAbi] = dev::jsonCompactPrint(m_compiler->contractABI(contractName)); + contractData[g_strAbi] = jsonCompactPrint(m_compiler->contractABI(contractName)); if (requests.count("metadata")) contractData["metadata"] = m_compiler->metadata(contractName); if (requests.count(g_strBinary) && m_compiler->compilationSuccessful()) @@ -1178,7 +1179,7 @@ void CommandLineInterface::handleCombinedJSON() if (requests.count(g_strBinaryRuntime) && m_compiler->compilationSuccessful()) contractData[g_strBinaryRuntime] = m_compiler->runtimeObject(contractName).toHex(); if (requests.count(g_strOpcodes) && m_compiler->compilationSuccessful()) - contractData[g_strOpcodes] = dev::eth::disassemble(m_compiler->object(contractName).bytecode); + contractData[g_strOpcodes] = evmasm::disassemble(m_compiler->object(contractName).bytecode); if (requests.count(g_strAsm) && m_compiler->compilationSuccessful()) contractData[g_strAsm] = m_compiler->assemblyJSON(contractName, m_sourceCodes); if (requests.count(g_strSrcMap) && m_compiler->compilationSuccessful()) @@ -1194,9 +1195,9 @@ void CommandLineInterface::handleCombinedJSON() if (requests.count(g_strSignatureHashes)) contractData[g_strSignatureHashes] = m_compiler->methodIdentifiers(contractName); if (requests.count(g_strNatspecDev)) - contractData[g_strNatspecDev] = dev::jsonCompactPrint(m_compiler->natspecDev(contractName)); + contractData[g_strNatspecDev] = jsonCompactPrint(m_compiler->natspecDev(contractName)); if (requests.count(g_strNatspecUser)) - contractData[g_strNatspecUser] = dev::jsonCompactPrint(m_compiler->natspecUser(contractName)); + contractData[g_strNatspecUser] = jsonCompactPrint(m_compiler->natspecUser(contractName)); } bool needsSourceList = requests.count(g_strAst) || requests.count(g_strSrcMap) || requests.count(g_strSrcMapRuntime); @@ -1221,7 +1222,7 @@ void CommandLineInterface::handleCombinedJSON() } } - string json = m_args.count(g_argPrettyJson) ? dev::jsonPrettyPrint(output) : dev::jsonCompactPrint(output); + string json = m_args.count(g_argPrettyJson) ? jsonPrettyPrint(output) : jsonCompactPrint(output); if (m_args.count(g_argOutputDir)) createJson("combined", json); @@ -1246,7 +1247,7 @@ void CommandLineInterface::handleAst(string const& _argStr) vector asts; for (auto const& sourceCode: m_sourceCodes) asts.push_back(&m_compiler->ast(sourceCode.first)); - map gasCosts; + map gasCosts; for (auto const& contract: m_compiler->contractNames()) if (m_compiler->compilationSuccessful()) if (auto const* assemblyItems = m_compiler->runtimeAssemblyItems(contract)) @@ -1309,7 +1310,7 @@ bool CommandLineInterface::link() // be just the cropped or '_'-padded library name, but this changed to // the cropped hex representation of the hash of the library name. // We support both ways of linking here. - librariesReplacements["__" + eth::LinkerObject::libraryPlaceholder(name) + "__"] = library.second; + librariesReplacements["__" + evmasm::LinkerObject::libraryPlaceholder(name) + "__"] = library.second; string replacement = "__"; for (size_t i = 0; i < placeholderSize - 4; ++i) @@ -1369,10 +1370,10 @@ void CommandLineInterface::writeLinkedFiles() string CommandLineInterface::libraryPlaceholderHint(string const& _libraryName) { - return "// " + eth::LinkerObject::libraryPlaceholder(_libraryName) + " -> " + _libraryName; + return "// " + evmasm::LinkerObject::libraryPlaceholder(_libraryName) + " -> " + _libraryName; } -string CommandLineInterface::objectWithLinkRefsHex(eth::LinkerObject const& _obj) +string CommandLineInterface::objectWithLinkRefsHex(evmasm::LinkerObject const& _obj) { string out = _obj.toHex(); if (!_obj.linkReferences.empty()) @@ -1534,7 +1535,7 @@ void CommandLineInterface::outputCompilationResults() { string ret; if (m_args.count(g_argAsmJson)) - ret = dev::jsonPrettyPrint(m_compiler->assemblyJSON(contract, m_sourceCodes)); + ret = jsonPrettyPrint(m_compiler->assemblyJSON(contract, m_sourceCodes)); else ret = m_compiler->assemblyString(contract, m_sourceCodes); @@ -1571,4 +1572,3 @@ void CommandLineInterface::outputCompilationResults() } } -} diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index 02fda0383..fd19fd8a7 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -31,9 +31,7 @@ #include -namespace dev -{ -namespace solidity +namespace solidity::frontend { //forward declaration @@ -56,7 +54,7 @@ private: /// @returns the ``// -> name`` hint for library placeholders. static std::string libraryPlaceholderHint(std::string const& _libraryName); /// @returns the full object with library placeholder hints in hex. - static std::string objectWithLinkRefsHex(eth::LinkerObject const& _obj); + static std::string objectWithLinkRefsHex(evmasm::LinkerObject const& _obj); bool assemble(yul::AssemblyStack::Language _language, yul::AssemblyStack::Machine _targetMachine, bool _optimize); @@ -103,13 +101,13 @@ private: /// map of input files to source code strings std::map m_sourceCodes; /// list of remappings - std::vector m_remappings; + std::vector m_remappings; /// list of allowed directories to read files from std::vector m_allowedDirectories; /// map of library names to addresses - std::map m_libraries; + std::map m_libraries; /// Solidity compiler stack - std::unique_ptr m_compiler; + std::unique_ptr m_compiler; /// EVM version to use langutil::EVMVersion m_evmVersion; /// How to handle revert strings @@ -121,4 +119,3 @@ private: }; } -} diff --git a/solc/main.cpp b/solc/main.cpp index f4a4c5d24..5307e40ad 100644 --- a/solc/main.cpp +++ b/solc/main.cpp @@ -53,7 +53,7 @@ static void setDefaultOrCLocale() int main(int argc, char** argv) { setDefaultOrCLocale(); - dev::solidity::CommandLineInterface cli; + solidity::frontend::CommandLineInterface cli; if (!cli.parseArguments(argc, argv)) return 1; if (!cli.processInput()) diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 9ea472eae..bb9164eea 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -148,9 +148,9 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept evmc_message message = _message; if (message.depth == 0) { - message.gas -= message.kind == EVMC_CREATE ? eth::GasCosts::txCreateGas : eth::GasCosts::txGas; + message.gas -= message.kind == EVMC_CREATE ? evmasm::GasCosts::txCreateGas : evmasm::GasCosts::txGas; for (size_t i = 0; i < message.input_size; ++i) - message.gas -= message.input_data[i] == 0 ? eth::GasCosts::txDataZeroGas : eth::GasCosts::txDataNonZeroGas(m_evmVersion); + message.gas -= message.input_data[i] == 0 ? evmasm::GasCosts::txDataZeroGas : evmasm::GasCosts::txDataNonZeroGas(m_evmVersion); if (message.gas < 0) { evmc::result result({}); @@ -200,7 +200,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept if (message.kind == EVMC_CREATE) { - result.gas_left -= eth::GasCosts::createDataGas * result.output_size; + result.gas_left -= evmasm::GasCosts::createDataGas * result.output_size; if (result.gas_left < 0) { result.gas_left = 0; diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index 4e9040b9d..756f7f2f1 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -42,7 +42,7 @@ namespace test namespace { - void checkCompilation(::dev::eth::Assembly const& _assembly) + void checkCompilation(::evmasm::Assembly const& _assembly) { LinkerObject output = _assembly.assemble(); BOOST_CHECK(output.bytecode.size() > 0); diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 869e91c83..0d550e072 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -57,20 +57,20 @@ namespace return input; } - eth::KnownState createInitialState(AssemblyItems const& _input) + evmasm::KnownState createInitialState(AssemblyItems const& _input) { - eth::KnownState state; + evmasm::KnownState state; for (auto const& item: addDummyLocations(_input)) state.feedItem(item, true); return state; } - AssemblyItems CSE(AssemblyItems const& _input, eth::KnownState const& _state = eth::KnownState()) + AssemblyItems CSE(AssemblyItems const& _input, evmasm::KnownState const& _state = evmasm::KnownState()) { AssemblyItems input = addDummyLocations(_input); bool usesMsize = (find(_input.begin(), _input.end(), AssemblyItem{Instruction::MSIZE}) != _input.end()); - eth::CommonSubexpressionEliminator cse(_state); + evmasm::CommonSubexpressionEliminator cse(_state); BOOST_REQUIRE(cse.feedItems(input.begin(), input.end(), usesMsize) == input.end()); AssemblyItems output = cse.getOptimizedItems(); @@ -84,7 +84,7 @@ namespace void checkCSE( AssemblyItems const& _input, AssemblyItems const& _expectation, - KnownState const& _state = eth::KnownState() + KnownState const& _state = evmasm::KnownState() ) { AssemblyItems output = CSE(_input, _state); @@ -118,8 +118,8 @@ BOOST_AUTO_TEST_SUITE(Optimiser) BOOST_AUTO_TEST_CASE(cse_intermediate_swap) { - eth::KnownState state; - eth::CommonSubexpressionEliminator cse(state); + evmasm::KnownState state; + evmasm::CommonSubexpressionEliminator cse(state); AssemblyItems input{ Instruction::SWAP1, Instruction::POP, Instruction::ADD, u256(0), Instruction::SWAP1, Instruction::SLOAD, Instruction::SWAP1, u256(100), Instruction::EXP, Instruction::SWAP1, @@ -651,7 +651,7 @@ BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_content_noninterfering_store_in_be BOOST_AUTO_TEST_CASE(cse_with_initially_known_stack) { - eth::KnownState state = createInitialState(AssemblyItems{ + evmasm::KnownState state = createInitialState(AssemblyItems{ u256(0x12), u256(0x20), Instruction::ADD @@ -664,7 +664,7 @@ BOOST_AUTO_TEST_CASE(cse_with_initially_known_stack) BOOST_AUTO_TEST_CASE(cse_equality_on_initially_known_stack) { - eth::KnownState state = createInitialState(AssemblyItems{Instruction::DUP1}); + evmasm::KnownState state = createInitialState(AssemblyItems{Instruction::DUP1}); AssemblyItems input{ Instruction::EQ }; @@ -677,7 +677,7 @@ BOOST_AUTO_TEST_CASE(cse_access_previous_sequence) { // Tests that the code generator detects whether it tries to access SLOAD instructions // from a sequenced expression which is not in its scope. - eth::KnownState state = createInitialState(AssemblyItems{ + evmasm::KnownState state = createInitialState(AssemblyItems{ u256(0), Instruction::SLOAD, u256(1), diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index bbad3718a..9323b0579 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -53,7 +53,7 @@ namespace test namespace { -eth::AssemblyItems compileContract(std::shared_ptr _sourceCode) +evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) { ErrorList errors; ErrorReporter errorReporter(errors); diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index d30a10f53..c5a066930 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -122,7 +122,7 @@ public: } protected: - map m_gasCosts; + map m_gasCosts; }; BOOST_FIXTURE_TEST_SUITE(GasMeterTests, GasMeterTestFramework) diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index eea3978f9..237692124 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -59,7 +59,7 @@ bytes SolidityExecutionFramework::compileContract( formatter.printErrorInformation(*error); BOOST_ERROR("Compiling contract failed"); } - eth::LinkerObject obj; + evmasm::LinkerObject obj; if (m_compileViaYul) { yul::AssemblyStack asmStack( diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index a0d860c61..00082c279 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -164,7 +164,7 @@ bytes compileFirstExpression( )); bytes instructions = context.assembledObject().bytecode; // debug - // cout << eth::disassemble(instructions) << endl; + // cout << evmasm::disassemble(instructions) << endl; return instructions; } BOOST_FAIL("No contract found in source."); diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 43ff9472e..fe7537936 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -109,7 +109,7 @@ public: bytes realCode = bytecodeSansMetadata(_bytecode); BOOST_REQUIRE_MESSAGE(!realCode.empty(), "Invalid or missing metadata in bytecode."); size_t instructions = 0; - dev::eth::eachInstruction(realCode, [&](Instruction _instr, u256 const&) { + evmasm::eachInstruction(realCode, [&](Instruction _instr, u256 const&) { if (!_which || *_which == _instr) instructions++; }); diff --git a/test/libyul/ObjectCompilerTest.cpp b/test/libyul/ObjectCompilerTest.cpp index 9773dedab..57ea5b9fb 100644 --- a/test/libyul/ObjectCompilerTest.cpp +++ b/test/libyul/ObjectCompilerTest.cpp @@ -82,7 +82,7 @@ TestCase::TestResult ObjectCompilerTest::run(ostream& _stream, string const& _li "Bytecode: " + toHex(obj.bytecode->bytecode) + "\nOpcodes: " + - boost::trim_copy(dev::eth::disassemble(obj.bytecode->bytecode)) + + boost::trim_copy(evmasm::disassemble(obj.bytecode->bytecode)) + "\n"; if (m_expectation != m_obtainedResult) diff --git a/test/libyul/StackReuseCodegen.cpp b/test/libyul/StackReuseCodegen.cpp index bb97a5c40..074096f01 100644 --- a/test/libyul/StackReuseCodegen.cpp +++ b/test/libyul/StackReuseCodegen.cpp @@ -39,7 +39,7 @@ string assemble(string const& _input) settings.optimizeStackAllocation = true; AssemblyStack asmStack(langutil::EVMVersion{}, AssemblyStack::Language::StrictAssembly, settings); BOOST_REQUIRE_MESSAGE(asmStack.parseAndAnalyze("", _input), "Source did not parse: " + _input); - return dev::eth::disassemble(asmStack.assemble(AssemblyStack::Machine::EVM).bytecode->bytecode); + return evmasm::disassemble(asmStack.assemble(AssemblyStack::Machine::EVM).bytecode->bytecode); } } diff --git a/test/tools/ossfuzz/abiV2FuzzerCommon.cpp b/test/tools/ossfuzz/abiV2FuzzerCommon.cpp index 45947ddc0..79aa08ba4 100644 --- a/test/tools/ossfuzz/abiV2FuzzerCommon.cpp +++ b/test/tools/ossfuzz/abiV2FuzzerCommon.cpp @@ -27,7 +27,7 @@ dev::bytes SolidityCompilationFramework::compileContract( ); std::cerr << "Compiling contract failed" << std::endl; } - dev::eth::LinkerObject obj = m_compiler.object( + evmasm::LinkerObject obj = m_compiler.object( _contractName.empty() ? m_compiler.lastContractName() : _contractName diff --git a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp index 07e062b8f..f6e65877d 100644 --- a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp +++ b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp @@ -124,7 +124,7 @@ DEFINE_PROTO_FUZZER(Contract const& _input) hexEncodedInput = methodIdentifiers["test()"].asString(); } // Ignore stack too deep errors during compilation - catch (eth::StackTooDeepException const&) + catch (evmasm::StackTooDeepException const&) { return; } diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index d6011d8c7..d285157ca 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -77,12 +77,12 @@ void copyZeroExtended( using u512 = boost::multiprecision::number>; u256 EVMInstructionInterpreter::eval( - dev::eth::Instruction _instruction, + evmasm::Instruction _instruction, vector const& _arguments ) { using namespace dev::eth; - using dev::eth::Instruction; + using evmasm::Instruction; auto info = instructionInfo(_instruction); yulAssert(size_t(info.args) == _arguments.size(), ""); @@ -484,9 +484,9 @@ void EVMInstructionInterpreter::writeMemoryWord(u256 const& _offset, u256 const& } -void EVMInstructionInterpreter::logTrace(dev::eth::Instruction _instruction, std::vector const& _arguments, bytes const& _data) +void EVMInstructionInterpreter::logTrace(evmasm::Instruction _instruction, std::vector const& _arguments, bytes const& _data) { - logTrace(dev::eth::instructionInfo(_instruction).name, _arguments, _data); + logTrace(evmasm::instructionInfo(_instruction).name, _arguments, _data); } void EVMInstructionInterpreter::logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments, bytes const& _data) diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.h b/test/tools/yulInterpreter/EVMInstructionInterpreter.h index b2545e9fa..2e9d2cc7a 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.h +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.h @@ -26,13 +26,10 @@ #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { enum class Instruction: uint8_t; } -} namespace yul { @@ -70,7 +67,7 @@ public: m_state(_state) {} /// Evaluate instruction - dev::u256 eval(dev::eth::Instruction _instruction, std::vector const& _arguments); + dev::u256 eval(evmasm::Instruction _instruction, std::vector const& _arguments); /// Evaluate builtin function dev::u256 evalBuiltin(BuiltinFunctionForEVM const& _fun, std::vector const& _arguments); @@ -89,7 +86,7 @@ private: /// Does not adjust msize, use @a accessMemory for that void writeMemoryWord(dev::u256 const& _offset, dev::u256 const& _value); - void logTrace(dev::eth::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); + void logTrace(evmasm::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); /// Appends a log to the trace representing an instruction or similar operation by string, /// with arguments and auxiliary data (if nonempty). void logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index 1f1ed9e60..d98ca6a56 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -95,7 +95,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a return {}; else if (_fun == "unreachable"_yulstring) { - logTrace(eth::Instruction::INVALID, {}); + logTrace(evmasm::Instruction::INVALID, {}); throw ExplicitlyTerminated(); } else if (_fun == "i64.add"_yulstring) @@ -188,7 +188,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a { // TODO read args from memory // TODO use readAddress to read address. - logTrace(eth::Instruction::CALL, {}); + logTrace(evmasm::Instruction::CALL, {}); return arg[0] & 1; } else if (_fun == "eth.callDataCopy"_yulstring) @@ -208,21 +208,21 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a { // TODO read args from memory // TODO use readAddress to read address. - logTrace(eth::Instruction::CALLCODE, {}); + logTrace(evmasm::Instruction::CALLCODE, {}); return arg[0] & 1; } else if (_fun == "eth.callDelegate"_yulstring) { // TODO read args from memory // TODO use readAddress to read address. - logTrace(eth::Instruction::DELEGATECALL, {}); + logTrace(evmasm::Instruction::DELEGATECALL, {}); return arg[0] & 1; } else if (_fun == "eth.callStatic"_yulstring) { // TODO read args from memory // TODO use readAddress to read address. - logTrace(eth::Instruction::STATICCALL, {}); + logTrace(evmasm::Instruction::STATICCALL, {}); return arg[0] & 1; } else if (_fun == "eth.storageStore"_yulstring) @@ -266,7 +266,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a { // TODO access memory // TODO use writeAddress to store resulting address - logTrace(eth::Instruction::CREATE, {}); + logTrace(evmasm::Instruction::CREATE, {}); return 0xcccccc + arg[1]; } else if (_fun == "eth.getBlockDifficulty"_yulstring) @@ -302,7 +302,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a uint64_t numberOfTopics = arg[2]; if (numberOfTopics > 4) throw ExplicitlyTerminated(); - logTrace(eth::logInstruction(numberOfTopics), {}); + logTrace(evmasm::logInstruction(numberOfTopics), {}); return 0; } else if (_fun == "eth.getBlockNumber"_yulstring) @@ -317,7 +317,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a bytes data; if (accessMemory(arg[0], arg[1])) data = readMemory(arg[0], arg[1]); - logTrace(eth::Instruction::RETURN, {}, data); + logTrace(evmasm::Instruction::RETURN, {}, data); throw ExplicitlyTerminated(); } else if (_fun == "eth.revert"_yulstring) @@ -325,7 +325,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a bytes data; if (accessMemory(arg[0], arg[1])) data = readMemory(arg[0], arg[1]); - logTrace(eth::Instruction::REVERT, {}, data); + logTrace(evmasm::Instruction::REVERT, {}, data); throw ExplicitlyTerminated(); } else if (_fun == "eth.getReturnDataSize"_yulstring) @@ -344,7 +344,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(YulString _fun, vector const& _a else if (_fun == "eth.selfDestruct"_yulstring) { // TODO use readAddress to read address. - logTrace(eth::Instruction::SELFDESTRUCT, {}); + logTrace(evmasm::Instruction::SELFDESTRUCT, {}); throw ExplicitlyTerminated(); } else if (_fun == "eth.getBlockTimestamp"_yulstring) @@ -417,9 +417,9 @@ u256 EwasmBuiltinInterpreter::readU256(uint64_t _offset, size_t _croppedTo) return value; } -void EwasmBuiltinInterpreter::logTrace(dev::eth::Instruction _instruction, std::vector const& _arguments, bytes const& _data) +void EwasmBuiltinInterpreter::logTrace(evmasm::Instruction _instruction, std::vector const& _arguments, bytes const& _data) { - logTrace(dev::eth::instructionInfo(_instruction).name, _arguments, _data); + logTrace(evmasm::instructionInfo(_instruction).name, _arguments, _data); } void EwasmBuiltinInterpreter::logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments, bytes const& _data) diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h index a9c733f8e..891aa65d5 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h @@ -99,7 +99,7 @@ private: dev::u256 readU128(uint64_t _offset) { return readU256(_offset, 16); } dev::u256 readAddress(uint64_t _offset) { return readU256(_offset, 20); } - void logTrace(dev::eth::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); + void logTrace(evmasm::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); /// Appends a log to the trace representing an instruction or similar operation by string, /// with arguments and auxiliary data (if nonempty). void logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); From ed45b000d186c94a066f734bbf22d9fcc4a19768 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 23 Dec 2019 16:50:30 +0100 Subject: [PATCH 32/57] Adapt tests directory to C++ namespace changes. --- test/Common.cpp | 8 +- test/Common.h | 8 +- test/EVMHost.cpp | 5 +- test/EVMHost.h | 11 +- test/ExecutionFramework.cpp | 19 +- test/ExecutionFramework.h | 33 ++- test/InteractiveTests.h | 8 +- test/Metadata.cpp | 11 +- test/Metadata.h | 5 +- test/Options.cpp | 2 +- test/Options.h | 5 +- test/TestCase.cpp | 8 +- test/TestCase.h | 9 +- test/boostTest.cpp | 19 +- test/cmdlineTests/yul_stack_opt_disabled/err | 2 +- test/contracts/AuctionRegistrar.cpp | 12 +- test/contracts/ContractInterface.h | 17 +- test/contracts/FixedFeeRegistrar.cpp | 12 +- test/contracts/Wallet.cpp | 15 +- test/libdevcore/Checksum.cpp | 5 +- test/libdevcore/CommonData.cpp | 9 +- test/libdevcore/IndentedWriter.cpp | 5 +- test/libdevcore/IpfsHash.cpp | 5 +- test/libdevcore/IterateReplacing.cpp | 5 +- test/libdevcore/JSON.cpp | 5 +- test/libdevcore/Keccak256.cpp | 5 +- test/libdevcore/StringUtils.cpp | 9 +- test/libdevcore/SwarmHash.cpp | 5 +- test/libdevcore/UTF8.cpp | 5 +- test/libdevcore/Whiskers.cpp | 5 +- test/libevmasm/Assembler.cpp | 16 +- test/libevmasm/Optimiser.cpp | 26 +-- test/liblangutil/CharStream.cpp | 7 +- test/liblangutil/SourceLocation.cpp | 5 +- test/liblll/Compiler.cpp | 15 +- test/liblll/EndToEndTest.cpp | 24 +-- test/liblll/ExecutionFramework.cpp | 2 +- test/liblll/ExecutionFramework.h | 17 +- test/liblll/LLL_ENS.cpp | 4 +- test/liblll/LLL_ERC20.cpp | 4 +- test/libsolidity/ABIDecoderTests.cpp | 18 +- test/libsolidity/ABIEncoderTests.cpp | 19 +- test/libsolidity/ABIJsonTest.cpp | 11 +- test/libsolidity/ABIJsonTest.h | 8 +- test/libsolidity/ABITestsCommon.h | 8 +- test/libsolidity/ASTJSONTest.cpp | 13 +- test/libsolidity/ASTJSONTest.h | 8 +- test/libsolidity/AnalysisFramework.cpp | 13 +- test/libsolidity/AnalysisFramework.h | 20 +- test/libsolidity/Assembly.cpp | 27 +-- test/libsolidity/ErrorCheck.cpp | 10 +- test/libsolidity/ErrorCheck.h | 8 +- test/libsolidity/GasCosts.cpp | 21 +- test/libsolidity/GasMeter.cpp | 36 ++-- test/libsolidity/GasTest.cpp | 8 +- test/libsolidity/GasTest.h | 8 +- test/libsolidity/Imports.cpp | 18 +- test/libsolidity/InlineAssembly.cpp | 32 ++- test/libsolidity/LibSolc.cpp | 10 +- test/libsolidity/Metadata.cpp | 68 +++--- test/libsolidity/SMTChecker.cpp | 14 +- test/libsolidity/SMTCheckerJSONTest.cpp | 9 +- test/libsolidity/SMTCheckerJSONTest.h | 8 +- test/libsolidity/SMTCheckerTest.cpp | 8 +- test/libsolidity/SMTCheckerTest.h | 8 +- test/libsolidity/SemVerMatcher.cpp | 10 +- test/libsolidity/SemanticTest.cpp | 12 +- test/libsolidity/SemanticTest.h | 10 +- test/libsolidity/SolidityCompiler.cpp | 14 +- test/libsolidity/SolidityEndToEndTest.cpp | 202 +++++++++--------- .../SolidityExecutionFramework.cpp | 10 +- test/libsolidity/SolidityExecutionFramework.h | 17 +- .../SolidityExpressionCompiler.cpp | 32 ++- .../SolidityNameAndTypeResolution.cpp | 28 +-- test/libsolidity/SolidityNatspecJSON.cpp | 16 +- test/libsolidity/SolidityOptimizer.cpp | 13 +- test/libsolidity/SolidityParser.cpp | 12 +- test/libsolidity/SolidityScanner.cpp | 10 +- test/libsolidity/SolidityTypes.cpp | 12 +- test/libsolidity/StandardCompiler.cpp | 78 ++++--- test/libsolidity/SyntaxTest.cpp | 13 +- test/libsolidity/SyntaxTest.h | 10 +- test/libsolidity/ViewPureChecker.cpp | 16 +- test/libsolidity/util/BytesUtils.cpp | 13 +- test/libsolidity/util/BytesUtils.h | 8 +- test/libsolidity/util/ContractABIUtils.cpp | 26 +-- test/libsolidity/util/ContractABIUtils.h | 8 +- test/libsolidity/util/SoltestErrors.h | 16 +- test/libsolidity/util/SoltestTypes.h | 8 +- test/libsolidity/util/TestFileParser.cpp | 8 +- test/libsolidity/util/TestFileParser.h | 8 +- test/libsolidity/util/TestFileParserTests.cpp | 11 +- test/libsolidity/util/TestFunctionCall.cpp | 16 +- test/libsolidity/util/TestFunctionCall.h | 8 +- .../util/TestFunctionCallTests.cpp | 11 +- test/libyul/Common.cpp | 15 +- test/libyul/Common.h | 9 +- test/libyul/CompilabilityChecker.cpp | 7 +- test/libyul/EwasmTranslationTest.cpp | 19 +- test/libyul/EwasmTranslationTest.h | 9 +- test/libyul/FunctionSideEffects.cpp | 13 +- test/libyul/FunctionSideEffects.h | 7 +- test/libyul/Inliner.cpp | 7 +- test/libyul/Metrics.cpp | 7 +- test/libyul/ObjectCompilerTest.cpp | 13 +- test/libyul/ObjectCompilerTest.h | 11 +- test/libyul/ObjectParser.cpp | 18 +- test/libyul/Parser.cpp | 12 +- test/libyul/StackReuseCodegen.cpp | 7 +- test/libyul/YulInterpreterTest.cpp | 17 +- test/libyul/YulInterpreterTest.h | 11 +- test/libyul/YulOptimizerTest.cpp | 21 +- test/libyul/YulOptimizerTest.h | 11 +- test/tools/IsolTestOptions.cpp | 5 +- test/tools/IsolTestOptions.h | 6 +- test/tools/afl_fuzzer.cpp | 3 +- test/tools/fuzzer_common.cpp | 5 +- test/tools/isoltest.cpp | 22 +- test/tools/ossfuzz/abiV2FuzzerCommon.cpp | 4 +- test/tools/ossfuzz/abiV2FuzzerCommon.h | 16 +- test/tools/ossfuzz/abiV2Proto.proto | 2 +- test/tools/ossfuzz/abiV2ProtoFuzzer.cpp | 17 +- test/tools/ossfuzz/protoToAbiV2.cpp | 5 +- test/tools/ossfuzz/protoToAbiV2.h | 14 +- test/tools/ossfuzz/protoToYul.cpp | 10 +- test/tools/ossfuzz/protoToYul.h | 14 +- .../ossfuzz/strictasm_assembly_ossfuzz.cpp | 5 +- test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp | 12 +- test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp | 6 +- test/tools/ossfuzz/yulFuzzerCommon.cpp | 5 +- test/tools/ossfuzz/yulFuzzerCommon.h | 10 +- test/tools/ossfuzz/yulProto.proto | 2 +- test/tools/ossfuzz/yulProtoFuzzer.cpp | 7 +- test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp | 14 +- .../EVMInstructionInterpreter.cpp | 15 +- .../EVMInstructionInterpreter.h | 24 +-- .../EwasmBuiltinInterpreter.cpp | 12 +- .../yulInterpreter/EwasmBuiltinInterpreter.h | 33 ++- test/tools/yulInterpreter/Interpreter.cpp | 8 +- test/tools/yulInterpreter/Interpreter.h | 68 +++--- test/tools/yulopti.cpp | 9 +- test/tools/yulrun.cpp | 11 +- 142 files changed, 836 insertions(+), 1201 deletions(-) diff --git a/test/Common.cpp b/test/Common.cpp index 48966d9a3..ddbb25739 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -24,9 +24,7 @@ namespace fs = boost::filesystem; namespace po = boost::program_options; -namespace dev -{ -namespace test +namespace solidity::test { /// If non-empty returns the value of the env. variable ETH_TEST_PATH, otherwise @@ -91,7 +89,7 @@ CommonOptions::CommonOptions(std::string _caption): { options.add_options() ("evm-version", po::value(&evmVersionString), "which evm version to use") - ("testpath", po::value(&this->testPath)->default_value(dev::test::testPath()), "path to test files") + ("testpath", po::value(&this->testPath)->default_value(solidity::test::testPath()), "path to test files") ("evmonepath", po::value(&evmonePath)->default_value(EVMOneEnvOrDefaultPath()), "path to evmone library") ("no-smt", po::bool_switch(&disableSMT), "disable SMT checker"); } @@ -138,5 +136,3 @@ langutil::EVMVersion CommonOptions::evmVersion() const } } - -} diff --git a/test/Common.h b/test/Common.h index bc632ff59..bf65627ca 100644 --- a/test/Common.h +++ b/test/Common.h @@ -24,10 +24,7 @@ #include #include -namespace dev -{ - -namespace test +namespace solidity::test { #ifdef _WIN32 @@ -42,7 +39,7 @@ static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/r #endif -struct ConfigException : public Exception {}; +struct ConfigException : public util::Exception {}; struct CommonOptions: boost::noncopyable { @@ -68,4 +65,3 @@ private: }; } -} diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index bb9164eea..49cb5808f 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -31,8 +31,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::test; using namespace evmc::literals; evmc::VM& EVMHost::getVM(string const& _path) diff --git a/test/EVMHost.h b/test/EVMHost.h index c3f69960c..31e08e411 100644 --- a/test/EVMHost.h +++ b/test/EVMHost.h @@ -29,11 +29,9 @@ #include -namespace dev +namespace solidity::test { -namespace test -{ -using Address = h160; +using Address = util::h160; class EVMHost: public evmc::MockedHost { @@ -69,8 +67,8 @@ public: static Address convertFromEVMC(evmc::address const& _addr); static evmc::address convertToEVMC(Address const& _addr); - static h256 convertFromEVMC(evmc::bytes32 const& _data); - static evmc::bytes32 convertToEVMC(h256 const& _data); + static util::h256 convertFromEVMC(evmc::bytes32 const& _data); + static evmc::bytes32 convertToEVMC(util::h256 const& _data); private: evmc::address m_currentAddress = {}; @@ -97,4 +95,3 @@ private: } -} diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index 4f5c8badd..528ee6a88 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -34,24 +34,25 @@ #include using namespace std; -using namespace dev; -using namespace dev::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::test; ExecutionFramework::ExecutionFramework(): - ExecutionFramework(dev::test::Options::get().evmVersion()) + ExecutionFramework(solidity::test::Options::get().evmVersion()) { } ExecutionFramework::ExecutionFramework(langutil::EVMVersion _evmVersion): m_evmVersion(_evmVersion), - m_optimiserSettings(solidity::OptimiserSettings::minimal()), - m_showMessages(dev::test::Options::get().showMessages), + m_optimiserSettings(solidity::frontend::OptimiserSettings::minimal()), + m_showMessages(solidity::test::Options::get().showMessages), m_evmHost(make_shared(m_evmVersion)) { - if (dev::test::Options::get().optimizeYul) - m_optimiserSettings = solidity::OptimiserSettings::full(); - else if (dev::test::Options::get().optimize) - m_optimiserSettings = solidity::OptimiserSettings::standard(); + if (solidity::test::Options::get().optimizeYul) + m_optimiserSettings = solidity::frontend::OptimiserSettings::full(); + else if (solidity::test::Options::get().optimize) + m_optimiserSettings = solidity::frontend::OptimiserSettings::standard(); m_evmHost->reset(); for (size_t i = 0; i < 10; i++) diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 564c83f79..9f4150525 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -34,16 +34,14 @@ #include -namespace dev -{ -namespace test +namespace solidity::test { class EVMHost; -using rational = boost::rational; +using rational = boost::rational; /// An Ethereum address: 20 bytes. /// @NOTE This is not endian-specific; it's just a bunch of bytes. -using Address = h160; +using Address = util::h160; // The various denominations; here for ease of use where needed within code. static const u256 wei = 1; @@ -101,7 +99,7 @@ public: bytes const& callContractFunctionWithValueNoEncoding(std::string _sig, u256 const& _value, bytes const& _arguments) { - FixedHash<4> hash(dev::keccak256(_sig)); + util::FixedHash<4> hash(util::keccak256(_sig)); sendMessage(hash.asBytes() + _arguments, false, _value); return m_output; } @@ -131,9 +129,9 @@ public: BOOST_CHECK_MESSAGE( contractResult == cppResult, "Computed values do not match.\nContract: " + - toHex(contractResult) + + util::toHex(contractResult) + "\nC++: " + - toHex(cppResult) + util::toHex(cppResult) ); } @@ -147,11 +145,11 @@ public: BOOST_CHECK_MESSAGE( contractResult == cppResult, "Computed values do not match.\nContract: " + - toHex(contractResult) + + util::toHex(contractResult) + "\nC++: " + - toHex(cppResult) + + util::toHex(cppResult) + "\nArgument: " + - toHex(encode(argument)) + util::toHex(encode(argument)) ); } } @@ -163,7 +161,7 @@ public: static bytes encode(size_t _value) { return encode(u256(_value)); } static bytes encode(char const* _value) { return encode(std::string(_value)); } static bytes encode(uint8_t _value) { return bytes(31, 0) + bytes{_value}; } - static bytes encode(u256 const& _value) { return toBigEndian(_value); } + static bytes encode(u256 const& _value) { return util::toBigEndian(_value); } /// @returns the fixed-point encoding of a rational number with a given /// number of fractional bits. static bytes encode(std::pair const& _valueAndPrecision) @@ -172,13 +170,13 @@ public: int fractionalBits = _valueAndPrecision.second; return encode(u256((value.numerator() << fractionalBits) / value.denominator())); } - static bytes encode(h256 const& _value) { return _value.asBytes(); } + static bytes encode(util::h256 const& _value) { return _value.asBytes(); } static bytes encode(bytes const& _value, bool _padLeft = true) { bytes padding = bytes((32 - _value.size() % 32) % 32, 0); return _padLeft ? padding + _value : _value + padding; } - static bytes encode(std::string const& _value) { return encode(asBytes(_value), false); } + static bytes encode(std::string const& _value) { return encode(util::asBytes(_value), false); } template static bytes encode(std::vector<_T> const& _value) { @@ -265,13 +263,13 @@ protected: size_t numLogs() const; size_t numLogTopics(size_t _logIdx) const; - h256 logTopic(size_t _logIdx, size_t _topicIdx) const; + util::h256 logTopic(size_t _logIdx, size_t _topicIdx) const; Address logAddress(size_t _logIdx) const; bytes logData(size_t _logIdx) const; langutil::EVMVersion m_evmVersion; - solidity::RevertStrings m_revertStrings = solidity::RevertStrings::Default; - solidity::OptimiserSettings m_optimiserSettings = solidity::OptimiserSettings::minimal(); + solidity::frontend::RevertStrings m_revertStrings = solidity::frontend::RevertStrings::Default; + solidity::frontend::OptimiserSettings m_optimiserSettings = solidity::frontend::OptimiserSettings::minimal(); bool m_showMessages = false; std::shared_ptr m_evmHost; @@ -290,6 +288,5 @@ protected: } while (0) -} } // end namespaces diff --git a/test/InteractiveTests.h b/test/InteractiveTests.h index 4a4c4df7c..8069ae522 100644 --- a/test/InteractiveTests.h +++ b/test/InteractiveTests.h @@ -33,11 +33,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { /** Container for all information regarding a testsuite */ @@ -72,5 +68,3 @@ Testsuite const g_interactiveTestsuites[] = { }; } -} -} diff --git a/test/Metadata.cpp b/test/Metadata.cpp index a121d42fc..12a5d3aae 100644 --- a/test/Metadata.cpp +++ b/test/Metadata.cpp @@ -28,9 +28,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::test { bytes onlyMetadata(bytes const& _bytecode) @@ -58,7 +56,7 @@ bytes bytecodeSansMetadata(bytes const& _bytecode) string bytecodeSansMetadata(string const& _bytecode) { - return toHex(bytecodeSansMetadata(fromHex(_bytecode, WhenError::Throw))); + return util::toHex(bytecodeSansMetadata(fromHex(_bytecode, util::WhenError::Throw))); } DEV_SIMPLE_EXCEPTION(CBORException); @@ -84,7 +82,7 @@ public: switch(nextType()) { case MajorType::ByteString: - return toHex(readBytes(readLength())); + return util::toHex(readBytes(readLength())); case MajorType::TextString: return readString(); case MajorType::SimpleData: @@ -174,7 +172,7 @@ std::optional> parseCBORMetadata(bytes const& _metadata) bool isValidMetadata(string const& _metadata) { Json::Value metadata; - if (!jsonParseStrict(_metadata, metadata)) + if (!util::jsonParseStrict(_metadata, metadata)) return false; if ( @@ -202,5 +200,4 @@ bool isValidMetadata(string const& _metadata) return true; } -} } // end namespaces diff --git a/test/Metadata.h b/test/Metadata.h index a52ccf2e9..f769f438f 100644 --- a/test/Metadata.h +++ b/test/Metadata.h @@ -25,9 +25,7 @@ #include #include -namespace dev -{ -namespace test +namespace solidity::test { /// Returns only the CBOR metadata. @@ -53,5 +51,4 @@ std::optional> parseCBORMetadata(bytes const& /// content is valid metadata. bool isValidMetadata(std::string const& _metadata); -} } // end namespaces diff --git a/test/Options.cpp b/test/Options.cpp index 3294dad1e..7498dc8c6 100644 --- a/test/Options.cpp +++ b/test/Options.cpp @@ -31,7 +31,7 @@ #include using namespace std; -using namespace dev::test; +using namespace solidity::test; namespace fs = boost::filesystem; namespace po = boost::program_options; diff --git a/test/Options.h b/test/Options.h index 35a49c619..79e2c9920 100644 --- a/test/Options.h +++ b/test/Options.h @@ -27,9 +27,7 @@ #include -namespace dev -{ -namespace test +namespace solidity::test { struct Options: CommonOptions @@ -44,4 +42,3 @@ private: }; } -} diff --git a/test/TestCase.cpp b/test/TestCase.cpp index a9f4e6252..e8b47c38d 100644 --- a/test/TestCase.cpp +++ b/test/TestCase.cpp @@ -29,10 +29,10 @@ #include -using namespace dev; -using namespace solidity; -using namespace dev::solidity::test; using namespace std; +using namespace solidity; +using namespace solidity::frontend; +using namespace solidity::frontend::test; void TestCase::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool) { @@ -57,7 +57,7 @@ bool TestCase::validateSettings(langutil::EVMVersion) if (!m_settings.empty()) throw runtime_error( "Unknown setting(s): " + - joinHumanReadable(m_settings | boost::adaptors::map_keys) + util::joinHumanReadable(m_settings | boost::adaptors::map_keys) ); return true; } diff --git a/test/TestCase.h b/test/TestCase.h index 0c149c22c..927490537 100644 --- a/test/TestCase.h +++ b/test/TestCase.h @@ -28,11 +28,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { /** @@ -114,6 +110,5 @@ public: /// Returns true, if the test case is supported for EVM version @arg _evmVersion, false otherwise. bool validateSettings(langutil::EVMVersion _evmVersion) override; }; -} -} + } diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 67f8df227..edecdd0de 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,7 @@ #include using namespace boost::unit_test; -using namespace dev::solidity::test; +using namespace solidity::frontend::test; namespace fs = boost::filesystem; using namespace std; @@ -68,7 +69,7 @@ int registerTests( { int numTestsAdded = 0; fs::path fullpath = _basepath / _path; - TestCase::Config config{fullpath.string(), dev::test::Options::get().evmVersion()}; + TestCase::Config config{fullpath.string(), solidity::test::Options::get().evmVersion()}; if (fs::is_directory(fullpath)) { test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string()); @@ -93,7 +94,7 @@ int registerTests( { stringstream errorStream; auto testCase = _testCaseCreator(config); - if (testCase->validateSettings(dev::test::Options::get().evmVersion())) + if (testCase->validateSettings(solidity::test::Options::get().evmVersion())) switch (testCase->run(errorStream)) { case TestCase::TestResult::Success: @@ -126,20 +127,20 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) { master_test_suite_t& master = framework::master_test_suite(); master.p_name.value = "SolidityTests"; - dev::test::Options::get().validate(); + solidity::test::Options::get().validate(); - bool disableSemantics = !dev::test::EVMHost::getVM(dev::test::Options::get().evmonePath.string()); + bool disableSemantics = !solidity::test::EVMHost::getVM(solidity::test::Options::get().evmonePath.string()); if (disableSemantics) { - cout << "Unable to find " << dev::test::evmoneFilename << ". Please provide the path using -- --evmonepath ." << endl; + cout << "Unable to find " << solidity::test::evmoneFilename << ". Please provide the path using -- --evmonepath ." << endl; cout << "You can download it at" << endl; - cout << dev::test::evmoneDownloadLink << endl; + cout << solidity::test::evmoneDownloadLink << endl; cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl; } // Include the interactive tests in the automatic tests as well for (auto const& ts: g_interactiveTestsuites) { - auto const& options = dev::test::Options::get(); + auto const& options = solidity::test::Options::get(); if (ts.smt && options.disableSMT) continue; @@ -176,7 +177,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) removeTestSuite(suite); } - if (dev::test::Options::get().disableSMT) + if (solidity::test::Options::get().disableSMT) removeTestSuite("SMTChecker"); return 0; diff --git a/test/cmdlineTests/yul_stack_opt_disabled/err b/test/cmdlineTests/yul_stack_opt_disabled/err index 43deb1b0e..3ff22e160 100644 --- a/test/cmdlineTests/yul_stack_opt_disabled/err +++ b/test/cmdlineTests/yul_stack_opt_disabled/err @@ -2,4 +2,4 @@ Warning: Yul is still experimental. Please use the output with care. Exception while assembling: Dynamic exception type: std::exception::what: Variable a1 is 17 slot(s) too deep inside the stack. -[dev::tag_comment*] = Variable a1 is 17 slot(s) too deep inside the stack. +[solidity::util::tag_comment*] = Variable a1 is 17 slot(s) too deep inside the stack. diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp index ffe1c3495..cf15f4ab4 100644 --- a/test/contracts/AuctionRegistrar.cpp +++ b/test/contracts/AuctionRegistrar.cpp @@ -29,13 +29,11 @@ #include using namespace std; -using namespace dev::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -455,6 +453,4 @@ BOOST_AUTO_TEST_CASE(auction_bidding) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/contracts/ContractInterface.h b/test/contracts/ContractInterface.h index 052b0db2d..4d063947e 100644 --- a/test/contracts/ContractInterface.h +++ b/test/contracts/ContractInterface.h @@ -22,9 +22,7 @@ #include -namespace dev -{ -namespace test +namespace solidity::test { class ContractInterface @@ -58,7 +56,7 @@ protected: BOOST_CHECK(call(_name + "(string,address,bool)", u256(0x60), _arg2, _arg3, _arg1.length(), _arg1).empty()); } - void callStringBytes32(std::string const& _name, std::string const& _arg1, h256 const& _arg2) + void callStringBytes32(std::string const& _name, std::string const& _arg1, util::h256 const& _arg2) { BOOST_CHECK(call(_name + "(string,bytes32)", u256(0x40), _arg2, _arg1.length(), _arg1).empty()); } @@ -68,25 +66,25 @@ protected: bytes const& ret = call(_name + "(string)", u256(0x20), _arg.length(), _arg); BOOST_REQUIRE(ret.size() == 0x20); BOOST_CHECK(std::count(ret.begin(), ret.begin() + 12, 0) == 12); - return u160(u256(h256(ret))); + return u160(u256(util::h256(ret))); } std::string callAddressReturnsString(std::string const& _name, u160 const& _arg) { bytesConstRef const ret(&call(_name + "(address)", _arg)); BOOST_REQUIRE(ret.size() >= 0x40); - u256 offset(h256(ret.cropped(0, 0x20))); + u256 offset(util::h256(ret.cropped(0, 0x20))); BOOST_REQUIRE_EQUAL(offset, 0x20); - u256 len(h256(ret.cropped(0x20, 0x20))); + u256 len(util::h256(ret.cropped(0x20, 0x20))); BOOST_REQUIRE_EQUAL(ret.size(), 0x40 + ((len + 0x1f) / 0x20) * 0x20); return ret.cropped(0x40, size_t(len)).toString(); } - h256 callStringReturnsBytes32(std::string const& _name, std::string const& _arg) + util::h256 callStringReturnsBytes32(std::string const& _name, std::string const& _arg) { bytes const& ret = call(_name + "(string)", u256(0x20), _arg.length(), _arg); BOOST_REQUIRE(ret.size() == 0x20); - return h256(ret); + return util::h256(ret); } private: @@ -94,6 +92,5 @@ private: ExecutionFramework& m_framework; }; -} } // end namespaces diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp index acc51c2b9..a0b1d2a8f 100644 --- a/test/contracts/FixedFeeRegistrar.cpp +++ b/test/contracts/FixedFeeRegistrar.cpp @@ -35,13 +35,11 @@ #include using namespace std; -using namespace dev::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -249,6 +247,4 @@ BOOST_AUTO_TEST_CASE(disown) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index 25b81d4d9..1d1718f60 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -35,13 +35,10 @@ #include using namespace std; -using namespace dev::test; +using namespace solidity::test; +using namespace solidity::util; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { static char const* walletCode = R"DELIMITER( @@ -467,7 +464,7 @@ BOOST_AUTO_TEST_CASE(creation) { deployWallet(200); BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true)); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; BOOST_REQUIRE(callContractFunction("isOwner(address)", ~h256(m_sender, h256::AlignRight)) == (v2 ? encodeArgs() : encodeArgs(false))); } @@ -590,7 +587,7 @@ BOOST_AUTO_TEST_CASE(revoke_addOwner) BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs()); // add a new owner Address deployer = m_sender; - h256 opHash = dev::keccak256(FixedHash<4>(dev::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes()); + h256 opHash = util::keccak256(FixedHash<4>(util::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes()); BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs()); BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false)); m_sender = account(0); @@ -703,6 +700,4 @@ BOOST_AUTO_TEST_CASE(daylimit_constructor) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libdevcore/Checksum.cpp b/test/libdevcore/Checksum.cpp index 95066b69f..a306e45cc 100644 --- a/test/libdevcore/Checksum.cpp +++ b/test/libdevcore/Checksum.cpp @@ -26,9 +26,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(Checksum) @@ -114,4 +112,3 @@ BOOST_AUTO_TEST_CASE(homocaps_invalid) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/CommonData.cpp b/test/libdevcore/CommonData.cpp index 18f7be6f8..5f6e744e4 100644 --- a/test/libdevcore/CommonData.cpp +++ b/test/libdevcore/CommonData.cpp @@ -26,14 +26,12 @@ #include using namespace std; -using namespace dev::solidity; +using namespace solidity::frontend; // TODO: Fix Boost... -BOOST_TEST_DONT_PRINT_LOG_VALUE(dev::bytes); +BOOST_TEST_DONT_PRINT_LOG_VALUE(solidity::bytes); -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(CommonData) @@ -140,4 +138,3 @@ BOOST_AUTO_TEST_CASE(test_format_number) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/IndentedWriter.cpp b/test/libdevcore/IndentedWriter.cpp index 916c99d09..bde910d13 100644 --- a/test/libdevcore/IndentedWriter.cpp +++ b/test/libdevcore/IndentedWriter.cpp @@ -24,9 +24,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(IndentedWriterTest) @@ -72,4 +70,3 @@ BOOST_AUTO_TEST_CASE(indent) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/IpfsHash.cpp b/test/libdevcore/IpfsHash.cpp index c684de87b..ee7baad1c 100644 --- a/test/libdevcore/IpfsHash.cpp +++ b/test/libdevcore/IpfsHash.cpp @@ -24,9 +24,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(IpfsHash) @@ -73,4 +71,3 @@ BOOST_AUTO_TEST_CASE(test_largest_unchunked) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/IterateReplacing.cpp b/test/libdevcore/IterateReplacing.cpp index dd64d481b..c17dacdc0 100644 --- a/test/libdevcore/IterateReplacing.cpp +++ b/test/libdevcore/IterateReplacing.cpp @@ -24,9 +24,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(IterateReplacing) @@ -94,4 +92,3 @@ BOOST_AUTO_TEST_CASE(inject_some_end) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/JSON.cpp b/test/libdevcore/JSON.cpp index 684fd92b2..33886333a 100644 --- a/test/libdevcore/JSON.cpp +++ b/test/libdevcore/JSON.cpp @@ -25,9 +25,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(JsonTest) @@ -107,4 +105,3 @@ BOOST_AUTO_TEST_CASE(parse_json_strict) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/Keccak256.cpp b/test/libdevcore/Keccak256.cpp index b52a458eb..ac97b6edd 100644 --- a/test/libdevcore/Keccak256.cpp +++ b/test/libdevcore/Keccak256.cpp @@ -23,9 +23,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(Keccak256) @@ -73,4 +71,3 @@ BOOST_AUTO_TEST_CASE(strings) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/StringUtils.cpp b/test/libdevcore/StringUtils.cpp index 0baeb964d..14551bbeb 100644 --- a/test/libdevcore/StringUtils.cpp +++ b/test/libdevcore/StringUtils.cpp @@ -28,9 +28,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(StringUtils) @@ -153,12 +151,11 @@ BOOST_AUTO_TEST_CASE(test_format_number_readable) // for formal/SMTChecker BOOST_CHECK_EQUAL( - formatNumberReadable(solidity::IntegerType(256).minValue()), "0"); + formatNumberReadable(frontend::IntegerType(256).minValue()), "0"); BOOST_CHECK_EQUAL( - formatNumberReadable(solidity::IntegerType(256).maxValue()), "2**256 - 1"); + formatNumberReadable(frontend::IntegerType(256).maxValue()), "2**256 - 1"); } BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/SwarmHash.cpp b/test/libdevcore/SwarmHash.cpp index 8fe185cd8..8aa34fe7a 100644 --- a/test/libdevcore/SwarmHash.cpp +++ b/test/libdevcore/SwarmHash.cpp @@ -26,9 +26,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(SwarmHash) @@ -100,4 +98,3 @@ BOOST_AUTO_TEST_CASE(bzz_hash_nonzero) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/UTF8.cpp b/test/libdevcore/UTF8.cpp index daf47bb06..aadb54987 100644 --- a/test/libdevcore/UTF8.cpp +++ b/test/libdevcore/UTF8.cpp @@ -25,9 +25,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(UTF8) @@ -213,4 +211,3 @@ hélló BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libdevcore/Whiskers.cpp b/test/libdevcore/Whiskers.cpp index 924f2efd0..56341e6ce 100644 --- a/test/libdevcore/Whiskers.cpp +++ b/test/libdevcore/Whiskers.cpp @@ -24,9 +24,7 @@ using namespace std; -namespace dev -{ -namespace test +namespace solidity::util::test { BOOST_AUTO_TEST_SUITE(WhiskersTest) @@ -197,4 +195,3 @@ BOOST_AUTO_TEST_CASE(invalid_param_rendered) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index 756f7f2f1..30a36c58c 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -30,19 +30,15 @@ #include using namespace std; -using namespace langutil; -using namespace dev::eth; +using namespace solidity::langutil; +using namespace solidity::evmasm; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace { - void checkCompilation(::evmasm::Assembly const& _assembly) + void checkCompilation(evmasm::Assembly const& _assembly) { LinkerObject output = _assembly.assemble(); BOOST_CHECK(output.bytecode.size() > 0); @@ -127,7 +123,7 @@ BOOST_AUTO_TEST_CASE(all_assembly_items) "auxdata: 0x4266eeaa\n" ); BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(_assembly.assemblyJSON()), + util::jsonCompactPrint(_assembly.assemblyJSON()), "{\".auxdata\":\"4266eeaa\",\".code\":[{\"begin\":1,\"end\":3,\"name\":\"tag\",\"value\":\"1\"}," "{\"begin\":1,\"end\":3,\"name\":\"JUMPDEST\"}," "{\"begin\":1,\"end\":3,\"name\":\"PUSH\",\"value\":\"1\"}," @@ -150,6 +146,4 @@ BOOST_AUTO_TEST_CASE(all_assembly_items) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 0d550e072..0eaab67da 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -36,14 +36,10 @@ #include using namespace std; -using namespace langutil; -using namespace dev::eth; +using namespace solidity::langutil; +using namespace solidity::evmasm; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -240,7 +236,7 @@ BOOST_AUTO_TEST_CASE(cse_associativity2) BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow) { - if (dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (solidity::test::Options::get().evmVersion().hasBitwiseShifting()) { AssemblyItems input{ Instruction::CALLVALUE, @@ -255,7 +251,7 @@ BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow) BOOST_AUTO_TEST_CASE(cse_double_shift_left_overflow) { - if (dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (solidity::test::Options::get().evmVersion().hasBitwiseShifting()) { AssemblyItems input{ Instruction::DUP1, @@ -508,7 +504,7 @@ BOOST_AUTO_TEST_CASE(cse_empty_keccak256) Instruction::KECCAK256 }; checkCSE(input, { - u256(dev::keccak256(bytesConstRef())) + u256(util::keccak256(bytesConstRef())) }); } @@ -526,7 +522,7 @@ BOOST_AUTO_TEST_CASE(cse_partial_keccak256) u256(0xabcd) << (256 - 16), u256(0), Instruction::MSTORE, - u256(dev::keccak256(bytes{0xab, 0xcd})) + u256(util::keccak256(bytes{0xab, 0xcd})) }); } @@ -1136,7 +1132,7 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies) main.append(t1.toSubAssemblyTag(subId)); main.append(u256(8)); - main.optimise(true, dev::test::Options::get().evmVersion(), false, 200); + main.optimise(true, solidity::test::Options::get().evmVersion(), false, 200); AssemblyItems expectationMain{ AssemblyItem(PushSubSize, 0), @@ -1182,7 +1178,7 @@ BOOST_AUTO_TEST_CASE(cse_sub_zero) BOOST_AUTO_TEST_CASE(cse_remove_redundant_shift_masking) { - if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) return; for (int i = 1; i < 256; i++) @@ -1330,7 +1326,7 @@ BOOST_AUTO_TEST_CASE(cse_remove_unwanted_masking_of_address) BOOST_AUTO_TEST_CASE(cse_replace_too_large_shift) { - if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) return; checkCSE({ @@ -1372,6 +1368,4 @@ BOOST_AUTO_TEST_CASE(cse_replace_too_large_shift) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/liblangutil/CharStream.cpp b/test/liblangutil/CharStream.cpp index abd3d02db..fda026532 100644 --- a/test/liblangutil/CharStream.cpp +++ b/test/liblangutil/CharStream.cpp @@ -25,9 +25,7 @@ #include -namespace langutil -{ -namespace test +namespace solidity::langutil::test { BOOST_AUTO_TEST_SUITE(CharStreamtest) @@ -43,11 +41,10 @@ BOOST_AUTO_TEST_CASE(test_fail) BOOST_CHECK('w' == source->setPosition(2)); BOOST_REQUIRE_THROW( source->setPosition(200), - ::langutil::InternalCompilerError + ::solidity::langutil::InternalCompilerError ); } BOOST_AUTO_TEST_SUITE_END() -} } // end namespaces diff --git a/test/liblangutil/SourceLocation.cpp b/test/liblangutil/SourceLocation.cpp index 12ea64630..f1808b22a 100644 --- a/test/liblangutil/SourceLocation.cpp +++ b/test/liblangutil/SourceLocation.cpp @@ -24,9 +24,7 @@ #include -namespace langutil -{ -namespace test +namespace solidity::langutil::test { BOOST_AUTO_TEST_SUITE(SourceLocationTest) @@ -47,5 +45,4 @@ BOOST_AUTO_TEST_CASE(test_fail) BOOST_AUTO_TEST_SUITE_END() -} } // end namespaces diff --git a/test/liblll/Compiler.cpp b/test/liblll/Compiler.cpp index d44ccb49f..3f9c4eceb 100644 --- a/test/liblll/Compiler.cpp +++ b/test/liblll/Compiler.cpp @@ -32,12 +32,9 @@ #include using namespace std; +using namespace solidity::util; -namespace dev -{ -namespace lll -{ -namespace test +namespace solidity::lll::test { namespace @@ -46,7 +43,7 @@ namespace bool successCompile(string const& _sourceCode) { vector errors; - bytes bytecode = lll::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), false, &errors); + bytes bytecode = lll::compileLLL(_sourceCode, solidity::test::Options::get().evmVersion(), false, &errors); if (!errors.empty()) return false; if (bytecode.empty()) @@ -365,7 +362,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional) for (size_t i = 0; i < opcodes_bytecode.size(); i++) { vector errors; - bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); + bytes code = lll::compileLLL(opcodes_lll[i], solidity::test::Options::get().evmVersion(), false, &errors); BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]); @@ -660,7 +657,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm) for (size_t i = 0; i < opcodes_bytecode.size(); i++) { vector errors; - bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); + bytes code = lll::compileLLL(opcodes_lll[i], solidity::test::Options::get().evmVersion(), false, &errors); BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]); @@ -670,6 +667,4 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp index 8c3191546..531249885 100644 --- a/test/liblll/EndToEndTest.cpp +++ b/test/liblll/EndToEndTest.cpp @@ -29,7 +29,7 @@ #include using namespace std; -using namespace dev::test; +using namespace solidity::test; namespace dev { @@ -605,7 +605,7 @@ BOOST_AUTO_TEST_CASE(send_two_args) { // "send" does not retain enough gas to be able to pay for account creation. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -621,7 +621,7 @@ BOOST_AUTO_TEST_CASE(send_three_args) { // "send" does not retain enough gas to be able to pay for account creation. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -740,7 +740,7 @@ BOOST_AUTO_TEST_CASE(msg_three_args) { // "msg" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -758,7 +758,7 @@ BOOST_AUTO_TEST_CASE(msg_two_args) { // "msg" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -776,7 +776,7 @@ BOOST_AUTO_TEST_CASE(create_one_arg) { // "call" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -795,7 +795,7 @@ BOOST_AUTO_TEST_CASE(create_two_args) { // "call" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -874,7 +874,7 @@ BOOST_AUTO_TEST_CASE(ecrecover) { // "ecrecover" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -898,7 +898,7 @@ BOOST_AUTO_TEST_CASE(sha256_two_args) { // "sha256" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -918,7 +918,7 @@ BOOST_AUTO_TEST_CASE(ripemd160_two_args) { // "ripemd160" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -938,7 +938,7 @@ BOOST_AUTO_TEST_CASE(sha256_one_arg) { // "sha256" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll @@ -956,7 +956,7 @@ BOOST_AUTO_TEST_CASE(ripemd160_one_arg) { // "ripemd160" does not retain enough gas. // Disabling for non-tangerineWhistle VMs. - if (dev::test::Options::get().evmVersion().canOverchargeGasForCall()) + if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall()) { char const* sourceCode = R"( (returnlll diff --git a/test/liblll/ExecutionFramework.cpp b/test/liblll/ExecutionFramework.cpp index 4719c5f50..7e8cb7629 100644 --- a/test/liblll/ExecutionFramework.cpp +++ b/test/liblll/ExecutionFramework.cpp @@ -24,7 +24,7 @@ #include #include -using namespace dev::test; +using namespace solidity::test; using namespace dev::lll::test; LLLExecutionFramework::LLLExecutionFramework() : diff --git a/test/liblll/ExecutionFramework.h b/test/liblll/ExecutionFramework.h index cbdd19887..1fc14f528 100644 --- a/test/liblll/ExecutionFramework.h +++ b/test/liblll/ExecutionFramework.h @@ -29,15 +29,10 @@ #include -namespace dev -{ -namespace lll +namespace solidity::lll::test { -namespace test -{ - -class LLLExecutionFramework: public dev::test::ExecutionFramework +class LLLExecutionFramework: public solidity::test::ExecutionFramework { public: LLLExecutionFramework(); @@ -47,7 +42,7 @@ public: u256 const& _value = 0, std::string const& _contractName = "", bytes const& _arguments = bytes(), - std::map const& _libraryAddresses = {} + std::map const& _libraryAddresses = {} ) override { BOOST_REQUIRE(_contractName.empty()); @@ -56,8 +51,8 @@ public: std::vector errors; bytes bytecode = lll::compileLLL( _sourceCode, - dev::test::Options::get().evmVersion(), - m_optimiserSettings == solidity::OptimiserSettings::standard(), + solidity::test::Options::get().evmVersion(), + m_optimiserSettings == solidity::frontend::OptimiserSettings::standard(), &errors ); if (!errors.empty()) @@ -71,6 +66,4 @@ public: } }; -} -} } // end namespaces diff --git a/test/liblll/LLL_ENS.cpp b/test/liblll/LLL_ENS.cpp index 0dfd656ce..a550be5a1 100644 --- a/test/liblll/LLL_ENS.cpp +++ b/test/liblll/LLL_ENS.cpp @@ -29,7 +29,7 @@ using namespace std; using namespace dev::lll; -using namespace dev::test; +using namespace solidity::test; namespace dev { @@ -346,7 +346,7 @@ protected: if (!s_compiledEns) { vector errors; - s_compiledEns.reset(new bytes(compileLLL(ensCode, dev::test::Options::get().evmVersion(), dev::test::Options::get().optimize, &errors))); + s_compiledEns.reset(new bytes(compileLLL(ensCode, solidity::test::Options::get().evmVersion(), solidity::test::Options::get().optimize, &errors))); BOOST_REQUIRE(errors.empty()); } sendMessage(*s_compiledEns, true); diff --git a/test/liblll/LLL_ERC20.cpp b/test/liblll/LLL_ERC20.cpp index bad482584..43090dc09 100644 --- a/test/liblll/LLL_ERC20.cpp +++ b/test/liblll/LLL_ERC20.cpp @@ -34,7 +34,7 @@ using namespace std; using namespace dev::lll; -using namespace dev::test; +using namespace solidity::test; namespace dev { @@ -397,7 +397,7 @@ protected: if (!s_compiledErc20) { vector errors; - s_compiledErc20.reset(new bytes(compileLLL(erc20Code, dev::test::Options::get().evmVersion(), dev::test::Options::get().optimize, &errors))); + s_compiledErc20.reset(new bytes(compileLLL(erc20Code, solidity::test::Options::get().evmVersion(), solidity::test::Options::get().optimize, &errors))); BOOST_REQUIRE(errors.empty()); } sendMessage(*s_compiledErc20, true); diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index 2bc3dcc74..c3bc548ec 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -29,13 +29,9 @@ using namespace std; using namespace std::placeholders; -using namespace dev::test; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_FIXTURE_TEST_SUITE(ABIDecoderTest, SolidityExecutionFramework) @@ -86,7 +82,7 @@ BOOST_AUTO_TEST_CASE(enums) } } )"; - bool newDecoder = dev::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::Options::get().useABIEncoderV2; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f(uint8)", 0), encodeArgs(u256(0))); @@ -108,7 +104,7 @@ BOOST_AUTO_TEST_CASE(cleanup) } } )"; - bool newDecoder = dev::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::Options::get().useABIEncoderV2; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK( @@ -577,7 +573,7 @@ BOOST_AUTO_TEST_CASE(validation_function_type) function i(function () external[] calldata a) external pure returns (uint r) { a[0]; r = 4; } } )"; - bool newDecoder = dev::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::Options::get().useABIEncoderV2; string validFun{"01234567890123456789abcd"}; string invalidFun{"01234567890123456789abcdX"}; BOTH_ENCODERS( @@ -954,7 +950,7 @@ BOOST_AUTO_TEST_CASE(out_of_bounds_bool_value) function f(bool b) public pure returns (bool) { return b; } } )"; - bool newDecoder = dev::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::Options::get().useABIEncoderV2; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(true)); @@ -967,6 +963,4 @@ BOOST_AUTO_TEST_CASE(out_of_bounds_bool_value) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp index 3f40bb8ee..426a34018 100644 --- a/test/libsolidity/ABIEncoderTests.cpp +++ b/test/libsolidity/ABIEncoderTests.cpp @@ -33,13 +33,10 @@ using namespace std; using namespace std::placeholders; -using namespace dev::test; +using namespace solidity::util; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { #define REQUIRE_LOG_DATA(DATA) do { \ @@ -168,7 +165,7 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim) } )"; - if (!dev::test::Options::get().useABIEncoderV2) + if (!solidity::test::Options::get().useABIEncoderV2) { compileAndRun(sourceCode); callContractFunction("f()"); @@ -343,7 +340,7 @@ BOOST_AUTO_TEST_CASE(external_function) BOTH_ENCODERS( compileAndRun(sourceCode); callContractFunction("f(uint256)", u256(0)); - string functionIdF = asString(m_contractAddress.ref()) + asString(FixedHash<4>(dev::keccak256("f(uint256)")).ref()); + string functionIdF = asString(m_contractAddress.ref()) + asString(FixedHash<4>(keccak256("f(uint256)")).ref()); REQUIRE_LOG_DATA(encodeArgs(functionIdF, functionIdF)); ) } @@ -453,7 +450,7 @@ BOOST_AUTO_TEST_CASE(structs) ); BOOST_CHECK(callContractFunction("f()") == encoded); REQUIRE_LOG_DATA(encoded); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("e(uint16,(uint16,uint16,(uint64[2])[],uint16))"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), keccak256(string("e(uint16,(uint16,uint16,(uint64[2])[],uint16))"))); ) } @@ -755,7 +752,7 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_indirect) } } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { NEW_ENCODER( compileAndRun(sourceCode, 0, "D"); @@ -787,6 +784,4 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_data_short) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/ABIJsonTest.cpp b/test/libsolidity/ABIJsonTest.cpp index a5b9d7ba8..4f41725ce 100644 --- a/test/libsolidity/ABIJsonTest.cpp +++ b/test/libsolidity/ABIJsonTest.cpp @@ -31,9 +31,10 @@ #include using namespace std; -using namespace dev; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; +using namespace solidity::frontend::test; ABIJsonTest::ABIJsonTest(string const& _filename) { @@ -51,8 +52,8 @@ TestCase::TestResult ABIJsonTest::run(ostream& _stream, string const& _linePrefi CompilerStack compiler; compiler.setSources({{"", "pragma solidity >=0.0;\n" + m_source}}); - compiler.setEVMVersion(dev::test::Options::get().evmVersion()); - compiler.setOptimiserSettings(dev::test::Options::get().optimize); + compiler.setEVMVersion(solidity::test::Options::get().evmVersion()); + compiler.setOptimiserSettings(solidity::test::Options::get().optimize); if (!compiler.parseAndAnalyze()) BOOST_THROW_EXCEPTION(runtime_error("Parsing contract failed")); diff --git a/test/libsolidity/ABIJsonTest.h b/test/libsolidity/ABIJsonTest.h index 82a19da3f..9193dc750 100644 --- a/test/libsolidity/ABIJsonTest.h +++ b/test/libsolidity/ABIJsonTest.h @@ -24,11 +24,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { @@ -53,5 +49,3 @@ private: }; } -} -} diff --git a/test/libsolidity/ABITestsCommon.h b/test/libsolidity/ABITestsCommon.h index 2ef555f3b..b2afcf125 100644 --- a/test/libsolidity/ABITestsCommon.h +++ b/test/libsolidity/ABITestsCommon.h @@ -17,11 +17,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { static std::string const NewEncoderPragma = "pragma experimental ABIEncoderV2;\n"; @@ -38,6 +34,4 @@ static std::string const NewEncoderPragma = "pragma experimental ABIEncoderV2;\n NEW_ENCODER(CODE) \ } -} -} } // end namespaces diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index a5f836864..673e30b92 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -28,11 +28,12 @@ #include #include -using namespace langutil; -using namespace dev::solidity; -using namespace dev::solidity::test; -using namespace dev::formatting; -using namespace dev; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::frontend::test; +using namespace solidity::util::formatting; +using namespace solidity::util; +using namespace solidity; using namespace std; namespace fs = boost::filesystem; using namespace boost::unit_test; @@ -102,7 +103,7 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi sourceIndices[m_sources[i].first] = i + 1; } c.setSources(sources); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); if (c.parse()) c.analyze(); else diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h index cf508e87b..01e9895a8 100644 --- a/test/libsolidity/ASTJSONTest.h +++ b/test/libsolidity/ASTJSONTest.h @@ -25,11 +25,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class ASTJSONTest: public TestCase @@ -54,5 +50,3 @@ private: }; } -} -} diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index c94e6c745..003953e70 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -34,10 +34,11 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::frontend::test; pair AnalysisFramework::parseAnalyseAndReturnError( @@ -50,7 +51,7 @@ AnalysisFramework::parseAnalyseAndReturnError( { compiler().reset(); compiler().setSources({{"", _insertVersionPragma ? "pragma solidity >=0.0;\n" + _source : _source}}); - compiler().setEVMVersion(dev::test::Options::get().evmVersion()); + compiler().setEVMVersion(solidity::test::Options::get().evmVersion()); compiler().setParserErrorRecovery(_allowRecoveryErrors); _allowMultipleErrors = _allowMultipleErrors || _allowRecoveryErrors; if (!compiler().parse()) @@ -147,6 +148,6 @@ FunctionTypePointer AnalysisFramework::retrieveFunctionBySignature( std::string const& _signature ) { - FixedHash<4> hash(dev::keccak256(_signature)); + FixedHash<4> hash(util::keccak256(_signature)); return _contract.interfaceFunctions()[hash]; } diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index 3fcb9e74a..26ca9e916 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -28,17 +28,15 @@ #include #include -namespace dev +namespace solidity::frontend { -namespace solidity -{ - class Type; class FunctionType; using TypePointer = Type const*; using FunctionTypePointer = FunctionType const*; +} -namespace test +namespace solidity::frontend::test { class AnalysisFramework @@ -74,23 +72,23 @@ protected: std::vector m_warningsToFilter = {"This is a pre-release compiler version"}; /// @returns reference to lazy-instanciated CompilerStack. - dev::solidity::CompilerStack& compiler() + solidity::frontend::CompilerStack& compiler() { if (!m_compiler) - m_compiler = std::make_unique(); + m_compiler = std::make_unique(); return *m_compiler; } /// @returns reference to lazy-instanciated CompilerStack. - dev::solidity::CompilerStack const& compiler() const + solidity::frontend::CompilerStack const& compiler() const { if (!m_compiler) - m_compiler = std::make_unique(); + m_compiler = std::make_unique(); return *m_compiler; } private: - mutable std::unique_ptr m_compiler; + mutable std::unique_ptr m_compiler; }; // Asserts that the compilation down to typechecking @@ -154,5 +152,3 @@ do \ while(0) } -} -} diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index 9323b0579..12b295f8c 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -39,15 +39,10 @@ #include using namespace std; -using namespace langutil; -using namespace dev::eth; +using namespace solidity::langutil; +using namespace solidity::evmasm; -namespace dev -{ -namespace solidity -{ -class Contract; -namespace test +namespace solidity::frontend::test { namespace @@ -57,14 +52,14 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) { ErrorList errors; ErrorReporter errorReporter(errors); - Parser parser(errorReporter, dev::test::Options::get().evmVersion()); + Parser parser(errorReporter, solidity::test::Options::get().evmVersion()); ASTPointer sourceUnit; BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(_sourceCode))); BOOST_CHECK(!!sourceUnit); map> scopes; GlobalContext globalContext; - NameAndTypeResolver resolver(globalContext, dev::test::Options::get().evmVersion(), scopes, errorReporter); + NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter); solAssert(Error::containsOnlyWarnings(errorReporter.errors()), ""); resolver.registerDeclarations(*sourceUnit); for (ASTPointer const& node: sourceUnit->nodes()) @@ -77,7 +72,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) for (ASTPointer const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - TypeChecker checker(dev::test::Options::get().evmVersion(), errorReporter); + TypeChecker checker(solidity::test::Options::get().evmVersion(), errorReporter); BOOST_REQUIRE_NO_THROW(checker.checkTypeRequirements(*contract)); if (!Error::containsOnlyWarnings(errorReporter.errors())) return AssemblyItems(); @@ -86,9 +81,9 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) if (ContractDefinition* contract = dynamic_cast(node.get())) { Compiler compiler( - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), RevertStrings::Default, - dev::test::Options::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal() + solidity::test::Options::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal() ); compiler.compileContract(*contract, map>{}, bytes()); @@ -166,12 +161,12 @@ BOOST_AUTO_TEST_CASE(location_test) } )", ""); AssemblyItems items = compileContract(sourceCode); - bool hasShifts = dev::test::Options::get().evmVersion().hasBitwiseShifting(); + bool hasShifts = solidity::test::Options::get().evmVersion().hasBitwiseShifting(); auto codegenCharStream = make_shared("", "--CODEGEN--"); vector locations; - if (dev::test::Options::get().optimize) + if (solidity::test::Options::get().optimize) locations = vector(4, SourceLocation{2, 82, sourceCode}) + vector(1, SourceLocation{8, 17, codegenCharStream}) + @@ -204,6 +199,4 @@ BOOST_AUTO_TEST_CASE(location_test) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/ErrorCheck.cpp b/test/libsolidity/ErrorCheck.cpp index e1f48fb2c..0c57d525f 100644 --- a/test/libsolidity/ErrorCheck.cpp +++ b/test/libsolidity/ErrorCheck.cpp @@ -26,9 +26,9 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; namespace { @@ -38,7 +38,7 @@ std::string errorMessage(Error const& _e) } } -bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _substr) +bool solidity::frontend::test::searchErrorMessage(Error const& _err, std::string const& _substr) { if (string const* errorMessage = _err.comment()) { @@ -54,7 +54,7 @@ bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _su return _substr.empty(); } -string dev::solidity::searchErrors(ErrorList const& _errors, vector> const& _expectations) +string solidity::frontend::test::searchErrors(ErrorList const& _errors, vector> const& _expectations) { auto expectations = _expectations; for (auto const& error: _errors) diff --git a/test/libsolidity/ErrorCheck.h b/test/libsolidity/ErrorCheck.h index c3a2f5226..5deae56dc 100644 --- a/test/libsolidity/ErrorCheck.h +++ b/test/libsolidity/ErrorCheck.h @@ -26,14 +26,14 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend::test { + bool searchErrorMessage(langutil::Error const& _err, std::string const& _substr); + /// Checks that all provided errors are of the given type and have a given substring in their /// description. /// If the expectations are not met, returns a nonempty description, otherwise an empty string. std::string searchErrors(langutil::ErrorList const& _errors, std::vector> const& _expectations); -} + } diff --git a/test/libsolidity/GasCosts.cpp b/test/libsolidity/GasCosts.cpp index de90c9076..c3f842f6f 100644 --- a/test/libsolidity/GasCosts.cpp +++ b/test/libsolidity/GasCosts.cpp @@ -26,22 +26,19 @@ #include using namespace std; -using namespace langutil; -using namespace dev::eth; -using namespace dev::solidity; -using namespace dev::test; +using namespace solidity::langutil; +using namespace solidity::langutil; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { #define CHECK_DEPLOY_GAS(_gasNoOpt, _gasOpt, _evmVersion) \ do \ { \ - u256 ipfsCost = GasMeter::dataGas(dev::ipfsHash(m_compiler.metadata(m_compiler.lastContractName())), true, _evmVersion); \ + u256 ipfsCost = GasMeter::dataGas(util::ipfsHash(m_compiler.metadata(m_compiler.lastContractName())), true, _evmVersion); \ u256 gasOpt{_gasOpt}; \ u256 gasNoOpt{_gasNoOpt}; \ u256 gas = m_optimiserSettings == OptimiserSettings::minimal() ? gasNoOpt : gasOpt; \ @@ -96,7 +93,7 @@ BOOST_AUTO_TEST_CASE(string_storage) m_compiler.overwriteReleaseFlag(true); compileAndRun(sourceCode); - auto evmVersion = dev::test::Options::get().evmVersion(); + auto evmVersion = solidity::test::Options::get().evmVersion(); if (evmVersion <= EVMVersion::byzantium()) CHECK_DEPLOY_GAS(134209, 130895, evmVersion); @@ -200,5 +197,3 @@ BOOST_AUTO_TEST_CASE(single_callvaluecheck) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index c5a066930..da2f79977 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -29,16 +29,12 @@ #include using namespace std; -using namespace langutil; -using namespace dev::eth; -using namespace dev::solidity; -using namespace dev::test; +using namespace solidity::langutil; +using namespace solidity::evmasm; +using namespace solidity::frontend; +using namespace solidity::frontend::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class GasMeterTestFramework: public SolidityExecutionFramework @@ -48,7 +44,7 @@ public: { m_compiler.reset(); m_compiler.setSources({{"", "pragma solidity >=0.0;\n" + _sourceCode}}); - m_compiler.setOptimiserSettings(dev::test::Options::get().optimize); + m_compiler.setOptimiserSettings(solidity::test::Options::get().optimize); m_compiler.setEVMVersion(m_evmVersion); BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed"); @@ -56,7 +52,7 @@ public: ASTNode const& sourceUnit = m_compiler.ast(""); BOOST_REQUIRE(items != nullptr); m_gasCosts = GasEstimator::breakToStatementLevel( - GasEstimator(dev::test::Options::get().evmVersion()).structuralEstimation(*items, vector({&sourceUnit})), + GasEstimator(solidity::test::Options::get().evmVersion()).structuralEstimation(*items, vector({&sourceUnit})), {&sourceUnit} ); } @@ -65,7 +61,7 @@ public: { compileAndRun(_sourceCode); auto state = make_shared(); - PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), dev::test::Options::get().evmVersion()); + PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), solidity::test::Options::get().evmVersion()); GasMeter::GasConsumption gas = meter.estimateMax(0, state); u256 bytecodeSize(m_compiler.runtimeObject(m_compiler.lastContractName()).bytecode.size()); // costs for deployment @@ -75,7 +71,7 @@ public: // Skip the tests when we force ABIEncoderV2. // TODO: We should enable this again once the yul optimizer is activated. - if (!dev::test::Options::get().useABIEncoderV2) + if (!solidity::test::Options::get().useABIEncoderV2) { BOOST_REQUIRE(!gas.isInfinite); BOOST_CHECK_LE(m_gasUsed, gas.value); @@ -89,7 +85,7 @@ public: { u256 gasUsed = 0; GasMeter::GasConsumption gas; - FixedHash<4> hash(dev::keccak256(_sig)); + util::FixedHash<4> hash(util::keccak256(_sig)); for (bytes const& arguments: _argumentVariants) { sendMessage(hash.asBytes() + arguments, false, 0); @@ -98,13 +94,13 @@ public: gas = max(gas, gasForTransaction(hash.asBytes() + arguments, false)); } - gas += GasEstimator(dev::test::Options::get().evmVersion()).functionalEstimation( + gas += GasEstimator(solidity::test::Options::get().evmVersion()).functionalEstimation( *m_compiler.runtimeAssemblyItems(m_compiler.lastContractName()), _sig ); // Skip the tests when we force ABIEncoderV2. // TODO: We should enable this again once the yul optimizer is activated. - if (!dev::test::Options::get().useABIEncoderV2) + if (!solidity::test::Options::get().useABIEncoderV2) { BOOST_REQUIRE(!gas.isInfinite); BOOST_CHECK_LE(m_gasUsed, gas.value); @@ -114,7 +110,7 @@ public: static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation) { - auto evmVersion = dev::test::Options::get().evmVersion(); + auto evmVersion = solidity::test::Options::get().evmVersion(); GasMeter::GasConsumption gas = _isCreation ? GasCosts::txCreateGas : GasCosts::txGas; for (auto i: _data) gas += i != 0 ? GasCosts::txDataNonZeroGas(evmVersion) : GasCosts::txDataZeroGas; @@ -149,7 +145,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs) if (first->first->location().intersects(second->first->location())) { BOOST_CHECK_MESSAGE(false, "Source locations should not overlap!"); - SourceReferenceFormatter formatter(cout); + langutil::SourceReferenceFormatter formatter(cout); formatter.printSourceLocation(&first->first->location()); formatter.printSourceLocation(&second->first->location()); @@ -197,7 +193,7 @@ BOOST_AUTO_TEST_CASE(updating_store) } } )"; - testCreationTimeGas(sourceCode, m_evmVersion < EVMVersion::constantinople() ? u256(0) : u256(9600)); + testCreationTimeGas(sourceCode, m_evmVersion < langutil::EVMVersion::constantinople() ? u256(0) : u256(9600)); } BOOST_AUTO_TEST_CASE(branches) @@ -362,5 +358,3 @@ BOOST_AUTO_TEST_CASE(complex_control_flow) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index c1d6dc625..e7b7f325c 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -26,10 +26,10 @@ #include #include -using namespace langutil; -using namespace dev::solidity; -using namespace dev::solidity::test; -using namespace dev; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::frontend::test; +using namespace solidity; using namespace std; namespace fs = boost::filesystem; using namespace boost::unit_test; diff --git a/test/libsolidity/GasTest.h b/test/libsolidity/GasTest.h index 79ce159b3..861e47bc9 100644 --- a/test/libsolidity/GasTest.h +++ b/test/libsolidity/GasTest.h @@ -26,11 +26,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class GasTest: AnalysisFramework, public TestCase @@ -56,5 +52,3 @@ private: }; } -} -} diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index a326b4e5d..7b6134d15 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -32,11 +32,7 @@ using namespace std; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_AUTO_TEST_SUITE(SolidityImports) @@ -51,7 +47,7 @@ BOOST_AUTO_TEST_CASE(remappings) {"s_1.4.6/s.sol", "contract S {} pragma solidity >=0.0;"}, {"Tee/tee.sol", "contract Tee {} pragma solidity >=0.0;"} }); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -65,7 +61,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings) {"s_1.4.6/s.sol", "contract SSix {} pragma solidity >=0.0;"}, {"s_1.4.7/s.sol", "contract SSeven {} pragma solidity >=0.0;"} }); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -83,7 +79,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_ensure_default_and_module_pres {"vendor/foo_1.0.0/foo.sol", "contract Foo1 {} pragma solidity >=0.0;"}, {"vendor/foo_2.0.0/foo.sol", "contract Foo2 {} pragma solidity >=0.0;"} }); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -97,7 +93,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent_1) {"d/z.sol", "contract D {} pragma solidity >=0.0;"}, {"e/y/z/z.sol", "contract E {} pragma solidity >=0.0;"} }); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -111,12 +107,10 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent_2) {"d/z.sol", "contract D {} pragma solidity >=0.0;"}, {"e/y/z/z.sol", "contract E {} pragma solidity >=0.0;"} }); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); } BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index a5068b27d..c4fa1ab8c 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -41,14 +41,10 @@ #include using namespace std; -using namespace langutil; -using namespace yul; +using namespace solidity::langutil; +using namespace solidity::yul; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -62,7 +58,7 @@ std::optional parseAndReturnFirstError( AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM ) { - AssemblyStack stack(dev::test::Options::get().evmVersion(), _language, dev::solidity::OptimiserSettings::none()); + AssemblyStack stack(solidity::test::Options::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none()); bool success = false; try { @@ -129,7 +125,7 @@ Error expectError( void parsePrintCompare(string const& _source, bool _canWarn = false) { - AssemblyStack stack(dev::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); + AssemblyStack stack(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); BOOST_REQUIRE(stack.parseAndAnalyze("", _source)); if (_canWarn) BOOST_REQUIRE(Error::containsOnlyWarnings(stack.errors())); @@ -542,7 +538,7 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode) { string source = "{ let x := \"\\u1bac\" }"; string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n"; - AssemblyStack stack(dev::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); + AssemblyStack stack(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); BOOST_REQUIRE(stack.parseAndAnalyze("", source)); BOOST_REQUIRE(stack.errors().empty()); BOOST_CHECK_EQUAL(stack.print(), parsed); @@ -689,42 +685,42 @@ BOOST_AUTO_TEST_CASE(keccak256) BOOST_AUTO_TEST_CASE(returndatasize) { - if (!dev::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::Options::get().evmVersion().supportsReturndata()) return; BOOST_CHECK(successAssemble("{ let r := returndatasize() }")); } BOOST_AUTO_TEST_CASE(returndatacopy) { - if (!dev::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::Options::get().evmVersion().supportsReturndata()) return; BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }")); } BOOST_AUTO_TEST_CASE(returndatacopy_functional) { - if (!dev::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::Options::get().evmVersion().supportsReturndata()) return; BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }")); } BOOST_AUTO_TEST_CASE(staticcall) { - if (!dev::test::Options::get().evmVersion().hasStaticCall()) + if (!solidity::test::Options::get().evmVersion().hasStaticCall()) return; BOOST_CHECK(successAssemble("{ pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) }")); } BOOST_AUTO_TEST_CASE(create2) { - if (!dev::test::Options::get().evmVersion().hasCreate2()) + if (!solidity::test::Options::get().evmVersion().hasCreate2()) return; BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }")); } BOOST_AUTO_TEST_CASE(shift) { - if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) return; BOOST_CHECK(successAssemble("{ pop(shl(10, 32)) }")); BOOST_CHECK(successAssemble("{ pop(shr(10, 32)) }")); @@ -733,7 +729,7 @@ BOOST_AUTO_TEST_CASE(shift) BOOST_AUTO_TEST_CASE(shift_constantinople_warning) { - if (dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (solidity::test::Options::get().evmVersion().hasBitwiseShifting()) return; CHECK_PARSE_WARNING("{ pop(shl(10, 32)) }", TypeError, "The \"shl\" instruction is only available for Constantinople-compatible VMs"); CHECK_PARSE_WARNING("{ pop(shr(10, 32)) }", TypeError, "The \"shr\" instruction is only available for Constantinople-compatible VMs"); @@ -750,6 +746,4 @@ BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/LibSolc.cpp b/test/libsolidity/LibSolc.cpp index e516e4581..cb4f8d2cc 100644 --- a/test/libsolidity/LibSolc.cpp +++ b/test/libsolidity/LibSolc.cpp @@ -28,11 +28,7 @@ using namespace std; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -64,7 +60,7 @@ Json::Value compile(string const& _input, CStyleReadFileCallback _callback = nul solidity_free(output_ptr); solidity_reset(); Json::Value ret; - BOOST_REQUIRE(jsonParseStrict(output, ret)); + BOOST_REQUIRE(util::jsonParseStrict(output, ret)); return ret; } @@ -184,6 +180,4 @@ BOOST_AUTO_TEST_CASE(with_callback) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index e8da61704..ba5261675 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -29,20 +29,16 @@ using namespace std; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace { map requireParsedCBORMetadata(bytes const& _bytecode) { - bytes cborMetadata = dev::test::onlyMetadata(_bytecode); + bytes cborMetadata = solidity::test::onlyMetadata(_bytecode); BOOST_REQUIRE(!cborMetadata.empty()); - std::optional> tmp = dev::test::parseCBORMetadata(cborMetadata); + std::optional> tmp = solidity::test::parseCBORMetadata(cborMetadata); BOOST_REQUIRE(tmp); return *tmp; } @@ -70,13 +66,13 @@ BOOST_AUTO_TEST_CASE(metadata_stamp) CompilerStack compilerStack; compilerStack.overwriteReleaseFlag(release); compilerStack.setSources({{"", std::string(sourceCode)}}); - compilerStack.setEVMVersion(dev::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(dev::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.setMetadataHash(metadataHash); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); bytes const& bytecode = compilerStack.runtimeObject("test").bytecode; std::string const& metadata = compilerStack.metadata("test"); - BOOST_CHECK(dev::test::isValidMetadata(metadata)); + BOOST_CHECK(solidity::test::isValidMetadata(metadata)); auto const cborMetadata = requireParsedCBORMetadata(bytecode); if (metadataHash == CompilerStack::MetadataHash::None) @@ -87,25 +83,25 @@ BOOST_AUTO_TEST_CASE(metadata_stamp) string hashMethod; if (metadataHash == CompilerStack::MetadataHash::IPFS) { - hash = dev::ipfsHash(metadata); + hash = util::ipfsHash(metadata); BOOST_REQUIRE(hash.size() == 34); hashMethod = "ipfs"; } else { - hash = dev::bzzr1Hash(metadata).asBytes(); + hash = util::bzzr1Hash(metadata).asBytes(); BOOST_REQUIRE(hash.size() == 32); hashMethod = "bzzr1"; } BOOST_CHECK(cborMetadata.size() == 2); BOOST_CHECK(cborMetadata.count(hashMethod) == 1); - BOOST_CHECK(cborMetadata.at(hashMethod) == toHex(hash)); + BOOST_CHECK(cborMetadata.at(hashMethod) == util::toHex(hash)); } BOOST_CHECK(cborMetadata.count("solc") == 1); if (release) - BOOST_CHECK(cborMetadata.at("solc") == toHex(VersionCompactBytes)); + BOOST_CHECK(cborMetadata.at("solc") == util::toHex(VersionCompactBytes)); else BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict); } @@ -131,13 +127,13 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental) CompilerStack compilerStack; compilerStack.overwriteReleaseFlag(release); compilerStack.setSources({{"", std::string(sourceCode)}}); - compilerStack.setEVMVersion(dev::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(dev::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.setMetadataHash(metadataHash); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); bytes const& bytecode = compilerStack.runtimeObject("test").bytecode; std::string const& metadata = compilerStack.metadata("test"); - BOOST_CHECK(dev::test::isValidMetadata(metadata)); + BOOST_CHECK(solidity::test::isValidMetadata(metadata)); auto const cborMetadata = requireParsedCBORMetadata(bytecode); if (metadataHash == CompilerStack::MetadataHash::None) @@ -148,25 +144,25 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental) string hashMethod; if (metadataHash == CompilerStack::MetadataHash::IPFS) { - hash = dev::ipfsHash(metadata); + hash = util::ipfsHash(metadata); BOOST_REQUIRE(hash.size() == 34); hashMethod = "ipfs"; } else { - hash = dev::bzzr1Hash(metadata).asBytes(); + hash = util::bzzr1Hash(metadata).asBytes(); BOOST_REQUIRE(hash.size() == 32); hashMethod = "bzzr1"; } BOOST_CHECK(cborMetadata.size() == 3); BOOST_CHECK(cborMetadata.count(hashMethod) == 1); - BOOST_CHECK(cborMetadata.at(hashMethod) == toHex(hash)); + BOOST_CHECK(cborMetadata.at(hashMethod) == util::toHex(hash)); } BOOST_CHECK(cborMetadata.count("solc") == 1); if (release) - BOOST_CHECK(cborMetadata.at("solc") == toHex(VersionCompactBytes)); + BOOST_CHECK(cborMetadata.at("solc") == util::toHex(VersionCompactBytes)); else BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict); BOOST_CHECK(cborMetadata.count("experimental") == 1); @@ -193,14 +189,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources) {"A", std::string(sourceCodeA)}, {"B", std::string(sourceCodeB)}, }); - compilerStack.setEVMVersion(dev::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(dev::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("A"); - BOOST_CHECK(dev::test::isValidMetadata(serialisedMetadata)); + BOOST_CHECK(solidity::test::isValidMetadata(serialisedMetadata)); Json::Value metadata; - BOOST_REQUIRE(jsonParseStrict(serialisedMetadata, metadata)); + BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK_EQUAL(metadata["sources"].size(), 1); BOOST_CHECK(metadata["sources"].isMember("A")); @@ -234,14 +230,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports) {"B", std::string(sourceCodeB)}, {"C", std::string(sourceCodeC)} }); - compilerStack.setEVMVersion(dev::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(dev::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("C"); - BOOST_CHECK(dev::test::isValidMetadata(serialisedMetadata)); + BOOST_CHECK(solidity::test::isValidMetadata(serialisedMetadata)); Json::Value metadata; - BOOST_REQUIRE(jsonParseStrict(serialisedMetadata, metadata)); + BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK_EQUAL(metadata["sources"].size(), 3); BOOST_CHECK(metadata["sources"].isMember("A")); @@ -262,14 +258,14 @@ BOOST_AUTO_TEST_CASE(metadata_useLiteralContent) { CompilerStack compilerStack; compilerStack.setSources({{"", std::string(_src)}}); - compilerStack.setEVMVersion(dev::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(dev::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.useMetadataLiteralSources(_literal); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); string metadata_str = compilerStack.metadata("test"); Json::Value metadata; - jsonParseStrict(metadata_str, metadata); - BOOST_CHECK(dev::test::isValidMetadata(metadata_str)); + util::jsonParseStrict(metadata_str, metadata); + BOOST_CHECK(solidity::test::isValidMetadata(metadata_str)); BOOST_CHECK(metadata.isMember("settings")); BOOST_CHECK(metadata["settings"].isMember("metadata")); BOOST_CHECK(metadata["settings"]["metadata"].isMember("bytecodeHash")); @@ -297,9 +293,9 @@ BOOST_AUTO_TEST_CASE(metadata_revert_strings) BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("A"); - BOOST_CHECK(dev::test::isValidMetadata(serialisedMetadata)); + BOOST_CHECK(solidity::test::isValidMetadata(serialisedMetadata)); Json::Value metadata; - BOOST_REQUIRE(jsonParseStrict(serialisedMetadata, metadata)); + BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata)); BOOST_CHECK_EQUAL(metadata["settings"]["debug"]["revertStrings"], "strip"); } @@ -307,5 +303,3 @@ BOOST_AUTO_TEST_CASE(metadata_revert_strings) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 52ba30b3f..3cf0c73f5 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -26,13 +26,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class SMTCheckerFramework: public AnalysisFramework @@ -87,7 +83,7 @@ BOOST_AUTO_TEST_CASE(import_base) } )"} }); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); unsigned asserts = 0; @@ -126,7 +122,7 @@ BOOST_AUTO_TEST_CASE(import_library) } )"} }); - c.setEVMVersion(dev::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(c.compile()); unsigned asserts = 0; @@ -145,5 +141,3 @@ BOOST_AUTO_TEST_CASE(import_library) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/SMTCheckerJSONTest.cpp b/test/libsolidity/SMTCheckerJSONTest.cpp index 59425b6a5..7758a2437 100644 --- a/test/libsolidity/SMTCheckerJSONTest.cpp +++ b/test/libsolidity/SMTCheckerJSONTest.cpp @@ -29,11 +29,12 @@ #include #include -using namespace dev::solidity::test; -using namespace dev::solidity; -using namespace dev::formatting; -using namespace dev; using namespace std; +using namespace solidity; +using namespace solidity::frontend; +using namespace solidity::frontend::test; +using namespace solidity::util; +using namespace solidity::util::formatting; using namespace boost::unit_test; SMTCheckerJSONTest::SMTCheckerJSONTest(string const& _filename, langutil::EVMVersion _evmVersion) diff --git a/test/libsolidity/SMTCheckerJSONTest.h b/test/libsolidity/SMTCheckerJSONTest.h index 027e87418..8d40c1ee8 100644 --- a/test/libsolidity/SMTCheckerJSONTest.h +++ b/test/libsolidity/SMTCheckerJSONTest.h @@ -23,11 +23,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class SMTCheckerJSONTest: public SyntaxTest @@ -49,5 +45,3 @@ private: }; } -} -} diff --git a/test/libsolidity/SMTCheckerTest.cpp b/test/libsolidity/SMTCheckerTest.cpp index 3b9532c03..47ed43ba5 100644 --- a/test/libsolidity/SMTCheckerTest.cpp +++ b/test/libsolidity/SMTCheckerTest.cpp @@ -20,11 +20,11 @@ #include -using namespace langutil; -using namespace dev::solidity; -using namespace dev::solidity::test; -using namespace dev; using namespace std; +using namespace solidity; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::frontend::test; SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion _evmVersion): SyntaxTest(_filename, _evmVersion) { diff --git a/test/libsolidity/SMTCheckerTest.h b/test/libsolidity/SMTCheckerTest.h index e48a587f1..ce28409e6 100644 --- a/test/libsolidity/SMTCheckerTest.h +++ b/test/libsolidity/SMTCheckerTest.h @@ -23,11 +23,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class SMTCheckerTest: public SyntaxTest @@ -51,5 +47,3 @@ protected: }; } -} -} diff --git a/test/libsolidity/SemVerMatcher.cpp b/test/libsolidity/SemVerMatcher.cpp index e0e643968..9b344a435 100644 --- a/test/libsolidity/SemVerMatcher.cpp +++ b/test/libsolidity/SemVerMatcher.cpp @@ -28,13 +28,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_AUTO_TEST_SUITE(SemVerMatcher) @@ -238,6 +234,4 @@ BOOST_AUTO_TEST_CASE(negative_range) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index ceb1db2ba..4082a6ab8 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -25,11 +25,11 @@ #include #include -using namespace dev; -using namespace solidity; -using namespace dev::solidity::test; -using namespace dev::formatting; using namespace std; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::util::formatting; +using namespace solidity::frontend::test; using namespace boost; using namespace boost::algorithm; using namespace boost::unit_test; @@ -78,7 +78,7 @@ TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePref for (auto& test: m_tests) test.reset(); - map libraries; + map libraries; bool constructed = false; @@ -190,7 +190,7 @@ void SemanticTest::parseExpectations(istream& _stream) std::move(functionCalls.begin(), functionCalls.end(), back_inserter(m_tests)); } -bool SemanticTest::deploy(string const& _contractName, u256 const& _value, bytes const& _arguments, map const& _libraries) +bool SemanticTest::deploy(string const& _contractName, u256 const& _value, bytes const& _arguments, map const& _libraries) { auto output = compileAndRunWithoutCheck(m_source, _value, _contractName, _arguments, _libraries); return !output.empty() && m_transactionSuccessful; diff --git a/test/libsolidity/SemanticTest.h b/test/libsolidity/SemanticTest.h index 71e03518b..b885b1565 100644 --- a/test/libsolidity/SemanticTest.h +++ b/test/libsolidity/SemanticTest.h @@ -27,11 +27,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { /** @@ -60,7 +56,7 @@ public: /// Compiles and deploys currently held source. /// Returns true if deployment was successful, false otherwise. - bool deploy(std::string const& _contractName, u256 const& _value, bytes const& _arguments, std::map const& _libraries = {}); + bool deploy(std::string const& _contractName, u256 const& _value, bytes const& _arguments, std::map const& _libraries = {}); private: std::string m_source; @@ -71,5 +67,3 @@ private: }; } -} -} diff --git a/test/libsolidity/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp index 8d8405f8b..142033556 100644 --- a/test/libsolidity/SolidityCompiler.cpp +++ b/test/libsolidity/SolidityCompiler.cpp @@ -24,11 +24,7 @@ using namespace std; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_FIXTURE_TEST_SUITE(SolidityCompiler, AnalysisFramework) @@ -42,11 +38,11 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions) function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; } } )"; - compiler().setOptimiserSettings(dev::test::Options::get().optimize); + compiler().setOptimiserSettings(solidity::test::Options::get().optimize); BOOST_REQUIRE(success(sourceCode)); BOOST_REQUIRE_MESSAGE(compiler().compile(), "Compiling contract failed"); - bytes const& creationBytecode = dev::test::bytecodeSansMetadata(compiler().object("C").bytecode); - bytes const& runtimeBytecode = dev::test::bytecodeSansMetadata(compiler().runtimeObject("C").bytecode); + bytes const& creationBytecode = solidity::test::bytecodeSansMetadata(compiler().object("C").bytecode); + bytes const& runtimeBytecode = solidity::test::bytecodeSansMetadata(compiler().runtimeObject("C").bytecode); BOOST_CHECK(creationBytecode.size() >= 90); BOOST_CHECK(creationBytecode.size() <= 120); BOOST_CHECK(runtimeBytecode.size() >= 10); @@ -56,5 +52,3 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c1ed1d67e..e8d29755b 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -42,8 +42,10 @@ using namespace std; using namespace std::placeholders; -using namespace dev::test; -using namespace langutil; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::test; +using namespace solidity::langutil; #define ALSO_VIA_YUL(CODE) \ { \ @@ -52,11 +54,7 @@ using namespace langutil; { CODE } \ } -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_FIXTURE_TEST_SUITE(SolidityEndToEndTest, SolidityExecutionFramework) @@ -1081,8 +1079,8 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors) compileAndRun(sourceCode); ABI_CHECK(callContractFunction("data()"), encodeArgs(8)); ABI_CHECK(callContractFunction("name()"), encodeArgs("Celina")); - ABI_CHECK(callContractFunction("a_hash()"), encodeArgs(dev::keccak256(bytes(1, 0x7b)))); - ABI_CHECK(callContractFunction("an_address()"), encodeArgs(toBigEndian(u160(0x1337)))); + ABI_CHECK(callContractFunction("a_hash()"), encodeArgs(util::keccak256(bytes(1, 0x7b)))); + ABI_CHECK(callContractFunction("an_address()"), encodeArgs(util::toBigEndian(u160(0x1337)))); ABI_CHECK(callContractFunction("super_secret_data()"), bytes()); ); } @@ -1136,7 +1134,7 @@ BOOST_AUTO_TEST_CASE(msg_sig) )"; ALSO_VIA_YUL( compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(dev::keccak256("foo(uint256)")).asBytes()))); + ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(util::keccak256("foo(uint256)")).asBytes()))); ) } @@ -1154,7 +1152,7 @@ BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same) )"; ALSO_VIA_YUL( compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(dev::keccak256("foo(uint256)")).asBytes()))); + ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(util::keccak256("foo(uint256)")).asBytes()))); ) } @@ -1391,7 +1389,7 @@ BOOST_AUTO_TEST_CASE(keccak256) compileAndRun(sourceCode); auto f = [&](u256 const& _x) -> u256 { - return dev::keccak256(toBigEndian(_x)); + return util::keccak256(toBigEndian(_x)); }; testContractAgainstCpp("a(bytes32)", f, u256(4)); testContractAgainstCpp("a(bytes32)", f, u256(5)); @@ -1462,7 +1460,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256) compileAndRun(sourceCode); auto f = [&](u256 const& _x) -> u256 { - return dev::keccak256( + return util::keccak256( toCompactBigEndian(unsigned(8)) + toBigEndian(_x) + toCompactBigEndian(unsigned(65536)) + @@ -1494,9 +1492,9 @@ BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types) compileAndRun(sourceCode); // Strangely, arrays are encoded with intra-element padding. ABI_CHECK(callContractFunction("f()"), encodeArgs( - dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))), - dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))), - dev::keccak256(fromHex(m_contractAddress.hex() + "26121ff0")) + util::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))), + util::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))), + util::keccak256(fromHex(m_contractAddress.hex() + "26121ff0")) )); } @@ -2508,7 +2506,7 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws) compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f()"), encodeArgs(0)); - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"YY( contract A { @@ -2549,7 +2547,7 @@ BOOST_AUTO_TEST_CASE(event) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK_EQUAL(h256(logData(0)), h256(u256(value))); BOOST_REQUIRE_EQUAL(numLogTopics(0), 3); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256)"))); BOOST_CHECK_EQUAL(logTopic(0, 1), h256(m_sender, h256::AlignRight)); BOOST_CHECK_EQUAL(logTopic(0, 2), h256(id)); } @@ -2574,7 +2572,7 @@ BOOST_AUTO_TEST_CASE(event_emit) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK_EQUAL(h256(logData(0)), h256(u256(value))); BOOST_REQUIRE_EQUAL(numLogTopics(0), 3); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256)"))); BOOST_CHECK_EQUAL(logTopic(0, 1), h256(m_sender, h256::AlignRight)); BOOST_CHECK_EQUAL(logTopic(0, 2), h256(id)); ) @@ -2598,7 +2596,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0).empty()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit()"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit()"))); ) } @@ -2621,7 +2619,7 @@ BOOST_AUTO_TEST_CASE(event_access_through_base_name_emit) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0).empty()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("x()"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("x()"))); } BOOST_AUTO_TEST_CASE(events_with_same_name) @@ -2659,28 +2657,28 @@ BOOST_AUTO_TEST_CASE(events_with_same_name) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0).empty()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit()"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit()"))); ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(2))); BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); ABI_CHECK(logData(0), encodeArgs(c_loggedAddress)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address)"))); ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(3))); BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); ABI_CHECK(logData(0), encodeArgs(c_loggedAddress, 100)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,uint256)"))); ABI_CHECK(callContractFunction("deposit(address,bool)", c_loggedAddress, false), encodeArgs(u256(4))); BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); ABI_CHECK(logData(0), encodeArgs(c_loggedAddress, false)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bool)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bool)"))); ) } @@ -2720,21 +2718,21 @@ BOOST_AUTO_TEST_CASE(events_with_same_name_inherited_emit) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0).empty()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit()"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit()"))); ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(1))); BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(c_loggedAddress)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address)"))); ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(1))); BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); ABI_CHECK(logData(0), encodeArgs(c_loggedAddress, 100)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,uint256)"))); ) } @@ -2800,7 +2798,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs((u160)m_sender, id, value, true)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256,bool)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256,bool)"))); ) } @@ -2818,9 +2816,9 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data) callContractFunction("deposit()"); BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); - BOOST_CHECK_EQUAL(toHex(logData(0)), toHex(encodeArgs(10, 0x60, 15, 4, asString(FixedHash<4>(dev::keccak256("deposit()")).asBytes())))); + BOOST_CHECK_EQUAL(toHex(logData(0)), toHex(encodeArgs(10, 0x60, 15, 4, asString(FixedHash<4>(util::keccak256("deposit()")).asBytes())))); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(uint256,bytes,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(uint256,bytes,uint256)"))); } BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage) @@ -2843,7 +2841,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK_EQUAL(toHex(logData(0)), toHex(encodeArgs(10, 0x60, 15, 3, string("ABC")))); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(uint256,bytes,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(uint256,bytes,uint256)"))); } BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage) @@ -2868,7 +2866,7 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(10, 0x60, 15, 31, string("ABC") + string(27, 0) + "Z")); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(uint256,bytes,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(uint256,bytes,uint256)"))); } BOOST_AUTO_TEST_CASE(event_struct_memory_v2) @@ -2890,7 +2888,7 @@ BOOST_AUTO_TEST_CASE(event_struct_memory_v2) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(x)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint256))"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint256))"))); } BOOST_AUTO_TEST_CASE(event_struct_storage_v2) @@ -2914,7 +2912,7 @@ BOOST_AUTO_TEST_CASE(event_struct_storage_v2) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(x)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint256))"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint256))"))); } BOOST_AUTO_TEST_CASE(event_dynamic_array_memory) @@ -2938,7 +2936,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_memory) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])"))); } BOOST_AUTO_TEST_CASE(event_dynamic_array_memory_v2) @@ -2963,7 +2961,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_memory_v2) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])"))); } BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_memory_v2) @@ -2991,7 +2989,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_memory_v2) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(0x20, 2, 0x40, 0xa0, 2, x, x + 1, 2, x + 2, x + 3)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[][])"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[][])"))); } BOOST_AUTO_TEST_CASE(event_dynamic_array_storage) @@ -3018,7 +3016,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_storage) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])"))); ) } @@ -3047,7 +3045,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_storage_v2) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])"))); ) } @@ -3078,7 +3076,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_storage_v2) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(0x20, 2, 0x40, 0xa0, 2, x, x + 1, 2, x + 2, x + 3)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[][])"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[][])"))); } BOOST_AUTO_TEST_CASE(event_indexed_string) @@ -3110,11 +3108,11 @@ BOOST_AUTO_TEST_CASE(event_indexed_string) dynx[i] = i; BOOST_CHECK(logData(0) == bytes()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 3); - BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(dynx)); - BOOST_CHECK_EQUAL(logTopic(0, 2), dev::keccak256( + BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(dynx)); + BOOST_CHECK_EQUAL(logTopic(0, 2), util::keccak256( encodeArgs(u256(4), u256(5), u256(6), u256(7)) )); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(string,uint256[4])"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(string,uint256[4])"))); } BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) @@ -3204,7 +3202,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments) compileAndRun(sourceCode); ABI_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13), encodeArgs( - dev::keccak256( + util::keccak256( toBigEndian(u256(10)) + toBigEndian(u256(12)) + toBigEndian(u256(13)) @@ -3225,7 +3223,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_numeric_literals) compileAndRun(sourceCode); ABI_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12), encodeArgs( - dev::keccak256( + util::keccak256( toBigEndian(u256(10)) + bytes{0x0, 0xc} + bytes(1, 0x91) @@ -3249,10 +3247,10 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_string_literals) )"; compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("foo()"), encodeArgs(dev::keccak256("foo"))); + ABI_CHECK(callContractFunction("foo()"), encodeArgs(util::keccak256("foo"))); ABI_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12), encodeArgs( - dev::keccak256( + util::keccak256( toBigEndian(u256(10)) + bytes{0x0, 0xc} + bytes(1, 0x91) + @@ -3295,7 +3293,7 @@ BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes) )ABC"; compileAndRun(sourceCode); ABI_CHECK(callContractFunction("foo()"), encodeArgs( - u256(dev::keccak256(bytes{'b'} + dev::keccak256("xyz").asBytes() + bytes{'a'})) + u256(util::keccak256(bytes{'b'} + util::keccak256("xyz").asBytes() + bytes{'a'})) )); } @@ -3373,7 +3371,7 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall) BOOST_AUTO_TEST_CASE(generic_staticcall) { - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"**( contract A { @@ -3518,10 +3516,10 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory) } )"; compileAndRun(sourceCode); - bytes calldata1 = FixedHash<4>(dev::keccak256("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12); + bytes calldata1 = FixedHash<4>(util::keccak256("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12); sendMessage(calldata1, false); BOOST_CHECK(m_transactionSuccessful); - BOOST_CHECK(m_output == encodeArgs(dev::keccak256(bytes{'a', 'b', 'c'} + calldata1))); + BOOST_CHECK(m_output == encodeArgs(util::keccak256(bytes{'a', 'b', 'c'} + calldata1))); } BOOST_AUTO_TEST_CASE(call_forward_bytes) @@ -3914,7 +3912,7 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean) BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_CHECK(logData(0) == encodeArgs(1)); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Ev(bool)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Ev(bool)"))); } @@ -4185,8 +4183,8 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments) )"; compileAndRun(sourceCode); - string innercalldata1 = asString(FixedHash<4>(dev::keccak256("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9)); - string innercalldata2 = asString(FixedHash<4>(dev::keccak256("g(uint256)")).asBytes() + encodeArgs(3)); + string innercalldata1 = asString(FixedHash<4>(util::keccak256("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9)); + string innercalldata2 = asString(FixedHash<4>(util::keccak256("g(uint256)")).asBytes() + encodeArgs(3)); bytes calldata = encodeArgs( 12, 32 * 4, u256(32 * 4 + 32 + (innercalldata1.length() + 31) / 32 * 32), 13, u256(innercalldata1.length()), innercalldata1, @@ -5477,7 +5475,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_keccak) } )"; compileAndRun(sourceCode); - ABI_CHECK(callContractFunction("f()"), encodeArgs(dev::keccak256("abc"))); + ABI_CHECK(callContractFunction("f()"), encodeArgs(util::keccak256("abc"))); } // Disabled until https://github.com/ethereum/solidity/issues/715 is implemented @@ -5759,7 +5757,7 @@ BOOST_AUTO_TEST_CASE(bool_conversion) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(bool)", 0), encodeArgs(0)); ABI_CHECK(callContractFunction("f(bool)", 1), encodeArgs(1)); ABI_CHECK(callContractFunction("f(bool)", 2), v2 ? encodeArgs() : encodeArgs(1)); @@ -5874,7 +5872,7 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged) BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_REQUIRE_EQUAL(numLogTopics(0), 1); - BOOST_REQUIRE_EQUAL(logTopic(0, 0), dev::keccak256(string("Log(uint8)"))); + BOOST_REQUIRE_EQUAL(logTopic(0, 0), util::keccak256(string("Log(uint8)"))); BOOST_CHECK_EQUAL(h256(logData(0)), h256(u256(0))); // should throw @@ -6205,7 +6203,7 @@ BOOST_AUTO_TEST_CASE(reusing_memory) } )"; compileAndRun(sourceCode, 0, "Main"); - BOOST_REQUIRE(callContractFunction("f(uint256)", 0x34) == encodeArgs(dev::keccak256(dev::toBigEndian(u256(0x34))))); + BOOST_REQUIRE(callContractFunction("f(uint256)", 0x34) == encodeArgs(util::keccak256(util::toBigEndian(u256(0x34))))); } BOOST_AUTO_TEST_CASE(return_string) @@ -7235,8 +7233,8 @@ BOOST_AUTO_TEST_CASE(calldata_struct_function_type) )"; compileAndRun(sourceCode, 0, "C"); - bytes fn_C_g = m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("g(uint256)")).asBytes() + bytes(8,0); - bytes fn_C_h = m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("h(uint256)")).asBytes() + bytes(8,0); + bytes fn_C_g = m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("g(uint256)")).asBytes() + bytes(8,0); + bytes fn_C_h = m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("h(uint256)")).asBytes() + bytes(8,0); ABI_CHECK(callContractFunctionNoEncoding("f((function))", fn_C_g), encodeArgs(42 * 3)); ABI_CHECK(callContractFunctionNoEncoding("f((function))", fn_C_h), encodeArgs(23)); } @@ -10020,7 +10018,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types) )"; compileAndRun(sourceCode, 0, "C"); // We input longer data on purpose. - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(bytes2,uint16)", string("abc"), u256(0x040102)), v2 ? encodeArgs() : encodeArgs(0)); } BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening) @@ -10057,7 +10055,7 @@ BOOST_AUTO_TEST_CASE(cleanup_address_types) )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; // We input longer data on purpose. ABI_CHECK(callContractFunction("f(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0)); ABI_CHECK(callContractFunction("g(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0)); @@ -10665,7 +10663,7 @@ BOOST_AUTO_TEST_CASE(receive_external_function_type) compileAndRun(sourceCode, 0, "C"); ABI_CHECK(callContractFunction( "f(function)", - m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0) + m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0) ), encodeArgs(u256(7))); } @@ -10683,7 +10681,7 @@ BOOST_AUTO_TEST_CASE(return_external_function_type) compileAndRun(sourceCode, 0, "C"); ABI_CHECK( callContractFunction("f()"), - m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0) + m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0) ); } @@ -11310,7 +11308,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(0xf))); ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(0x1004)), v2 ? encodeArgs() : encodeArgs(u256(0xf))); } @@ -11336,7 +11334,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled_signed) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(3)), encodeArgs(u256(-2))); ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(-1))); ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0xFF)), encodeArgs(u256(-1))); @@ -11530,7 +11528,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103))); ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52))); ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); @@ -11548,7 +11546,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103))); ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52))); ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); @@ -11566,7 +11564,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = dev::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::Options::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103))); ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52))); ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); @@ -12094,7 +12092,7 @@ BOOST_AUTO_TEST_CASE(revert_with_cause) } } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12168,7 +12166,7 @@ BOOST_AUTO_TEST_CASE(require_with_message) } } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12214,7 +12212,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages) } } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12252,7 +12250,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer) } } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12291,7 +12289,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create) } } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12496,7 +12494,7 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address) ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1))); ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1))); - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"YY( contract C { @@ -12512,10 +12510,10 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address) BOOST_AUTO_TEST_CASE(bare_call_return_data) { - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { vector calltypes = {"call", "delegatecall"}; - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) calltypes.emplace_back("staticcall"); for (string const& calltype: calltypes) { @@ -12639,7 +12637,7 @@ BOOST_AUTO_TEST_CASE(bare_call_return_data) BOOST_AUTO_TEST_CASE(delegatecall_return_value) { - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { char const* sourceCode = R"DELIMITER( contract C { @@ -12735,10 +12733,10 @@ BOOST_AUTO_TEST_CASE(function_types_sig) } )"; compileAndRun(sourceCode, 0, "C"); - ABI_CHECK(callContractFunction("f()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes()))); - ABI_CHECK(callContractFunction("g()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes()))); - ABI_CHECK(callContractFunction("h()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes()))); - ABI_CHECK(callContractFunction("i()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("x()")).asBytes()))); + ABI_CHECK(callContractFunction("f()"), encodeArgs(asString(FixedHash<4>(util::keccak256("f()")).asBytes()))); + ABI_CHECK(callContractFunction("g()"), encodeArgs(asString(FixedHash<4>(util::keccak256("f()")).asBytes()))); + ABI_CHECK(callContractFunction("h()"), encodeArgs(asString(FixedHash<4>(util::keccak256("f()")).asBytes()))); + ABI_CHECK(callContractFunction("i()"), encodeArgs(asString(FixedHash<4>(util::keccak256("x()")).asBytes()))); } BOOST_AUTO_TEST_CASE(constant_string) @@ -13149,12 +13147,12 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_structs) bytes structEnc = encodeArgs(int(0x12), u256(-7), int(2), int(3), u256(-7), u256(-8)); ABI_CHECK(callContractFunction("testStorage()"), encodeArgs()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 2); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16,uint8[2],int16[]))"))); - BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(structEnc))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16,uint8[2],int16[]))"))); + BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(structEnc))); ABI_CHECK(callContractFunction("testMemory()"), encodeArgs()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 2); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16,uint8[2],int16[]))"))); - BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(structEnc))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16,uint8[2],int16[]))"))); + BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(structEnc))); } BOOST_AUTO_TEST_CASE(abi_encodePackedV2_nestedArray) @@ -13182,8 +13180,8 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_nestedArray) bytes structEnc = encodeArgs(1, 2, 3, 0, 0, 0, 0, 4); ABI_CHECK(callContractFunction("testNestedArrays()"), encodeArgs()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 2); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16)[2][][3])"))); - BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(structEnc))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16)[2][][3])"))); + BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(structEnc))); } BOOST_AUTO_TEST_CASE(abi_encodePackedV2_arrayOfStrings) @@ -13210,12 +13208,12 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_arrayOfStrings) bytes arrayEncoding = encodeArgs("abc", "0123456789012345678901234567890123456789"); ABI_CHECK(callContractFunction("testStorage()"), encodeArgs()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 2); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(string[])"))); - BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(arrayEncoding))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(string[])"))); + BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(arrayEncoding))); ABI_CHECK(callContractFunction("testMemory()"), encodeArgs()); BOOST_REQUIRE_EQUAL(numLogTopics(0), 2); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(string[])"))); - BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(arrayEncoding))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(string[])"))); + BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(arrayEncoding))); } BOOST_AUTO_TEST_CASE(event_signature_in_library) @@ -13243,7 +13241,7 @@ BOOST_AUTO_TEST_CASE(event_signature_in_library) )"; compileAndRun(sourceCode, 0, "C"); BOOST_REQUIRE_EQUAL(numLogTopics(0), 2); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16),(uint8,int16))"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16),(uint8,int16))"))); } @@ -13440,7 +13438,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_empty_string) )"; compileAndRun(sourceCode, 0, "C"); - if (!dev::test::Options::get().useABIEncoderV2) + if (!solidity::test::Options::get().useABIEncoderV2) { // ABI Encoder V2 has slightly different padding, tested below. ABI_CHECK(callContractFunction("f()"), encodeArgs( @@ -13564,7 +13562,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) compileAndRun(sourceCode, 0, "D"); // This should work (called via CALL) ABI_CHECK(callContractFunction("f()"), encodeArgs(1)); - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) { // These should throw (called via STATICCALL) ABI_CHECK(callContractFunction("fview()"), encodeArgs()); @@ -13579,7 +13577,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople) { - if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) return; char const* sourceCode = R"( contract C { @@ -13618,7 +13616,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople) BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) { - if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) return; char const* sourceCode = R"( contract C { @@ -13685,7 +13683,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined) { - if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) return; char const* sourceCode = R"( contract C { @@ -14324,7 +14322,7 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name) BOOST_REQUIRE_EQUAL(numLogs(), 1); BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress); BOOST_REQUIRE_EQUAL(numLogTopics(0), 3); - BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256)"))); + BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256)"))); } BOOST_AUTO_TEST_CASE(uninitialized_internal_storage_function) @@ -14441,7 +14439,7 @@ BOOST_AUTO_TEST_CASE(try_catch_library_call) } } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "L", bytes()); compileAndRun(sourceCode, 0, "C", bytes(), map{{"L", m_contractAddress}}); @@ -14504,6 +14502,4 @@ BOOST_AUTO_TEST_CASE(strip_reason_strings) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index 237692124..27deb4d23 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -24,10 +24,10 @@ #include #include -using namespace dev; -using namespace dev::test; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::test; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; bytes SolidityExecutionFramework::compileContract( @@ -39,7 +39,7 @@ bytes SolidityExecutionFramework::compileContract( // Silence compiler version warning std::string sourceCode = "pragma solidity >=0.0;\n"; if ( - dev::test::Options::get().useABIEncoderV2 && + solidity::test::Options::get().useABIEncoderV2 && _sourceCode.find("pragma experimental ABIEncoderV2;") == std::string::npos ) sourceCode += "pragma experimental ABIEncoderV2;\n"; diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h index dee8cdc6f..28246a26c 100644 --- a/test/libsolidity/SolidityExecutionFramework.h +++ b/test/libsolidity/SolidityExecutionFramework.h @@ -33,15 +33,10 @@ #include #include -namespace dev -{ -namespace solidity +namespace solidity::frontend::test { -namespace test -{ - -class SolidityExecutionFramework: public dev::test::ExecutionFramework +class SolidityExecutionFramework: public solidity::test::ExecutionFramework { public: @@ -55,7 +50,7 @@ public: u256 const& _value = 0, std::string const& _contractName = "", bytes const& _arguments = bytes(), - std::map const& _libraryAddresses = std::map() + std::map const& _libraryAddresses = std::map() ) override { bytes bytecode = compileContract(_sourceCode, _contractName, _libraryAddresses); @@ -66,15 +61,13 @@ public: bytes compileContract( std::string const& _sourceCode, std::string const& _contractName = "", - std::map const& _libraryAddresses = std::map() + std::map const& _libraryAddresses = std::map() ); protected: - dev::solidity::CompilerStack m_compiler; + solidity::frontend::CompilerStack m_compiler; bool m_compileViaYul = false; }; -} -} } // end namespaces diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 00082c279..1a7fa4ce8 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -34,14 +34,10 @@ #include using namespace std; -using namespace dev::eth; -using namespace langutil; +using namespace solidity::evmasm; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -102,7 +98,7 @@ bytes compileFirstExpression( { ErrorList errors; ErrorReporter errorReporter(errors); - sourceUnit = Parser(errorReporter, dev::test::Options::get().evmVersion()).parse( + sourceUnit = Parser(errorReporter, solidity::test::Options::get().evmVersion()).parse( make_shared(CharStream(_sourceCode, "")) ); if (!sourceUnit) @@ -118,7 +114,7 @@ bytes compileFirstExpression( ErrorReporter errorReporter(errors); GlobalContext globalContext; map> scopes; - NameAndTypeResolver resolver(globalContext, dev::test::Options::get().evmVersion(), scopes, errorReporter); + NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter); resolver.registerDeclarations(*sourceUnit); vector inheritanceHierarchy; @@ -132,7 +128,7 @@ bytes compileFirstExpression( if (ContractDefinition* contract = dynamic_cast(node.get())) { ErrorReporter errorReporter(errors); - TypeChecker typeChecker(dev::test::Options::get().evmVersion(), errorReporter); + TypeChecker typeChecker(solidity::test::Options::get().evmVersion(), errorReporter); BOOST_REQUIRE(typeChecker.checkTypeRequirements(*contract)); } for (ASTPointer const& node: sourceUnit->nodes()) @@ -141,7 +137,7 @@ bytes compileFirstExpression( FirstExpressionExtractor extractor(*contract); BOOST_REQUIRE(extractor.expression() != nullptr); - CompilerContext context(dev::test::Options::get().evmVersion()); + CompilerContext context(solidity::test::Options::get().evmVersion()); context.resetVisitedNodes(contract); context.setInheritanceHierarchy(inheritanceHierarchy); unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack @@ -155,7 +151,7 @@ bytes compileFirstExpression( ExpressionCompiler( context, RevertStrings::Default, - dev::test::Options::get().optimize + solidity::test::Options::get().optimize ).compile(*extractor.expression()); for (vector const& function: _functions) @@ -286,7 +282,7 @@ BOOST_AUTO_TEST_CASE(comparison) bytes code = compileFirstExpression(sourceCode); bytes expectation; - if (dev::test::Options::get().optimize) + if (solidity::test::Options::get().optimize) expectation = { uint8_t(Instruction::PUSH2), 0x11, 0xaa, uint8_t(Instruction::PUSH2), 0x10, 0xaa, @@ -349,7 +345,7 @@ BOOST_AUTO_TEST_CASE(arithmetic) bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes expectation; - if (dev::test::Options::get().optimize) + if (solidity::test::Options::get().optimize) expectation = { uint8_t(Instruction::PUSH1), 0x2, uint8_t(Instruction::PUSH1), 0x3, @@ -430,7 +426,7 @@ BOOST_AUTO_TEST_CASE(unary_operators) bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes expectation; - if (dev::test::Options::get().optimize) + if (solidity::test::Options::get().optimize) expectation = { uint8_t(Instruction::DUP1), uint8_t(Instruction::PUSH1), 0x0, @@ -521,7 +517,7 @@ BOOST_AUTO_TEST_CASE(assignment) // Stack: a, b bytes expectation; - if (dev::test::Options::get().optimize) + if (solidity::test::Options::get().optimize) expectation = { uint8_t(Instruction::DUP1), uint8_t(Instruction::DUP3), @@ -633,7 +629,7 @@ BOOST_AUTO_TEST_CASE(selfbalance) bytes code = compileFirstExpression(sourceCode, {}, {}); - if (dev::test::Options::get().evmVersion() == EVMVersion::istanbul()) + if (solidity::test::Options::get().evmVersion() == EVMVersion::istanbul()) { bytes expectation({uint8_t(Instruction::SELFBALANCE)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); @@ -642,6 +638,4 @@ BOOST_AUTO_TEST_CASE(selfbalance) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index d22d1880f..3baa740b4 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -33,13 +33,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_FIXTURE_TEST_SUITE(SolidityNameAndTypeResolution, AnalysisFramework) @@ -365,7 +361,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) } } )"; - if (dev::test::Options::get().evmVersion() == EVMVersion::homestead()) + if (solidity::test::Options::get().evmVersion() == EVMVersion::homestead()) CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type string memory."); else CHECK_SUCCESS_NO_WARNINGS(sourceCode); @@ -390,7 +386,7 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable) vector> expectations(vector>{ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} }); - if (!dev::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::Options::get().evmVersion().supportsReturndata()) expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible VMs"))); CHECK_ALLOW_MULTI(text, expectations); } @@ -405,7 +401,7 @@ BOOST_AUTO_TEST_CASE(create2_as_variable) vector> expectations(vector>{ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} }); - if (!dev::test::Options::get().evmVersion().hasCreate2()) + if (!solidity::test::Options::get().evmVersion().hasCreate2()) expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"create2\" instruction is only available for Constantinople-compatible VMs"))); CHECK_ALLOW_MULTI(text, expectations); } @@ -420,7 +416,7 @@ BOOST_AUTO_TEST_CASE(extcodehash_as_variable) vector> expectations(vector>{ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} }); - if (!dev::test::Options::get().evmVersion().hasExtCodeHash()) + if (!solidity::test::Options::get().evmVersion().hasExtCodeHash()) expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"extcodehash\" instruction is only available for Constantinople-compatible VMs"))); CHECK_ALLOW_MULTI(text, expectations); } @@ -456,7 +452,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall) } )"; - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) CHECK_SUCCESS_NO_WARNINGS(sourceCode); else CHECK_ERROR(sourceCode, TypeError, "\"staticcall\" is not supported by the VM version."); @@ -464,7 +460,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall) BOOST_AUTO_TEST_CASE(address_staticcall_value) { - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"( contract C { @@ -488,7 +484,7 @@ BOOST_AUTO_TEST_CASE(address_call_full_return_type) } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) CHECK_SUCCESS_NO_WARNINGS(sourceCode); else CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory."); @@ -505,7 +501,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type) } )"; - if (dev::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::Options::get().evmVersion().supportsReturndata()) CHECK_SUCCESS_NO_WARNINGS(sourceCode); else CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory."); @@ -514,7 +510,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type) BOOST_AUTO_TEST_CASE(address_staticcall_full_return_type) { - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"( contract C { @@ -531,6 +527,4 @@ BOOST_AUTO_TEST_CASE(address_staticcall_full_return_type) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 435ff7f08..d59b59685 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -27,13 +27,9 @@ #include #include -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class DocumentationChecker @@ -48,7 +44,7 @@ public: { m_compilerStack.reset(); m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}}); - m_compilerStack.setEVMVersion(dev::test::Options::get().evmVersion()); + m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed"); Json::Value generatedDocumentation; @@ -57,7 +53,7 @@ public: else generatedDocumentation = m_compilerStack.natspecDev(_contractName); Json::Value expectedDocumentation; - jsonParseStrict(_expectedDocumentationString, expectedDocumentation); + util::jsonParseStrict(_expectedDocumentationString, expectedDocumentation); BOOST_CHECK_MESSAGE( expectedDocumentation == generatedDocumentation, "Expected:\n" << expectedDocumentation.toStyledString() << @@ -69,7 +65,7 @@ public: { m_compilerStack.reset(); m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}}); - m_compilerStack.setEVMVersion(dev::test::Options::get().evmVersion()); + m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); BOOST_CHECK(!m_compilerStack.parseAndAnalyze()); BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError)); } @@ -979,5 +975,3 @@ BOOST_AUTO_TEST_CASE(dev_constructor_and_function) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index fe7537936..fec67f0e6 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -33,14 +33,11 @@ #include using namespace std; -using namespace dev::eth; -using namespace dev::test; +using namespace solidity::util; +using namespace solidity::evmasm; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { class OptimizerTestFramework: public SolidityExecutionFramework @@ -714,6 +711,4 @@ BOOST_AUTO_TEST_CASE(shift_optimizer_bug) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 1b6c0de35..6a0c9efbd 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -30,13 +30,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -46,7 +42,7 @@ ASTPointer parseText(std::string const& _source, ErrorList& ErrorReporter errorReporter(_errors); ASTPointer sourceUnit = Parser( errorReporter, - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), errorRecovery ).parse(std::make_shared(CharStream(_source, ""))); if (!sourceUnit) @@ -694,6 +690,4 @@ BOOST_AUTO_TEST_CASE(inline_asm_end_location) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp index 5d97ee988..a80ef8b5c 100644 --- a/test/libsolidity/SolidityScanner.cpp +++ b/test/libsolidity/SolidityScanner.cpp @@ -24,13 +24,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_AUTO_TEST_SUITE(SolidityScanner) @@ -666,6 +662,4 @@ BOOST_AUTO_TEST_CASE(irregular_line_breaks_in_strings) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp index 419ac5606..0701b8187 100644 --- a/test/libsolidity/SolidityTypes.cpp +++ b/test/libsolidity/SolidityTypes.cpp @@ -27,13 +27,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_AUTO_TEST_SUITE(SolidityTypes) @@ -274,7 +270,7 @@ BOOST_AUTO_TEST_CASE(helper_bool_result) BOOST_AUTO_TEST_CASE(helper_string_result) { - using StringResult = Result; + using StringResult = util::Result; StringResult r1{string{"Success"}}; StringResult r2 = StringResult::err("Failure"); @@ -291,5 +287,3 @@ BOOST_AUTO_TEST_CASE(helper_string_result) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 2664c5851..8b354d9a3 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -27,13 +27,9 @@ #include using namespace std; -using namespace dev::eth; +using namespace solidity::evmasm; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { namespace @@ -89,7 +85,7 @@ Json::Value compile(string _input) StandardCompiler compiler; string output = compiler.compile(std::move(_input)); Json::Value ret; - BOOST_REQUIRE(jsonParseStrict(output, ret)); + BOOST_REQUIRE(util::jsonParseStrict(output, ret)); return ret; } @@ -102,7 +98,7 @@ BOOST_AUTO_TEST_CASE(assume_object_input) Json::Value result; /// Use the native JSON interface of StandardCompiler to trigger these - solidity::StandardCompiler compiler; + frontend::StandardCompiler compiler; result = compiler.compile(Json::Value()); BOOST_CHECK(containsError(result, "JSONError", "Input is not a JSON object.")); result = compiler.compile(Json::Value("INVALID")); @@ -352,19 +348,19 @@ BOOST_AUTO_TEST_CASE(basic_compilation) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); BOOST_CHECK(contract["devdoc"].isObject()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["devdoc"]), "{\"methods\":{}}"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["devdoc"]), "{\"methods\":{}}"); BOOST_CHECK(contract["userdoc"].isObject()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["userdoc"]), "{\"methods\":{}}"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["userdoc"]), "{\"methods\":{}}"); BOOST_CHECK(contract["evm"].isObject()); /// @TODO check evm.methodIdentifiers, legacyAssembly, bytecode, deployedBytecode BOOST_CHECK(contract["evm"]["bytecode"].isObject()); BOOST_CHECK(contract["evm"]["bytecode"]["object"].isString()); BOOST_CHECK_EQUAL( - dev::test::bytecodeSansMetadata(contract["evm"]["bytecode"]["object"].asString()), + solidity::test::bytecodeSansMetadata(contract["evm"]["bytecode"]["object"].asString()), string("6080604052348015600f57600080fd5b5060") + - (VersionIsRelease ? "3f" : toHex(bytes{uint8_t(61 + VersionStringStrict.size())})) + + (VersionIsRelease ? "3f" : util::toHex(bytes{uint8_t(61 + VersionStringStrict.size())})) + "80601d6000396000f3fe6080604052600080fdfe" ); BOOST_CHECK(contract["evm"]["assembly"].isString()); @@ -396,7 +392,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(contract["evm"]["legacyAssembly"].isObject()); BOOST_CHECK(contract["evm"]["legacyAssembly"][".code"].isArray()); BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(contract["evm"]["legacyAssembly"][".code"]), + util::jsonCompactPrint(contract["evm"]["legacyAssembly"][".code"]), "[{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"80\"}," "{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"40\"}," "{\"begin\":0,\"end\":14,\"name\":\"MSTORE\"}," @@ -420,12 +416,12 @@ BOOST_AUTO_TEST_CASE(basic_compilation) "{\"begin\":0,\"end\":14,\"name\":\"RETURN\"}]" ); BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString())); + BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString())); BOOST_CHECK(result["sources"].isObject()); BOOST_CHECK(result["sources"]["fileA"].isObject()); BOOST_CHECK(result["sources"]["fileA"]["legacyAST"].isObject()); BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(result["sources"]["fileA"]["legacyAST"]), + util::jsonCompactPrint(result["sources"]["fileA"]["legacyAST"]), "{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}},\"children\":" "[{\"attributes\":{\"abstract\":false,\"baseContracts\":[null],\"contractDependencies\":[null],\"contractKind\":\"contract\"," "\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nodes\":[null],\"scope\":2}," @@ -464,7 +460,7 @@ BOOST_AUTO_TEST_CASE(compilation_error) if (error["message"].asString().find("pre-release compiler") == string::npos) { BOOST_CHECK_EQUAL( - dev::jsonCompactPrint(error), + util::jsonCompactPrint(error), "{\"component\":\"general\",\"formattedMessage\":\"fileA:1:23: ParserError: Expected identifier but got '}'\\n" "contract A { function }\\n ^\\n\",\"message\":\"Expected identifier but got '}'\"," "\"severity\":\"error\",\"sourceLocation\":{\"end\":23,\"file\":\"fileA\",\"start\":22},\"type\":\"ParserError\"}" @@ -499,7 +495,7 @@ BOOST_AUTO_TEST_CASE(output_selection_explicit) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } BOOST_AUTO_TEST_CASE(output_selection_all_contracts) @@ -528,7 +524,7 @@ BOOST_AUTO_TEST_CASE(output_selection_all_contracts) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } BOOST_AUTO_TEST_CASE(output_selection_all_files_single_contract) @@ -557,7 +553,7 @@ BOOST_AUTO_TEST_CASE(output_selection_all_files_single_contract) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } BOOST_AUTO_TEST_CASE(output_selection_all_files_all_contracts) @@ -586,7 +582,7 @@ BOOST_AUTO_TEST_CASE(output_selection_all_files_all_contracts) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } BOOST_AUTO_TEST_CASE(output_selection_dependent_contract) @@ -615,7 +611,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"); } BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import) @@ -647,7 +643,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"); } BOOST_AUTO_TEST_CASE(filename_with_colon) @@ -676,7 +672,7 @@ BOOST_AUTO_TEST_CASE(filename_with_colon) Json::Value contract = getContractResult(result, "http://github.com/ethereum/solidity/std/StandardToken.sol", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["abi"].isArray()); - BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]"); + BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]"); } BOOST_AUTO_TEST_CASE(library_filename_with_colon) @@ -933,7 +929,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_default_disabled) BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["metadata"].isString()); Json::Value metadata; - BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata)); + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); Json::Value const& optimizer = metadata["settings"]["optimizer"]; BOOST_CHECK(optimizer.isMember("enabled")); @@ -966,7 +962,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_default_enabled) BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["metadata"].isString()); Json::Value metadata; - BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata)); + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); Json::Value const& optimizer = metadata["settings"]["optimizer"]; BOOST_CHECK(optimizer.isMember("enabled")); @@ -1006,7 +1002,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_details_exactly_as_default_disabled) BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["metadata"].isString()); Json::Value metadata; - BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata)); + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); Json::Value const& optimizer = metadata["settings"]["optimizer"]; BOOST_CHECK(optimizer.isMember("enabled")); @@ -1048,7 +1044,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_details_different) BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["metadata"].isString()); Json::Value metadata; - BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata)); + BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata)); Json::Value const& optimizer = metadata["settings"]["optimizer"]; BOOST_CHECK(!optimizer.isMember("enabled")); @@ -1097,7 +1093,7 @@ BOOST_AUTO_TEST_CASE(metadata_without_compilation) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString())); + BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString())); } BOOST_AUTO_TEST_CASE(common_pattern) @@ -1124,7 +1120,7 @@ BOOST_AUTO_TEST_CASE(common_pattern) Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); BOOST_CHECK(contract["metadata"].isString()); - BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString())); + BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString())); BOOST_CHECK(contract["evm"]["bytecode"].isObject()); BOOST_CHECK(contract["evm"]["bytecode"]["object"].isString()); } @@ -1178,9 +1174,9 @@ BOOST_AUTO_TEST_CASE(use_stack_optimization) )"; Json::Value parsedInput; - BOOST_REQUIRE(jsonParseStrict(input, parsedInput)); + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); - dev::solidity::StandardCompiler compiler; + solidity::frontend::StandardCompiler compiler; Json::Value result = compiler.compile(parsedInput); BOOST_CHECK(containsAtMostWarnings(result)); @@ -1223,9 +1219,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard) )"; Json::Value parsedInput; - BOOST_REQUIRE(jsonParseStrict(input, parsedInput)); + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); - dev::solidity::StandardCompiler compiler; + solidity::frontend::StandardCompiler compiler; Json::Value result = compiler.compile(parsedInput); BOOST_REQUIRE(result["contracts"].isObject()); @@ -1264,9 +1260,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_colon_source) )"; Json::Value parsedInput; - BOOST_REQUIRE(jsonParseStrict(input, parsedInput)); + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); - dev::solidity::StandardCompiler compiler; + solidity::frontend::StandardCompiler compiler; Json::Value result = compiler.compile(parsedInput); BOOST_REQUIRE(result["contracts"].isObject()); @@ -1304,9 +1300,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_empty_source) )"; Json::Value parsedInput; - BOOST_REQUIRE(jsonParseStrict(input, parsedInput)); + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); - dev::solidity::StandardCompiler compiler; + solidity::frontend::StandardCompiler compiler; Json::Value result = compiler.compile(parsedInput); BOOST_REQUIRE(result["contracts"].isObject()); @@ -1348,9 +1344,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_multiple_sources) )"; Json::Value parsedInput; - BOOST_REQUIRE(jsonParseStrict(input, parsedInput)); + BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput)); - dev::solidity::StandardCompiler compiler; + solidity::frontend::StandardCompiler compiler; Json::Value result = compiler.compile(parsedInput); BOOST_REQUIRE(result["contracts"].isObject()); @@ -1368,6 +1364,4 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_multiple_sources) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index 68e7c67c1..a3322fdb2 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -24,14 +24,15 @@ #include #include -using namespace langutil; -using namespace dev::solidity; -using namespace dev::solidity::test; -using namespace dev::formatting; -using namespace dev; using namespace std; -namespace fs = boost::filesystem; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::util::formatting; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace boost::unit_test; +namespace fs = boost::filesystem; namespace { diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h index 05d0bb90e..a231a951f 100644 --- a/test/libsolidity/SyntaxTest.h +++ b/test/libsolidity/SyntaxTest.h @@ -27,11 +27,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { struct SyntaxTestError @@ -74,7 +70,7 @@ public: printErrorList(_stream, m_errorList, _linePrefix, false); } - static std::string errorMessage(Exception const& _e); + static std::string errorMessage(util::Exception const& _e); protected: void setupCompiler(); void parseAndAnalyze(); @@ -100,5 +96,3 @@ protected: }; } -} -} diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp index f1176b865..a29d13525 100644 --- a/test/libsolidity/ViewPureChecker.cpp +++ b/test/libsolidity/ViewPureChecker.cpp @@ -28,13 +28,9 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_FIXTURE_TEST_SUITE(ViewPureChecker, AnalysisFramework) @@ -56,7 +52,7 @@ BOOST_AUTO_TEST_CASE(environment_access) "this", "address(1).balance", }; - if (dev::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::Options::get().evmVersion().hasStaticCall()) view.emplace_back("address(0x4242).staticcall(\"\")"); // ``block.blockhash`` and ``blockhash`` are tested separately below because their usage will @@ -109,7 +105,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall) } } )"; - if (!dev::test::Options::get().evmVersion().hasStaticCall()) + if (!solidity::test::Options::get().evmVersion().hasStaticCall()) CHECK_ERROR(text, TypeError, "\"staticcall\" is not supported by the VM version."); else CHECK_SUCCESS_NO_WARNINGS(text); @@ -125,7 +121,7 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall) } } )"; - if (!dev::test::Options::get().evmVersion().hasStaticCall()) + if (!solidity::test::Options::get().evmVersion().hasStaticCall()) CHECK_ERROR(text, TypeError, "\"staticcall\" instruction is only available for Byzantium-compatible"); else CHECK_SUCCESS_NO_WARNINGS(text); @@ -134,5 +130,3 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/util/BytesUtils.cpp b/test/libsolidity/util/BytesUtils.cpp index 312b5fb2e..c91231521 100644 --- a/test/libsolidity/util/BytesUtils.cpp +++ b/test/libsolidity/util/BytesUtils.cpp @@ -32,10 +32,11 @@ #include #include -using namespace dev; -using namespace langutil; using namespace solidity; -using namespace dev::solidity::test; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; using namespace soltest; @@ -205,7 +206,7 @@ string BytesUtils::formatString(bytes const& _bytes, size_t _cutOff) string BytesUtils::formatRawBytes( bytes const& _bytes, - dev::solidity::test::ParameterList const& _parameters, + solidity::frontend::test::ParameterList const& _parameters, string _linePrefix) { stringstream os; @@ -275,7 +276,7 @@ string BytesUtils::formatBytes( string BytesUtils::formatBytesRange( bytes _bytes, - dev::solidity::test::ParameterList const& _parameters, + solidity::frontend::test::ParameterList const& _parameters, bool _highlight ) { @@ -297,7 +298,7 @@ string BytesUtils::formatBytesRange( AnsiColorized( os, _highlight, - {dev::formatting::RED_BACKGROUND} + {util::formatting::RED_BACKGROUND} ) << formatBytes(byteRange, parameter.abiType); else os << parameter.rawString; diff --git a/test/libsolidity/util/BytesUtils.h b/test/libsolidity/util/BytesUtils.h index 0038baffb..99e33055e 100644 --- a/test/libsolidity/util/BytesUtils.h +++ b/test/libsolidity/util/BytesUtils.h @@ -18,11 +18,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { /** @@ -129,5 +125,3 @@ public: }; } -} -} diff --git a/test/libsolidity/util/ContractABIUtils.cpp b/test/libsolidity/util/ContractABIUtils.cpp index bd94ec99a..2e600e4c1 100644 --- a/test/libsolidity/util/ContractABIUtils.cpp +++ b/test/libsolidity/util/ContractABIUtils.cpp @@ -32,17 +32,17 @@ #include #include -using namespace dev; -using namespace langutil; using namespace solidity; -using namespace dev::solidity::test; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend::test; using namespace std; using namespace soltest; namespace { -using ParameterList = dev::solidity::test::ParameterList; +using ParameterList = solidity::frontend::test::ParameterList; size_t arraySize(string const& _arrayType) { @@ -141,7 +141,7 @@ string functionSignatureFromABI(Json::Value const& _functionABI) } -std::optional ContractABIUtils::parametersFromJsonOutputs( +std::optional ContractABIUtils::parametersFromJsonOutputs( ErrorReporter& _errorReporter, Json::Value const& _contractABI, string const& _functionSignature @@ -255,8 +255,8 @@ bool ContractABIUtils::appendTypesFromName( void ContractABIUtils::overwriteParameters( ErrorReporter& _errorReporter, - dev::solidity::test::ParameterList& _targetParameters, - dev::solidity::test::ParameterList const& _sourceParameters + solidity::frontend::test::ParameterList& _targetParameters, + solidity::frontend::test::ParameterList const& _sourceParameters ) { boost::for_each( @@ -280,10 +280,10 @@ void ContractABIUtils::overwriteParameters( ); } -dev::solidity::test::ParameterList ContractABIUtils::preferredParameters( +solidity::frontend::test::ParameterList ContractABIUtils::preferredParameters( ErrorReporter& _errorReporter, - dev::solidity::test::ParameterList const& _targetParameters, - dev::solidity::test::ParameterList const& _sourceParameters, + solidity::frontend::test::ParameterList const& _targetParameters, + solidity::frontend::test::ParameterList const& _sourceParameters, bytes const& _bytes ) { @@ -300,7 +300,7 @@ dev::solidity::test::ParameterList ContractABIUtils::preferredParameters( return _targetParameters; } -dev::solidity::test::ParameterList ContractABIUtils::defaultParameters(size_t count) +solidity::frontend::test::ParameterList ContractABIUtils::defaultParameters(size_t count) { ParameterList parameters; @@ -313,7 +313,7 @@ dev::solidity::test::ParameterList ContractABIUtils::defaultParameters(size_t co return parameters; } -dev::solidity::test::ParameterList ContractABIUtils::failureParameters(bytes const _bytes) +solidity::frontend::test::ParameterList ContractABIUtils::failureParameters(bytes const _bytes) { ParameterList parameters; @@ -330,7 +330,7 @@ dev::solidity::test::ParameterList ContractABIUtils::failureParameters(bytes con } size_t ContractABIUtils::encodingSize( - dev::solidity::test::ParameterList const& _parameters + solidity::frontend::test::ParameterList const& _parameters ) { auto sizeFold = [](size_t const _a, Parameter const& _b) { return _a + _b.abiType.size; }; diff --git a/test/libsolidity/util/ContractABIUtils.h b/test/libsolidity/util/ContractABIUtils.h index cc4a541ee..2c9ce0da2 100644 --- a/test/libsolidity/util/ContractABIUtils.h +++ b/test/libsolidity/util/ContractABIUtils.h @@ -22,11 +22,7 @@ #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { using ABITypes = std::vector; @@ -98,5 +94,3 @@ private: }; } -} -} diff --git a/test/libsolidity/util/SoltestErrors.h b/test/libsolidity/util/SoltestErrors.h index 23b5afc42..a9a7e88e0 100644 --- a/test/libsolidity/util/SoltestErrors.h +++ b/test/libsolidity/util/SoltestErrors.h @@ -18,11 +18,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { #define soltestAssert(CONDITION, DESCRIPTION) \ @@ -101,17 +97,17 @@ public: break; case FormatError::Warning: - AnsiColorized( + util::AnsiColorized( os, _formatted, - {formatting::YELLOW} + {util::formatting::YELLOW} ) << _linePrefix << "Warning: " << error.message << std::endl; break; case FormatError::Error: - AnsiColorized( + util::AnsiColorized( os, _formatted, - {formatting::RED} + {util::formatting::RED} ) << _linePrefix << "Error: " << error.message << std::endl; break; } @@ -124,5 +120,3 @@ private: }; } -} -} diff --git a/test/libsolidity/util/SoltestTypes.h b/test/libsolidity/util/SoltestTypes.h index d945ee022..8b2bed9a4 100644 --- a/test/libsolidity/util/SoltestTypes.h +++ b/test/libsolidity/util/SoltestTypes.h @@ -18,11 +18,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { /** @@ -274,5 +270,3 @@ struct FunctionCall }; } -} -} diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 77330f51c..58314db26 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -31,10 +31,10 @@ #include #include -using namespace dev; -using namespace langutil; using namespace solidity; -using namespace dev::solidity::test; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; using namespace soltest; @@ -48,7 +48,7 @@ char TestFileParser::Scanner::peek() const noexcept return *next; } -vector TestFileParser::parseFunctionCalls(size_t _lineOffset) +vector TestFileParser::parseFunctionCalls(size_t _lineOffset) { vector calls; if (!accept(Token::EOS)) diff --git a/test/libsolidity/util/TestFileParser.h b/test/libsolidity/util/TestFileParser.h index a460f4d40..1e6fbf21a 100644 --- a/test/libsolidity/util/TestFileParser.h +++ b/test/libsolidity/util/TestFileParser.h @@ -27,11 +27,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { /** @@ -193,5 +189,3 @@ private: }; } -} -} diff --git a/test/libsolidity/util/TestFileParserTests.cpp b/test/libsolidity/util/TestFileParserTests.cpp index 2323609b5..c7e4cb22a 100644 --- a/test/libsolidity/util/TestFileParserTests.cpp +++ b/test/libsolidity/util/TestFileParserTests.cpp @@ -28,13 +28,10 @@ #include using namespace std; -using namespace dev::test; +using namespace solidity::util; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { using fmt = ExecutionFramework; @@ -936,5 +933,3 @@ BOOST_AUTO_TEST_CASE(library) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index 5fcfef08b..5cf48f88d 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -25,9 +25,9 @@ #include #include -using namespace dev; using namespace solidity; -using namespace dev::solidity::test; +using namespace solidity::util; +using namespace solidity::frontend::test; using namespace std; string TestFunctionCall::format( @@ -110,7 +110,7 @@ string TestFunctionCall::format( formatFailure(_errorReporter, m_call, m_rawBytes, _renderResult, highlight) : formatRawParameters(m_call.expectations.result); if (!result.empty()) - AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << ws << result; + AnsiColorized(stream, highlight, {util::formatting::RED_BACKGROUND}) << ws << result; } else { @@ -159,7 +159,7 @@ string TestFunctionCall::format( } if (isFailure) - AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << ws << result; + AnsiColorized(stream, highlight, {util::formatting::RED_BACKGROUND}) << ws << result; else if (!result.empty()) stream << ws << result; @@ -190,12 +190,12 @@ string TestFunctionCall::formatBytesParameters( ErrorReporter& _errorReporter, bytes const& _bytes, string const& _signature, - dev::solidity::test::ParameterList const& _parameters, + solidity::frontend::test::ParameterList const& _parameters, bool _highlight, bool _failure ) const { - using ParameterList = dev::solidity::test::ParameterList; + using ParameterList = solidity::frontend::test::ParameterList; stringstream os; @@ -248,7 +248,7 @@ string TestFunctionCall::formatBytesParameters( string TestFunctionCall::formatFailure( ErrorReporter& _errorReporter, - dev::solidity::test::FunctionCall const& _call, + solidity::frontend::test::FunctionCall const& _call, bytes const& _output, bool _renderResult, bool _highlight @@ -279,7 +279,7 @@ string TestFunctionCall::formatFailure( } string TestFunctionCall::formatRawParameters( - dev::solidity::test::ParameterList const& _params, + solidity::frontend::test::ParameterList const& _params, std::string const& _linePrefix ) const { diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index 6e5c16dab..4717f9903 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -30,11 +30,7 @@ #include #include -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { /** @@ -136,5 +132,3 @@ private: }; } -} -} diff --git a/test/libsolidity/util/TestFunctionCallTests.cpp b/test/libsolidity/util/TestFunctionCallTests.cpp index 9f67c7b91..f3f977bbf 100644 --- a/test/libsolidity/util/TestFunctionCallTests.cpp +++ b/test/libsolidity/util/TestFunctionCallTests.cpp @@ -25,13 +25,10 @@ #include using namespace std; -using namespace dev::test; +using namespace solidity::util; +using namespace solidity::test; -namespace dev -{ -namespace solidity -{ -namespace test +namespace solidity::frontend::test { BOOST_AUTO_TEST_SUITE(TestFunctionCallTest) @@ -256,5 +253,3 @@ BOOST_AUTO_TEST_CASE(format_failure_singleline) BOOST_AUTO_TEST_SUITE_END() } -} -} diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp index aa3492cb0..e50239807 100644 --- a/test/libyul/Common.cpp +++ b/test/libyul/Common.cpp @@ -40,14 +40,15 @@ #include using namespace std; -using namespace langutil; -using namespace yul; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::langutil; namespace { Dialect const& defaultDialect(bool _yul) { - return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(dev::test::Options::get().evmVersion()); + return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(solidity::test::Options::get().evmVersion()); } } @@ -63,11 +64,11 @@ void yul::test::printErrors(ErrorList const& _errors) pair, shared_ptr> yul::test::parse(string const& _source, bool _yul) { AssemblyStack stack( - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), _yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, - dev::test::Options::get().optimize ? - dev::solidity::OptimiserSettings::standard() : - dev::solidity::OptimiserSettings::minimal() + solidity::test::Options::get().optimize ? + solidity::frontend::OptimiserSettings::standard() : + solidity::frontend::OptimiserSettings::minimal() ); if (!stack.parseAndAnalyze("", _source) || !stack.errors().empty()) BOOST_FAIL("Invalid source."); diff --git a/test/libyul/Common.h b/test/libyul/Common.h index 01fc416ab..96de22aa9 100644 --- a/test/libyul/Common.h +++ b/test/libyul/Common.h @@ -27,20 +27,18 @@ #include #include -namespace langutil +namespace solidity::langutil { class Error; using ErrorList = std::vector>; } -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; } -namespace yul -{ -namespace test +namespace solidity::yul::test { void printErrors(langutil::ErrorList const& _errors); @@ -50,4 +48,3 @@ Block disambiguate(std::string const& _source, bool _yul = true); std::string format(std::string const& _source, bool _yul = true); } -} diff --git a/test/libyul/CompilabilityChecker.cpp b/test/libyul/CompilabilityChecker.cpp index 5d3181da8..f8772a1c1 100644 --- a/test/libyul/CompilabilityChecker.cpp +++ b/test/libyul/CompilabilityChecker.cpp @@ -28,9 +28,7 @@ using namespace std; -namespace yul -{ -namespace test +namespace solidity::yul::test { namespace @@ -40,7 +38,7 @@ string check(string const& _input) Object obj; std::tie(obj.code, obj.analysisInfo) = yul::test::parse(_input, false); BOOST_REQUIRE(obj.code); - map functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(dev::test::Options::get().evmVersion()), obj, true); + map functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(solidity::test::Options::get().evmVersion()), obj, true); string out; for (auto const& function: functions) out += function.first.str() + ": " + to_string(function.second) + " "; @@ -223,4 +221,3 @@ BOOST_AUTO_TEST_CASE(also_in_outer_block) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libyul/EwasmTranslationTest.cpp b/test/libyul/EwasmTranslationTest.cpp index b0583537e..cd5ce7623 100644 --- a/test/libyul/EwasmTranslationTest.cpp +++ b/test/libyul/EwasmTranslationTest.cpp @@ -38,12 +38,13 @@ #include -using namespace dev; -using namespace langutil; -using namespace yul; -using namespace yul::test; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; @@ -66,7 +67,7 @@ TestCase::TestResult EwasmTranslationTest::run(ostream& _stream, string const& _ return TestResult::FatalError; *m_object = EVMToEwasmTranslator( - EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()) + EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()) ).run(*m_object); // Add call to "main()". @@ -110,9 +111,9 @@ void EwasmTranslationTest::printIndented(ostream& _stream, string const& _output bool EwasmTranslationTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted) { AssemblyStack stack( - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::none() + solidity::frontend::OptimiserSettings::none() ); if (stack.parseAndAnalyze("", m_source)) { diff --git a/test/libyul/EwasmTranslationTest.h b/test/libyul/EwasmTranslationTest.h index 23c002625..68b640032 100644 --- a/test/libyul/EwasmTranslationTest.h +++ b/test/libyul/EwasmTranslationTest.h @@ -20,19 +20,17 @@ #include #include -namespace langutil +namespace solidity::langutil { class Scanner; class Error; using ErrorList = std::vector>; } -namespace yul -{ -namespace test +namespace solidity::yul::test { -class EwasmTranslationTest: public dev::solidity::test::EVMVersionRestrictedTestCase +class EwasmTranslationTest: public solidity::frontend::test::EVMVersionRestrictedTestCase { public: static std::unique_ptr create(Config const& _config) @@ -62,4 +60,3 @@ private: }; } -} diff --git a/test/libyul/FunctionSideEffects.cpp b/test/libyul/FunctionSideEffects.cpp index ba0a17599..6577f7383 100644 --- a/test/libyul/FunctionSideEffects.cpp +++ b/test/libyul/FunctionSideEffects.cpp @@ -32,12 +32,13 @@ #include -using namespace dev; -using namespace langutil; -using namespace yul; -using namespace yul::test; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; namespace diff --git a/test/libyul/FunctionSideEffects.h b/test/libyul/FunctionSideEffects.h index 582b45432..829a17c2e 100644 --- a/test/libyul/FunctionSideEffects.h +++ b/test/libyul/FunctionSideEffects.h @@ -25,12 +25,10 @@ #include #include -namespace yul -{ -namespace test +namespace solidity::yul::test { -class FunctionSideEffects: public dev::solidity::test::TestCase +class FunctionSideEffects: public solidity::frontend::test::TestCase { public: static std::unique_ptr create(Config const& _config) @@ -51,4 +49,3 @@ private: }; } -} diff --git a/test/libyul/Inliner.cpp b/test/libyul/Inliner.cpp index 242828029..e564ac2b8 100644 --- a/test/libyul/Inliner.cpp +++ b/test/libyul/Inliner.cpp @@ -34,9 +34,10 @@ #include using namespace std; -using namespace dev; -using namespace yul; -using namespace yul::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::yul; +using namespace solidity::yul::test; namespace { diff --git a/test/libyul/Metrics.cpp b/test/libyul/Metrics.cpp index 3fa849c23..f5e3ec7ab 100644 --- a/test/libyul/Metrics.cpp +++ b/test/libyul/Metrics.cpp @@ -27,11 +27,9 @@ using namespace std; -using namespace langutil; +using namespace solidity::langutil; -namespace yul -{ -namespace test +namespace solidity::yul::test { namespace @@ -176,4 +174,3 @@ BOOST_AUTO_TEST_CASE(switch_statement_large) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libyul/ObjectCompilerTest.cpp b/test/libyul/ObjectCompilerTest.cpp index 57ea5b9fb..e7c87a708 100644 --- a/test/libyul/ObjectCompilerTest.cpp +++ b/test/libyul/ObjectCompilerTest.cpp @@ -29,12 +29,13 @@ #include -using namespace dev; -using namespace langutil; -using namespace yul; -using namespace yul::test; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; ObjectCompilerTest::ObjectCompilerTest(string const& _filename) diff --git a/test/libyul/ObjectCompilerTest.h b/test/libyul/ObjectCompilerTest.h index 6e89e059d..dc02d504c 100644 --- a/test/libyul/ObjectCompilerTest.h +++ b/test/libyul/ObjectCompilerTest.h @@ -19,25 +19,23 @@ #include -namespace langutil +namespace solidity::langutil { class Scanner; class Error; using ErrorList = std::vector>; } -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; struct Block; } -namespace yul -{ -namespace test +namespace solidity::yul::test { -class ObjectCompilerTest: public dev::solidity::test::TestCase +class ObjectCompilerTest: public solidity::frontend::test::TestCase { public: static std::unique_ptr create(Config const& _config) @@ -66,4 +64,3 @@ private: }; } -} diff --git a/test/libyul/ObjectParser.cpp b/test/libyul/ObjectParser.cpp index 35cf21f24..72ddb02de 100644 --- a/test/libyul/ObjectParser.cpp +++ b/test/libyul/ObjectParser.cpp @@ -34,11 +34,10 @@ #include using namespace std; -using namespace langutil; +using namespace solidity::frontend; +using namespace solidity::langutil; -namespace yul -{ -namespace test +namespace solidity::yul::test { namespace @@ -49,9 +48,9 @@ std::pair parse(string const& _source) try { AssemblyStack asmStack( - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::none() + solidity::frontend::OptimiserSettings::none() ); bool success = asmStack.parseAndAnalyze("source", _source); return {success, asmStack.errors()}; @@ -108,7 +107,7 @@ do \ { \ Error err = expectError((text), false); \ BOOST_CHECK(err.type() == (Error::Type::typ)); \ - BOOST_CHECK(dev::solidity::searchErrorMessage(err, (substring))); \ + BOOST_CHECK(::solidity::frontend::test::searchErrorMessage(err, (substring))); \ } while(0) BOOST_AUTO_TEST_SUITE(YulObjectParser) @@ -240,9 +239,9 @@ BOOST_AUTO_TEST_CASE(to_string) )"; expectation = boost::replace_all_copy(expectation, "\t", " "); AssemblyStack asmStack( - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::none() + solidity::frontend::OptimiserSettings::none() ); BOOST_REQUIRE(asmStack.parseAndAnalyze("source", code)); BOOST_CHECK_EQUAL(asmStack.print(), expectation); @@ -294,4 +293,3 @@ BOOST_AUTO_TEST_CASE(non_existing_objects) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index 92a84cb08..6f25304d8 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -38,12 +38,11 @@ #include using namespace std; -using namespace dev; -using namespace langutil; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; -namespace yul -{ -namespace test +namespace solidity::yul::test { namespace @@ -117,7 +116,7 @@ do \ { \ Error err = expectError((text), dialect, false); \ BOOST_CHECK(err.type() == (Error::Type::typ)); \ - BOOST_CHECK(dev::solidity::searchErrorMessage(err, (substring))); \ + BOOST_CHECK(solidity::frontend::test::searchErrorMessage(err, (substring))); \ } while(0) #define CHECK_ERROR(text, typ, substring) CHECK_ERROR_DIALECT(text, typ, substring, Dialect::yul()) @@ -569,5 +568,4 @@ BOOST_AUTO_TEST_CASE(builtins_analysis) BOOST_AUTO_TEST_SUITE_END() -} } // end namespaces diff --git a/test/libyul/StackReuseCodegen.cpp b/test/libyul/StackReuseCodegen.cpp index 074096f01..574ed9462 100644 --- a/test/libyul/StackReuseCodegen.cpp +++ b/test/libyul/StackReuseCodegen.cpp @@ -25,16 +25,14 @@ using namespace std; -namespace yul -{ -namespace test +namespace solidity::yul::test { namespace { string assemble(string const& _input) { - dev::solidity::OptimiserSettings settings = dev::solidity::OptimiserSettings::full(); + solidity::frontend::OptimiserSettings settings = solidity::frontend::OptimiserSettings::full(); settings.runYulOptimiser = false; settings.optimizeStackAllocation = true; AssemblyStack asmStack(langutil::EVMVersion{}, AssemblyStack::Language::StrictAssembly, settings); @@ -349,4 +347,3 @@ BOOST_AUTO_TEST_CASE(reuse_slots_function_with_gaps) BOOST_AUTO_TEST_SUITE_END() } -} diff --git a/test/libyul/YulInterpreterTest.cpp b/test/libyul/YulInterpreterTest.cpp index 4a57e0b47..8818206fa 100644 --- a/test/libyul/YulInterpreterTest.cpp +++ b/test/libyul/YulInterpreterTest.cpp @@ -36,12 +36,13 @@ #include -using namespace dev; -using namespace langutil; -using namespace yul; -using namespace yul::test; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; YulInterpreterTest::YulInterpreterTest(string const& _filename) @@ -98,9 +99,9 @@ void YulInterpreterTest::printIndented(ostream& _stream, string const& _output, bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted) { AssemblyStack stack( - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::none() + solidity::frontend::OptimiserSettings::none() ); if (stack.parseAndAnalyze("", m_source)) { diff --git a/test/libyul/YulInterpreterTest.h b/test/libyul/YulInterpreterTest.h index eb456f1d0..5fb6d02b3 100644 --- a/test/libyul/YulInterpreterTest.h +++ b/test/libyul/YulInterpreterTest.h @@ -19,25 +19,23 @@ #include -namespace langutil +namespace solidity::langutil { class Scanner; class Error; using ErrorList = std::vector>; } -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; struct Block; } -namespace yul -{ -namespace test +namespace solidity::yul::test { -class YulInterpreterTest: public dev::solidity::test::EVMVersionRestrictedTestCase +class YulInterpreterTest: public solidity::frontend::test::EVMVersionRestrictedTestCase { public: static std::unique_ptr create(Config const& _config) @@ -68,4 +66,3 @@ private: }; } -} diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 8b0561378..fb3f8360d 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -78,12 +78,13 @@ #include #include -using namespace dev; -using namespace langutil; -using namespace yul; -using namespace yul::test; -using namespace dev::solidity; -using namespace dev::solidity::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; +using namespace solidity::frontend; +using namespace solidity::frontend::test; using namespace std; YulOptimizerTest::YulOptimizerTest(string const& _filename) @@ -107,7 +108,7 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename) else if (dialectName == "ewasm") m_dialect = &WasmDialect::instance(); else if (dialectName == "evm") - m_dialect = &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); + m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()); else BOOST_THROW_EXCEPTION(runtime_error("Invalid dialect " + dialectName)); @@ -115,7 +116,7 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename) m_settings.erase("dialect"); } else - m_dialect = &EVMDialect::strictAssemblyForEVMObjects(dev::test::Options::get().evmVersion()); + m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()); if (m_settings.count("step")) { @@ -418,9 +419,9 @@ void YulOptimizerTest::printIndented(ostream& _stream, string const& _output, st bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted) { AssemblyStack stack( - dev::test::Options::get().evmVersion(), + solidity::test::Options::get().evmVersion(), m_dialect->flavour == AsmFlavour::Yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::none() + solidity::frontend::OptimiserSettings::none() ); if (!stack.parseAndAnalyze("", m_source) || !stack.errors().empty()) { diff --git a/test/libyul/YulOptimizerTest.h b/test/libyul/YulOptimizerTest.h index d74e3fc16..41e38fca0 100644 --- a/test/libyul/YulOptimizerTest.h +++ b/test/libyul/YulOptimizerTest.h @@ -27,26 +27,24 @@ #include #include -namespace langutil +namespace solidity::langutil { class Scanner; class Error; using ErrorList = std::vector>; } -namespace yul +namespace solidity::yul { struct AsmAnalysisInfo; struct Block; struct Dialect; } -namespace yul -{ -namespace test +namespace solidity::yul::test { -class YulOptimizerTest: public dev::solidity::test::EVMVersionRestrictedTestCase +class YulOptimizerTest: public solidity::frontend::test::EVMVersionRestrictedTestCase { public: static std::unique_ptr create(Config const& _config) @@ -85,4 +83,3 @@ private: }; } -} diff --git a/test/tools/IsolTestOptions.cpp b/test/tools/IsolTestOptions.cpp index 5b875393d..0921c5927 100644 --- a/test/tools/IsolTestOptions.cpp +++ b/test/tools/IsolTestOptions.cpp @@ -31,9 +31,7 @@ namespace fs = boost::filesystem; namespace po = boost::program_options; -namespace dev -{ -namespace test +namespace solidity::test { auto const description = R"(isoltest, tool for interactively managing test contracts. @@ -87,4 +85,3 @@ void IsolTestOptions::validate() const } } -} diff --git a/test/tools/IsolTestOptions.h b/test/tools/IsolTestOptions.h index e77e623f1..93d365191 100644 --- a/test/tools/IsolTestOptions.h +++ b/test/tools/IsolTestOptions.h @@ -23,9 +23,7 @@ #include -namespace dev -{ -namespace test +namespace solidity::test { struct IsolTestOptions: CommonOptions @@ -38,5 +36,5 @@ struct IsolTestOptions: CommonOptions bool parse(int _argc, char const* const* _argv) override; void validate() const override; }; -} + } diff --git a/test/tools/afl_fuzzer.cpp b/test/tools/afl_fuzzer.cpp index 2a8632899..ed1318b6b 100644 --- a/test/tools/afl_fuzzer.cpp +++ b/test/tools/afl_fuzzer.cpp @@ -28,7 +28,8 @@ #include using namespace std; -using namespace dev; +using namespace solidity; +using namespace solidity::util; namespace po = boost::program_options; diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp index 0817aea1b..ab6ab3cbb 100644 --- a/test/tools/fuzzer_common.cpp +++ b/test/tools/fuzzer_common.cpp @@ -25,8 +25,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::eth; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::evmasm; static vector s_evmVersions = { "homestead", diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index 052e6b570..6ce05d592 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -39,16 +39,18 @@ #include #endif -using namespace dev; -using namespace dev::solidity; -using namespace dev::solidity::test; -using namespace dev::formatting; using namespace std; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::frontend; +using namespace solidity::frontend::test; +using namespace solidity::util::formatting; + namespace po = boost::program_options; namespace fs = boost::filesystem; using TestCreator = TestCase::TestCaseCreator; -using TestOptions = dev::test::IsolTestOptions; +using TestOptions = solidity::test::IsolTestOptions; struct TestStats { @@ -399,7 +401,7 @@ int main(int argc, char const *argv[]) { setupTerminal(); - dev::test::IsolTestOptions options(&TestTool::editor); + solidity::test::IsolTestOptions options(&TestTool::editor); try { @@ -414,12 +416,12 @@ int main(int argc, char const *argv[]) return 1; } - bool disableSemantics = !dev::test::EVMHost::getVM(options.evmonePath.string()); + bool disableSemantics = !solidity::test::EVMHost::getVM(options.evmonePath.string()); if (disableSemantics) { - cout << "Unable to find " << dev::test::evmoneFilename << ". Please provide the path using --evmonepath ." << endl; + cout << "Unable to find " << solidity::test::evmoneFilename << ". Please provide the path using --evmonepath ." << endl; cout << "You can download it at" << endl; - cout << dev::test::evmoneDownloadLink << endl; + cout << solidity::test::evmoneDownloadLink << endl; cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl; } @@ -462,7 +464,7 @@ int main(int argc, char const *argv[]) cout << "." << endl; if (disableSemantics) - cout << "\nNOTE: Skipped semantics tests because " << dev::test::evmoneFilename << " could not be found.\n" << endl; + cout << "\nNOTE: Skipped semantics tests because " << solidity::test::evmoneFilename << " could not be found.\n" << endl; return global_stats ? 0 : 1; } diff --git a/test/tools/ossfuzz/abiV2FuzzerCommon.cpp b/test/tools/ossfuzz/abiV2FuzzerCommon.cpp index 79aa08ba4..f30a8517a 100644 --- a/test/tools/ossfuzz/abiV2FuzzerCommon.cpp +++ b/test/tools/ossfuzz/abiV2FuzzerCommon.cpp @@ -1,13 +1,13 @@ #include -using namespace dev::test::abiv2fuzzer; +using namespace solidity::test::abiv2fuzzer; SolidityCompilationFramework::SolidityCompilationFramework(langutil::EVMVersion _evmVersion) { m_evmVersion = _evmVersion; } -dev::bytes SolidityCompilationFramework::compileContract( +solidity::bytes SolidityCompilationFramework::compileContract( std::string const& _sourceCode, std::string const& _contractName ) diff --git a/test/tools/ossfuzz/abiV2FuzzerCommon.h b/test/tools/ossfuzz/abiV2FuzzerCommon.h index ee2ececc7..5027302e8 100644 --- a/test/tools/ossfuzz/abiV2FuzzerCommon.h +++ b/test/tools/ossfuzz/abiV2FuzzerCommon.h @@ -9,12 +9,9 @@ #include -namespace dev -{ -namespace test -{ -namespace abiv2fuzzer +namespace solidity::test::abiv2fuzzer { + class SolidityCompilationFramework { public: @@ -24,15 +21,14 @@ public: { return m_compiler.methodIdentifiers(m_compiler.lastContractName()); } - dev::bytes compileContract( + bytes compileContract( std::string const& _sourceCode, std::string const& _contractName = {} ); protected: - dev::solidity::CompilerStack m_compiler; + frontend::CompilerStack m_compiler; langutil::EVMVersion m_evmVersion; - dev::solidity::OptimiserSettings m_optimiserSettings = dev::solidity::OptimiserSettings::none(); + frontend::OptimiserSettings m_optimiserSettings = frontend::OptimiserSettings::none(); }; -} -} + } diff --git a/test/tools/ossfuzz/abiV2Proto.proto b/test/tools/ossfuzz/abiV2Proto.proto index 33f887587..b581c9904 100644 --- a/test/tools/ossfuzz/abiV2Proto.proto +++ b/test/tools/ossfuzz/abiV2Proto.proto @@ -101,4 +101,4 @@ message Contract { required Test test = 3; } -package dev.test.abiv2fuzzer; \ No newline at end of file +package solidity.test.abiv2fuzzer; diff --git a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp index f6e65877d..89d5a3566 100644 --- a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp +++ b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp @@ -26,9 +26,10 @@ static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; -using namespace dev::test::abiv2fuzzer; -using namespace dev::test; -using namespace dev; +using namespace solidity::test::abiv2fuzzer; +using namespace solidity::test; +using namespace solidity::util; +using namespace solidity; using namespace std; namespace @@ -59,7 +60,7 @@ bool isOutputExpected(uint8_t const* _result, size_t _length) /// The gas field is set to the maximum permissible value so that we /// don't run into out of gas errors. The input field is copied from /// user input. -evmc_message initializeMessage(dev::bytes const& _input) +evmc_message initializeMessage(bytes const& _input) { // Zero initialize all message fields evmc_message msg = {}; @@ -76,7 +77,7 @@ evmc_message initializeMessage(dev::bytes const& _input) /// input and returns the result of the execution of the called function. evmc::result executeContract( EVMHost& _hostContext, - dev::bytes const& _functionHash, + bytes const& _functionHash, evmc_address _deployedAddress ) { @@ -89,7 +90,7 @@ evmc::result executeContract( /// Accepts a reference to host context implementation and byte code /// as input and deploys it on the simulated blockchain. Returns the /// result of deployment. -evmc::result deployContract(EVMHost& _hostContext, dev::bytes const& _code) +evmc::result deployContract(EVMHost& _hostContext, bytes const& _code) { evmc_message message = initializeMessage(_code); message.kind = EVMC_CREATE; @@ -110,7 +111,7 @@ DEFINE_PROTO_FUZZER(Contract const& _input) } // Raw runtime byte code generated by solidity - dev::bytes byteCode; + bytes byteCode; std::string hexEncodedInput; try @@ -166,4 +167,4 @@ DEFINE_PROTO_FUZZER(Contract const& _input) isOutputExpected(callResult.output_data, callResult.output_size), "Proto ABIv2 fuzzer: ABIv2 coding failure found" ); -} \ No newline at end of file +} diff --git a/test/tools/ossfuzz/protoToAbiV2.cpp b/test/tools/ossfuzz/protoToAbiV2.cpp index c7ac06c22..1c422ef8c 100644 --- a/test/tools/ossfuzz/protoToAbiV2.cpp +++ b/test/tools/ossfuzz/protoToAbiV2.cpp @@ -1,8 +1,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::test::abiv2fuzzer; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::test::abiv2fuzzer; string ProtoConverter::getVarDecl( string const& _type, diff --git a/test/tools/ossfuzz/protoToAbiV2.h b/test/tools/ossfuzz/protoToAbiV2.h index 236554bbc..94f37631f 100644 --- a/test/tools/ossfuzz/protoToAbiV2.h +++ b/test/tools/ossfuzz/protoToAbiV2.h @@ -131,12 +131,9 @@ * } */ -namespace dev -{ -namespace test -{ -namespace abiv2fuzzer +namespace solidity::test::abiv2fuzzer { + /// Converts a protobuf input into a Solidity program that tests /// abi coding. class ProtoConverter @@ -485,7 +482,7 @@ public: // Convert _counter to string and return its keccak256 hash static u256 hashUnsignedInt(unsigned _counter) { - return keccak256(h256(_counter)); + return util::keccak256(util::h256(_counter)); } static u256 maskUnsignedInt(unsigned _counter, unsigned _numMaskNibbles) @@ -497,7 +494,7 @@ public: // Note: Don't change HexPrefix::Add. See comment in fixedByteValueAsString(). static std::string maskUnsignedIntToHex(unsigned _counter, unsigned _numMaskNibbles) { - return toHex(maskUnsignedInt(_counter, _numMaskNibbles), HexPrefix::Add); + return toHex(maskUnsignedInt(_counter, _numMaskNibbles), util::HexPrefix::Add); } /// Dynamically sized arrays can have a length of at least zero @@ -933,6 +930,5 @@ public: using AbiV2ProtoVisitor::visit; }; -} -} + } diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index 8c8ff3032..b0a2a6d44 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -28,8 +28,10 @@ #include using namespace std; -using namespace yul::test::yul_fuzzer; -using namespace dev; +using namespace solidity::yul::test::yul_fuzzer; +using namespace solidity::yul::test; +using namespace solidity::util; +using namespace solidity; string ProtoConverter::dictionaryToken(HexPrefix _p) { @@ -1232,7 +1234,7 @@ void ProtoConverter::visit(Block const& _x) vector ProtoConverter::createVars(unsigned _startIdx, unsigned _endIdx) { yulAssert(_endIdx > _startIdx, "Proto fuzzer: Variable indices not in range"); - string varsStr = dev::suffixedVariableNameList("x_", _startIdx, _endIdx); + string varsStr = suffixedVariableNameList("x_", _startIdx, _endIdx); m_output << varsStr; vector varsVec; boost::split( @@ -1546,4 +1548,4 @@ std::string ProtoConverter::functionTypeToString(NumFunctionReturns _type) case NumFunctionReturns::Multiple: return "m"; } -} \ No newline at end of file +} diff --git a/test/tools/ossfuzz/protoToYul.h b/test/tools/ossfuzz/protoToYul.h index 2ac7d3800..ff0f4ddfd 100644 --- a/test/tools/ossfuzz/protoToYul.h +++ b/test/tools/ossfuzz/protoToYul.h @@ -31,11 +31,7 @@ #include #include -namespace yul -{ -namespace test -{ -namespace yul_fuzzer +namespace solidity::yul::test::yul_fuzzer { class ProtoConverter { @@ -269,7 +265,7 @@ private: /// index = (m_inputSize * m_inputSize + counter) % dictionarySize /// where m_inputSize is the size of the protobuf input and /// dictionarySize is the total number of entries in the dictionary. - std::string dictionaryToken(dev::HexPrefix _p = dev::HexPrefix::Add); + std::string dictionaryToken(util::HexPrefix _p = util::HexPrefix::Add); /// Returns a monotonically increasing counter that starts from zero. unsigned counter() @@ -296,7 +292,7 @@ private: /// enclosed within double quotes. std::string newObjectId(bool _decorate = true) { - return dev::Whiskers(R"("object")") + return util::Whiskers(R"("object")") ("decorate", _decorate) ("id", std::to_string(m_objectId++)) .render(); @@ -325,7 +321,7 @@ private: /// Maps FunctionDef object to its name std::map m_functionDefMap; // Set that is used for deduplicating switch case literals - std::stack> m_switchLiteralSetPerScope; + std::stack> m_switchLiteralSetPerScope; // Look-up table per function type that holds the number of input (output) function parameters std::map> m_functionSigMap; /// Tree of objects and their scopes @@ -356,5 +352,3 @@ private: bool m_isObject; }; } -} -} diff --git a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp index e795d047d..b9373a301 100644 --- a/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_assembly_ossfuzz.cpp @@ -19,7 +19,8 @@ #include #include -using namespace yul; +using namespace solidity; +using namespace solidity::yul; using namespace std; extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) @@ -33,7 +34,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) AssemblyStack stack( langutil::EVMVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::full() + solidity::frontend::OptimiserSettings::full() ); if (!stack.parseAndAnalyze("source", input)) diff --git a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp index 477189798..8156143b6 100644 --- a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp @@ -36,12 +36,12 @@ #include #include -using namespace yul; using namespace std; - -using namespace langutil; -using namespace dev; -using namespace yul::test::yul_fuzzer; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul::test::yul_fuzzer; extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) { @@ -60,7 +60,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) AssemblyStack stack( langutil::EVMVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::full() + solidity::frontend::OptimiserSettings::full() ); try { diff --git a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp index 70c385847..a8378f72e 100644 --- a/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_opt_ossfuzz.cpp @@ -18,7 +18,9 @@ #include #include -using namespace yul; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::yul; using namespace std; extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) @@ -32,7 +34,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) AssemblyStack stack( langutil::EVMVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::full() + solidity::frontend::OptimiserSettings::full() ); if (!stack.parseAndAnalyze("source", input)) diff --git a/test/tools/ossfuzz/yulFuzzerCommon.cpp b/test/tools/ossfuzz/yulFuzzerCommon.cpp index 2069582b0..214caf3f8 100644 --- a/test/tools/ossfuzz/yulFuzzerCommon.cpp +++ b/test/tools/ossfuzz/yulFuzzerCommon.cpp @@ -17,8 +17,9 @@ #include using namespace std; -using namespace yul; -using namespace yul::test::yul_fuzzer; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::test::yul_fuzzer; yulFuzzerUtil::TerminationReason yulFuzzerUtil::interpret( ostream& _os, diff --git a/test/tools/ossfuzz/yulFuzzerCommon.h b/test/tools/ossfuzz/yulFuzzerCommon.h index 7cc0e156f..08e17e381 100644 --- a/test/tools/ossfuzz/yulFuzzerCommon.h +++ b/test/tools/ossfuzz/yulFuzzerCommon.h @@ -17,12 +17,9 @@ #include #include -namespace yul -{ -namespace test -{ -namespace yul_fuzzer +namespace solidity::yul::test::yul_fuzzer { + struct yulFuzzerUtil { enum class TerminationReason @@ -43,6 +40,5 @@ struct yulFuzzerUtil static size_t constexpr maxSteps = 100; static size_t constexpr maxTraceSize = 75; }; -} -} + } diff --git a/test/tools/ossfuzz/yulProto.proto b/test/tools/ossfuzz/yulProto.proto index 491a2b329..d998da474 100644 --- a/test/tools/ossfuzz/yulProto.proto +++ b/test/tools/ossfuzz/yulProto.proto @@ -411,4 +411,4 @@ message Program { } } -package yul.test.yul_fuzzer; +package solidity.yul.test.yul_fuzzer; diff --git a/test/tools/ossfuzz/yulProtoFuzzer.cpp b/test/tools/ossfuzz/yulProtoFuzzer.cpp index 604fc88d6..411198d36 100644 --- a/test/tools/ossfuzz/yulProtoFuzzer.cpp +++ b/test/tools/ossfuzz/yulProtoFuzzer.cpp @@ -26,8 +26,9 @@ #include #include -using namespace yul; -using namespace yul::test::yul_fuzzer; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::test::yul_fuzzer; using namespace std; DEFINE_PROTO_FUZZER(Program const& _input) @@ -52,7 +53,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) AssemblyStack stack( langutil::EVMVersion(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::full() + solidity::frontend::OptimiserSettings::full() ); // Parse protobuf mutated YUL code diff --git a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp index 4a298e359..f3f65bb31 100644 --- a/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/yulProto_diff_ossfuzz.cpp @@ -31,13 +31,13 @@ #include -using namespace yul; -using namespace yul::test::yul_fuzzer; using namespace std; - -using namespace langutil; -using namespace dev; -using namespace yul::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; +using namespace solidity::yul::test::yul_fuzzer; namespace { @@ -71,7 +71,7 @@ DEFINE_PROTO_FUZZER(Program const& _input) AssemblyStack stack( langutil::EVMVersion::berlin(), AssemblyStack::Language::StrictAssembly, - dev::solidity::OptimiserSettings::full() + solidity::frontend::OptimiserSettings::full() ); // Parse protobuf mutated YUL code diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index d285157ca..65067d101 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -30,9 +30,12 @@ #include using namespace std; -using namespace dev; -using namespace yul; -using namespace yul::test; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::test; + +using solidity::util::h256; +using solidity::util::keccak256; namespace { @@ -81,7 +84,7 @@ u256 EVMInstructionInterpreter::eval( vector const& _arguments ) { - using namespace dev::eth; + using namespace solidity::evmasm; using evmasm::Instruction; auto info = instructionInfo(_instruction); @@ -493,10 +496,10 @@ void EVMInstructionInterpreter::logTrace(std::string const& _pseudoInstruction, { string message = _pseudoInstruction + "("; for (size_t i = 0; i < _arguments.size(); ++i) - message += (i > 0 ? ", " : "") + formatNumber(_arguments[i]); + message += (i > 0 ? ", " : "") + util::formatNumber(_arguments[i]); message += ")"; if (!_data.empty()) - message += " [" + toHex(_data) + "]"; + message += " [" + util::toHex(_data) + "]"; m_state.trace.emplace_back(std::move(message)); if (m_state.maxTraceSize > 0 && m_state.trace.size() >= m_state.maxTraceSize) { diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.h b/test/tools/yulInterpreter/EVMInstructionInterpreter.h index 2e9d2cc7a..35fc1a6da 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.h +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.h @@ -31,12 +31,13 @@ namespace solidity::evmasm enum class Instruction: uint8_t; } -namespace yul +namespace solidity::yul { class YulString; struct BuiltinFunctionForEVM; +} -namespace test +namespace solidity::yul::test { struct InterpreterState; @@ -67,32 +68,31 @@ public: m_state(_state) {} /// Evaluate instruction - dev::u256 eval(evmasm::Instruction _instruction, std::vector const& _arguments); + u256 eval(evmasm::Instruction _instruction, std::vector const& _arguments); /// Evaluate builtin function - dev::u256 evalBuiltin(BuiltinFunctionForEVM const& _fun, std::vector const& _arguments); + u256 evalBuiltin(BuiltinFunctionForEVM const& _fun, std::vector const& _arguments); private: /// Checks if the memory access is not too large for the interpreter and adjusts /// msize accordingly. /// @returns false if the amount of bytes read is lager than 0xffff - bool accessMemory(dev::u256 const& _offset, dev::u256 const& _size = 32); + bool accessMemory(u256 const& _offset, u256 const& _size = 32); /// @returns the memory contents at the provided address. /// Does not adjust msize, use @a accessMemory for that - dev::bytes readMemory(dev::u256 const& _offset, dev::u256 const& _size = 32); + bytes readMemory(u256 const& _offset, u256 const& _size = 32); /// @returns the memory contents at the provided address. /// Does not adjust msize, use @a accessMemory for that - dev::u256 readMemoryWord(dev::u256 const& _offset); + u256 readMemoryWord(u256 const& _offset); /// @returns writes a word to memory /// Does not adjust msize, use @a accessMemory for that - void writeMemoryWord(dev::u256 const& _offset, dev::u256 const& _value); + void writeMemoryWord(u256 const& _offset, u256 const& _value); - void logTrace(evmasm::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); + void logTrace(evmasm::Instruction _instruction, std::vector const& _arguments = {}, bytes const& _data = {}); /// Appends a log to the trace representing an instruction or similar operation by string, /// with arguments and auxiliary data (if nonempty). - void logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); + void logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments = {}, bytes const& _data = {}); InterpreterState& m_state; }; -} -} +} // solidity::yul::test diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index d98ca6a56..419b73d10 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -30,9 +30,11 @@ #include using namespace std; -using namespace dev; -using namespace yul; -using namespace yul::test; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::test; + +using solidity::util::h256; namespace { @@ -426,10 +428,10 @@ void EwasmBuiltinInterpreter::logTrace(std::string const& _pseudoInstruction, st { string message = _pseudoInstruction + "("; for (size_t i = 0; i < _arguments.size(); ++i) - message += (i > 0 ? ", " : "") + formatNumber(_arguments[i]); + message += (i > 0 ? ", " : "") + util::formatNumber(_arguments[i]); message += ")"; if (!_data.empty()) - message += " [" + toHex(_data) + "]"; + message += " [" + util::toHex(_data) + "]"; m_state.trace.emplace_back(std::move(message)); if (m_state.maxTraceSize > 0 && m_state.trace.size() >= m_state.maxTraceSize) { diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h index 891aa65d5..fc73bd020 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h @@ -26,20 +26,18 @@ #include -namespace dev -{ -namespace eth +namespace solidity::evmasm { enum class Instruction: uint8_t; } -} -namespace yul +namespace solidity::yul { class YulString; struct BuiltinFunctionForEVM; +} -namespace test +namespace solidity::yul::test { struct InterpreterState; @@ -70,16 +68,16 @@ public: m_state(_state) {} /// Evaluate builtin function - dev::u256 evalBuiltin(YulString _fun, std::vector const& _arguments); + u256 evalBuiltin(YulString _fun, std::vector const& _arguments); private: /// Checks if the memory access is not too large for the interpreter and adjusts /// msize accordingly. /// @returns false if the amount of bytes read is lager than 0xffff - bool accessMemory(dev::u256 const& _offset, dev::u256 const& _size = 32); + bool accessMemory(u256 const& _offset, u256 const& _size = 32); /// @returns the memory contents at the provided address. /// Does not adjust msize, use @a accessMemory for that - dev::bytes readMemory(uint64_t _offset, uint64_t _size = 32); + bytes readMemory(uint64_t _offset, uint64_t _size = 32); /// @returns the memory contents at the provided address (little-endian). /// Does not adjust msize, use @a accessMemory for that uint64_t readMemoryWord(uint64_t _offset); @@ -91,21 +89,20 @@ private: void writeMemoryByte(uint64_t _offset, uint8_t _value); /// Helper for eth.* builtins. Writes to memory (big-endian) and always returns zero. - void writeU256(uint64_t _offset, dev::u256 _value, size_t _croppedTo = 32); - void writeU128(uint64_t _offset, dev::u256 _value) { writeU256(_offset, std::move(_value), 16); } - void writeAddress(uint64_t _offset, dev::u256 _value) { writeU256(_offset, std::move(_value), 20); } + void writeU256(uint64_t _offset, u256 _value, size_t _croppedTo = 32); + void writeU128(uint64_t _offset, u256 _value) { writeU256(_offset, std::move(_value), 16); } + void writeAddress(uint64_t _offset, u256 _value) { writeU256(_offset, std::move(_value), 20); } /// Helper for eth.* builtins. Reads from memory (big-endian) and returns the value; - dev::u256 readU256(uint64_t _offset, size_t _croppedTo = 32); - dev::u256 readU128(uint64_t _offset) { return readU256(_offset, 16); } - dev::u256 readAddress(uint64_t _offset) { return readU256(_offset, 20); } + u256 readU256(uint64_t _offset, size_t _croppedTo = 32); + u256 readU128(uint64_t _offset) { return readU256(_offset, 16); } + u256 readAddress(uint64_t _offset) { return readU256(_offset, 20); } - void logTrace(evmasm::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); + void logTrace(evmasm::Instruction _instruction, std::vector const& _arguments = {}, bytes const& _data = {}); /// Appends a log to the trace representing an instruction or similar operation by string, /// with arguments and auxiliary data (if nonempty). - void logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); + void logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments = {}, bytes const& _data = {}); InterpreterState& m_state; }; } -} diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index 64f73803a..b1edacc9b 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -40,9 +40,11 @@ #include using namespace std; -using namespace dev; -using namespace yul; -using namespace yul::test; +using namespace solidity; +using namespace solidity::yul; +using namespace solidity::yul::test; + +using solidity::util::h256; void InterpreterState::dumpTraceAndState(ostream& _out) const { diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index d3ef30419..1cd871e41 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -30,14 +30,15 @@ #include -namespace yul +namespace solidity::yul { struct Dialect; +} -namespace test +namespace solidity::yul::test { -class InterpreterTerminatedGeneric: public dev::Exception +class InterpreterTerminatedGeneric: public util::Exception { }; @@ -63,27 +64,27 @@ enum class ControlFlowState struct InterpreterState { - dev::bytes calldata; - dev::bytes returndata; - std::map memory; + bytes calldata; + bytes returndata; + std::map memory; /// This is different than memory.size() because we ignore gas. - dev::u256 msize; - std::map storage; - dev::u160 address = 0x11111111; - dev::u256 balance = 0x22222222; - dev::u256 selfbalance = 0x22223333; - dev::u160 origin = 0x33333333; - dev::u160 caller = 0x44444444; - dev::u256 callvalue = 0x55555555; + u256 msize; + std::map storage; + u160 address = 0x11111111; + u256 balance = 0x22222222; + u256 selfbalance = 0x22223333; + u160 origin = 0x33333333; + u160 caller = 0x44444444; + u256 callvalue = 0x55555555; /// Deployed code - dev::bytes code = dev::asBytes("codecodecodecodecode"); - dev::u256 gasprice = 0x66666666; - dev::u160 coinbase = 0x77777777; - dev::u256 timestamp = 0x88888888; - dev::u256 blockNumber = 1024; - dev::u256 difficulty = 0x9999999; - dev::u256 gaslimit = 4000000; - dev::u256 chainid = 0x01; + bytes code = util::asBytes("codecodecodecodecode"); + u256 gasprice = 0x66666666; + u160 coinbase = 0x77777777; + u256 timestamp = 0x88888888; + u256 blockNumber = 1024; + u256 difficulty = 0x9999999; + u256 gaslimit = 4000000; + u256 chainid = 0x01; /// Log of changes / effects. Sholud be structured data in the future. std::vector trace; /// This is actually an input parameter that more or less limits the runtime. @@ -104,7 +105,7 @@ public: Interpreter( InterpreterState& _state, Dialect const& _dialect, - std::map _variables = {}, + std::map _variables = {}, std::vector> _scopes = {} ): m_dialect(_dialect), @@ -127,13 +128,13 @@ public: std::vector const& trace() const { return m_state.trace; } - dev::u256 valueOfVariable(YulString _name) const { return m_variables.at(_name); } + u256 valueOfVariable(YulString _name) const { return m_variables.at(_name); } private: /// Asserts that the expression evaluates to exactly one value and returns it. - dev::u256 evaluate(Expression const& _expression); + u256 evaluate(Expression const& _expression); /// Evaluates the expression and returns its value. - std::vector evaluateMulti(Expression const& _expression); + std::vector evaluateMulti(Expression const& _expression); void openScope() { m_scopes.push_back({}); } /// Unregisters variables and functions. @@ -142,7 +143,7 @@ private: Dialect const& m_dialect; InterpreterState& m_state; /// Values of variables. - std::map m_variables; + std::map m_variables; /// Scopes of variables and functions. Used for lookup, clearing at end of blocks /// and passing over the visible functions across function calls. /// The pointer is nullptr if and only if the key is a variable. @@ -158,7 +159,7 @@ public: ExpressionEvaluator( InterpreterState& _state, Dialect const& _dialect, - std::map const& _variables, + std::map const& _variables, std::vector> const& _scopes ): m_state(_state), @@ -172,12 +173,12 @@ public: void operator()(FunctionCall const& _funCall) override; /// Asserts that the expression has exactly one value and returns it. - dev::u256 value() const; + u256 value() const; /// Returns the list of values of the expression. - std::vector values() const { return m_values; } + std::vector values() const { return m_values; } private: - void setValue(dev::u256 _value); + void setValue(u256 _value); /// Evaluates the given expression from right to left and /// stores it in m_value. @@ -193,13 +194,12 @@ private: InterpreterState& m_state; Dialect const& m_dialect; /// Values of variables. - std::map const& m_variables; + std::map const& m_variables; /// Stack of scopes in the current context. std::vector> const& m_scopes; /// Current value of the expression - std::vector m_values; + std::vector m_values; }; } -} diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index f7318f45d..3a9b19721 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -76,10 +76,11 @@ #include using namespace std; -using namespace dev; -using namespace langutil; -using namespace dev::solidity; -using namespace yul; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::frontend; +using namespace solidity::yul; namespace po = boost::program_options; diff --git a/test/tools/yulrun.cpp b/test/tools/yulrun.cpp index 1f213fbd5..c18a6c322 100644 --- a/test/tools/yulrun.cpp +++ b/test/tools/yulrun.cpp @@ -42,10 +42,11 @@ #include using namespace std; -using namespace langutil; -using namespace yul; -using namespace dev; -using namespace yul::test; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::langutil; +using namespace solidity::yul; +using namespace solidity::yul::test; namespace po = boost::program_options; @@ -63,7 +64,7 @@ pair, shared_ptr> parse(string const& _source AssemblyStack stack( langutil::EVMVersion(), AssemblyStack::Language::StrictAssembly, - solidity::OptimiserSettings::none() + solidity::frontend::OptimiserSettings::none() ); if (stack.parseAndAnalyze("--INPUT--", _source)) { From 8ac6258d31671cfd9ed52c223296bd62c221de99 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 6 Jan 2020 11:23:58 +0100 Subject: [PATCH 33/57] lll: Adapted to namespace changes. --- liblll/CodeFragment.cpp | 7 ++++--- liblll/CodeFragment.h | 7 ++----- liblll/Compiler.cpp | 11 ++++++----- liblll/Compiler.h | 5 +---- liblll/CompilerState.cpp | 4 ++-- liblll/CompilerState.h | 5 +---- liblll/Exceptions.h | 7 ++----- liblll/Parser.cpp | 15 ++++++++------- liblll/Parser.h | 5 +---- lllc/main.cpp | 5 +++-- test/liblll/EndToEndTest.cpp | 9 ++------- test/liblll/ExecutionFramework.cpp | 2 +- test/liblll/LLL_ENS.cpp | 11 +++-------- test/liblll/LLL_ERC20.cpp | 11 +++-------- test/liblll/Parser.cpp | 8 +------- 15 files changed, 40 insertions(+), 72 deletions(-) diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 36f282feb..e6ae19199 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -40,9 +40,10 @@ using namespace std; -using namespace dev; -using namespace dev::eth; -using namespace dev::lll; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::evmasm; +using namespace solidity::lll; void CodeFragment::finalise(CompilerState const& _cs) { diff --git a/liblll/CodeFragment.h b/liblll/CodeFragment.h index cd6ad6f3e..c4dff9f6a 100644 --- a/liblll/CodeFragment.h +++ b/liblll/CodeFragment.h @@ -29,9 +29,7 @@ namespace boost { namespace spirit { class utree; } } namespace sp = boost::spirit; -namespace dev -{ -namespace lll +namespace solidity::lll { struct CompilerState; @@ -55,7 +53,7 @@ private: template static void error() { BOOST_THROW_EXCEPTION(T() ); } template static void error(std::string const& reason) { auto err = T(); - err << errinfo_comment(reason); + err << util::errinfo_comment(reason); BOOST_THROW_EXCEPTION(err); } void constructOperation(sp::utree const& _t, CompilerState& _s); @@ -68,4 +66,3 @@ private: static CodeFragment const NullCodeFragment; } -} diff --git a/liblll/Compiler.cpp b/liblll/Compiler.cpp index 2bea6ca6a..a1ccf47d6 100644 --- a/liblll/Compiler.cpp +++ b/liblll/Compiler.cpp @@ -25,10 +25,11 @@ #include using namespace std; -using namespace dev; -using namespace dev::lll; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::lll; -bytes dev::lll::compileLLL(string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector* _errors, ReadCallback const& _readFile) +bytes solidity::lll::compileLLL(string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector* _errors, ReadCallback const& _readFile) { try { @@ -66,7 +67,7 @@ bytes dev::lll::compileLLL(string _src, langutil::EVMVersion _evmVersion, bool _ return bytes(); } -std::string dev::lll::compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector* _errors, ReadCallback const& _readFile) +std::string solidity::lll::compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion, bool _opt, std::vector* _errors, ReadCallback const& _readFile) { try { @@ -104,7 +105,7 @@ std::string dev::lll::compileLLLToAsm(std::string _src, langutil::EVMVersion _ev return string(); } -string dev::lll::parseLLL(string _src) +string solidity::lll::parseLLL(string _src) { sp::utree o; diff --git a/liblll/Compiler.h b/liblll/Compiler.h index 14b10f750..23dae8537 100644 --- a/liblll/Compiler.h +++ b/liblll/Compiler.h @@ -28,9 +28,7 @@ #include #include -namespace dev -{ -namespace lll +namespace solidity::lll { using ReadCallback = std::function; @@ -40,4 +38,3 @@ std::string compileLLLToAsm(std::string _src, langutil::EVMVersion _evmVersion, bytes compileLLL(std::string _src, langutil::EVMVersion _evmVersion, bool _opt = true, std::vector* _errors = nullptr, ReadCallback const& _readFile = ReadCallback()); } -} diff --git a/liblll/CompilerState.cpp b/liblll/CompilerState.cpp index 2ae2b0af3..b35763ca5 100644 --- a/liblll/CompilerState.cpp +++ b/liblll/CompilerState.cpp @@ -23,8 +23,8 @@ #include using namespace std; -using namespace dev; -using namespace dev::lll; +using namespace solidity; +using namespace solidity::lll; CompilerState::CompilerState() { diff --git a/liblll/CompilerState.h b/liblll/CompilerState.h index d7ba38c33..2313272b1 100644 --- a/liblll/CompilerState.h +++ b/liblll/CompilerState.h @@ -24,9 +24,7 @@ #include #include -namespace dev -{ -namespace lll +namespace solidity::lll { struct Macro @@ -54,4 +52,3 @@ struct CompilerState }; } -} diff --git a/liblll/Exceptions.h b/liblll/Exceptions.h index 7bd951e35..25a01a2a8 100644 --- a/liblll/Exceptions.h +++ b/liblll/Exceptions.h @@ -23,13 +23,11 @@ #include -namespace dev -{ -namespace lll +namespace solidity::lll { /// Compile a Low-level Lisp-like Language program into EVM-code. -class CompilerException: public dev::Exception {}; +class CompilerException: public util::Exception {}; class InvalidOperation: public CompilerException {}; class IntegerOutOfRange: public CompilerException {}; class EmptyList: public CompilerException {}; @@ -42,4 +40,3 @@ class BareSymbol: public CompilerException {}; class ParserException: public CompilerException {}; } -} diff --git a/liblll/Parser.cpp b/liblll/Parser.cpp index 3b68bc2da..0f8ff1053 100644 --- a/liblll/Parser.cpp +++ b/liblll/Parser.cpp @@ -32,13 +32,14 @@ #include using namespace std; -using namespace dev; -using namespace dev::lll; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::lll; namespace qi = boost::spirit::qi; namespace px = boost::phoenix; namespace sp = boost::spirit; -void dev::lll::killBigints(sp::utree const& _this) +void solidity::lll::killBigints(sp::utree const& _this) { switch (_this.which()) { @@ -48,7 +49,7 @@ void dev::lll::killBigints(sp::utree const& _this) } } -void dev::lll::debugOutAST(ostream& _out, sp::utree const& _this) +void solidity::lll::debugOutAST(ostream& _out, sp::utree const& _this) { switch (_this.which()) { @@ -74,7 +75,7 @@ void dev::lll::debugOutAST(ostream& _out, sp::utree const& _this) } } -namespace dev { +namespace solidity { namespace lll { namespace parseTreeLLL_ { @@ -89,11 +90,11 @@ struct tagNode }}} -void dev::lll::parseTreeLLL(string const& _s, sp::utree& o_out) +void solidity::lll::parseTreeLLL(string const& _s, sp::utree& o_out) { using qi::standard::space; using qi::standard::space_type; - using dev::lll::parseTreeLLL_::tagNode; + using solidity::lll::parseTreeLLL_::tagNode; using symbol_type = sp::basic_string; using it = string::const_iterator; diff --git a/liblll/Parser.h b/liblll/Parser.h index 37b39c6b6..9dac1baed 100644 --- a/liblll/Parser.h +++ b/liblll/Parser.h @@ -29,9 +29,7 @@ namespace boost { namespace spirit { class utree; } } namespace sp = boost::spirit; -namespace dev -{ -namespace lll +namespace solidity::lll { void killBigints(sp::utree const& _this); @@ -39,4 +37,3 @@ void parseTreeLLL(std::string const& _s, sp::utree& o_out); void debugOutAST(std::ostream& _out, sp::utree const& _this); } -} diff --git a/lllc/main.cpp b/lllc/main.cpp index fab5c65ee..b04d58eef 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -30,8 +30,9 @@ #include using namespace std; -using namespace dev; -using namespace dev::lll; +using namespace solidity; +using namespace solidity::util; +using namespace solidity::lll; static string const VersionString = string(ETH_PROJECT_VERSION) + diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp index 531249885..cadfae757 100644 --- a/test/liblll/EndToEndTest.cpp +++ b/test/liblll/EndToEndTest.cpp @@ -29,13 +29,10 @@ #include using namespace std; +using namespace solidity::util; using namespace solidity::test; -namespace dev -{ -namespace lll -{ -namespace test +namespace solidity::lll::test { BOOST_FIXTURE_TEST_SUITE(LLLEndToEndTest, LLLExecutionFramework) @@ -1026,6 +1023,4 @@ BOOST_AUTO_TEST_CASE(string_literal) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/liblll/ExecutionFramework.cpp b/test/liblll/ExecutionFramework.cpp index 7e8cb7629..8f2cec672 100644 --- a/test/liblll/ExecutionFramework.cpp +++ b/test/liblll/ExecutionFramework.cpp @@ -25,7 +25,7 @@ #include using namespace solidity::test; -using namespace dev::lll::test; +using namespace solidity::lll::test; LLLExecutionFramework::LLLExecutionFramework() : ExecutionFramework() diff --git a/test/liblll/LLL_ENS.cpp b/test/liblll/LLL_ENS.cpp index a550be5a1..51d303b82 100644 --- a/test/liblll/LLL_ENS.cpp +++ b/test/liblll/LLL_ENS.cpp @@ -28,14 +28,11 @@ #define ACCOUNT(n) h256(account(n), h256::AlignRight) using namespace std; -using namespace dev::lll; +using namespace solidity::lll; +using namespace solidity::util; using namespace solidity::test; -namespace dev -{ -namespace lll -{ -namespace test +namespace solidity::lll::test { namespace @@ -503,6 +500,4 @@ BOOST_AUTO_TEST_CASE(fallback) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/liblll/LLL_ERC20.cpp b/test/liblll/LLL_ERC20.cpp index 43090dc09..4047ede8a 100644 --- a/test/liblll/LLL_ERC20.cpp +++ b/test/liblll/LLL_ERC20.cpp @@ -33,14 +33,11 @@ #define SUCCESS encodeArgs(1) using namespace std; -using namespace dev::lll; +using namespace solidity::lll; +using namespace solidity::util; using namespace solidity::test; -namespace dev -{ -namespace lll -{ -namespace test +namespace solidity::lll::test { namespace @@ -652,6 +649,4 @@ BOOST_AUTO_TEST_CASE(bad_data) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces diff --git a/test/liblll/Parser.cpp b/test/liblll/Parser.cpp index d343aab1f..bfee38171 100644 --- a/test/liblll/Parser.cpp +++ b/test/liblll/Parser.cpp @@ -27,11 +27,7 @@ using namespace std; -namespace dev -{ -namespace lll -{ -namespace test +namespace solidity::lll::test { namespace @@ -182,6 +178,4 @@ BOOST_AUTO_TEST_CASE(macro_with_zero_args) BOOST_AUTO_TEST_SUITE_END() -} -} } // end namespaces From 345f9928ab0e3259a9d3c1f2795ea4c50ca066ed Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 6 Jan 2020 11:52:23 +0100 Subject: [PATCH 34/57] Library libdevcore renamed to libsolutil. --- CMakeLists.txt | 2 +- CODING_STYLE.md | 6 ++-- Changelog.md | 2 +- libevmasm/Assembly.h | 6 ++-- libevmasm/AssemblyItem.cpp | 4 +-- libevmasm/AssemblyItem.h | 4 +-- libevmasm/BlockDeduplicator.h | 2 +- libevmasm/CommonSubexpressionEliminator.cpp | 2 +- libevmasm/CommonSubexpressionEliminator.h | 4 +-- libevmasm/ConstantOptimiser.cpp | 2 +- libevmasm/ConstantOptimiser.h | 6 ++-- libevmasm/ControlFlowGraph.h | 4 +-- libevmasm/Exceptions.h | 2 +- libevmasm/ExpressionClasses.h | 2 +- libevmasm/GasMeter.cpp | 2 +- libevmasm/Instruction.cpp | 4 +-- libevmasm/Instruction.h | 4 +-- libevmasm/KnownState.cpp | 2 +- libevmasm/KnownState.h | 4 +-- libevmasm/LinkerObject.cpp | 4 +-- libevmasm/LinkerObject.h | 4 +-- libevmasm/RuleList.h | 2 +- libevmasm/SimplificationRule.h | 2 +- libevmasm/SimplificationRules.cpp | 2 +- libevmasm/SimplificationRules.h | 2 +- liblangutil/ErrorReporter.h | 4 +-- liblangutil/Exceptions.h | 6 ++-- liblangutil/Scanner.h | 4 +-- liblangutil/SourceLocation.h | 6 ++-- liblangutil/SourceReferenceFormatterHuman.h | 2 +- liblangutil/Token.h | 2 +- liblll/CodeFragment.cpp | 2 +- liblll/CodeFragment.h | 2 +- liblll/Compiler.h | 2 +- liblll/Exceptions.h | 2 +- liblll/Parser.h | 2 +- libsolc/libsolc.cpp | 4 +-- libsolidity/analysis/ControlFlowAnalyzer.cpp | 2 +- libsolidity/analysis/DeclarationContainer.cpp | 2 +- libsolidity/analysis/NameAndTypeResolver.cpp | 2 +- libsolidity/analysis/OverrideChecker.cpp | 2 +- libsolidity/analysis/PostTypeChecker.cpp | 2 +- libsolidity/analysis/ReferencesResolver.cpp | 2 +- libsolidity/analysis/TypeChecker.cpp | 4 +-- libsolidity/ast/AST.cpp | 2 +- libsolidity/ast/AST.h | 2 +- libsolidity/ast/ASTJsonConverter.cpp | 4 +-- libsolidity/ast/Types.cpp | 10 +++---- libsolidity/ast/Types.h | 6 ++-- libsolidity/codegen/ABIFunctions.cpp | 6 ++-- libsolidity/codegen/CompilerContext.h | 2 +- libsolidity/codegen/CompilerUtils.cpp | 2 +- libsolidity/codegen/ContractCompiler.cpp | 2 +- libsolidity/codegen/ExpressionCompiler.cpp | 6 ++-- libsolidity/codegen/ExpressionCompiler.h | 2 +- libsolidity/codegen/YulUtilFunctions.cpp | 6 ++-- .../codegen/ir/IRGenerationContext.cpp | 4 +-- libsolidity/codegen/ir/IRGenerationContext.h | 2 +- libsolidity/codegen/ir/IRGenerator.cpp | 6 ++-- libsolidity/codegen/ir/IRLValue.cpp | 2 +- libsolidity/codegen/ir/IRLValue.h | 2 +- libsolidity/formal/CHCSmtLib2Interface.cpp | 2 +- libsolidity/formal/CVC4Interface.cpp | 2 +- libsolidity/formal/SMTLib2Interface.cpp | 2 +- libsolidity/formal/SMTLib2Interface.h | 4 +-- libsolidity/formal/SMTPortfolio.h | 2 +- libsolidity/formal/SolverInterface.h | 4 +-- libsolidity/formal/SymbolicTypes.cpp | 2 +- libsolidity/formal/Z3CHCInterface.cpp | 2 +- libsolidity/formal/Z3Interface.cpp | 2 +- libsolidity/interface/CompilerStack.cpp | 6 ++-- libsolidity/interface/CompilerStack.h | 4 +-- libsolidity/interface/GasEstimator.cpp | 2 +- libsolidity/interface/StandardCompiler.cpp | 4 +-- libsolidity/interface/Version.cpp | 4 +-- libsolidity/interface/Version.h | 2 +- {libdevcore => libsolutil}/Algorithms.h | 0 {libdevcore => libsolutil}/AnsiColorized.h | 0 {libdevcore => libsolutil}/Assertions.h | 2 +- {libdevcore => libsolutil}/CMakeLists.txt | 0 {libdevcore => libsolutil}/Common.h | 2 +- {libdevcore => libsolutil}/CommonData.cpp | 10 +++---- {libdevcore => libsolutil}/CommonData.h | 2 +- {libdevcore => libsolutil}/CommonIO.cpp | 4 +-- {libdevcore => libsolutil}/CommonIO.h | 2 +- {libdevcore => libsolutil}/Exceptions.cpp | 2 +- {libdevcore => libsolutil}/Exceptions.h | 0 {libdevcore => libsolutil}/FixedHash.h | 2 +- {libdevcore => libsolutil}/IndentedWriter.cpp | 4 +-- {libdevcore => libsolutil}/IndentedWriter.h | 2 +- {libdevcore => libsolutil}/InvertibleMap.h | 0 {libdevcore => libsolutil}/IpfsHash.cpp | 10 +++---- {libdevcore => libsolutil}/IpfsHash.h | 2 +- {libdevcore => libsolutil}/JSON.cpp | 4 +-- {libdevcore => libsolutil}/JSON.h | 0 {libdevcore => libsolutil}/Keccak256.cpp | 2 +- {libdevcore => libsolutil}/Keccak256.h | 2 +- {libdevcore => libsolutil}/Result.h | 0 {libdevcore => libsolutil}/StringUtils.cpp | 2 +- {libdevcore => libsolutil}/StringUtils.h | 2 +- {libdevcore => libsolutil}/SwarmHash.cpp | 4 +-- {libdevcore => libsolutil}/SwarmHash.h | 2 +- {libdevcore => libsolutil}/UTF8.cpp | 2 +- {libdevcore => libsolutil}/UTF8.h | 0 {libdevcore => libsolutil}/Visitor.h | 0 {libdevcore => libsolutil}/Whiskers.cpp | 4 +-- {libdevcore => libsolutil}/Whiskers.h | 2 +- {libdevcore => libsolutil}/picosha2.h | 0 {libdevcore => libsolutil}/vector_ref.h | 0 libyul/AsmJsonConverter.cpp | 2 +- libyul/AsmParser.cpp | 2 +- libyul/AsmPrinter.cpp | 2 +- libyul/AsmScope.h | 2 +- libyul/AsmScopeFiller.cpp | 2 +- libyul/Exceptions.h | 4 +-- libyul/Object.cpp | 4 +-- libyul/Object.h | 2 +- libyul/ObjectParser.h | 2 +- libyul/Utilities.cpp | 4 +-- libyul/Utilities.h | 2 +- libyul/backends/evm/AbstractAssembly.h | 4 +-- libyul/backends/evm/AsmCodeGen.cpp | 2 +- libyul/backends/evm/ConstantOptimiser.cpp | 2 +- libyul/backends/evm/ConstantOptimiser.h | 2 +- libyul/backends/evm/EVMMetrics.cpp | 4 +-- libyul/backends/wasm/BinaryTransform.cpp | 2 +- libyul/backends/wasm/BinaryTransform.h | 2 +- libyul/backends/wasm/TextTransform.cpp | 2 +- libyul/backends/wasm/WasmObjectCompiler.cpp | 2 +- libyul/backends/wasm/WasmObjectCompiler.h | 2 +- libyul/backends/wasm/WordSizeTransform.cpp | 2 +- libyul/optimiser/ASTCopier.cpp | 2 +- libyul/optimiser/BlockFlattener.cpp | 4 +-- libyul/optimiser/BlockHasher.cpp | 2 +- libyul/optimiser/CallGraphGenerator.h | 2 +- libyul/optimiser/ConditionalSimplifier.cpp | 4 +-- libyul/optimiser/ConditionalSimplifier.h | 2 +- libyul/optimiser/ConditionalUnsimplifier.cpp | 4 +-- libyul/optimiser/ConditionalUnsimplifier.h | 2 +- libyul/optimiser/ControlFlowSimplifier.cpp | 4 +-- libyul/optimiser/DataFlowAnalyzer.cpp | 2 +- libyul/optimiser/DataFlowAnalyzer.h | 2 +- .../optimiser/EquivalentFunctionCombiner.cpp | 2 +- libyul/optimiser/ExpressionJoiner.cpp | 2 +- libyul/optimiser/ExpressionSimplifier.cpp | 2 +- libyul/optimiser/ExpressionSplitter.cpp | 2 +- libyul/optimiser/ForLoopConditionIntoBody.cpp | 2 +- .../optimiser/ForLoopConditionOutOfBody.cpp | 2 +- libyul/optimiser/ForLoopInitRewriter.cpp | 2 +- libyul/optimiser/FullInliner.cpp | 4 +-- libyul/optimiser/FunctionHoister.cpp | 2 +- libyul/optimiser/KnowledgeBase.cpp | 2 +- libyul/optimiser/LoopInvariantCodeMotion.cpp | 2 +- libyul/optimiser/MainFunction.cpp | 2 +- libyul/optimiser/Metrics.cpp | 4 +-- libyul/optimiser/OptimizerUtilities.cpp | 2 +- libyul/optimiser/OptimizerUtilities.h | 2 +- .../optimiser/RedundantAssignEliminator.cpp | 2 +- libyul/optimiser/SSAReverser.cpp | 2 +- libyul/optimiser/SSATransform.cpp | 2 +- libyul/optimiser/Semantics.cpp | 4 +-- libyul/optimiser/SimplificationRules.h | 2 +- libyul/optimiser/StructuralSimplifier.cpp | 4 +-- libyul/optimiser/StructuralSimplifier.h | 2 +- libyul/optimiser/Suite.cpp | 2 +- libyul/optimiser/SyntacticalEquality.cpp | 2 +- libyul/optimiser/VarDeclInitializer.cpp | 4 +-- lllc/main.cpp | 4 +-- solc/CommandLineInterface.cpp | 8 +++--- test/CMakeLists.txt | 28 +++++++++---------- test/Common.cpp | 2 +- test/Common.h | 2 +- test/EVMHost.cpp | 8 +++--- test/EVMHost.h | 2 +- test/ExecutionFramework.cpp | 2 +- test/ExecutionFramework.h | 4 +-- test/Metadata.cpp | 6 ++-- test/Metadata.h | 2 +- test/TestCase.cpp | 2 +- test/libevmasm/Assembler.cpp | 2 +- test/liblll/Compiler.cpp | 2 +- test/libsolidity/ABIJsonTest.cpp | 4 +-- test/libsolidity/ASTJSONTest.cpp | 2 +- test/libsolidity/ASTJSONTest.h | 2 +- test/libsolidity/AnalysisFramework.cpp | 2 +- test/libsolidity/ErrorCheck.cpp | 2 +- test/libsolidity/GasCosts.cpp | 2 +- test/libsolidity/GasTest.cpp | 4 +-- test/libsolidity/LibSolc.cpp | 2 +- test/libsolidity/Metadata.cpp | 6 ++-- test/libsolidity/SMTCheckerJSONTest.cpp | 4 +-- test/libsolidity/SMTCheckerJSONTest.h | 2 +- test/libsolidity/SemanticTest.h | 2 +- test/libsolidity/SolidityEndToEndTest.cpp | 2 +- .../SolidityNameAndTypeResolution.cpp | 2 +- test/libsolidity/SolidityNatspecJSON.cpp | 4 +-- test/libsolidity/SolidityTypes.cpp | 2 +- test/libsolidity/StandardCompiler.cpp | 2 +- test/libsolidity/SyntaxTest.h | 2 +- test/libsolidity/util/BytesUtils.cpp | 2 +- test/libsolidity/util/BytesUtils.h | 2 +- test/libsolidity/util/ContractABIUtils.h | 2 +- test/libsolidity/util/SoltestErrors.h | 6 ++-- test/libsolidity/util/SoltestTypes.h | 4 +-- test/libsolidity/util/TestFileParser.h | 2 +- test/libsolidity/util/TestFunctionCall.cpp | 2 +- test/libsolidity/util/TestFunctionCall.h | 4 +-- test/{libdevcore => libsolutil}/Checksum.cpp | 4 +-- .../{libdevcore => libsolutil}/CommonData.cpp | 6 ++-- .../IndentedWriter.cpp | 2 +- test/{libdevcore => libsolutil}/IpfsHash.cpp | 2 +- .../IterateReplacing.cpp | 2 +- test/{libdevcore => libsolutil}/JSON.cpp | 2 +- test/{libdevcore => libsolutil}/Keccak256.cpp | 2 +- .../StringUtils.cpp | 6 ++-- test/{libdevcore => libsolutil}/SwarmHash.cpp | 4 +-- test/{libdevcore => libsolutil}/UTF8.cpp | 4 +-- test/{libdevcore => libsolutil}/Whiskers.cpp | 2 +- test/libyul/EwasmTranslationTest.cpp | 2 +- test/libyul/FunctionSideEffects.cpp | 4 +-- test/libyul/FunctionSideEffects.h | 2 +- test/libyul/ObjectCompilerTest.cpp | 2 +- test/libyul/YulInterpreterTest.cpp | 2 +- test/libyul/YulOptimizerTest.cpp | 2 +- test/tools/IsolTestOptions.cpp | 2 +- test/tools/afl_fuzzer.cpp | 2 +- test/tools/fuzzer_common.cpp | 2 +- test/tools/isoltest.cpp | 4 +-- test/tools/ossfuzz/abiV2FuzzerCommon.h | 2 +- test/tools/ossfuzz/protoToAbiV2.h | 8 +++--- test/tools/ossfuzz/protoToYul.cpp | 2 +- test/tools/ossfuzz/protoToYul.h | 6 ++-- test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp | 4 +-- .../EVMInstructionInterpreter.cpp | 2 +- .../EVMInstructionInterpreter.h | 2 +- .../EwasmBuiltinInterpreter.cpp | 2 +- .../yulInterpreter/EwasmBuiltinInterpreter.h | 2 +- test/tools/yulInterpreter/Interpreter.cpp | 2 +- test/tools/yulInterpreter/Interpreter.h | 6 ++-- test/tools/yulopti.cpp | 4 +-- test/tools/yulrun.cpp | 4 +-- 241 files changed, 355 insertions(+), 355 deletions(-) rename {libdevcore => libsolutil}/Algorithms.h (100%) rename {libdevcore => libsolutil}/AnsiColorized.h (100%) rename {libdevcore => libsolutil}/Assertions.h (97%) rename {libdevcore => libsolutil}/CMakeLists.txt (100%) rename {libdevcore => libsolutil}/Common.h (99%) rename {libdevcore => libsolutil}/CommonData.cpp (96%) rename {libdevcore => libsolutil}/CommonData.h (99%) rename {libdevcore => libsolutil}/CommonIO.cpp (98%) rename {libdevcore => libsolutil}/CommonIO.h (98%) rename {libdevcore => libsolutil}/Exceptions.cpp (97%) rename {libdevcore => libsolutil}/Exceptions.h (100%) rename {libdevcore => libsolutil}/FixedHash.h (99%) rename {libdevcore => libsolutil}/IndentedWriter.cpp (95%) rename {libdevcore => libsolutil}/IndentedWriter.h (97%) rename {libdevcore => libsolutil}/InvertibleMap.h (100%) rename {libdevcore => libsolutil}/IpfsHash.cpp (93%) rename {libdevcore => libsolutil}/IpfsHash.h (97%) rename {libdevcore => libsolutil}/JSON.cpp (98%) rename {libdevcore => libsolutil}/JSON.h (100%) rename {libdevcore => libsolutil}/Keccak256.cpp (99%) rename {libdevcore => libsolutil}/Keccak256.h (97%) rename {libdevcore => libsolutil}/Result.h (100%) rename {libdevcore => libsolutil}/StringUtils.cpp (99%) rename {libdevcore => libsolutil}/StringUtils.h (99%) rename {libdevcore => libsolutil}/SwarmHash.cpp (97%) rename {libdevcore => libsolutil}/SwarmHash.h (96%) rename {libdevcore => libsolutil}/UTF8.cpp (98%) rename {libdevcore => libsolutil}/UTF8.h (100%) rename {libdevcore => libsolutil}/Visitor.h (100%) rename {libdevcore => libsolutil}/Whiskers.cpp (98%) rename {libdevcore => libsolutil}/Whiskers.h (99%) rename {libdevcore => libsolutil}/picosha2.h (100%) rename {libdevcore => libsolutil}/vector_ref.h (100%) rename test/{libdevcore => libsolutil}/Checksum.cpp (98%) rename test/{libdevcore => libsolutil}/CommonData.cpp (98%) rename test/{libdevcore => libsolutil}/IndentedWriter.cpp (97%) rename test/{libdevcore => libsolutil}/IpfsHash.cpp (98%) rename test/{libdevcore => libsolutil}/IterateReplacing.cpp (98%) rename test/{libdevcore => libsolutil}/JSON.cpp (98%) rename test/{libdevcore => libsolutil}/Keccak256.cpp (98%) rename test/{libdevcore => libsolutil}/StringUtils.cpp (98%) rename test/{libdevcore => libsolutil}/SwarmHash.cpp (98%) rename test/{libdevcore => libsolutil}/UTF8.cpp (98%) rename test/{libdevcore => libsolutil}/Whiskers.cpp (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb8c1a49c..3c7a6b533 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" include/licens include(EthOptions) configure_project(TESTS) -add_subdirectory(libdevcore) +add_subdirectory(libsolutil) add_subdirectory(liblangutil) add_subdirectory(libevmasm) add_subdirectory(libyul) diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 0d17fad18..6bdb48fba 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -211,7 +211,7 @@ for (map::iterator i = l.begin(); i != l.end(); ## 12. Include Headers -1. Includes should go in increasing order of generality (`libsolidity` -> `libevmasm` -> `libdevcore` -> `boost` -> `STL`). +1. Includes should go in increasing order of generality (`libsolidity` -> `libevmasm` -> `libsolutil` -> `boost` -> `STL`). 2. The corresponding `.h` file should be the first include in the respective `.cpp` file. 3. Insert empty lines between blocks of include files. @@ -226,8 +226,8 @@ Example: #include -#include -#include +#include +#include #include #include diff --git a/Changelog.md b/Changelog.md index 4487b30e4..14125c809 100644 --- a/Changelog.md +++ b/Changelog.md @@ -900,7 +900,7 @@ Features: * ABI JSON: Include new field ``stateMutability`` with values ``pure``, ``view``, ``nonpayable`` and ``payable``. * Analyzer: Experimental partial support for Z3 SMT checker ("SMTChecker"). - * Build System: Shared libraries (``libdevcore``, ``libevmasm``, ``libsolidity`` + * Build System: Shared libraries (``libsolutil``, ``libevmasm``, ``libsolidity`` and ``liblll``) are no longer produced during the build process. * Code generator: Experimental new implementation of ABI encoder that can encode arbitrarily nested arrays ("ABIEncoderV2") diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index de5f46465..9e146be01 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -25,9 +25,9 @@ #include -#include -#include -#include +#include +#include +#include #include diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index a2104a576..b9b6c4acd 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -17,8 +17,8 @@ #include -#include -#include +#include +#include #include diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h index b860a3657..31f175103 100644 --- a/libevmasm/AssemblyItem.h +++ b/libevmasm/AssemblyItem.h @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libevmasm/BlockDeduplicator.h b/libevmasm/BlockDeduplicator.h index ecb4bc797..ce12b4bfb 100644 --- a/libevmasm/BlockDeduplicator.h +++ b/libevmasm/BlockDeduplicator.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include #include diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index 945768120..747f78f24 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/libevmasm/CommonSubexpressionEliminator.h b/libevmasm/CommonSubexpressionEliminator.h index 1b7a7e168..0e6f6ee36 100644 --- a/libevmasm/CommonSubexpressionEliminator.h +++ b/libevmasm/CommonSubexpressionEliminator.h @@ -28,8 +28,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index b6b746231..8e6d991a5 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h index b46b1936d..a9db47ab1 100644 --- a/libevmasm/ConstantOptimiser.h +++ b/libevmasm/ConstantOptimiser.h @@ -25,9 +25,9 @@ #include -#include -#include -#include +#include +#include +#include #include diff --git a/libevmasm/ControlFlowGraph.h b/libevmasm/ControlFlowGraph.h index f5bf487c5..a0c2b9632 100644 --- a/libevmasm/ControlFlowGraph.h +++ b/libevmasm/ControlFlowGraph.h @@ -25,8 +25,8 @@ #include #include -#include -#include +#include +#include #include namespace solidity::evmasm diff --git a/libevmasm/Exceptions.h b/libevmasm/Exceptions.h index f4d4cfa93..e4fadb53c 100644 --- a/libevmasm/Exceptions.h +++ b/libevmasm/Exceptions.h @@ -21,7 +21,7 @@ #pragma once -#include +#include namespace solidity::evmasm { diff --git a/libevmasm/ExpressionClasses.h b/libevmasm/ExpressionClasses.h index 7014cc46d..f9eebabd0 100644 --- a/libevmasm/ExpressionClasses.h +++ b/libevmasm/ExpressionClasses.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include #include diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index cd781b71d..358d67c3a 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -19,7 +19,7 @@ #include -#include +#include using namespace std; using namespace solidity; diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index 47930fb4e..34fef1642 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -21,8 +21,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 78146c1e9..511e3cf1b 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -22,8 +22,8 @@ #pragma once #include -#include -#include +#include +#include #include namespace solidity::evmasm diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index e8838afa4..b6198e994 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h index 7a9efa13d..a9cc4f201 100644 --- a/libevmasm/KnownState.h +++ b/libevmasm/KnownState.h @@ -41,8 +41,8 @@ #pragma clang diagnostic pop #endif // defined(__clang__) -#include -#include +#include +#include #include #include diff --git a/libevmasm/LinkerObject.cpp b/libevmasm/LinkerObject.cpp index 2906c9abf..21b213101 100644 --- a/libevmasm/LinkerObject.cpp +++ b/libevmasm/LinkerObject.cpp @@ -20,8 +20,8 @@ */ #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/libevmasm/LinkerObject.h b/libevmasm/LinkerObject.h index 85439485d..e7a1e9667 100644 --- a/libevmasm/LinkerObject.h +++ b/libevmasm/LinkerObject.h @@ -21,8 +21,8 @@ #pragma once -#include -#include +#include +#include namespace solidity::evmasm { diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index f2daa88ea..812c67002 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/libevmasm/SimplificationRule.h b/libevmasm/SimplificationRule.h index f50090ce4..3e40e25ed 100644 --- a/libevmasm/SimplificationRule.h +++ b/libevmasm/SimplificationRule.h @@ -21,7 +21,7 @@ #pragma once #include -#include +#include #include namespace solidity::evmasm diff --git a/libevmasm/SimplificationRules.cpp b/libevmasm/SimplificationRules.cpp index 542e650b8..751153b05 100644 --- a/libevmasm/SimplificationRules.cpp +++ b/libevmasm/SimplificationRules.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/libevmasm/SimplificationRules.h b/libevmasm/SimplificationRules.h index 0d02aa15a..72884d32a 100644 --- a/libevmasm/SimplificationRules.h +++ b/libevmasm/SimplificationRules.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include diff --git a/liblangutil/ErrorReporter.h b/liblangutil/ErrorReporter.h index d4147e050..3acf5afee 100644 --- a/liblangutil/ErrorReporter.h +++ b/liblangutil/ErrorReporter.h @@ -22,11 +22,11 @@ #pragma once -#include +#include #include #include -#include +#include #include diff --git a/liblangutil/Exceptions.h b/liblangutil/Exceptions.h index 93096ad75..de72eba37 100644 --- a/liblangutil/Exceptions.h +++ b/liblangutil/Exceptions.h @@ -26,9 +26,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include namespace solidity::langutil diff --git a/liblangutil/Scanner.h b/liblangutil/Scanner.h index 8dda74bfc..20dfbf29c 100644 --- a/liblangutil/Scanner.h +++ b/liblangutil/Scanner.h @@ -55,8 +55,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/liblangutil/SourceLocation.h b/liblangutil/SourceLocation.h index 5f3d637e3..d86dd206a 100644 --- a/liblangutil/SourceLocation.h +++ b/liblangutil/SourceLocation.h @@ -22,9 +22,9 @@ #pragma once -#include -#include // defines noexcept macro for MSVC -#include +#include +#include // defines noexcept macro for MSVC +#include #include #include #include diff --git a/liblangutil/SourceReferenceFormatterHuman.h b/liblangutil/SourceReferenceFormatterHuman.h index a04344a8b..060adc00e 100644 --- a/liblangutil/SourceReferenceFormatterHuman.h +++ b/liblangutil/SourceReferenceFormatterHuman.h @@ -23,7 +23,7 @@ #include #include // SourceReferenceFormatterBase -#include +#include #include #include diff --git a/liblangutil/Token.h b/liblangutil/Token.h index ee76605fe..ed6cff3e1 100644 --- a/liblangutil/Token.h +++ b/liblangutil/Token.h @@ -42,7 +42,7 @@ #pragma once -#include +#include #include #include diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index e6ae19199..556f3dcf6 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include diff --git a/liblll/CodeFragment.h b/liblll/CodeFragment.h index c4dff9f6a..894c91821 100644 --- a/liblll/CodeFragment.h +++ b/liblll/CodeFragment.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include namespace boost { namespace spirit { class utree; } } namespace sp = boost::spirit; diff --git a/liblll/Compiler.h b/liblll/Compiler.h index 23dae8537..8d2989ce5 100644 --- a/liblll/Compiler.h +++ b/liblll/Compiler.h @@ -21,7 +21,7 @@ #pragma once -#include +#include #include diff --git a/liblll/Exceptions.h b/liblll/Exceptions.h index 25a01a2a8..57fbf6ad3 100644 --- a/liblll/Exceptions.h +++ b/liblll/Exceptions.h @@ -21,7 +21,7 @@ #pragma once -#include +#include namespace solidity::lll { diff --git a/liblll/Parser.h b/liblll/Parser.h index 9dac1baed..424356e0c 100644 --- a/liblll/Parser.h +++ b/liblll/Parser.h @@ -22,7 +22,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp index 8e8afe899..d216ae8a2 100644 --- a/libsolc/libsolc.cpp +++ b/libsolc/libsolc.cpp @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/analysis/ControlFlowAnalyzer.cpp b/libsolidity/analysis/ControlFlowAnalyzer.cpp index 84088cc42..a774dee61 100644 --- a/libsolidity/analysis/ControlFlowAnalyzer.cpp +++ b/libsolidity/analysis/ControlFlowAnalyzer.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include using namespace std; diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index 036511d33..2450778cd 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 7995ae6c9..c2e9124a7 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include using namespace std; diff --git a/libsolidity/analysis/OverrideChecker.cpp b/libsolidity/analysis/OverrideChecker.cpp index f401020d1..fc2c8df62 100644 --- a/libsolidity/analysis/OverrideChecker.cpp +++ b/libsolidity/analysis/OverrideChecker.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index 0c3cc4afe..a83c51d3b 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 7c809ad83..889ec4d2d 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index a7f4c8762..e1b289c73 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -31,8 +31,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index e8065c370..bd48c21a4 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 203914bdb..0c36128b0 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index d42a4d8f4..655f3c670 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -26,8 +26,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 7e140e9c4..4f596468b 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -25,11 +25,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 13a9c5628..0308fc452 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -27,9 +27,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index ea7106ede..df8cacf86 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -23,9 +23,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index 9abda7aa1..45f16f1f1 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 8d7cfb386..f9a0fbcec 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index bbe064402..ecf62d29a 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -35,7 +35,7 @@ #include -#include +#include #include #include diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 7e460db9d..921e2ecff 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -29,9 +29,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index 2842b7e78..57f198819 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index 0f62450c9..b06d07182 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -24,9 +24,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/libsolidity/codegen/ir/IRGenerationContext.cpp b/libsolidity/codegen/ir/IRGenerationContext.cpp index 3a2bdb9f0..29fc3aa03 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.cpp +++ b/libsolidity/codegen/ir/IRGenerationContext.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/libsolidity/codegen/ir/IRGenerationContext.h b/libsolidity/codegen/ir/IRGenerationContext.h index f2710e6ab..3151d4357 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.h +++ b/libsolidity/codegen/ir/IRGenerationContext.h @@ -26,7 +26,7 @@ #include -#include +#include #include #include diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index e004fc173..bd2099c4a 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -32,9 +32,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/libsolidity/codegen/ir/IRLValue.cpp b/libsolidity/codegen/ir/IRLValue.cpp index 99b0daa0c..9cbf4e992 100644 --- a/libsolidity/codegen/ir/IRLValue.cpp +++ b/libsolidity/codegen/ir/IRLValue.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libsolidity/codegen/ir/IRLValue.h b/libsolidity/codegen/ir/IRLValue.h index 412ad54f5..7b58416c0 100644 --- a/libsolidity/codegen/ir/IRLValue.h +++ b/libsolidity/codegen/ir/IRLValue.h @@ -22,7 +22,7 @@ #include -#include +#include #include #include diff --git a/libsolidity/formal/CHCSmtLib2Interface.cpp b/libsolidity/formal/CHCSmtLib2Interface.cpp index b654207e4..1b58b791e 100644 --- a/libsolidity/formal/CHCSmtLib2Interface.cpp +++ b/libsolidity/formal/CHCSmtLib2Interface.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include diff --git a/libsolidity/formal/CVC4Interface.cpp b/libsolidity/formal/CVC4Interface.cpp index c2aa8d65b..9aecc2586 100644 --- a/libsolidity/formal/CVC4Interface.cpp +++ b/libsolidity/formal/CVC4Interface.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libsolidity/formal/SMTLib2Interface.cpp b/libsolidity/formal/SMTLib2Interface.cpp index 850bcee69..74529b4c5 100644 --- a/libsolidity/formal/SMTLib2Interface.cpp +++ b/libsolidity/formal/SMTLib2Interface.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include diff --git a/libsolidity/formal/SMTLib2Interface.h b/libsolidity/formal/SMTLib2Interface.h index 550b8af7c..17d385cb2 100644 --- a/libsolidity/formal/SMTLib2Interface.h +++ b/libsolidity/formal/SMTLib2Interface.h @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/formal/SMTPortfolio.h b/libsolidity/formal/SMTPortfolio.h index 1cd1e6f89..7799f2268 100644 --- a/libsolidity/formal/SMTPortfolio.h +++ b/libsolidity/formal/SMTPortfolio.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/libsolidity/formal/SolverInterface.h b/libsolidity/formal/SolverInterface.h index 3afb0c468..512be65bb 100644 --- a/libsolidity/formal/SolverInterface.h +++ b/libsolidity/formal/SolverInterface.h @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/formal/SymbolicTypes.cpp b/libsolidity/formal/SymbolicTypes.cpp index 90cf33a63..a2475b337 100644 --- a/libsolidity/formal/SymbolicTypes.cpp +++ b/libsolidity/formal/SymbolicTypes.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include using namespace std; diff --git a/libsolidity/formal/Z3CHCInterface.cpp b/libsolidity/formal/Z3CHCInterface.cpp index 05b0a2032..c64da2edc 100644 --- a/libsolidity/formal/Z3CHCInterface.cpp +++ b/libsolidity/formal/Z3CHCInterface.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 679dda43e..20150c337 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include using namespace std; using namespace solidity::frontend::smt; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index e6d50f7e4..7c64d0df3 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -58,9 +58,9 @@ #include -#include -#include -#include +#include +#include +#include #include diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 80249ec5c..0e9ffaff1 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -35,8 +35,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/interface/GasEstimator.cpp b/libsolidity/interface/GasEstimator.cpp index 8e6827ed0..7282b1598 100644 --- a/libsolidity/interface/GasEstimator.cpp +++ b/libsolidity/interface/GasEstimator.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index a942c74be..3a86914d1 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -27,8 +27,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/interface/Version.cpp b/libsolidity/interface/Version.cpp index f00192861..412750bc8 100644 --- a/libsolidity/interface/Version.cpp +++ b/libsolidity/interface/Version.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/libsolidity/interface/Version.h b/libsolidity/interface/Version.h index 60d624a3c..f2b1ad429 100644 --- a/libsolidity/interface/Version.h +++ b/libsolidity/interface/Version.h @@ -22,7 +22,7 @@ #pragma once -#include +#include #include namespace solidity::frontend diff --git a/libdevcore/Algorithms.h b/libsolutil/Algorithms.h similarity index 100% rename from libdevcore/Algorithms.h rename to libsolutil/Algorithms.h diff --git a/libdevcore/AnsiColorized.h b/libsolutil/AnsiColorized.h similarity index 100% rename from libdevcore/AnsiColorized.h rename to libsolutil/AnsiColorized.h diff --git a/libdevcore/Assertions.h b/libsolutil/Assertions.h similarity index 97% rename from libdevcore/Assertions.h rename to libsolutil/Assertions.h index f74991651..c0c330835 100644 --- a/libdevcore/Assertions.h +++ b/libsolutil/Assertions.h @@ -24,7 +24,7 @@ #pragma once -#include +#include namespace solidity::util { diff --git a/libdevcore/CMakeLists.txt b/libsolutil/CMakeLists.txt similarity index 100% rename from libdevcore/CMakeLists.txt rename to libsolutil/CMakeLists.txt diff --git a/libdevcore/Common.h b/libsolutil/Common.h similarity index 99% rename from libdevcore/Common.h rename to libsolutil/Common.h index 4075ce153..35bd37fe8 100644 --- a/libdevcore/Common.h +++ b/libsolutil/Common.h @@ -37,7 +37,7 @@ #pragma warning(disable:3682) //call through incomplete class #endif -#include +#include #include #if (BOOST_VERSION < 106500) diff --git a/libdevcore/CommonData.cpp b/libsolutil/CommonData.cpp similarity index 96% rename from libdevcore/CommonData.cpp rename to libsolutil/CommonData.cpp index d6104861b..2024a1b1f 100644 --- a/libdevcore/CommonData.cpp +++ b/libsolutil/CommonData.cpp @@ -19,11 +19,11 @@ * @date 2014 */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/libdevcore/CommonData.h b/libsolutil/CommonData.h similarity index 99% rename from libdevcore/CommonData.h rename to libsolutil/CommonData.h index d9566a2fe..c7c9d80e3 100644 --- a/libdevcore/CommonData.h +++ b/libsolutil/CommonData.h @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libdevcore/CommonIO.cpp b/libsolutil/CommonIO.cpp similarity index 98% rename from libdevcore/CommonIO.cpp rename to libsolutil/CommonIO.cpp index ee7f5ead4..0eca85720 100644 --- a/libdevcore/CommonIO.cpp +++ b/libsolutil/CommonIO.cpp @@ -19,8 +19,8 @@ * @date 2014 */ -#include -#include +#include +#include #include diff --git a/libdevcore/CommonIO.h b/libsolutil/CommonIO.h similarity index 98% rename from libdevcore/CommonIO.h rename to libsolutil/CommonIO.h index 52232be14..15291df33 100644 --- a/libdevcore/CommonIO.h +++ b/libsolutil/CommonIO.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include #include #include diff --git a/libdevcore/Exceptions.cpp b/libsolutil/Exceptions.cpp similarity index 97% rename from libdevcore/Exceptions.cpp rename to libsolutil/Exceptions.cpp index e0e0c4bd8..94b40f634 100644 --- a/libdevcore/Exceptions.cpp +++ b/libsolutil/Exceptions.cpp @@ -15,7 +15,7 @@ along with solidity. If not, see . */ -#include +#include using namespace std; using namespace solidity::util; diff --git a/libdevcore/Exceptions.h b/libsolutil/Exceptions.h similarity index 100% rename from libdevcore/Exceptions.h rename to libsolutil/Exceptions.h diff --git a/libdevcore/FixedHash.h b/libsolutil/FixedHash.h similarity index 99% rename from libdevcore/FixedHash.h rename to libsolutil/FixedHash.h index 3a9ebdcc8..90c0ab4dc 100644 --- a/libdevcore/FixedHash.h +++ b/libsolutil/FixedHash.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include #include diff --git a/libdevcore/IndentedWriter.cpp b/libsolutil/IndentedWriter.cpp similarity index 95% rename from libdevcore/IndentedWriter.cpp rename to libsolutil/IndentedWriter.cpp index 11bf869eb..884b50e9c 100644 --- a/libdevcore/IndentedWriter.cpp +++ b/libsolutil/IndentedWriter.cpp @@ -19,8 +19,8 @@ * Indented text writer. */ -#include -#include +#include +#include using namespace std; using namespace solidity::util; diff --git a/libdevcore/IndentedWriter.h b/libsolutil/IndentedWriter.h similarity index 97% rename from libdevcore/IndentedWriter.h rename to libsolutil/IndentedWriter.h index 1f56ce8a3..29ecc4f6d 100644 --- a/libdevcore/IndentedWriter.h +++ b/libsolutil/IndentedWriter.h @@ -24,7 +24,7 @@ #include #include -#include +#include namespace solidity::util { diff --git a/libdevcore/InvertibleMap.h b/libsolutil/InvertibleMap.h similarity index 100% rename from libdevcore/InvertibleMap.h rename to libsolutil/InvertibleMap.h diff --git a/libdevcore/IpfsHash.cpp b/libsolutil/IpfsHash.cpp similarity index 93% rename from libdevcore/IpfsHash.cpp rename to libsolutil/IpfsHash.cpp index 246854038..d6a511a24 100644 --- a/libdevcore/IpfsHash.cpp +++ b/libsolutil/IpfsHash.cpp @@ -15,12 +15,12 @@ along with solidity. If not, see . */ -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include using namespace std; using namespace solidity; diff --git a/libdevcore/IpfsHash.h b/libsolutil/IpfsHash.h similarity index 97% rename from libdevcore/IpfsHash.h rename to libsolutil/IpfsHash.h index 1a9638005..555b35961 100644 --- a/libdevcore/IpfsHash.h +++ b/libsolutil/IpfsHash.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include diff --git a/libdevcore/JSON.cpp b/libsolutil/JSON.cpp similarity index 98% rename from libdevcore/JSON.cpp rename to libsolutil/JSON.cpp index 0fdbcd411..c66aab9b2 100644 --- a/libdevcore/JSON.cpp +++ b/libsolutil/JSON.cpp @@ -19,9 +19,9 @@ * @date 2018 */ -#include +#include -#include +#include #include diff --git a/libdevcore/JSON.h b/libsolutil/JSON.h similarity index 100% rename from libdevcore/JSON.h rename to libsolutil/JSON.h diff --git a/libdevcore/Keccak256.cpp b/libsolutil/Keccak256.cpp similarity index 99% rename from libdevcore/Keccak256.cpp rename to libsolutil/Keccak256.cpp index e0df05cd6..d9e9363f6 100644 --- a/libdevcore/Keccak256.cpp +++ b/libsolutil/Keccak256.cpp @@ -19,7 +19,7 @@ * @date 2014 */ -#include +#include #include #include diff --git a/libdevcore/Keccak256.h b/libsolutil/Keccak256.h similarity index 97% rename from libdevcore/Keccak256.h rename to libsolutil/Keccak256.h index eeba453c9..7135e55c0 100644 --- a/libdevcore/Keccak256.h +++ b/libsolutil/Keccak256.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include diff --git a/libdevcore/Result.h b/libsolutil/Result.h similarity index 100% rename from libdevcore/Result.h rename to libsolutil/Result.h diff --git a/libdevcore/StringUtils.cpp b/libsolutil/StringUtils.cpp similarity index 99% rename from libdevcore/StringUtils.cpp rename to libsolutil/StringUtils.cpp index 004e9cdb2..a5b0149c2 100644 --- a/libdevcore/StringUtils.cpp +++ b/libsolutil/StringUtils.cpp @@ -21,7 +21,7 @@ * String routines */ -#include +#include #include #include #include diff --git a/libdevcore/StringUtils.h b/libsolutil/StringUtils.h similarity index 99% rename from libdevcore/StringUtils.h rename to libsolutil/StringUtils.h index 72668031a..98158aa6d 100644 --- a/libdevcore/StringUtils.h +++ b/libsolutil/StringUtils.h @@ -26,7 +26,7 @@ #include #include -#include +#include namespace solidity::util { diff --git a/libdevcore/SwarmHash.cpp b/libsolutil/SwarmHash.cpp similarity index 97% rename from libdevcore/SwarmHash.cpp rename to libsolutil/SwarmHash.cpp index 388bb8f0d..4cfc0fe66 100644 --- a/libdevcore/SwarmHash.cpp +++ b/libsolutil/SwarmHash.cpp @@ -17,9 +17,9 @@ /** @file SwarmHash.cpp */ -#include +#include -#include +#include using namespace std; using namespace solidity; diff --git a/libdevcore/SwarmHash.h b/libsolutil/SwarmHash.h similarity index 96% rename from libdevcore/SwarmHash.h rename to libsolutil/SwarmHash.h index 52c779811..3905b2f5f 100644 --- a/libdevcore/SwarmHash.h +++ b/libsolutil/SwarmHash.h @@ -19,7 +19,7 @@ #pragma once -#include +#include #include diff --git a/libdevcore/UTF8.cpp b/libsolutil/UTF8.cpp similarity index 98% rename from libdevcore/UTF8.cpp rename to libsolutil/UTF8.cpp index 98ee8904c..a7d55af6c 100644 --- a/libdevcore/UTF8.cpp +++ b/libsolutil/UTF8.cpp @@ -21,7 +21,7 @@ * UTF-8 related helpers */ -#include +#include namespace solidity::util { diff --git a/libdevcore/UTF8.h b/libsolutil/UTF8.h similarity index 100% rename from libdevcore/UTF8.h rename to libsolutil/UTF8.h diff --git a/libdevcore/Visitor.h b/libsolutil/Visitor.h similarity index 100% rename from libdevcore/Visitor.h rename to libsolutil/Visitor.h diff --git a/libdevcore/Whiskers.cpp b/libsolutil/Whiskers.cpp similarity index 98% rename from libdevcore/Whiskers.cpp rename to libsolutil/Whiskers.cpp index a40398086..208719d43 100644 --- a/libdevcore/Whiskers.cpp +++ b/libsolutil/Whiskers.cpp @@ -21,9 +21,9 @@ * Moustache-like templates. */ -#include +#include -#include +#include #include diff --git a/libdevcore/Whiskers.h b/libsolutil/Whiskers.h similarity index 99% rename from libdevcore/Whiskers.h rename to libsolutil/Whiskers.h index 04020d6ff..0165429fb 100644 --- a/libdevcore/Whiskers.h +++ b/libsolutil/Whiskers.h @@ -23,7 +23,7 @@ #pragma once -#include +#include #include #include diff --git a/libdevcore/picosha2.h b/libsolutil/picosha2.h similarity index 100% rename from libdevcore/picosha2.h rename to libsolutil/picosha2.h diff --git a/libdevcore/vector_ref.h b/libsolutil/vector_ref.h similarity index 100% rename from libdevcore/vector_ref.h rename to libsolutil/vector_ref.h diff --git a/libyul/AsmJsonConverter.cpp b/libyul/AsmJsonConverter.cpp index d71e57254..4af0380cd 100644 --- a/libyul/AsmJsonConverter.cpp +++ b/libyul/AsmJsonConverter.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include using namespace std; diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index 839c5c0df..ac9ccce76 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index 718dfc15d..eb894f0a1 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/libyul/AsmScope.h b/libyul/AsmScope.h index adb0fba98..a452e04ba 100644 --- a/libyul/AsmScope.h +++ b/libyul/AsmScope.h @@ -24,7 +24,7 @@ #include -#include +#include #include #include diff --git a/libyul/AsmScopeFiller.cpp b/libyul/AsmScopeFiller.cpp index 46b868d91..3a8e548b8 100644 --- a/libyul/AsmScopeFiller.cpp +++ b/libyul/AsmScopeFiller.cpp @@ -27,7 +27,7 @@ #include -#include +#include #include diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h index a627610fb..9bb6a5d04 100644 --- a/libyul/Exceptions.h +++ b/libyul/Exceptions.h @@ -20,8 +20,8 @@ #pragma once -#include -#include +#include +#include namespace solidity::yul { diff --git a/libyul/Object.cpp b/libyul/Object.cpp index 64408230e..4006f6d81 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/libyul/Object.h b/libyul/Object.h index 7bcb70921..d7926d8bb 100644 --- a/libyul/Object.h +++ b/libyul/Object.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/libyul/ObjectParser.h b/libyul/ObjectParser.h index 14ce80f07..1bd9d956f 100644 --- a/libyul/ObjectParser.h +++ b/libyul/ObjectParser.h @@ -27,7 +27,7 @@ #include #include -#include +#include #include diff --git a/libyul/Utilities.cpp b/libyul/Utilities.cpp index b6951decb..dfe72b05e 100644 --- a/libyul/Utilities.cpp +++ b/libyul/Utilities.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/libyul/Utilities.h b/libyul/Utilities.h index 9198e46ca..8b4547be3 100644 --- a/libyul/Utilities.h +++ b/libyul/Utilities.h @@ -20,7 +20,7 @@ #pragma once -#include +#include #include namespace solidity::yul diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index de83a1e9a..9187bb88d 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -22,8 +22,8 @@ #pragma once -#include -#include +#include +#include #include #include diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 94c4fad64..a864b0a09 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -32,7 +32,7 @@ #include -#include +#include #include #include diff --git a/libyul/backends/evm/ConstantOptimiser.cpp b/libyul/backends/evm/ConstantOptimiser.cpp index 83003144f..d8399d095 100644 --- a/libyul/backends/evm/ConstantOptimiser.cpp +++ b/libyul/backends/evm/ConstantOptimiser.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/libyul/backends/evm/ConstantOptimiser.h b/libyul/backends/evm/ConstantOptimiser.h index 97ce9879f..7423b5270 100644 --- a/libyul/backends/evm/ConstantOptimiser.h +++ b/libyul/backends/evm/ConstantOptimiser.h @@ -28,7 +28,7 @@ #include -#include +#include #include #include diff --git a/libyul/backends/evm/EVMMetrics.cpp b/libyul/backends/evm/EVMMetrics.cpp index 43c2a3cf5..4d1103578 100644 --- a/libyul/backends/evm/EVMMetrics.cpp +++ b/libyul/backends/evm/EVMMetrics.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/libyul/backends/wasm/BinaryTransform.cpp b/libyul/backends/wasm/BinaryTransform.cpp index 5ea09e9e4..8abd2b080 100644 --- a/libyul/backends/wasm/BinaryTransform.cpp +++ b/libyul/backends/wasm/BinaryTransform.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/libyul/backends/wasm/BinaryTransform.h b/libyul/backends/wasm/BinaryTransform.h index 6c9128489..d4e4375c2 100644 --- a/libyul/backends/wasm/BinaryTransform.h +++ b/libyul/backends/wasm/BinaryTransform.h @@ -22,7 +22,7 @@ #include -#include +#include #include #include diff --git a/libyul/backends/wasm/TextTransform.cpp b/libyul/backends/wasm/TextTransform.cpp index 72b6d01c1..3edeb9365 100644 --- a/libyul/backends/wasm/TextTransform.cpp +++ b/libyul/backends/wasm/TextTransform.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include diff --git a/libyul/backends/wasm/WasmObjectCompiler.cpp b/libyul/backends/wasm/WasmObjectCompiler.cpp index a6683b5ab..52d485a7f 100644 --- a/libyul/backends/wasm/WasmObjectCompiler.cpp +++ b/libyul/backends/wasm/WasmObjectCompiler.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include using namespace solidity; using namespace solidity::yul; diff --git a/libyul/backends/wasm/WasmObjectCompiler.h b/libyul/backends/wasm/WasmObjectCompiler.h index 8c93aba64..c5932a976 100644 --- a/libyul/backends/wasm/WasmObjectCompiler.h +++ b/libyul/backends/wasm/WasmObjectCompiler.h @@ -23,7 +23,7 @@ #include #include #include -#include // solidity::bytes +#include // solidity::bytes namespace solidity::yul { diff --git a/libyul/backends/wasm/WordSizeTransform.cpp b/libyul/backends/wasm/WordSizeTransform.cpp index d1867a2e8..79df8be9a 100644 --- a/libyul/backends/wasm/WordSizeTransform.cpp +++ b/libyul/backends/wasm/WordSizeTransform.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/libyul/optimiser/ASTCopier.cpp b/libyul/optimiser/ASTCopier.cpp index 99868d27f..16f257818 100644 --- a/libyul/optimiser/ASTCopier.cpp +++ b/libyul/optimiser/ASTCopier.cpp @@ -24,7 +24,7 @@ #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/BlockFlattener.cpp b/libyul/optimiser/BlockFlattener.cpp index 804d6ea77..02e4c42f5 100644 --- a/libyul/optimiser/BlockFlattener.cpp +++ b/libyul/optimiser/BlockFlattener.cpp @@ -16,8 +16,8 @@ */ #include #include -#include -#include +#include +#include #include using namespace std; diff --git a/libyul/optimiser/BlockHasher.cpp b/libyul/optimiser/BlockHasher.cpp index 0c6c04a1c..a878db601 100644 --- a/libyul/optimiser/BlockHasher.cpp +++ b/libyul/optimiser/BlockHasher.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/CallGraphGenerator.h b/libyul/optimiser/CallGraphGenerator.h index 89895e410..2a05c7564 100644 --- a/libyul/optimiser/CallGraphGenerator.h +++ b/libyul/optimiser/CallGraphGenerator.h @@ -22,7 +22,7 @@ #include -#include +#include #include #include diff --git a/libyul/optimiser/ConditionalSimplifier.cpp b/libyul/optimiser/ConditionalSimplifier.cpp index 3cd92283a..858ac8999 100644 --- a/libyul/optimiser/ConditionalSimplifier.cpp +++ b/libyul/optimiser/ConditionalSimplifier.cpp @@ -19,8 +19,8 @@ #include #include #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/ConditionalSimplifier.h b/libyul/optimiser/ConditionalSimplifier.h index 9f0cd6b34..18f8a74b2 100644 --- a/libyul/optimiser/ConditionalSimplifier.h +++ b/libyul/optimiser/ConditionalSimplifier.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace solidity::yul { diff --git a/libyul/optimiser/ConditionalUnsimplifier.cpp b/libyul/optimiser/ConditionalUnsimplifier.cpp index 6670034d0..f11079032 100644 --- a/libyul/optimiser/ConditionalUnsimplifier.cpp +++ b/libyul/optimiser/ConditionalUnsimplifier.cpp @@ -19,8 +19,8 @@ #include #include #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/ConditionalUnsimplifier.h b/libyul/optimiser/ConditionalUnsimplifier.h index 0b5be9bfd..116ab2536 100644 --- a/libyul/optimiser/ConditionalUnsimplifier.h +++ b/libyul/optimiser/ConditionalUnsimplifier.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace solidity::yul { diff --git a/libyul/optimiser/ControlFlowSimplifier.cpp b/libyul/optimiser/ControlFlowSimplifier.cpp index df5ead104..8af8e6bb0 100644 --- a/libyul/optimiser/ControlFlowSimplifier.cpp +++ b/libyul/optimiser/ControlFlowSimplifier.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp index e1874088d..db1517f59 100644 --- a/libyul/optimiser/DataFlowAnalyzer.cpp +++ b/libyul/optimiser/DataFlowAnalyzer.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index 64de71a14..45f41bea8 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -31,7 +31,7 @@ // TODO avoid #include -#include +#include #include #include diff --git a/libyul/optimiser/EquivalentFunctionCombiner.cpp b/libyul/optimiser/EquivalentFunctionCombiner.cpp index 894563678..d62768a25 100644 --- a/libyul/optimiser/EquivalentFunctionCombiner.cpp +++ b/libyul/optimiser/EquivalentFunctionCombiner.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/ExpressionJoiner.cpp b/libyul/optimiser/ExpressionJoiner.cpp index 4558a1c87..ba38fa86e 100644 --- a/libyul/optimiser/ExpressionJoiner.cpp +++ b/libyul/optimiser/ExpressionJoiner.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include diff --git a/libyul/optimiser/ExpressionSimplifier.cpp b/libyul/optimiser/ExpressionSimplifier.cpp index 0653eb9a7..da3056057 100644 --- a/libyul/optimiser/ExpressionSimplifier.cpp +++ b/libyul/optimiser/ExpressionSimplifier.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/ExpressionSplitter.cpp b/libyul/optimiser/ExpressionSplitter.cpp index 94c107da9..d95e11a81 100644 --- a/libyul/optimiser/ExpressionSplitter.cpp +++ b/libyul/optimiser/ExpressionSplitter.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include diff --git a/libyul/optimiser/ForLoopConditionIntoBody.cpp b/libyul/optimiser/ForLoopConditionIntoBody.cpp index 81f038cbf..a45b33635 100644 --- a/libyul/optimiser/ForLoopConditionIntoBody.cpp +++ b/libyul/optimiser/ForLoopConditionIntoBody.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/ForLoopConditionOutOfBody.cpp b/libyul/optimiser/ForLoopConditionOutOfBody.cpp index 1d8291cf7..fc7d48d62 100644 --- a/libyul/optimiser/ForLoopConditionOutOfBody.cpp +++ b/libyul/optimiser/ForLoopConditionOutOfBody.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp index 60a901e1d..163a999cd 100644 --- a/libyul/optimiser/ForLoopInitRewriter.cpp +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -16,7 +16,7 @@ */ #include #include -#include +#include #include using namespace std; diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index 487e16db0..4b72e4ad9 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -30,8 +30,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/libyul/optimiser/FunctionHoister.cpp b/libyul/optimiser/FunctionHoister.cpp index b3e8c32f7..303cf1fb3 100644 --- a/libyul/optimiser/FunctionHoister.cpp +++ b/libyul/optimiser/FunctionHoister.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/KnowledgeBase.cpp b/libyul/optimiser/KnowledgeBase.cpp index d71e1ec25..398c2f213 100644 --- a/libyul/optimiser/KnowledgeBase.cpp +++ b/libyul/optimiser/KnowledgeBase.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/libyul/optimiser/LoopInvariantCodeMotion.cpp b/libyul/optimiser/LoopInvariantCodeMotion.cpp index ed176dc8b..b7d7874c2 100644 --- a/libyul/optimiser/LoopInvariantCodeMotion.cpp +++ b/libyul/optimiser/LoopInvariantCodeMotion.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include diff --git a/libyul/optimiser/MainFunction.cpp b/libyul/optimiser/MainFunction.cpp index ab58fb374..e91cadb4d 100644 --- a/libyul/optimiser/MainFunction.cpp +++ b/libyul/optimiser/MainFunction.cpp @@ -26,7 +26,7 @@ #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/Metrics.cpp b/libyul/optimiser/Metrics.cpp index b470a7286..bcd723464 100644 --- a/libyul/optimiser/Metrics.cpp +++ b/libyul/optimiser/Metrics.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/OptimizerUtilities.cpp b/libyul/optimiser/OptimizerUtilities.cpp index 19d6e2406..132301696 100644 --- a/libyul/optimiser/OptimizerUtilities.cpp +++ b/libyul/optimiser/OptimizerUtilities.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/libyul/optimiser/OptimizerUtilities.h b/libyul/optimiser/OptimizerUtilities.h index 153cd7b7e..01bb7dae6 100644 --- a/libyul/optimiser/OptimizerUtilities.h +++ b/libyul/optimiser/OptimizerUtilities.h @@ -20,7 +20,7 @@ #pragma once -#include +#include #include namespace solidity::yul diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/RedundantAssignEliminator.cpp index faa040f31..236a27fb0 100644 --- a/libyul/optimiser/RedundantAssignEliminator.cpp +++ b/libyul/optimiser/RedundantAssignEliminator.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include diff --git a/libyul/optimiser/SSAReverser.cpp b/libyul/optimiser/SSAReverser.cpp index 03593c2e9..a4373fb66 100644 --- a/libyul/optimiser/SSAReverser.cpp +++ b/libyul/optimiser/SSAReverser.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include diff --git a/libyul/optimiser/SSATransform.cpp b/libyul/optimiser/SSATransform.cpp index fbd3cdd10..91454b9ee 100644 --- a/libyul/optimiser/SSATransform.cpp +++ b/libyul/optimiser/SSATransform.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/Semantics.cpp b/libyul/optimiser/Semantics.cpp index 8c6cab95f..1e2dcb104 100644 --- a/libyul/optimiser/Semantics.cpp +++ b/libyul/optimiser/Semantics.cpp @@ -27,8 +27,8 @@ #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/SimplificationRules.h b/libyul/optimiser/SimplificationRules.h index 25443e129..866fcb90e 100644 --- a/libyul/optimiser/SimplificationRules.h +++ b/libyul/optimiser/SimplificationRules.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp index c4dcd6bee..836169701 100644 --- a/libyul/optimiser/StructuralSimplifier.cpp +++ b/libyul/optimiser/StructuralSimplifier.cpp @@ -18,8 +18,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/libyul/optimiser/StructuralSimplifier.h b/libyul/optimiser/StructuralSimplifier.h index ab17d1b1a..8b9df5beb 100644 --- a/libyul/optimiser/StructuralSimplifier.h +++ b/libyul/optimiser/StructuralSimplifier.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace solidity::yul { diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp index ba0ca07a9..6cf592f8a 100644 --- a/libyul/optimiser/Suite.cpp +++ b/libyul/optimiser/Suite.cpp @@ -64,7 +64,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/SyntacticalEquality.cpp b/libyul/optimiser/SyntacticalEquality.cpp index 3af7ccf01..1ce5da7d1 100644 --- a/libyul/optimiser/SyntacticalEquality.cpp +++ b/libyul/optimiser/SyntacticalEquality.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include using namespace std; using namespace solidity; diff --git a/libyul/optimiser/VarDeclInitializer.cpp b/libyul/optimiser/VarDeclInitializer.cpp index 36fe07a91..bad601f0e 100644 --- a/libyul/optimiser/VarDeclInitializer.cpp +++ b/libyul/optimiser/VarDeclInitializer.cpp @@ -18,8 +18,8 @@ #include #include -#include -#include +#include +#include using namespace std; using namespace solidity; diff --git a/lllc/main.cpp b/lllc/main.cpp index b04d58eef..75d193e23 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index e81efa1d4..af5d45179 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -44,10 +44,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 609f9f047..223cf4e5f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,20 +24,20 @@ set(contracts_sources ) detect_stray_source_files("${contracts_sources}" "contracts/") -set(libdevcore_sources - libdevcore/Checksum.cpp - libdevcore/CommonData.cpp - libdevcore/IndentedWriter.cpp - libdevcore/IpfsHash.cpp - libdevcore/IterateReplacing.cpp - libdevcore/JSON.cpp - libdevcore/Keccak256.cpp - libdevcore/StringUtils.cpp - libdevcore/SwarmHash.cpp - libdevcore/UTF8.cpp - libdevcore/Whiskers.cpp +set(libsolutil_sources + libsolutil/Checksum.cpp + libsolutil/CommonData.cpp + libsolutil/IndentedWriter.cpp + libsolutil/IpfsHash.cpp + libsolutil/IterateReplacing.cpp + libsolutil/JSON.cpp + libsolutil/Keccak256.cpp + libsolutil/StringUtils.cpp + libsolutil/SwarmHash.cpp + libsolutil/UTF8.cpp + libsolutil/Whiskers.cpp ) -detect_stray_source_files("${libdevcore_sources}" "libdevcore/") +detect_stray_source_files("${libsolutil_sources}" "libsolutil/") set(libevmasm_sources libevmasm/Assembler.cpp @@ -151,7 +151,7 @@ detect_stray_source_files("${libyul_sources}" "libyul/") add_executable(soltest ${sources} ${contracts_sources} - ${libdevcore_sources} + ${libsolutil_sources} ${liblangutil_sources} ${libevmasm_sources} ${libyul_sources} diff --git a/test/Common.cpp b/test/Common.cpp index ddbb25739..1cd5c3e13 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include diff --git a/test/Common.h b/test/Common.h index bf65627ca..88b75507a 100644 --- a/test/Common.h +++ b/test/Common.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include #include diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 49cb5808f..fd5394fb5 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -25,10 +25,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include using namespace std; using namespace solidity; diff --git a/test/EVMHost.h b/test/EVMHost.h index 31e08e411..1e3540012 100644 --- a/test/EVMHost.h +++ b/test/EVMHost.h @@ -27,7 +27,7 @@ #include -#include +#include namespace solidity::test { diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index 528ee6a88..51d73284b 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -26,7 +26,7 @@ #include -#include +#include #include #include diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 9f4150525..33301b6f2 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -29,8 +29,8 @@ #include -#include -#include +#include +#include #include diff --git a/test/Metadata.cpp b/test/Metadata.cpp index 12a5d3aae..cf61c4c99 100644 --- a/test/Metadata.cpp +++ b/test/Metadata.cpp @@ -21,9 +21,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include using namespace std; diff --git a/test/Metadata.h b/test/Metadata.h index f769f438f..f032f1d1f 100644 --- a/test/Metadata.h +++ b/test/Metadata.h @@ -19,7 +19,7 @@ * Metadata processing helpers. */ -#include +#include #include #include diff --git a/test/TestCase.cpp b/test/TestCase.cpp index e8b47c38d..01dc51e7c 100644 --- a/test/TestCase.cpp +++ b/test/TestCase.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include diff --git a/test/libevmasm/Assembler.cpp b/test/libevmasm/Assembler.cpp index 30a36c58c..f03c9fbb9 100644 --- a/test/libevmasm/Assembler.cpp +++ b/test/libevmasm/Assembler.cpp @@ -20,7 +20,7 @@ * Tests for the assembler. */ -#include +#include #include #include diff --git a/test/liblll/Compiler.cpp b/test/liblll/Compiler.cpp index 3f9c4eceb..3c60e7ee9 100644 --- a/test/liblll/Compiler.cpp +++ b/test/liblll/Compiler.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/ABIJsonTest.cpp b/test/libsolidity/ABIJsonTest.cpp index 4f41725ce..daaee026c 100644 --- a/test/libsolidity/ABIJsonTest.cpp +++ b/test/libsolidity/ABIJsonTest.cpp @@ -23,8 +23,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index 673e30b92..c42daf14c 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/libsolidity/ASTJSONTest.h b/test/libsolidity/ASTJSONTest.h index 01e9895a8..92658edd6 100644 --- a/test/libsolidity/ASTJSONTest.h +++ b/test/libsolidity/ASTJSONTest.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include #include diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index 003953e70..a76af1081 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -29,7 +29,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/ErrorCheck.cpp b/test/libsolidity/ErrorCheck.cpp index 0c57d525f..1f51006ed 100644 --- a/test/libsolidity/ErrorCheck.cpp +++ b/test/libsolidity/ErrorCheck.cpp @@ -20,7 +20,7 @@ */ #include -#include +#include #include #include diff --git a/test/libsolidity/GasCosts.cpp b/test/libsolidity/GasCosts.cpp index c3f842f6f..d3312d7e4 100644 --- a/test/libsolidity/GasCosts.cpp +++ b/test/libsolidity/GasCosts.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index e7b7f325c..c29608b5c 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -17,8 +17,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/test/libsolidity/LibSolc.cpp b/test/libsolidity/LibSolc.cpp index cb4f8d2cc..9802e37c2 100644 --- a/test/libsolidity/LibSolc.cpp +++ b/test/libsolidity/LibSolc.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index ba5261675..e8bf69348 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -23,9 +23,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include using namespace std; diff --git a/test/libsolidity/SMTCheckerJSONTest.cpp b/test/libsolidity/SMTCheckerJSONTest.cpp index 7758a2437..cee5b560a 100644 --- a/test/libsolidity/SMTCheckerJSONTest.cpp +++ b/test/libsolidity/SMTCheckerJSONTest.cpp @@ -18,8 +18,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/test/libsolidity/SMTCheckerJSONTest.h b/test/libsolidity/SMTCheckerJSONTest.h index 8d40c1ee8..b5d199e7d 100644 --- a/test/libsolidity/SMTCheckerJSONTest.h +++ b/test/libsolidity/SMTCheckerJSONTest.h @@ -19,7 +19,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/SemanticTest.h b/test/libsolidity/SemanticTest.h index b885b1565..680e03316 100644 --- a/test/libsolidity/SemanticTest.h +++ b/test/libsolidity/SemanticTest.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index e8d29755b..df89fb3f9 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -31,7 +31,7 @@ #include -#include +#include #include #include diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 3baa740b4..e5e82d392 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -26,7 +26,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index d59b59685..965bfc7c8 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -22,10 +22,10 @@ #include #include -#include +#include #include #include -#include +#include using namespace solidity::langutil; diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp index 0701b8187..debec99b7 100644 --- a/test/libsolidity/SolidityTypes.cpp +++ b/test/libsolidity/SolidityTypes.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include using namespace std; diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index 8b354d9a3..31c37060a 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include using namespace std; diff --git a/test/libsolidity/SyntaxTest.h b/test/libsolidity/SyntaxTest.h index a231a951f..0a1752f10 100644 --- a/test/libsolidity/SyntaxTest.h +++ b/test/libsolidity/SyntaxTest.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/libsolidity/util/BytesUtils.cpp b/test/libsolidity/util/BytesUtils.cpp index c91231521..751318f9c 100644 --- a/test/libsolidity/util/BytesUtils.cpp +++ b/test/libsolidity/util/BytesUtils.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/util/BytesUtils.h b/test/libsolidity/util/BytesUtils.h index 99e33055e..e97aa90c9 100644 --- a/test/libsolidity/util/BytesUtils.h +++ b/test/libsolidity/util/BytesUtils.h @@ -16,7 +16,7 @@ #include -#include +#include namespace solidity::frontend::test { diff --git a/test/libsolidity/util/ContractABIUtils.h b/test/libsolidity/util/ContractABIUtils.h index 2c9ce0da2..0e56c98e5 100644 --- a/test/libsolidity/util/ContractABIUtils.h +++ b/test/libsolidity/util/ContractABIUtils.h @@ -18,7 +18,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/util/SoltestErrors.h b/test/libsolidity/util/SoltestErrors.h index a9a7e88e0..f895e706b 100644 --- a/test/libsolidity/util/SoltestErrors.h +++ b/test/libsolidity/util/SoltestErrors.h @@ -14,9 +14,9 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace solidity::frontend::test { diff --git a/test/libsolidity/util/SoltestTypes.h b/test/libsolidity/util/SoltestTypes.h index 8b2bed9a4..0fec97eb1 100644 --- a/test/libsolidity/util/SoltestTypes.h +++ b/test/libsolidity/util/SoltestTypes.h @@ -14,8 +14,8 @@ #pragma once -#include -#include +#include +#include #include namespace solidity::frontend::test diff --git a/test/libsolidity/util/TestFileParser.h b/test/libsolidity/util/TestFileParser.h index 1e6fbf21a..a10bb1114 100644 --- a/test/libsolidity/util/TestFileParser.h +++ b/test/libsolidity/util/TestFileParser.h @@ -14,7 +14,7 @@ #pragma once -#include +#include #include #include #include diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index 5cf48f88d..ac7a92a08 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index 4717f9903..baa0990b1 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/test/libdevcore/Checksum.cpp b/test/libsolutil/Checksum.cpp similarity index 98% rename from test/libdevcore/Checksum.cpp rename to test/libsolutil/Checksum.cpp index a306e45cc..e813f7bfb 100644 --- a/test/libdevcore/Checksum.cpp +++ b/test/libsolutil/Checksum.cpp @@ -18,8 +18,8 @@ * Unit tests for the address checksum. */ -#include -#include +#include +#include #include diff --git a/test/libdevcore/CommonData.cpp b/test/libsolutil/CommonData.cpp similarity index 98% rename from test/libdevcore/CommonData.cpp rename to test/libsolutil/CommonData.cpp index 5f6e744e4..e2687b53b 100644 --- a/test/libdevcore/CommonData.cpp +++ b/test/libsolutil/CommonData.cpp @@ -18,9 +18,9 @@ * Unit tests for the StringUtils routines. */ -#include -#include -#include +#include +#include +#include #include // for IntegerType #include diff --git a/test/libdevcore/IndentedWriter.cpp b/test/libsolutil/IndentedWriter.cpp similarity index 97% rename from test/libdevcore/IndentedWriter.cpp rename to test/libsolutil/IndentedWriter.cpp index bde910d13..3f7c31c02 100644 --- a/test/libdevcore/IndentedWriter.cpp +++ b/test/libsolutil/IndentedWriter.cpp @@ -18,7 +18,7 @@ * Unit tests for IndentedWriter. */ -#include +#include #include diff --git a/test/libdevcore/IpfsHash.cpp b/test/libsolutil/IpfsHash.cpp similarity index 98% rename from test/libdevcore/IpfsHash.cpp rename to test/libsolutil/IpfsHash.cpp index ee7baad1c..bb82f7b5c 100644 --- a/test/libdevcore/IpfsHash.cpp +++ b/test/libsolutil/IpfsHash.cpp @@ -18,7 +18,7 @@ * Unit tests for the ipfs hash computation routine. */ -#include +#include #include diff --git a/test/libdevcore/IterateReplacing.cpp b/test/libsolutil/IterateReplacing.cpp similarity index 98% rename from test/libdevcore/IterateReplacing.cpp rename to test/libsolutil/IterateReplacing.cpp index c17dacdc0..ebd82c9c7 100644 --- a/test/libdevcore/IterateReplacing.cpp +++ b/test/libsolutil/IterateReplacing.cpp @@ -18,7 +18,7 @@ * Unit tests for the iterateReplacing function */ -#include +#include #include diff --git a/test/libdevcore/JSON.cpp b/test/libsolutil/JSON.cpp similarity index 98% rename from test/libdevcore/JSON.cpp rename to test/libsolutil/JSON.cpp index 33886333a..176d3027a 100644 --- a/test/libdevcore/JSON.cpp +++ b/test/libsolutil/JSON.cpp @@ -19,7 +19,7 @@ * Unit tests for JSON.h. */ -#include +#include #include diff --git a/test/libdevcore/Keccak256.cpp b/test/libsolutil/Keccak256.cpp similarity index 98% rename from test/libdevcore/Keccak256.cpp rename to test/libsolutil/Keccak256.cpp index ac97b6edd..4bb3bddd6 100644 --- a/test/libdevcore/Keccak256.cpp +++ b/test/libsolutil/Keccak256.cpp @@ -17,7 +17,7 @@ /** * Unit tests for keccak256. */ -#include +#include #include diff --git a/test/libdevcore/StringUtils.cpp b/test/libsolutil/StringUtils.cpp similarity index 98% rename from test/libdevcore/StringUtils.cpp rename to test/libsolutil/StringUtils.cpp index 14551bbeb..3b977e0f6 100644 --- a/test/libdevcore/StringUtils.cpp +++ b/test/libsolutil/StringUtils.cpp @@ -18,9 +18,9 @@ * Unit tests for the StringUtils routines. */ -#include -#include -#include +#include +#include +#include #include // for IntegerType diff --git a/test/libdevcore/SwarmHash.cpp b/test/libsolutil/SwarmHash.cpp similarity index 98% rename from test/libdevcore/SwarmHash.cpp rename to test/libsolutil/SwarmHash.cpp index 8aa34fe7a..03c5af5f7 100644 --- a/test/libdevcore/SwarmHash.cpp +++ b/test/libsolutil/SwarmHash.cpp @@ -18,11 +18,11 @@ * Unit tests for the swarm hash computation routine. */ -#include +#include #include -#include +#include using namespace std; diff --git a/test/libdevcore/UTF8.cpp b/test/libsolutil/UTF8.cpp similarity index 98% rename from test/libdevcore/UTF8.cpp rename to test/libsolutil/UTF8.cpp index aadb54987..8bb49e9a4 100644 --- a/test/libdevcore/UTF8.cpp +++ b/test/libsolutil/UTF8.cpp @@ -18,8 +18,8 @@ * Unit tests for UTF-8 validation. */ -#include -#include +#include +#include #include diff --git a/test/libdevcore/Whiskers.cpp b/test/libsolutil/Whiskers.cpp similarity index 99% rename from test/libdevcore/Whiskers.cpp rename to test/libsolutil/Whiskers.cpp index 56341e6ce..293ffedfd 100644 --- a/test/libdevcore/Whiskers.cpp +++ b/test/libsolutil/Whiskers.cpp @@ -18,7 +18,7 @@ * Unit tests for the mini moustache class. */ -#include +#include #include diff --git a/test/libyul/EwasmTranslationTest.cpp b/test/libyul/EwasmTranslationTest.cpp index cd5ce7623..a5e01d286 100644 --- a/test/libyul/EwasmTranslationTest.cpp +++ b/test/libyul/EwasmTranslationTest.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include diff --git a/test/libyul/FunctionSideEffects.cpp b/test/libyul/FunctionSideEffects.cpp index 6577f7383..d7a184dc4 100644 --- a/test/libyul/FunctionSideEffects.cpp +++ b/test/libyul/FunctionSideEffects.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -27,7 +27,7 @@ #include #include -#include +#include #include diff --git a/test/libyul/FunctionSideEffects.h b/test/libyul/FunctionSideEffects.h index 829a17c2e..b35994b00 100644 --- a/test/libyul/FunctionSideEffects.h +++ b/test/libyul/FunctionSideEffects.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include #include diff --git a/test/libyul/ObjectCompilerTest.cpp b/test/libyul/ObjectCompilerTest.cpp index e7c87a708..7472b124f 100644 --- a/test/libyul/ObjectCompilerTest.cpp +++ b/test/libyul/ObjectCompilerTest.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include diff --git a/test/libyul/YulInterpreterTest.cpp b/test/libyul/YulInterpreterTest.cpp index 8818206fa..939fa2e1e 100644 --- a/test/libyul/YulInterpreterTest.cpp +++ b/test/libyul/YulInterpreterTest.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index fb3f8360d..053b7772e 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -70,7 +70,7 @@ #include #include -#include +#include #include #include diff --git a/test/tools/IsolTestOptions.cpp b/test/tools/IsolTestOptions.cpp index 0921c5927..b8ae70a63 100644 --- a/test/tools/IsolTestOptions.cpp +++ b/test/tools/IsolTestOptions.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/test/tools/afl_fuzzer.cpp b/test/tools/afl_fuzzer.cpp index ed1318b6b..1ca5428e1 100644 --- a/test/tools/afl_fuzzer.cpp +++ b/test/tools/afl_fuzzer.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/test/tools/fuzzer_common.cpp b/test/tools/fuzzer_common.cpp index ab6ab3cbb..f66c2e841 100644 --- a/test/tools/fuzzer_common.cpp +++ b/test/tools/fuzzer_common.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include #include #include diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index 6ce05d592..d96091dcb 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -15,8 +15,8 @@ along with solidity. If not, see . */ -#include -#include +#include +#include #include #include diff --git a/test/tools/ossfuzz/abiV2FuzzerCommon.h b/test/tools/ossfuzz/abiV2FuzzerCommon.h index 5027302e8..3094fbdc1 100644 --- a/test/tools/ossfuzz/abiV2FuzzerCommon.h +++ b/test/tools/ossfuzz/abiV2FuzzerCommon.h @@ -7,7 +7,7 @@ #include #include -#include +#include namespace solidity::test::abiv2fuzzer { diff --git a/test/tools/ossfuzz/protoToAbiV2.h b/test/tools/ossfuzz/protoToAbiV2.h index 94f37631f..f75f5d7e4 100644 --- a/test/tools/ossfuzz/protoToAbiV2.h +++ b/test/tools/ossfuzz/protoToAbiV2.h @@ -2,10 +2,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index b0a2a6d44..bf152052b 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include diff --git a/test/tools/ossfuzz/protoToYul.h b/test/tools/ossfuzz/protoToYul.h index ff0f4ddfd..43058f45c 100644 --- a/test/tools/ossfuzz/protoToYul.h +++ b/test/tools/ossfuzz/protoToYul.h @@ -27,9 +27,9 @@ #include -#include -#include -#include +#include +#include +#include namespace solidity::yul::test::yul_fuzzer { diff --git a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp index 8156143b6..b4211dfc9 100644 --- a/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp +++ b/test/tools/ossfuzz/strictasm_diff_ossfuzz.cpp @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index 65067d101..d60b63b10 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -27,7 +27,7 @@ #include -#include +#include using namespace std; using namespace solidity; diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.h b/test/tools/yulInterpreter/EVMInstructionInterpreter.h index 35fc1a6da..02104178b 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.h +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.h @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp index 419b73d10..7abd43112 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.cpp @@ -27,7 +27,7 @@ #include -#include +#include using namespace std; using namespace solidity; diff --git a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h index fc73bd020..c6819743c 100644 --- a/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h +++ b/test/tools/yulInterpreter/EwasmBuiltinInterpreter.h @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index b1edacc9b..4d28633f6 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -31,7 +31,7 @@ #include -#include +#include #include #include diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index 1cd871e41..ab0386165 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -23,10 +23,10 @@ #include #include -#include -#include +#include +#include -#include +#include #include diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index 3a9b19721..67b34a784 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -18,7 +18,7 @@ * Interactive yul optimizer */ -#include +#include #include #include #include @@ -66,7 +66,7 @@ #include -#include +#include #include diff --git a/test/tools/yulrun.cpp b/test/tools/yulrun.cpp index c18a6c322..1e82fba7f 100644 --- a/test/tools/yulrun.cpp +++ b/test/tools/yulrun.cpp @@ -32,8 +32,8 @@ #include #include -#include -#include +#include +#include #include From 7772ee145ce026a0339ac9b4c96a900e8926f212 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 8 Jan 2020 09:17:59 +0100 Subject: [PATCH 35/57] Change naming to "destructible". --- docs/contracts/function-modifiers.rst | 6 +-- docs/contracts/inheritance.rst | 56 +++++++++++++-------------- docs/metadata.rst | 4 +- docs/using-the-compiler.rst | 4 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index 785be74e9..90eb2fc27 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -39,12 +39,12 @@ if they are marked ``virtual``. For details, please see } } - contract retrievable is owned { + contract destructible is owned { // This contract inherits the `onlyOwner` modifier from // `owned` and applies it to the `close` function, which // causes that calls to `close` only have an effect if // they are made by the stored owner. - function close() public onlyOwner { + function destroy() public onlyOwner { selfdestruct(owner); } } @@ -58,7 +58,7 @@ if they are marked ``virtual``. For details, please see } } - contract Register is priced, owned { + contract Register is priced, destructible { mapping (address => bool) registeredAddresses; uint price; diff --git a/docs/contracts/inheritance.rst b/docs/contracts/inheritance.rst index cc5534a06..18c369df4 100644 --- a/docs/contracts/inheritance.rst +++ b/docs/contracts/inheritance.rst @@ -51,10 +51,10 @@ Details are given in the following example. // contracts can access all non-private members including // internal functions and state variables. These cannot be // accessed externally via `this`, though. - contract Temporary is Owned { + contract Destructible is Owned { // The keyword `virtual` means that the function can change // its behaviour in derived classes ("overriding"). - function shutdown() virtual public { + function destroy() virtual public { if (msg.sender == owner) selfdestruct(owner); } } @@ -76,9 +76,9 @@ Details are given in the following example. // Multiple inheritance is possible. Note that `owned` is - // also a base class of `Temporary`, yet there is only a single + // also a base class of `Destructible`, yet there is only a single // instance of `owned` (as for virtual inheritance in C++). - contract Named is Owned, Temporary { + contract Named is Owned, Destructible { constructor(bytes32 name) public { Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970); NameReg(config.lookup(1)).register(name); @@ -92,13 +92,13 @@ Details are given in the following example. // If you want the function to override, you need to use the // `override` keyword. You need to specify the `virtual` keyword again // if you want this function to be overridden again. - function shutdown() public virtual override { + function destroy() public virtual override { if (msg.sender == owner) { Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970); NameReg(config.lookup(1)).unregister(); // It is still possible to call a specific // overridden function. - Temporary.shutdown(); + Destructible.destroy(); } } } @@ -107,21 +107,21 @@ Details are given in the following example. // If a constructor takes an argument, it needs to be // provided in the header (or modifier-invocation-style at // the constructor of the derived contract (see below)). - contract PriceFeed is Owned, Temporary, Named("GoldFeed") { + contract PriceFeed is Owned, Destructible, Named("GoldFeed") { function updateInfo(uint newInfo) public { if (msg.sender == owner) info = newInfo; } // Here, we only specify `override` and not `virtual`. // This means that contracts deriving from `PriceFeed` - // cannot change the behaviour of `shutdown` anymore. - function shutdown() public override(Temporary, Named) { Named.shutdown(); } + // cannot change the behaviour of `destroy` anymore. + function destroy() public override(Destructible, Named) { Named.destroy(); } function get() public view returns(uint r) { return info; } uint info; } -Note that above, we call ``Temporary.shutdown()`` to "forward" the +Note that above, we call ``Destructible.destroy()`` to "forward" the destruction request. The way this is done is problematic, as seen in the following example:: @@ -132,27 +132,27 @@ seen in the following example:: address payable owner; } - contract Temporary is owned { - function shutdown() public virtual { + contract Destructible is owned { + function destroy() public virtual { if (msg.sender == owner) selfdestruct(owner); } } - contract Base1 is Temporary { - function shutdown() public virtual override { /* do cleanup 1 */ Temporary.shutdown(); } + contract Base1 is Destructible { + function destroy() public virtual override { /* do cleanup 1 */ Destructible.destroy(); } } - contract Base2 is Temporary { - function shutdown() public virtual override { /* do cleanup 2 */ Temporary.shutdown(); } + contract Base2 is Destructible { + function destroy() public virtual override { /* do cleanup 2 */ Destructible.destroy(); } } contract Final is Base1, Base2 { - function shutdown() public override(Base1, Base2) { Base2.shutdown(); } + function destroy() public override(Base1, Base2) { Base2.destroy(); } } -A call to ``Final.shutdown()`` will call ``Base2.shutdown`` because we specify it +A call to ``Final.destroy()`` will call ``Base2.destroy`` because we specify it explicitly in the final override, but this function will bypass -``Base1.shutdown``. The way around this is to use ``super``:: +``Base1.destroy``. The way around this is to use ``super``:: pragma solidity >=0.4.22 <0.7.0; @@ -161,31 +161,31 @@ explicitly in the final override, but this function will bypass address payable owner; } - contract Temporary is owned { - function shutdown() virtual public { + contract Destructible is owned { + function destroy() virtual public { if (msg.sender == owner) selfdestruct(owner); } } - contract Base1 is Temporary { - function shutdown() public virtual override { /* do cleanup 1 */ super.shutdown(); } + contract Base1 is Destructible { + function destroy() public virtual override { /* do cleanup 1 */ super.destroy(); } } - contract Base2 is Temporary { - function shutdown() public virtual override { /* do cleanup 2 */ super.shutdown(); } + contract Base2 is Destructible { + function destroy() public virtual override { /* do cleanup 2 */ super.destroy(); } } contract Final is Base1, Base2 { - function shutdown() public override(Base1, Base2) { super.shutdown(); } + function destroy() public override(Base1, Base2) { super.destroy(); } } If ``Base2`` calls a function of ``super``, it does not simply call this function on one of its base contracts. Rather, it calls this function on the next base contract in the final -inheritance graph, so it will call ``Base1.shutdown()`` (note that +inheritance graph, so it will call ``Base1.destroy()`` (note that the final inheritance sequence is -- starting with the most -derived contract: Final, Base2, Base1, Temporary, owned). +derived contract: Final, Base2, Base1, Destructible, owned). The actual function that is called when using super is not known in the context of the class where it is used, although its type is known. This is similar for ordinary diff --git a/docs/metadata.rst b/docs/metadata.rst index 3660ce69a..a91751858 100644 --- a/docs/metadata.rst +++ b/docs/metadata.rst @@ -56,11 +56,11 @@ explanatory purposes. // Swarm URL is recommended "urls": [ "bzzr://56ab..." ] }, - "retrievable": { + "destructible": { // Required: keccak256 hash of the source file "keccak256": "0x234...", // Required (unless "url" is used): literal contents of the source file - "content": "contract retrievable is owned { function shutdown() { if (msg.sender == owner) selfdestruct(owner); } }" + "content": "contract destructible is owned { function destroy() { if (msg.sender == owner) selfdestruct(owner); } }" } }, // Required: Compiler settings diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 30b00bae0..c91e4e505 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -180,12 +180,12 @@ Input Description // `--allow-paths `. ] }, - "retrievable": + "destructible": { // Optional: keccak256 hash of the source file "keccak256": "0x234...", // Required (unless "urls" is used): literal contents of the source file - "content": "contract retrievable is owned { function shutdown() { if (msg.sender == owner) selfdestruct(owner); } }" + "content": "contract destructible is owned { function shutdown() { if (msg.sender == owner) selfdestruct(owner); } }" } }, // Optional From 25d3f27c119eda579dbd25535771d66844e465da Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 27 Nov 2019 10:44:40 +0100 Subject: [PATCH 36/57] Tune Rematerializer --- libyul/optimiser/DataFlowAnalyzer.cpp | 27 ++++++++++++-- libyul/optimiser/DataFlowAnalyzer.h | 7 ++++ libyul/optimiser/Rematerialiser.cpp | 7 +++- libyul/optimiser/Rematerialiser.h | 7 +++- .../fullSuite/clear_after_if_continue.yul | 3 +- .../fullSuite/devcon_example.yul | 3 +- .../fullSuite/loopInvariantCodeMotion.yul | 6 ++- .../fullSuite/no_move_loop_orig.yul | 3 +- .../many_refs_small_cost_loop.yul | 28 ++++++++++++++ .../rematerialiser/no_remat_in_loop.yul | 37 +++++++++++++++++++ .../some_refs_small_cost_loop.yul | 17 +++++++++ .../some_refs_small_cost_nested_loop.yul | 26 +++++++++++++ 12 files changed, 159 insertions(+), 12 deletions(-) create mode 100644 test/libyul/yulOptimizerTests/rematerialiser/many_refs_small_cost_loop.yul create mode 100644 test/libyul/yulOptimizerTests/rematerialiser/no_remat_in_loop.yul create mode 100644 test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul create mode 100644 test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp index db1517f59..baa66553b 100644 --- a/libyul/optimiser/DataFlowAnalyzer.cpp +++ b/libyul/optimiser/DataFlowAnalyzer.cpp @@ -145,10 +145,14 @@ void DataFlowAnalyzer::operator()(FunctionDefinition& _fun) // Save all information. We might rather reinstantiate this class, // but this could be difficult if it is subclassed. map value; + map variableLoopDepth; + size_t loopDepth{0}; InvertibleRelation references; InvertibleMap storage; InvertibleMap memory; - m_value.swap(value); + swap(m_value, value); + swap(m_variableLoopDepth, variableLoopDepth); + swap(m_loopDepth, loopDepth); swap(m_references, references); swap(m_storage, storage); swap(m_memory, memory); @@ -168,7 +172,9 @@ void DataFlowAnalyzer::operator()(FunctionDefinition& _fun) // statement. popScope(); - m_value.swap(value); + swap(m_value, value); + swap(m_variableLoopDepth, variableLoopDepth); + swap(m_loopDepth, loopDepth); swap(m_references, references); swap(m_storage, storage); swap(m_memory, memory); @@ -180,6 +186,8 @@ void DataFlowAnalyzer::operator()(ForLoop& _for) // we would have to deal with more complicated scoping rules. assertThrow(_for.pre.statements.empty(), OptimizerException, ""); + ++m_loopDepth; + AssignmentsSinceContinue assignmentsSinceCont; assignmentsSinceCont(_for.body); @@ -202,6 +210,8 @@ void DataFlowAnalyzer::operator()(ForLoop& _for) clearKnowledgeIfInvalidated(*_for.condition); clearKnowledgeIfInvalidated(_for.post); clearKnowledgeIfInvalidated(_for.body); + + --m_loopDepth; } void DataFlowAnalyzer::operator()(Block& _block) @@ -222,7 +232,7 @@ void DataFlowAnalyzer::handleAssignment(set const& _variables, Expres movableChecker.visit(*_value); else for (auto const& var: _variables) - m_value[var] = &m_zero; + assignValue(var, &m_zero); if (_value && _variables.size() == 1) { @@ -230,7 +240,7 @@ void DataFlowAnalyzer::handleAssignment(set const& _variables, Expres // Expression has to be movable and cannot contain a reference // to the variable that will be assigned to. if (movableChecker.movable() && !movableChecker.referencedVariables().count(name)) - m_value[name] = _value; + assignValue(name, _value); } auto const& referencedVariables = movableChecker.referencedVariables(); @@ -296,11 +306,20 @@ void DataFlowAnalyzer::clearValues(set _variables) // Clear the value and update the reference relation. for (auto const& name: _variables) + { m_value.erase(name); + m_variableLoopDepth.erase(name); + } for (auto const& name: _variables) m_references.eraseKey(name); } +void DataFlowAnalyzer::assignValue(YulString _variable, Expression const* _value) +{ + m_value[_variable] = _value; + m_variableLoopDepth[_variable] = m_loopDepth; +} + void DataFlowAnalyzer::clearKnowledgeIfInvalidated(Block const& _block) { SideEffectsCollector sideEffects(m_dialect, _block, &m_functionSideEffects); diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index 45f41bea8..04de94197 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -110,6 +110,8 @@ protected: /// for example at points where control flow is merged. void clearValues(std::set _names); + void assignValue(YulString _variable, Expression const* _value); + /// Clears knowledge about storage or memory if they may be modified inside the block. void clearKnowledgeIfInvalidated(Block const& _block); @@ -144,6 +146,8 @@ protected: /// Current values of variables, always movable. std::map m_value; + /// The loop nesting depth of the definition of variables (those used in m_value). + std::map m_variableLoopDepth; /// m_references.forward[a].contains(b) <=> the current expression assigned to a references b /// m_references.backward[b].contains(a) <=> the current expression assigned to a references b InvertibleRelation m_references; @@ -153,6 +157,9 @@ protected: KnowledgeBase m_knowledgeBase; + /// Current nesting depth of loops. + size_t m_loopDepth{0}; + struct Scope { explicit Scope(bool _isFunction): isFunction(_isFunction) {} diff --git a/libyul/optimiser/Rematerialiser.cpp b/libyul/optimiser/Rematerialiser.cpp index 5d7350d97..c148778f9 100644 --- a/libyul/optimiser/Rematerialiser.cpp +++ b/libyul/optimiser/Rematerialiser.cpp @@ -78,7 +78,12 @@ void Rematerialiser::visit(Expression& _e) auto const& value = *m_value.at(name); size_t refs = m_referenceCounts[name]; size_t cost = CodeCost::codeCost(m_dialect, value); - if (refs <= 1 || cost == 0 || (refs <= 5 && cost <= 1) || m_varsToAlwaysRematerialize.count(name)) + if ( + (refs <= 1 && m_variableLoopDepth.at(name) == m_loopDepth) || + cost == 0 || + (refs <= 5 && cost <= 1) || + m_varsToAlwaysRematerialize.count(name) + ) { assertThrow(m_referenceCounts[name] > 0, OptimizerException, ""); for (auto const& ref: m_references.forward[name]) diff --git a/libyul/optimiser/Rematerialiser.h b/libyul/optimiser/Rematerialiser.h index 2d70e0b0d..51c5eb4cf 100644 --- a/libyul/optimiser/Rematerialiser.h +++ b/libyul/optimiser/Rematerialiser.h @@ -27,9 +27,10 @@ namespace solidity::yul { /** - * Optimisation stage that replaces variables by their most recently assigned expressions, + * Optimisation stage that replaces variable references by those expressions + * that are most recently assigned to the referenced variables, * but only if the expression is movable and one of the following holds: - * - the variable is referenced exactly once + * - the variable is referenced exactly once (and definition-to-reference does not cross a loop boundary) * - the value is extremely cheap ("cost" of zero like ``caller()``) * - the variable is referenced at most 5 times and the value is rather cheap * ("cost" of at most 1 like a constant up to 0xff) @@ -68,6 +69,8 @@ protected: std::set _varsToAlwaysRematerialize = {} ); + using DataFlowAnalyzer::operator(); + using ASTModifier::visit; void visit(Expression& _e) override; diff --git a/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul b/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul index 19816b445..ca6b5fec1 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul @@ -12,7 +12,8 @@ // { // { // let y := mload(0x20) -// for { } and(y, 8) { if y { revert(0, 0) } } +// let _1 := iszero(and(y, 8)) +// for { } iszero(_1) { if y { revert(0, 0) } } // { // if y { continue } // sstore(1, 0) diff --git a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul index ff898b926..d215bc728 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul @@ -21,8 +21,9 @@ // { // let _1 := calldataload(0) // let sum := 0 +// let length := calldataload(_1) // let i := sum -// for { } lt(i, calldataload(_1)) { i := add(i, 1) } +// for { } lt(i, length) { i := add(i, 1) } // { // sum := add(sum, calldataload(add(add(_1, mul(i, 0x20)), 0x20))) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul index f570d2ecf..8b69593bb 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul @@ -24,10 +24,12 @@ // { // let _1 := calldataload(0) // let sum := 0 +// let length := calldataload(_1) // let i := sum -// for { } lt(i, calldataload(_1)) { i := add(i, 1) } +// let _2 := calldataload(7) +// for { } lt(i, length) { i := add(i, 1) } // { -// sum := add(sum, add(calldataload(add(add(_1, mul(i, 0x20)), 0x20)), calldataload(7))) +// sum := add(sum, add(calldataload(add(add(_1, mul(i, 0x20)), 0x20)), _2)) // } // sstore(0, sum) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul b/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul index 456f32d42..77c384021 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul @@ -12,10 +12,11 @@ // ---- // { // { +// let _1 := iszero(caller()) // for { } // 1 // { -// for { } caller() { } +// for { } iszero(_1) { } // { } // mstore(192, 0) // } diff --git a/test/libyul/yulOptimizerTests/rematerialiser/many_refs_small_cost_loop.yul b/test/libyul/yulOptimizerTests/rematerialiser/many_refs_small_cost_loop.yul new file mode 100644 index 000000000..0d42afa97 --- /dev/null +++ b/test/libyul/yulOptimizerTests/rematerialiser/many_refs_small_cost_loop.yul @@ -0,0 +1,28 @@ +{ + // Cost of rematerializating x is 1 + let x := 0xff + // Although x has low cost, it is not considered for + // rematerialization because it is referenced more than 5 times + for {} lt(x, 0x100) {} + { + let y := add(x, 1) + let z := mul(x, 1) + let a := div(x, 2) + let b := mod(x, 3) + let c := sdiv(x, 4) + } +} +// ==== +// step: rematerialiser +// ---- +// { +// let x := 0xff +// for { } lt(x, 0x100) { } +// { +// let y := add(x, 1) +// let z := mul(x, 1) +// let a := div(x, 2) +// let b := mod(x, 3) +// let c := sdiv(x, 4) +// } +// } diff --git a/test/libyul/yulOptimizerTests/rematerialiser/no_remat_in_loop.yul b/test/libyul/yulOptimizerTests/rematerialiser/no_remat_in_loop.yul new file mode 100644 index 000000000..8fdd1f002 --- /dev/null +++ b/test/libyul/yulOptimizerTests/rematerialiser/no_remat_in_loop.yul @@ -0,0 +1,37 @@ +{ + // origin has zero cost and thus will be rematerialised, + // calldataload(0) has low cost and will not be rematerialised + let a := origin() + let b := calldataload(0) + let i := 0 + let z := calldataload(9) + for {} lt(i, 10) {i := add(a, b)} { + // This will be rematerialised, because it stays inside + // the loop. + let x := calldataload(1) + mstore(9, x) + // No, because again one loop further down. + let y := calldataload(2) + for {} y {} { + // Again no. + mstore(12, z) + } + } +} +// ==== +// step: rematerialiser +// ---- +// { +// let a := origin() +// let b := calldataload(0) +// let i := 0 +// let z := calldataload(9) +// for { } lt(i, 10) { i := add(origin(), b) } +// { +// let x := calldataload(1) +// mstore(9, calldataload(1)) +// let y := calldataload(2) +// for { } y { } +// { mstore(12, z) } +// } +// } diff --git a/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul new file mode 100644 index 000000000..6c0c85831 --- /dev/null +++ b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul @@ -0,0 +1,17 @@ +{ + // Cost of rematerializating x is 1 + let x := 0xff + // Reference to x is not rematerialized because the reference is in a loop + for {} lt(x, 0x100) {} + { + let y := add(x, 1) + } +} +// ==== +// step: rematerialiser +// ---- +// { +// let x := 0xff +// for { } lt(0xff, 0x100) { } +// { let y := add(0xff, 1) } +// } diff --git a/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul new file mode 100644 index 000000000..4b55fe564 --- /dev/null +++ b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul @@ -0,0 +1,26 @@ +{ + // Cost of rematerializating x is 1 + let x := 0xff + // Although x has a low cost and fewer than 6 references, + // its references in a loop are not rematerialized + for {} lt(x, 0x100) {} + { + let y := add(x, 1) + for {} lt(x, 0x200) {} + { + let z := mul(x, 2) + } + } +} +// ==== +// step: rematerialiser +// ---- +// { +// let x := 0xff +// for { } lt(0xff, 0x100) { } +// { +// let y := add(0xff, 1) +// for { } lt(0xff, 0x200) { } +// { let z := mul(0xff, 2) } +// } +// } From 40c0602b5c1867e9afaf4cd0c0dcbde691447407 Mon Sep 17 00:00:00 2001 From: chriseth Date: Fri, 29 Nov 2019 12:04:29 +0100 Subject: [PATCH 37/57] Do not rematerialize in loops. --- libyul/optimiser/Rematerialiser.cpp | 2 +- libyul/optimiser/Rematerialiser.h | 2 +- test/libsolidity/gasTests/abiv2_optimised.sol | 4 +-- .../fullSuite/abi_example1.yul | 36 ++++++++++--------- .../yulOptimizerTests/fullSuite/aztec.yul | 3 +- .../fullSuite/clear_after_if_continue.yul | 10 +++++- .../fullSuite/devcon_example.yul | 3 +- .../fullSuite/loopInvariantCodeMotion.yul | 3 +- .../some_refs_small_cost_loop.yul | 4 +-- .../some_refs_small_cost_nested_loop.yul | 8 ++--- 10 files changed, 45 insertions(+), 30 deletions(-) diff --git a/libyul/optimiser/Rematerialiser.cpp b/libyul/optimiser/Rematerialiser.cpp index c148778f9..02ac48e96 100644 --- a/libyul/optimiser/Rematerialiser.cpp +++ b/libyul/optimiser/Rematerialiser.cpp @@ -81,7 +81,7 @@ void Rematerialiser::visit(Expression& _e) if ( (refs <= 1 && m_variableLoopDepth.at(name) == m_loopDepth) || cost == 0 || - (refs <= 5 && cost <= 1) || + (refs <= 5 && cost <= 1 && m_loopDepth == 0) || m_varsToAlwaysRematerialize.count(name) ) { diff --git a/libyul/optimiser/Rematerialiser.h b/libyul/optimiser/Rematerialiser.h index 51c5eb4cf..1316f0373 100644 --- a/libyul/optimiser/Rematerialiser.h +++ b/libyul/optimiser/Rematerialiser.h @@ -33,7 +33,7 @@ namespace solidity::yul * - the variable is referenced exactly once (and definition-to-reference does not cross a loop boundary) * - the value is extremely cheap ("cost" of zero like ``caller()``) * - the variable is referenced at most 5 times and the value is rather cheap - * ("cost" of at most 1 like a constant up to 0xff) + * ("cost" of at most 1 like a constant up to 0xff) and we are not in a loop * * Prerequisite: Disambiguator, ForLoopInitRewriter. */ diff --git a/test/libsolidity/gasTests/abiv2_optimised.sol b/test/libsolidity/gasTests/abiv2_optimised.sol index 92323fc68..b1bc1ff5d 100644 --- a/test/libsolidity/gasTests/abiv2_optimised.sol +++ b/test/libsolidity/gasTests/abiv2_optimised.sol @@ -17,9 +17,9 @@ contract C { // optimize-yul: true // ---- // creation: -// codeDepositCost: 605800 +// codeDepositCost: 603000 // executionCost: 638 -// totalCost: 606438 +// totalCost: 603638 // external: // a(): 1029 // b(uint256): 2084 diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul index 0d37cf1b9..4557c1889 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul @@ -492,34 +492,37 @@ // } // function abi_decode_t_array$_t_array$_t_uint256_$2_memory_$dyn_memory_ptr(offset, end) -> array // { -// if iszero(slt(add(offset, 0x1f), end)) { revert(array, array) } +// let _1 := 0x1f +// if iszero(slt(add(offset, _1), end)) { revert(array, array) } // let length := calldataload(offset) // array := allocateMemory(array_allocation_size_t_array$_t_address_$dyn_memory(length)) // let dst := array // mstore(array, length) -// let _1 := 0x20 -// dst := add(array, _1) -// let src := add(offset, _1) -// if gt(add(add(offset, mul(length, 0x40)), _1), end) { revert(0, 0) } +// let _2 := 0x20 +// dst := add(array, _2) +// let src := add(offset, _2) +// let _3 := 0x40 +// if gt(add(add(offset, mul(length, _3)), _2), end) { revert(0, 0) } // let i := 0 // for { } lt(i, length) { i := add(i, 1) } // { -// if iszero(slt(add(src, 0x1f), end)) { revert(0, 0) } -// let dst_1 := allocateMemory(array_allocation_size_t_array$_t_uint256_$2_memory(0x2)) +// if iszero(slt(add(src, _1), end)) { revert(0, 0) } +// let _4 := 0x2 +// let dst_1 := allocateMemory(array_allocation_size_t_array$_t_uint256_$2_memory(_4)) // let dst_2 := dst_1 // let src_1 := src -// let _2 := add(src, 0x40) -// if gt(_2, end) { revert(0, 0) } +// let _5 := add(src, _3) +// if gt(_5, end) { revert(0, 0) } // let i_1 := 0 -// for { } lt(i_1, 0x2) { i_1 := add(i_1, 1) } +// for { } lt(i_1, _4) { i_1 := add(i_1, 1) } // { // mstore(dst_1, calldataload(src_1)) -// dst_1 := add(dst_1, _1) -// src_1 := add(src_1, _1) +// dst_1 := add(dst_1, _2) +// src_1 := add(src_1, _2) // } // mstore(dst, dst_2) -// dst := add(dst, _1) -// src := _2 +// dst := add(dst, _2) +// src := _5 // } // } // function abi_decode_t_array$_t_uint256_$dyn_memory_ptr(offset, end) -> array @@ -548,8 +551,9 @@ // for { } lt(i, 0x3) { i := add(i, 1) } // { // mstore(pos, and(mload(srcPtr), sub(shl(160, 1), 1))) -// srcPtr := add(srcPtr, 0x20) -// pos := add(pos, 0x20) +// let _1 := 0x20 +// srcPtr := add(srcPtr, _1) +// pos := add(pos, _1) // } // } // function allocateMemory(size) -> memPtr diff --git a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul index 35e1bb7b3..635da72d6 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul @@ -375,7 +375,8 @@ // let i := 0 // for { } lt(i, n) { i := add(i, 0x01) } // { -// calldatacopy(add(0x300, mul(i, 0x80)), add(add(notes, mul(i, 0xc0)), 0x60), 0x80) +// let _1 := 0x80 +// calldatacopy(add(0x300, mul(i, _1)), add(add(notes, mul(i, 0xc0)), 0x60), _1) // } // mstore(0, keccak256(0x300, mul(n, 0x80))) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul b/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul index ca6b5fec1..a9cdb84e0 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul @@ -13,7 +13,15 @@ // { // let y := mload(0x20) // let _1 := iszero(and(y, 8)) -// for { } iszero(_1) { if y { revert(0, 0) } } +// for { } +// iszero(_1) +// { +// if y +// { +// let _2 := 0 +// revert(_2, _2) +// } +// } // { // if y { continue } // sstore(1, 0) diff --git a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul index d215bc728..314f2a363 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul @@ -25,7 +25,8 @@ // let i := sum // for { } lt(i, length) { i := add(i, 1) } // { -// sum := add(sum, calldataload(add(add(_1, mul(i, 0x20)), 0x20))) +// let _2 := 0x20 +// sum := add(sum, calldataload(add(add(_1, mul(i, _2)), _2))) // } // sstore(0, sum) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul index 8b69593bb..f8fb81aa8 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul @@ -29,7 +29,8 @@ // let _2 := calldataload(7) // for { } lt(i, length) { i := add(i, 1) } // { -// sum := add(sum, add(calldataload(add(add(_1, mul(i, 0x20)), 0x20)), _2)) +// let _3 := 0x20 +// sum := add(sum, add(calldataload(add(add(_1, mul(i, _3)), _3)), _2)) // } // sstore(0, sum) // } diff --git a/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul index 6c0c85831..0eeb248a6 100644 --- a/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul +++ b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_loop.yul @@ -12,6 +12,6 @@ // ---- // { // let x := 0xff -// for { } lt(0xff, 0x100) { } -// { let y := add(0xff, 1) } +// for { } lt(x, 0x100) { } +// { let y := add(x, 1) } // } diff --git a/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul index 4b55fe564..c95cf5454 100644 --- a/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul +++ b/test/libyul/yulOptimizerTests/rematerialiser/some_refs_small_cost_nested_loop.yul @@ -17,10 +17,10 @@ // ---- // { // let x := 0xff -// for { } lt(0xff, 0x100) { } +// for { } lt(x, 0x100) { } // { -// let y := add(0xff, 1) -// for { } lt(0xff, 0x200) { } -// { let z := mul(0xff, 2) } +// let y := add(x, 1) +// for { } lt(x, 0x200) { } +// { let z := mul(x, 2) } // } // } From 01dfc512a929c6158fdbf8d09aa69656865f959f Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 8 Jan 2020 09:56:57 +0100 Subject: [PATCH 38/57] Changelog entry. --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 93d24cdaa..47df79890 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ Language Features: Compiler Features: * General: Raise warning if runtime bytecode exceeds 24576 bytes (a limit introduced in Spurious Dragon). + * Yul Optimizer: Apply penalty when trying to rematerialize into loops. Bugfixes: From b8c59c56e0f0a259561650ce9f464b8979ec865a Mon Sep 17 00:00:00 2001 From: rodiazet Date: Wed, 8 Jan 2020 10:08:26 +0100 Subject: [PATCH 39/57] [WASM] Add keccak256, balance, extcodecopy, blockhash, coinbase, log's, call, callcode, delegatecall, staticcall --- libyul/backends/wasm/EVMToEwasmTranslator.cpp | 220 ++++++++++++------ .../standard_eWasm_requested/output.json | 49 ++-- test/libyul/ewasmTranslationTests/balance.yul | 6 +- .../ewasmTranslationTests/blockhash.yul | 5 +- .../libyul/ewasmTranslationTests/coinbase.yul | 3 +- .../ewasmTranslationTests/extcodecopy.yul | 5 +- .../ewasmTranslationTests/extcodesize.yul | 4 +- test/libyul/ewasmTranslationTests/log0.yul | 2 +- test/libyul/ewasmTranslationTests/log1.yul | 2 +- test/libyul/ewasmTranslationTests/log2.yul | 2 +- test/libyul/ewasmTranslationTests/log3.yul | 2 +- test/libyul/ewasmTranslationTests/log4.yul | 2 +- .../ewasmTranslationTests/selfdestruct.yul | 4 +- .../ewasmTranslationTests/smoke_call.yul | 5 +- .../ewasmTranslationTests/smoke_callcode.yul | 5 +- .../ewasmTranslationTests/smoke_create.yul | 2 +- .../smoke_delegatecall.yul | 5 +- .../smoke_staticcall.yul | 5 +- 18 files changed, 224 insertions(+), 104 deletions(-) diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index 7264515df..168f5fbf4 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -214,7 +214,10 @@ function cmp(a, b) -> r { r := i64.ne(a, b) } } - +)" +// Split long string to make it compilable on msvc +// https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2026?view=vs-2019 +R"( function lt(x1, x2, x3, x4, y1, y2, y3, y4) -> z1, z2, z3, z4 { switch cmp(x1, y1) case 0 { @@ -335,6 +338,11 @@ function signextend(x1, x2, x3, x4, y1, y2, y3, y4) -> z1, z2, z3, z4 { // TODO implement unreachable() } +function u256_to_u128(x1, x2, x3, x4) -> v1, v2 { + if i64.ne(0, i64.or(x1, x2)) { invalid() } + v2 := x4 + v1 := x3 +} function u256_to_i64(x1, x2, x3, x4) -> v { if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { invalid() } @@ -347,10 +355,30 @@ function u256_to_i32(x1, x2, x3, x4) -> v { v := x4 } +function u256_to_byte(x1, x2, x3, x4) -> v { + if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { invalid() } + if i64.gt_u(x4, 255) { invalid() } + v := x4 +} + function u256_to_i32ptr(x1, x2, x3, x4) -> v { v := u256_to_i32(x1, x2, x3, x4) } +function to_internal_i32ptr(x1, x2, x3, x4) -> r { + let p := u256_to_i32ptr(x1, x2, x3, x4) + r := i64.add(p, 64) + if i64.lt_u(r, p) { invalid() } +} + +function u256_to_address(x1, x2, x3, x4) -> r1, r2, r3 { + if i64.ne(0, x1) { invalid() } + if i64.ne(0, i64.shr_u(x2, 32)) { invalid() } + r1 := x2 + r2 := x3 + r3 := x4 +} + function keccak256(x1, x2, x3, x4, y1, y2, y3, y4) -> z1, z2, z3, z4 { // TODO implement unreachable() @@ -361,8 +389,9 @@ function address() -> z1, z2, z3, z4 { z1, z2, z3, z4 := mload_internal(0) } function balance(x1, x2, x3, x4) -> z1, z2, z3, z4 { - // TODO implement - unreachable() + mstore_address(0, x1, x2, x3, x4) + eth.getExternalBalance(12, 48) + z1, z2, z3, z4 := mload_internal(32) } function selfbalance() -> z1, z2, z3, z4 { // TODO: not part of current Ewasm spec @@ -393,8 +422,7 @@ function calldatasize() -> z1, z2, z3, z4 { } function calldatacopy(x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4) { eth.callDataCopy( - // scratch - TODO: overflow check - i64.add(u256_to_i32ptr(x1, x2, x3, x4), 64), + to_internal_i32ptr(x1, x2, x3, x4), u256_to_i32(y1, y2, y3, y4), u256_to_i32(z1, z2, z3, z4) ) @@ -406,8 +434,7 @@ function codesize() -> z1, z2, z3, z4 { } function codecopy(x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4) { eth.codeCopy( - // scratch - TODO: overflow check - i64.add(u256_to_i32ptr(x1, x2, x3, x4), 64), + to_internal_i32ptr(x1, x2, x3, x4), u256_to_i32(y1, y2, y3, y4), u256_to_i32(z1, z2, z3, z4) ) @@ -421,17 +448,22 @@ function gasprice() -> z1, z2, z3, z4 { eth.getTxGasPrice(0) z1, z2, z3, z4 := mload_internal(0) } +function extcodesize_internal(x1, x2, x3, x4) -> r { + mstore_address(0, x1, x2, x3, x4) + r := eth.getExternalCodeSize(12) +} function extcodesize(x1, x2, x3, x4) -> z1, z2, z3, z4 { - // TODO implement - unreachable() + z4 := extcodesize_internal(x1, x2, x3, x4) } function extcodehash(x1, x2, x3, x4) -> z1, z2, z3, z4 { // TODO: not part of current Ewasm spec unreachable() } -function extcodecopy(v1, v2, v3, v4, x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4) { - // TODO implement - unreachable() +function extcodecopy(a1, a2, a3, a4, p1, p2, p3, p4, o1, o2, o3, o4, l1, l2, l3, l4) { + mstore_address(0, a1, a2, a3, a4) + let codeOffset := u256_to_i32(o1, o2, o3, o4) + let codeLength := u256_to_i32(l1, l2, l3, l4) + eth.externalCodeCopy(12, to_internal_i32ptr(p1, p2, p3, p4), codeOffset, codeLength) } function returndatasize() -> z1, z2, z3, z4 { @@ -439,20 +471,21 @@ function returndatasize() -> z1, z2, z3, z4 { } function returndatacopy(x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4) { eth.returnDataCopy( - // scratch - TODO: overflow check - i64.add(u256_to_i32ptr(x1, x2, x3, x4), 64), + to_internal_i32ptr(x1, x2, x3, x4), u256_to_i32(y1, y2, y3, y4), u256_to_i32(z1, z2, z3, z4) ) } function blockhash(x1, x2, x3, x4) -> z1, z2, z3, z4 { - // TODO implement - unreachable() + let r := eth.getBlockHash(u256_to_i64(x1, x2, x3, x4), 0) + if i64.eqz(r) { + z1, z2, z3, z4 := mload_internal(0) + } } function coinbase() -> z1, z2, z3, z4 { - // TODO implement - unreachable() + eth.getBlockCoinbase(0) + z1, z2, z3, z4 := mload_internal(0) } function timestamp() -> z1, z2, z3, z4 { z4 := eth.getBlockTimestamp() @@ -522,11 +555,7 @@ function restore_temp_mem_64(t1, t2, t3, t4, t5, t6, t7, t8) { i64.store(54, t8) } function mload(x1, x2, x3, x4) -> z1, z2, z3, z4 { - let pos := u256_to_i32ptr(x1, x2, x3, x4) - // Make room for the scratch space - // TODO do we need to check for overflow? - pos := i64.add(pos, 64) - z1, z2, z3, z4 := mload_internal(pos) + z1, z2, z3, z4 := mload_internal(to_internal_i32ptr(x1, x2, x3, x4)) } function mload_internal(pos) -> z1, z2, z3, z4 { z1 := endian_swap(i64.load(pos)) @@ -535,11 +564,7 @@ function mload_internal(pos) -> z1, z2, z3, z4 { z4 := endian_swap(i64.load(i64.add(pos, 24))) } function mstore(x1, x2, x3, x4, y1, y2, y3, y4) { - let pos := u256_to_i32ptr(x1, x2, x3, x4) - // Make room for the scratch space - // TODO do we need to check for overflow? - pos := i64.add(pos, 64) - mstore_internal(pos, y1, y2, y3, y4) + mstore_internal(to_internal_i32ptr(x1, x2, x3, x4), y1, y2, y3, y4) } function mstore_internal(pos, y1, y2, y3, y4) { i64.store(pos, endian_swap(y1)) @@ -547,6 +572,10 @@ function mstore_internal(pos, y1, y2, y3, y4) { i64.store(i64.add(pos, 16), endian_swap(y3)) i64.store(i64.add(pos, 24), endian_swap(y4)) } +function mstore_address(pos, a1, a2, a3, a4) { + a1, a2, a3 := u256_to_address(a1, a2, a3, a4) + mstore_internal(pos, 0, a1, a2, a3) +} function mstore8(x1, x2, x3, x4, y1, y2, y3, y4) { // TODO implement unreachable() @@ -578,47 +607,84 @@ function gas() -> z1, z2, z3, z4 { } function log0(p1, p2, p3, p4, s1, s2, s3, s4) { - // TODO implement - unreachable() + eth.log( + to_internal_i32ptr(p1, p2, p3, p4), + u256_to_i32(s1, s2, s3, s4), + 0, 0, 0, 0, 0 + ) } function log1( p1, p2, p3, p4, s1, s2, s3, s4, - t11, t12, t13, t14 + t1_1, t1_2, t1_3, t1_4 ) { - // TODO implement - unreachable() + eth.log( + to_internal_i32ptr(p1, p2, p3, p4), + u256_to_i32(s1, s2, s3, s4), + 1, + to_internal_i32ptr(t1_1, t1_2, t1_3, t1_4), + 0, 0, 0 + ) } function log2( p1, p2, p3, p4, s1, s2, s3, s4, - t11, t12, t13, t14, - t21, t22, t23, t24 + t1_1, t1_2, t1_3, t1_4, + t2_1, t2_2, t2_3, t2_4 ) { - // TODO implement - unreachable() + eth.log( + to_internal_i32ptr(p1, p2, p3, p4), + u256_to_i32(s1, s2, s3, s4), + 2, + to_internal_i32ptr(t1_1, t1_2, t1_3, t1_4), + to_internal_i32ptr(t2_1, t2_2, t2_3, t2_4), + 0, 0 + ) } function log3( p1, p2, p3, p4, s1, s2, s3, s4, - t11, t12, t13, t14, - t21, t22, t23, t24, - t31, t32, t33, t34 + t1_1, t1_2, t1_3, t1_4, + t2_1, t2_2, t2_3, t2_4, + t3_1, t3_2, t3_3, t3_4 ) { - // TODO implement - unreachable() + eth.log( + to_internal_i32ptr(p1, p2, p3, p4), + u256_to_i32(s1, s2, s3, s4), + 3, + to_internal_i32ptr(t1_1, t1_2, t1_3, t1_4), + to_internal_i32ptr(t2_1, t2_2, t2_3, t2_4), + to_internal_i32ptr(t3_1, t3_2, t3_3, t3_4), + 0 + ) } function log4( p1, p2, p3, p4, s1, s2, s3, s4, - t11, t12, t13, t14, - t21, t22, t23, t24, - t31, t32, t33, t34, - t41, t42, t43, t44, + t1_1, t1_2, t1_3, t1_4, + t2_1, t2_2, t2_3, t2_4, + t3_1, t3_2, t3_3, t3_4, + t4_1, t4_2, t4_3, t4_4, ) { - // TODO implement - unreachable() + eth.log( + to_internal_i32ptr(p1, p2, p3, p4), + u256_to_i32(s1, s2, s3, s4), + 4, + to_internal_i32ptr(t1_1, t1_2, t1_3, t1_4), + to_internal_i32ptr(t2_1, t2_2, t2_3, t2_4), + to_internal_i32ptr(t3_1, t3_2, t3_3, t3_4), + to_internal_i32ptr(t4_1, t4_2, t4_3, t4_4) + ) } -function create(x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4) -> a1, a2, a3, a4 { - // TODO implement - unreachable() +function create( + x1, x2, x3, x4, + y1, y2, y3, y4, + z1, z2, z3, z4 +) -> a1, a2, a3, a4 { + let v1, v2 := u256_to_u128(x1, x2, x3, x4) + mstore_internal(0, 0, 0, v1, v2) + + let r := eth.create(0, to_internal_i32ptr(y1, y2, y3, y4), u256_to_i32(z1, z2, z3, z4), 32) + if i64.eqz(r) { + a1, a2, a3, a4 := mload_internal(32) + } } function call( a1, a2, a3, a4, @@ -629,8 +695,13 @@ function call( f1, f2, f3, f4, g1, g2, g3, g4 ) -> x1, x2, x3, x4 { - // TODO implement - unreachable() + let g := u256_to_i64(a1, a2, a3, a4) + mstore_address(0, b1, b2, b3, b4) + + let v1, v2 := u256_to_u128(c1, c2, c3, c4) + mstore_internal(32, 0, 0, v1, v2) + + x4 := eth.call(g, 12, 32, to_internal_i32ptr(d1, d2, d3, d4), u256_to_i32(e1, e2, e3, e4)) } function callcode( a1, a2, a3, a4, @@ -641,8 +712,18 @@ function callcode( f1, f2, f3, f4, g1, g2, g3, g4 ) -> x1, x2, x3, x4 { - // TODO implement - unreachable() + mstore_address(0, b1, b2, b3, b4) + + let v1, v2 := u256_to_u128(c1, c2, c3, c4) + mstore_internal(32, 0, 0, v1, v2) + + x4 := eth.callCode( + u256_to_i64(a1, a2, a3, a4), + 12, + 32, + to_internal_i32ptr(d1, d2, d3, d4), + u256_to_i32(e1, e2, e3, e4) + ) } function delegatecall( a1, a2, a3, a4, @@ -652,8 +733,14 @@ function delegatecall( e1, e2, e3, e4, f1, f2, f3, f4 ) -> x1, x2, x3, x4 { - // TODO implement - unreachable() + mstore_address(0, b1, b2, b3, b4) + + x4 := eth.callDelegate( + u256_to_i64(a1, a2, a3, a4), + 12, + to_internal_i32ptr(c1, c2, c3, c4), + u256_to_i32(d1, d2, d3, d4) + ) } function staticcall( a1, a2, a3, a4, @@ -663,8 +750,14 @@ function staticcall( e1, e2, e3, e4, f1, f2, f3, f4 ) -> x1, x2, x3, x4 { - // TODO implement - unreachable() + mstore_address(0, b1, b2, b3, b4) + + x4 := eth.callStatic( + u256_to_i64(a1, a2, a3, a4), + 12, + to_internal_i32ptr(c1, c2, c3, c4), + u256_to_i32(d1, d2, d3, d4) + ) } function create2( a1, a2, a3, a4, @@ -676,22 +769,20 @@ function create2( unreachable() } function selfdestruct(a1, a2, a3, a4) { - mstore(0, 0, 0, 0, a1, a2, a3, a4) + mstore_address(0, a1, a2, a3, a4) // In EVM, addresses are padded to 32 bytes, so discard the first 12. eth.selfDestruct(12) } function return(x1, x2, x3, x4, y1, y2, y3, y4) { eth.finish( - // scratch - TODO: overflow check - i64.add(u256_to_i32ptr(x1, x2, x3, x4), 64), + to_internal_i32ptr(x1, x2, x3, x4), u256_to_i32(y1, y2, y3, y4) ) } function revert(x1, x2, x3, x4, y1, y2, y3, y4) { eth.revert( - // scratch - TODO: overflow check - i64.add(u256_to_i32ptr(x1, x2, x3, x4), 64), + to_internal_i32ptr(x1, x2, x3, x4), u256_to_i32(y1, y2, y3, y4) ) } @@ -768,4 +859,3 @@ void EVMToEwasmTranslator::parsePolyfill() for (auto const& statement: m_polyfill->statements) m_polyfillFunctions.insert(std::get(statement).name); } - diff --git a/test/cmdlineTests/standard_eWasm_requested/output.json b/test/cmdlineTests/standard_eWasm_requested/output.json index 9b7e42572..a0c6849f1 100644 --- a/test/cmdlineTests/standard_eWasm_requested/output.json +++ b/test/cmdlineTests/standard_eWasm_requested/output.json @@ -7,23 +7,29 @@ (func $main (local $_1 i64) - (local $_2 i64) + (local $p i64) + (local $r i64) (local $hi i64) - (local $y i64) (local $hi_1 i64) - (local $_3 i64) + (local $y i64) + (local $hi_2 i64) + (local $_2 i64) (local.set $_1 (i64.const 0)) - (local.set $_2 (i64.add (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 64)) (i64.const 64))) - (local.set $hi (i64.shl (i64.or (i64.shl (i64.or (i64.and (i64.shl (local.get $_1) (i64.const 8)) (i64.const 65280)) (i64.and (i64.shr_u (local.get $_1) (i64.const 8)) (i64.const 255))) (i64.const 16)) (call $endian_swap_16 (i64.shr_u (local.get $_1) (i64.const 16)))) (i64.const 32))) - (local.set $y (i64.or (local.get $hi) (call $endian_swap_32 (i64.shr_u (local.get $_1) (i64.const 32))))) - (i64.store (i32.wrap_i64 (local.get $_2)) (local.get $y)) - (i64.store (i32.wrap_i64 (i64.add (local.get $_2) (i64.const 8))) (local.get $y)) - (i64.store (i32.wrap_i64 (i64.add (local.get $_2) (i64.const 16))) (local.get $y)) - (local.set $hi_1 (i64.shl (call $endian_swap_32 (i64.const 128)) (i64.const 32))) - (i64.store (i32.wrap_i64 (i64.add (local.get $_2) (i64.const 24))) (i64.or (local.get $hi_1) (call $endian_swap_32 (i64.shr_u (i64.const 128) (i64.const 32))))) - (local.set $_3 (datasize \"C_2_deployed\")) - (call $eth.codeCopy (i32.wrap_i64 (i64.add (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)) (i64.const 64))) (i32.wrap_i64 (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (dataoffset \"C_2_deployed\"))) (i32.wrap_i64 (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_3)))) - (call $eth.finish (i32.wrap_i64 (i64.add (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1)) (i64.const 64))) (i32.wrap_i64 (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_3)))) + (local.set $p (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (i64.const 64))) + (local.set $r (i64.add (local.get $p) (i64.const 64))) + (if (i64.ne (i64.extend_i32_u (i64.lt_u (local.get $r) (local.get $p))) (i64.const 0)) (then + (unreachable))) + (local.set $hi (i64.shl (call $endian_swap_16 (local.get $_1)) (i64.const 16))) + (local.set $hi_1 (i64.shl (i64.or (local.get $hi) (call $endian_swap_16 (i64.shr_u (local.get $_1) (i64.const 16)))) (i64.const 32))) + (local.set $y (i64.or (local.get $hi_1) (call $endian_swap_32 (i64.shr_u (local.get $_1) (i64.const 32))))) + (i64.store (i32.wrap_i64 (local.get $r)) (local.get $y)) + (i64.store (i32.wrap_i64 (i64.add (local.get $r) (i64.const 8))) (local.get $y)) + (i64.store (i32.wrap_i64 (i64.add (local.get $r) (i64.const 16))) (local.get $y)) + (local.set $hi_2 (i64.shl (call $endian_swap_32 (i64.const 128)) (i64.const 32))) + (i64.store (i32.wrap_i64 (i64.add (local.get $r) (i64.const 24))) (i64.or (local.get $hi_2) (call $endian_swap_32 (i64.shr_u (i64.const 128) (i64.const 32))))) + (local.set $_2 (datasize \"C_2_deployed\")) + (call $eth.codeCopy (i32.wrap_i64 (call $to_internal_i32ptr (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))) (i32.wrap_i64 (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (dataoffset \"C_2_deployed\"))) (i32.wrap_i64 (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_2)))) + (call $eth.finish (i32.wrap_i64 (call $to_internal_i32ptr (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_1))) (i32.wrap_i64 (call $u256_to_i32 (local.get $_1) (local.get $_1) (local.get $_1) (local.get $_2)))) ) (func $u256_to_i32 @@ -41,6 +47,21 @@ (local.get $v) ) +(func $to_internal_i32ptr + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (result i64) + (local $r i64) + (local $p i64) + (local.set $p (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4))) + (local.set $r (i64.add (local.get $p) (i64.const 64))) + (if (i64.ne (i64.extend_i32_u (i64.lt_u (local.get $r) (local.get $p))) (i64.const 0)) (then + (unreachable))) + (local.get $r) +) + (func $endian_swap_16 (param $x i64) (result i64) diff --git a/test/libyul/ewasmTranslationTests/balance.yul b/test/libyul/ewasmTranslationTests/balance.yul index ed4aad891..f8bb5017a 100644 --- a/test/libyul/ewasmTranslationTests/balance.yul +++ b/test/libyul/ewasmTranslationTests/balance.yul @@ -4,7 +4,9 @@ } // ---- // Trace: -// INVALID() // Memory dump: -// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// 0: 0000000000000000000000000000000000000000000000000000000000000001 +// 20: 0000000000000000000000000000000000000000000000000000000022222222 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000022222222 +// 0000000000000000000000000000000000000000000000000000000000000001: 0000000000000000000000000000000000000000000000000000000022222222 diff --git a/test/libyul/ewasmTranslationTests/blockhash.yul b/test/libyul/ewasmTranslationTests/blockhash.yul index 35d431c60..8b906232f 100644 --- a/test/libyul/ewasmTranslationTests/blockhash.yul +++ b/test/libyul/ewasmTranslationTests/blockhash.yul @@ -1,8 +1,9 @@ { - sstore(0, blockhash(1)) + sstore(0, blockhash(1023)) } // ---- // Trace: -// INVALID() // Memory dump: +// 20: 00000000000000000000000000000000000000000000000000000000aaaaa9a9 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 00000000000000000000000000000000000000000000000000000000aaaaa9a9 diff --git a/test/libyul/ewasmTranslationTests/coinbase.yul b/test/libyul/ewasmTranslationTests/coinbase.yul index 023ee3140..ad9eac9cc 100644 --- a/test/libyul/ewasmTranslationTests/coinbase.yul +++ b/test/libyul/ewasmTranslationTests/coinbase.yul @@ -3,6 +3,7 @@ } // ---- // Trace: -// INVALID() // Memory dump: +// 20: 0000000000000000000000000000000077777777000000000000000000000000 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000077777777000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/extcodecopy.yul b/test/libyul/ewasmTranslationTests/extcodecopy.yul index 1c78b5e55..4fd049281 100644 --- a/test/libyul/ewasmTranslationTests/extcodecopy.yul +++ b/test/libyul/ewasmTranslationTests/extcodecopy.yul @@ -4,7 +4,8 @@ } // ---- // Trace: -// INVALID() // Memory dump: -// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// 20: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 +// 140: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 diff --git a/test/libyul/ewasmTranslationTests/extcodesize.yul b/test/libyul/ewasmTranslationTests/extcodesize.yul index 7fa810d06..fb12db5ea 100644 --- a/test/libyul/ewasmTranslationTests/extcodesize.yul +++ b/test/libyul/ewasmTranslationTests/extcodesize.yul @@ -3,7 +3,7 @@ } // ---- // Trace: -// INVALID() // Memory dump: -// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// 20: 000000000000000000000000000000000000000000000000000000000000077b // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 000000000000000000000000000000000000000000000000000000000000077b diff --git a/test/libyul/ewasmTranslationTests/log0.yul b/test/libyul/ewasmTranslationTests/log0.yul index cd10eb28b..6b02e598b 100644 --- a/test/libyul/ewasmTranslationTests/log0.yul +++ b/test/libyul/ewasmTranslationTests/log0.yul @@ -3,6 +3,6 @@ } // ---- // Trace: -// INVALID() +// LOG0() // Memory dump: // Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log1.yul b/test/libyul/ewasmTranslationTests/log1.yul index a985a3f05..296484bd7 100644 --- a/test/libyul/ewasmTranslationTests/log1.yul +++ b/test/libyul/ewasmTranslationTests/log1.yul @@ -3,6 +3,6 @@ } // ---- // Trace: -// INVALID() +// LOG1() // Memory dump: // Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log2.yul b/test/libyul/ewasmTranslationTests/log2.yul index 90c645542..887fef66f 100644 --- a/test/libyul/ewasmTranslationTests/log2.yul +++ b/test/libyul/ewasmTranslationTests/log2.yul @@ -3,6 +3,6 @@ } // ---- // Trace: -// INVALID() +// LOG2() // Memory dump: // Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log3.yul b/test/libyul/ewasmTranslationTests/log3.yul index efff47f08..8ff23e2bd 100644 --- a/test/libyul/ewasmTranslationTests/log3.yul +++ b/test/libyul/ewasmTranslationTests/log3.yul @@ -3,6 +3,6 @@ } // ---- // Trace: -// INVALID() +// LOG3() // Memory dump: // Storage dump: diff --git a/test/libyul/ewasmTranslationTests/log4.yul b/test/libyul/ewasmTranslationTests/log4.yul index 81069baa2..152595e28 100644 --- a/test/libyul/ewasmTranslationTests/log4.yul +++ b/test/libyul/ewasmTranslationTests/log4.yul @@ -3,6 +3,6 @@ } // ---- // Trace: -// INVALID() +// LOG4() // Memory dump: // Storage dump: diff --git a/test/libyul/ewasmTranslationTests/selfdestruct.yul b/test/libyul/ewasmTranslationTests/selfdestruct.yul index 07cf6170e..c000393fb 100644 --- a/test/libyul/ewasmTranslationTests/selfdestruct.yul +++ b/test/libyul/ewasmTranslationTests/selfdestruct.yul @@ -1,10 +1,10 @@ { - selfdestruct(not(0)) + selfdestruct(0xffffffffffffffffffffffffffffffffffffffff) invalid() } // ---- // Trace: // SELFDESTRUCT() // Memory dump: -// 40: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +// 0: 000000000000000000000000ffffffffffffffffffffffffffffffffffffffff // Storage dump: diff --git a/test/libyul/ewasmTranslationTests/smoke_call.yul b/test/libyul/ewasmTranslationTests/smoke_call.yul index 0efe7b38a..6d9377016 100644 --- a/test/libyul/ewasmTranslationTests/smoke_call.yul +++ b/test/libyul/ewasmTranslationTests/smoke_call.yul @@ -3,7 +3,8 @@ } // ---- // Trace: -// INVALID() +// CALL() // Memory dump: -// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// 20: 0000000000000000000000000000000000000000000000000000000000000001 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000001 diff --git a/test/libyul/ewasmTranslationTests/smoke_callcode.yul b/test/libyul/ewasmTranslationTests/smoke_callcode.yul index c82f1d376..dd22ef261 100644 --- a/test/libyul/ewasmTranslationTests/smoke_callcode.yul +++ b/test/libyul/ewasmTranslationTests/smoke_callcode.yul @@ -3,7 +3,8 @@ } // ---- // Trace: -// INVALID() +// CALLCODE() // Memory dump: -// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// 20: 0000000000000000000000000000000000000000000000000000000000000001 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000001 diff --git a/test/libyul/ewasmTranslationTests/smoke_create.yul b/test/libyul/ewasmTranslationTests/smoke_create.yul index ae6d457c4..7650e9e6c 100644 --- a/test/libyul/ewasmTranslationTests/smoke_create.yul +++ b/test/libyul/ewasmTranslationTests/smoke_create.yul @@ -5,7 +5,7 @@ } // ---- // Trace: -// INVALID() +// CREATE() // Memory dump: // 40: 636f6465636f6465636f6465636f6465636f6465000000000000000000000000 // Storage dump: diff --git a/test/libyul/ewasmTranslationTests/smoke_delegatecall.yul b/test/libyul/ewasmTranslationTests/smoke_delegatecall.yul index c8e5ccb4d..30ad4b96d 100644 --- a/test/libyul/ewasmTranslationTests/smoke_delegatecall.yul +++ b/test/libyul/ewasmTranslationTests/smoke_delegatecall.yul @@ -3,7 +3,8 @@ } // ---- // Trace: -// INVALID() +// DELEGATECALL() // Memory dump: -// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// 20: 0000000000000000000000000000000000000000000000000000000000000001 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000001 diff --git a/test/libyul/ewasmTranslationTests/smoke_staticcall.yul b/test/libyul/ewasmTranslationTests/smoke_staticcall.yul index 50669b9fc..25faaa9ee 100644 --- a/test/libyul/ewasmTranslationTests/smoke_staticcall.yul +++ b/test/libyul/ewasmTranslationTests/smoke_staticcall.yul @@ -5,7 +5,8 @@ // EVMVersion: >=byzantium // ---- // Trace: -// INVALID() +// STATICCALL() // Memory dump: -// 0: 0000000000000000000000000000000011111111000000000000000000000000 +// 20: 0000000000000000000000000000000000000000000000000000000000000001 // Storage dump: +// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000001 From bd7ac57f32fae7c1ce9bf1d72e32732e08bb19bc Mon Sep 17 00:00:00 2001 From: Chris Chinchilla Date: Thu, 2 Jan 2020 14:09:43 +0100 Subject: [PATCH 40/57] Add new resources and change sort order --- docs/resources.rst | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/docs/resources.rst b/docs/resources.rst index 3a9e3c0c2..02c1930aa 100644 --- a/docs/resources.rst +++ b/docs/resources.rst @@ -97,23 +97,38 @@ Discontinued: Solidity Tools ~~~~~~~~~~~~~~ +* `ABI to Solidity interface converter `_ + A script for generating contract interfaces from the ABI of a smart contract. + * `Dapp `_ Build tool, package manager, and deployment assistant for Solidity. -* `Solidity REPL `_ - Try Solidity instantly with a command-line Solidity console. - -* `solgraph `_ - Visualize Solidity control flow and highlight potential security vulnerabilities. - * `Doxity `_ Documentation Generator for Solidity. * `evmdis `_ EVM Disassembler that performs static analysis on the bytecode to provide a higher level of abstraction than raw EVM operations. -* `ABI to solidity interface converter `_ - A script for generating contract interfaces from the ABI of a smart contract. +* `EVM Lab `_ + Rich tool package to interact with the EVM. Includes a VM, Etherchain API, and a trace-viewer with gas cost display. + +* `leafleth `_ + A documentation generator for Solidity smart-contracts. + +* `PIET `_ + A tool to develop, audit and use Solidity smart contracts through a simple graphical interface. + +* `solc-select `_ + A script to quickly switch between Solidity compiler versions. + +* `Solidity prettier plugin `_ + A Prettier Plugin for Solidity. + +* `Solidity REPL `_ + Try Solidity instantly with a command-line Solidity console. + +* `solgraph `_ + Visualize Solidity control flow and highlight potential security vulnerabilities. * `Securify `_ Fully automated online static analyzer for smart contracts, providing a security report based on vulnerability patterns. @@ -121,18 +136,9 @@ Solidity Tools * `Sūrya `_ Utility tool for smart contract systems, offering a number of visual outputs and information about the contracts' structure. Also supports querying the function call graph. -* `EVM Lab `_ - Rich tool package to interact with the EVM. Includes a VM, Etherchain API, and a trace-viewer with gas cost display. - * `Universal Mutator `_ A tool for mutation generation, with configurable rules and support for Solidity and Vyper. -* `PIET `_ - A tool to develop, audit and use solidity smart contracts through a simple graphical interface. - -.. note:: - Information like variable names, comments, and source code formatting is lost in the compilation process and it is not possible to completely recover the original source code. Decompiling smart contracts to view the original source code might not be possible, or the end result that useful. - Third-Party Solidity Parsers and Grammars ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 61652366ab4174d11249125af1e88e1e5beefd41 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 8 Jan 2020 10:42:19 +0100 Subject: [PATCH 41/57] Fix indentation --- test/tools/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt index acc70c2dc..69db42107 100644 --- a/test/tools/CMakeLists.txt +++ b/test/tools/CMakeLists.txt @@ -17,8 +17,8 @@ add_executable(isoltest ../Common.cpp ../EVMHost.cpp ../TestCase.cpp - ../libsolidity/util/BytesUtils.cpp - ../libsolidity/util/ContractABIUtils.cpp + ../libsolidity/util/BytesUtils.cpp + ../libsolidity/util/ContractABIUtils.cpp ../libsolidity/util/TestFileParser.cpp ../libsolidity/util/TestFunctionCall.cpp ../libsolidity/GasTest.cpp From b8488597da1842b236be945995673761576c18c7 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 28 Nov 2019 14:22:17 +0100 Subject: [PATCH 42/57] Combine value and loop depth. --- .../optimiser/CommonSubexpressionEliminator.cpp | 16 ++++++++-------- libyul/optimiser/DataFlowAnalyzer.cpp | 11 ++--------- libyul/optimiser/DataFlowAnalyzer.h | 12 +++++++++--- libyul/optimiser/KnowledgeBase.cpp | 1 + libyul/optimiser/KnowledgeBase.h | 5 +++-- libyul/optimiser/Rematerialiser.cpp | 14 +++++++------- libyul/optimiser/SimplificationRules.cpp | 7 ++++--- libyul/optimiser/SimplificationRules.h | 5 +++-- libyul/optimiser/StackCompressor.cpp | 2 +- 9 files changed, 38 insertions(+), 35 deletions(-) diff --git a/libyul/optimiser/CommonSubexpressionEliminator.cpp b/libyul/optimiser/CommonSubexpressionEliminator.cpp index 7528a4299..84074ad27 100644 --- a/libyul/optimiser/CommonSubexpressionEliminator.cpp +++ b/libyul/optimiser/CommonSubexpressionEliminator.cpp @@ -79,10 +79,10 @@ void CommonSubexpressionEliminator::visit(Expression& _e) YulString name = identifier.name; if (m_value.count(name)) { - assertThrow(m_value.at(name), OptimizerException, ""); - if (holds_alternative(*m_value.at(name))) + assertThrow(m_value.at(name).value, OptimizerException, ""); + if (holds_alternative(*m_value.at(name).value)) { - YulString value = std::get(*m_value.at(name)).name; + YulString value = std::get(*m_value.at(name).value).name; assertThrow(inScope(value), OptimizerException, ""); _e = Identifier{locationOf(_e), value}; } @@ -91,13 +91,13 @@ void CommonSubexpressionEliminator::visit(Expression& _e) else { // TODO this search is rather inefficient. - for (auto const& var: m_value) + for (auto const& [variable, value]: m_value) { - assertThrow(var.second, OptimizerException, ""); - assertThrow(inScope(var.first), OptimizerException, ""); - if (SyntacticallyEqual{}(_e, *var.second)) + assertThrow(value.value, OptimizerException, ""); + assertThrow(inScope(variable), OptimizerException, ""); + if (SyntacticallyEqual{}(_e, *value.value)) { - _e = Identifier{locationOf(_e), var.first}; + _e = Identifier{locationOf(_e), variable}; break; } } diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp index baa66553b..d78d7870d 100644 --- a/libyul/optimiser/DataFlowAnalyzer.cpp +++ b/libyul/optimiser/DataFlowAnalyzer.cpp @@ -144,14 +144,12 @@ void DataFlowAnalyzer::operator()(FunctionDefinition& _fun) { // Save all information. We might rather reinstantiate this class, // but this could be difficult if it is subclassed. - map value; - map variableLoopDepth; + map value; size_t loopDepth{0}; InvertibleRelation references; InvertibleMap storage; InvertibleMap memory; swap(m_value, value); - swap(m_variableLoopDepth, variableLoopDepth); swap(m_loopDepth, loopDepth); swap(m_references, references); swap(m_storage, storage); @@ -173,7 +171,6 @@ void DataFlowAnalyzer::operator()(FunctionDefinition& _fun) popScope(); swap(m_value, value); - swap(m_variableLoopDepth, variableLoopDepth); swap(m_loopDepth, loopDepth); swap(m_references, references); swap(m_storage, storage); @@ -306,18 +303,14 @@ void DataFlowAnalyzer::clearValues(set _variables) // Clear the value and update the reference relation. for (auto const& name: _variables) - { m_value.erase(name); - m_variableLoopDepth.erase(name); - } for (auto const& name: _variables) m_references.eraseKey(name); } void DataFlowAnalyzer::assignValue(YulString _variable, Expression const* _value) { - m_value[_variable] = _value; - m_variableLoopDepth[_variable] = m_loopDepth; + m_value[_variable] = {_value, m_loopDepth}; } void DataFlowAnalyzer::clearKnowledgeIfInvalidated(Block const& _block) diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index 04de94197..d17ad4632 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -41,6 +41,14 @@ namespace solidity::yul struct Dialect; struct SideEffects; +/// Value assigned to a variable. +struct AssignedValue +{ + Expression const* value{nullptr}; + /// Loop nesting depth of the definition of the variable. + size_t loopDepth{0}; +}; + /** * Base class to perform data flow analysis during AST walks. * Tracks assignments and is used as base class for both Rematerialiser and @@ -145,9 +153,7 @@ protected: std::map m_functionSideEffects; /// Current values of variables, always movable. - std::map m_value; - /// The loop nesting depth of the definition of variables (those used in m_value). - std::map m_variableLoopDepth; + std::map m_value; /// m_references.forward[a].contains(b) <=> the current expression assigned to a references b /// m_references.backward[b].contains(a) <=> the current expression assigned to a references b InvertibleRelation m_references; diff --git a/libyul/optimiser/KnowledgeBase.cpp b/libyul/optimiser/KnowledgeBase.cpp index 398c2f213..c68085420 100644 --- a/libyul/optimiser/KnowledgeBase.cpp +++ b/libyul/optimiser/KnowledgeBase.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/libyul/optimiser/KnowledgeBase.h b/libyul/optimiser/KnowledgeBase.h index 32cffa820..8d7bcdd90 100644 --- a/libyul/optimiser/KnowledgeBase.h +++ b/libyul/optimiser/KnowledgeBase.h @@ -28,6 +28,7 @@ namespace solidity::yul { struct Dialect; +struct AssignedValue; /** * Class that can answer questions about values of variables and their relations. @@ -37,7 +38,7 @@ struct Dialect; class KnowledgeBase { public: - KnowledgeBase(Dialect const& _dialect, std::map const& _variableValues): + KnowledgeBase(Dialect const& _dialect, std::map const& _variableValues): m_dialect(_dialect), m_variableValues(_variableValues) {} @@ -50,7 +51,7 @@ private: Expression simplify(Expression _expression); Dialect const& m_dialect; - std::map const& m_variableValues; + std::map const& m_variableValues; size_t m_recursionCounter = 0; }; diff --git a/libyul/optimiser/Rematerialiser.cpp b/libyul/optimiser/Rematerialiser.cpp index 02ac48e96..53974616c 100644 --- a/libyul/optimiser/Rematerialiser.cpp +++ b/libyul/optimiser/Rematerialiser.cpp @@ -74,12 +74,12 @@ void Rematerialiser::visit(Expression& _e) YulString name = identifier.name; if (m_value.count(name)) { - assertThrow(m_value.at(name), OptimizerException, ""); - auto const& value = *m_value.at(name); + assertThrow(m_value.at(name).value, OptimizerException, ""); + AssignedValue const& value = m_value.at(name); size_t refs = m_referenceCounts[name]; - size_t cost = CodeCost::codeCost(m_dialect, value); + size_t cost = CodeCost::codeCost(m_dialect, *value.value); if ( - (refs <= 1 && m_variableLoopDepth.at(name) == m_loopDepth) || + (refs <= 1 && value.loopDepth == m_loopDepth) || cost == 0 || (refs <= 5 && cost <= 1 && m_loopDepth == 0) || m_varsToAlwaysRematerialize.count(name) @@ -90,9 +90,9 @@ void Rematerialiser::visit(Expression& _e) assertThrow(inScope(ref), OptimizerException, ""); // update reference counts m_referenceCounts[name]--; - for (auto const& ref: ReferencesCounter::countReferences(value)) + for (auto const& ref: ReferencesCounter::countReferences(*value.value)) m_referenceCounts[ref.first] += ref.second; - _e = (ASTCopier{}).translate(value); + _e = (ASTCopier{}).translate(*value.value); } } } @@ -107,7 +107,7 @@ void LiteralRematerialiser::visit(Expression& _e) YulString name = identifier.name; if (m_value.count(name)) { - Expression const* value = m_value.at(name); + Expression const* value = m_value.at(name).value; assertThrow(value, OptimizerException, ""); if (holds_alternative(*value)) _e = *value; diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp index 5e0edb0a8..0d70fbf38 100644 --- a/libyul/optimiser/SimplificationRules.cpp +++ b/libyul/optimiser/SimplificationRules.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -38,7 +39,7 @@ using namespace solidity::yul; SimplificationRule const* SimplificationRules::findFirstMatch( Expression const& _expr, Dialect const& _dialect, - map const& _ssaValues + map const& _ssaValues ) { auto instruction = instructionAndArguments(_dialect, _expr); @@ -126,7 +127,7 @@ void Pattern::setMatchGroup(unsigned _group, map& _ bool Pattern::matches( Expression const& _expr, Dialect const& _dialect, - map const& _ssaValues + map const& _ssaValues ) const { Expression const* expr = &_expr; @@ -137,7 +138,7 @@ bool Pattern::matches( { YulString varName = std::get(_expr).name; if (_ssaValues.count(varName)) - if (Expression const* new_expr = _ssaValues.at(varName)) + if (Expression const* new_expr = _ssaValues.at(varName).value) expr = new_expr; } assertThrow(expr, OptimizerException, ""); diff --git a/libyul/optimiser/SimplificationRules.h b/libyul/optimiser/SimplificationRules.h index 866fcb90e..1a438ce36 100644 --- a/libyul/optimiser/SimplificationRules.h +++ b/libyul/optimiser/SimplificationRules.h @@ -36,6 +36,7 @@ namespace solidity::yul { struct Dialect; +struct AssignedValue; class Pattern; /** @@ -52,7 +53,7 @@ public: static evmasm::SimplificationRule const* findFirstMatch( Expression const& _expr, Dialect const& _dialect, - std::map const& _ssaValues + std::map const& _ssaValues ); /// Checks whether the rulelist is non-empty. This is usually enforced @@ -109,7 +110,7 @@ public: bool matches( Expression const& _expr, Dialect const& _dialect, - std::map const& _ssaValues + std::map const& _ssaValues ) const; std::vector arguments() const { return m_arguments; } diff --git a/libyul/optimiser/StackCompressor.cpp b/libyul/optimiser/StackCompressor.cpp index 0d72bc0db..cfb2fef82 100644 --- a/libyul/optimiser/StackCompressor.cpp +++ b/libyul/optimiser/StackCompressor.cpp @@ -70,7 +70,7 @@ public: { YulString varName = _varDecl.variables.front().name; if (m_value.count(varName)) - m_expressionCodeCost[varName] = CodeCost::codeCost(m_dialect, *m_value[varName]); + m_expressionCodeCost[varName] = CodeCost::codeCost(m_dialect, *m_value[varName].value); } } From 9f8d49e3589019b3b10048458393c67277bb3881 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Tue, 17 Dec 2019 15:18:58 +0000 Subject: [PATCH 43/57] Move modifier context check to PostTypeChecker refs #7566 --- libsolidity/analysis/PostTypeChecker.cpp | 48 +++++++++++++++++++++++- libsolidity/analysis/PostTypeChecker.h | 4 ++ libsolidity/analysis/TypeChecker.cpp | 15 +------- libsolidity/analysis/TypeChecker.h | 3 -- 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index a83c51d3b..58eb9d79a 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -67,6 +67,15 @@ bool PostTypeChecker::visit(Identifier const& _identifier) return callVisit(_identifier); } +bool PostTypeChecker::visit(ModifierInvocation const& _modifierInvocation) +{ + return callVisit(_modifierInvocation); +} + +void PostTypeChecker::endVisit(ModifierInvocation const& _modifierInvocation) +{ + callEndVisit(_modifierInvocation); +} namespace { @@ -183,11 +192,48 @@ struct OverrideSpecifierChecker: public PostTypeChecker::Checker } } }; -} +struct ModifierContextChecker: public PostTypeChecker::Checker +{ + ModifierContextChecker(ErrorReporter& _errorReporter): + Checker(_errorReporter) {} + + bool visit(ModifierInvocation const&) override + { + m_insideModifierInvocation = true; + + return true; + } + + void endVisit(ModifierInvocation const&) override + { + m_insideModifierInvocation = false; + } + + bool visit(Identifier const& _identifier) override + { + if (m_insideModifierInvocation) + return true; + + if (ModifierType const* type = dynamic_cast(_identifier.annotation().type)) + { + m_errorReporter.typeError( + _identifier.location(), + "Modifier can only be referenced in function headers." + ); + } + + return false; + } +private: + /// Flag indicating whether we are currently inside the invocation of a modifier + bool m_insideModifierInvocation = false; +}; +} PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) { m_checkers.push_back(make_shared(_errorReporter)); m_checkers.push_back(make_shared(_errorReporter)); + m_checkers.push_back(make_shared(_errorReporter)); } diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index a772643f8..325d01ebb 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -36,6 +36,7 @@ namespace solidity::frontend * This module performs analyses on the AST that are done after type checking and assignments of types: * - whether there are circular references in constant state variables * - whether override specifiers are actually contracts + * - whether a modifier is in a function header * * When adding a new checker, make sure a visitor that forwards calls that your * checker uses exists in PostTypeChecker. Add missing ones. @@ -69,6 +70,9 @@ private: bool visit(Identifier const& _identifier) override; + bool visit(ModifierInvocation const& _modifierInvocation) override; + void endVisit(ModifierInvocation const& _modifierInvocation) override; + template bool callVisit(T const& _node) { diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 8f167e875..ea0c976e0 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -547,11 +547,7 @@ void TypeChecker::visitManually( for (ASTPointer const& argument: arguments) argument->accept(*this); - { - m_insideModifierInvocation = true; - ScopeGuard resetFlag{[&] () { m_insideModifierInvocation = false; }}; - _modifier.name()->accept(*this); - } + _modifier.name()->accept(*this); auto const* declaration = &dereference(*_modifier.name()); vector> emptyParameterList; @@ -2704,15 +2700,6 @@ bool TypeChecker::visit(Identifier const& _identifier) ); } - if (!m_insideModifierInvocation) - if (ModifierType const* type = dynamic_cast(_identifier.annotation().type)) - { - m_errorReporter.typeError( - _identifier.location(), - "Modifier can only be referenced in function headers." - ); - } - return false; } diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index ae83559d5..455b60fb8 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -170,9 +170,6 @@ private: /// Flag indicating whether we are currently inside a StructDefinition. bool m_insideStruct = false; - /// Flag indicating whether we are currently inside the invocation of a modifier - bool m_insideModifierInvocation = false; - langutil::ErrorReporter& m_errorReporter; }; From 21844aa545164b52570889a15f6c131937775641 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Tue, 17 Dec 2019 16:04:18 +0000 Subject: [PATCH 44/57] Move event-outside-emit check to PostTypeChecker refs #7566 --- libsolidity/analysis/PostTypeChecker.cpp | 54 ++++++++++++++++++++++++ libsolidity/analysis/PostTypeChecker.h | 6 +++ libsolidity/analysis/TypeChecker.cpp | 8 ---- libsolidity/analysis/TypeChecker.h | 4 -- 4 files changed, 60 insertions(+), 12 deletions(-) diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index 58eb9d79a..a18ee4320 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -62,6 +62,21 @@ void PostTypeChecker::endVisit(VariableDeclaration const& _variable) callEndVisit(_variable); } +bool PostTypeChecker::visit(EmitStatement const& _emit) +{ + return callVisit(_emit); +} + +void PostTypeChecker::endVisit(EmitStatement const& _emit) +{ + callEndVisit(_emit); +} + +bool PostTypeChecker::visit(FunctionCall const& _functionCall) +{ + return callVisit(_functionCall); +} + bool PostTypeChecker::visit(Identifier const& _identifier) { return callVisit(_identifier); @@ -229,6 +244,44 @@ private: /// Flag indicating whether we are currently inside the invocation of a modifier bool m_insideModifierInvocation = false; }; + +struct EventOutsideEmitChecker: public PostTypeChecker::Checker +{ + EventOutsideEmitChecker(ErrorReporter& _errorReporter): + Checker(_errorReporter) {} + + bool visit(EmitStatement const&) override + { + m_insideEmitStatement = true; + return true; + } + + void endVisit(EmitStatement const&) override + { + m_insideEmitStatement = true; + } + + bool visit(FunctionCall const& _functionCall) override + { + if (_functionCall.annotation().kind != FunctionCallKind::FunctionCall) + return true; + + if (FunctionTypePointer const functionType = dynamic_cast(_functionCall.expression().annotation().type)) + // Check for event outside of emit statement + if (!m_insideEmitStatement && functionType->kind() == FunctionType::Kind::Event) + m_errorReporter.typeError( + _functionCall.location(), + "Event invocations have to be prefixed by \"emit\"." + ); + + return true; + } + +private: + /// Flag indicating whether we are currently inside an EmitStatement. + bool m_insideEmitStatement = false; +}; + } PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) @@ -236,4 +289,5 @@ PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_err m_checkers.push_back(make_shared(_errorReporter)); m_checkers.push_back(make_shared(_errorReporter)); m_checkers.push_back(make_shared(_errorReporter)); + m_checkers.push_back(make_shared(_errorReporter)); } diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index 325d01ebb..7a48dfb22 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -37,6 +37,7 @@ namespace solidity::frontend * - whether there are circular references in constant state variables * - whether override specifiers are actually contracts * - whether a modifier is in a function header + * - whether an event is used outside of an emit statement * * When adding a new checker, make sure a visitor that forwards calls that your * checker uses exists in PostTypeChecker. Add missing ones. @@ -68,6 +69,11 @@ private: bool visit(VariableDeclaration const& _variable) override; void endVisit(VariableDeclaration const& _variable) override; + bool visit(EmitStatement const& _emit) override; + void endVisit(EmitStatement const& _emit) override; + + bool visit(FunctionCall const& _functionCall) override; + bool visit(Identifier const& _identifier) override; bool visit(ModifierInvocation const& _modifierInvocation) override; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index ea0c976e0..6315ac15f 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -981,7 +981,6 @@ void TypeChecker::endVisit(EmitStatement const& _emit) dynamic_cast(*type(_emit.eventCall().expression())).kind() != FunctionType::Kind::Event ) m_errorReporter.typeError(_emit.eventCall().expression().location(), "Expression has to be an event invocation."); - m_insideEmitStatement = false; } namespace @@ -1715,13 +1714,6 @@ void TypeChecker::typeCheckFunctionCall( "\"staticcall\" is not supported by the VM version." ); - // Check for event outside of emit statement - if (!m_insideEmitStatement && _functionType->kind() == FunctionType::Kind::Event) - m_errorReporter.typeError( - _functionCall.location(), - "Event invocations have to be prefixed by \"emit\"." - ); - // Perform standard function call type checking typeCheckFunctionGeneralChecks(_functionCall, _functionType); } diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 455b60fb8..1e30ac1b5 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -126,7 +126,6 @@ private: bool visit(WhileStatement const& _whileStatement) override; bool visit(ForStatement const& _forStatement) override; void endVisit(Return const& _return) override; - bool visit(EmitStatement const&) override { m_insideEmitStatement = true; return true; } void endVisit(EmitStatement const& _emit) override; bool visit(VariableDeclarationStatement const& _variable) override; void endVisit(ExpressionStatement const& _statement) override; @@ -164,9 +163,6 @@ private: langutil::EVMVersion m_evmVersion; - /// Flag indicating whether we are currently inside an EmitStatement. - bool m_insideEmitStatement = false; - /// Flag indicating whether we are currently inside a StructDefinition. bool m_insideStruct = false; From 21795627854a1160a404dcf827a3019023117f60 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Tue, 17 Dec 2019 16:58:53 +0000 Subject: [PATCH 45/57] Move variables-in-interfaces checker to PostTypeChecker refs #7566 --- libsolidity/analysis/PostTypeChecker.cpp | 60 ++++++++++++++++++++++++ libsolidity/analysis/PostTypeChecker.h | 4 ++ libsolidity/analysis/TypeChecker.cpp | 13 ----- libsolidity/analysis/TypeChecker.h | 3 -- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/libsolidity/analysis/PostTypeChecker.cpp b/libsolidity/analysis/PostTypeChecker.cpp index a18ee4320..6ed306269 100644 --- a/libsolidity/analysis/PostTypeChecker.cpp +++ b/libsolidity/analysis/PostTypeChecker.cpp @@ -82,6 +82,16 @@ bool PostTypeChecker::visit(Identifier const& _identifier) return callVisit(_identifier); } +bool PostTypeChecker::visit(StructDefinition const& _struct) +{ + return callVisit(_struct); +} + +void PostTypeChecker::endVisit(StructDefinition const& _struct) +{ + callEndVisit(_struct); +} + bool PostTypeChecker::visit(ModifierInvocation const& _modifierInvocation) { return callVisit(_modifierInvocation); @@ -282,6 +292,55 @@ private: bool m_insideEmitStatement = false; }; +struct NoVariablesInInterfaceChecker: public PostTypeChecker::Checker +{ + NoVariablesInInterfaceChecker(ErrorReporter& _errorReporter): + Checker(_errorReporter) + {} + + bool visit(VariableDeclaration const& _variable) override + { + // Forbid any variable declarations inside interfaces unless they are part of + // * a function's input/output parameters, + // * or inside of a struct definition. + if ( + m_scope && m_scope->isInterface() + && !_variable.isCallableOrCatchParameter() + && !m_insideStruct + ) + m_errorReporter.typeError(_variable.location(), "Variables cannot be declared in interfaces."); + + return true; + } + + bool visit(ContractDefinition const& _contract) override + { + m_scope = &_contract; + return true; + } + + void endVisit(ContractDefinition const&) override + { + m_scope = nullptr; + } + + bool visit(StructDefinition const&) override + { + solAssert(m_insideStruct >= 0, ""); + m_insideStruct++; + return true; + } + + void endVisit(StructDefinition const&) override + { + m_insideStruct--; + solAssert(m_insideStruct >= 0, ""); + } +private: + ContractDefinition const* m_scope = nullptr; + /// Flag indicating whether we are currently inside a StructDefinition. + int m_insideStruct = 0; +}; } PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) @@ -290,4 +349,5 @@ PostTypeChecker::PostTypeChecker(langutil::ErrorReporter& _errorReporter): m_err m_checkers.push_back(make_shared(_errorReporter)); m_checkers.push_back(make_shared(_errorReporter)); m_checkers.push_back(make_shared(_errorReporter)); + m_checkers.push_back(make_shared(_errorReporter)); } diff --git a/libsolidity/analysis/PostTypeChecker.h b/libsolidity/analysis/PostTypeChecker.h index 7a48dfb22..0a3358553 100644 --- a/libsolidity/analysis/PostTypeChecker.h +++ b/libsolidity/analysis/PostTypeChecker.h @@ -38,6 +38,7 @@ namespace solidity::frontend * - whether override specifiers are actually contracts * - whether a modifier is in a function header * - whether an event is used outside of an emit statement + * - whether a variable is declared in a interface * * When adding a new checker, make sure a visitor that forwards calls that your * checker uses exists in PostTypeChecker. Add missing ones. @@ -76,6 +77,9 @@ private: bool visit(Identifier const& _identifier) override; + bool visit(StructDefinition const& _struct) override; + void endVisit(StructDefinition const& _struct) override; + bool visit(ModifierInvocation const& _modifierInvocation) override; void endVisit(ModifierInvocation const& _modifierInvocation) override; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 6315ac15f..eb1b6ddcc 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -317,10 +317,7 @@ bool TypeChecker::visit(StructDefinition const& _struct) if (CycleDetector(visitor).run(_struct) != nullptr) m_errorReporter.fatalTypeError(_struct.location(), "Recursive struct definition."); - bool insideStruct = true; - swap(insideStruct, m_insideStruct); ASTNode::listAccept(_struct.members(), *this); - m_insideStruct = insideStruct; return false; } @@ -451,16 +448,6 @@ bool TypeChecker::visit(FunctionDefinition const& _function) bool TypeChecker::visit(VariableDeclaration const& _variable) { - // Forbid any variable declarations inside interfaces unless they are part of - // * a function's input/output parameters, - // * or inside of a struct definition. - if ( - m_scope->isInterface() - && !_variable.isCallableOrCatchParameter() - && !m_insideStruct - ) - m_errorReporter.typeError(_variable.location(), "Variables cannot be declared in interfaces."); - if (_variable.typeName()) _variable.typeName()->accept(*this); diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 1e30ac1b5..c7443b29c 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -163,9 +163,6 @@ private: langutil::EVMVersion m_evmVersion; - /// Flag indicating whether we are currently inside a StructDefinition. - bool m_insideStruct = false; - langutil::ErrorReporter& m_errorReporter; }; From b68ea243fc2d05ca182bd873cf08978e20e7e2fe Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 8 Jan 2020 18:37:46 +0100 Subject: [PATCH 46/57] Fix comment. --- docs/contracts/function-modifiers.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index 90eb2fc27..758ba74ea 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -41,8 +41,8 @@ if they are marked ``virtual``. For details, please see contract destructible is owned { // This contract inherits the `onlyOwner` modifier from - // `owned` and applies it to the `close` function, which - // causes that calls to `close` only have an effect if + // `owned` and applies it to the `destroy` function, which + // causes that calls to `destroy` only have an effect if // they are made by the stored owner. function destroy() public onlyOwner { selfdestruct(owner); From a02308cfa521a6d475a74eb45b9061290995cf16 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Tue, 7 Jan 2020 15:45:57 +0100 Subject: [PATCH 47/57] Replace void cast by maybe_unused --- libsolidity/ast/Types.h | 4 ++-- libsolidity/formal/SMTPortfolio.cpp | 3 +-- libyul/AsmParser.cpp | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 0308fc452..3859e847f 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -211,7 +211,7 @@ public: /// Always returns a value greater than zero and throws if the type cannot be encoded in calldata /// (or is dynamically encoded). /// If @a _padded then it is assumed that each element is padded to a multiple of 32 bytes. - virtual unsigned calldataEncodedSize(bool _padded) const { (void)_padded; solAssert(false, ""); } + virtual unsigned calldataEncodedSize([[maybe_unused]] bool _padded) const { solAssert(false, ""); } /// Convenience version of @see calldataEncodedSize(bool) unsigned calldataEncodedSize() const { return calldataEncodedSize(true); } /// @returns the distance between two elements of this type in a calldata array, tuple or struct. @@ -1432,7 +1432,7 @@ public: BoolResult isImplicitlyConvertibleTo(Type const&) const override { return false; } BoolResult isExplicitlyConvertibleTo(Type const&) const override { return false; } TypeResult binaryOperatorResult(Token, Type const*) const override { return nullptr; } - unsigned calldataEncodedSize(bool _padded) const override { (void)_padded; return 32; } + unsigned calldataEncodedSize(bool) const override { return 32; } bool canBeStored() const override { return false; } bool canLiveOutsideStorage() const override { return false; } bool isValueType() const override { return true; } diff --git a/libsolidity/formal/SMTPortfolio.cpp b/libsolidity/formal/SMTPortfolio.cpp index 9ae745b7c..2ce698bdf 100644 --- a/libsolidity/formal/SMTPortfolio.cpp +++ b/libsolidity/formal/SMTPortfolio.cpp @@ -34,7 +34,7 @@ using namespace solidity::frontend::smt; SMTPortfolio::SMTPortfolio( map const& _smtlib2Responses, ReadCallback::Callback const& _smtCallback, - SMTSolverChoice _enabledSolvers + [[maybe_unused]] SMTSolverChoice _enabledSolvers ) { m_solvers.emplace_back(make_unique(_smtlib2Responses, _smtCallback)); @@ -46,7 +46,6 @@ SMTPortfolio::SMTPortfolio( if (_enabledSolvers.cvc4) m_solvers.emplace_back(make_unique()); #endif - (void)_enabledSolvers; } void SMTPortfolio::reset() diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index ac9ccce76..0dd2a633c 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -554,8 +554,7 @@ bool Parser::isValidNumberLiteral(string const& _literal) try { // Try to convert _literal to u256. - auto tmp = u256(_literal); - (void) tmp; + [[maybe_unused]] auto tmp = u256(_literal); } catch (...) { From 03c70f45d6d0e30d8550d485d2dd564a21b533d5 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 9 Jan 2020 14:18:54 +0100 Subject: [PATCH 48/57] Handle empty source strings in SourceReferenceExtractor --- liblangutil/SourceReferenceExtractor.cpp | 3 +++ liblangutil/SourceReferenceExtractor.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/liblangutil/SourceReferenceExtractor.cpp b/liblangutil/SourceReferenceExtractor.cpp index ff045a198..44f1540ca 100644 --- a/liblangutil/SourceReferenceExtractor.cpp +++ b/liblangutil/SourceReferenceExtractor.cpp @@ -46,6 +46,9 @@ SourceReference SourceReferenceExtractor::extract(SourceLocation const* _locatio if (!_location || !_location->source.get()) // Nothing we can extract here return SourceReference::MessageOnly(std::move(message)); + if (_location->source->source().empty()) // No source text, so we can only extract the source name + return SourceReference::MessageOnly(std::move(message), _location->source->name()); + shared_ptr const& source = _location->source; LineColumn const interest = source->translatePositionToLineColumn(_location->start); diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h index 12f608409..6aa0ab34a 100644 --- a/liblangutil/SourceReferenceExtractor.h +++ b/liblangutil/SourceReferenceExtractor.h @@ -49,10 +49,11 @@ struct SourceReference int endColumn = {-1}; ///< Highlighting range-end of text field. /// Constructs a SourceReference containing a message only. - static SourceReference MessageOnly(std::string _msg) + static SourceReference MessageOnly(std::string _msg, std::string _sourceName = {}) { SourceReference sref; sref.message = std::move(_msg); + sref.sourceName = std::move(_sourceName); return sref; } }; From dc6c19cafa17674922e6ab821a52dd8da88f7942 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Fri, 20 Dec 2019 23:10:01 -0500 Subject: [PATCH 49/57] Add methods for AST annotation implementation --- libsolidity/ast/AST.cpp | 98 ++++++++++------------------------------- libsolidity/ast/AST.h | 23 +++++++++- 2 files changed, 45 insertions(+), 76 deletions(-) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 0983da397..8fd482b73 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -69,9 +69,7 @@ ASTAnnotation& ASTNode::annotation() const SourceUnitAnnotation& SourceUnit::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } set SourceUnit::referencedSourceUnits(bool _recurse, set _skipList) const @@ -93,9 +91,7 @@ set SourceUnit::referencedSourceUnits(bool _recurse, set(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } TypePointer ImportDirective::type() const @@ -262,16 +258,12 @@ TypePointer ContractDefinition::type() const ContractDefinitionAnnotation& ContractDefinition::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } TypeNameAnnotation& TypeName::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } TypePointer StructDefinition::type() const @@ -281,9 +273,7 @@ TypePointer StructDefinition::type() const TypeDeclarationAnnotation& StructDefinition::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } TypePointer EnumValue::type() const @@ -300,9 +290,7 @@ TypePointer EnumDefinition::type() const TypeDeclarationAnnotation& EnumDefinition::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } ContractKind FunctionDefinition::inContractKind() const @@ -314,11 +302,7 @@ ContractKind FunctionDefinition::inContractKind() const CallableDeclarationAnnotation& CallableDeclaration::annotation() const { - solAssert( - m_annotation, - "CallableDeclarationAnnotation is an abstract base, need to call annotation on the concrete class first." - ); - return dynamic_cast(*m_annotation); + return abstractAnnotation("CallableDeclarationAnnotation"); } @@ -375,9 +359,7 @@ string FunctionDefinition::externalIdentifierHex() const FunctionDefinitionAnnotation& FunctionDefinition::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } TypePointer ModifierDefinition::type() const @@ -387,9 +369,7 @@ TypePointer ModifierDefinition::type() const ModifierDefinitionAnnotation& ModifierDefinition::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } TypePointer EventDefinition::type() const @@ -407,16 +387,12 @@ FunctionTypePointer EventDefinition::functionType(bool _internal) const EventDefinitionAnnotation& EventDefinition::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } UserDefinedTypeNameAnnotation& UserDefinedTypeName::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } SourceUnit const& Scopable::sourceUnit() const @@ -451,9 +427,7 @@ string Scopable::sourceUnitName() const DeclarationAnnotation& Declaration::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } bool VariableDeclaration::isLValue() const @@ -641,86 +615,62 @@ FunctionTypePointer VariableDeclaration::functionType(bool _internal) const VariableDeclarationAnnotation& VariableDeclaration::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } StatementAnnotation& Statement::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } InlineAssemblyAnnotation& InlineAssembly::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } BlockAnnotation& Block::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } TryCatchClauseAnnotation& TryCatchClause::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } ForStatementAnnotation& ForStatement::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } ReturnAnnotation& Return::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } ExpressionAnnotation& Expression::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } MemberAccessAnnotation& MemberAccess::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } BinaryOperationAnnotation& BinaryOperation::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } FunctionCallAnnotation& FunctionCall::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } IdentifierAnnotation& Identifier::annotation() const { - if (!m_annotation) - m_annotation = make_unique(); - return dynamic_cast(*m_annotation); + return initAnnotation(); } ASTString Literal::valueWithoutUnderscores() const diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 3ef066f8a..28a5cc76e 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -108,10 +108,29 @@ public: protected: size_t const m_id = 0; - /// Annotation - is specialised in derived classes, is created upon request (because of polymorphism). - mutable std::unique_ptr m_annotation; + + template + T& initAnnotation() const + { + if (!m_annotation) + m_annotation = std::make_unique(); + return dynamic_cast(*m_annotation); + } + + template + T& abstractAnnotation(std::string _className) const + { + solAssert( + m_annotation, + _className + " is an abstract base, need to call annotation on the concrete class first." + ); + + return dynamic_cast(*m_annotation); + } private: + /// Annotation - is specialised in derived classes, is created upon request (because of polymorphism). + mutable std::unique_ptr m_annotation; SourceLocation m_location; }; From dc380f017f3fed2847ea88107c7b74a91dc4ad23 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Tue, 7 Jan 2020 08:34:20 -0500 Subject: [PATCH 50/57] Make CallableDeclaration::annotation pure virtual --- libsolidity/ast/AST.cpp | 6 ------ libsolidity/ast/AST.h | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 8fd482b73..f11725469 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -300,12 +300,6 @@ ContractKind FunctionDefinition::inContractKind() const return contractDef->contractKind(); } -CallableDeclarationAnnotation& CallableDeclaration::annotation() const -{ - return abstractAnnotation("CallableDeclarationAnnotation"); -} - - FunctionTypePointer FunctionDefinition::functionType(bool _internal) const { if (_internal) diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 28a5cc76e..5bb670d27 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -637,7 +637,7 @@ public: bool markedVirtual() const { return m_isVirtual; } virtual bool virtualSemantics() const { return markedVirtual(); } - CallableDeclarationAnnotation& annotation() const override; + CallableDeclarationAnnotation& annotation() const override = 0; protected: ASTPointer m_parameters; From 3726f7448e2574d7f8f835b2bf7fff4c09c2a4be Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Thu, 9 Jan 2020 08:44:24 -0500 Subject: [PATCH 51/57] Remove now-unused abstractAnnotation helper --- libsolidity/ast/AST.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 5bb670d27..fc0b3a5be 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -117,17 +117,6 @@ protected: return dynamic_cast(*m_annotation); } - template - T& abstractAnnotation(std::string _className) const - { - solAssert( - m_annotation, - _className + " is an abstract base, need to call annotation on the concrete class first." - ); - - return dynamic_cast(*m_annotation); - } - private: /// Annotation - is specialised in derived classes, is created upon request (because of polymorphism). mutable std::unique_ptr m_annotation; From b845595cbd66e305d46d03d3b9a16346ece8eecf Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 9 Jan 2020 14:49:11 +0100 Subject: [PATCH 52/57] Ignore empty options to (i)soltest --- test/Common.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Common.cpp b/test/Common.cpp index 725902e25..a88871669 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -122,6 +122,11 @@ bool CommonOptions::parse(int argc, char const* const* argv) for (auto const& parsedOption: parsedOptions.options) if (parsedOption.position_key >= 0) { + if ( + parsedOption.original_tokens.empty() || + (parsedOption.original_tokens.size() == 1 && parsedOption.original_tokens.front().empty()) + ) + continue; // ignore empty options std::stringstream errorMessage; errorMessage << "Unrecognized option: "; for (auto const& token: parsedOption.original_tokens) From 9535c0f520d70513e96d0e43320b28a9bdb87040 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 7 Jan 2020 11:42:37 +0100 Subject: [PATCH 53/57] Introduce FunctionKind::Declaration and allow accessing function signatures via contract name. --- Changelog.md | 1 + libsolidity/analysis/TypeChecker.cpp | 10 ++++ libsolidity/ast/AST.cpp | 8 +-- libsolidity/ast/TypeProvider.cpp | 4 +- libsolidity/ast/TypeProvider.h | 4 +- libsolidity/ast/Types.cpp | 58 ++++++++++++++----- libsolidity/ast/Types.h | 11 +++- libsolidity/codegen/ExpressionCompiler.cpp | 24 ++++++-- libsolidity/interface/ABI.cpp | 4 +- .../function_selector_via_contract_name.sol | 20 +++++++ ...sign_function_via_contract_name_to_var.sol | 14 +++++ .../call_function_via_contract_name.sol | 17 ++++++ .../function_selector_via_contract_name.sol | 9 +++ .../function_selector_via_interface_name.sol | 9 +++ .../function_via_contract_name_internal.sol | 11 ++++ .../function_via_contract_name_overloaded.sol | 12 ++++ .../function_via_contract_name_private.sol | 11 ++++ .../function_via_contract_name_public.sol | 9 +++ 18 files changed, 202 insertions(+), 34 deletions(-) create mode 100644 test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/assign_function_via_contract_name_to_var.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/call_function_via_contract_name.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_contract_name.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_interface_name.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_internal.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_overloaded.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_private.sol create mode 100644 test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_public.sol diff --git a/Changelog.md b/Changelog.md index 47df79890..21e0e91f5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ### 0.6.2 (unreleased) Language Features: + * Allow accessing external functions via contract and interface names to obtain their selector. Compiler Features: diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index eb1b6ddcc..5d8c7b85f 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1691,6 +1691,16 @@ void TypeChecker::typeCheckFunctionCall( solAssert(!!_functionType, ""); solAssert(_functionType->kind() != FunctionType::Kind::ABIDecode, ""); + if (_functionType->kind() == FunctionType::Kind::Declaration) + { + m_errorReporter.typeError( + _functionCall.location(), + "Cannot call function via contract name." + ); + return; + } + + // Check for unsupported use of bare static call if ( _functionType->kind() == FunctionType::Kind::BareStaticCall && diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 0983da397..db72e51ee 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -203,7 +203,7 @@ vector, FunctionTypePointer>> const& ContractDefinition: vector functions; for (FunctionDefinition const* f: contract->definedFunctions()) if (f->isPartOfExternalInterface()) - functions.push_back(TypeProvider::function(*f, false)); + functions.push_back(TypeProvider::function(*f, FunctionType::Kind::External)); for (VariableDeclaration const* v: contract->stateVariables()) if (v->isPartOfExternalInterface()) functions.push_back(TypeProvider::function(*v)); @@ -333,7 +333,7 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const case Visibility::Private: case Visibility::Internal: case Visibility::Public: - return TypeProvider::function(*this, _internal); + return TypeProvider::function(*this, FunctionType::Kind::Internal); case Visibility::External: return {}; } @@ -349,7 +349,7 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const return {}; case Visibility::Public: case Visibility::External: - return TypeProvider::function(*this, _internal); + return TypeProvider::function(*this, FunctionType::Kind::External); } } @@ -360,7 +360,7 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const TypePointer FunctionDefinition::type() const { solAssert(visibility() != Visibility::External, ""); - return TypeProvider::function(*this); + return TypeProvider::function(*this, FunctionType::Kind::Internal); } string FunctionDefinition::externalSignature() const diff --git a/libsolidity/ast/TypeProvider.cpp b/libsolidity/ast/TypeProvider.cpp index 749a77655..4cb3e781b 100644 --- a/libsolidity/ast/TypeProvider.cpp +++ b/libsolidity/ast/TypeProvider.cpp @@ -414,9 +414,9 @@ ReferenceType const* TypeProvider::withLocation(ReferenceType const* _type, Data return static_cast(instance().m_generalTypes.back().get()); } -FunctionType const* TypeProvider::function(FunctionDefinition const& _function, bool _isInternal) +FunctionType const* TypeProvider::function(FunctionDefinition const& _function, FunctionType::Kind _kind) { - return createAndGet(_function, _isInternal); + return createAndGet(_function, _kind); } FunctionType const* TypeProvider::function(VariableDeclaration const& _varDecl) diff --git a/libsolidity/ast/TypeProvider.h b/libsolidity/ast/TypeProvider.h index 1932ae919..cef182aed 100644 --- a/libsolidity/ast/TypeProvider.h +++ b/libsolidity/ast/TypeProvider.h @@ -120,8 +120,8 @@ public: return _type; } - /// @returns the internally-facing or externally-facing type of a function. - static FunctionType const* function(FunctionDefinition const& _function, bool _isInternal = true); + /// @returns the internally-facing or externally-facing type of a function or the type of a function declaration. + static FunctionType const* function(FunctionDefinition const& _function, FunctionType::Kind _kind = FunctionType::Kind::Declaration); /// @returns the accessor function type of a state variable. static FunctionType const* function(VariableDeclaration const& _varDecl); diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 4f596468b..f3f575a18 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -362,7 +362,7 @@ MemberList::MemberMap Type::boundFunctions(Type const& _type, ContractDefinition seenFunctions.insert(function); if (function->parameters().empty()) continue; - FunctionTypePointer fun = FunctionType(*function, false).asCallableFunction(true, true); + FunctionTypePointer fun = FunctionType(*function, FunctionType::Kind::External).asCallableFunction(true, true); if (_type.isImplicitlyConvertibleTo(*fun->selfType())) members.emplace_back(function->name(), fun, function); } @@ -1933,7 +1933,7 @@ MemberList::MemberMap ContractType::nativeMembers(ContractDefinition const* _con if (!function->isVisibleInDerivedContracts() || !function->isImplemented()) continue; - auto functionType = TypeProvider::function(*function, true); + auto functionType = TypeProvider::function(*function, FunctionType::Kind::Internal); bool functionWithEqualArgumentsFound = false; for (auto const& member: members) { @@ -2465,12 +2465,16 @@ TypePointer TupleType::closestTemporaryType(Type const* _targetType) const return TypeProvider::tuple(move(tempComponents)); } -FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal): - m_kind(_isInternal ? Kind::Internal : Kind::External), +FunctionType::FunctionType(FunctionDefinition const& _function, Kind _kind): + m_kind(_kind), m_stateMutability(_function.stateMutability()), m_declaration(&_function) { - if (_isInternal && m_stateMutability == StateMutability::Payable) + solAssert( + _kind == Kind::Internal || _kind == Kind::External || _kind == Kind::Declaration, + "Only internal or external function types or function declaration types can be created from function definitions." + ); + if (_kind == Kind::Internal && m_stateMutability == StateMutability::Payable) m_stateMutability = StateMutability::NonPayable; for (ASTPointer const& var: _function.parameters()) @@ -2689,6 +2693,7 @@ string FunctionType::richIdentifier() const string id = "t_function_"; switch (m_kind) { + case Kind::Declaration: id += "declaration"; break; case Kind::Internal: id += "internal"; break; case Kind::External: id += "external"; break; case Kind::DelegateCall: id += "delegatecall"; break; @@ -2755,7 +2760,12 @@ bool FunctionType::operator==(Type const& _other) const BoolResult FunctionType::isExplicitlyConvertibleTo(Type const& _convertTo) const { - return _convertTo.category() == category(); + if (_convertTo.category() == category()) + { + auto const& convertToType = dynamic_cast(_convertTo); + return (m_kind == FunctionType::Kind::Declaration) == (convertToType.kind() == FunctionType::Kind::Declaration); + } + return false; } BoolResult FunctionType::isImplicitlyConvertibleTo(Type const& _convertTo) const @@ -2808,7 +2818,18 @@ string FunctionType::canonicalName() const string FunctionType::toString(bool _short) const { - string name = "function ("; + string name = "function "; + if (m_kind == Kind::Declaration) + { + auto const* functionDefinition = dynamic_cast(m_declaration); + solAssert(functionDefinition, ""); + auto const* contract = dynamic_cast(functionDefinition->scope()); + solAssert(contract, ""); + name += contract->annotation().canonicalName; + name += '.'; + name += functionDefinition->name(); + } + name += '('; for (auto it = m_parameterTypes.begin(); it != m_parameterTypes.end(); ++it) name += (*it)->toString(_short) + (it + 1 == m_parameterTypes.end() ? "" : ","); name += ")"; @@ -2940,6 +2961,8 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con { switch (m_kind) { + case Kind::Declaration: + return {{"selector", TypeProvider::fixedBytes(4)}}; case Kind::External: case Kind::Creation: case Kind::BareCall: @@ -3146,6 +3169,7 @@ string FunctionType::externalSignature() const case Kind::External: case Kind::DelegateCall: case Kind::Event: + case Kind::Declaration: break; default: solAssert(false, "Invalid function type for requesting external signature."); @@ -3210,6 +3234,7 @@ TypePointers FunctionType::parseElementaryTypeVector(strings const& _types) TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) const { + solAssert(m_kind != Kind::Declaration, ""); return TypeProvider::function( m_parameterTypes, m_returnParameterTypes, @@ -3387,14 +3412,6 @@ MemberList::MemberMap TypeType::nativeMembers(ContractDefinition const* _current auto const& currentBases = _currentScope->annotation().linearizedBaseContracts; isBase = (find(currentBases.begin(), currentBases.end(), &contract) != currentBases.end()); } - if (contract.isLibrary()) - for (FunctionDefinition const* function: contract.definedFunctions()) - if (function->isVisibleAsLibraryMember()) - members.emplace_back( - function->name(), - FunctionType(*function).asCallableFunction(true), - function - ); if (isBase) { // We are accessing the type of a base contract, so add all public and protected @@ -3404,6 +3421,17 @@ MemberList::MemberMap TypeType::nativeMembers(ContractDefinition const* _current } else { + bool inLibrary = contract.isLibrary(); + for (FunctionDefinition const* function: contract.definedFunctions()) + if ( + (inLibrary && function->isVisibleAsLibraryMember()) || + (!inLibrary && function->isPartOfExternalInterface()) + ) + members.emplace_back( + function->name(), + FunctionType(*function).asCallableFunction(inLibrary), + function + ); for (auto const& stru: contract.definedStructs()) members.emplace_back(stru->name(), stru->type(), stru); for (auto const& enu: contract.definedEnums()) diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 0308fc452..f7e088282 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -1051,11 +1051,16 @@ public: ABIEncodeWithSignature, ABIDecode, GasLeft, ///< gasleft() - MetaType ///< type(...) + MetaType, ///< type(...) + /// Refers to a function declaration without calling context + /// (i.e. when accessed directly via the name of the containing contract). + /// Cannot be called. + Declaration }; /// Creates the type of a function. - explicit FunctionType(FunctionDefinition const& _function, bool _isInternal = true); + /// @arg _kind must be Kind::Internal, Kind::External or Kind::Declaration. + explicit FunctionType(FunctionDefinition const& _function, Kind _kind = Kind::Declaration); /// Creates the accessor function type of a state variable. explicit FunctionType(VariableDeclaration const& _varDecl); /// Creates the function type of an event. @@ -1066,7 +1071,7 @@ public: FunctionType( strings const& _parameterTypes, strings const& _returnParameterTypes, - Kind _kind = Kind::Internal, + Kind _kind, bool _arbitraryParameters = false, StateMutability _stateMutability = StateMutability::NonPayable ): FunctionType( diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 921e2ecff..2e1ef44dc 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -550,6 +550,9 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) solAssert(function.kind() == FunctionType::Kind::DelegateCall || function.kind() == FunctionType::Kind::Internal, ""); switch (function.kind()) { + case FunctionType::Kind::Declaration: + solAssert(false, "Attempted to generate code for calling a function definition."); + break; case FunctionType::Kind::Internal: { // Calling convention: Caller pushes return address and arguments @@ -1289,14 +1292,22 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) _memberAccess.expression().accept(*this); return false; } - // Another special case for `this.f.selector` which does not need the address. - // There are other uses of `.selector` which do need the address, but we want this - // specific use to be a pure expression. + // Another special case for `this.f.selector` and for ``C.f.selector`` which do not need the address. + // There are other uses of `.selector` which do need the address, but we want these + // specific uses to be pure expressions. if ( - _memberAccess.expression().annotation().type->category() == Type::Category::Function && - member == "selector" + auto const* functionType = dynamic_cast(_memberAccess.expression().annotation().type); + functionType && member == "selector" ) - if (auto const* expr = dynamic_cast(&_memberAccess.expression())) + { + if (functionType->kind() == FunctionType::Kind::Declaration) + { + m_context << functionType->externalIdentifier(); + /// need to store it as bytes4 + utils().leftShiftNumberOnStack(224); + return false; + } + else if (auto const* expr = dynamic_cast(&_memberAccess.expression())) if (auto const* exprInt = dynamic_cast(&expr->expression())) if (exprInt->name() == "this") if (Declaration const* declaration = expr->annotation().referencedDeclaration) @@ -1313,6 +1324,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) utils().leftShiftNumberOnStack(224); return false; } + } // Another special case for `address(this).balance`. Post-Istanbul, we can use the selfbalance // opcode. if ( diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index 7ab3861cd..56e2ecbde 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -75,7 +75,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) } if (_contractDef.constructor()) { - FunctionType constrType(*_contractDef.constructor(), false); + FunctionType constrType(*_contractDef.constructor()); FunctionType const* externalFunctionType = constrType.interfaceFunctionType(); solAssert(!!externalFunctionType, ""); Json::Value method; @@ -92,7 +92,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) for (auto const* fallbackOrReceive: {_contractDef.fallbackFunction(), _contractDef.receiveFunction()}) if (fallbackOrReceive) { - FunctionType const* externalFunctionType = FunctionType(*fallbackOrReceive, false).interfaceFunctionType(); + auto const* externalFunctionType = FunctionType(*fallbackOrReceive).interfaceFunctionType(); solAssert(!!externalFunctionType, ""); Json::Value method; method["type"] = TokenTraits::toString(fallbackOrReceive->kind()); diff --git a/test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol b/test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol new file mode 100644 index 000000000..0a9e6d3ff --- /dev/null +++ b/test/libsolidity/semanticTests/functionSelector/function_selector_via_contract_name.sol @@ -0,0 +1,20 @@ +contract A { + function f() external {} + function g(uint256) external {} +} +contract B { + function f() external returns (uint256) {} + function g(uint256) external returns (uint256) {} +} +contract C { + function test1() external returns(bytes4, bytes4, bytes4, bytes4) { + return (A.f.selector, A.g.selector, B.f.selector, B.g.selector); + } + function test2() external returns(bytes4, bytes4, bytes4, bytes4) { + A a; B b; + return (a.f.selector, a.g.selector, b.f.selector, b.g.selector); + } +} +// ---- +// test1() -> left(0x26121ff0), left(0xe420264a), left(0x26121ff0), left(0xe420264a) +// test2() -> left(0x26121ff0), left(0xe420264a), left(0x26121ff0), left(0xe420264a) diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/assign_function_via_contract_name_to_var.sol b/test/libsolidity/syntaxTests/types/function_types/definition/assign_function_via_contract_name_to_var.sol new file mode 100644 index 000000000..546779548 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/assign_function_via_contract_name_to_var.sol @@ -0,0 +1,14 @@ +contract A { + function f() external {} + function g() external pure {} +} + +contract B { + function h() external { + function() external f = A.f; + function() external pure g = A.g; + } +} +// ---- +// TypeError: (128-155): Type function A.f() is not implicitly convertible to expected type function () external. +// TypeError: (165-197): Type function A.g() pure is not implicitly convertible to expected type function () pure external. diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/call_function_via_contract_name.sol b/test/libsolidity/syntaxTests/types/function_types/definition/call_function_via_contract_name.sol new file mode 100644 index 000000000..12b49007e --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/call_function_via_contract_name.sol @@ -0,0 +1,17 @@ +contract A { + function f() external {} + function g() external pure {} + function h() public pure {} +} + +contract B { + function i() external { + A.f(); + A.g(); + A.h(); // might be allowed in the future + } +} +// ---- +// TypeError: (160-165): Cannot call function via contract name. +// TypeError: (175-180): Cannot call function via contract name. +// TypeError: (190-195): Cannot call function via contract name. diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_contract_name.sol b/test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_contract_name.sol new file mode 100644 index 000000000..ec53a0f60 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_contract_name.sol @@ -0,0 +1,9 @@ +contract A { + function f() external {} +} + +contract B { + function g() external pure { + A.f.selector; + } +} diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_interface_name.sol b/test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_interface_name.sol new file mode 100644 index 000000000..e733b6701 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/function_selector_via_interface_name.sol @@ -0,0 +1,9 @@ +interface I { + function f() external; +} + +contract B { + function g() external pure { + I.f.selector; + } +} diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_internal.sol b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_internal.sol new file mode 100644 index 000000000..0c2247fdb --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_internal.sol @@ -0,0 +1,11 @@ +contract A { + function f() internal {} +} + +contract B { + function g() external { + A.f; + } +} +// ---- +// TypeError: (94-97): Member "f" not found or not visible after argument-dependent lookup in type(contract A). diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_overloaded.sol b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_overloaded.sol new file mode 100644 index 000000000..23bed07d0 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_overloaded.sol @@ -0,0 +1,12 @@ +contract A { + function f() external {} + function f(uint256) external {} +} + +contract B { + function g() external { + A.f; + } +} +// ---- +// TypeError: (130-133): Member "f" not unique after argument-dependent lookup in type(contract A). diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_private.sol b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_private.sol new file mode 100644 index 000000000..eec0f69ba --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_private.sol @@ -0,0 +1,11 @@ +contract A { + function f() private {} +} + +contract B { + function g() external { + A.f; + } +} +// ---- +// TypeError: (93-96): Member "f" not found or not visible after argument-dependent lookup in type(contract A). diff --git a/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_public.sol b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_public.sol new file mode 100644 index 000000000..28d1ff6d1 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/function_types/definition/function_via_contract_name_public.sol @@ -0,0 +1,9 @@ +contract A { + function f() public {} +} + +contract B { + function g() external pure { + A.f.selector; + } +} From 57fcab80fc20169a0cdf99f9d445e19ffdf514a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20S=C3=A1?= Date: Thu, 9 Jan 2020 23:12:24 +0000 Subject: [PATCH 54/57] Update grammar to represent optionality in catch clauses parameter list --- docs/grammar.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/grammar.txt b/docs/grammar.txt index f70ec1342..9f4bf55db 100644 --- a/docs/grammar.txt +++ b/docs/grammar.txt @@ -72,7 +72,7 @@ Statement = IfStatement | TryStatement | WhileStatement | ForStatement | Block | ExpressionStatement = Expression IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )? TryStatement = 'try' Expression ( 'returns' ParameterList )? Block CatchClause+ -CatchClause = 'catch' Identifier? ParameterList Block +CatchClause = 'catch' ( Identifier? ParameterList )? Block WhileStatement = 'while' '(' Expression ')' Statement PlaceholderStatement = '_' SimpleStatement = VariableDefinition | ExpressionStatement From 90e494615e121da3c1e9ad5496dcf0e877cd75eb Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 28 Nov 2019 19:47:08 +0100 Subject: [PATCH 55/57] Build soljson.js with embedded base64-encoded wasm binary. --- Changelog.md | 3 +++ cmake/EthCompilerSettings.cmake | 10 +++++++--- scripts/travis-emscripten/build_emscripten.sh | 8 -------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Changelog.md b/Changelog.md index 47df79890..3d4652f23 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,9 @@ Compiler Features: Bugfixes: +Build System: + * Switch to building soljson.js with an embedded base64-encoded wasm binary. + ### 0.6.1 (2020-01-02) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index afd145118..18b4e9fe5 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -110,9 +110,13 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s STRICT=1") # Export the Emscripten-generated auxiliary methods which are needed by solc-js. # Which methods of libsolc itself are exported is specified in libsolc/CMakeLists.txt. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap','addFunction','removeFunction','UTF8ToString','lengthBytesUTF8','_malloc','stringToUTF8','setValue']") - # Do not build as a WebAssembly target - we need an asm.js output. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS=['cwrap','addFunction','removeFunction','UTF8ToString','lengthBytesUTF8','stringToUTF8','setValue']") + # Build for webassembly target. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1") + # Set webassembly build to synchronous loading. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM_ASYNC_COMPILATION=0") + # Output a single js file with the wasm binary embedded as base64 string. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s SINGLE_FILE=1") # Disable warnings about not being pure asm.js due to memory growth. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-almost-asm") diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index 8011205db..7d3253515 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -54,14 +54,6 @@ fi WORKSPACE=/root/project -# Increase nodejs stack size -if ! [ -e /emsdk_portable/node/current/bin/node_orig ] -then - mv /emsdk_portable/node/current/bin/node /emsdk_portable/node/current/bin/node_orig - echo -e '#!/bin/sh\nexec /emsdk_portable/node/current/bin/node_orig --stack-size=8192 $@' > /emsdk_portable/node/current/bin/node - chmod 755 /emsdk_portable/node/current/bin/node -fi - # Boost echo -en 'travis_fold:start:compiling_boost\\r' test -e "$WORKSPACE"/boost_1_70_0_install/include/boost/version.hpp || ( From abb9f1eed77730da453f978970a31703e5bbe704 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 13 Jan 2020 15:52:46 +0100 Subject: [PATCH 56/57] CMake: Renaming devcore static library to solutil (to match source code paths) --- libevmasm/CMakeLists.txt | 2 +- liblangutil/CMakeLists.txt | 2 +- liblll/CMakeLists.txt | 2 +- libsolidity/CMakeLists.txt | 2 +- libsolutil/CMakeLists.txt | 10 +++++----- libyul/CMakeLists.txt | 2 +- test/CMakeLists.txt | 2 +- test/tools/yulInterpreter/CMakeLists.txt | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libevmasm/CMakeLists.txt b/libevmasm/CMakeLists.txt index 426799385..9ef622f09 100644 --- a/libevmasm/CMakeLists.txt +++ b/libevmasm/CMakeLists.txt @@ -36,4 +36,4 @@ set(sources ) add_library(evmasm ${sources}) -target_link_libraries(evmasm PUBLIC devcore) +target_link_libraries(evmasm PUBLIC solutil) diff --git a/liblangutil/CMakeLists.txt b/liblangutil/CMakeLists.txt index 63c9de39d..df86476c2 100644 --- a/liblangutil/CMakeLists.txt +++ b/liblangutil/CMakeLists.txt @@ -28,4 +28,4 @@ set(sources ) add_library(langutil ${sources}) -target_link_libraries(langutil PUBLIC devcore) +target_link_libraries(langutil PUBLIC solutil) diff --git a/liblll/CMakeLists.txt b/liblll/CMakeLists.txt index c529461b1..a6c8f3a9a 100644 --- a/liblll/CMakeLists.txt +++ b/liblll/CMakeLists.txt @@ -11,4 +11,4 @@ set(sources ) add_library(lll ${sources}) -target_link_libraries(lll PUBLIC evmasm devcore) +target_link_libraries(lll PUBLIC evmasm solutil) diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index 87eb0e9b7..0a6ba4e58 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -151,7 +151,7 @@ if (NOT (${Z3_FOUND} OR ${CVC4_FOUND})) endif() add_library(solidity ${sources} ${z3_SRCS} ${cvc4_SRCS}) -target_link_libraries(solidity PUBLIC yul evmasm langutil devcore Boost::boost Boost::filesystem Boost::system) +target_link_libraries(solidity PUBLIC yul evmasm langutil solutil Boost::boost Boost::filesystem Boost::system) if (${Z3_FOUND}) target_link_libraries(solidity PUBLIC z3::libz3) diff --git a/libsolutil/CMakeLists.txt b/libsolutil/CMakeLists.txt index 7b4342f12..2c6b6b26f 100644 --- a/libsolutil/CMakeLists.txt +++ b/libsolutil/CMakeLists.txt @@ -33,11 +33,11 @@ set(sources Whiskers.h ) -add_library(devcore ${sources}) -target_link_libraries(devcore PUBLIC jsoncpp Boost::boost Boost::filesystem Boost::system) -target_include_directories(devcore PUBLIC "${CMAKE_SOURCE_DIR}") -add_dependencies(devcore solidity_BuildInfo.h) +add_library(solutil ${sources}) +target_link_libraries(solutil PUBLIC jsoncpp Boost::boost Boost::filesystem Boost::system) +target_include_directories(solutil PUBLIC "${CMAKE_SOURCE_DIR}") +add_dependencies(solutil solidity_BuildInfo.h) if(SOLC_LINK_STATIC) - target_link_libraries(devcore PUBLIC Threads::Threads) + target_link_libraries(solutil PUBLIC Threads::Threads) endif() diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 23aca8bb2..ac766d918 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -158,4 +158,4 @@ add_library(yul optimiser/VarNameCleaner.cpp optimiser/VarNameCleaner.h ) -target_link_libraries(yul PUBLIC evmasm devcore langutil) +target_link_libraries(yul PUBLIC evmasm solutil langutil) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 223cf4e5f..4ce4439e8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -159,7 +159,7 @@ add_executable(soltest ${sources} ${libsolidity_sources} ${libsolidity_util_sources} ) -target_link_libraries(soltest PRIVATE libsolc yul solidity yulInterpreter evmasm devcore Boost::boost Boost::program_options Boost::unit_test_framework evmc) +target_link_libraries(soltest PRIVATE libsolc yul solidity yulInterpreter evmasm solutil Boost::boost Boost::program_options Boost::unit_test_framework evmc) # Special compilation flag for Visual Studio (version 2019 at least affected) diff --git a/test/tools/yulInterpreter/CMakeLists.txt b/test/tools/yulInterpreter/CMakeLists.txt index 95f4c3f3d..d3ddac13d 100644 --- a/test/tools/yulInterpreter/CMakeLists.txt +++ b/test/tools/yulInterpreter/CMakeLists.txt @@ -8,4 +8,4 @@ set(sources ) add_library(yulInterpreter ${sources}) -target_link_libraries(yulInterpreter PUBLIC yul solidity devcore) +target_link_libraries(yulInterpreter PUBLIC yul solidity solutil) From b6ddb32497321b55ed36ff0cc4e29e2a3cbed8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20S=C3=A1?= Date: Mon, 13 Jan 2020 19:41:36 +0000 Subject: [PATCH 57/57] Update grammar to include special functions (constructor, fallback, receive ether) --- docs/grammar.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/grammar.txt b/docs/grammar.txt index 9f4bf55db..06b306499 100644 --- a/docs/grammar.txt +++ b/docs/grammar.txt @@ -24,10 +24,12 @@ StructDefinition = 'struct' Identifier '{' ModifierDefinition = 'modifier' Identifier ParameterList? ( 'virtual' | OverrideSpecifier )* Block ModifierInvocation = Identifier ( '(' ExpressionList? ')' )? -FunctionDefinition = 'function' Identifier? ParameterList +FunctionDefinition = FunctionDescriptor ParameterList ( ModifierInvocation | StateMutability | 'external' | 'public' | 'internal' | 'private' | 'virtual' | OverrideSpecifier )* ( 'returns' ParameterList )? ( ';' | Block ) +FunctionDescriptor = 'function' Identifier | 'constructor' | 'fallback' | 'receive' + OverrideSpecifier = 'override' ( '(' UserDefinedTypeName (',' UserDefinedTypeName)* ')' )? EventDefinition = 'event' Identifier EventParameterList 'anonymous'? ';'