mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replace uses of BOOST_THROW_EXCEPTION with assertThrow
Where appropriate.
This commit is contained in:
parent
e2627e2232
commit
991fbd2956
@ -17,6 +17,7 @@
|
||||
|
||||
#include <libdevcore/IpfsHash.h>
|
||||
|
||||
#include <libdevcore/Assertions.h>
|
||||
#include <libdevcore/Exceptions.h>
|
||||
#include <libdevcore/picosha2.h>
|
||||
#include <libdevcore/CommonData.h>
|
||||
@ -55,11 +56,7 @@ string base58Encode(bytes const& _data)
|
||||
|
||||
bytes dev::ipfsHash(string _data)
|
||||
{
|
||||
if (_data.length() >= 1024 * 256)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
DataTooLong() <<
|
||||
errinfo_comment("Ipfs hash for large (chunked) files not yet implemented.")
|
||||
);
|
||||
assertThrow(_data.length() < 1024 * 256, DataTooLong, "IPFS hash for large (chunked) files not yet implemented.");
|
||||
|
||||
bytes lengthAsVarint = varintEncoding(_data.size());
|
||||
|
||||
|
@ -323,7 +323,7 @@ Json::Value Assembly::assemblyJSON(StringMap const& _sourceCodes) const
|
||||
collection.append(createJsonValue("PUSH data", i.location().start, i.location().end, toStringInHex(i.data())));
|
||||
break;
|
||||
default:
|
||||
BOOST_THROW_EXCEPTION(InvalidOpcode());
|
||||
assertThrow(false, InvalidOpcode, "");
|
||||
}
|
||||
}
|
||||
|
||||
@ -641,7 +641,7 @@ LinkerObject const& Assembly::assemble() const
|
||||
ret.bytecode.push_back((uint8_t)Instruction::JUMPDEST);
|
||||
break;
|
||||
default:
|
||||
BOOST_THROW_EXCEPTION(InvalidOpcode());
|
||||
assertThrow(false, InvalidOpcode, "Unexpected opcode while assembling.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const
|
||||
default:
|
||||
break;
|
||||
}
|
||||
BOOST_THROW_EXCEPTION(InvalidOpcode());
|
||||
assertThrow(false, InvalidOpcode, "");
|
||||
}
|
||||
|
||||
int AssemblyItem::arguments() const
|
||||
@ -212,7 +212,7 @@ string AssemblyItem::toAssemblyText() const
|
||||
assertThrow(false, AssemblyException, "Invalid assembly item.");
|
||||
break;
|
||||
default:
|
||||
BOOST_THROW_EXCEPTION(InvalidOpcode());
|
||||
assertThrow(false, InvalidOpcode, "");
|
||||
}
|
||||
if (m_jumpType == JumpType::IntoFunction || m_jumpType == JumpType::OutOfFunction)
|
||||
{
|
||||
@ -277,7 +277,7 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item)
|
||||
_out << " ???";
|
||||
break;
|
||||
default:
|
||||
BOOST_THROW_EXCEPTION(InvalidOpcode());
|
||||
assertThrow(false, InvalidOpcode, "");
|
||||
}
|
||||
return _out;
|
||||
}
|
||||
|
@ -158,11 +158,10 @@ AssemblyItems CSECodeGenerator::generateCode(
|
||||
for (auto id: {p.first, p.second})
|
||||
if (unsigned seqNr = m_expressionClasses.representative(id).sequenceNumber)
|
||||
{
|
||||
if (seqNr < _initialSequenceNumber)
|
||||
// Invalid sequenced operation.
|
||||
// @todo quick fix for now. Proper fix needs to choose representative with higher
|
||||
// sequence number during dependency analysis.
|
||||
BOOST_THROW_EXCEPTION(StackTooDeepException());
|
||||
// Invalid sequenced operation.
|
||||
// @todo quick fix for now. Proper fix needs to choose representative with higher
|
||||
// sequence number during dependency analysis.
|
||||
assertThrow(seqNr >= _initialSequenceNumber, StackTooDeepException, "");
|
||||
sequencedExpressions.insert(make_pair(seqNr, id));
|
||||
}
|
||||
|
||||
@ -222,12 +221,9 @@ void CSECodeGenerator::addDependencies(Id _c)
|
||||
return; // we already computed the dependencies for _c
|
||||
ExpressionClasses::Expression expr = m_expressionClasses.representative(_c);
|
||||
assertThrow(expr.item, OptimizerException, "");
|
||||
if (expr.item->type() == UndefinedItem)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
// If this exception happens, we need to find a different way to generate the
|
||||
// compound expression.
|
||||
ItemNotAvailableException() << errinfo_comment("Undefined item requested but not available.")
|
||||
);
|
||||
// If this exception happens, we need to find a different way to generate the
|
||||
// compound expression.
|
||||
assertThrow(expr.item->type() != UndefinedItem, ItemNotAvailableException, "Undefined item requested but not available.");
|
||||
for (Id argument: expr.arguments)
|
||||
{
|
||||
addDependencies(argument);
|
||||
|
@ -207,11 +207,11 @@ void CodeGenerator::assemble(
|
||||
}
|
||||
catch (StackTooDeepError const& _e)
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(
|
||||
InternalCompilerError() << errinfo_comment(
|
||||
"Stack too deep when compiling inline assembly" +
|
||||
(_e.comment() ? ": " + *_e.comment() : ".")
|
||||
));
|
||||
solAssert(
|
||||
false,
|
||||
"Stack too deep when compiling inline assembly" +
|
||||
(_e.comment() ? ": " + *_e.comment() : ".")
|
||||
);
|
||||
}
|
||||
solAssert(transform.stackErrors().empty(), "Stack errors present but not thrown.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user