mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Review comments and cleanup.
This commit is contained in:
parent
3f1f0316c6
commit
83bf34c571
@ -654,6 +654,8 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
|
|||||||
else if (!var->type()->isValueType())
|
else if (!var->type()->isValueType())
|
||||||
valueSize = 1;
|
valueSize = 1;
|
||||||
else
|
else
|
||||||
|
// We cannot use `sizeOnStack()` here because we do not insert the value
|
||||||
|
// into inline assembly but rather the storage location.
|
||||||
valueSize = 2; // slot number, intra slot offset
|
valueSize = 2; // slot number, intra slot offset
|
||||||
}
|
}
|
||||||
else if (auto contract = dynamic_cast<ContractDefinition const*>(declaration))
|
else if (auto contract = dynamic_cast<ContractDefinition const*>(declaration))
|
||||||
|
@ -591,7 +591,9 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
solAssert(false, "Invalid declaration type.");
|
solAssert(false, "Invalid declaration type.");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// lvalue context
|
// lvalue context
|
||||||
auto variable = dynamic_cast<VariableDeclaration const*>(decl);
|
auto variable = dynamic_cast<VariableDeclaration const*>(decl);
|
||||||
solAssert(
|
solAssert(
|
||||||
@ -606,7 +608,8 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
|||||||
errinfo_sourceLocation(_inlineAssembly.location()) <<
|
errinfo_sourceLocation(_inlineAssembly.location()) <<
|
||||||
errinfo_comment("Stack too deep, try removing local variables.")
|
errinfo_comment("Stack too deep, try removing local variables.")
|
||||||
);
|
);
|
||||||
for (unsigned i = 0; i < size; ++i) {
|
for (unsigned i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
_assembly.append(swapInstruction(stackDiff));
|
_assembly.append(swapInstruction(stackDiff));
|
||||||
_assembly.append(Instruction::POP);
|
_assembly.append(Instruction::POP);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ bool AsmAnalyzer::operator()(assembly::FunctionCall const& _funCall)
|
|||||||
if (!expectDeposit(1, stackHeight, locationOf(arg)))
|
if (!expectDeposit(1, stackHeight, locationOf(arg)))
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
m_stackHeight += returns - arguments;
|
m_stackHeight += int(returns) - int(arguments);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,9 +255,8 @@ bool AsmAnalyzer::operator()(Block const& _block)
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
m_currentScope = &scope(&_block);
|
m_currentScope = &scope(&_block);
|
||||||
|
|
||||||
int const virtualVariablesInNextBlock = m_virtualVariablesInNextBlock;
|
int const initialStackHeight = m_stackHeight - m_virtualVariablesInNextBlock;
|
||||||
m_virtualVariablesInNextBlock = 0;
|
m_virtualVariablesInNextBlock = 0;
|
||||||
int const initialStackHeight = m_stackHeight;
|
|
||||||
|
|
||||||
for (auto const& s: _block.statements)
|
for (auto const& s: _block.statements)
|
||||||
if (!boost::apply_visitor(*this, s))
|
if (!boost::apply_visitor(*this, s))
|
||||||
@ -267,7 +266,7 @@ bool AsmAnalyzer::operator()(Block const& _block)
|
|||||||
if (identifier.second.type() == typeid(Scope::Variable))
|
if (identifier.second.type() == typeid(Scope::Variable))
|
||||||
--m_stackHeight;
|
--m_stackHeight;
|
||||||
|
|
||||||
int const stackDiff = m_stackHeight - initialStackHeight + virtualVariablesInNextBlock;
|
int const stackDiff = m_stackHeight - initialStackHeight;
|
||||||
if (stackDiff != 0)
|
if (stackDiff != 0)
|
||||||
{
|
{
|
||||||
m_errors.push_back(make_shared<Error>(
|
m_errors.push_back(make_shared<Error>(
|
||||||
|
@ -82,8 +82,9 @@ private:
|
|||||||
bool expectDeposit(int _deposit, int _oldHeight, SourceLocation const& _location);
|
bool expectDeposit(int _deposit, int _oldHeight, SourceLocation const& _location);
|
||||||
Scope& scope(assembly::Block const* _block);
|
Scope& scope(assembly::Block const* _block);
|
||||||
|
|
||||||
/// Number of excess stack slots generated by function arguments to take into account for
|
/// This is used when we enter the body of a function definition. There, the parameters
|
||||||
/// next block.
|
/// and return parameters appear as variables which are already on the stack before
|
||||||
|
/// we enter the block.
|
||||||
int m_virtualVariablesInNextBlock = 0;
|
int m_virtualVariablesInNextBlock = 0;
|
||||||
int m_stackHeight = 0;
|
int m_stackHeight = 0;
|
||||||
ExternalIdentifierAccess::Resolver const& m_resolver;
|
ExternalIdentifierAccess::Resolver const& m_resolver;
|
||||||
|
Loading…
Reference in New Issue
Block a user