wasm/BinaryTransform: Don't add an empty local entry in binary wasm if there are no locals

This commit is contained in:
Kamil Śliwak
2020-06-05 21:03:06 +02:00
parent d243f5baac
commit 976a0f9395
3 changed files with 10 additions and 5 deletions
+8 -3
View File
@@ -430,9 +430,14 @@ bytes BinaryTransform::operator()(FunctionDefinition const& _function)
// This is a kind of run-length-encoding of local types. Has to be adapted once
// we have locals of different types.
ret += lebEncode(1); // number of locals groups
ret += lebEncode(_function.locals.size());
ret += toBytes(ValueType::I64);
if (_function.locals.size() == 0)
ret += lebEncode(0); // number of locals groups
else
{
ret += lebEncode(1); // number of locals groups
ret += lebEncode(_function.locals.size());
ret += toBytes(ValueType::I64);
}
m_locals.clear();
size_t varIdx = 0;