mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into develop_060
This commit is contained in:
@@ -118,19 +118,19 @@ void EthAssemblyAdapter::appendJumpToIf(LabelID _labelId)
|
||||
void EthAssemblyAdapter::appendBeginsub(LabelID, int)
|
||||
{
|
||||
// TODO we could emulate that, though
|
||||
solAssert(false, "BEGINSUB not implemented for EVM 1.0");
|
||||
yulAssert(false, "BEGINSUB not implemented for EVM 1.0");
|
||||
}
|
||||
|
||||
void EthAssemblyAdapter::appendJumpsub(LabelID, int, int)
|
||||
{
|
||||
// TODO we could emulate that, though
|
||||
solAssert(false, "JUMPSUB not implemented for EVM 1.0");
|
||||
yulAssert(false, "JUMPSUB not implemented for EVM 1.0");
|
||||
}
|
||||
|
||||
void EthAssemblyAdapter::appendReturnsub(int, int)
|
||||
{
|
||||
// TODO we could emulate that, though
|
||||
solAssert(false, "RETURNSUB not implemented for EVM 1.0");
|
||||
yulAssert(false, "RETURNSUB not implemented for EVM 1.0");
|
||||
}
|
||||
|
||||
void EthAssemblyAdapter::appendAssemblySize()
|
||||
@@ -174,7 +174,7 @@ AbstractAssembly::SubID EthAssemblyAdapter::appendData(bytes const& _data)
|
||||
EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(eth::AssemblyItem const& _tag)
|
||||
{
|
||||
u256 id = _tag.data();
|
||||
solAssert(id <= std::numeric_limits<LabelID>::max(), "Tag id too large.");
|
||||
yulAssert(id <= std::numeric_limits<LabelID>::max(), "Tag id too large.");
|
||||
return LabelID(id);
|
||||
}
|
||||
|
||||
@@ -207,11 +207,11 @@ void CodeGenerator::assemble(
|
||||
}
|
||||
catch (StackTooDeepError const& _e)
|
||||
{
|
||||
solAssert(
|
||||
yulAssert(
|
||||
false,
|
||||
"Stack too deep when compiling inline assembly" +
|
||||
(_e.comment() ? ": " + *_e.comment() : ".")
|
||||
);
|
||||
}
|
||||
solAssert(transform.stackErrors().empty(), "Stack errors present but not thrown.");
|
||||
yulAssert(transform.stackErrors().empty(), "Stack errors present but not thrown.");
|
||||
}
|
||||
|
||||
@@ -19,11 +19,10 @@
|
||||
*/
|
||||
|
||||
#include <libyul/backends/evm/EVMAssembly.h>
|
||||
#include <libyul/Exceptions.h>
|
||||
|
||||
#include <libevmasm/Instruction.h>
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::eth;
|
||||
@@ -65,7 +64,7 @@ void EVMAssembly::appendLabel(LabelID _labelId)
|
||||
|
||||
void EVMAssembly::appendLabelReference(LabelID _labelId)
|
||||
{
|
||||
solAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode.");
|
||||
yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode.");
|
||||
// @TODO we now always use labelReferenceSize for all labels, it could be shortened
|
||||
// for some of them.
|
||||
appendInstruction(dev::eth::pushInstruction(labelReferenceSize));
|
||||
@@ -81,7 +80,7 @@ EVMAssembly::LabelID EVMAssembly::newLabelId()
|
||||
|
||||
AbstractAssembly::LabelID EVMAssembly::namedLabel(string const& _name)
|
||||
{
|
||||
solAssert(!_name.empty(), "");
|
||||
yulAssert(!_name.empty(), "");
|
||||
if (!m_namedLabels.count(_name))
|
||||
m_namedLabels[_name] = newLabelId();
|
||||
return m_namedLabels[_name];
|
||||
@@ -89,12 +88,12 @@ AbstractAssembly::LabelID EVMAssembly::namedLabel(string const& _name)
|
||||
|
||||
void EVMAssembly::appendLinkerSymbol(string const&)
|
||||
{
|
||||
solAssert(false, "Linker symbols not yet implemented.");
|
||||
yulAssert(false, "Linker symbols not yet implemented.");
|
||||
}
|
||||
|
||||
void EVMAssembly::appendJump(int _stackDiffAfter)
|
||||
{
|
||||
solAssert(!m_evm15, "Plain JUMP used for EVM 1.5");
|
||||
yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5");
|
||||
appendInstruction(dev::eth::Instruction::JUMP);
|
||||
m_stackHeight += _stackDiffAfter;
|
||||
}
|
||||
@@ -131,8 +130,8 @@ void EVMAssembly::appendJumpToIf(LabelID _labelId)
|
||||
|
||||
void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments)
|
||||
{
|
||||
solAssert(m_evm15, "BEGINSUB used for EVM 1.0");
|
||||
solAssert(_arguments >= 0, "");
|
||||
yulAssert(m_evm15, "BEGINSUB used for EVM 1.0");
|
||||
yulAssert(_arguments >= 0, "");
|
||||
setLabelToCurrentPosition(_labelId);
|
||||
m_bytecode.push_back(uint8_t(dev::eth::Instruction::BEGINSUB));
|
||||
m_stackHeight += _arguments;
|
||||
@@ -140,8 +139,8 @@ void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments)
|
||||
|
||||
void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns)
|
||||
{
|
||||
solAssert(m_evm15, "JUMPSUB used for EVM 1.0");
|
||||
solAssert(_arguments >= 0 && _returns >= 0, "");
|
||||
yulAssert(m_evm15, "JUMPSUB used for EVM 1.0");
|
||||
yulAssert(_arguments >= 0 && _returns >= 0, "");
|
||||
m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPSUB));
|
||||
appendLabelReferenceInternal(_labelId);
|
||||
m_stackHeight += _returns - _arguments;
|
||||
@@ -149,8 +148,8 @@ void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns)
|
||||
|
||||
void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter)
|
||||
{
|
||||
solAssert(m_evm15, "RETURNSUB used for EVM 1.0");
|
||||
solAssert(_returns >= 0, "");
|
||||
yulAssert(m_evm15, "RETURNSUB used for EVM 1.0");
|
||||
yulAssert(_returns >= 0, "");
|
||||
m_bytecode.push_back(uint8_t(dev::eth::Instruction::RETURNSUB));
|
||||
m_stackHeight += _stackDiffAfter - _returns;
|
||||
}
|
||||
@@ -164,9 +163,9 @@ eth::LinkerObject EVMAssembly::finalize()
|
||||
for (auto const& ref: m_labelReferences)
|
||||
{
|
||||
size_t referencePos = ref.first;
|
||||
solAssert(m_labelPositions.count(ref.second), "");
|
||||
yulAssert(m_labelPositions.count(ref.second), "");
|
||||
size_t labelPos = m_labelPositions.at(ref.second);
|
||||
solAssert(labelPos != size_t(-1), "Undefined but allocated label used.");
|
||||
yulAssert(labelPos != size_t(-1), "Undefined but allocated label used.");
|
||||
updateReference(referencePos, labelReferenceSize, u256(labelPos));
|
||||
}
|
||||
|
||||
@@ -177,8 +176,8 @@ eth::LinkerObject EVMAssembly::finalize()
|
||||
|
||||
void EVMAssembly::setLabelToCurrentPosition(LabelID _labelId)
|
||||
{
|
||||
solAssert(m_labelPositions.count(_labelId), "Label not found.");
|
||||
solAssert(m_labelPositions[_labelId] == size_t(-1), "Label already set.");
|
||||
yulAssert(m_labelPositions.count(_labelId), "Label not found.");
|
||||
yulAssert(m_labelPositions[_labelId] == size_t(-1), "Label already set.");
|
||||
m_labelPositions[_labelId] = m_bytecode.size();
|
||||
}
|
||||
|
||||
@@ -197,29 +196,29 @@ void EVMAssembly::appendAssemblySize()
|
||||
|
||||
pair<shared_ptr<AbstractAssembly>, AbstractAssembly::SubID> EVMAssembly::createSubAssembly()
|
||||
{
|
||||
solAssert(false, "Sub assemblies not implemented.");
|
||||
yulAssert(false, "Sub assemblies not implemented.");
|
||||
return {};
|
||||
}
|
||||
|
||||
void EVMAssembly::appendDataOffset(AbstractAssembly::SubID)
|
||||
{
|
||||
solAssert(false, "Data not implemented.");
|
||||
yulAssert(false, "Data not implemented.");
|
||||
}
|
||||
|
||||
void EVMAssembly::appendDataSize(AbstractAssembly::SubID)
|
||||
{
|
||||
solAssert(false, "Data not implemented.");
|
||||
yulAssert(false, "Data not implemented.");
|
||||
}
|
||||
|
||||
AbstractAssembly::SubID EVMAssembly::appendData(bytes const&)
|
||||
{
|
||||
solAssert(false, "Data not implemented.");
|
||||
yulAssert(false, "Data not implemented.");
|
||||
}
|
||||
|
||||
void EVMAssembly::updateReference(size_t pos, size_t size, u256 value)
|
||||
{
|
||||
solAssert(m_bytecode.size() >= size && pos <= m_bytecode.size() - size, "");
|
||||
solAssert(value < (u256(1) << (8 * size)), "");
|
||||
yulAssert(m_bytecode.size() >= size && pos <= m_bytecode.size() - size, "");
|
||||
yulAssert(value < (u256(1) << (8 * size)), "");
|
||||
for (size_t i = 0; i < size; i++)
|
||||
m_bytecode[pos + i] = uint8_t((value >> (8 * (size - i - 1))) & 0xff);
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ void VariableReferenceCounter::operator()(FunctionDefinition const& _function)
|
||||
{
|
||||
Scope* originalScope = m_scope;
|
||||
|
||||
solAssert(m_info.virtualBlocks.at(&_function), "");
|
||||
yulAssert(m_info.virtualBlocks.at(&_function), "");
|
||||
m_scope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get();
|
||||
solAssert(m_scope, "Variable scope does not exist.");
|
||||
yulAssert(m_scope, "Variable scope does not exist.");
|
||||
|
||||
for (auto const& v: _function.returnVariables)
|
||||
increaseRefIfFound(v.name);
|
||||
@@ -131,7 +131,7 @@ void CodeTransform::decreaseReference(YulString, Scope::Variable const& _var)
|
||||
return;
|
||||
|
||||
unsigned& ref = m_context->variableReferences.at(&_var);
|
||||
solAssert(ref >= 1, "");
|
||||
yulAssert(ref >= 1, "");
|
||||
--ref;
|
||||
if (ref == 0)
|
||||
m_variablesScheduledForDeletion.insert(&_var);
|
||||
@@ -157,7 +157,7 @@ void CodeTransform::freeUnusedVariables()
|
||||
|
||||
while (m_unusedStackSlots.count(m_assembly.stackHeight() - 1))
|
||||
{
|
||||
solAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), "");
|
||||
yulAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), "");
|
||||
m_assembly.appendInstruction(dev::eth::Instruction::POP);
|
||||
--m_stackAdjustment;
|
||||
}
|
||||
@@ -165,8 +165,8 @@ void CodeTransform::freeUnusedVariables()
|
||||
|
||||
void CodeTransform::deleteVariable(Scope::Variable const& _var)
|
||||
{
|
||||
solAssert(m_allowStackOpt, "");
|
||||
solAssert(m_context->variableStackHeights.count(&_var) > 0, "");
|
||||
yulAssert(m_allowStackOpt, "");
|
||||
yulAssert(m_context->variableStackHeights.count(&_var) > 0, "");
|
||||
m_unusedStackSlots.insert(m_context->variableStackHeights[&_var]);
|
||||
m_context->variableStackHeights.erase(&_var);
|
||||
m_context->variableReferences.erase(&_var);
|
||||
@@ -175,7 +175,7 @@ void CodeTransform::deleteVariable(Scope::Variable const& _var)
|
||||
|
||||
void CodeTransform::operator()(VariableDeclaration const& _varDecl)
|
||||
{
|
||||
solAssert(m_scope, "");
|
||||
yulAssert(m_scope, "");
|
||||
|
||||
int const numVariables = _varDecl.variables.size();
|
||||
int height = m_assembly.stackHeight();
|
||||
@@ -261,7 +261,7 @@ void CodeTransform::operator()(ExpressionStatement const& _statement)
|
||||
|
||||
void CodeTransform::operator()(FunctionCall const& _call)
|
||||
{
|
||||
solAssert(m_scope, "");
|
||||
yulAssert(m_scope, "");
|
||||
|
||||
if (BuiltinFunctionForEVM const* builtin = m_dialect.builtin(_call.functionName.name))
|
||||
{
|
||||
@@ -283,13 +283,13 @@ void CodeTransform::operator()(FunctionCall const& _call)
|
||||
}
|
||||
|
||||
Scope::Function* function = nullptr;
|
||||
solAssert(m_scope->lookup(_call.functionName.name, GenericVisitor{
|
||||
[=](Scope::Variable&) { solAssert(false, "Expected function name."); },
|
||||
[=](Scope::Label&) { solAssert(false, "Expected function name."); },
|
||||
yulAssert(m_scope->lookup(_call.functionName.name, GenericVisitor{
|
||||
[=](Scope::Variable&) { yulAssert(false, "Expected function name."); },
|
||||
[=](Scope::Label&) { yulAssert(false, "Expected function name."); },
|
||||
[&](Scope::Function& _function) { function = &_function; }
|
||||
}), "Function name not found.");
|
||||
solAssert(function, "");
|
||||
solAssert(function->arguments.size() == _call.arguments.size(), "");
|
||||
yulAssert(function, "");
|
||||
yulAssert(function->arguments.size() == _call.arguments.size(), "");
|
||||
for (auto const& arg: _call.arguments | boost::adaptors::reversed)
|
||||
visitExpression(arg);
|
||||
m_assembly.setSourceLocation(_call.location);
|
||||
@@ -309,7 +309,7 @@ void CodeTransform::operator()(Identifier const& _identifier)
|
||||
{
|
||||
m_assembly.setSourceLocation(_identifier.location);
|
||||
// First search internals, then externals.
|
||||
solAssert(m_scope, "");
|
||||
yulAssert(m_scope, "");
|
||||
if (m_scope->lookup(_identifier.name, GenericVisitor{
|
||||
[=](Scope::Variable& _var)
|
||||
{
|
||||
@@ -328,13 +328,13 @@ void CodeTransform::operator()(Identifier const& _identifier)
|
||||
},
|
||||
[=](Scope::Function&)
|
||||
{
|
||||
solAssert(false, "Function not removed during desugaring.");
|
||||
yulAssert(false, "Function not removed during desugaring.");
|
||||
}
|
||||
}))
|
||||
{
|
||||
return;
|
||||
}
|
||||
solAssert(
|
||||
yulAssert(
|
||||
m_identifierAccess.generateCode,
|
||||
"Identifier not found and no external access available."
|
||||
);
|
||||
@@ -352,9 +352,9 @@ void CodeTransform::operator()(Literal const& _literal)
|
||||
|
||||
void CodeTransform::operator()(yul::Instruction const& _instruction)
|
||||
{
|
||||
solAssert(!m_allowStackOpt, "");
|
||||
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");
|
||||
yulAssert(!m_allowStackOpt, "");
|
||||
yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMP, "Bare JUMP instruction used for EVM1.5");
|
||||
yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMPI, "Bare JUMPI instruction used for EVM1.5");
|
||||
m_assembly.setSourceLocation(_instruction.location);
|
||||
m_assembly.appendInstruction(_instruction.instruction);
|
||||
checkStackHeight(&_instruction);
|
||||
@@ -389,7 +389,7 @@ void CodeTransform::operator()(Switch const& _switch)
|
||||
m_assembly.setSourceLocation(c.location);
|
||||
AbstractAssembly::LabelID bodyLabel = m_assembly.newLabelId();
|
||||
caseBodies[&c] = bodyLabel;
|
||||
solAssert(m_assembly.stackHeight() == expressionHeight + 1, "");
|
||||
yulAssert(m_assembly.stackHeight() == expressionHeight + 1, "");
|
||||
m_assembly.appendInstruction(dev::eth::dupInstruction(2));
|
||||
m_assembly.appendInstruction(dev::eth::Instruction::EQ);
|
||||
m_assembly.appendJumpToIf(bodyLabel);
|
||||
@@ -423,15 +423,15 @@ void CodeTransform::operator()(Switch const& _switch)
|
||||
|
||||
void CodeTransform::operator()(FunctionDefinition const& _function)
|
||||
{
|
||||
solAssert(m_scope, "");
|
||||
solAssert(m_scope->identifiers.count(_function.name), "");
|
||||
yulAssert(m_scope, "");
|
||||
yulAssert(m_scope->identifiers.count(_function.name), "");
|
||||
Scope::Function& function = std::get<Scope::Function>(m_scope->identifiers.at(_function.name));
|
||||
|
||||
int const localStackAdjustment = m_evm15 ? 0 : 1;
|
||||
int height = localStackAdjustment;
|
||||
solAssert(m_info.scopes.at(&_function.body), "");
|
||||
yulAssert(m_info.scopes.at(&_function.body), "");
|
||||
Scope* varScope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get();
|
||||
solAssert(varScope, "");
|
||||
yulAssert(varScope, "");
|
||||
for (auto const& v: _function.parameters | boost::adaptors::reversed)
|
||||
{
|
||||
auto& var = std::get<Scope::Variable>(varScope->identifiers.at(v.name));
|
||||
@@ -535,7 +535,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
||||
swap(stackLayout[stackLayout.back()], stackLayout.back());
|
||||
}
|
||||
for (int i = 0; size_t(i) < stackLayout.size(); ++i)
|
||||
solAssert(i == stackLayout[i], "Error reshuffling stack.");
|
||||
yulAssert(i == stackLayout[i], "Error reshuffling stack.");
|
||||
}
|
||||
}
|
||||
if (m_evm15)
|
||||
@@ -647,15 +647,15 @@ AbstractAssembly::LabelID CodeTransform::labelFromIdentifier(Identifier const& _
|
||||
{
|
||||
AbstractAssembly::LabelID label = AbstractAssembly::LabelID(-1);
|
||||
if (!m_scope->lookup(_identifier.name, GenericVisitor{
|
||||
[=](Scope::Variable&) { solAssert(false, "Expected label"); },
|
||||
[=](Scope::Variable&) { yulAssert(false, "Expected label"); },
|
||||
[&](Scope::Label& _label)
|
||||
{
|
||||
label = labelID(_label);
|
||||
},
|
||||
[=](Scope::Function&) { solAssert(false, "Expected label"); }
|
||||
[=](Scope::Function&) { yulAssert(false, "Expected label"); }
|
||||
}))
|
||||
{
|
||||
solAssert(false, "Identifier not found.");
|
||||
yulAssert(false, "Identifier not found.");
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@@ -723,15 +723,15 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight
|
||||
freeUnusedVariables();
|
||||
|
||||
// pop variables
|
||||
solAssert(m_info.scopes.at(&_block).get() == m_scope, "");
|
||||
yulAssert(m_info.scopes.at(&_block).get() == m_scope, "");
|
||||
for (auto const& id: m_scope->identifiers)
|
||||
if (holds_alternative<Scope::Variable>(id.second))
|
||||
{
|
||||
Scope::Variable const& var = std::get<Scope::Variable>(id.second);
|
||||
if (m_allowStackOpt)
|
||||
{
|
||||
solAssert(!m_context->variableStackHeights.count(&var), "");
|
||||
solAssert(!m_context->variableReferences.count(&var), "");
|
||||
yulAssert(!m_context->variableStackHeights.count(&var), "");
|
||||
yulAssert(!m_context->variableReferences.count(&var), "");
|
||||
m_stackAdjustment++;
|
||||
}
|
||||
else
|
||||
@@ -739,20 +739,20 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight
|
||||
}
|
||||
|
||||
int deposit = m_assembly.stackHeight() - blockStartStackHeight;
|
||||
solAssert(deposit == 0, "Invalid stack height at end of block: " + to_string(deposit));
|
||||
yulAssert(deposit == 0, "Invalid stack height at end of block: " + to_string(deposit));
|
||||
checkStackHeight(&_block);
|
||||
}
|
||||
|
||||
void CodeTransform::generateMultiAssignment(vector<Identifier> const& _variableNames)
|
||||
{
|
||||
solAssert(m_scope, "");
|
||||
yulAssert(m_scope, "");
|
||||
for (auto const& variableName: _variableNames | boost::adaptors::reversed)
|
||||
generateAssignment(variableName);
|
||||
}
|
||||
|
||||
void CodeTransform::generateAssignment(Identifier const& _variableName)
|
||||
{
|
||||
solAssert(m_scope, "");
|
||||
yulAssert(m_scope, "");
|
||||
if (auto var = m_scope->lookup(_variableName.name))
|
||||
{
|
||||
Scope::Variable const& _var = std::get<Scope::Variable>(*var);
|
||||
@@ -763,7 +763,7 @@ void CodeTransform::generateAssignment(Identifier const& _variableName)
|
||||
}
|
||||
else
|
||||
{
|
||||
solAssert(
|
||||
yulAssert(
|
||||
m_identifierAccess.generateCode,
|
||||
"Identifier not found and no external access available."
|
||||
);
|
||||
@@ -773,9 +773,9 @@ void CodeTransform::generateAssignment(Identifier const& _variableName)
|
||||
|
||||
int CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString _varName, bool _forSwap)
|
||||
{
|
||||
solAssert(m_context->variableStackHeights.count(&_var), "");
|
||||
yulAssert(m_context->variableStackHeights.count(&_var), "");
|
||||
int heightDiff = m_assembly.stackHeight() - m_context->variableStackHeights[&_var];
|
||||
solAssert(heightDiff > (_forSwap ? 1 : 0), "Negative stack difference for variable.");
|
||||
yulAssert(heightDiff > (_forSwap ? 1 : 0), "Negative stack difference for variable.");
|
||||
int limit = _forSwap ? 17 : 16;
|
||||
if (heightDiff > limit)
|
||||
{
|
||||
@@ -794,15 +794,15 @@ int CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString _va
|
||||
|
||||
void CodeTransform::expectDeposit(int _deposit, int _oldHeight) const
|
||||
{
|
||||
solAssert(m_assembly.stackHeight() == _oldHeight + _deposit, "Invalid stack deposit.");
|
||||
yulAssert(m_assembly.stackHeight() == _oldHeight + _deposit, "Invalid stack deposit.");
|
||||
}
|
||||
|
||||
void CodeTransform::checkStackHeight(void const* _astElement) const
|
||||
{
|
||||
solAssert(m_info.stackHeightInfo.count(_astElement), "Stack height for AST element not found.");
|
||||
yulAssert(m_info.stackHeightInfo.count(_astElement), "Stack height for AST element not found.");
|
||||
int stackHeightInAnalysis = m_info.stackHeightInfo.at(_astElement);
|
||||
int stackHeightInCodegen = m_assembly.stackHeight() - m_stackAdjustment;
|
||||
solAssert(
|
||||
yulAssert(
|
||||
stackHeightInAnalysis == stackHeightInCodegen,
|
||||
"Stack height mismatch between analysis and code generation phase: Analysis: " +
|
||||
to_string(stackHeightInAnalysis) +
|
||||
|
||||
@@ -19,11 +19,10 @@
|
||||
*/
|
||||
|
||||
#include <libyul/backends/evm/NoOutputAssembly.h>
|
||||
#include <libyul/Exceptions.h>
|
||||
|
||||
#include <libevmasm/Instruction.h>
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
@@ -47,7 +46,7 @@ void NoOutputAssembly::appendLabel(LabelID)
|
||||
|
||||
void NoOutputAssembly::appendLabelReference(LabelID)
|
||||
{
|
||||
solAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode.");
|
||||
yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode.");
|
||||
appendInstruction(dev::eth::pushInstruction(1));
|
||||
}
|
||||
|
||||
@@ -63,12 +62,12 @@ AbstractAssembly::LabelID NoOutputAssembly::namedLabel(string const&)
|
||||
|
||||
void NoOutputAssembly::appendLinkerSymbol(string const&)
|
||||
{
|
||||
solAssert(false, "Linker symbols not yet implemented.");
|
||||
yulAssert(false, "Linker symbols not yet implemented.");
|
||||
}
|
||||
|
||||
void NoOutputAssembly::appendJump(int _stackDiffAfter)
|
||||
{
|
||||
solAssert(!m_evm15, "Plain JUMP used for EVM 1.5");
|
||||
yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5");
|
||||
appendInstruction(dev::eth::Instruction::JUMP);
|
||||
m_stackHeight += _stackDiffAfter;
|
||||
}
|
||||
@@ -97,22 +96,22 @@ void NoOutputAssembly::appendJumpToIf(LabelID _labelId)
|
||||
|
||||
void NoOutputAssembly::appendBeginsub(LabelID, int _arguments)
|
||||
{
|
||||
solAssert(m_evm15, "BEGINSUB used for EVM 1.0");
|
||||
solAssert(_arguments >= 0, "");
|
||||
yulAssert(m_evm15, "BEGINSUB used for EVM 1.0");
|
||||
yulAssert(_arguments >= 0, "");
|
||||
m_stackHeight += _arguments;
|
||||
}
|
||||
|
||||
void NoOutputAssembly::appendJumpsub(LabelID, int _arguments, int _returns)
|
||||
{
|
||||
solAssert(m_evm15, "JUMPSUB used for EVM 1.0");
|
||||
solAssert(_arguments >= 0 && _returns >= 0, "");
|
||||
yulAssert(m_evm15, "JUMPSUB used for EVM 1.0");
|
||||
yulAssert(_arguments >= 0 && _returns >= 0, "");
|
||||
m_stackHeight += _returns - _arguments;
|
||||
}
|
||||
|
||||
void NoOutputAssembly::appendReturnsub(int _returns, int _stackDiffAfter)
|
||||
{
|
||||
solAssert(m_evm15, "RETURNSUB used for EVM 1.0");
|
||||
solAssert(_returns >= 0, "");
|
||||
yulAssert(m_evm15, "RETURNSUB used for EVM 1.0");
|
||||
yulAssert(_returns >= 0, "");
|
||||
m_stackHeight += _stackDiffAfter - _returns;
|
||||
}
|
||||
|
||||
@@ -123,7 +122,7 @@ void NoOutputAssembly::appendAssemblySize()
|
||||
|
||||
pair<shared_ptr<AbstractAssembly>, AbstractAssembly::SubID> NoOutputAssembly::createSubAssembly()
|
||||
{
|
||||
solAssert(false, "Sub assemblies not implemented.");
|
||||
yulAssert(false, "Sub assemblies not implemented.");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user