mirror of
https://github.com/fluencelabs/interface-types
synced 2024-12-04 07:10:21 +00:00
make array_lower_memory work with bytearrays
This commit is contained in:
parent
a44c433c4d
commit
f8aa7e0616
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user