mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Reuse stack helpers from tests.
This commit is contained in:
parent
1612648268
commit
55e60bd493
@ -22,6 +22,7 @@
|
||||
|
||||
#include <libyul/backends/evm/ControlFlowGraph.h>
|
||||
#include <libyul/backends/evm/ControlFlowGraphBuilder.h>
|
||||
#include <libyul/backends/evm/StackHelpers.h>
|
||||
#include <libyul/Object.h>
|
||||
#include <liblangutil/SourceReferenceFormatter.h>
|
||||
|
||||
@ -52,26 +53,6 @@ ControlFlowGraphTest::ControlFlowGraphTest(string const& _filename):
|
||||
|
||||
namespace
|
||||
{
|
||||
static std::string stackSlotToString(StackSlot const& _slot)
|
||||
{
|
||||
return std::visit(util::GenericVisitor{
|
||||
[](FunctionCallReturnLabelSlot const& _ret) -> std::string { return "RET[" + _ret.call.get().functionName.name.str() + "]"; },
|
||||
[](FunctionReturnLabelSlot const&) -> std::string { return "RET"; },
|
||||
[](VariableSlot const& _var) { return _var.variable.get().name.str(); },
|
||||
[](LiteralSlot const& _lit) { return util::toCompactHexWithPrefix(_lit.value); },
|
||||
[](TemporarySlot const& _tmp) -> std::string { return "TMP[" + _tmp.call.get().functionName.name.str() + ", " + std::to_string(_tmp.index) + "]"; },
|
||||
[](JunkSlot const&) -> std::string { return "JUNK"; }
|
||||
}, _slot);
|
||||
}
|
||||
|
||||
static std::string stackToString(Stack const& _stack)
|
||||
{
|
||||
std::string result("[ ");
|
||||
for (auto const& slot: _stack)
|
||||
result += stackSlotToString(slot) + ' ';
|
||||
result += ']';
|
||||
return result;
|
||||
}
|
||||
static std::string variableSlotToString(VariableSlot const& _slot)
|
||||
{
|
||||
return _slot.variable.get().name.str();
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <libyul/backends/evm/ControlFlowGraph.h>
|
||||
#include <libyul/backends/evm/ControlFlowGraphBuilder.h>
|
||||
#include <libyul/backends/evm/StackHelpers.h>
|
||||
#include <libyul/backends/evm/StackLayoutGenerator.h>
|
||||
#include <libyul/Object.h>
|
||||
#include <liblangutil/SourceReferenceFormatter.h>
|
||||
@ -55,26 +56,6 @@ StackLayoutGeneratorTest::StackLayoutGeneratorTest(string const& _filename):
|
||||
|
||||
namespace
|
||||
{
|
||||
static std::string stackSlotToString(StackSlot const& _slot)
|
||||
{
|
||||
return std::visit(util::GenericVisitor{
|
||||
[](FunctionCallReturnLabelSlot const& _ret) -> std::string { return "RET[" + _ret.call.get().functionName.name.str() + "]"; },
|
||||
[](FunctionReturnLabelSlot const&) -> std::string { return "RET"; },
|
||||
[](VariableSlot const& _var) { return _var.variable.get().name.str(); },
|
||||
[](LiteralSlot const& _lit) { return util::toCompactHexWithPrefix(_lit.value); },
|
||||
[](TemporarySlot const& _tmp) -> std::string { return "TMP[" + _tmp.call.get().functionName.name.str() + ", " + std::to_string(_tmp.index) + "]"; },
|
||||
[](JunkSlot const&) -> std::string { return "JUNK"; }
|
||||
}, _slot);
|
||||
}
|
||||
|
||||
static std::string stackToString(Stack const& _stack)
|
||||
{
|
||||
std::string result("[ ");
|
||||
for (auto const& slot: _stack)
|
||||
result += stackSlotToString(slot) + ' ';
|
||||
result += ']';
|
||||
return result;
|
||||
}
|
||||
static std::string variableSlotToString(VariableSlot const& _slot)
|
||||
{
|
||||
return _slot.variable.get().name.str();
|
||||
|
Loading…
Reference in New Issue
Block a user