make array_lower_memory work with bytearrays

This commit is contained in:
vms 2021-04-25 13:20:12 +03:00
parent a44c433c4d
commit f8aa7e0616
3 changed files with 21 additions and 4 deletions

View File

@ -21,7 +21,6 @@ use crate::traits::DEFAULT_MEMORY_INDEX;
use crate::utils::type_tag_form_itype;
use std::cell::Cell;
use crate::lowerer::LoError;
pub struct MemoryWriter<'i, R: Allocatable> {
heap_manager: &'i R,

View File

@ -134,6 +134,27 @@ where
Ok(())
}
IValue::ByteArray(bytearray) => {
let lo_helper = lilo::LoHelper::new(&**instance);
let lowerer = ILowerer::new(&lo_helper)
.map_err(|e| InstructionError::from_lo(instruction.clone(), e))?;
let offset = lowerer
.writer
.write_bytes(&bytearray)
.map_err(|e| InstructionError::from_lo(instruction.clone(), e))?;
let size = bytearray.len();
log::trace!(
"array.lower_memory: pushing bytes {}, {} on the stack",
offset,
size
);
runtime.stack.push(IValue::I32(offset as _));
runtime.stack.push(IValue::I32(size as _));
Ok(())
}
_ => instr_error!(
instruction.clone(),
InstructionErrorKind::InvalidValueOnTheStack {

View File

@ -18,7 +18,6 @@ executable_instruction!(
InstructionErrorKind::StackIsTooSmall { needed: 2 },
)
})?;
println!("byte_array lift memory: {:?}", inputs);
let memory_index = 0;
let memory = runtime
@ -40,8 +39,6 @@ executable_instruction!(
.map_err(|e| (e, "length").into())
.map_err(|k| InstructionError::from_error_kind(instruction.clone(), k))?;
println!("byte_array lift memory: pointer {} length {}", pointer, length);
let memory_view = memory.view();
if length == 0 {