diff --git a/libevmasm/Assembly.h b/libevmasm/Assembly.h index a53c92420..ebf032ac1 100644 --- a/libevmasm/Assembly.h +++ b/libevmasm/Assembly.h @@ -68,10 +68,10 @@ public: void appendProgramSize() { append(AssemblyItem(PushProgramSize)); } void appendLibraryAddress(std::string const& _identifier) { append(newPushLibraryAddress(_identifier)); } - AssemblyItem appendJump() { auto ret = append(newPushTag()); append(solidity::Instruction::JUMP); return ret; } - AssemblyItem appendJumpI() { auto ret = append(newPushTag()); append(solidity::Instruction::JUMPI); return ret; } - AssemblyItem appendJump(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(solidity::Instruction::JUMP); return ret; } - AssemblyItem appendJumpI(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(solidity::Instruction::JUMPI); return ret; } + AssemblyItem appendJump() { auto ret = append(newPushTag()); append(Instruction::JUMP); return ret; } + AssemblyItem appendJumpI() { auto ret = append(newPushTag()); append(Instruction::JUMPI); return ret; } + AssemblyItem appendJump(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(Instruction::JUMP); return ret; } + AssemblyItem appendJumpI(AssemblyItem const& _tag) { auto ret = append(_tag.pushTag()); append(Instruction::JUMPI); return ret; } /// Adds a subroutine to the code (in the data section) and pushes its size (via a tag) /// on the stack. @returns the pushsub assembly item. diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 0043f76b6..61355530e 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -231,7 +231,7 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item) { case Operation: _out << " " << instructionInfo(_item.instruction()).name; - if (_item.instruction() == solidity::Instruction::JUMP || _item.instruction() == solidity::Instruction::JUMPI) + if (_item.instruction() == Instruction::JUMP || _item.instruction() == Instruction::JUMPI) _out << "\t" << _item.getJumpTypeAsString(); break; case Push: diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h index d21be1991..95b09d47f 100644 --- a/libevmasm/AssemblyItem.h +++ b/libevmasm/AssemblyItem.h @@ -21,14 +21,13 @@ #pragma once -#include -#include +#include +#include +#include #include #include -#include -#include -#include "Exceptions.h" -using namespace dev::solidity; +#include +#include namespace dev { @@ -59,7 +58,7 @@ public: AssemblyItem(u256 _push, langutil::SourceLocation _location = langutil::SourceLocation()): AssemblyItem(Push, std::move(_push), std::move(_location)) { } - AssemblyItem(solidity::Instruction _i, langutil::SourceLocation _location = langutil::SourceLocation()): + AssemblyItem(Instruction _i, langutil::SourceLocation _location = langutil::SourceLocation()): m_type(Operation), m_instruction(_i), m_location(std::move(_location)) diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index b3ee0fe50..6dd9da6b9 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -19,17 +19,18 @@ * @date 2014 */ -#include "./Instruction.h" +#include -#include -#include #include #include +#include +#include + using namespace std; using namespace dev; -using namespace dev::solidity; +using namespace dev::eth; -std::map const dev::solidity::c_instructions = +std::map const dev::eth::c_instructions = { { "STOP", Instruction::STOP }, { "ADD", Instruction::ADD }, @@ -317,7 +318,7 @@ static std::map const c_instructionInfo = { Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Special } } }; -void dev::solidity::eachInstruction( +void dev::eth::eachInstruction( bytes const& _mem, function const& _onInstruction ) @@ -346,7 +347,7 @@ void dev::solidity::eachInstruction( } } -string dev::solidity::disassemble(bytes const& _mem) +string dev::eth::disassemble(bytes const& _mem) { stringstream ret; eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) { @@ -363,7 +364,7 @@ string dev::solidity::disassemble(bytes const& _mem) return ret.str(); } -InstructionInfo dev::solidity::instructionInfo(Instruction _inst) +InstructionInfo dev::eth::instructionInfo(Instruction _inst) { try { @@ -375,7 +376,7 @@ InstructionInfo dev::solidity::instructionInfo(Instruction _inst) } } -bool dev::solidity::isValidInstruction(Instruction _inst) +bool dev::eth::isValidInstruction(Instruction _inst) { return !!c_instructionInfo.count(_inst); } diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 539a83b01..9a0a5d4e3 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -21,14 +21,14 @@ #pragma once -#include +#include #include #include -#include "Exceptions.h" +#include namespace dev { -namespace solidity +namespace eth { DEV_SIMPLE_EXCEPTION(InvalidDeposit); diff --git a/libevmasm/RuleList.h b/libevmasm/RuleList.h index c091fc21a..f989fb801 100644 --- a/libevmasm/RuleList.h +++ b/libevmasm/RuleList.h @@ -21,19 +21,20 @@ #pragma once -#include -#include - -#include #include #include #include +#include + +#include +#include + namespace dev { -namespace solidity +namespace eth { template S divWorkaround(S const& _a, S const& _b) diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index 2a24a27ea..f21fcc6aa 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -96,14 +96,14 @@ bool SemanticInformation::isDupInstruction(AssemblyItem const& _item) { if (_item.type() != Operation) return false; - return solidity::isDupInstruction(_item.instruction()); + return dev::eth::isDupInstruction(_item.instruction()); } bool SemanticInformation::isSwapInstruction(AssemblyItem const& _item) { if (_item.type() != Operation) return false; - return solidity::isSwapInstruction(_item.instruction()); + return dev::eth::isSwapInstruction(_item.instruction()); } bool SemanticInformation::isJumpInstruction(AssemblyItem const& _item) diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index 8bdc70bec..3bdaac76c 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -53,13 +53,13 @@ struct SemanticInformation /// @returns true if the instruction can be moved or copied (together with its arguments) /// without altering the semantics. This means it cannot depend on storage or memory, /// cannot have any side-effects, but it can depend on a call-constant state of the blockchain. - static bool movable(solidity::Instruction _instruction); + static bool movable(Instruction _instruction); /// @returns true if the given instruction modifies memory. - static bool invalidatesMemory(solidity::Instruction _instruction); + static bool invalidatesMemory(Instruction _instruction); /// @returns true if the given instruction modifies storage (even indirectly). - static bool invalidatesStorage(solidity::Instruction _instruction); - static bool invalidInPureFunctions(solidity::Instruction _instruction); - static bool invalidInViewFunctions(solidity::Instruction _instruction); + static bool invalidatesStorage(Instruction _instruction); + static bool invalidInPureFunctions(Instruction _instruction); + static bool invalidInViewFunctions(Instruction _instruction); }; } diff --git a/libevmasm/SimplificationRule.h b/libevmasm/SimplificationRule.h index fa1d50691..5c752545f 100644 --- a/libevmasm/SimplificationRule.h +++ b/libevmasm/SimplificationRule.h @@ -24,7 +24,7 @@ namespace dev { -namespace solidity +namespace eth { /** diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index b9cb96151..ab150c661 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -41,6 +41,7 @@ using namespace std; using namespace dev; +using namespace dev::eth; using namespace dev::lll; void CodeFragment::finalise(CompilerState const& _cs) @@ -66,7 +67,7 @@ bool validAssemblyInstruction(string us) auto it = c_instructions.find(us); return !( it == c_instructions.end() || - solidity::isPushInstruction(it->second) + isPushInstruction(it->second) ); } @@ -76,10 +77,10 @@ bool validFunctionalInstruction(string us) auto it = c_instructions.find(us); return !( it == c_instructions.end() || - solidity::isPushInstruction(it->second) || - solidity::isDupInstruction(it->second) || - solidity::isSwapInstruction(it->second) || - it->second == solidity::Instruction::JUMPDEST + isPushInstruction(it->second) || + isDupInstruction(it->second) || + isSwapInstruction(it->second) || + it->second == Instruction::JUMPDEST ); } } diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index d5f972801..aaf03769b 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -241,7 +241,7 @@ vector NameAndTypeResolver::cleanedDeclarations( void NameAndTypeResolver::warnVariablesNamedLikeInstructions() { - for (auto const& instruction: c_instructions) + for (auto const& instruction: dev::eth::c_instructions) { string const instructionName{boost::algorithm::to_lower_copy(instruction.first)}; auto declarations = nameFromCurrentScope(instructionName, true); diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 70b907b5b..9067e13ea 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -108,11 +108,11 @@ public: private: std::function m_reportMutability; - void checkInstruction(SourceLocation _location, solidity::Instruction _instruction) + void checkInstruction(SourceLocation _location, dev::eth::Instruction _instruction) { if (eth::SemanticInformation::invalidInViewFunctions(_instruction)) m_reportMutability(StateMutability::NonPayable, _location); - else if (_instruction == Instruction::CALLVALUE) + else if (_instruction == dev::eth::Instruction::CALLVALUE) m_reportMutability(StateMutability::Payable, _location); else if (eth::SemanticInformation::invalidInPureFunctions(_instruction)) m_reportMutability(StateMutability::View, _location); diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 5c4a65323..e79821cc2 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -32,8 +32,9 @@ using namespace std; using namespace dev; +using namespace dev::eth; using namespace langutil; -using namespace solidity; +using namespace dev::solidity; void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType const& _sourceType) const { diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index ef642becf..033a05fe3 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -53,11 +53,9 @@ using namespace std; using namespace langutil; - -namespace dev -{ -namespace solidity -{ +using namespace dev::eth; +using namespace dev; +using namespace dev::solidity; void CompilerContext::addStateVariable( VariableDeclaration const& _declaration, @@ -554,6 +552,3 @@ void CompilerContext::FunctionCompilationQueue::startFunction(Declaration const& m_functionsToCompile.pop(); m_alreadyCompiledFunctions.insert(&_function); } - -} -} diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index 3744913c3..869dd0dc8 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -203,7 +203,7 @@ public: /// Append elements to the current instruction list and adjust @a m_stackOffset. CompilerContext& operator<<(eth::AssemblyItem const& _item) { m_asm->append(_item); return *this; } - CompilerContext& operator<<(Instruction _instruction) { m_asm->append(_instruction); return *this; } + CompilerContext& operator<<(dev::eth::Instruction _instruction) { m_asm->append(_instruction); return *this; } CompilerContext& operator<<(u256 const& _value) { m_asm->append(_value); return *this; } CompilerContext& operator<<(bytes const& _data) { m_asm->append(_data); return *this; } diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 3d207b8e3..8c1d1a6bc 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -31,11 +31,9 @@ using namespace std; using namespace langutil; - -namespace dev -{ -namespace solidity -{ +using namespace dev; +using namespace dev::eth; +using namespace dev::solidity; unsigned const CompilerUtils::dataStartOffset = 4; size_t const CompilerUtils::freeMemoryPointer = 64; @@ -1414,6 +1412,3 @@ unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords) return numBytes; } - -} -} diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 2e5338942..d2819e805 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -39,6 +39,7 @@ using namespace std; using namespace dev; using namespace langutil; +using namespace dev::eth; using namespace dev::solidity; namespace diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 986d6b8c7..fef178349 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -39,11 +39,10 @@ using namespace std; using namespace langutil; +using namespace dev; +using namespace dev::eth; +using namespace dev::solidity; -namespace dev -{ -namespace solidity -{ void ExpressionCompiler::compile(Expression const& _expression) { @@ -2269,6 +2268,3 @@ CompilerUtils ExpressionCompiler::utils() { return CompilerUtils(m_context); } - -} -} diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index d3fe4e439..5e0db653a 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -29,8 +29,9 @@ using namespace std; using namespace dev; +using namespace dev::eth; +using namespace dev::solidity; using namespace langutil; -using namespace solidity; StackVariable::StackVariable(CompilerContext& _compilerContext, VariableDeclaration const& _declaration): diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 679832ba6..3bc638f82 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -239,7 +239,7 @@ Json::Value collectEVMObject(eth::LinkerObject const& _object, string const* _so { Json::Value output = Json::objectValue; output["object"] = _object.toHex(); - output["opcodes"] = solidity::disassemble(_object.bytecode); + output["opcodes"] = dev::eth::disassemble(_object.bytecode); output["sourceMap"] = _sourceMap ? *_sourceMap : ""; output["linkReferences"] = formatLinkReferences(_object.linkReferences); return output; diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 33132756f..8cd11ba62 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -41,9 +41,9 @@ using namespace dev; using namespace langutil; using namespace yul; using namespace dev; -using namespace dev::solidity; -namespace { +namespace +{ set const builtinTypes{"bool", "u8", "s8", "u32", "s32", "u64", "s64", "u128", "s128", "u256", "s256"}; @@ -86,7 +86,7 @@ bool AsmAnalyzer::operator()(Label const& _label) "The use of labels is disallowed. Please use \"if\", \"switch\", \"for\" or function calls instead." ); m_info.stackHeightInfo[&_label] = m_stackHeight; - warnOnInstructions(solidity::Instruction::JUMPDEST, _label.location); + warnOnInstructions(dev::eth::Instruction::JUMPDEST, _label.location); return true; } @@ -653,7 +653,7 @@ void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _loc ); } -void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocation const& _location) +void AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocation const& _location) { // We assume that returndatacopy, returndatasize and staticcall are either all available // or all not available. @@ -677,33 +677,37 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio }; if (( - _instr == solidity::Instruction::RETURNDATACOPY || - _instr == solidity::Instruction::RETURNDATASIZE + _instr == dev::eth::Instruction::RETURNDATACOPY || + _instr == dev::eth::Instruction::RETURNDATASIZE ) && !m_evmVersion.supportsReturndata()) { errorForVM("only available for Byzantium-compatible"); } - else if (_instr == solidity::Instruction::STATICCALL && !m_evmVersion.hasStaticCall()) + else if (_instr == dev::eth::Instruction::STATICCALL && !m_evmVersion.hasStaticCall()) { errorForVM("only available for Byzantium-compatible"); } else if (( - _instr == solidity::Instruction::SHL || - _instr == solidity::Instruction::SHR || - _instr == solidity::Instruction::SAR + _instr == dev::eth::Instruction::SHL || + _instr == dev::eth::Instruction::SHR || + _instr == dev::eth::Instruction::SAR ) && !m_evmVersion.hasBitwiseShifting()) { errorForVM("only available for Constantinople-compatible"); } - else if (_instr == solidity::Instruction::CREATE2 && !m_evmVersion.hasCreate2()) + else if (_instr == dev::eth::Instruction::CREATE2 && !m_evmVersion.hasCreate2()) { errorForVM("only available for Constantinople-compatible"); } - else if (_instr == solidity::Instruction::EXTCODEHASH && !m_evmVersion.hasExtCodeHash()) + else if (_instr == dev::eth::Instruction::EXTCODEHASH && !m_evmVersion.hasExtCodeHash()) { errorForVM("only available for Constantinople-compatible"); } - else if (_instr == solidity::Instruction::JUMP || _instr == solidity::Instruction::JUMPI || _instr == solidity::Instruction::JUMPDEST) + else if ( + _instr == dev::eth::Instruction::JUMP || + _instr == dev::eth::Instruction::JUMPI || + _instr == dev::eth::Instruction::JUMPDEST + ) { if (m_dialect->flavour == AsmFlavour::Loose) m_errorReporter.error( diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index d25b3340a..ab0c718f5 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -109,7 +109,7 @@ private: Scope& scope(Block const* _block); void expectValidType(std::string const& type, langutil::SourceLocation const& _location); - void warnOnInstructions(dev::solidity::Instruction _instr, langutil::SourceLocation const& _location); + void warnOnInstructions(dev::eth::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 diff --git a/libyul/AsmData.h b/libyul/AsmData.h index 3b1eaaf8b..cedff1106 100644 --- a/libyul/AsmData.h +++ b/libyul/AsmData.h @@ -43,7 +43,7 @@ struct TypedName { langutil::SourceLocation location; YulString name; Type type; using TypedNameList = std::vector; /// Direct EVM instruction (except PUSHi and JUMPDEST) -struct Instruction { langutil::SourceLocation location; dev::solidity::Instruction instruction; }; +struct Instruction { langutil::SourceLocation location; dev::eth::Instruction instruction; }; /// Literal number or string (up to 32 bytes) enum class LiteralKind { Number, Boolean, String }; struct Literal { langutil::SourceLocation location; LiteralKind kind; YulString value; Type type; }; @@ -61,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 variableNames; std::unique_ptr value; }; /// Functional instruction, e.g. "mul(mload(20:u256), add(2:u256, x))" -struct FunctionalInstruction { langutil::SourceLocation location; dev::solidity::Instruction instruction; std::vector arguments; }; +struct FunctionalInstruction { langutil::SourceLocation location; dev::eth::Instruction instruction; std::vector arguments; }; struct FunctionCall { langutil::SourceLocation location; Identifier functionName; std::vector arguments; }; /// Statement that contains only a single expression struct ExpressionStatement { langutil::SourceLocation location; Expression expression; }; diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index 320da666b..a7787ebe4 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -34,7 +34,6 @@ using namespace std; using namespace dev; using namespace langutil; using namespace yul; -using namespace dev::solidity; shared_ptr Parser::parse(std::shared_ptr const& _scanner, bool _reuseScanner) { @@ -341,17 +340,17 @@ Expression Parser::parseExpression() } } -std::map const& Parser::instructions() +std::map const& Parser::instructions() { // Allowed instructions, lowercase names. - static map s_instructions; + static map s_instructions; if (s_instructions.empty()) { - for (auto const& instruction: solidity::c_instructions) + for (auto const& instruction: dev::eth::c_instructions) { if ( - instruction.second == solidity::Instruction::JUMPDEST || - solidity::isPushInstruction(instruction.second) + instruction.second == dev::eth::Instruction::JUMPDEST || + dev::eth::isPushInstruction(instruction.second) ) continue; string name = instruction.first; @@ -362,16 +361,16 @@ std::map const& Parser::instructions() return s_instructions; } -std::map const& Parser::instructionNames() +std::map const& Parser::instructionNames() { - static map s_instructionNames; + static map s_instructionNames; if (s_instructionNames.empty()) { for (auto const& instr: instructions()) s_instructionNames[instr.second] = instr.first; // set the ambiguous instructions to a clear default - s_instructionNames[solidity::Instruction::SELFDESTRUCT] = "selfdestruct"; - s_instructionNames[solidity::Instruction::KECCAK256] = "keccak256"; + s_instructionNames[dev::eth::Instruction::SELFDESTRUCT] = "selfdestruct"; + s_instructionNames[dev::eth::Instruction::KECCAK256] = "keccak256"; } return s_instructionNames; } @@ -401,7 +400,7 @@ Parser::ElementaryOperation Parser::parseElementaryOperation() ret = Identifier{location(), literal}; else if (m_dialect->flavour != AsmFlavour::Yul && instructions().count(literal.str())) { - dev::solidity::Instruction const& instr = instructions().at(literal.str()); + dev::eth::Instruction const& instr = instructions().at(literal.str()); ret = Instruction{location(), instr}; } else @@ -530,11 +529,11 @@ Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp) FunctionalInstruction ret; ret.instruction = instruction.instruction; ret.location = std::move(instruction.location); - solidity::Instruction instr = ret.instruction; - InstructionInfo instrInfo = instructionInfo(instr); - if (solidity::isDupInstruction(instr)) + dev::eth::Instruction instr = ret.instruction; + dev::eth::InstructionInfo instrInfo = instructionInfo(instr); + if (dev::eth::isDupInstruction(instr)) fatalParserError("DUPi instructions not allowed for functional notation"); - if (solidity::isSwapInstruction(instr)) + if (dev::eth::isSwapInstruction(instr)) fatalParserError("SWAPi instructions not allowed for functional notation"); expectToken(Token::LParen); unsigned args = unsigned(instrInfo.args); diff --git a/libyul/AsmParser.h b/libyul/AsmParser.h index 098e237b9..5985f1f93 100644 --- a/libyul/AsmParser.h +++ b/libyul/AsmParser.h @@ -71,8 +71,8 @@ protected: ForLoop parseForLoop(); /// Parses a functional expression that has to push exactly one stack element Expression parseExpression(); - static std::map const& instructions(); - static std::map const& instructionNames(); + static std::map const& instructions(); + static std::map const& instructionNames(); /// Parses an elementary operation, i.e. a literal, identifier or instruction. /// This will parse instructions even in strict mode as part of the full parser /// for FunctionalInstruction. diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index fd360bc32..a7a819440 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -36,7 +36,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; //@TODO source locations diff --git a/libyul/AsmScopeFiller.cpp b/libyul/AsmScopeFiller.cpp index e9461473b..547796d3c 100644 --- a/libyul/AsmScopeFiller.cpp +++ b/libyul/AsmScopeFiller.cpp @@ -38,7 +38,6 @@ using namespace std; using namespace dev; using namespace langutil; using namespace yul; -using namespace dev::solidity; ScopeFiller::ScopeFiller(AsmAnalysisInfo& _info, ErrorReporter& _errorReporter): m_info(_info), m_errorReporter(_errorReporter) diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 3b00fc6a2..11fd608e5 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -31,7 +31,6 @@ using namespace std; using namespace yul; using namespace dev; -using namespace dev::solidity; map CompilabilityChecker::run( shared_ptr _dialect, diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 0cc41056f..a531c0624 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -35,7 +35,7 @@ struct SourceLocation; namespace dev { -namespace solidity +namespace eth { enum class Instruction: uint8_t; } @@ -63,7 +63,7 @@ public: /// at the beginning. virtual int stackHeight() const = 0; /// Append an EVM instruction. - virtual void appendInstruction(dev::solidity::Instruction _instruction) = 0; + virtual void appendInstruction(dev::eth::Instruction _instruction) = 0; /// Append a constant. virtual void appendConstant(dev::u256 const& _constant) = 0; /// Append a label. diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index 489bfdc19..4e9776e17 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -57,7 +57,7 @@ int EthAssemblyAdapter::stackHeight() const return m_assembly.deposit(); } -void EthAssemblyAdapter::appendInstruction(solidity::Instruction _instruction) +void EthAssemblyAdapter::appendInstruction(dev::eth::Instruction _instruction) { m_assembly.append(_instruction); } @@ -94,7 +94,7 @@ void EthAssemblyAdapter::appendLinkerSymbol(std::string const& _linkerSymbol) void EthAssemblyAdapter::appendJump(int _stackDiffAfter) { - appendInstruction(solidity::Instruction::JUMP); + appendInstruction(dev::eth::Instruction::JUMP); m_assembly.adjustDeposit(_stackDiffAfter); } @@ -107,7 +107,7 @@ void EthAssemblyAdapter::appendJumpTo(LabelID _labelId, int _stackDiffAfter) void EthAssemblyAdapter::appendJumpToIf(LabelID _labelId) { appendLabelReference(_labelId); - appendInstruction(solidity::Instruction::JUMPI); + appendInstruction(dev::eth::Instruction::JUMPI); } void EthAssemblyAdapter::appendBeginsub(LabelID, int) diff --git a/libyul/backends/evm/AsmCodeGen.h b/libyul/backends/evm/AsmCodeGen.h index 9647014ce..3d2e9e191 100644 --- a/libyul/backends/evm/AsmCodeGen.h +++ b/libyul/backends/evm/AsmCodeGen.h @@ -44,7 +44,7 @@ public: explicit EthAssemblyAdapter(dev::eth::Assembly& _assembly); void setSourceLocation(langutil::SourceLocation const& _location) override; int stackHeight() const override; - void appendInstruction(dev::solidity::Instruction _instruction) override; + void appendInstruction(dev::eth::Instruction _instruction) override; void appendConstant(dev::u256 const& _constant) override; void appendLabel(LabelID _labelId) override; void appendLabelReference(LabelID _labelId) override; diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index 2cf9f0011..65d22cbd8 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -26,6 +26,7 @@ using namespace std; using namespace dev; +using namespace dev::eth; using namespace langutil; using namespace yul; @@ -43,23 +44,23 @@ void EVMAssembly::setSourceLocation(SourceLocation const&) // Ignored for now; } -void EVMAssembly::appendInstruction(solidity::Instruction _instr) +void EVMAssembly::appendInstruction(dev::eth::Instruction _instr) { m_bytecode.push_back(uint8_t(_instr)); - m_stackHeight += solidity::instructionInfo(_instr).ret - solidity::instructionInfo(_instr).args; + m_stackHeight += instructionInfo(_instr).ret - instructionInfo(_instr).args; } void EVMAssembly::appendConstant(u256 const& _constant) { bytes data = toCompactBigEndian(_constant, 1); - appendInstruction(solidity::pushInstruction(data.size())); + appendInstruction(pushInstruction(data.size())); m_bytecode += data; } void EVMAssembly::appendLabel(LabelID _labelId) { setLabelToCurrentPosition(_labelId); - appendInstruction(solidity::Instruction::JUMPDEST); + appendInstruction(dev::eth::Instruction::JUMPDEST); } void EVMAssembly::appendLabelReference(LabelID _labelId) @@ -67,7 +68,7 @@ void EVMAssembly::appendLabelReference(LabelID _labelId) solAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); // @TODO we now always use labelReferenceSize for all labels, it could be shortened // for some of them. - appendInstruction(solidity::pushInstruction(labelReferenceSize)); + appendInstruction(dev::eth::pushInstruction(labelReferenceSize)); m_labelReferences[m_bytecode.size()] = _labelId; m_bytecode += bytes(labelReferenceSize); } @@ -94,7 +95,7 @@ void EVMAssembly::appendLinkerSymbol(string const&) void EVMAssembly::appendJump(int _stackDiffAfter) { solAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); - appendInstruction(solidity::Instruction::JUMP); + appendInstruction(dev::eth::Instruction::JUMP); m_stackHeight += _stackDiffAfter; } @@ -102,7 +103,7 @@ void EVMAssembly::appendJumpTo(LabelID _labelId, int _stackDiffAfter) { if (m_evm15) { - m_bytecode.push_back(uint8_t(solidity::Instruction::JUMPTO)); + m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPTO)); appendLabelReferenceInternal(_labelId); m_stackHeight += _stackDiffAfter; } @@ -117,14 +118,14 @@ void EVMAssembly::appendJumpToIf(LabelID _labelId) { if (m_evm15) { - m_bytecode.push_back(uint8_t(solidity::Instruction::JUMPIF)); + m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPIF)); appendLabelReferenceInternal(_labelId); m_stackHeight--; } else { appendLabelReference(_labelId); - appendInstruction(solidity::Instruction::JUMPI); + appendInstruction(dev::eth::Instruction::JUMPI); } } @@ -133,7 +134,7 @@ void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments) solAssert(m_evm15, "BEGINSUB used for EVM 1.0"); solAssert(_arguments >= 0, ""); setLabelToCurrentPosition(_labelId); - m_bytecode.push_back(uint8_t(solidity::Instruction::BEGINSUB)); + m_bytecode.push_back(uint8_t(dev::eth::Instruction::BEGINSUB)); m_stackHeight += _arguments; } @@ -141,7 +142,7 @@ void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns) { solAssert(m_evm15, "JUMPSUB used for EVM 1.0"); solAssert(_arguments >= 0 && _returns >= 0, ""); - m_bytecode.push_back(uint8_t(solidity::Instruction::JUMPSUB)); + m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPSUB)); appendLabelReferenceInternal(_labelId); m_stackHeight += _returns - _arguments; } @@ -150,7 +151,7 @@ void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter) { solAssert(m_evm15, "RETURNSUB used for EVM 1.0"); solAssert(_returns >= 0, ""); - m_bytecode.push_back(uint8_t(solidity::Instruction::RETURNSUB)); + m_bytecode.push_back(uint8_t(dev::eth::Instruction::RETURNSUB)); m_stackHeight += _stackDiffAfter - _returns; } @@ -189,7 +190,7 @@ void EVMAssembly::appendLabelReferenceInternal(LabelID _labelId) void EVMAssembly::appendAssemblySize() { - appendInstruction(solidity::pushInstruction(assemblySizeReferenceSize)); + appendInstruction(dev::eth::pushInstruction(assemblySizeReferenceSize)); m_assemblySizePositions.push_back(m_bytecode.size()); m_bytecode += bytes(assemblySizeReferenceSize); } diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h index e62bc87e4..a2318aea7 100644 --- a/libyul/backends/evm/EVMAssembly.h +++ b/libyul/backends/evm/EVMAssembly.h @@ -46,7 +46,7 @@ public: /// at the beginning. int stackHeight() const override { return m_stackHeight; } /// Append an EVM instruction. - void appendInstruction(dev::solidity::Instruction _instruction) override; + void appendInstruction(dev::eth::Instruction _instruction) override; /// Append a constant. void appendConstant(dev::u256 const& _constant) override; /// Append a label. diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 15dc3800d..728162b4c 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -32,7 +32,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void VariableReferenceCounter::operator()(Identifier const& _identifier) { @@ -155,7 +154,7 @@ void CodeTransform::freeUnusedVariables() while (m_unusedStackSlots.count(m_assembly.stackHeight() - 1)) { solAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), ""); - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::Instruction::POP); --m_stackAdjustment; } } @@ -203,7 +202,7 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl) { m_context->variableStackHeights.erase(&var); m_assembly.setSourceLocation(_varDecl.location); - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::Instruction::POP); --m_stackAdjustment; } else @@ -218,8 +217,8 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl) m_context->variableStackHeights[&var] = slot; m_assembly.setSourceLocation(_varDecl.location); if (int heightDiff = variableHeightDiff(var, varName, true)) - m_assembly.appendInstruction(solidity::swapInstruction(heightDiff - 1)); - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::swapInstruction(heightDiff - 1)); + m_assembly.appendInstruction(dev::eth::Instruction::POP); --m_stackAdjustment; } } @@ -228,10 +227,10 @@ void CodeTransform::operator()(VariableDeclaration const& _varDecl) void CodeTransform::stackError(StackTooDeepError _error, int _targetStackHeight) { - m_assembly.appendInstruction(solidity::Instruction::INVALID); + m_assembly.appendInstruction(dev::eth::Instruction::INVALID); // Correct the stack. while (m_assembly.stackHeight() > _targetStackHeight) - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::Instruction::POP); while (m_assembly.stackHeight() < _targetStackHeight) m_assembly.appendConstant(u256(0)); // Store error. @@ -324,11 +323,11 @@ void CodeTransform::operator()(FunctionCall const& _call) void CodeTransform::operator()(FunctionalInstruction const& _instruction) { if (m_evm15 && ( - _instruction.instruction == solidity::Instruction::JUMP || - _instruction.instruction == solidity::Instruction::JUMPI + _instruction.instruction == dev::eth::Instruction::JUMP || + _instruction.instruction == dev::eth::Instruction::JUMPI )) { - bool const isJumpI = _instruction.instruction == solidity::Instruction::JUMPI; + bool const isJumpI = _instruction.instruction == dev::eth::Instruction::JUMPI; if (isJumpI) { solAssert(_instruction.arguments.size() == 2, ""); @@ -366,7 +365,7 @@ void CodeTransform::operator()(Identifier const& _identifier) // TODO: opportunity for optimization: Do not DUP if this is the last reference // to the top most element of the stack if (int heightDiff = variableHeightDiff(_var, _identifier.name, false)) - m_assembly.appendInstruction(solidity::dupInstruction(heightDiff)); + m_assembly.appendInstruction(dev::eth::dupInstruction(heightDiff)); else // Store something to balance the stack m_assembly.appendConstant(u256(0)); @@ -403,8 +402,8 @@ void CodeTransform::operator()(Literal const& _literal) void CodeTransform::operator()(yul::Instruction const& _instruction) { solAssert(!m_allowStackOpt, ""); - 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"); + solAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMP, "Bare JUMP instruction used for EVM1.5"); + solAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMPI, "Bare JUMPI instruction used for EVM1.5"); m_assembly.setSourceLocation(_instruction.location); m_assembly.appendInstruction(_instruction.instruction); checkStackHeight(&_instruction); @@ -414,7 +413,7 @@ void CodeTransform::operator()(If const& _if) { visitExpression(*_if.condition); m_assembly.setSourceLocation(_if.location); - m_assembly.appendInstruction(solidity::Instruction::ISZERO); + m_assembly.appendInstruction(dev::eth::Instruction::ISZERO); AbstractAssembly::LabelID end = m_assembly.newLabelId(); m_assembly.appendJumpToIf(end); (*this)(_if.body); @@ -440,8 +439,8 @@ void CodeTransform::operator()(Switch const& _switch) AbstractAssembly::LabelID bodyLabel = m_assembly.newLabelId(); caseBodies[&c] = bodyLabel; solAssert(m_assembly.stackHeight() == expressionHeight + 1, ""); - m_assembly.appendInstruction(solidity::dupInstruction(2)); - m_assembly.appendInstruction(solidity::Instruction::EQ); + m_assembly.appendInstruction(dev::eth::dupInstruction(2)); + m_assembly.appendInstruction(dev::eth::Instruction::EQ); m_assembly.appendJumpToIf(bodyLabel); } else @@ -467,7 +466,7 @@ void CodeTransform::operator()(Switch const& _switch) m_assembly.setSourceLocation(_switch.location); m_assembly.appendLabel(end); - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::Instruction::POP); checkStackHeight(&_switch); } @@ -573,12 +572,12 @@ void CodeTransform::operator()(FunctionDefinition const& _function) while (!stackLayout.empty() && stackLayout.back() != int(stackLayout.size() - 1)) if (stackLayout.back() < 0) { - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::Instruction::POP); stackLayout.pop_back(); } else { - m_assembly.appendInstruction(swapInstruction(stackLayout.size() - stackLayout.back() - 1)); + m_assembly.appendInstruction(dev::eth::swapInstruction(stackLayout.size() - stackLayout.back() - 1)); swap(stackLayout[stackLayout.back()], stackLayout.back()); } for (int i = 0; size_t(i) < stackLayout.size(); ++i) @@ -612,7 +611,7 @@ void CodeTransform::operator()(ForLoop const& _forLoop) visitExpression(*_forLoop.condition); m_assembly.setSourceLocation(_forLoop.location); - m_assembly.appendInstruction(solidity::Instruction::ISZERO); + m_assembly.appendInstruction(dev::eth::Instruction::ISZERO); m_assembly.appendJumpToIf(loopEnd); int const stackHeightBody = m_assembly.stackHeight(); @@ -732,7 +731,7 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight m_stackAdjustment++; } else - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::Instruction::POP); } int deposit = m_assembly.stackHeight() - blockStartStackHeight; @@ -754,8 +753,8 @@ void CodeTransform::generateAssignment(Identifier const& _variableName) { Scope::Variable const& _var = boost::get(*var); if (int heightDiff = variableHeightDiff(_var, _variableName.name, true)) - m_assembly.appendInstruction(solidity::swapInstruction(heightDiff - 1)); - m_assembly.appendInstruction(solidity::Instruction::POP); + m_assembly.appendInstruction(dev::eth::swapInstruction(heightDiff - 1)); + m_assembly.appendInstruction(dev::eth::Instruction::POP); decreaseReference(_variableName.name, _var); } else diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 6337bf9e3..69ae4034c 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -34,8 +34,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; - EVMDialect::EVMDialect(AsmFlavour _flavour, bool _objectAccess, langutil::EVMVersion _evmVersion): Dialect{_flavour}, m_objectAccess(_objectAccess), m_evmVersion(_evmVersion) @@ -84,7 +82,7 @@ EVMDialect::EVMDialect(AsmFlavour _flavour, bool _objectAccess, langutil::EVMVer std::function _visitArguments ) { _visitArguments(); - _assembly.appendInstruction(solidity::Instruction::CODECOPY); + _assembly.appendInstruction(dev::eth::Instruction::CODECOPY); }); } diff --git a/libyul/backends/evm/NoOutputAssembly.cpp b/libyul/backends/evm/NoOutputAssembly.cpp index 9d40a71c1..887bf2f63 100644 --- a/libyul/backends/evm/NoOutputAssembly.cpp +++ b/libyul/backends/evm/NoOutputAssembly.cpp @@ -30,25 +30,25 @@ using namespace langutil; using namespace yul; -void NoOutputAssembly::appendInstruction(solidity::Instruction _instr) +void NoOutputAssembly::appendInstruction(dev::eth::Instruction _instr) { - m_stackHeight += solidity::instructionInfo(_instr).ret - solidity::instructionInfo(_instr).args; + m_stackHeight += instructionInfo(_instr).ret - instructionInfo(_instr).args; } void NoOutputAssembly::appendConstant(u256 const&) { - appendInstruction(solidity::pushInstruction(1)); + appendInstruction(dev::eth::pushInstruction(1)); } void NoOutputAssembly::appendLabel(LabelID) { - appendInstruction(solidity::Instruction::JUMPDEST); + appendInstruction(dev::eth::Instruction::JUMPDEST); } void NoOutputAssembly::appendLabelReference(LabelID) { solAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); - appendInstruction(solidity::pushInstruction(1)); + appendInstruction(dev::eth::pushInstruction(1)); } NoOutputAssembly::LabelID NoOutputAssembly::newLabelId() @@ -69,7 +69,7 @@ void NoOutputAssembly::appendLinkerSymbol(string const&) void NoOutputAssembly::appendJump(int _stackDiffAfter) { solAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); - appendInstruction(solidity::Instruction::JUMP); + appendInstruction(dev::eth::Instruction::JUMP); m_stackHeight += _stackDiffAfter; } @@ -91,7 +91,7 @@ void NoOutputAssembly::appendJumpToIf(LabelID _labelId) else { appendLabelReference(_labelId); - appendInstruction(solidity::Instruction::JUMPI); + appendInstruction(dev::eth::Instruction::JUMPI); } } @@ -118,7 +118,7 @@ void NoOutputAssembly::appendReturnsub(int _returns, int _stackDiffAfter) void NoOutputAssembly::appendAssemblySize() { - appendInstruction(solidity::Instruction::PUSH1); + appendInstruction(dev::eth::Instruction::PUSH1); } pair, AbstractAssembly::SubID> NoOutputAssembly::createSubAssembly() @@ -129,12 +129,12 @@ pair, AbstractAssembly::SubID> NoOutputAssembly::cr void NoOutputAssembly::appendDataOffset(AbstractAssembly::SubID) { - appendInstruction(solidity::Instruction::PUSH1); + appendInstruction(dev::eth::Instruction::PUSH1); } void NoOutputAssembly::appendDataSize(AbstractAssembly::SubID) { - appendInstruction(solidity::Instruction::PUSH1); + appendInstruction(dev::eth::Instruction::PUSH1); } AbstractAssembly::SubID NoOutputAssembly::appendData(bytes const&) @@ -153,7 +153,7 @@ NoOutputEVMDialect::NoOutputEVMDialect(shared_ptr const& _copyFrom): { _visitArguments(); for (size_t i = 0; i < parameters; i++) - _assembly.appendInstruction(dev::solidity::Instruction::POP); + _assembly.appendInstruction(dev::eth::Instruction::POP); for (size_t i = 0; i < returns; i++) _assembly.appendConstant(u256(0)); diff --git a/libyul/backends/evm/NoOutputAssembly.h b/libyul/backends/evm/NoOutputAssembly.h index 78d26b5e3..ee01726a7 100644 --- a/libyul/backends/evm/NoOutputAssembly.h +++ b/libyul/backends/evm/NoOutputAssembly.h @@ -49,7 +49,7 @@ public: void setSourceLocation(langutil::SourceLocation const&) override {} int stackHeight() const override { return m_stackHeight; } - void appendInstruction(dev::solidity::Instruction _instruction) override; + void appendInstruction(dev::eth::Instruction _instruction) override; void appendConstant(dev::u256 const& _constant) override; void appendLabel(LabelID _labelId) override; void appendLabelReference(LabelID _labelId) override; diff --git a/libyul/optimiser/ASTWalker.cpp b/libyul/optimiser/ASTWalker.cpp index fe08c4313..85234c4c7 100644 --- a/libyul/optimiser/ASTWalker.cpp +++ b/libyul/optimiser/ASTWalker.cpp @@ -27,8 +27,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; - void ASTWalker::operator()(FunctionalInstruction const& _instr) { diff --git a/libyul/optimiser/Disambiguator.cpp b/libyul/optimiser/Disambiguator.cpp index cb56ee998..d1459bce8 100644 --- a/libyul/optimiser/Disambiguator.cpp +++ b/libyul/optimiser/Disambiguator.cpp @@ -28,7 +28,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; YulString Disambiguator::translateIdentifier(YulString _originalName) { diff --git a/libyul/optimiser/EquivalentFunctionCombiner.cpp b/libyul/optimiser/EquivalentFunctionCombiner.cpp index 939e63d23..c9b34436b 100644 --- a/libyul/optimiser/EquivalentFunctionCombiner.cpp +++ b/libyul/optimiser/EquivalentFunctionCombiner.cpp @@ -25,7 +25,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void EquivalentFunctionCombiner::run(Block& _ast) { diff --git a/libyul/optimiser/EquivalentFunctionDetector.cpp b/libyul/optimiser/EquivalentFunctionDetector.cpp index d3a697bdc..e4fd7f5c8 100644 --- a/libyul/optimiser/EquivalentFunctionDetector.cpp +++ b/libyul/optimiser/EquivalentFunctionDetector.cpp @@ -27,7 +27,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace solidity; void EquivalentFunctionDetector::operator()(FunctionDefinition const& _fun) { diff --git a/libyul/optimiser/ExpressionInliner.cpp b/libyul/optimiser/ExpressionInliner.cpp index 858c87337..43a6a3342 100644 --- a/libyul/optimiser/ExpressionInliner.cpp +++ b/libyul/optimiser/ExpressionInliner.cpp @@ -30,7 +30,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void ExpressionInliner::run() { diff --git a/libyul/optimiser/ExpressionJoiner.cpp b/libyul/optimiser/ExpressionJoiner.cpp index 02ac4e45e..654e9b5a8 100644 --- a/libyul/optimiser/ExpressionJoiner.cpp +++ b/libyul/optimiser/ExpressionJoiner.cpp @@ -33,7 +33,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void ExpressionJoiner::operator()(FunctionalInstruction& _instruction) { diff --git a/libyul/optimiser/ExpressionSimplifier.cpp b/libyul/optimiser/ExpressionSimplifier.cpp index 213cac977..c1764c792 100644 --- a/libyul/optimiser/ExpressionSimplifier.cpp +++ b/libyul/optimiser/ExpressionSimplifier.cpp @@ -30,8 +30,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; - void ExpressionSimplifier::visit(Expression& _expression) { diff --git a/libyul/optimiser/ExpressionSplitter.cpp b/libyul/optimiser/ExpressionSplitter.cpp index 2f80fc32c..7eb099b8e 100644 --- a/libyul/optimiser/ExpressionSplitter.cpp +++ b/libyul/optimiser/ExpressionSplitter.cpp @@ -34,7 +34,6 @@ using namespace std; using namespace dev; using namespace langutil; using namespace yul; -using namespace dev::solidity; void ExpressionSplitter::operator()(FunctionalInstruction& _instruction) { diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index 3a60a33d4..9dd09734f 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -37,7 +37,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; FullInliner::FullInliner(Block& _ast, NameDispenser& _dispenser): m_ast(_ast), m_nameDispenser(_dispenser) diff --git a/libyul/optimiser/FunctionGrouper.cpp b/libyul/optimiser/FunctionGrouper.cpp index b9852fcd9..a8d7982b4 100644 --- a/libyul/optimiser/FunctionGrouper.cpp +++ b/libyul/optimiser/FunctionGrouper.cpp @@ -28,7 +28,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void FunctionGrouper::operator()(Block& _block) diff --git a/libyul/optimiser/FunctionHoister.cpp b/libyul/optimiser/FunctionHoister.cpp index 4863b94d9..6ed930fcc 100644 --- a/libyul/optimiser/FunctionHoister.cpp +++ b/libyul/optimiser/FunctionHoister.cpp @@ -29,7 +29,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void FunctionHoister::operator()(Block& _block) { diff --git a/libyul/optimiser/MainFunction.cpp b/libyul/optimiser/MainFunction.cpp index fabbf66fd..7ece2c330 100644 --- a/libyul/optimiser/MainFunction.cpp +++ b/libyul/optimiser/MainFunction.cpp @@ -31,7 +31,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void MainFunction::operator()(Block& _block) { diff --git a/libyul/optimiser/Metrics.cpp b/libyul/optimiser/Metrics.cpp index a171f3610..b3cc3411a 100644 --- a/libyul/optimiser/Metrics.cpp +++ b/libyul/optimiser/Metrics.cpp @@ -99,12 +99,11 @@ void CodeCost::operator()(FunctionCall const& _funCall) void CodeCost::operator()(FunctionalInstruction const& _instr) { - using namespace dev::solidity; yulAssert(m_cost >= 1, "Should assign cost one in visit(Expression)."); - Tier gasPriceTier = instructionInfo(_instr.instruction).gasPriceTier; - if (gasPriceTier < Tier::VeryLow) + dev::eth::Tier gasPriceTier = dev::eth::instructionInfo(_instr.instruction).gasPriceTier; + if (gasPriceTier < dev::eth::Tier::VeryLow) m_cost -= 1; - else if (gasPriceTier < Tier::High) + else if (gasPriceTier < dev::eth::Tier::High) m_cost += 1; else m_cost += 49; diff --git a/libyul/optimiser/RedundantAssignEliminator.cpp b/libyul/optimiser/RedundantAssignEliminator.cpp index e679be540..b9740ad89 100644 --- a/libyul/optimiser/RedundantAssignEliminator.cpp +++ b/libyul/optimiser/RedundantAssignEliminator.cpp @@ -31,7 +31,6 @@ using namespace std; using namespace dev; using namespace yul; -using namespace dev::solidity; void RedundantAssignEliminator::operator()(Identifier const& _identifier) { diff --git a/libyul/optimiser/SSATransform.cpp b/libyul/optimiser/SSATransform.cpp index dd10336c6..0c38e8d82 100644 --- a/libyul/optimiser/SSATransform.cpp +++ b/libyul/optimiser/SSATransform.cpp @@ -27,12 +27,10 @@ #include - using namespace std; using namespace dev; using namespace langutil; using namespace yul; -using namespace dev::solidity; void SSATransform::operator()(Identifier& _identifier) { diff --git a/libyul/optimiser/SimplificationRules.cpp b/libyul/optimiser/SimplificationRules.cpp index c70ed2061..205b42c07 100644 --- a/libyul/optimiser/SimplificationRules.cpp +++ b/libyul/optimiser/SimplificationRules.cpp @@ -30,11 +30,12 @@ using namespace std; using namespace dev; +using namespace dev::eth; using namespace langutil; using namespace yul; -SimplificationRule const* SimplificationRules::findFirstMatch( +SimplificationRule const* SimplificationRules::findFirstMatch( Expression const& _expr, Dialect const& _dialect, map const& _ssaValues @@ -59,7 +60,7 @@ SimplificationRule const* SimplificationRules::findFirstMatch( bool SimplificationRules::isInitialized() const { - return !m_rules[uint8_t(solidity::Instruction::ADD)].empty(); + return !m_rules[uint8_t(dev::eth::Instruction::ADD)].empty(); } void SimplificationRules::addRules(vector> const& _rules) @@ -93,7 +94,7 @@ SimplificationRules::SimplificationRules() assertThrow(isInitialized(), OptimizerException, "Rule list not properly initialized."); } -Pattern::Pattern(solidity::Instruction _instruction, vector const& _arguments): +yul::Pattern::Pattern(dev::eth::Instruction _instruction, vector const& _arguments): m_kind(PatternKind::Operation), m_instruction(_instruction), m_arguments(_arguments) @@ -187,7 +188,7 @@ bool Pattern::matches( return true; } -solidity::Instruction Pattern::instruction() const +dev::eth::Instruction Pattern::instruction() const { assertThrow(m_kind == PatternKind::Operation, OptimizerException, ""); return m_instruction; diff --git a/libyul/optimiser/SimplificationRules.h b/libyul/optimiser/SimplificationRules.h index 8213a185b..40ae43260 100644 --- a/libyul/optimiser/SimplificationRules.h +++ b/libyul/optimiser/SimplificationRules.h @@ -20,7 +20,6 @@ #pragma once -#include #include #include @@ -47,7 +46,7 @@ public: /// @returns a pointer to the first matching pattern and sets the match /// groups accordingly. /// @param _ssaValues values of variables that are assigned exactly once. - static SimplificationRule const* findFirstMatch( + static dev::eth::SimplificationRule const* findFirstMatch( Expression const& _expr, Dialect const& _dialect, std::map const& _ssaValues @@ -57,13 +56,13 @@ public: /// by the constructor, but we had some issues with static initialization. bool isInitialized() const; private: - void addRules(std::vector> const& _rules); - void addRule(SimplificationRule const& _rule); + void addRules(std::vector> const& _rules); + void addRule(dev::eth::SimplificationRule const& _rule); void resetMatchGroups() { m_matchGroups.clear(); } std::map m_matchGroups; - std::vector> m_rules[256]; + std::vector> m_rules[256]; }; enum class PatternKind @@ -88,7 +87,7 @@ public: // Matches a specific constant value. Pattern(dev::u256 const& _value): m_kind(PatternKind::Constant), m_data(std::make_shared(_value)) {} // Matches a given instruction with given arguments - Pattern(dev::solidity::Instruction _instruction, std::vector const& _arguments = {}); + Pattern(dev::eth::Instruction _instruction, std::vector 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. @@ -105,7 +104,7 @@ public: /// @returns the data of the matched expression if this pattern is part of a match group. dev::u256 d() const; - dev::solidity::Instruction instruction() const; + dev::eth::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. @@ -115,7 +114,7 @@ private: Expression const& matchGroupValue() const; PatternKind m_kind = PatternKind::Any; - dev::solidity::Instruction m_instruction; ///< Only valid if m_kind is Operation + dev::eth::Instruction m_instruction; ///< Only valid if m_kind is Operation std::shared_ptr m_data; ///< Only valid if m_kind is Constant std::vector m_arguments; unsigned m_matchGroup = 0; diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp index dd94a4ad3..391e4153c 100644 --- a/libyul/optimiser/StructuralSimplifier.cpp +++ b/libyul/optimiser/StructuralSimplifier.cpp @@ -36,7 +36,7 @@ ExpressionStatement makePopExpressionStatement(langutil::SourceLocation const& _ { return {_location, FunctionalInstruction{ _location, - solidity::Instruction::POP, + dev::eth::Instruction::POP, {std::move(_expression)} }}; } @@ -105,7 +105,7 @@ OptionalStatements reduceSingleCaseSwitch(Switch& _switchStmt) std::move(_switchStmt.location), make_unique(FunctionalInstruction{ std::move(loc), - solidity::Instruction::EQ, + dev::eth::Instruction::EQ, {std::move(*switchCase.value), std::move(*_switchStmt.expression)} }), std::move(switchCase.body) diff --git a/libyul/optimiser/UnusedPruner.cpp b/libyul/optimiser/UnusedPruner.cpp index f9878e4da..4b1295a43 100644 --- a/libyul/optimiser/UnusedPruner.cpp +++ b/libyul/optimiser/UnusedPruner.cpp @@ -85,7 +85,7 @@ void UnusedPruner::operator()(Block& _block) // instead of `pop`. statement = ExpressionStatement{varDecl.location, FunctionalInstruction{ varDecl.location, - solidity::Instruction::POP, + dev::eth::Instruction::POP, {*std::move(varDecl.value)} }}; } diff --git a/lllc/main.cpp b/lllc/main.cpp index f7f45e741..b70047415 100644 --- a/lllc/main.cpp +++ b/lllc/main.cpp @@ -31,7 +31,6 @@ using namespace std; using namespace dev; -using namespace dev::solidity; using namespace dev::lll; static string const VersionString = @@ -130,7 +129,7 @@ int main(int argc, char** argv) } else if (mode == Disassemble) { - cout << disassemble(fromHex(src)) << endl; + cout << dev::eth::disassemble(fromHex(src)) << endl; } else if (mode == Binary || mode == Hex) { diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 4f825e6c8..c461d4f5e 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -284,11 +284,11 @@ void CommandLineInterface::handleBinary(string const& _contract) void CommandLineInterface::handleOpcode(string const& _contract) { if (m_args.count(g_argOutputDir)) - createFile(m_compiler->filesystemFriendlyName(_contract) + ".opcode", solidity::disassemble(m_compiler->object(_contract).bytecode)); + createFile(m_compiler->filesystemFriendlyName(_contract) + ".opcode", dev::eth::disassemble(m_compiler->object(_contract).bytecode)); else { sout() << "Opcodes: " << endl; - sout() << solidity::disassemble(m_compiler->object(_contract).bytecode); + sout() << dev::eth::disassemble(m_compiler->object(_contract).bytecode); sout() << endl; } } @@ -1001,7 +1001,7 @@ void CommandLineInterface::handleCombinedJSON() if (requests.count(g_strBinaryRuntime)) contractData[g_strBinaryRuntime] = m_compiler->runtimeObject(contractName).toHex(); if (requests.count(g_strOpcodes)) - contractData[g_strOpcodes] = solidity::disassemble(m_compiler->object(contractName).bytecode); + contractData[g_strOpcodes] = dev::eth::disassemble(m_compiler->object(contractName).bytecode); if (requests.count(g_strAsm)) contractData[g_strAsm] = m_compiler->assemblyJSON(contractName, m_sourceCodes); if (requests.count(g_strSrcMap)) diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 65ee97bc0..3795e5f4c 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -33,6 +33,7 @@ #include using namespace std; +using namespace dev::eth; using namespace langutil; namespace dev diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp index 419bc8ad8..bd058a743 100644 --- a/test/libsolidity/SolidityOptimizer.cpp +++ b/test/libsolidity/SolidityOptimizer.cpp @@ -109,7 +109,7 @@ public: bytes realCode = bytecodeSansMetadata(_bytecode); BOOST_REQUIRE_MESSAGE(!realCode.empty(), "Invalid or missing metadata in bytecode."); size_t instructions = 0; - solidity::eachInstruction(realCode, [&](Instruction _instr, u256 const&) { + dev::eth::eachInstruction(realCode, [&](Instruction _instr, u256 const&) { if (!_which || *_which == _instr) instructions++; }); diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp index 21e3e591f..770b4a791 100644 --- a/test/libyul/Common.cpp +++ b/test/libyul/Common.cpp @@ -40,7 +40,6 @@ using namespace std; using namespace langutil; using namespace yul; -using namespace dev::solidity; namespace { diff --git a/test/libyul/Inliner.cpp b/test/libyul/Inliner.cpp index 631cda086..870ea3f12 100644 --- a/test/libyul/Inliner.cpp +++ b/test/libyul/Inliner.cpp @@ -37,7 +37,6 @@ using namespace std; using namespace dev; using namespace yul; using namespace yul::test; -using namespace dev::solidity; namespace { diff --git a/test/libyul/ObjectCompilerTest.cpp b/test/libyul/ObjectCompilerTest.cpp index 4c4315733..66b0d0545 100644 --- a/test/libyul/ObjectCompilerTest.cpp +++ b/test/libyul/ObjectCompilerTest.cpp @@ -85,7 +85,7 @@ bool ObjectCompilerTest::run(ostream& _stream, string const& _linePrefix, bool c "Bytecode: " + toHex(obj.bytecode->bytecode) + "\nOpcodes: " + - boost::trim_copy(solidity::disassemble(obj.bytecode->bytecode)) + + boost::trim_copy(dev::eth::disassemble(obj.bytecode->bytecode)) + "\n"; if (m_expectation != m_obtainedResult) diff --git a/test/libyul/StackReuseCodegen.cpp b/test/libyul/StackReuseCodegen.cpp index e1a3fd8c3..d4c82b2e4 100644 --- a/test/libyul/StackReuseCodegen.cpp +++ b/test/libyul/StackReuseCodegen.cpp @@ -36,7 +36,7 @@ string assemble(string const& _input) { AssemblyStack asmStack; BOOST_REQUIRE_MESSAGE(asmStack.parseAndAnalyze("", _input), "Source did not parse: " + _input); - return dev::solidity::disassemble(asmStack.assemble(AssemblyStack::Machine::EVM, true).bytecode->bytecode); + return dev::eth::disassemble(asmStack.assemble(AssemblyStack::Machine::EVM, true).bytecode->bytecode); } } diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp index 072ae0fd2..1ad3d1aef 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.cpp @@ -92,13 +92,14 @@ void copyZeroExtended( using u512 = boost::multiprecision::number>; u256 EVMInstructionInterpreter::eval( - solidity::Instruction _instruction, + dev::eth::Instruction _instruction, vector const& _arguments ) { - using dev::solidity::Instruction; + using namespace dev::eth; + using dev::eth::Instruction; - auto info = solidity::instructionInfo(_instruction); + auto info = instructionInfo(_instruction); yulAssert(size_t(info.args) == _arguments.size(), ""); auto const& arg = _arguments; @@ -474,9 +475,9 @@ bool EVMInstructionInterpreter::logMemory(bool _write, u256 const& _offset, u256 return false; } -void EVMInstructionInterpreter::logTrace(solidity::Instruction _instruction, std::vector const& _arguments, bytes const& _data) +void EVMInstructionInterpreter::logTrace(dev::eth::Instruction _instruction, std::vector const& _arguments, bytes const& _data) { - logTrace(solidity::instructionInfo(_instruction).name, _arguments, _data); + logTrace(dev::eth::instructionInfo(_instruction).name, _arguments, _data); } void EVMInstructionInterpreter::logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments, bytes const& _data) diff --git a/test/tools/yulInterpreter/EVMInstructionInterpreter.h b/test/tools/yulInterpreter/EVMInstructionInterpreter.h index 1ce6dbd9a..bd943b634 100644 --- a/test/tools/yulInterpreter/EVMInstructionInterpreter.h +++ b/test/tools/yulInterpreter/EVMInstructionInterpreter.h @@ -28,7 +28,7 @@ namespace dev { -namespace solidity +namespace eth { enum class Instruction: uint8_t; } @@ -66,7 +66,7 @@ public: explicit EVMInstructionInterpreter(InterpreterState& _state): m_state(_state) {} - dev::u256 eval(dev::solidity::Instruction _instruction, std::vector const& _arguments); + dev::u256 eval(dev::eth::Instruction _instruction, std::vector const& _arguments); private: /// Record a memory read in the trace. Also updates m_state.msize @@ -78,7 +78,7 @@ private: bool logMemory(bool _write, dev::u256 const& _offset, dev::u256 const& _size = 32, dev::bytes const& _data = {}); - void logTrace(dev::solidity::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); + void logTrace(dev::eth::Instruction _instruction, std::vector const& _arguments = {}, dev::bytes const& _data = {}); /// Appends a log to the trace representing an instruction or similar operation by string, /// with arguments and auxiliary data (if nonempty). void logTrace(std::string const& _pseudoInstruction, std::vector const& _arguments = {}, dev::bytes const& _data = {});