mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-25 04:47:57 +00:00
implement byte stores and assert heap values to be either i256 or i8
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -789,7 +789,13 @@ where
|
||||
.expect("should be IntValue")
|
||||
.const_truncate(self.xlen_type()),
|
||||
)?;
|
||||
let value = self.build_byte_swap(value.as_basic_value_enum());
|
||||
|
||||
let value = value.as_basic_value_enum();
|
||||
let value = match value.get_type().into_int_type().get_bit_width() as usize {
|
||||
revive_common::BIT_LENGTH_FIELD => self.build_byte_swap(value),
|
||||
revive_common::BIT_LENGTH_BYTE => value,
|
||||
_ => unreachable!("Only word and byte sized values can be stored on EVM heap"),
|
||||
};
|
||||
|
||||
self.builder
|
||||
.build_store(heap_pointer.value, value)?
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
//! Translates the heap memory operations.
|
||||
//!
|
||||
|
||||
use inkwell::values::BasicValue;
|
||||
|
||||
use crate::eravm::context::address_space::AddressSpace;
|
||||
use crate::eravm::context::pointer::Pointer;
|
||||
use crate::eravm::context::Context;
|
||||
@@ -68,20 +66,16 @@ pub fn store_byte<'ctx, D>(
|
||||
where
|
||||
D: Dependency + Clone,
|
||||
{
|
||||
let offset_pointer = Pointer::new_with_offset(
|
||||
let byte_type = context.byte_type();
|
||||
let value = context
|
||||
.builder()
|
||||
.build_int_truncate(value, byte_type, "mstore8_value")?;
|
||||
let pointer = Pointer::new_with_offset(
|
||||
context,
|
||||
AddressSpace::Heap,
|
||||
context.byte_type(),
|
||||
byte_type,
|
||||
offset,
|
||||
"mstore8_offset_pointer",
|
||||
"mstore8_destination",
|
||||
);
|
||||
context.build_call(
|
||||
context.llvm_runtime().mstore8,
|
||||
&[
|
||||
offset_pointer.value.as_basic_value_enum(),
|
||||
value.as_basic_value_enum(),
|
||||
],
|
||||
"mstore8_call",
|
||||
);
|
||||
Ok(())
|
||||
context.build_store(pointer, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user