[ewasm] Add assertion for datasize/dataoffset in BinaryTransform

This commit is contained in:
Alex Beregszaszi 2020-10-27 17:43:27 +00:00
parent 6d79a8885f
commit 13652bd4a9

View File

@ -356,11 +356,15 @@ bytes BinaryTransform::operator()(BuiltinCall const& _call)
if (_call.functionName == "dataoffset")
{
string name = get<StringLiteral>(_call.arguments.at(0)).value;
// TODO: support the case where name refers to the current object
yulAssert(m_subModulePosAndSize.count(name), "");
return toBytes(Opcode::I64Const) + lebEncodeSigned(static_cast<int64_t>(m_subModulePosAndSize.at(name).first));
}
else if (_call.functionName == "datasize")
{
string name = get<StringLiteral>(_call.arguments.at(0)).value;
// TODO: support the case where name refers to the current object
yulAssert(m_subModulePosAndSize.count(name), "");
return toBytes(Opcode::I64Const) + lebEncodeSigned(static_cast<int64_t>(m_subModulePosAndSize.at(name).second));
}