mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replace raw throw with BOOST_THROW_EXCEPTION.
This commit is contained in:
parent
5c6633f975
commit
c44bb7e7ef
@ -43,7 +43,7 @@ SemVerVersion::SemVerVersion(string const& _versionString)
|
||||
if (level < 2)
|
||||
{
|
||||
if (i == end || *i != '.')
|
||||
throw SemVerError();
|
||||
BOOST_THROW_EXCEPTION(SemVerError());
|
||||
else
|
||||
++i;
|
||||
}
|
||||
@ -61,7 +61,7 @@ SemVerVersion::SemVerVersion(string const& _versionString)
|
||||
build = string(buildStart, i);
|
||||
}
|
||||
if (i != end)
|
||||
throw SemVerError();
|
||||
BOOST_THROW_EXCEPTION(SemVerError());
|
||||
}
|
||||
|
||||
bool SemVerMatchExpression::MatchComponent::matches(SemVerVersion const& _version) const
|
||||
@ -162,7 +162,7 @@ optional<SemVerMatchExpression> SemVerMatchExpressionParser::parse()
|
||||
if (m_pos >= m_tokens.size())
|
||||
break;
|
||||
if (currentToken() != Token::Or)
|
||||
throw SemVerError();
|
||||
BOOST_THROW_EXCEPTION(SemVerError());
|
||||
nextToken();
|
||||
}
|
||||
}
|
||||
@ -256,14 +256,14 @@ unsigned SemVerMatchExpressionParser::parseVersionPart()
|
||||
{
|
||||
c = currentChar();
|
||||
if (v * 10 < v || v * 10 + static_cast<unsigned>(c - '0') < v * 10)
|
||||
throw SemVerError();
|
||||
BOOST_THROW_EXCEPTION(SemVerError());
|
||||
v = v * 10 + static_cast<unsigned>(c - '0');
|
||||
nextChar();
|
||||
}
|
||||
return v;
|
||||
}
|
||||
else
|
||||
throw SemVerError();
|
||||
BOOST_THROW_EXCEPTION(SemVerError());
|
||||
}
|
||||
|
||||
char SemVerMatchExpressionParser::currentChar() const
|
||||
|
@ -34,7 +34,7 @@
|
||||
namespace solidity::langutil
|
||||
{
|
||||
|
||||
class SemVerError: util::Exception
|
||||
class SemVerError: public util::Exception
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -221,7 +221,7 @@ void IRGeneratorForStatements::generate(Block const& _block)
|
||||
{
|
||||
if (!boost::get_error_info<langutil::errinfo_sourceLocation>(_error))
|
||||
_error << langutil::errinfo_sourceLocation(m_currentLocation);
|
||||
throw _error;
|
||||
BOOST_THROW_EXCEPTION(_error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ void IRGeneratorForStatements::initializeStateVar(VariableDeclaration const& _va
|
||||
{
|
||||
if (!boost::get_error_info<langutil::errinfo_sourceLocation>(_error))
|
||||
_error << langutil::errinfo_sourceLocation(m_currentLocation);
|
||||
throw _error;
|
||||
BOOST_THROW_EXCEPTION(_error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ void IRGeneratorForStatements::initializeLocalVar(VariableDeclaration const& _va
|
||||
{
|
||||
if (!boost::get_error_info<langutil::errinfo_sourceLocation>(_error))
|
||||
_error << langutil::errinfo_sourceLocation(m_currentLocation);
|
||||
throw _error;
|
||||
BOOST_THROW_EXCEPTION(_error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ IRVariable IRGeneratorForStatements::evaluateExpression(Expression const& _expre
|
||||
{
|
||||
if (!boost::get_error_info<langutil::errinfo_sourceLocation>(_error))
|
||||
_error << langutil::errinfo_sourceLocation(m_currentLocation);
|
||||
throw _error;
|
||||
BOOST_THROW_EXCEPTION(_error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,7 +333,7 @@ string IRGeneratorForStatements::constantValueFunction(VariableDeclaration const
|
||||
{
|
||||
if (!boost::get_error_info<langutil::errinfo_sourceLocation>(_error))
|
||||
_error << langutil::errinfo_sourceLocation(m_currentLocation);
|
||||
throw _error;
|
||||
BOOST_THROW_EXCEPTION(_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ bool CommonOptions::parse(int argc, char const* const* argv)
|
||||
errorMessage << "Unrecognized option: ";
|
||||
for (auto const& token: parsedOption.original_tokens)
|
||||
errorMessage << token;
|
||||
throw std::runtime_error(errorMessage.str());
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error(errorMessage.str()));
|
||||
}
|
||||
|
||||
if (vmPaths.empty())
|
||||
@ -185,7 +185,7 @@ langutil::EVMVersion CommonOptions::evmVersion() const
|
||||
{
|
||||
auto version = langutil::EVMVersion::fromString(evmVersionString);
|
||||
if (!version)
|
||||
throw std::runtime_error("Invalid EVM version: " + evmVersionString);
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid EVM version: " + evmVersionString));
|
||||
return *version;
|
||||
}
|
||||
else
|
||||
@ -196,7 +196,7 @@ langutil::EVMVersion CommonOptions::evmVersion() const
|
||||
CommonOptions const& CommonOptions::get()
|
||||
{
|
||||
if (!m_singleton)
|
||||
throw std::runtime_error("Options not yet constructed!");
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("Options not yet constructed!"));
|
||||
|
||||
return *m_singleton;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace
|
||||
int parseUnsignedInteger(string::iterator& _it, string::iterator _end)
|
||||
{
|
||||
if (_it == _end || !isdigit(*_it))
|
||||
throw runtime_error("Invalid test expectation. Source location expected.");
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Invalid test expectation. Source location expected."));
|
||||
int result = 0;
|
||||
while (_it != _end && isdigit(*_it))
|
||||
{
|
||||
|
@ -80,14 +80,14 @@ bool EVMHost::checkVmPaths(vector<boost::filesystem::path> const& _vmPaths)
|
||||
if (vm.has_capability(EVMC_CAPABILITY_EVM1))
|
||||
{
|
||||
if (evmVmFound)
|
||||
throw runtime_error("Multiple evm1 evmc vms defined. Please only define one evm1 evmc vm.");
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Multiple evm1 evmc vms defined. Please only define one evm1 evmc vm."));
|
||||
evmVmFound = true;
|
||||
}
|
||||
|
||||
if (vm.has_capability(EVMC_CAPABILITY_EWASM))
|
||||
{
|
||||
if (ewasmVmFound)
|
||||
throw runtime_error("Multiple ewasm evmc vms where defined. Please only define one ewasm evmc vm.");
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Multiple ewasm evmc vms where defined. Please only define one ewasm evmc vm."));
|
||||
ewasmVmFound = true;
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ bool TestCase::shouldRun()
|
||||
void TestCase::expect(string::iterator& _it, string::iterator _end, string::value_type _c)
|
||||
{
|
||||
if (_it == _end || *_it != _c)
|
||||
throw runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\".");
|
||||
BOOST_THROW_EXCEPTION(runtime_error(string("Invalid test expectation. Expected: \"") + _c + "\"."));
|
||||
++_it;
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,10 @@ string TestCaseReader::stringSetting(string const& _name, string const& _default
|
||||
void TestCaseReader::ensureAllSettingsRead() const
|
||||
{
|
||||
if (!m_unreadSettings.empty())
|
||||
throw runtime_error(
|
||||
BOOST_THROW_EXCEPTION(runtime_error(
|
||||
"Unknown setting(s): " +
|
||||
util::joinHumanReadable(m_unreadSettings | boost::adaptors::map_keys)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
pair<SourceMap, size_t> TestCaseReader::parseSourcesAndSettingsWithLineNumber(istream& _stream)
|
||||
@ -134,7 +134,7 @@ pair<SourceMap, size_t> TestCaseReader::parseSourcesAndSettingsWithLineNumber(is
|
||||
line.size() - sourceDelimiterEnd.size() - sourceDelimiterStart.size()
|
||||
));
|
||||
if (sources.count(currentSourceName))
|
||||
throw runtime_error("Multiple definitions of test source \"" + currentSourceName + "\".");
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Multiple definitions of test source \"" + currentSourceName + "\"."));
|
||||
}
|
||||
else
|
||||
currentSource += line + "\n";
|
||||
@ -143,7 +143,7 @@ pair<SourceMap, size_t> TestCaseReader::parseSourcesAndSettingsWithLineNumber(is
|
||||
{
|
||||
size_t colon = line.find(':');
|
||||
if (colon == string::npos)
|
||||
throw runtime_error(string("Expected \":\" inside setting."));
|
||||
BOOST_THROW_EXCEPTION(runtime_error(string("Expected \":\" inside setting.")));
|
||||
string key = line.substr(comment.size(), colon - comment.size());
|
||||
string value = line.substr(colon + 1);
|
||||
boost::algorithm::trim(key);
|
||||
@ -151,7 +151,7 @@ pair<SourceMap, size_t> TestCaseReader::parseSourcesAndSettingsWithLineNumber(is
|
||||
m_settings[key] = value;
|
||||
}
|
||||
else
|
||||
throw runtime_error(string("Expected \"//\" or \"// ---\" to terminate settings and source."));
|
||||
BOOST_THROW_EXCEPTION(runtime_error(string("Expected \"//\" or \"// ---\" to terminate settings and source.")));
|
||||
}
|
||||
// Register the last source as the main one
|
||||
sources[currentSourceName] = currentSource;
|
||||
|
@ -81,7 +81,7 @@ bytes BytesUtils::convertBoolean(string const& _literal)
|
||||
else if (_literal == "false")
|
||||
return bytes{false};
|
||||
else
|
||||
throw TestParserError("Boolean literal invalid.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Boolean literal invalid."));
|
||||
}
|
||||
|
||||
bytes BytesUtils::convertNumber(string const& _literal)
|
||||
@ -92,7 +92,7 @@ bytes BytesUtils::convertNumber(string const& _literal)
|
||||
}
|
||||
catch (std::exception const&)
|
||||
{
|
||||
throw TestParserError("Number encoding invalid.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Number encoding invalid."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ bytes BytesUtils::convertHexNumber(string const& _literal)
|
||||
}
|
||||
catch (std::exception const&)
|
||||
{
|
||||
throw TestParserError("Hex number encoding invalid.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Hex number encoding invalid."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ bytes BytesUtils::convertString(string const& _literal)
|
||||
}
|
||||
catch (std::exception const&)
|
||||
{
|
||||
throw TestParserError("String encoding invalid.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("String encoding invalid."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
|
||||
else if (m_scanner.currentLiteral() == "nonempty")
|
||||
call.expectations.result.back().rawBytes = bytes(1, uint8_t(true));
|
||||
else
|
||||
throw TestParserError("Expected \"empty\" or \"nonempty\".");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Expected \"empty\" or \"nonempty\"."));
|
||||
call.kind = FunctionCall::Kind::Storage;
|
||||
m_scanner.scanNextToken();
|
||||
}
|
||||
@ -150,7 +150,9 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
|
||||
}
|
||||
catch (TestParserError const& _e)
|
||||
{
|
||||
throw TestParserError("Line " + to_string(_lineOffset + m_lineNumber) + ": " + _e.what());
|
||||
BOOST_THROW_EXCEPTION(
|
||||
TestParserError("Line " + to_string(_lineOffset + m_lineNumber) + ": " + _e.what())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -170,11 +172,12 @@ bool TestFileParser::accept(Token _token, bool const _expect)
|
||||
bool TestFileParser::expect(Token _token, bool const _advance)
|
||||
{
|
||||
if (m_scanner.currentToken() != _token || m_scanner.currentToken() == Token::Invalid)
|
||||
throw TestParserError(
|
||||
BOOST_THROW_EXCEPTION(TestParserError(
|
||||
"Unexpected " + formatToken(m_scanner.currentToken()) + ": \"" +
|
||||
m_scanner.currentLiteral() + "\". " +
|
||||
"Expected \"" + formatToken(_token) + "\"."
|
||||
);
|
||||
)
|
||||
);
|
||||
if (_advance)
|
||||
m_scanner.scanNextToken();
|
||||
return true;
|
||||
@ -206,10 +209,10 @@ pair<string, bool> TestFileParser::parseFunctionSignature()
|
||||
parameters += parseIdentifierOrTuple();
|
||||
}
|
||||
if (accept(Token::Arrow, true))
|
||||
throw TestParserError("Invalid signature detected: " + signature);
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid signature detected: " + signature));
|
||||
|
||||
if (!hasName && !parameters.empty())
|
||||
throw TestParserError("Signatures without a name cannot have parameters: " + signature);
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Signatures without a name cannot have parameters: " + signature));
|
||||
else
|
||||
signature += parameters;
|
||||
|
||||
@ -226,7 +229,7 @@ FunctionValue TestFileParser::parseFunctionCallValue()
|
||||
u256 value{ parseDecimalNumber() };
|
||||
Token token = m_scanner.currentToken();
|
||||
if (token != Token::Ether && token != Token::Wei)
|
||||
throw TestParserError("Invalid value unit provided. Coins can be wei or ether.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid value unit provided. Coins can be wei or ether."));
|
||||
|
||||
m_scanner.scanNextToken();
|
||||
|
||||
@ -235,7 +238,7 @@ FunctionValue TestFileParser::parseFunctionCallValue()
|
||||
}
|
||||
catch (std::exception const&)
|
||||
{
|
||||
throw TestParserError("Ether value encoding invalid.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Ether value encoding invalid."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +248,7 @@ FunctionCallArgs TestFileParser::parseFunctionCallArguments()
|
||||
|
||||
auto param = parseParameter();
|
||||
if (param.abiType.type == ABIType::None)
|
||||
throw TestParserError("No argument provided.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("No argument provided."));
|
||||
arguments.parameters.emplace_back(param);
|
||||
|
||||
while (accept(Token::Comma, true))
|
||||
@ -309,7 +312,7 @@ Parameter TestFileParser::parseParameter()
|
||||
if (accept(Token::Boolean))
|
||||
{
|
||||
if (isSigned)
|
||||
throw TestParserError("Invalid boolean literal.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid boolean literal."));
|
||||
|
||||
parameter.abiType = ABIType{ABIType::Boolean, ABIType::AlignRight, 32};
|
||||
string parsed = parseBoolean();
|
||||
@ -323,7 +326,7 @@ Parameter TestFileParser::parseParameter()
|
||||
else if (accept(Token::HexNumber))
|
||||
{
|
||||
if (isSigned)
|
||||
throw TestParserError("Invalid hex number literal.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid hex number literal."));
|
||||
|
||||
parameter.abiType = ABIType{ABIType::Hex, ABIType::AlignRight, 32};
|
||||
string parsed = parseHexNumber();
|
||||
@ -337,9 +340,9 @@ Parameter TestFileParser::parseParameter()
|
||||
else if (accept(Token::Hex, true))
|
||||
{
|
||||
if (isSigned)
|
||||
throw TestParserError("Invalid hex string literal.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid hex string literal."));
|
||||
if (parameter.alignment != Parameter::Alignment::None)
|
||||
throw TestParserError("Hex string literals cannot be aligned or padded.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Hex string literals cannot be aligned or padded."));
|
||||
|
||||
string parsed = parseString();
|
||||
parameter.rawString += "hex\"" + parsed + "\"";
|
||||
@ -351,9 +354,9 @@ Parameter TestFileParser::parseParameter()
|
||||
else if (accept(Token::String))
|
||||
{
|
||||
if (isSigned)
|
||||
throw TestParserError("Invalid string literal.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid string literal."));
|
||||
if (parameter.alignment != Parameter::Alignment::None)
|
||||
throw TestParserError("String literals cannot be aligned or padded.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("String literals cannot be aligned or padded."));
|
||||
|
||||
string parsed = parseString();
|
||||
parameter.abiType = ABIType{ABIType::String, ABIType::AlignLeft, parsed.size()};
|
||||
@ -383,7 +386,7 @@ Parameter TestFileParser::parseParameter()
|
||||
else if (accept(Token::Failure, true))
|
||||
{
|
||||
if (isSigned)
|
||||
throw TestParserError("Invalid failure literal.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid failure literal."));
|
||||
|
||||
parameter.abiType = ABIType{ABIType::Failure, ABIType::AlignRight, 0};
|
||||
parameter.rawBytes = bytes{};
|
||||
@ -578,7 +581,7 @@ void TestFileParser::Scanner::scanNextToken()
|
||||
m_currentLiteral = "";
|
||||
}
|
||||
else
|
||||
throw TestParserError("Unexpected character: '" + string{current()} + "'");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Unexpected character: '" + string{current()} + "'"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -670,7 +673,7 @@ string TestFileParser::Scanner::scanString()
|
||||
str += scanHexPart();
|
||||
break;
|
||||
default:
|
||||
throw TestParserError("Invalid or escape sequence found in string literal.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("Invalid or escape sequence found in string literal."));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -693,7 +696,7 @@ char TestFileParser::Scanner::scanHexPart()
|
||||
else if (tolower(current()) >= 'a' && tolower(current()) <= 'f')
|
||||
value = tolower(current()) - 'a' + 10;
|
||||
else
|
||||
throw TestParserError("\\x used with no following hex digits.");
|
||||
BOOST_THROW_EXCEPTION(TestParserError("\\x used with no following hex digits."));
|
||||
|
||||
advance();
|
||||
if (current() == '"')
|
||||
|
@ -139,7 +139,7 @@ void FuzzerUtil::runCompiler(string const& _input, bool _quiet)
|
||||
{
|
||||
string msg{"Compiler produced invalid JSON output."};
|
||||
cout << msg << endl;
|
||||
throw std::runtime_error(std::move(msg));
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg)));
|
||||
}
|
||||
if (output.isMember("errors"))
|
||||
for (auto const& error: output["errors"])
|
||||
@ -152,7 +152,7 @@ void FuzzerUtil::runCompiler(string const& _input, bool _quiet)
|
||||
{
|
||||
string msg = "Invalid error: \"" + error["type"].asString() + "\"";
|
||||
cout << msg << endl;
|
||||
throw std::runtime_error(std::move(msg));
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error(std::move(msg)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ u256 EVMInstructionInterpreter::eval(
|
||||
switch (_instruction)
|
||||
{
|
||||
case Instruction::STOP:
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
// --------------- arithmetic ---------------
|
||||
case Instruction::ADD:
|
||||
return arg[0] + arg[1];
|
||||
@ -328,18 +328,18 @@ u256 EVMInstructionInterpreter::eval(
|
||||
if (accessMemory(arg[0], arg[1]))
|
||||
data = readMemory(arg[0], arg[1]);
|
||||
logTrace(_instruction, arg, data);
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
}
|
||||
case Instruction::REVERT:
|
||||
accessMemory(arg[0], arg[1]);
|
||||
logTrace(_instruction, arg);
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
case Instruction::INVALID:
|
||||
logTrace(_instruction);
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
case Instruction::SELFDESTRUCT:
|
||||
logTrace(_instruction, arg);
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
case Instruction::POP:
|
||||
break;
|
||||
// --------------- invalid in strict assembly ---------------
|
||||
@ -527,6 +527,6 @@ void EVMInstructionInterpreter::logTrace(std::string const& _pseudoInstruction,
|
||||
if (m_state.maxTraceSize > 0 && m_state.trace.size() >= m_state.maxTraceSize)
|
||||
{
|
||||
m_state.trace.emplace_back("Trace size limit reached.");
|
||||
throw TraceLimitReached();
|
||||
BOOST_THROW_EXCEPTION(TraceLimitReached());
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(
|
||||
else if (fun == "unreachable")
|
||||
{
|
||||
logTrace(evmasm::Instruction::INVALID, {});
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
}
|
||||
else if (fun == "i64.store")
|
||||
{
|
||||
@ -258,14 +258,14 @@ u256 EwasmBuiltinInterpreter::evalWasmBuiltin(string const& _fun, vector<Word> c
|
||||
else if (_fun == "div_u")
|
||||
{
|
||||
if (arg[1] == 0)
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
else
|
||||
return arg[0] / arg[1];
|
||||
}
|
||||
else if (_fun == "rem_u")
|
||||
{
|
||||
if (arg[1] == 0)
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
else
|
||||
return arg[0] % arg[1];
|
||||
}
|
||||
@ -337,7 +337,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
||||
else if (_fun == "callDataCopy")
|
||||
{
|
||||
if (arg[1] + arg[2] < arg[1] || arg[1] + arg[2] > m_state.calldata.size())
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
accessMemory(arg[0], arg[2]);
|
||||
copyZeroExtended(
|
||||
m_state.memory, m_state.calldata,
|
||||
@ -446,7 +446,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
||||
accessMemory(arg[0], arg[1]);
|
||||
uint64_t numberOfTopics = arg[2];
|
||||
if (numberOfTopics > 4)
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
if (numberOfTopics > 0)
|
||||
readBytes32(arg[3]);
|
||||
if (numberOfTopics > 1)
|
||||
@ -471,7 +471,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
||||
accessMemory(arg[0], arg[1]);
|
||||
data = readMemory(arg[0], arg[1]);
|
||||
logTrace(evmasm::Instruction::RETURN, {}, data);
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
}
|
||||
else if (_fun == "revert")
|
||||
{
|
||||
@ -479,14 +479,14 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
||||
accessMemory(arg[0], arg[1]);
|
||||
data = readMemory(arg[0], arg[1]);
|
||||
logTrace(evmasm::Instruction::REVERT, {}, data);
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
}
|
||||
else if (_fun == "getReturnDataSize")
|
||||
return m_state.returndata.size();
|
||||
else if (_fun == "returnDataCopy")
|
||||
{
|
||||
if (arg[1] + arg[2] < arg[1] || arg[1] + arg[2] > m_state.returndata.size())
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
accessMemory(arg[0], arg[2]);
|
||||
copyZeroExtended(
|
||||
m_state.memory, m_state.calldata,
|
||||
@ -498,7 +498,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
||||
{
|
||||
readAddress(arg[0]);
|
||||
logTrace(evmasm::Instruction::SELFDESTRUCT, {});
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
}
|
||||
else if (_fun == "getBlockTimestamp")
|
||||
return m_state.timestamp;
|
||||
@ -516,7 +516,7 @@ void EwasmBuiltinInterpreter::accessMemory(u256 const& _offset, u256 const& _siz
|
||||
|
||||
if (((_offset + _size) < _offset) || ((_offset + _size) > m_state.msize))
|
||||
// Ewasm throws out of bounds exception as opposed to the EVM.
|
||||
throw ExplicitlyTerminated();
|
||||
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
|
||||
}
|
||||
|
||||
bytes EwasmBuiltinInterpreter::readMemory(uint64_t _offset, uint64_t _size)
|
||||
@ -604,6 +604,6 @@ void EwasmBuiltinInterpreter::logTrace(std::string const& _pseudoInstruction, st
|
||||
if (m_state.maxTraceSize > 0 && m_state.trace.size() >= m_state.maxTraceSize)
|
||||
{
|
||||
m_state.trace.emplace_back("Trace size limit reached.");
|
||||
throw TraceLimitReached();
|
||||
BOOST_THROW_EXCEPTION(TraceLimitReached());
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ void Interpreter::incrementStep()
|
||||
if (m_state.maxSteps > 0 && m_state.numSteps >= m_state.maxSteps)
|
||||
{
|
||||
m_state.trace.emplace_back("Interpreter execution step limit reached.");
|
||||
throw StepLimitReached();
|
||||
BOOST_THROW_EXCEPTION(StepLimitReached());
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,6 +351,6 @@ void ExpressionEvaluator::incrementStep()
|
||||
if (m_state.maxExprNesting > 0 && m_nestingLevel > m_state.maxExprNesting)
|
||||
{
|
||||
m_state.trace.emplace_back("Maximum expression nesting level reached.");
|
||||
throw ExpressionNestingLimitReached();
|
||||
BOOST_THROW_EXCEPTION(ExpressionNestingLimitReached());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user