diff options
author | chriseth <c@ethdev.com> | 2015-06-06 07:04:55 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-06-07 18:51:15 +0800 |
commit | c2a9419e495e931a825e8146aec49ffc34e44954 (patch) | |
tree | a6674b16ad95fe108794e305abddc7981c1bed79 /LValue.cpp | |
parent | b51ef4a357b4b60fc01038b0e97280fb9ecca01e (diff) | |
download | dexon-solidity-c2a9419e495e931a825e8146aec49ffc34e44954.tar.gz dexon-solidity-c2a9419e495e931a825e8146aec49ffc34e44954.tar.zst dexon-solidity-c2a9419e495e931a825e8146aec49ffc34e44954.zip |
Improved "Stack too deep" error message.
Closes #2080.
Diffstat (limited to 'LValue.cpp')
-rw-r--r-- | LValue.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
@@ -42,8 +42,11 @@ void StackVariable::retrieveValue(SourceLocation const& _location, bool) const { unsigned stackPos = m_context.baseToCurrentStackOffset(m_baseStackOffset); if (stackPos >= 15) //@todo correct this by fetching earlier or moving to memory - BOOST_THROW_EXCEPTION(CompilerError() - << errinfo_sourceLocation(_location) << errinfo_comment("Stack too deep.")); + BOOST_THROW_EXCEPTION( + CompilerError() << + errinfo_sourceLocation(_location) << + errinfo_comment("Stack too deep, try removing local variables.") + ); for (unsigned i = 0; i < m_size; ++i) m_context << eth::dupInstruction(stackPos + 1); } @@ -52,8 +55,11 @@ void StackVariable::storeValue(Type const&, SourceLocation const& _location, boo { unsigned stackDiff = m_context.baseToCurrentStackOffset(m_baseStackOffset) - m_size + 1; if (stackDiff > 16) - BOOST_THROW_EXCEPTION(CompilerError() - << errinfo_sourceLocation(_location) << errinfo_comment("Stack too deep.")); + BOOST_THROW_EXCEPTION( + CompilerError() << + errinfo_sourceLocation(_location) << + errinfo_comment("Stack too deep, try removing local variables.") + ); else if (stackDiff > 0) for (unsigned i = 0; i < m_size; ++i) m_context << eth::swapInstruction(stackDiff) << eth::Instruction::POP; @@ -65,8 +71,11 @@ void StackVariable::setToZero(SourceLocation const& _location, bool) const { unsigned stackDiff = m_context.baseToCurrentStackOffset(m_baseStackOffset); if (stackDiff > 16) - BOOST_THROW_EXCEPTION(CompilerError() - << errinfo_sourceLocation(_location) << errinfo_comment("Stack too deep.")); + BOOST_THROW_EXCEPTION( + CompilerError() << + errinfo_sourceLocation(_location) << + errinfo_comment("Stack too deep, try removing local variables.") + ); solAssert(stackDiff >= m_size - 1, ""); for (unsigned i = 0; i < m_size; ++i) m_context << u256(0) << eth::swapInstruction(stackDiff + 1 - i) @@ -204,7 +213,10 @@ void StorageItem::storeValue(Type const& _sourceType, SourceLocation const& _loc // stack: source_ref source_off target_ref target_off member_slot_offset member_byte_offset source_member_ref source_member_off StorageItem(m_context, *memberType).retrieveValue(_location, true); // stack: source_ref source_off target_ref target_off member_offset source_value... - solAssert(4 + memberType->getSizeOnStack() <= 16, "Stack too deep."); + solAssert( + 4 + memberType->getSizeOnStack() <= 16, + "Stack too deep, try removing local varibales." + ); m_context << eth::dupInstruction(4 + memberType->getSizeOnStack()) << eth::dupInstruction(3 + memberType->getSizeOnStack()) << eth::Instruction::ADD |