Use 16-bit pointers in the bytecode

This commit is contained in:
Andrew Morris
2022-05-21 14:12:36 +10:00
parent 99db7d6c0a
commit 587d6da4e8
2 changed files with 5 additions and 3 deletions

View File

@@ -61,7 +61,8 @@ impl LocationMapper for LocationMap {
.or_default()
.push(output.len());
output.push(0xff); // TODO: Support >255
output.push(0xff);
output.push(0xff); // TODO: Support >65535
}
fn resolve(&self, output: &mut Vec<u8>) {
@@ -79,7 +80,8 @@ impl LocationMapper for LocationMap {
let location = location_optional.unwrap();
for ref_location in ref_locations {
output[*ref_location] = *location as u8; // TODO: Support >255
output[*ref_location] = (*location % 256) as u8;
output[*ref_location + 1] = (*location / 256) as u8; // TODO: Support >65535
}
}
}

View File

@@ -169,7 +169,7 @@ impl BytecodeDecoder {
pub fn decode_pos(&mut self) -> usize {
// TODO: the number of bytes to represent a position should be based on the
// size of the bytecode
return self.decode_byte() as usize;
return self.decode_byte() as usize + 256 * self.decode_byte() as usize;
}
pub fn decode_register_index(&mut self) -> Option<usize> {