aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp6
-rw-r--r--libsolidity/analysis/TypeChecker.cpp8
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp30
-rw-r--r--libsolidity/ast/AST.h18
-rw-r--r--libsolidity/ast/ASTAnnotations.h16
-rw-r--r--libsolidity/ast/ASTJsonConverter.cpp4
-rw-r--r--libsolidity/ast/ASTJsonConverter.h2
-rw-r--r--libsolidity/codegen/CompilerContext.cpp16
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp6
-rw-r--r--libsolidity/interface/AssemblyStack.cpp24
-rw-r--r--libsolidity/interface/AssemblyStack.h17
-rw-r--r--libsolidity/parsing/Parser.cpp4
-rw-r--r--libyul/ASTDataForward.h30
-rw-r--r--libyul/AsmAnalysis.cpp31
-rw-r--r--libyul/AsmAnalysis.h54
-rw-r--r--libyul/AsmAnalysisInfo.h12
-rw-r--r--libyul/AsmCodeGen.cpp10
-rw-r--r--libyul/AsmCodeGen.h10
-rw-r--r--libyul/AsmData.h14
-rw-r--r--libyul/AsmDataForward.h8
-rw-r--r--libyul/AsmParser.cpp68
-rw-r--r--libyul/AsmParser.h14
-rw-r--r--libyul/AsmPrinter.cpp24
-rw-r--r--libyul/AsmPrinter.h40
-rw-r--r--libyul/AsmScope.cpp12
-rw-r--r--libyul/AsmScope.h28
-rw-r--r--libyul/AsmScopeFiller.cpp6
-rw-r--r--libyul/AsmScopeFiller.h40
-rw-r--r--libyul/Exceptions.h7
-rw-r--r--libyul/YulString.h3
-rw-r--r--libyul/backends/evm/AbstractAssembly.h19
-rw-r--r--libyul/backends/evm/EVMAssembly.cpp2
-rw-r--r--libyul/backends/evm/EVMAssembly.h13
-rw-r--r--libyul/backends/evm/EVMCodeTransform.cpp18
-rw-r--r--libyul/backends/evm/EVMCodeTransform.h32
-rw-r--r--libyul/optimiser/ASTCopier.cpp2
-rw-r--r--libyul/optimiser/ASTCopier.h3
-rw-r--r--libyul/optimiser/ASTWalker.cpp2
-rw-r--r--libyul/optimiser/ASTWalker.h3
-rw-r--r--libyul/optimiser/BlockFlattener.cpp2
-rw-r--r--libyul/optimiser/BlockFlattener.h3
-rw-r--r--libyul/optimiser/CommonSubexpressionEliminator.cpp2
-rw-r--r--libyul/optimiser/CommonSubexpressionEliminator.h3
-rw-r--r--libyul/optimiser/DataFlowAnalyzer.cpp2
-rw-r--r--libyul/optimiser/DataFlowAnalyzer.h3
-rw-r--r--libyul/optimiser/Disambiguator.cpp4
-rw-r--r--libyul/optimiser/Disambiguator.h13
-rw-r--r--libyul/optimiser/ExpressionInliner.cpp2
-rw-r--r--libyul/optimiser/ExpressionInliner.h3
-rw-r--r--libyul/optimiser/ExpressionJoiner.cpp2
-rw-r--r--libyul/optimiser/ExpressionJoiner.h3
-rw-r--r--libyul/optimiser/ExpressionSimplifier.cpp2
-rw-r--r--libyul/optimiser/ExpressionSimplifier.h3
-rw-r--r--libyul/optimiser/ExpressionSplitter.cpp2
-rw-r--r--libyul/optimiser/ExpressionSplitter.h3
-rw-r--r--libyul/optimiser/ForLoopInitRewriter.cpp2
-rw-r--r--libyul/optimiser/ForLoopInitRewriter.h3
-rw-r--r--libyul/optimiser/FullInliner.cpp2
-rw-r--r--libyul/optimiser/FullInliner.h3
-rw-r--r--libyul/optimiser/FunctionGrouper.cpp2
-rw-r--r--libyul/optimiser/FunctionGrouper.h3
-rw-r--r--libyul/optimiser/FunctionHoister.cpp2
-rw-r--r--libyul/optimiser/FunctionHoister.h3
-rw-r--r--libyul/optimiser/InlinableExpressionFunctionFinder.cpp2
-rw-r--r--libyul/optimiser/InlinableExpressionFunctionFinder.h3
-rw-r--r--libyul/optimiser/MainFunction.cpp2
-rw-r--r--libyul/optimiser/MainFunction.h3
-rw-r--r--libyul/optimiser/Metrics.cpp2
-rw-r--r--libyul/optimiser/Metrics.h3
-rw-r--r--libyul/optimiser/NameCollector.cpp2
-rw-r--r--libyul/optimiser/NameCollector.h3
-rw-r--r--libyul/optimiser/NameDispenser.cpp2
-rw-r--r--libyul/optimiser/NameDispenser.h3
-rw-r--r--libyul/optimiser/RedundantAssignEliminator.cpp2
-rw-r--r--libyul/optimiser/RedundantAssignEliminator.h3
-rw-r--r--libyul/optimiser/Rematerialiser.cpp2
-rw-r--r--libyul/optimiser/Rematerialiser.h3
-rw-r--r--libyul/optimiser/SSATransform.cpp2
-rw-r--r--libyul/optimiser/SSATransform.h3
-rw-r--r--libyul/optimiser/SSAValueTracker.cpp2
-rw-r--r--libyul/optimiser/SSAValueTracker.h3
-rw-r--r--libyul/optimiser/Semantics.cpp2
-rw-r--r--libyul/optimiser/Semantics.h3
-rw-r--r--libyul/optimiser/SimplificationRules.cpp8
-rw-r--r--libyul/optimiser/SimplificationRules.h17
-rw-r--r--libyul/optimiser/Substitution.cpp2
-rw-r--r--libyul/optimiser/Substitution.h3
-rw-r--r--libyul/optimiser/Suite.cpp4
-rw-r--r--libyul/optimiser/Suite.h14
-rw-r--r--libyul/optimiser/SyntacticalEquality.cpp2
-rw-r--r--libyul/optimiser/SyntacticalEquality.h3
-rw-r--r--libyul/optimiser/UnusedPruner.cpp2
-rw-r--r--libyul/optimiser/UnusedPruner.h3
-rw-r--r--libyul/optimiser/Utilities.cpp4
-rw-r--r--libyul/optimiser/Utilities.h3
-rw-r--r--libyul/optimiser/VarDeclPropagator.cpp5
-rw-r--r--libyul/optimiser/VarDeclPropagator.h3
-rw-r--r--test/boostTest.cpp2
-rw-r--r--test/libyul/Common.cpp20
-rw-r--r--test/libyul/Common.h13
-rw-r--r--test/libyul/Inliner.cpp4
-rw-r--r--test/libyul/Parser.cpp16
-rw-r--r--test/libyul/YulOptimizerTest.cpp16
-rw-r--r--test/libyul/YulOptimizerTest.h15
-rw-r--r--test/tools/yulopti.cpp11
105 files changed, 366 insertions, 582 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index 1593c3e0..c4931d98 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -273,7 +273,7 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
ErrorList errors;
ErrorReporter errorsIgnored(errors);
yul::ExternalIdentifierAccess::Resolver resolver =
- [&](assembly::Identifier const& _identifier, yul::IdentifierContext, bool _crossesFunctionBoundary) {
+ [&](yul::Identifier const& _identifier, yul::IdentifierContext, bool _crossesFunctionBoundary) {
auto declarations = m_resolver.nameFromCurrentScope(_identifier.name.str());
bool isSlot = boost::algorithm::ends_with(_identifier.name.str(), "_slot");
bool isOffset = boost::algorithm::ends_with(_identifier.name.str(), "_offset");
@@ -314,9 +314,9 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
// Will be re-generated later with correct information
// We use the latest EVM version because we will re-run it anyway.
- assembly::AsmAnalysisInfo analysisInfo;
+ yul::AsmAnalysisInfo analysisInfo;
boost::optional<Error::Type> errorTypeForLoose = Error::Type::SyntaxError;
- assembly::AsmAnalyzer(analysisInfo, errorsIgnored, EVMVersion(), errorTypeForLoose, assembly::AsmFlavour::Loose, resolver).analyze(_inlineAssembly.operations());
+ yul::AsmAnalyzer(analysisInfo, errorsIgnored, EVMVersion(), errorTypeForLoose, yul::AsmFlavour::Loose, resolver).analyze(_inlineAssembly.operations());
return false;
}
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 3cf4d79f..4e63875b 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -954,7 +954,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
// External references have already been resolved in a prior stage and stored in the annotation.
// We run the resolve step again regardless.
yul::ExternalIdentifierAccess::Resolver identifierAccess = [&](
- assembly::Identifier const& _identifier,
+ yul::Identifier const& _identifier,
yul::IdentifierContext _context,
bool
)
@@ -1039,13 +1039,13 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
return size_t(1);
};
solAssert(!_inlineAssembly.annotation().analysisInfo, "");
- _inlineAssembly.annotation().analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
- assembly::AsmAnalyzer analyzer(
+ _inlineAssembly.annotation().analysisInfo = make_shared<yul::AsmAnalysisInfo>();
+ yul::AsmAnalyzer analyzer(
*_inlineAssembly.annotation().analysisInfo,
m_errorReporter,
m_evmVersion,
Error::Type::SyntaxError,
- assembly::AsmFlavour::Loose,
+ yul::AsmFlavour::Loose,
identifierAccess
);
if (!analyzer.analyze(_inlineAssembly.operations()))
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index 7839ecd3..1112d682 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -40,48 +40,48 @@ public:
explicit AssemblyViewPureChecker(std::function<void(StateMutability, SourceLocation const&)> _reportMutability):
m_reportMutability(_reportMutability) {}
- void operator()(assembly::Label const&) { }
- void operator()(assembly::Instruction const& _instruction)
+ void operator()(yul::Label const&) { }
+ void operator()(yul::Instruction const& _instruction)
{
checkInstruction(_instruction.location, _instruction.instruction);
}
- void operator()(assembly::Literal const&) {}
- void operator()(assembly::Identifier const&) {}
- void operator()(assembly::FunctionalInstruction const& _instr)
+ void operator()(yul::Literal const&) {}
+ void operator()(yul::Identifier const&) {}
+ void operator()(yul::FunctionalInstruction const& _instr)
{
checkInstruction(_instr.location, _instr.instruction);
for (auto const& arg: _instr.arguments)
boost::apply_visitor(*this, arg);
}
- void operator()(assembly::ExpressionStatement const& _expr)
+ void operator()(yul::ExpressionStatement const& _expr)
{
boost::apply_visitor(*this, _expr.expression);
}
- void operator()(assembly::StackAssignment const&) {}
- void operator()(assembly::Assignment const& _assignment)
+ void operator()(yul::StackAssignment const&) {}
+ void operator()(yul::Assignment const& _assignment)
{
boost::apply_visitor(*this, *_assignment.value);
}
- void operator()(assembly::VariableDeclaration const& _varDecl)
+ void operator()(yul::VariableDeclaration const& _varDecl)
{
if (_varDecl.value)
boost::apply_visitor(*this, *_varDecl.value);
}
- void operator()(assembly::FunctionDefinition const& _funDef)
+ void operator()(yul::FunctionDefinition const& _funDef)
{
(*this)(_funDef.body);
}
- void operator()(assembly::FunctionCall const& _funCall)
+ void operator()(yul::FunctionCall const& _funCall)
{
for (auto const& arg: _funCall.arguments)
boost::apply_visitor(*this, arg);
}
- void operator()(assembly::If const& _if)
+ void operator()(yul::If const& _if)
{
boost::apply_visitor(*this, *_if.condition);
(*this)(_if.body);
}
- void operator()(assembly::Switch const& _switch)
+ void operator()(yul::Switch const& _switch)
{
boost::apply_visitor(*this, *_switch.expression);
for (auto const& _case: _switch.cases)
@@ -91,14 +91,14 @@ public:
(*this)(_case.body);
}
}
- void operator()(assembly::ForLoop const& _for)
+ void operator()(yul::ForLoop const& _for)
{
(*this)(_for.pre);
boost::apply_visitor(*this, *_for.condition);
(*this)(_for.body);
(*this)(_for.post);
}
- void operator()(assembly::Block const& _block)
+ void operator()(yul::Block const& _block)
{
for (auto const& s: _block.statements)
boost::apply_visitor(*this, s);
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index d23562ad..2f418b09 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -41,6 +41,12 @@
#include <vector>
#include <memory>
+namespace yul
+{
+// Forward-declaration to <yul/AsmData.h>
+struct Block;
+}
+
namespace dev
{
namespace solidity
@@ -1028,12 +1034,6 @@ public:
StatementAnnotation& annotation() const override;
};
-namespace assembly
-{
-// Forward-declaration to AsmData.h
-struct Block;
-}
-
/**
* Inline assembly.
*/
@@ -1043,18 +1043,18 @@ public:
InlineAssembly(
SourceLocation const& _location,
ASTPointer<ASTString> const& _docString,
- std::shared_ptr<assembly::Block> const& _operations
+ std::shared_ptr<yul::Block> const& _operations
):
Statement(_location, _docString), m_operations(_operations) {}
void accept(ASTVisitor& _visitor) override;
void accept(ASTConstVisitor& _visitor) const override;
- assembly::Block const& operations() const { return *m_operations; }
+ yul::Block const& operations() const { return *m_operations; }
InlineAssemblyAnnotation& annotation() const override;
private:
- std::shared_ptr<assembly::Block> m_operations;
+ std::shared_ptr<yul::Block> m_operations;
};
/**
diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h
index e0b3f492..e9cc905e 100644
--- a/libsolidity/ast/ASTAnnotations.h
+++ b/libsolidity/ast/ASTAnnotations.h
@@ -30,6 +30,12 @@
#include <vector>
#include <set>
+namespace yul
+{
+ struct AsmAnalysisInfo;
+ struct Identifier;
+}
+
namespace dev
{
namespace solidity
@@ -120,12 +126,6 @@ struct StatementAnnotation: ASTAnnotation, DocumentedAnnotation
{
};
-namespace assembly
-{
- struct AsmAnalysisInfo;
- struct Identifier;
-}
-
struct InlineAssemblyAnnotation: StatementAnnotation
{
struct ExternalIdentifierInfo
@@ -137,9 +137,9 @@ struct InlineAssemblyAnnotation: StatementAnnotation
};
/// Mapping containing resolved references to external identifiers and their value size
- std::map<assembly::Identifier const*, ExternalIdentifierInfo> externalReferences;
+ std::map<yul::Identifier const*, ExternalIdentifierInfo> externalReferences;
/// Information generated during analysis phase.
- std::shared_ptr<assembly::AsmAnalysisInfo> analysisInfo;
+ std::shared_ptr<yul::AsmAnalysisInfo> analysisInfo;
};
struct ReturnAnnotation: StatementAnnotation
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp
index bd6deb6e..b9054692 100644
--- a/libsolidity/ast/ASTJsonConverter.cpp
+++ b/libsolidity/ast/ASTJsonConverter.cpp
@@ -172,7 +172,7 @@ void ASTJsonConverter::appendExpressionAttributes(
_attributes += exprAttributes;
}
-Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<assembly::Identifier const* ,InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const
+Json::Value ASTJsonConverter::inlineAssemblyIdentifierToJson(pair<yul::Identifier const* ,InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const
{
Json::Value tuple(Json::objectValue);
tuple["src"] = sourceLocationToString(_info.first->location);
@@ -465,7 +465,7 @@ bool ASTJsonConverter::visit(InlineAssembly const& _node)
}
}
setJsonNode(_node, "InlineAssembly", {
- make_pair("operations", Json::Value(assembly::AsmPrinter()(_node.operations()))),
+ make_pair("operations", Json::Value(yul::AsmPrinter()(_node.operations()))),
make_pair("externalReferences", std::move(externalReferences))
});
return false;
diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h
index dec3ac96..ef0a217a 100644
--- a/libsolidity/ast/ASTJsonConverter.h
+++ b/libsolidity/ast/ASTJsonConverter.h
@@ -135,7 +135,7 @@ private:
{
return _node ? toJson(*_node) : Json::nullValue;
}
- Json::Value inlineAssemblyIdentifierToJson(std::pair<assembly::Identifier const* , InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const;
+ Json::Value inlineAssemblyIdentifierToJson(std::pair<yul::Identifier const* , InlineAssemblyAnnotation::ExternalIdentifierInfo> _info) const;
static std::string location(VariableDeclaration::Location _location);
static std::string contractKind(ContractDefinition::ContractKind _kind);
static std::string functionCallKind(FunctionCallKind _kind);
diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp
index 32be521c..d1bf29fc 100644
--- a/libsolidity/codegen/CompilerContext.cpp
+++ b/libsolidity/codegen/CompilerContext.cpp
@@ -323,7 +323,7 @@ void CompilerContext::appendInlineAssembly(
yul::ExternalIdentifierAccess identifierAccess;
identifierAccess.resolve = [&](
- assembly::Identifier const& _identifier,
+ yul::Identifier const& _identifier,
yul::IdentifierContext,
bool
)
@@ -332,7 +332,7 @@ void CompilerContext::appendInlineAssembly(
return it == _localVariables.end() ? size_t(-1) : 1;
};
identifierAccess.generateCode = [&](
- assembly::Identifier const& _identifier,
+ yul::Identifier const& _identifier,
yul::IdentifierContext _context,
yul::AbstractAssembly& _assembly
)
@@ -361,19 +361,19 @@ void CompilerContext::appendInlineAssembly(
ErrorList errors;
ErrorReporter errorReporter(errors);
auto scanner = make_shared<langutil::Scanner>(langutil::CharStream(_assembly), "--CODEGEN--");
- auto parserResult = assembly::Parser(errorReporter, assembly::AsmFlavour::Strict).parse(scanner, false);
+ auto parserResult = yul::Parser(errorReporter, yul::AsmFlavour::Strict).parse(scanner, false);
#ifdef SOL_OUTPUT_ASM
- cout << assembly::AsmPrinter()(*parserResult) << endl;
+ cout << yul::AsmPrinter()(*parserResult) << endl;
#endif
- assembly::AsmAnalysisInfo analysisInfo;
+ yul::AsmAnalysisInfo analysisInfo;
bool analyzerResult = false;
if (parserResult)
- analyzerResult = assembly::AsmAnalyzer(
+ analyzerResult = yul::AsmAnalyzer(
analysisInfo,
errorReporter,
m_evmVersion,
boost::none,
- assembly::AsmFlavour::Strict,
+ yul::AsmFlavour::Strict,
identifierAccess.resolve
).analyze(*parserResult);
if (!parserResult || !errorReporter.errors().empty() || !analyzerResult)
@@ -395,7 +395,7 @@ void CompilerContext::appendInlineAssembly(
}
solAssert(errorReporter.errors().empty(), "Failed to analyze inline assembly block.");
- assembly::CodeGenerator::assemble(*parserResult, analysisInfo, *m_asm, identifierAccess, _system);
+ yul::CodeGenerator::assemble(*parserResult, analysisInfo, *m_asm, identifierAccess, _system);
// Reset the source location to the one of the node (instead of the CODEGEN source location)
updateSourceLocation();
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 815c2a4f..157d5fa7 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -496,14 +496,14 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
{
unsigned startStackHeight = m_context.stackHeight();
yul::ExternalIdentifierAccess identifierAccess;
- identifierAccess.resolve = [&](assembly::Identifier const& _identifier, yul::IdentifierContext, bool)
+ identifierAccess.resolve = [&](yul::Identifier const& _identifier, yul::IdentifierContext, bool)
{
auto ref = _inlineAssembly.annotation().externalReferences.find(&_identifier);
if (ref == _inlineAssembly.annotation().externalReferences.end())
return size_t(-1);
return ref->second.valueSize;
};
- identifierAccess.generateCode = [&](assembly::Identifier const& _identifier, yul::IdentifierContext _context, yul::AbstractAssembly& _assembly)
+ identifierAccess.generateCode = [&](yul::Identifier const& _identifier, yul::IdentifierContext _context, yul::AbstractAssembly& _assembly)
{
auto ref = _inlineAssembly.annotation().externalReferences.find(&_identifier);
solAssert(ref != _inlineAssembly.annotation().externalReferences.end(), "");
@@ -615,7 +615,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
}
};
solAssert(_inlineAssembly.annotation().analysisInfo, "");
- assembly::CodeGenerator::assemble(
+ yul::CodeGenerator::assemble(
_inlineAssembly.operations(),
*_inlineAssembly.annotation().analysisInfo,
m_context.nonConstAssembly(),
diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp
index cd8b125e..31959d93 100644
--- a/libsolidity/interface/AssemblyStack.cpp
+++ b/libsolidity/interface/AssemblyStack.cpp
@@ -40,19 +40,19 @@ using namespace dev::solidity;
namespace
{
-assembly::AsmFlavour languageToAsmFlavour(AssemblyStack::Language _language)
+yul::AsmFlavour languageToAsmFlavour(AssemblyStack::Language _language)
{
switch (_language)
{
case AssemblyStack::Language::Assembly:
- return assembly::AsmFlavour::Loose;
+ return yul::AsmFlavour::Loose;
case AssemblyStack::Language::StrictAssembly:
- return assembly::AsmFlavour::Strict;
+ return yul::AsmFlavour::Strict;
case AssemblyStack::Language::Yul:
- return assembly::AsmFlavour::Yul;
+ return yul::AsmFlavour::Yul;
}
solAssert(false, "");
- return assembly::AsmFlavour::Yul;
+ return yul::AsmFlavour::Yul;
}
}
@@ -69,7 +69,7 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string
m_errors.clear();
m_analysisSuccessful = false;
m_scanner = make_shared<Scanner>(CharStream(_source), _sourceName);
- m_parserResult = assembly::Parser(m_errorReporter, languageToAsmFlavour(m_language)).parse(m_scanner, false);
+ m_parserResult = yul::Parser(m_errorReporter, languageToAsmFlavour(m_language)).parse(m_scanner, false);
if (!m_errorReporter.errors().empty())
return false;
solAssert(m_parserResult, "");
@@ -77,21 +77,21 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string
return analyzeParsed();
}
-bool AssemblyStack::analyze(assembly::Block const& _block, Scanner const* _scanner)
+bool AssemblyStack::analyze(yul::Block const& _block, Scanner const* _scanner)
{
m_errors.clear();
m_analysisSuccessful = false;
if (_scanner)
m_scanner = make_shared<Scanner>(*_scanner);
- m_parserResult = make_shared<assembly::Block>(_block);
+ m_parserResult = make_shared<yul::Block>(_block);
return analyzeParsed();
}
bool AssemblyStack::analyzeParsed()
{
- m_analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
- assembly::AsmAnalyzer analyzer(*m_analysisInfo, m_errorReporter, m_evmVersion, boost::none, languageToAsmFlavour(m_language));
+ m_analysisInfo = make_shared<yul::AsmAnalysisInfo>();
+ yul::AsmAnalyzer analyzer(*m_analysisInfo, m_errorReporter, m_evmVersion, boost::none, languageToAsmFlavour(m_language));
m_analysisSuccessful = analyzer.analyze(*m_parserResult);
return m_analysisSuccessful;
}
@@ -108,7 +108,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
{
MachineAssemblyObject object;
eth::Assembly assembly;
- assembly::CodeGenerator::assemble(*m_parserResult, *m_analysisInfo, assembly);
+ yul::CodeGenerator::assemble(*m_parserResult, *m_analysisInfo, assembly);
object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble());
object.assembly = assembly.assemblyString();
return object;
@@ -132,5 +132,5 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const
string AssemblyStack::print() const
{
solAssert(m_parserResult, "");
- return assembly::AsmPrinter(m_language == Language::Yul)(*m_parserResult);
+ return yul::AsmPrinter(m_language == Language::Yul)(*m_parserResult);
}
diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h
index d6ee33cf..03b811db 100644
--- a/libsolidity/interface/AssemblyStack.h
+++ b/libsolidity/interface/AssemblyStack.h
@@ -34,16 +34,17 @@ namespace langutil
class Scanner;
}
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct AsmAnalysisInfo;
struct Block;
}
+namespace dev
+{
+namespace solidity
+{
+
struct MachineAssemblyObject
{
std::shared_ptr<eth::LinkerObject> bytecode;
@@ -73,7 +74,7 @@ public:
/// Runs analysis step on the supplied block, returns false if input cannot be assembled.
/// Multiple calls overwrite the previous state.
- bool analyze(assembly::Block const& _block, langutil::Scanner const* _scanner = nullptr);
+ bool analyze(yul::Block const& _block, langutil::Scanner const* _scanner = nullptr);
/// Run the assembly step (should only be called after parseAndAnalyze).
MachineAssemblyObject assemble(Machine _machine) const;
@@ -93,8 +94,8 @@ private:
std::shared_ptr<langutil::Scanner> m_scanner;
bool m_analysisSuccessful = false;
- std::shared_ptr<assembly::Block> m_parserResult;
- std::shared_ptr<assembly::AsmAnalysisInfo> m_analysisInfo;
+ std::shared_ptr<yul::Block> m_parserResult;
+ std::shared_ptr<yul::AsmAnalysisInfo> m_analysisInfo;
langutil::ErrorList m_errors;
langutil::ErrorReporter m_errorReporter;
};
diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp
index 560d8e8b..ffe2be83 100644
--- a/libsolidity/parsing/Parser.cpp
+++ b/libsolidity/parsing/Parser.cpp
@@ -1012,8 +1012,8 @@ ASTPointer<InlineAssembly> Parser::parseInlineAssembly(ASTPointer<ASTString> con
m_scanner->next();
}
- assembly::Parser asmParser(m_errorReporter);
- shared_ptr<assembly::Block> block = asmParser.parse(m_scanner, true);
+ yul::Parser asmParser(m_errorReporter);
+ shared_ptr<yul::Block> block = asmParser.parse(m_scanner, true);
nodeFactory.markEndPosition();
return nodeFactory.createNode<InlineAssembly>(_docString, block);
}
diff --git a/libyul/ASTDataForward.h b/libyul/ASTDataForward.h
index 16dc7411..dffe1c74 100644
--- a/libyul/ASTDataForward.h
+++ b/libyul/ASTDataForward.h
@@ -23,33 +23,3 @@
#include <libyul/AsmDataForward.h>
-namespace dev
-{
-namespace yul
-{
-
-using Instruction = solidity::assembly::Instruction;
-using Literal = solidity::assembly::Literal;
-using Label = solidity::assembly::Label;
-using StackAssignment = solidity::assembly::StackAssignment;
-using Identifier = solidity::assembly::Identifier;
-using Assignment = solidity::assembly::Assignment;
-using VariableDeclaration = solidity::assembly::VariableDeclaration;
-using FunctionalInstruction = solidity::assembly::FunctionalInstruction;
-using FunctionDefinition = solidity::assembly::FunctionDefinition;
-using FunctionCall = solidity::assembly::FunctionCall;
-using If = solidity::assembly::If;
-using Case = solidity::assembly::Case;
-using Switch = solidity::assembly::Switch;
-using ForLoop = solidity::assembly::ForLoop;
-using ExpressionStatement = solidity::assembly::ExpressionStatement;
-using Block = solidity::assembly::Block;
-
-using TypedName = solidity::assembly::TypedName;
-class YulString;
-
-using Expression = boost::variant<FunctionalInstruction, FunctionCall, Identifier, Literal>;
-using Statement = boost::variant<ExpressionStatement, Instruction, Label, StackAssignment, Assignment, VariableDeclaration, FunctionDefinition, If, Switch, ForLoop, Block>;
-
-}
-}
diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp
index 34c5fbb6..d3f6de84 100644
--- a/libyul/AsmAnalysis.cpp
+++ b/libyul/AsmAnalysis.cpp
@@ -36,8 +36,9 @@
using namespace std;
using namespace dev;
using namespace langutil;
+using namespace yul;
+using namespace dev;
using namespace dev::solidity;
-using namespace dev::solidity::assembly;
namespace {
@@ -65,7 +66,7 @@ bool AsmAnalyzer::operator()(Label const& _label)
return true;
}
-bool AsmAnalyzer::operator()(assembly::Instruction const& _instruction)
+bool AsmAnalyzer::operator()(yul::Instruction const& _instruction)
{
checkLooseFeature(
_instruction.location,
@@ -78,11 +79,11 @@ bool AsmAnalyzer::operator()(assembly::Instruction const& _instruction)
return true;
}
-bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
+bool AsmAnalyzer::operator()(Literal const& _literal)
{
expectValidType(_literal.type.str(), _literal.location);
++m_stackHeight;
- if (_literal.kind == assembly::LiteralKind::String && _literal.value.str().size() > 32)
+ if (_literal.kind == LiteralKind::String && _literal.value.str().size() > 32)
{
m_errorReporter.typeError(
_literal.location,
@@ -90,7 +91,7 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
);
return false;
}
- else if (_literal.kind == assembly::LiteralKind::Number && bigint(_literal.value.str()) > u256(-1))
+ else if (_literal.kind == LiteralKind::Number && bigint(_literal.value.str()) > u256(-1))
{
m_errorReporter.typeError(
_literal.location,
@@ -98,7 +99,7 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
);
return false;
}
- else if (_literal.kind == assembly::LiteralKind::Boolean)
+ else if (_literal.kind == LiteralKind::Boolean)
{
solAssert(m_flavour == AsmFlavour::Yul, "");
solAssert(_literal.value == YulString{string("true")} || _literal.value == YulString{string("false")}, "");
@@ -107,7 +108,7 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
return true;
}
-bool AsmAnalyzer::operator()(assembly::Identifier const& _identifier)
+bool AsmAnalyzer::operator()(Identifier const& _identifier)
{
solAssert(!_identifier.name.empty(), "");
size_t numErrorsBefore = m_errorReporter.errors().size();
@@ -177,7 +178,7 @@ bool AsmAnalyzer::operator()(FunctionalInstruction const& _instr)
return success;
}
-bool AsmAnalyzer::operator()(assembly::ExpressionStatement const& _statement)
+bool AsmAnalyzer::operator()(ExpressionStatement const& _statement)
{
int initialStackHeight = m_stackHeight;
bool success = boost::apply_visitor(*this, _statement.expression);
@@ -198,7 +199,7 @@ bool AsmAnalyzer::operator()(assembly::ExpressionStatement const& _statement)
return success;
}
-bool AsmAnalyzer::operator()(assembly::StackAssignment const& _assignment)
+bool AsmAnalyzer::operator()(StackAssignment const& _assignment)
{
checkLooseFeature(
_assignment.location,
@@ -209,7 +210,7 @@ bool AsmAnalyzer::operator()(assembly::StackAssignment const& _assignment)
return success;
}
-bool AsmAnalyzer::operator()(assembly::Assignment const& _assignment)
+bool AsmAnalyzer::operator()(Assignment const& _assignment)
{
solAssert(_assignment.value, "");
int const expectedItems = _assignment.variableNames.size();
@@ -235,7 +236,7 @@ bool AsmAnalyzer::operator()(assembly::Assignment const& _assignment)
return success;
}
-bool AsmAnalyzer::operator()(assembly::VariableDeclaration const& _varDecl)
+bool AsmAnalyzer::operator()(VariableDeclaration const& _varDecl)
{
bool success = true;
int const numVariables = _varDecl.variables.size();
@@ -261,7 +262,7 @@ bool AsmAnalyzer::operator()(assembly::VariableDeclaration const& _varDecl)
return success;
}
-bool AsmAnalyzer::operator()(assembly::FunctionDefinition const& _funDef)
+bool AsmAnalyzer::operator()(FunctionDefinition const& _funDef)
{
solAssert(!_funDef.name.empty(), "");
Block const* virtualBlock = m_info.virtualBlocks.at(&_funDef).get();
@@ -283,7 +284,7 @@ bool AsmAnalyzer::operator()(assembly::FunctionDefinition const& _funDef)
return success;
}
-bool AsmAnalyzer::operator()(assembly::FunctionCall const& _funCall)
+bool AsmAnalyzer::operator()(FunctionCall const& _funCall)
{
solAssert(!_funCall.functionName.name.empty(), "");
bool success = true;
@@ -397,7 +398,7 @@ bool AsmAnalyzer::operator()(Switch const& _switch)
return success;
}
-bool AsmAnalyzer::operator()(assembly::ForLoop const& _for)
+bool AsmAnalyzer::operator()(ForLoop const& _for)
{
solAssert(_for.condition, "");
@@ -486,7 +487,7 @@ bool AsmAnalyzer::expectDeposit(int _deposit, int _oldHeight, SourceLocation con
return true;
}
-bool AsmAnalyzer::checkAssignment(assembly::Identifier const& _variable, size_t _valueSize)
+bool AsmAnalyzer::checkAssignment(Identifier const& _variable, size_t _valueSize)
{
solAssert(!_variable.name.empty(), "");
bool success = true;
diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h
index edca5b50..34e32eb0 100644
--- a/libyul/AsmAnalysis.h
+++ b/libyul/AsmAnalysis.h
@@ -41,11 +41,7 @@ class ErrorReporter;
struct SourceLocation;
}
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct AsmAnalysisInfo;
@@ -61,10 +57,10 @@ public:
explicit AsmAnalyzer(
AsmAnalysisInfo& _analysisInfo,
langutil::ErrorReporter& _errorReporter,
- EVMVersion _evmVersion,
+ dev::solidity::EVMVersion _evmVersion,
boost::optional<langutil::Error::Type> _errorTypeForLoose,
AsmFlavour _flavour = AsmFlavour::Loose,
- yul::ExternalIdentifierAccess::Resolver const& _resolver = yul::ExternalIdentifierAccess::Resolver()
+ ExternalIdentifierAccess::Resolver const& _resolver = ExternalIdentifierAccess::Resolver()
):
m_resolver(_resolver),
m_info(_analysisInfo),
@@ -74,23 +70,23 @@ public:
m_errorTypeForLoose(_errorTypeForLoose)
{}
- bool analyze(assembly::Block const& _block);
-
- bool operator()(assembly::Instruction const&);
- bool operator()(assembly::Literal const& _literal);
- bool operator()(assembly::Identifier const&);
- bool operator()(assembly::FunctionalInstruction const& _functionalInstruction);
- bool operator()(assembly::Label const& _label);
- bool operator()(assembly::ExpressionStatement const&);
- bool operator()(assembly::StackAssignment const&);
- bool operator()(assembly::Assignment const& _assignment);
- bool operator()(assembly::VariableDeclaration const& _variableDeclaration);
- bool operator()(assembly::FunctionDefinition const& _functionDefinition);
- bool operator()(assembly::FunctionCall const& _functionCall);
- bool operator()(assembly::If const& _if);
- bool operator()(assembly::Switch const& _switch);
- bool operator()(assembly::ForLoop const& _forLoop);
- bool operator()(assembly::Block const& _block);
+ bool analyze(Block const& _block);
+
+ bool operator()(Instruction const&);
+ bool operator()(Literal const& _literal);
+ bool operator()(Identifier const&);
+ bool operator()(FunctionalInstruction const& _functionalInstruction);
+ bool operator()(Label const& _label);
+ bool operator()(ExpressionStatement const&);
+ bool operator()(StackAssignment const&);
+ bool operator()(Assignment const& _assignment);
+ bool operator()(VariableDeclaration const& _variableDeclaration);
+ bool operator()(FunctionDefinition const& _functionDefinition);
+ bool operator()(FunctionCall const& _functionCall);
+ bool operator()(If const& _if);
+ bool operator()(Switch const& _switch);
+ bool operator()(ForLoop const& _forLoop);
+ bool operator()(Block const& _block);
private:
/// Visits the statement and expects it to deposit one item onto the stack.
@@ -99,11 +95,11 @@ private:
/// Verifies that a variable to be assigned to exists and has the same size
/// as the value, @a _valueSize, unless that is equal to -1.
- bool checkAssignment(assembly::Identifier const& _assignment, size_t _valueSize = size_t(-1));
+ bool checkAssignment(Identifier const& _assignment, size_t _valueSize = size_t(-1));
- Scope& scope(assembly::Block const* _block);
+ Scope& scope(Block const* _block);
void expectValidType(std::string const& type, langutil::SourceLocation const& _location);
- void warnOnInstructions(solidity::Instruction _instr, langutil::SourceLocation const& _location);
+ void warnOnInstructions(dev::solidity::Instruction _instr, langutil::SourceLocation const& _location);
/// Depending on @a m_flavour and @a m_errorTypeForLoose, throws an internal compiler
/// exception (if the flavour is not Loose), reports an error/warning
@@ -118,11 +114,9 @@ private:
std::set<Scope::Variable const*> m_activeVariables;
AsmAnalysisInfo& m_info;
langutil::ErrorReporter& m_errorReporter;
- EVMVersion m_evmVersion;
+ dev::solidity::EVMVersion m_evmVersion;
AsmFlavour m_flavour = AsmFlavour::Loose;
boost::optional<langutil::Error::Type> m_errorTypeForLoose;
};
}
-}
-}
diff --git a/libyul/AsmAnalysisInfo.h b/libyul/AsmAnalysisInfo.h
index 372ff3ed..08a35ade 100644
--- a/libyul/AsmAnalysisInfo.h
+++ b/libyul/AsmAnalysisInfo.h
@@ -28,11 +28,7 @@
#include <memory>
#include <vector>
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct Scope;
@@ -40,13 +36,11 @@ struct Scope;
struct AsmAnalysisInfo
{
using StackHeightInfo = std::map<void const*, int>;
- using Scopes = std::map<assembly::Block const*, std::shared_ptr<Scope>>;
+ using Scopes = std::map<Block const*, std::shared_ptr<Scope>>;
Scopes scopes;
StackHeightInfo stackHeightInfo;
/// Virtual blocks which will be used for scopes for function arguments and return values.
- std::map<FunctionDefinition const*, std::shared_ptr<assembly::Block const>> virtualBlocks;
+ std::map<FunctionDefinition const*, std::shared_ptr<Block const>> virtualBlocks;
};
}
-}
-}
diff --git a/libyul/AsmCodeGen.cpp b/libyul/AsmCodeGen.cpp
index 5bc2fee3..23bf395d 100644
--- a/libyul/AsmCodeGen.cpp
+++ b/libyul/AsmCodeGen.cpp
@@ -48,10 +48,10 @@
using namespace std;
using namespace dev;
using namespace langutil;
+using namespace yul;
using namespace dev::solidity;
-using namespace dev::solidity::assembly;
-class EthAssemblyAdapter: public yul::AbstractAssembly
+class EthAssemblyAdapter: public AbstractAssembly
{
public:
explicit EthAssemblyAdapter(eth::Assembly& _assembly):
@@ -143,16 +143,16 @@ private:
eth::Assembly& m_assembly;
};
-void assembly::CodeGenerator::assemble(
+void CodeGenerator::assemble(
Block const& _parsedData,
AsmAnalysisInfo& _analysisInfo,
eth::Assembly& _assembly,
- yul::ExternalIdentifierAccess const& _identifierAccess,
+ ExternalIdentifierAccess const& _identifierAccess,
bool _useNamedLabelsForFunctions
)
{
EthAssemblyAdapter assemblyAdapter(_assembly);
- yul::CodeTransform(
+ CodeTransform(
assemblyAdapter,
_analysisInfo,
false,
diff --git a/libyul/AsmCodeGen.h b/libyul/AsmCodeGen.h
index e5e53c0d..fd5ac0a1 100644
--- a/libyul/AsmCodeGen.h
+++ b/libyul/AsmCodeGen.h
@@ -32,9 +32,9 @@ namespace eth
{
class Assembly;
}
-namespace solidity
-{
-namespace assembly
+}
+
+namespace yul
{
struct Block;
@@ -45,12 +45,10 @@ public:
static void assemble(
Block const& _parsedData,
AsmAnalysisInfo& _analysisInfo,
- eth::Assembly& _assembly,
+ dev::eth::Assembly& _assembly,
yul::ExternalIdentifierAccess const& _identifierAccess = yul::ExternalIdentifierAccess(),
bool _useNamedLabelsForFunctions = false
);
};
}
-}
-}
diff --git a/libyul/AsmData.h b/libyul/AsmData.h
index 6979d29c..86c373a4 100644
--- a/libyul/AsmData.h
+++ b/libyul/AsmData.h
@@ -23,7 +23,6 @@
#pragma once
#include <libyul/AsmDataForward.h>
-
#include <libyul/YulString.h>
#include <libevmasm/Instruction.h>
@@ -35,21 +34,16 @@
#include <map>
#include <memory>
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
-using YulString = dev::yul::YulString;
using Type = YulString;
struct TypedName { langutil::SourceLocation location; YulString name; Type type; };
using TypedNameList = std::vector<TypedName>;
/// Direct EVM instruction (except PUSHi and JUMPDEST)
-struct Instruction { langutil::SourceLocation location; solidity::Instruction instruction; };
+struct Instruction { langutil::SourceLocation location; dev::solidity::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; };
@@ -67,7 +61,7 @@ struct StackAssignment { langutil::SourceLocation location; Identifier variableN
/// the same amount of items as the number of variables.
struct Assignment { langutil::SourceLocation location; std::vector<Identifier> variableNames; std::shared_ptr<Expression> value; };
/// Functional instruction, e.g. "mul(mload(20:u256), add(2:u256, x))"
-struct FunctionalInstruction { langutil::SourceLocation location; solidity::Instruction instruction; std::vector<Expression> arguments; };
+struct FunctionalInstruction { langutil::SourceLocation location; dev::solidity::Instruction instruction; std::vector<Expression> arguments; };
struct FunctionCall { langutil::SourceLocation location; Identifier functionName; std::vector<Expression> arguments; };
/// Statement that contains only a single expression
struct ExpressionStatement { langutil::SourceLocation location; Expression expression; };
@@ -100,5 +94,3 @@ template <class T> inline langutil::SourceLocation locationOf(T const& _node)
}
}
-}
-}
diff --git a/libyul/AsmDataForward.h b/libyul/AsmDataForward.h
index 69cf8f1d..046c8248 100644
--- a/libyul/AsmDataForward.h
+++ b/libyul/AsmDataForward.h
@@ -24,11 +24,7 @@
#include <boost/variant.hpp>
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct Instruction;
@@ -61,5 +57,3 @@ enum class AsmFlavour
};
}
-}
-}
diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp
index 0d3bc32f..2ce94f85 100644
--- a/libyul/AsmParser.cpp
+++ b/libyul/AsmParser.cpp
@@ -32,10 +32,10 @@
using namespace std;
using namespace dev;
using namespace langutil;
+using namespace yul;
using namespace dev::solidity;
-using namespace dev::solidity::assembly;
-shared_ptr<assembly::Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
+shared_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
{
m_recursionDepth = 0;
try
@@ -54,10 +54,10 @@ shared_ptr<assembly::Block> Parser::parse(std::shared_ptr<Scanner> const& _scann
return nullptr;
}
-assembly::Block Parser::parseBlock()
+Block Parser::parseBlock()
{
RecursionGuard recursionGuard(*this);
- assembly::Block block = createWithLocation<Block>();
+ Block block = createWithLocation<Block>();
expectToken(Token::LBrace);
while (currentToken() != Token::RBrace)
block.statements.emplace_back(parseStatement());
@@ -66,7 +66,7 @@ assembly::Block Parser::parseBlock()
return block;
}
-assembly::Statement Parser::parseStatement()
+Statement Parser::parseStatement()
{
RecursionGuard recursionGuard(*this);
switch (currentToken())
@@ -79,7 +79,7 @@ assembly::Statement Parser::parseStatement()
return parseBlock();
case Token::If:
{
- assembly::If _if = createWithLocation<assembly::If>();
+ If _if = createWithLocation<If>();
m_scanner->next();
_if.condition = make_shared<Expression>(parseExpression());
_if.body = parseBlock();
@@ -87,7 +87,7 @@ assembly::Statement Parser::parseStatement()
}
case Token::Switch:
{
- assembly::Switch _switch = createWithLocation<assembly::Switch>();
+ Switch _switch = createWithLocation<Switch>();
m_scanner->next();
_switch.expression = make_shared<Expression>(parseExpression());
while (m_scanner->currentToken() == Token::Case)
@@ -109,7 +109,7 @@ assembly::Statement Parser::parseStatement()
{
if (m_flavour != AsmFlavour::Loose)
break;
- assembly::StackAssignment assignment = createWithLocation<assembly::StackAssignment>();
+ StackAssignment assignment = createWithLocation<StackAssignment>();
advance();
expectToken(Token::Colon);
assignment.variableName.location = location();
@@ -139,9 +139,9 @@ assembly::Statement Parser::parseStatement()
{
// if a comma follows, a multiple assignment is assumed
- if (elementary.type() != typeid(assembly::Identifier))
+ if (elementary.type() != typeid(Identifier))
fatalParserError("Label name / variable name must precede \",\" (multiple assignment).");
- assembly::Identifier const& identifier = boost::get<assembly::Identifier>(elementary);
+ Identifier const& identifier = boost::get<Identifier>(elementary);
Assignment assignment = createWithLocation<Assignment>(identifier.location);
assignment.variableNames.emplace_back(identifier);
@@ -150,9 +150,9 @@ assembly::Statement Parser::parseStatement()
{
expectToken(Token::Comma);
elementary = parseElementaryOperation();
- if (elementary.type() != typeid(assembly::Identifier))
+ if (elementary.type() != typeid(Identifier))
fatalParserError("Variable name expected in multiple assignment.");
- assignment.variableNames.emplace_back(boost::get<assembly::Identifier>(elementary));
+ assignment.variableNames.emplace_back(boost::get<Identifier>(elementary));
}
while (currentToken() == Token::Comma);
@@ -165,15 +165,15 @@ assembly::Statement Parser::parseStatement()
}
case Token::Colon:
{
- if (elementary.type() != typeid(assembly::Identifier))
+ if (elementary.type() != typeid(Identifier))
fatalParserError("Label name / variable name must precede \":\".");
- assembly::Identifier const& identifier = boost::get<assembly::Identifier>(elementary);
+ Identifier const& identifier = boost::get<Identifier>(elementary);
advance();
// identifier:=: should be parsed as identifier: =: (i.e. a label),
// while identifier:= (being followed by a non-colon) as identifier := (assignment).
if (currentToken() == Token::Assign && peekNextToken() != Token::Colon)
{
- assembly::Assignment assignment = createWithLocation<assembly::Assignment>(identifier.location);
+ Assignment assignment = createWithLocation<Assignment>(identifier.location);
if (m_flavour != AsmFlavour::Yul && instructions().count(identifier.name.str()))
fatalParserError("Cannot use instruction names for identifier names.");
advance();
@@ -197,36 +197,36 @@ assembly::Statement Parser::parseStatement()
fatalParserError("Call or assignment expected.");
break;
}
- if (elementary.type() == typeid(assembly::Identifier))
+ if (elementary.type() == typeid(Identifier))
{
- Expression expr = boost::get<assembly::Identifier>(elementary);
+ Expression expr = boost::get<Identifier>(elementary);
return ExpressionStatement{locationOf(expr), expr};
}
- else if (elementary.type() == typeid(assembly::Literal))
+ else if (elementary.type() == typeid(Literal))
{
- Expression expr = boost::get<assembly::Literal>(elementary);
+ Expression expr = boost::get<Literal>(elementary);
return ExpressionStatement{locationOf(expr), expr};
}
else
{
- solAssert(elementary.type() == typeid(assembly::Instruction), "Invalid elementary operation.");
- return boost::get<assembly::Instruction>(elementary);
+ solAssert(elementary.type() == typeid(Instruction), "Invalid elementary operation.");
+ return boost::get<Instruction>(elementary);
}
}
-assembly::Case Parser::parseCase()
+Case Parser::parseCase()
{
RecursionGuard recursionGuard(*this);
- assembly::Case _case = createWithLocation<assembly::Case>();
+ Case _case = createWithLocation<Case>();
if (m_scanner->currentToken() == Token::Default)
m_scanner->next();
else if (m_scanner->currentToken() == Token::Case)
{
m_scanner->next();
ElementaryOperation literal = parseElementaryOperation();
- if (literal.type() != typeid(assembly::Literal))
+ if (literal.type() != typeid(Literal))
fatalParserError("Literal expected.");
- _case.value = make_shared<Literal>(boost::get<assembly::Literal>(std::move(literal)));
+ _case.value = make_shared<Literal>(boost::get<Literal>(std::move(literal)));
}
else
fatalParserError("Case or default case expected.");
@@ -235,7 +235,7 @@ assembly::Case Parser::parseCase()
return _case;
}
-assembly::ForLoop Parser::parseForLoop()
+ForLoop Parser::parseForLoop()
{
RecursionGuard recursionGuard(*this);
ForLoop forLoop = createWithLocation<ForLoop>();
@@ -248,7 +248,7 @@ assembly::ForLoop Parser::parseForLoop()
return forLoop;
}
-assembly::Expression Parser::parseExpression()
+Expression Parser::parseExpression()
{
RecursionGuard recursionGuard(*this);
// In strict mode, this might parse a plain Instruction, but
@@ -293,12 +293,12 @@ assembly::Expression Parser::parseExpression()
Instruction& instr = boost::get<Instruction>(operation);
return FunctionalInstruction{std::move(instr.location), instr.instruction, {}};
}
- else if (operation.type() == typeid(assembly::Identifier))
- return boost::get<assembly::Identifier>(operation);
+ else if (operation.type() == typeid(Identifier))
+ return boost::get<Identifier>(operation);
else
{
- solAssert(operation.type() == typeid(assembly::Literal), "");
- return boost::get<assembly::Literal>(operation);
+ solAssert(operation.type() == typeid(Literal), "");
+ return boost::get<Literal>(operation);
}
}
@@ -420,7 +420,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation()
return ret;
}
-assembly::VariableDeclaration Parser::parseVariableDeclaration()
+VariableDeclaration Parser::parseVariableDeclaration()
{
RecursionGuard recursionGuard(*this);
VariableDeclaration varDecl = createWithLocation<VariableDeclaration>();
@@ -445,7 +445,7 @@ assembly::VariableDeclaration Parser::parseVariableDeclaration()
return varDecl;
}
-assembly::FunctionDefinition Parser::parseFunctionDefinition()
+FunctionDefinition Parser::parseFunctionDefinition()
{
RecursionGuard recursionGuard(*this);
FunctionDefinition funDef = createWithLocation<FunctionDefinition>();
@@ -477,7 +477,7 @@ assembly::FunctionDefinition Parser::parseFunctionDefinition()
return funDef;
}
-assembly::Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
+Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
{
RecursionGuard recursionGuard(*this);
if (_initialOp.type() == typeid(Instruction))
diff --git a/libyul/AsmParser.h b/libyul/AsmParser.h
index 874b4d6d..cea3b667 100644
--- a/libyul/AsmParser.h
+++ b/libyul/AsmParser.h
@@ -29,11 +29,7 @@
#include <liblangutil/Scanner.h>
#include <liblangutil/ParserBase.h>
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
class Parser: public langutil::ParserBase
@@ -48,7 +44,7 @@ public:
std::shared_ptr<Block> parse(std::shared_ptr<langutil::Scanner> const& _scanner, bool _reuseScanner);
protected:
- using ElementaryOperation = boost::variant<assembly::Instruction, assembly::Literal, assembly::Identifier>;
+ using ElementaryOperation = boost::variant<Instruction, Literal, Identifier>;
/// Creates an inline assembly node with the given source location.
template <class T> T createWithLocation(langutil::SourceLocation const& _loc = {}) const
@@ -71,7 +67,7 @@ protected:
Case parseCase();
ForLoop parseForLoop();
/// Parses a functional expression that has to push exactly one stack element
- assembly::Expression parseExpression();
+ Expression parseExpression();
static std::map<std::string, dev::solidity::Instruction> const& instructions();
static std::map<dev::solidity::Instruction, std::string> const& instructionNames();
/// Parses an elementary operation, i.e. a literal, identifier or instruction.
@@ -80,7 +76,7 @@ protected:
ElementaryOperation parseElementaryOperation();
VariableDeclaration parseVariableDeclaration();
FunctionDefinition parseFunctionDefinition();
- assembly::Expression parseCall(ElementaryOperation&& _initialOp);
+ Expression parseCall(ElementaryOperation&& _initialOp);
TypedName parseTypedName();
std::string expectAsmIdentifier();
@@ -91,5 +87,3 @@ private:
};
}
-}
-}
diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp
index 49e2f33b..eaaba9f3 100644
--- a/libyul/AsmPrinter.cpp
+++ b/libyul/AsmPrinter.cpp
@@ -35,19 +35,19 @@
using namespace std;
using namespace dev;
+using namespace yul;
using namespace dev::solidity;
-using namespace dev::solidity::assembly;
//@TODO source locations
-string AsmPrinter::operator()(assembly::Instruction const& _instruction)
+string AsmPrinter::operator()(yul::Instruction const& _instruction)
{
solAssert(!m_yul, "");
solAssert(isValidInstruction(_instruction.instruction), "Invalid instruction");
return boost::to_lower_copy(instructionInfo(_instruction.instruction).name);
}
-string AsmPrinter::operator()(assembly::Literal const& _literal)
+string AsmPrinter::operator()(Literal const& _literal)
{
switch (_literal.kind)
{
@@ -90,13 +90,13 @@ string AsmPrinter::operator()(assembly::Literal const& _literal)
return "\"" + out + "\"" + appendTypeName(_literal.type);
}
-string AsmPrinter::operator()(assembly::Identifier const& _identifier)
+string AsmPrinter::operator()(Identifier const& _identifier)
{
solAssert(!_identifier.name.empty(), "Invalid identifier.");
return _identifier.name.str();
}
-string AsmPrinter::operator()(assembly::FunctionalInstruction const& _functionalInstruction)
+string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstruction)
{
solAssert(!m_yul, "");
solAssert(isValidInstruction(_functionalInstruction.instruction), "Invalid instruction");
@@ -114,21 +114,21 @@ string AsmPrinter::operator()(ExpressionStatement const& _statement)
return boost::apply_visitor(*this, _statement.expression);
}
-string AsmPrinter::operator()(assembly::Label const& _label)
+string AsmPrinter::operator()(Label const& _label)
{
solAssert(!m_yul, "");
solAssert(!_label.name.empty(), "Invalid label.");
return _label.name.str() + ":";
}
-string AsmPrinter::operator()(assembly::StackAssignment const& _assignment)
+string AsmPrinter::operator()(StackAssignment const& _assignment)
{
solAssert(!m_yul, "");
solAssert(!_assignment.variableName.name.empty(), "Invalid variable name.");
return "=: " + (*this)(_assignment.variableName);
}
-string AsmPrinter::operator()(assembly::Assignment const& _assignment)
+string AsmPrinter::operator()(Assignment const& _assignment)
{
solAssert(_assignment.variableNames.size() >= 1, "");
string variables = (*this)(_assignment.variableNames.front());
@@ -137,7 +137,7 @@ string AsmPrinter::operator()(assembly::Assignment const& _assignment)
return variables + " := " + boost::apply_visitor(*this, *_assignment.value);
}
-string AsmPrinter::operator()(assembly::VariableDeclaration const& _variableDeclaration)
+string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration)
{
string out = "let ";
out += boost::algorithm::join(
@@ -154,7 +154,7 @@ string AsmPrinter::operator()(assembly::VariableDeclaration const& _variableDecl
return out;
}
-string AsmPrinter::operator()(assembly::FunctionDefinition const& _functionDefinition)
+string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition)
{
solAssert(!_functionDefinition.name.empty(), "Invalid function name.");
string out = "function " + _functionDefinition.name.str() + "(";
@@ -179,7 +179,7 @@ string AsmPrinter::operator()(assembly::FunctionDefinition const& _functionDefin
return out + "\n" + (*this)(_functionDefinition.body);
}
-string AsmPrinter::operator()(assembly::FunctionCall const& _functionCall)
+string AsmPrinter::operator()(FunctionCall const& _functionCall)
{
return
(*this)(_functionCall.functionName) + "(" +
@@ -210,7 +210,7 @@ string AsmPrinter::operator()(Switch const& _switch)
return out;
}
-string AsmPrinter::operator()(assembly::ForLoop const& _forLoop)
+string AsmPrinter::operator()(ForLoop const& _forLoop)
{
solAssert(_forLoop.condition, "Invalid for loop condition.");
string out = "for ";
diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h
index ab0c9a08..61dfc18c 100644
--- a/libyul/AsmPrinter.h
+++ b/libyul/AsmPrinter.h
@@ -28,11 +28,7 @@
#include <boost/variant.hpp>
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
class AsmPrinter: public boost::static_visitor<std::string>
@@ -40,29 +36,27 @@ class AsmPrinter: public boost::static_visitor<std::string>
public:
explicit AsmPrinter(bool _yul = false): m_yul(_yul) {}
- std::string operator()(assembly::Instruction const& _instruction);
- std::string operator()(assembly::Literal const& _literal);
- std::string operator()(assembly::Identifier const& _identifier);
- std::string operator()(assembly::FunctionalInstruction const& _functionalInstruction);
- std::string operator()(assembly::ExpressionStatement const& _expr);
- std::string operator()(assembly::Label const& _label);
- std::string operator()(assembly::StackAssignment const& _assignment);
- std::string operator()(assembly::Assignment const& _assignment);
- std::string operator()(assembly::VariableDeclaration const& _variableDeclaration);
- std::string operator()(assembly::FunctionDefinition const& _functionDefinition);
- std::string operator()(assembly::FunctionCall const& _functionCall);
- std::string operator()(assembly::If const& _if);
- std::string operator()(assembly::Switch const& _switch);
- std::string operator()(assembly::ForLoop const& _forLoop);
- std::string operator()(assembly::Block const& _block);
+ std::string operator()(Instruction const& _instruction);
+ std::string operator()(Literal const& _literal);
+ std::string operator()(Identifier const& _identifier);
+ std::string operator()(FunctionalInstruction const& _functionalInstruction);
+ std::string operator()(ExpressionStatement const& _expr);
+ std::string operator()(Label const& _label);
+ std::string operator()(StackAssignment const& _assignment);
+ std::string operator()(Assignment const& _assignment);
+ std::string operator()(VariableDeclaration const& _variableDeclaration);
+ std::string operator()(FunctionDefinition const& _functionDefinition);
+ std::string operator()(FunctionCall const& _functionCall);
+ std::string operator()(If const& _if);
+ std::string operator()(Switch const& _switch);
+ std::string operator()(ForLoop const& _forLoop);
+ std::string operator()(Block const& _block);
private:
std::string formatTypedName(TypedName _variable) const;
- std::string appendTypeName(yul::YulString _type) const;
+ std::string appendTypeName(YulString _type) const;
bool m_yul = false;
};
}
-}
-}
diff --git a/libyul/AsmScope.cpp b/libyul/AsmScope.cpp
index 0d7aca57..b71f2367 100644
--- a/libyul/AsmScope.cpp
+++ b/libyul/AsmScope.cpp
@@ -22,9 +22,9 @@
using namespace std;
using namespace dev;
-using namespace dev::solidity::assembly;
+using namespace yul;
-bool Scope::registerLabel(yul::YulString _name)
+bool Scope::registerLabel(YulString _name)
{
if (exists(_name))
return false;
@@ -32,7 +32,7 @@ bool Scope::registerLabel(yul::YulString _name)
return true;
}
-bool Scope::registerVariable(yul::YulString _name, YulType const& _type)
+bool Scope::registerVariable(YulString _name, YulType const& _type)
{
if (exists(_name))
return false;
@@ -42,7 +42,7 @@ bool Scope::registerVariable(yul::YulString _name, YulType const& _type)
return true;
}
-bool Scope::registerFunction(yul::YulString _name, std::vector<YulType> const& _arguments, std::vector<YulType> const& _returns)
+bool Scope::registerFunction(YulString _name, std::vector<YulType> const& _arguments, std::vector<YulType> const& _returns)
{
if (exists(_name))
return false;
@@ -50,7 +50,7 @@ bool Scope::registerFunction(yul::YulString _name, std::vector<YulType> const& _
return true;
}
-Scope::Identifier* Scope::lookup(yul::YulString _name)
+Scope::Identifier* Scope::lookup(YulString _name)
{
bool crossedFunctionBoundary = false;
for (Scope* s = this; s; s = s->superScope)
@@ -70,7 +70,7 @@ Scope::Identifier* Scope::lookup(yul::YulString _name)
return nullptr;
}
-bool Scope::exists(yul::YulString _name) const
+bool Scope::exists(YulString _name) const
{
if (identifiers.count(_name))
return true;
diff --git a/libyul/AsmScope.h b/libyul/AsmScope.h
index 12c05716..2a8ef49e 100644
--- a/libyul/AsmScope.h
+++ b/libyul/AsmScope.h
@@ -32,16 +32,12 @@
#include <functional>
#include <memory>
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct Scope
{
- using YulType = yul::YulString;
+ using YulType = YulString;
using LabelID = size_t;
struct Variable { YulType type; };
@@ -53,13 +49,13 @@ struct Scope
};
using Identifier = boost::variant<Variable, Label, Function>;
- using Visitor = GenericVisitor<Variable const, Label const, Function const>;
- using NonconstVisitor = GenericVisitor<Variable, Label, Function>;
+ using Visitor = dev::GenericVisitor<Variable const, Label const, Function const>;
+ using NonconstVisitor = dev::GenericVisitor<Variable, Label, Function>;
- bool registerVariable(yul::YulString _name, YulType const& _type);
- bool registerLabel(yul::YulString _name);
+ bool registerVariable(YulString _name, YulType const& _type);
+ bool registerLabel(YulString _name);
bool registerFunction(
- yul::YulString _name,
+ YulString _name,
std::vector<YulType> const& _arguments,
std::vector<YulType> const& _returns
);
@@ -69,12 +65,12 @@ struct Scope
/// will any lookups across assembly boundaries.
/// The pointer will be invalidated if the scope is modified.
/// @param _crossedFunction if true, we already crossed a function boundary during recursive lookup
- Identifier* lookup(yul::YulString _name);
+ Identifier* lookup(YulString _name);
/// Looks up the identifier in this and super scopes (will not find variables across function
/// boundaries and generally stops at assembly boundaries) and calls the visitor, returns
/// false if not found.
template <class V>
- bool lookup(yul::YulString _name, V const& _visitor)
+ bool lookup(YulString _name, V const& _visitor)
{
if (Identifier* id = lookup(_name))
{
@@ -86,7 +82,7 @@ struct Scope
}
/// @returns true if the name exists in this scope or in super scopes (also searches
/// across function and assembly boundaries).
- bool exists(yul::YulString _name) const;
+ bool exists(YulString _name) const;
/// @returns the number of variables directly registered inside the scope.
size_t numberOfVariables() const;
@@ -97,9 +93,7 @@ struct Scope
/// If true, variables from the super scope are not visible here (other identifiers are),
/// but they are still taken into account to prevent shadowing.
bool functionScope = false;
- std::map<yul::YulString, Identifier> identifiers;
+ std::map<YulString, Identifier> identifiers;
};
}
-}
-}
diff --git a/libyul/AsmScopeFiller.cpp b/libyul/AsmScopeFiller.cpp
index 2070d8de..ee797d6a 100644
--- a/libyul/AsmScopeFiller.cpp
+++ b/libyul/AsmScopeFiller.cpp
@@ -37,8 +37,8 @@
using namespace std;
using namespace dev;
using namespace langutil;
+using namespace yul;
using namespace dev::solidity;
-using namespace dev::solidity::assembly;
ScopeFiller::ScopeFiller(AsmAnalysisInfo& _info, ErrorReporter& _errorReporter):
m_info(_info), m_errorReporter(_errorReporter)
@@ -65,7 +65,7 @@ bool ScopeFiller::operator()(Label const& _item)
return true;
}
-bool ScopeFiller::operator()(assembly::VariableDeclaration const& _varDecl)
+bool ScopeFiller::operator()(VariableDeclaration const& _varDecl)
{
for (auto const& variable: _varDecl.variables)
if (!registerVariable(variable, _varDecl.location, *m_currentScope))
@@ -73,7 +73,7 @@ bool ScopeFiller::operator()(assembly::VariableDeclaration const& _varDecl)
return true;
}
-bool ScopeFiller::operator()(assembly::FunctionDefinition const& _funDef)
+bool ScopeFiller::operator()(FunctionDefinition const& _funDef)
{
bool success = true;
vector<Scope::YulType> arguments;
diff --git a/libyul/AsmScopeFiller.h b/libyul/AsmScopeFiller.h
index fbd65bba..e8fb88d5 100644
--- a/libyul/AsmScopeFiller.h
+++ b/libyul/AsmScopeFiller.h
@@ -33,11 +33,7 @@ class ErrorReporter;
struct SourceLocation;
}
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct TypedName;
@@ -53,21 +49,21 @@ class ScopeFiller: public boost::static_visitor<bool>
public:
ScopeFiller(AsmAnalysisInfo& _info, langutil::ErrorReporter& _errorReporter);
- bool operator()(assembly::Instruction const&) { return true; }
- bool operator()(assembly::Literal const&) { return true; }
- bool operator()(assembly::Identifier const&) { return true; }
- bool operator()(assembly::FunctionalInstruction const&) { return true; }
- bool operator()(assembly::ExpressionStatement const& _expr);
- bool operator()(assembly::Label const& _label);
- bool operator()(assembly::StackAssignment const&) { return true; }
- bool operator()(assembly::Assignment const&) { return true; }
- bool operator()(assembly::VariableDeclaration const& _variableDeclaration);
- bool operator()(assembly::FunctionDefinition const& _functionDefinition);
- bool operator()(assembly::FunctionCall const&) { return true; }
- bool operator()(assembly::If const& _if);
- bool operator()(assembly::Switch const& _switch);
- bool operator()(assembly::ForLoop const& _forLoop);
- bool operator()(assembly::Block const& _block);
+ bool operator()(Instruction const&) { return true; }
+ bool operator()(Literal const&) { return true; }
+ bool operator()(Identifier const&) { return true; }
+ bool operator()(FunctionalInstruction const&) { return true; }
+ bool operator()(ExpressionStatement const& _expr);
+ bool operator()(Label const& _label);
+ bool operator()(StackAssignment const&) { return true; }
+ bool operator()(Assignment const&) { return true; }
+ bool operator()(VariableDeclaration const& _variableDeclaration);
+ bool operator()(FunctionDefinition const& _functionDefinition);
+ bool operator()(FunctionCall const&) { return true; }
+ bool operator()(If const& _if);
+ bool operator()(Switch const& _switch);
+ bool operator()(ForLoop const& _forLoop);
+ bool operator()(Block const& _block);
private:
bool registerVariable(
@@ -76,7 +72,7 @@ private:
Scope& _scope
);
- Scope& scope(assembly::Block const* _block);
+ Scope& scope(Block const* _block);
Scope* m_currentScope = nullptr;
AsmAnalysisInfo& m_info;
@@ -84,5 +80,3 @@ private:
};
}
-}
-}
diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h
index 0c421dbf..e10e53ef 100644
--- a/libyul/Exceptions.h
+++ b/libyul/Exceptions.h
@@ -23,18 +23,15 @@
#include <libdevcore/Exceptions.h>
#include <libdevcore/Assertions.h>
-namespace dev
-{
namespace yul
{
-struct YulException: virtual Exception {};
+struct YulException: virtual dev::Exception {};
struct OptimizerException: 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, ::dev::yul::YulException, DESCRIPTION)
+ assertThrow(CONDITION, ::yul::YulException, DESCRIPTION)
}
-}
diff --git a/libyul/YulString.h b/libyul/YulString.h
index ad900a70..2179c23b 100644
--- a/libyul/YulString.h
+++ b/libyul/YulString.h
@@ -27,8 +27,6 @@
#include <vector>
#include <string>
-namespace dev
-{
namespace yul
{
@@ -130,4 +128,3 @@ private:
};
}
-}
diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h
index 5a1140cb..97b1d305 100644
--- a/libyul/backends/evm/AbstractAssembly.h
+++ b/libyul/backends/evm/AbstractAssembly.h
@@ -22,6 +22,7 @@
#pragma once
+#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <functional>
@@ -36,14 +37,13 @@ namespace dev
namespace solidity
{
enum class Instruction: uint8_t;
-namespace assembly
-{
-struct Instruction;
-struct Identifier;
}
}
+
namespace yul
{
+struct Instruction;
+struct Identifier;
///
/// Assembly class that abstracts both the libevmasm assembly and the new Yul assembly.
@@ -61,9 +61,9 @@ public:
/// at the beginning.
virtual int stackHeight() const = 0;
/// Append an EVM instruction.
- virtual void appendInstruction(solidity::Instruction _instruction) = 0;
+ virtual void appendInstruction(dev::solidity::Instruction _instruction) = 0;
/// Append a constant.
- virtual void appendConstant(u256 const& _constant) = 0;
+ virtual void appendConstant(dev::u256 const& _constant) = 0;
/// Append a label.
virtual void appendLabel(LabelID _labelId) = 0;
/// Append a label reference.
@@ -106,18 +106,15 @@ enum class IdentifierContext { LValue, RValue };
/// to inline assembly (not used in standalone assembly mode).
struct ExternalIdentifierAccess
{
- using Resolver = std::function<size_t(solidity::assembly::Identifier const&, IdentifierContext, bool /*_crossesFunctionBoundary*/)>;
+ using Resolver = std::function<size_t(Identifier const&, IdentifierContext, bool /*_crossesFunctionBoundary*/)>;
/// Resolve an external reference given by the identifier in the given context.
/// @returns the size of the value (number of stack slots) or size_t(-1) if not found.
Resolver resolve;
- using CodeGenerator = std::function<void(solidity::assembly::Identifier const&, IdentifierContext, yul::AbstractAssembly&)>;
+ using CodeGenerator = std::function<void(Identifier const&, IdentifierContext, yul::AbstractAssembly&)>;
/// Generate code for retrieving the value (rvalue context) or storing the value (lvalue context)
/// of an identifier. The code should be appended to the assembly. In rvalue context, the value is supposed
/// to be put onto the stack, in lvalue context, the value is assumed to be at the top of the stack.
CodeGenerator generateCode;
};
-
-
-}
}
diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp
index 791b6226..99506317 100644
--- a/libyul/backends/evm/EVMAssembly.cpp
+++ b/libyul/backends/evm/EVMAssembly.cpp
@@ -27,7 +27,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
-using namespace dev::yul;
+using namespace yul;
namespace
{
diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h
index c9190634..d0a437cc 100644
--- a/libyul/backends/evm/EVMAssembly.h
+++ b/libyul/backends/evm/EVMAssembly.h
@@ -31,8 +31,6 @@ namespace langutil
struct SourceLocation;
}
-namespace dev
-{
namespace yul
{
@@ -48,9 +46,9 @@ public:
/// at the beginning.
int stackHeight() const override { return m_stackHeight; }
/// Append an EVM instruction.
- void appendInstruction(solidity::Instruction _instruction) override;
+ void appendInstruction(dev::solidity::Instruction _instruction) override;
/// Append a constant.
- void appendConstant(u256 const& _constant) override;
+ void appendConstant(dev::u256 const& _constant) override;
/// Append a label.
void appendLabel(LabelID _labelId) override;
/// Append a label reference.
@@ -81,17 +79,17 @@ public:
void appendAssemblySize() override;
/// Resolves references inside the bytecode and returns the linker object.
- eth::LinkerObject finalize();
+ dev::eth::LinkerObject finalize();
private:
void setLabelToCurrentPosition(AbstractAssembly::LabelID _labelId);
void appendLabelReferenceInternal(AbstractAssembly::LabelID _labelId);
- void updateReference(size_t pos, size_t size, u256 value);
+ void updateReference(size_t pos, size_t size, dev::u256 value);
bool m_evm15 = false; ///< if true, switch to evm1.5 mode
LabelID m_nextLabelId = 0;
int m_stackHeight = 0;
- bytes m_bytecode;
+ dev::bytes m_bytecode;
std::map<std::string, LabelID> m_namedLabels;
std::map<LabelID, size_t> m_labelPositions;
std::map<size_t, LabelID> m_labelReferences;
@@ -99,4 +97,3 @@ private:
};
}
-}
diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp
index 3cf1061a..12abd754 100644
--- a/libyul/backends/evm/EVMCodeTransform.cpp
+++ b/libyul/backends/evm/EVMCodeTransform.cpp
@@ -29,11 +29,9 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
-using Scope = dev::solidity::assembly::Scope;
-
void CodeTransform::operator()(VariableDeclaration const& _varDecl)
{
solAssert(m_scope, "");
@@ -147,7 +145,7 @@ void CodeTransform::operator()(FunctionalInstruction const& _instruction)
solAssert(_instruction.arguments.size() == 1, "");
}
m_assembly.setSourceLocation(_instruction.location);
- auto label = labelFromIdentifier(boost::get<assembly::Identifier>(_instruction.arguments.at(0)));
+ auto label = labelFromIdentifier(boost::get<Identifier>(_instruction.arguments.at(0)));
if (isJumpI)
m_assembly.appendJumpToIf(label);
else
@@ -163,7 +161,7 @@ void CodeTransform::operator()(FunctionalInstruction const& _instruction)
checkStackHeight(&_instruction);
}
-void CodeTransform::operator()(assembly::Identifier const& _identifier)
+void CodeTransform::operator()(Identifier const& _identifier)
{
m_assembly.setSourceLocation(_identifier.location);
// First search internals, then externals.
@@ -197,12 +195,12 @@ void CodeTransform::operator()(assembly::Identifier const& _identifier)
checkStackHeight(&_identifier);
}
-void CodeTransform::operator()(assembly::Literal const& _literal)
+void CodeTransform::operator()(Literal const& _literal)
{
m_assembly.setSourceLocation(_literal.location);
- if (_literal.kind == assembly::LiteralKind::Number)
+ if (_literal.kind == LiteralKind::Number)
m_assembly.appendConstant(u256(_literal.value.str()));
- else if (_literal.kind == assembly::LiteralKind::Boolean)
+ else if (_literal.kind == LiteralKind::Boolean)
{
if (_literal.value.str() == "true")
m_assembly.appendConstant(u256(1));
@@ -217,7 +215,7 @@ void CodeTransform::operator()(assembly::Literal const& _literal)
checkStackHeight(&_literal);
}
-void CodeTransform::operator()(assembly::Instruction const& _instruction)
+void CodeTransform::operator()(yul::Instruction const& _instruction)
{
solAssert(!m_evm15 || _instruction.instruction != solidity::Instruction::JUMP, "Bare JUMP instruction used for EVM1.5");
solAssert(!m_evm15 || _instruction.instruction != solidity::Instruction::JUMPI, "Bare JUMPI instruction used for EVM1.5");
@@ -522,7 +520,7 @@ void CodeTransform::generateAssignment(Identifier const& _variableName)
}
}
-int CodeTransform::variableHeightDiff(solidity::assembly::Scope::Variable const& _var, bool _forSwap) const
+int CodeTransform::variableHeightDiff(Scope::Variable const& _var, bool _forSwap) const
{
solAssert(m_context->variableStackHeights.count(&_var), "");
int heightDiff = m_assembly.stackHeight() - m_context->variableStackHeights[&_var];
diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h
index f4696e81..bf195dcd 100644
--- a/libyul/backends/evm/EVMCodeTransform.h
+++ b/libyul/backends/evm/EVMCodeTransform.h
@@ -27,18 +27,14 @@
#include <boost/variant.hpp>
#include <boost/optional.hpp>
-namespace dev
-{
-namespace solidity
+namespace langutil
{
class ErrorReporter;
-namespace assembly
-{
-struct AsmAnalysisInfo;
-}
}
+
namespace yul
{
+struct AsmAnalysisInfo;
class EVMAssembly;
class CodeTransform: public boost::static_visitor<>
@@ -47,8 +43,8 @@ public:
/// Create the code transformer.
/// @param _identifierAccess used to resolve identifiers external to the inline assembly
CodeTransform(
- yul::AbstractAssembly& _assembly,
- solidity::assembly::AsmAnalysisInfo& _analysisInfo,
+ AbstractAssembly& _assembly,
+ AsmAnalysisInfo& _analysisInfo,
bool _yul = false,
bool _evm15 = false,
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(),
@@ -69,15 +65,14 @@ public:
protected:
struct Context
{
- using Scope = solidity::assembly::Scope;
std::map<Scope::Label const*, AbstractAssembly::LabelID> labelIDs;
std::map<Scope::Function const*, AbstractAssembly::LabelID> functionEntryIDs;
std::map<Scope::Variable const*, int> variableStackHeights;
};
CodeTransform(
- yul::AbstractAssembly& _assembly,
- solidity::assembly::AsmAnalysisInfo& _analysisInfo,
+ AbstractAssembly& _assembly,
+ AsmAnalysisInfo& _analysisInfo,
bool _yul,
bool _evm15,
ExternalIdentifierAccess const& _identifierAccess,
@@ -116,8 +111,8 @@ private:
AbstractAssembly::LabelID labelFromIdentifier(Identifier const& _identifier);
/// @returns the label ID corresponding to the given label, allocating a new one if
/// necessary.
- AbstractAssembly::LabelID labelID(solidity::assembly::Scope::Label const& _label);
- AbstractAssembly::LabelID functionEntryID(YulString _name, solidity::assembly::Scope::Function const& _function);
+ AbstractAssembly::LabelID labelID(Scope::Label const& _label);
+ AbstractAssembly::LabelID functionEntryID(YulString _name, Scope::Function const& _function);
/// Generates code for an expression that is supposed to return a single value.
void visitExpression(Expression const& _expression);
@@ -133,15 +128,15 @@ private:
/// Determines the stack height difference to the given variables. Throws
/// if it is not yet in scope or the height difference is too large. Returns
/// the (positive) stack height difference otherwise.
- int variableHeightDiff(solidity::assembly::Scope::Variable const& _var, bool _forSwap) const;
+ int variableHeightDiff(Scope::Variable const& _var, bool _forSwap) const;
void expectDeposit(int _deposit, int _oldHeight) const;
void checkStackHeight(void const* _astElement) const;
- yul::AbstractAssembly& m_assembly;
- solidity::assembly::AsmAnalysisInfo& m_info;
- solidity::assembly::Scope* m_scope = nullptr;
+ AbstractAssembly& m_assembly;
+ AsmAnalysisInfo& m_info;
+ Scope* m_scope = nullptr;
bool m_yul = false;
bool m_evm15 = false;
bool m_useNamedLabelsForFunctions = false;
@@ -155,4 +150,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/ASTCopier.cpp b/libyul/optimiser/ASTCopier.cpp
index d4781ec2..f18b0e6b 100644
--- a/libyul/optimiser/ASTCopier.cpp
+++ b/libyul/optimiser/ASTCopier.cpp
@@ -28,7 +28,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
Statement ASTCopier::operator()(Instruction const&)
{
diff --git a/libyul/optimiser/ASTCopier.h b/libyul/optimiser/ASTCopier.h
index 95e58a56..7daf74b8 100644
--- a/libyul/optimiser/ASTCopier.h
+++ b/libyul/optimiser/ASTCopier.h
@@ -31,8 +31,6 @@
#include <set>
#include <memory>
-namespace dev
-{
namespace yul
{
@@ -123,4 +121,3 @@ std::vector<T> ASTCopier::translateVector(std::vector<T> const& _values)
}
-}
diff --git a/libyul/optimiser/ASTWalker.cpp b/libyul/optimiser/ASTWalker.cpp
index ed4a07ad..0d568007 100644
--- a/libyul/optimiser/ASTWalker.cpp
+++ b/libyul/optimiser/ASTWalker.cpp
@@ -26,7 +26,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
diff --git a/libyul/optimiser/ASTWalker.h b/libyul/optimiser/ASTWalker.h
index 38cb85ea..9647c323 100644
--- a/libyul/optimiser/ASTWalker.h
+++ b/libyul/optimiser/ASTWalker.h
@@ -32,8 +32,6 @@
#include <set>
#include <map>
-namespace dev
-{
namespace yul
{
@@ -120,4 +118,3 @@ protected:
};
}
-}
diff --git a/libyul/optimiser/BlockFlattener.cpp b/libyul/optimiser/BlockFlattener.cpp
index 4552e3f1..e6f08524 100644
--- a/libyul/optimiser/BlockFlattener.cpp
+++ b/libyul/optimiser/BlockFlattener.cpp
@@ -22,7 +22,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void BlockFlattener::operator()(Block& _block)
{
diff --git a/libyul/optimiser/BlockFlattener.h b/libyul/optimiser/BlockFlattener.h
index 88c49dda..b732422d 100644
--- a/libyul/optimiser/BlockFlattener.h
+++ b/libyul/optimiser/BlockFlattener.h
@@ -18,8 +18,6 @@
#include <libyul/optimiser/ASTWalker.h>
-namespace dev
-{
namespace yul
{
@@ -31,4 +29,3 @@ public:
};
}
-}
diff --git a/libyul/optimiser/CommonSubexpressionEliminator.cpp b/libyul/optimiser/CommonSubexpressionEliminator.cpp
index fc78b1ad..9b851333 100644
--- a/libyul/optimiser/CommonSubexpressionEliminator.cpp
+++ b/libyul/optimiser/CommonSubexpressionEliminator.cpp
@@ -28,7 +28,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void CommonSubexpressionEliminator::visit(Expression& _e)
{
diff --git a/libyul/optimiser/CommonSubexpressionEliminator.h b/libyul/optimiser/CommonSubexpressionEliminator.h
index 16b39f5b..ac1ebe3a 100644
--- a/libyul/optimiser/CommonSubexpressionEliminator.h
+++ b/libyul/optimiser/CommonSubexpressionEliminator.h
@@ -23,8 +23,6 @@
#include <libyul/optimiser/DataFlowAnalyzer.h>
-namespace dev
-{
namespace yul
{
@@ -42,4 +40,3 @@ protected:
};
}
-}
diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp
index 046f466c..64c67b38 100644
--- a/libyul/optimiser/DataFlowAnalyzer.cpp
+++ b/libyul/optimiser/DataFlowAnalyzer.cpp
@@ -33,7 +33,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void DataFlowAnalyzer::operator()(Assignment& _assignment)
{
diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h
index f83543c5..cd134d48 100644
--- a/libyul/optimiser/DataFlowAnalyzer.h
+++ b/libyul/optimiser/DataFlowAnalyzer.h
@@ -28,8 +28,6 @@
#include <map>
#include <set>
-namespace dev
-{
namespace yul
{
@@ -87,4 +85,3 @@ protected:
};
}
-}
diff --git a/libyul/optimiser/Disambiguator.cpp b/libyul/optimiser/Disambiguator.cpp
index e8c31aea..fda5895b 100644
--- a/libyul/optimiser/Disambiguator.cpp
+++ b/libyul/optimiser/Disambiguator.cpp
@@ -26,11 +26,9 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
-using Scope = dev::solidity::assembly::Scope;
-
YulString Disambiguator::translateIdentifier(YulString _originalName)
{
if ((m_externallyUsedIdentifiers.count(_originalName)))
diff --git a/libyul/optimiser/Disambiguator.h b/libyul/optimiser/Disambiguator.h
index b2f80e47..4dd278e6 100644
--- a/libyul/optimiser/Disambiguator.h
+++ b/libyul/optimiser/Disambiguator.h
@@ -30,8 +30,6 @@
#include <set>
-namespace dev
-{
namespace yul
{
@@ -42,7 +40,7 @@ class Disambiguator: public ASTCopier
{
public:
explicit Disambiguator(
- solidity::assembly::AsmAnalysisInfo const& _analysisInfo,
+ AsmAnalysisInfo const& _analysisInfo,
std::set<YulString> const& _externallyUsedIdentifiers = {}
):
m_info(_analysisInfo), m_externallyUsedIdentifiers(_externallyUsedIdentifiers), m_nameDispenser(m_externallyUsedIdentifiers)
@@ -56,16 +54,15 @@ protected:
void leaveFunction(FunctionDefinition const& _function) override;
YulString translateIdentifier(YulString _name) override;
- void enterScopeInternal(solidity::assembly::Scope& _scope);
- void leaveScopeInternal(solidity::assembly::Scope& _scope);
+ void enterScopeInternal(Scope& _scope);
+ void leaveScopeInternal(Scope& _scope);
- solidity::assembly::AsmAnalysisInfo const& m_info;
+ AsmAnalysisInfo const& m_info;
std::set<YulString> const& m_externallyUsedIdentifiers;
- std::vector<solidity::assembly::Scope*> m_scopes;
+ std::vector<Scope*> m_scopes;
std::map<void const*, YulString> m_translations;
NameDispenser m_nameDispenser;
};
}
-}
diff --git a/libyul/optimiser/ExpressionInliner.cpp b/libyul/optimiser/ExpressionInliner.cpp
index abc006d4..27d43ac0 100644
--- a/libyul/optimiser/ExpressionInliner.cpp
+++ b/libyul/optimiser/ExpressionInliner.cpp
@@ -29,7 +29,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
void ExpressionInliner::run()
diff --git a/libyul/optimiser/ExpressionInliner.h b/libyul/optimiser/ExpressionInliner.h
index 46c27080..681b0db4 100644
--- a/libyul/optimiser/ExpressionInliner.h
+++ b/libyul/optimiser/ExpressionInliner.h
@@ -27,8 +27,6 @@
#include <set>
-namespace dev
-{
namespace yul
{
@@ -68,4 +66,3 @@ private:
}
-}
diff --git a/libyul/optimiser/ExpressionJoiner.cpp b/libyul/optimiser/ExpressionJoiner.cpp
index 90301bad..de2b5d53 100644
--- a/libyul/optimiser/ExpressionJoiner.cpp
+++ b/libyul/optimiser/ExpressionJoiner.cpp
@@ -32,7 +32,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
void ExpressionJoiner::operator()(FunctionalInstruction& _instruction)
diff --git a/libyul/optimiser/ExpressionJoiner.h b/libyul/optimiser/ExpressionJoiner.h
index 62d3beb9..2d680b5c 100644
--- a/libyul/optimiser/ExpressionJoiner.h
+++ b/libyul/optimiser/ExpressionJoiner.h
@@ -25,8 +25,6 @@
#include <map>
-namespace dev
-{
namespace yul
{
@@ -98,4 +96,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/ExpressionSimplifier.cpp b/libyul/optimiser/ExpressionSimplifier.cpp
index 8746a783..cda44e8e 100644
--- a/libyul/optimiser/ExpressionSimplifier.cpp
+++ b/libyul/optimiser/ExpressionSimplifier.cpp
@@ -29,7 +29,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
diff --git a/libyul/optimiser/ExpressionSimplifier.h b/libyul/optimiser/ExpressionSimplifier.h
index 5965a1bb..83e82b2b 100644
--- a/libyul/optimiser/ExpressionSimplifier.h
+++ b/libyul/optimiser/ExpressionSimplifier.h
@@ -24,8 +24,6 @@
#include <libyul/optimiser/ASTWalker.h>
-namespace dev
-{
namespace yul
{
@@ -52,4 +50,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/ExpressionSplitter.cpp b/libyul/optimiser/ExpressionSplitter.cpp
index 54a03620..a3b2dc11 100644
--- a/libyul/optimiser/ExpressionSplitter.cpp
+++ b/libyul/optimiser/ExpressionSplitter.cpp
@@ -32,7 +32,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
void ExpressionSplitter::operator()(FunctionalInstruction& _instruction)
diff --git a/libyul/optimiser/ExpressionSplitter.h b/libyul/optimiser/ExpressionSplitter.h
index 82274203..e5b86adc 100644
--- a/libyul/optimiser/ExpressionSplitter.h
+++ b/libyul/optimiser/ExpressionSplitter.h
@@ -27,8 +27,6 @@
#include <vector>
-namespace dev
-{
namespace yul
{
@@ -83,4 +81,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp
index b5e59884..80d39248 100644
--- a/libyul/optimiser/ForLoopInitRewriter.cpp
+++ b/libyul/optimiser/ForLoopInitRewriter.cpp
@@ -21,7 +21,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void ForLoopInitRewriter::operator()(Block& _block)
{
diff --git a/libyul/optimiser/ForLoopInitRewriter.h b/libyul/optimiser/ForLoopInitRewriter.h
index 64f53711..e925c6c2 100644
--- a/libyul/optimiser/ForLoopInitRewriter.h
+++ b/libyul/optimiser/ForLoopInitRewriter.h
@@ -18,8 +18,6 @@
#include <libyul/optimiser/ASTWalker.h>
-namespace dev
-{
namespace yul
{
@@ -36,4 +34,3 @@ public:
};
}
-}
diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp
index 47299f5f..8ae26fbb 100644
--- a/libyul/optimiser/FullInliner.cpp
+++ b/libyul/optimiser/FullInliner.cpp
@@ -36,7 +36,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser):
diff --git a/libyul/optimiser/FullInliner.h b/libyul/optimiser/FullInliner.h
index 5ebb3bf6..161d1945 100644
--- a/libyul/optimiser/FullInliner.h
+++ b/libyul/optimiser/FullInliner.h
@@ -33,8 +33,6 @@
#include <set>
-namespace dev
-{
namespace yul
{
@@ -153,4 +151,3 @@ public:
}
-}
diff --git a/libyul/optimiser/FunctionGrouper.cpp b/libyul/optimiser/FunctionGrouper.cpp
index dc721cae..02ce22cd 100644
--- a/libyul/optimiser/FunctionGrouper.cpp
+++ b/libyul/optimiser/FunctionGrouper.cpp
@@ -27,7 +27,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
diff --git a/libyul/optimiser/FunctionGrouper.h b/libyul/optimiser/FunctionGrouper.h
index 63cfbfb1..508daf5d 100644
--- a/libyul/optimiser/FunctionGrouper.h
+++ b/libyul/optimiser/FunctionGrouper.h
@@ -23,8 +23,6 @@
#include <libyul/ASTDataForward.h>
-namespace dev
-{
namespace yul
{
@@ -43,4 +41,3 @@ public:
};
}
-}
diff --git a/libyul/optimiser/FunctionHoister.cpp b/libyul/optimiser/FunctionHoister.cpp
index 51755968..bd1c781b 100644
--- a/libyul/optimiser/FunctionHoister.cpp
+++ b/libyul/optimiser/FunctionHoister.cpp
@@ -28,7 +28,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
void FunctionHoister::operator()(Block& _block)
diff --git a/libyul/optimiser/FunctionHoister.h b/libyul/optimiser/FunctionHoister.h
index 29894895..3d53aa89 100644
--- a/libyul/optimiser/FunctionHoister.h
+++ b/libyul/optimiser/FunctionHoister.h
@@ -24,8 +24,6 @@
#include <libyul/ASTDataForward.h>
#include <libyul/optimiser/ASTWalker.h>
-namespace dev
-{
namespace yul
{
@@ -48,4 +46,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/InlinableExpressionFunctionFinder.cpp b/libyul/optimiser/InlinableExpressionFunctionFinder.cpp
index 22267b62..662cdf25 100644
--- a/libyul/optimiser/InlinableExpressionFunctionFinder.cpp
+++ b/libyul/optimiser/InlinableExpressionFunctionFinder.cpp
@@ -25,7 +25,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void InlinableExpressionFunctionFinder::operator()(Identifier const& _identifier)
{
diff --git a/libyul/optimiser/InlinableExpressionFunctionFinder.h b/libyul/optimiser/InlinableExpressionFunctionFinder.h
index a96f042f..f64155de 100644
--- a/libyul/optimiser/InlinableExpressionFunctionFinder.h
+++ b/libyul/optimiser/InlinableExpressionFunctionFinder.h
@@ -25,8 +25,6 @@
#include <set>
-namespace dev
-{
namespace yul
{
@@ -66,4 +64,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/MainFunction.cpp b/libyul/optimiser/MainFunction.cpp
index 5f335031..63eea2db 100644
--- a/libyul/optimiser/MainFunction.cpp
+++ b/libyul/optimiser/MainFunction.cpp
@@ -30,7 +30,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
void MainFunction::operator()(Block& _block)
diff --git a/libyul/optimiser/MainFunction.h b/libyul/optimiser/MainFunction.h
index 4a73283a..f4a64303 100644
--- a/libyul/optimiser/MainFunction.h
+++ b/libyul/optimiser/MainFunction.h
@@ -23,8 +23,6 @@
#include <libyul/ASTDataForward.h>
-namespace dev
-{
namespace yul
{
@@ -38,4 +36,3 @@ public:
};
}
-}
diff --git a/libyul/optimiser/Metrics.cpp b/libyul/optimiser/Metrics.cpp
index 5107fc59..a5557fb3 100644
--- a/libyul/optimiser/Metrics.cpp
+++ b/libyul/optimiser/Metrics.cpp
@@ -23,7 +23,7 @@
#include <libyul/AsmData.h>
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
size_t CodeSize::codeSize(Statement const& _statement)
{
diff --git a/libyul/optimiser/Metrics.h b/libyul/optimiser/Metrics.h
index e65110a8..ca244600 100644
--- a/libyul/optimiser/Metrics.h
+++ b/libyul/optimiser/Metrics.h
@@ -22,8 +22,6 @@
#include <libyul/optimiser/ASTWalker.h>
-namespace dev
-{
namespace yul
{
@@ -49,4 +47,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/NameCollector.cpp b/libyul/optimiser/NameCollector.cpp
index 7da001f8..f9079827 100644
--- a/libyul/optimiser/NameCollector.cpp
+++ b/libyul/optimiser/NameCollector.cpp
@@ -24,7 +24,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void NameCollector::operator()(VariableDeclaration const& _varDecl)
{
diff --git a/libyul/optimiser/NameCollector.h b/libyul/optimiser/NameCollector.h
index 8ef0178d..c177a399 100644
--- a/libyul/optimiser/NameCollector.h
+++ b/libyul/optimiser/NameCollector.h
@@ -25,8 +25,6 @@
#include <map>
#include <set>
-namespace dev
-{
namespace yul
{
@@ -83,4 +81,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp
index 11e85477..e7cdc60f 100644
--- a/libyul/optimiser/NameDispenser.cpp
+++ b/libyul/optimiser/NameDispenser.cpp
@@ -25,7 +25,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
NameDispenser::NameDispenser(Block const& _ast):
NameDispenser(NameCollector(_ast).names())
diff --git a/libyul/optimiser/NameDispenser.h b/libyul/optimiser/NameDispenser.h
index 7311440b..1d31fd38 100644
--- a/libyul/optimiser/NameDispenser.h
+++ b/libyul/optimiser/NameDispenser.h
@@ -25,8 +25,6 @@
#include <set>
-namespace dev
-{
namespace yul
{
@@ -58,4 +56,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/RedundantAssignEliminator.cpp
index f415a36c..7b18e8ca 100644
--- a/libyul/optimiser/RedundantAssignEliminator.cpp
+++ b/libyul/optimiser/RedundantAssignEliminator.cpp
@@ -30,7 +30,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
void RedundantAssignEliminator::operator()(Identifier const& _identifier)
diff --git a/libyul/optimiser/RedundantAssignEliminator.h b/libyul/optimiser/RedundantAssignEliminator.h
index bffbb07a..014a7c77 100644
--- a/libyul/optimiser/RedundantAssignEliminator.h
+++ b/libyul/optimiser/RedundantAssignEliminator.h
@@ -26,8 +26,6 @@
#include <map>
-namespace dev
-{
namespace yul
{
@@ -189,4 +187,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/Rematerialiser.cpp b/libyul/optimiser/Rematerialiser.cpp
index b9a127bb..4180bfc3 100644
--- a/libyul/optimiser/Rematerialiser.cpp
+++ b/libyul/optimiser/Rematerialiser.cpp
@@ -27,7 +27,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void Rematerialiser::visit(Expression& _e)
{
diff --git a/libyul/optimiser/Rematerialiser.h b/libyul/optimiser/Rematerialiser.h
index f0e7cb01..b3841519 100644
--- a/libyul/optimiser/Rematerialiser.h
+++ b/libyul/optimiser/Rematerialiser.h
@@ -22,8 +22,6 @@
#include <libyul/optimiser/DataFlowAnalyzer.h>
-namespace dev
-{
namespace yul
{
@@ -41,4 +39,3 @@ protected:
};
}
-}
diff --git a/libyul/optimiser/SSATransform.cpp b/libyul/optimiser/SSATransform.cpp
index ae84dd94..928c0859 100644
--- a/libyul/optimiser/SSATransform.cpp
+++ b/libyul/optimiser/SSATransform.cpp
@@ -31,7 +31,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
void SSATransform::operator()(Identifier& _identifier)
diff --git a/libyul/optimiser/SSATransform.h b/libyul/optimiser/SSATransform.h
index 69638904..2f069284 100644
--- a/libyul/optimiser/SSATransform.h
+++ b/libyul/optimiser/SSATransform.h
@@ -25,8 +25,6 @@
#include <vector>
-namespace dev
-{
namespace yul
{
@@ -94,4 +92,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/SSAValueTracker.cpp b/libyul/optimiser/SSAValueTracker.cpp
index 24776498..35b29b04 100644
--- a/libyul/optimiser/SSAValueTracker.cpp
+++ b/libyul/optimiser/SSAValueTracker.cpp
@@ -25,7 +25,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void SSAValueTracker::operator()(Assignment const& _assignment)
{
diff --git a/libyul/optimiser/SSAValueTracker.h b/libyul/optimiser/SSAValueTracker.h
index acd5229c..e182e013 100644
--- a/libyul/optimiser/SSAValueTracker.h
+++ b/libyul/optimiser/SSAValueTracker.h
@@ -26,8 +26,6 @@
#include <map>
#include <set>
-namespace dev
-{
namespace yul
{
@@ -54,4 +52,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/Semantics.cpp b/libyul/optimiser/Semantics.cpp
index ad9b1922..91bb2709 100644
--- a/libyul/optimiser/Semantics.cpp
+++ b/libyul/optimiser/Semantics.cpp
@@ -29,7 +29,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
MovableChecker::MovableChecker(Expression const& _expression)
{
diff --git a/libyul/optimiser/Semantics.h b/libyul/optimiser/Semantics.h
index a7e8706b..70c50806 100644
--- a/libyul/optimiser/Semantics.h
+++ b/libyul/optimiser/Semantics.h
@@ -24,8 +24,6 @@
#include <set>
-namespace dev
-{
namespace yul
{
@@ -57,4 +55,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp
index ec5379fc..b3190fef 100644
--- a/libyul/optimiser/SimplificationRules.cpp
+++ b/libyul/optimiser/SimplificationRules.cpp
@@ -31,7 +31,7 @@
using namespace std;
using namespace dev;
using namespace langutil;
-using namespace dev::yul;
+using namespace yul;
SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch(
@@ -123,7 +123,7 @@ bool Pattern::matches(Expression const& _expr, map<YulString, Expression const*>
if (expr->type() != typeid(Literal))
return false;
Literal const& literal = boost::get<Literal>(*expr);
- if (literal.kind != assembly::LiteralKind::Number)
+ if (literal.kind != LiteralKind::Number)
return false;
if (m_data && *m_data != u256(literal.value.str()))
return false;
@@ -193,7 +193,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, assembly::LiteralKind::Number, YulString{formatNumber(*m_data)}, {}};
+ return Literal{_location, LiteralKind::Number, YulString{formatNumber(*m_data)}, {}};
}
else if (m_kind == PatternKind::Operation)
{
@@ -208,7 +208,7 @@ Expression Pattern::toExpression(SourceLocation const& _location) const
u256 Pattern::d() const
{
Literal const& literal = boost::get<Literal>(matchGroupValue());
- assertThrow(literal.kind == assembly::LiteralKind::Number, OptimizerException, "");
+ assertThrow(literal.kind == LiteralKind::Number, OptimizerException, "");
assertThrow(isValidDecimal(literal.value.str()) || isValidHex(literal.value.str()), OptimizerException, "");
return u256(literal.value.str());
}
diff --git a/libyul/optimiser/SimplificationRules.h b/libyul/optimiser/SimplificationRules.h
index 3d3d8d2b..023a61f7 100644
--- a/libyul/optimiser/SimplificationRules.h
+++ b/libyul/optimiser/SimplificationRules.h
@@ -31,8 +31,6 @@
#include <functional>
#include <vector>
-namespace dev
-{
namespace yul
{
@@ -85,11 +83,11 @@ public:
/// Matches any expression.
Pattern(PatternKind _kind = PatternKind::Any): m_kind(_kind) {}
// Matches a specific constant value.
- Pattern(unsigned _value): Pattern(u256(_value)) {}
+ Pattern(unsigned _value): Pattern(dev::u256(_value)) {}
// Matches a specific constant value.
- Pattern(u256 const& _value): m_kind(PatternKind::Constant), m_data(std::make_shared<u256>(_value)) {}
+ Pattern(dev::u256 const& _value): m_kind(PatternKind::Constant), m_data(std::make_shared<dev::u256>(_value)) {}
// Matches a given instruction with given arguments
- Pattern(solidity::Instruction _instruction, std::vector<Pattern> const& _arguments = {});
+ Pattern(dev::solidity::Instruction _instruction, std::vector<Pattern> const& _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.
@@ -100,9 +98,9 @@ public:
std::vector<Pattern> arguments() const { return m_arguments; }
/// @returns the data of the matched expression if this pattern is part of a match group.
- u256 d() const;
+ dev::u256 d() const;
- solidity::Instruction instruction() const;
+ dev::solidity::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.
@@ -112,12 +110,11 @@ private:
Expression const& matchGroupValue() const;
PatternKind m_kind = PatternKind::Any;
- solidity::Instruction m_instruction; ///< Only valid if m_kind is Operation
- std::shared_ptr<u256> m_data; ///< Only valid if m_kind is Constant
+ dev::solidity::Instruction m_instruction; ///< Only valid if m_kind is Operation
+ std::shared_ptr<dev::u256> m_data; ///< Only valid if m_kind is Constant
std::vector<Pattern> m_arguments;
unsigned m_matchGroup = 0;
std::map<unsigned, Expression const*>* m_matchGroups = nullptr;
};
}
-}
diff --git a/libyul/optimiser/Substitution.cpp b/libyul/optimiser/Substitution.cpp
index dbac5cf6..bc9efe96 100644
--- a/libyul/optimiser/Substitution.cpp
+++ b/libyul/optimiser/Substitution.cpp
@@ -24,7 +24,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
Expression Substitution::translate(Expression const& _expression)
{
diff --git a/libyul/optimiser/Substitution.h b/libyul/optimiser/Substitution.h
index 6a0679f5..41f73b92 100644
--- a/libyul/optimiser/Substitution.h
+++ b/libyul/optimiser/Substitution.h
@@ -25,8 +25,6 @@
#include <map>
-namespace dev
-{
namespace yul
{
@@ -46,4 +44,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/Suite.cpp b/libyul/optimiser/Suite.cpp
index b6920633..36f0e1eb 100644
--- a/libyul/optimiser/Suite.cpp
+++ b/libyul/optimiser/Suite.cpp
@@ -43,11 +43,11 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
void OptimiserSuite::run(
Block& _ast,
- solidity::assembly::AsmAnalysisInfo const& _analysisInfo,
+ AsmAnalysisInfo const& _analysisInfo,
set<YulString> const& _externallyUsedIdentifiers
)
{
diff --git a/libyul/optimiser/Suite.h b/libyul/optimiser/Suite.h
index 5b564c56..3f23ee9f 100644
--- a/libyul/optimiser/Suite.h
+++ b/libyul/optimiser/Suite.h
@@ -25,18 +25,11 @@
#include <set>
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
-{
-struct AsmAnalysisInfo;
-}
-}
namespace yul
{
+struct AsmAnalysisInfo;
+
/**
* Optimiser suite that combines all steps and also provides the settings for the heuristics
*/
@@ -45,11 +38,10 @@ class OptimiserSuite
public:
static void run(
Block& _ast,
- solidity::assembly::AsmAnalysisInfo const& _analysisInfo,
+ AsmAnalysisInfo const& _analysisInfo,
std::set<YulString> const& _externallyUsedIdentifiers = {}
);
};
}
-}
diff --git a/libyul/optimiser/SyntacticalEquality.cpp b/libyul/optimiser/SyntacticalEquality.cpp
index ff4ff81b..99ce06e5 100644
--- a/libyul/optimiser/SyntacticalEquality.cpp
+++ b/libyul/optimiser/SyntacticalEquality.cpp
@@ -27,7 +27,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
bool SyntacticalEqualityChecker::equal(Expression const& _e1, Expression const& _e2)
{
diff --git a/libyul/optimiser/SyntacticalEquality.h b/libyul/optimiser/SyntacticalEquality.h
index e9fbebe0..46527a66 100644
--- a/libyul/optimiser/SyntacticalEquality.h
+++ b/libyul/optimiser/SyntacticalEquality.h
@@ -24,8 +24,6 @@
#include <vector>
-namespace dev
-{
namespace yul
{
@@ -47,4 +45,3 @@ protected:
};
}
-}
diff --git a/libyul/optimiser/UnusedPruner.cpp b/libyul/optimiser/UnusedPruner.cpp
index 484e7475..31aead82 100644
--- a/libyul/optimiser/UnusedPruner.cpp
+++ b/libyul/optimiser/UnusedPruner.cpp
@@ -30,7 +30,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
UnusedPruner::UnusedPruner(Block& _ast, set<YulString> const& _externallyUsedFunctions)
{
diff --git a/libyul/optimiser/UnusedPruner.h b/libyul/optimiser/UnusedPruner.h
index b5b46443..64e02b35 100644
--- a/libyul/optimiser/UnusedPruner.h
+++ b/libyul/optimiser/UnusedPruner.h
@@ -26,8 +26,6 @@
#include <map>
#include <set>
-namespace dev
-{
namespace yul
{
@@ -62,4 +60,3 @@ private:
};
}
-}
diff --git a/libyul/optimiser/Utilities.cpp b/libyul/optimiser/Utilities.cpp
index e41fd15d..b8cdd339 100644
--- a/libyul/optimiser/Utilities.cpp
+++ b/libyul/optimiser/Utilities.cpp
@@ -28,9 +28,9 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
+using namespace yul;
-void dev::yul::removeEmptyBlocks(Block& _block)
+void yul::removeEmptyBlocks(Block& _block)
{
auto isEmptyBlock = [](Statement const& _st) -> bool {
return _st.type() == typeid(Block) && boost::get<Block>(_st).statements.empty();
diff --git a/libyul/optimiser/Utilities.h b/libyul/optimiser/Utilities.h
index 5b18a27c..11c9fa19 100644
--- a/libyul/optimiser/Utilities.h
+++ b/libyul/optimiser/Utilities.h
@@ -22,8 +22,6 @@
#include <libyul/ASTDataForward.h>
-namespace dev
-{
namespace yul
{
@@ -31,4 +29,3 @@ namespace yul
void removeEmptyBlocks(Block& _block);
}
-}
diff --git a/libyul/optimiser/VarDeclPropagator.cpp b/libyul/optimiser/VarDeclPropagator.cpp
index 855b8215..bf974f44 100644
--- a/libyul/optimiser/VarDeclPropagator.cpp
+++ b/libyul/optimiser/VarDeclPropagator.cpp
@@ -24,10 +24,7 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
-
-using dev::solidity::assembly::TypedName;
-using dev::solidity::assembly::TypedNameList;
+using namespace yul;
void VarDeclPropagator::operator()(Block& _block)
{
diff --git a/libyul/optimiser/VarDeclPropagator.h b/libyul/optimiser/VarDeclPropagator.h
index ffecd217..7a68d326 100644
--- a/libyul/optimiser/VarDeclPropagator.h
+++ b/libyul/optimiser/VarDeclPropagator.h
@@ -25,8 +25,6 @@
#include <set>
#include <map>
-namespace dev
-{
namespace yul
{
@@ -60,4 +58,3 @@ private:
};
}
-}
diff --git a/test/boostTest.cpp b/test/boostTest.cpp
index 5352ef85..966badfc 100644
--- a/test/boostTest.cpp
+++ b/test/boostTest.cpp
@@ -143,7 +143,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
master,
dev::test::Options::get().testPath / "libyul",
"yulOptimizerTests",
- dev::yul::test::YulOptimizerTest::create
+ yul::test::YulOptimizerTest::create
) > 0, "no Yul Optimizer tests found");
if (!dev::test::Options::get().disableSMT)
solAssert(registerTests(
diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp
index 5851555a..d7785287 100644
--- a/test/libyul/Common.cpp
+++ b/test/libyul/Common.cpp
@@ -37,10 +37,10 @@
using namespace std;
using namespace langutil;
-using namespace dev::yul;
+using namespace yul;
using namespace dev::solidity;
-void dev::yul::test::printErrors(ErrorList const& _errors, Scanner const& _scanner)
+void yul::test::printErrors(ErrorList const& _errors, Scanner const& _scanner)
{
SourceReferenceFormatter formatter(cout, [&](std::string const&) -> Scanner const& { return _scanner; });
@@ -52,18 +52,18 @@ void dev::yul::test::printErrors(ErrorList const& _errors, Scanner const& _scann
}
-pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::yul::test::parse(string const& _source, bool _yul)
+pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(string const& _source, bool _yul)
{
- auto flavour = _yul ? assembly::AsmFlavour::Yul : assembly::AsmFlavour::Strict;
+ auto flavour = _yul ? yul::AsmFlavour::Yul : yul::AsmFlavour::Strict;
ErrorList errors;
ErrorReporter errorReporter(errors);
auto scanner = make_shared<Scanner>(CharStream(_source), "");
- auto parserResult = assembly::Parser(errorReporter, flavour).parse(scanner, false);
+ auto parserResult = yul::Parser(errorReporter, flavour).parse(scanner, false);
if (parserResult)
{
BOOST_REQUIRE(errorReporter.errors().empty());
- auto analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
- assembly::AsmAnalyzer analyzer(
+ auto analysisInfo = make_shared<yul::AsmAnalysisInfo>();
+ yul::AsmAnalyzer analyzer(
*analysisInfo,
errorReporter,
dev::test::Options::get().evmVersion(),
@@ -83,13 +83,13 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::yul::test::p
return {};
}
-assembly::Block dev::yul::test::disambiguate(string const& _source, bool _yul)
+yul::Block yul::test::disambiguate(string const& _source, bool _yul)
{
auto result = parse(_source, _yul);
return boost::get<Block>(Disambiguator(*result.second, {})(*result.first));
}
-string dev::yul::test::format(string const& _source, bool _yul)
+string yul::test::format(string const& _source, bool _yul)
{
- return assembly::AsmPrinter(_yul)(*parse(_source, _yul).first);
+ return yul::AsmPrinter(_yul)(*parse(_source, _yul).first);
}
diff --git a/test/libyul/Common.h b/test/libyul/Common.h
index 8241bfe1..a1c64ca5 100644
--- a/test/libyul/Common.h
+++ b/test/libyul/Common.h
@@ -34,26 +34,21 @@ class Error;
using ErrorList = std::vector<std::shared_ptr<Error const>>;
}
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct AsmAnalysisInfo;
}
-}
+
namespace yul
{
namespace test
{
void printErrors(langutil::ErrorList const& _errors, langutil::Scanner const& _scanner);
-std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>>
+std::pair<std::shared_ptr<Block>, std::shared_ptr<AsmAnalysisInfo>>
parse(std::string const& _source, bool _yul = true);
-solidity::assembly::Block disambiguate(std::string const& _source, bool _yul = true);
+Block disambiguate(std::string const& _source, bool _yul = true);
std::string format(std::string const& _source, bool _yul = true);
}
}
-}
diff --git a/test/libyul/Inliner.cpp b/test/libyul/Inliner.cpp
index 0f82dee3..631cda08 100644
--- a/test/libyul/Inliner.cpp
+++ b/test/libyul/Inliner.cpp
@@ -35,8 +35,8 @@
using namespace std;
using namespace dev;
-using namespace dev::yul;
-using namespace dev::yul::test;
+using namespace yul;
+using namespace yul::test;
using namespace dev::solidity;
namespace
diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp
index 957973d0..6f946362 100644
--- a/test/libyul/Parser.cpp
+++ b/test/libyul/Parser.cpp
@@ -36,11 +36,10 @@
#include <memory>
using namespace std;
+using namespace dev;
using namespace langutil;
-namespace dev
-{
-namespace solidity
+namespace yul
{
namespace test
{
@@ -53,16 +52,16 @@ bool parse(string const& _source, ErrorReporter& errorReporter)
try
{
auto scanner = make_shared<Scanner>(CharStream(_source));
- auto parserResult = assembly::Parser(errorReporter, assembly::AsmFlavour::Yul).parse(scanner, false);
+ auto parserResult = yul::Parser(errorReporter, yul::AsmFlavour::Yul).parse(scanner, false);
if (parserResult)
{
- assembly::AsmAnalysisInfo analysisInfo;
- return (assembly::AsmAnalyzer(
+ yul::AsmAnalysisInfo analysisInfo;
+ return (yul::AsmAnalyzer(
analysisInfo,
errorReporter,
dev::test::Options::get().evmVersion(),
boost::none,
- assembly::AsmFlavour::Yul
+ yul::AsmFlavour::Yul
)).analyze(*parserResult);
}
}
@@ -117,7 +116,7 @@ do \
{ \
Error err = expectError((text), false); \
BOOST_CHECK(err.type() == (Error::Type::typ)); \
- BOOST_CHECK(searchErrorMessage(err, (substring))); \
+ BOOST_CHECK(dev::solidity::searchErrorMessage(err, (substring))); \
} while(0)
BOOST_AUTO_TEST_SUITE(YulParser)
@@ -303,5 +302,4 @@ BOOST_AUTO_TEST_CASE(if_statement_invalid)
BOOST_AUTO_TEST_SUITE_END()
}
-}
} // end namespaces
diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp
index 02a63ae3..9c2da493 100644
--- a/test/libyul/YulOptimizerTest.cpp
+++ b/test/libyul/YulOptimizerTest.cpp
@@ -55,8 +55,8 @@
using namespace dev;
using namespace langutil;
-using namespace dev::yul;
-using namespace dev::yul::test;
+using namespace yul;
+using namespace yul::test;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace std;
@@ -92,9 +92,9 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename)
bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
{
- assembly::AsmPrinter printer{m_yul};
+ yul::AsmPrinter printer{m_yul};
shared_ptr<Block> ast;
- shared_ptr<assembly::AsmAnalysisInfo> analysisInfo;
+ shared_ptr<yul::AsmAnalysisInfo> analysisInfo;
if (!parse(_stream, _linePrefix, _formatted))
return false;
@@ -256,19 +256,19 @@ void YulOptimizerTest::printIndented(ostream& _stream, string const& _output, st
bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
{
- assembly::AsmFlavour flavour = m_yul ? assembly::AsmFlavour::Yul : assembly::AsmFlavour::Strict;
+ yul::AsmFlavour flavour = m_yul ? yul::AsmFlavour::Yul : yul::AsmFlavour::Strict;
ErrorList errors;
ErrorReporter errorReporter(errors);
shared_ptr<Scanner> scanner = make_shared<Scanner>(CharStream(m_source), "");
- m_ast = assembly::Parser(errorReporter, flavour).parse(scanner, false);
+ m_ast = yul::Parser(errorReporter, flavour).parse(scanner, false);
if (!m_ast || !errorReporter.errors().empty())
{
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
printErrors(_stream, errorReporter.errors(), *scanner);
return false;
}
- m_analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
- assembly::AsmAnalyzer analyzer(
+ m_analysisInfo = make_shared<yul::AsmAnalysisInfo>();
+ yul::AsmAnalyzer analyzer(
*m_analysisInfo,
errorReporter,
dev::test::Options::get().evmVersion(),
diff --git a/test/libyul/YulOptimizerTest.h b/test/libyul/YulOptimizerTest.h
index d11ff8fb..72c4299f 100644
--- a/test/libyul/YulOptimizerTest.h
+++ b/test/libyul/YulOptimizerTest.h
@@ -26,22 +26,18 @@ class Error;
using ErrorList = std::vector<std::shared_ptr<Error const>>;
}
-namespace dev
-{
-namespace solidity
-{
-namespace assembly
+namespace yul
{
struct AsmAnalysisInfo;
struct Block;
}
-}
+
namespace yul
{
namespace test
{
-class YulOptimizerTest: public solidity::test::TestCase
+class YulOptimizerTest: public dev::solidity::test::TestCase
{
public:
static std::unique_ptr<TestCase> create(std::string const& _filename)
@@ -68,11 +64,10 @@ private:
std::string m_optimizerStep;
std::string m_expectation;
- std::shared_ptr<solidity::assembly::Block> m_ast;
- std::shared_ptr<solidity::assembly::AsmAnalysisInfo> m_analysisInfo;
+ std::shared_ptr<Block> m_ast;
+ std::shared_ptr<AsmAnalysisInfo> m_analysisInfo;
std::string m_obtainedResult;
};
}
}
-}
diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp
index 4e916b49..7a147137 100644
--- a/test/tools/yulopti.cpp
+++ b/test/tools/yulopti.cpp
@@ -60,8 +60,7 @@ using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
-using namespace dev::solidity::assembly;
-using namespace dev::yul;
+using namespace yul;
namespace po = boost::program_options;
@@ -83,14 +82,14 @@ public:
{
ErrorReporter errorReporter(m_errors);
shared_ptr<Scanner> scanner = make_shared<Scanner>(CharStream(_input), "");
- m_ast = assembly::Parser(errorReporter, assembly::AsmFlavour::Strict).parse(scanner, false);
+ m_ast = yul::Parser(errorReporter, yul::AsmFlavour::Strict).parse(scanner, false);
if (!m_ast || !errorReporter.errors().empty())
{
cout << "Error parsing source." << endl;
printErrors(*scanner);
return false;
}
- m_analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
+ m_analysisInfo = make_shared<yul::AsmAnalysisInfo>();
AsmAnalyzer analyzer(
*m_analysisInfo,
errorReporter,
@@ -118,7 +117,7 @@ public:
return;
if (!disambiguated)
{
- *m_ast = boost::get<assembly::Block>(Disambiguator(*m_analysisInfo)(*m_ast));
+ *m_ast = boost::get<yul::Block>(Disambiguator(*m_analysisInfo)(*m_ast));
m_analysisInfo.reset();
m_nameDispenser = make_shared<NameDispenser>(*m_ast);
disambiguated = true;
@@ -187,7 +186,7 @@ public:
private:
ErrorList m_errors;
- shared_ptr<assembly::Block> m_ast;
+ shared_ptr<yul::Block> m_ast;
shared_ptr<AsmAnalysisInfo> m_analysisInfo;
shared_ptr<NameDispenser> m_nameDispenser;
};