mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Use 16-bit pointers in the bytecode
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user