Use ValueType::End to mark the end of arrays and objects instead of encoding the number of elements

This commit is contained in:
Andrew Morris
2023-03-06 08:54:47 +11:00
parent 8c15b5b5eb
commit 01559ce0bd

View File

@@ -298,26 +298,28 @@ impl Assembler {
fn array(&mut self, array: &Array) {
self.output.push(ValueType::Array as u8);
self.varsize_uint(array.values.len());
for value in &array.values {
self.value(value);
}
self.output.push(ValueType::End as u8);
}
fn object(&mut self, object: &Object) {
self.output.push(ValueType::Object as u8);
self.varsize_uint(object.properties.len());
for (key, value) in &object.properties {
self.value(key);
self.value(value);
}
self.output.push(ValueType::End as u8);
}
}
enum ValueType {
// End = 0x00,
End = 0x00,
Void = 0x01,
Undefined = 0x02,
Null = 0x03,