MCPcopy Create free account
hub / github.com/argotorg/solidity / moveToStackVariable

Method moveToStackVariable

libsolidity/codegen/CompilerUtils.cpp:1420–1434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1418}
1419
1420void CompilerUtils::moveToStackVariable(VariableDeclaration const& _variable)
1421{
1422 unsigned const stackPosition = m_context.baseToCurrentStackOffset(m_context.baseStackOffsetOfVariable(_variable));
1423 unsigned const size = _variable.annotation().type->sizeOnStack();
1424 solAssert(stackPosition >= size, "Variable size and position mismatch.");
1425 // move variable starting from its top end in the stack
1426 if (stackPosition - size + 1 > m_context.reachableStackDepth())
1427 BOOST_THROW_EXCEPTION(
1428 StackTooDeepError() <<
1429 errinfo_sourceLocation(_variable.location()) <<
1430 util::errinfo_comment(util::stackTooDeepString)
1431 );
1432 for (unsigned i = 0; i < size; ++i)
1433 m_context << swapInstruction(stackPosition - size + 1) << Instruction::POP;
1434}
1435
1436void CompilerUtils::copyToStackTop(unsigned _stackDepth, unsigned _itemSize)
1437{

Callers 1

visitMethod · 0.80

Calls 7

swapInstructionFunction · 0.85
StackTooDeepErrorClass · 0.50
sizeOnStackMethod · 0.45
reachableStackDepthMethod · 0.45
locationMethod · 0.45

Tested by

no test coverage detected