feat(interface-types) Implement the string.size instruction.

This commit is contained in:
Ivan Enderlin
2020-03-24 15:33:42 +01:00
parent 50a6d9d92c
commit 55a5b97443
7 changed files with 84 additions and 2 deletions

View File

@@ -299,6 +299,8 @@ where
0x23_u8.to_bytes(writer)?;
(*allocator_index as u64).to_bytes(writer)?;
}
Instruction::StringSize => 0x24_u8.to_bytes(writer)?,
}
Ok(())
@@ -577,9 +579,10 @@ mod tests {
Instruction::I64FromU64,
Instruction::StringLiftMemory,
Instruction::StringLowerMemory { allocator_index: 1 },
Instruction::StringSize,
],
&[
0x24, // list of 36 items
0x25, // list of 37 items
0x00, 0x01, // ArgumentGet { index: 1 }
0x01, 0x01, // CallCore { function_index: 1 }
0x02, // S8FromI32
@@ -616,6 +619,7 @@ mod tests {
0x21, // I64FromU64
0x22, // StringLiftMemory
0x23, 0x01, // StringLowerMemory { allocator_index: 1 }
0x24, // StringSize
]
);
}