rename llvm-context crate

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-05-01 15:45:09 +02:00
parent 9b341853b4
commit 72515254fe
55 changed files with 529 additions and 529 deletions
@@ -115,13 +115,13 @@ impl Assignment {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Assignment
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Assignment
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn into_llvm(
mut self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
let value = match self.initializer.into_llvm(context)? {
Some(value) => value,
@@ -136,13 +136,13 @@ impl Block {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Block
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Block
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn into_llvm(
self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
let current_function = context.current_function().borrow().name().to_owned();
let current_block = context.basic_block();
@@ -63,13 +63,13 @@ impl Code {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Code
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Code
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn into_llvm(
self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
self.block.into_llvm(context)?;
@@ -127,17 +127,17 @@ impl FunctionCall {
///
pub fn into_llvm<'ctx, D>(
mut self,
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<Option<inkwell::values::BasicValueEnum<'ctx>>>
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
let location = self.location;
match self.name {
Name::UserDefined(name)
if name.starts_with(
era_compiler_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX,
revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX,
) && context.is_system_mode() =>
{
unimplemented!();
@@ -176,7 +176,7 @@ impl FunctionCall {
Name::Add => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_arithmetic::addition(
revive_llvm_context::eravm_evm_arithmetic::addition(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -185,7 +185,7 @@ impl FunctionCall {
}
Name::Sub => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_arithmetic::subtraction(
revive_llvm_context::eravm_evm_arithmetic::subtraction(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -194,7 +194,7 @@ impl FunctionCall {
}
Name::Mul => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_arithmetic::multiplication(
revive_llvm_context::eravm_evm_arithmetic::multiplication(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -203,7 +203,7 @@ impl FunctionCall {
}
Name::Div => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_arithmetic::division(
revive_llvm_context::eravm_evm_arithmetic::division(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -212,7 +212,7 @@ impl FunctionCall {
}
Name::Mod => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_arithmetic::remainder(
revive_llvm_context::eravm_evm_arithmetic::remainder(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -221,7 +221,7 @@ impl FunctionCall {
}
Name::Sdiv => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_arithmetic::division_signed(
revive_llvm_context::eravm_evm_arithmetic::division_signed(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -230,7 +230,7 @@ impl FunctionCall {
}
Name::Smod => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_arithmetic::remainder_signed(
revive_llvm_context::eravm_evm_arithmetic::remainder_signed(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -240,7 +240,7 @@ impl FunctionCall {
Name::Lt => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_comparison::compare(
revive_llvm_context::eravm_evm_comparison::compare(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -250,7 +250,7 @@ impl FunctionCall {
}
Name::Gt => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_comparison::compare(
revive_llvm_context::eravm_evm_comparison::compare(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -260,7 +260,7 @@ impl FunctionCall {
}
Name::Eq => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_comparison::compare(
revive_llvm_context::eravm_evm_comparison::compare(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -270,7 +270,7 @@ impl FunctionCall {
}
Name::IsZero => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
era_compiler_llvm_context::eravm_evm_comparison::compare(
revive_llvm_context::eravm_evm_comparison::compare(
context,
arguments[0].into_int_value(),
context.field_const(0),
@@ -280,7 +280,7 @@ impl FunctionCall {
}
Name::Slt => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_comparison::compare(
revive_llvm_context::eravm_evm_comparison::compare(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -290,7 +290,7 @@ impl FunctionCall {
}
Name::Sgt => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_comparison::compare(
revive_llvm_context::eravm_evm_comparison::compare(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -301,7 +301,7 @@ impl FunctionCall {
Name::Or => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::or(
revive_llvm_context::eravm_evm_bitwise::or(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -310,7 +310,7 @@ impl FunctionCall {
}
Name::Xor => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::xor(
revive_llvm_context::eravm_evm_bitwise::xor(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -319,7 +319,7 @@ impl FunctionCall {
}
Name::Not => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::xor(
revive_llvm_context::eravm_evm_bitwise::xor(
context,
arguments[0].into_int_value(),
context.field_type().const_all_ones(),
@@ -328,7 +328,7 @@ impl FunctionCall {
}
Name::And => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::and(
revive_llvm_context::eravm_evm_bitwise::and(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -337,7 +337,7 @@ impl FunctionCall {
}
Name::Shl => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::shift_left(
revive_llvm_context::eravm_evm_bitwise::shift_left(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -346,7 +346,7 @@ impl FunctionCall {
}
Name::Shr => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::shift_right(
revive_llvm_context::eravm_evm_bitwise::shift_right(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -355,7 +355,7 @@ impl FunctionCall {
}
Name::Sar => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::shift_right_arithmetic(
revive_llvm_context::eravm_evm_bitwise::shift_right_arithmetic(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -364,7 +364,7 @@ impl FunctionCall {
}
Name::Byte => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_bitwise::byte(
revive_llvm_context::eravm_evm_bitwise::byte(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -378,7 +378,7 @@ impl FunctionCall {
Name::AddMod => {
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
era_compiler_llvm_context::eravm_evm_math::add_mod(
revive_llvm_context::eravm_evm_math::add_mod(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -388,7 +388,7 @@ impl FunctionCall {
}
Name::MulMod => {
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
era_compiler_llvm_context::eravm_evm_math::mul_mod(
revive_llvm_context::eravm_evm_math::mul_mod(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -398,7 +398,7 @@ impl FunctionCall {
}
Name::Exp => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_math::exponent(
revive_llvm_context::eravm_evm_math::exponent(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -407,7 +407,7 @@ impl FunctionCall {
}
Name::SignExtend => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_math::sign_extend(
revive_llvm_context::eravm_evm_math::sign_extend(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -417,7 +417,7 @@ impl FunctionCall {
Name::Keccak256 => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_crypto::sha3(
revive_llvm_context::eravm_evm_crypto::sha3(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -427,7 +427,7 @@ impl FunctionCall {
Name::MLoad => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
era_compiler_llvm_context::eravm_evm_memory::load(
revive_llvm_context::eravm_evm_memory::load(
context,
arguments[0].into_int_value(),
)
@@ -435,7 +435,7 @@ impl FunctionCall {
}
Name::MStore => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_memory::store(
revive_llvm_context::eravm_evm_memory::store(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -444,7 +444,7 @@ impl FunctionCall {
}
Name::MStore8 => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_memory::store_byte(
revive_llvm_context::eravm_evm_memory::store_byte(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -453,16 +453,16 @@ impl FunctionCall {
}
Name::MCopy => {
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
let destination = era_compiler_llvm_context::EraVMPointer::new_with_offset(
let destination = revive_llvm_context::EraVMPointer::new_with_offset(
context,
era_compiler_llvm_context::EraVMAddressSpace::Heap,
revive_llvm_context::EraVMAddressSpace::Heap,
context.byte_type(),
arguments[0].into_int_value(),
"mcopy_destination",
);
let source = era_compiler_llvm_context::EraVMPointer::new_with_offset(
let source = revive_llvm_context::EraVMPointer::new_with_offset(
context,
era_compiler_llvm_context::EraVMAddressSpace::Heap,
revive_llvm_context::EraVMAddressSpace::Heap,
context.byte_type(),
arguments[1].into_int_value(),
"mcopy_source",
@@ -480,7 +480,7 @@ impl FunctionCall {
Name::SLoad => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
era_compiler_llvm_context::eravm_evm_storage::load(
revive_llvm_context::eravm_evm_storage::load(
context,
arguments[0].into_int_value(),
)
@@ -488,7 +488,7 @@ impl FunctionCall {
}
Name::SStore => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_storage::store(
revive_llvm_context::eravm_evm_storage::store(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -524,7 +524,7 @@ impl FunctionCall {
let index = context.field_const(offset as u64);
let value = arguments[2].value.into_int_value();
era_compiler_llvm_context::eravm_evm_immutable::store(context, index, value)
revive_llvm_context::eravm_evm_immutable::store(context, index, value)
.map(|_| None)
}
@@ -535,11 +535,11 @@ impl FunctionCall {
.code_type()
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
{
era_compiler_llvm_context::EraVMCodeType::Deploy => {
revive_llvm_context::EraVMCodeType::Deploy => {
Ok(Some(context.field_const(0).as_basic_value_enum()))
}
era_compiler_llvm_context::EraVMCodeType::Runtime => {
era_compiler_llvm_context::eravm_evm_calldata::load(
revive_llvm_context::EraVMCodeType::Runtime => {
revive_llvm_context::eravm_evm_calldata::load(
context,
arguments[0].into_int_value(),
)
@@ -552,11 +552,11 @@ impl FunctionCall {
.code_type()
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
{
era_compiler_llvm_context::EraVMCodeType::Deploy => {
revive_llvm_context::EraVMCodeType::Deploy => {
Ok(Some(context.field_const(0).as_basic_value_enum()))
}
era_compiler_llvm_context::EraVMCodeType::Runtime => {
era_compiler_llvm_context::eravm_evm_calldata::size(context).map(Some)
revive_llvm_context::EraVMCodeType::Runtime => {
revive_llvm_context::eravm_evm_calldata::size(context).map(Some)
}
}
}
@@ -567,11 +567,11 @@ impl FunctionCall {
.code_type()
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
{
era_compiler_llvm_context::EraVMCodeType::Deploy => {
revive_llvm_context::EraVMCodeType::Deploy => {
let calldata_size =
era_compiler_llvm_context::eravm_evm_calldata::size(context)?;
revive_llvm_context::eravm_evm_calldata::size(context)?;
era_compiler_llvm_context::eravm_evm_calldata::copy(
revive_llvm_context::eravm_evm_calldata::copy(
context,
arguments[0].into_int_value(),
calldata_size.into_int_value(),
@@ -579,8 +579,8 @@ impl FunctionCall {
)
.map(|_| None)
}
era_compiler_llvm_context::EraVMCodeType::Runtime => {
era_compiler_llvm_context::eravm_evm_calldata::copy(
revive_llvm_context::EraVMCodeType::Runtime => {
revive_llvm_context::eravm_evm_calldata::copy(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -595,16 +595,16 @@ impl FunctionCall {
.code_type()
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
{
era_compiler_llvm_context::EraVMCodeType::Deploy => {
era_compiler_llvm_context::eravm_evm_calldata::size(context).map(Some)
revive_llvm_context::EraVMCodeType::Deploy => {
revive_llvm_context::eravm_evm_calldata::size(context).map(Some)
}
era_compiler_llvm_context::EraVMCodeType::Runtime => {
revive_llvm_context::EraVMCodeType::Runtime => {
todo!()
}
}
}
Name::CodeCopy => {
if let era_compiler_llvm_context::EraVMCodeType::Runtime = context
if let revive_llvm_context::EraVMCodeType::Runtime = context
.code_type()
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?
{
@@ -615,7 +615,7 @@ impl FunctionCall {
}
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
era_compiler_llvm_context::eravm_evm_calldata::copy(
revive_llvm_context::eravm_evm_calldata::copy(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -624,11 +624,11 @@ impl FunctionCall {
.map(|_| None)
}
Name::ReturnDataSize => {
era_compiler_llvm_context::eravm_evm_return_data::size(context).map(Some)
revive_llvm_context::eravm_evm_return_data::size(context).map(Some)
}
Name::ReturnDataCopy => {
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
era_compiler_llvm_context::eravm_evm_return_data::copy(
revive_llvm_context::eravm_evm_return_data::copy(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -638,7 +638,7 @@ impl FunctionCall {
}
Name::ExtCodeSize => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
era_compiler_llvm_context::eravm_evm_ext_code::size(
revive_llvm_context::eravm_evm_ext_code::size(
context,
arguments[0].into_int_value(),
)
@@ -646,7 +646,7 @@ impl FunctionCall {
}
Name::ExtCodeHash => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
era_compiler_llvm_context::eravm_evm_ext_code::hash(
revive_llvm_context::eravm_evm_ext_code::hash(
context,
arguments[0].into_int_value(),
)
@@ -655,7 +655,7 @@ impl FunctionCall {
Name::Return => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_return::r#return(
revive_llvm_context::eravm_evm_return::r#return(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -664,21 +664,21 @@ impl FunctionCall {
}
Name::Revert => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_return::revert(
revive_llvm_context::eravm_evm_return::revert(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
)
.map(|_| None)
}
Name::Stop => era_compiler_llvm_context::eravm_evm_return::stop(context).map(|_| None),
Name::Stop => revive_llvm_context::eravm_evm_return::stop(context).map(|_| None),
Name::Invalid => {
era_compiler_llvm_context::eravm_evm_return::invalid(context).map(|_| None)
revive_llvm_context::eravm_evm_return::invalid(context).map(|_| None)
}
Name::Log0 => {
let arguments = self.pop_arguments_llvm::<D, 2>(context)?;
era_compiler_llvm_context::eravm_evm_event::log(
revive_llvm_context::eravm_evm_event::log(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -688,7 +688,7 @@ impl FunctionCall {
}
Name::Log1 => {
let arguments = self.pop_arguments_llvm::<D, 3>(context)?;
era_compiler_llvm_context::eravm_evm_event::log(
revive_llvm_context::eravm_evm_event::log(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -701,7 +701,7 @@ impl FunctionCall {
}
Name::Log2 => {
let arguments = self.pop_arguments_llvm::<D, 4>(context)?;
era_compiler_llvm_context::eravm_evm_event::log(
revive_llvm_context::eravm_evm_event::log(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -714,7 +714,7 @@ impl FunctionCall {
}
Name::Log3 => {
let arguments = self.pop_arguments_llvm::<D, 5>(context)?;
era_compiler_llvm_context::eravm_evm_event::log(
revive_llvm_context::eravm_evm_event::log(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -727,7 +727,7 @@ impl FunctionCall {
}
Name::Log4 => {
let arguments = self.pop_arguments_llvm::<D, 6>(context)?;
era_compiler_llvm_context::eravm_evm_event::log(
revive_llvm_context::eravm_evm_event::log(
context,
arguments[0].into_int_value(),
arguments[1].into_int_value(),
@@ -757,7 +757,7 @@ impl FunctionCall {
todo!()
/*
era_compiler_llvm_context::eravm_evm_call::default(
revive_llvm_context::eravm_evm_call::default(
context,
context.llvm_runtime().far_call,
gas,
@@ -787,7 +787,7 @@ impl FunctionCall {
.map(|mut argument| argument.constant.take())
.collect();
era_compiler_llvm_context::eravm_evm_call::default(
revive_llvm_context::eravm_evm_call::default(
context,
context.llvm_runtime().static_call,
gas,
@@ -816,7 +816,7 @@ impl FunctionCall {
.map(|mut argument| argument.constant.take())
.collect();
era_compiler_llvm_context::eravm_evm_call::default(
revive_llvm_context::eravm_evm_call::default(
context,
context.llvm_runtime().delegate_call,
gas,
@@ -838,7 +838,7 @@ impl FunctionCall {
let input_offset = arguments[1].into_int_value();
let input_length = arguments[2].into_int_value();
era_compiler_llvm_context::eravm_evm_create::create(
revive_llvm_context::eravm_evm_create::create(
context,
value,
input_offset,
@@ -854,7 +854,7 @@ impl FunctionCall {
let input_length = arguments[2].into_int_value();
let salt = arguments[3].into_int_value();
era_compiler_llvm_context::eravm_evm_create::create2(
revive_llvm_context::eravm_evm_create::create2(
context,
value,
input_offset,
@@ -870,7 +870,7 @@ impl FunctionCall {
anyhow::anyhow!("{} `dataoffset` object identifier is missing", location)
})?;
era_compiler_llvm_context::eravm_evm_create::contract_hash(context, identifier)
revive_llvm_context::eravm_evm_create::contract_hash(context, identifier)
.map(|argument| Some(argument.value))
}
Name::DataSize => {
@@ -880,7 +880,7 @@ impl FunctionCall {
anyhow::anyhow!("{} `dataoffset` object identifier is missing", location)
})?;
era_compiler_llvm_context::eravm_evm_create::header_size(context, identifier)
revive_llvm_context::eravm_evm_create::header_size(context, identifier)
.map(|argument| Some(argument.value))
}
Name::DataCopy => {
@@ -892,7 +892,7 @@ impl FunctionCall {
),
"datacopy_contract_hash_offset",
)?;
era_compiler_llvm_context::eravm_evm_memory::store(
revive_llvm_context::eravm_evm_memory::store(
context,
offset,
arguments[1].into_int_value(),
@@ -922,42 +922,42 @@ impl FunctionCall {
}
Name::CallValue => {
era_compiler_llvm_context::eravm_evm_ether_gas::value(context).map(Some)
revive_llvm_context::eravm_evm_ether_gas::value(context).map(Some)
}
Name::Gas => era_compiler_llvm_context::eravm_evm_ether_gas::gas(context).map(Some),
Name::Gas => revive_llvm_context::eravm_evm_ether_gas::gas(context).map(Some),
Name::Balance => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
let address = arguments[0].into_int_value();
era_compiler_llvm_context::eravm_evm_ether_gas::balance(context, address).map(Some)
revive_llvm_context::eravm_evm_ether_gas::balance(context, address).map(Some)
}
Name::SelfBalance => todo!(),
Name::GasLimit => {
era_compiler_llvm_context::eravm_evm_contract_context::gas_limit(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::gas_limit(context).map(Some)
}
Name::GasPrice => {
era_compiler_llvm_context::eravm_evm_contract_context::gas_price(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::gas_price(context).map(Some)
}
Name::Origin => {
era_compiler_llvm_context::eravm_evm_contract_context::origin(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::origin(context).map(Some)
}
Name::ChainId => {
era_compiler_llvm_context::eravm_evm_contract_context::chain_id(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::chain_id(context).map(Some)
}
Name::Timestamp => {
era_compiler_llvm_context::eravm_evm_contract_context::block_timestamp(context)
revive_llvm_context::eravm_evm_contract_context::block_timestamp(context)
.map(Some)
}
Name::Number => {
era_compiler_llvm_context::eravm_evm_contract_context::block_number(context)
revive_llvm_context::eravm_evm_contract_context::block_number(context)
.map(Some)
}
Name::BlockHash => {
let arguments = self.pop_arguments_llvm::<D, 1>(context)?;
let index = arguments[0].into_int_value();
era_compiler_llvm_context::eravm_evm_contract_context::block_hash(context, index)
revive_llvm_context::eravm_evm_contract_context::block_hash(context, index)
.map(Some)
}
Name::BlobHash => {
@@ -968,13 +968,13 @@ impl FunctionCall {
);
}
Name::Difficulty | Name::Prevrandao => {
era_compiler_llvm_context::eravm_evm_contract_context::difficulty(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::difficulty(context).map(Some)
}
Name::CoinBase => {
era_compiler_llvm_context::eravm_evm_contract_context::coinbase(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::coinbase(context).map(Some)
}
Name::BaseFee => {
era_compiler_llvm_context::eravm_evm_contract_context::basefee(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::basefee(context).map(Some)
}
Name::BlobBaseFee => {
anyhow::bail!(
@@ -983,7 +983,7 @@ impl FunctionCall {
);
}
Name::MSize => {
era_compiler_llvm_context::eravm_evm_contract_context::msize(context).map(Some)
revive_llvm_context::eravm_evm_contract_context::msize(context).map(Some)
}
Name::Verbatim {
@@ -1018,10 +1018,10 @@ impl FunctionCall {
///
fn pop_arguments_llvm<'ctx, D, const N: usize>(
&mut self,
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<[inkwell::values::BasicValueEnum<'ctx>; N]>
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
let mut arguments = Vec::with_capacity(N);
for expression in self.arguments.drain(0..N).rev() {
@@ -1037,10 +1037,10 @@ impl FunctionCall {
///
fn pop_arguments<'ctx, D, const N: usize>(
&mut self,
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<[era_compiler_llvm_context::EraVMArgument<'ctx>; N]>
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<[revive_llvm_context::EraVMArgument<'ctx>; N]>
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
let mut arguments = Vec::with_capacity(N);
for expression in self.arguments.drain(0..N).rev() {
@@ -8,13 +8,13 @@ use crate::yul::parser::statement::expression::function_call::FunctionCall;
/// Translates the verbatim simulations.
///
pub fn verbatim<'ctx, D>(
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
call: &mut FunctionCall,
_input_size: usize,
output_size: usize,
) -> anyhow::Result<Option<inkwell::values::BasicValueEnum<'ctx>>>
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
if output_size > 1 {
anyhow::bail!(
@@ -80,10 +80,10 @@ impl Literal {
///
pub fn into_llvm<'ctx, D>(
self,
context: &era_compiler_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<era_compiler_llvm_context::EraVMArgument<'ctx>>
context: &revive_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<revive_llvm_context::EraVMArgument<'ctx>>
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
match self.inner {
LexicalLiteral::Boolean(inner) => {
@@ -105,7 +105,7 @@ impl Literal {
BooleanLiteral::True => num::BigUint::one(),
};
Ok(era_compiler_llvm_context::EraVMArgument::new_with_constant(
Ok(revive_llvm_context::EraVMArgument::new_with_constant(
value, constant,
))
}
@@ -135,7 +135,7 @@ impl Literal {
}
.expect("Always valid");
Ok(era_compiler_llvm_context::EraVMArgument::new_with_constant(
Ok(revive_llvm_context::EraVMArgument::new_with_constant(
value, constant,
))
}
@@ -209,7 +209,7 @@ impl Literal {
};
if hex_string.len() > revive_common::BYTE_LENGTH_FIELD * 2 {
return Ok(era_compiler_llvm_context::EraVMArgument::new_with_original(
return Ok(revive_llvm_context::EraVMArgument::new_with_original(
r#type.const_zero().as_basic_value_enum(),
string,
));
@@ -229,7 +229,7 @@ impl Literal {
)
.expect("The value is valid")
.as_basic_value_enum();
Ok(era_compiler_llvm_context::EraVMArgument::new_with_original(
Ok(revive_llvm_context::EraVMArgument::new_with_original(
value, string,
))
}
@@ -108,10 +108,10 @@ impl Expression {
///
pub fn into_llvm<'ctx, D>(
self,
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<Option<era_compiler_llvm_context::EraVMArgument<'ctx>>>
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<Option<revive_llvm_context::EraVMArgument<'ctx>>>
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
match self {
Self::Literal(literal) => literal
@@ -149,7 +149,7 @@ impl Expression {
match constant {
Some(constant) => Ok(Some(
era_compiler_llvm_context::EraVMArgument::new_with_constant(
revive_llvm_context::EraVMArgument::new_with_constant(
value, constant,
),
)),
@@ -158,7 +158,7 @@ impl Expression {
}
Self::FunctionCall(call) => Ok(call
.into_llvm(context)?
.map(era_compiler_llvm_context::EraVMArgument::new)),
.map(revive_llvm_context::EraVMArgument::new)),
}
}
}
@@ -68,13 +68,13 @@ impl ForLoop {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for ForLoop
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for ForLoop
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn into_llvm(
self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
self.initializer.into_llvm(context)?;
@@ -40,7 +40,7 @@ pub struct FunctionDefinition {
/// The function body block.
pub body: Block,
/// The function LLVM attributes encoded in the identifier.
pub attributes: BTreeSet<era_compiler_llvm_context::EraVMAttribute>,
pub attributes: BTreeSet<revive_llvm_context::EraVMAttribute>,
}
impl FunctionDefinition {
@@ -102,7 +102,7 @@ impl FunctionDefinition {
let (mut arguments, next) = Identifier::parse_typed_list(lexer, None)?;
if identifier
.inner
.contains(era_compiler_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
.contains(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
{
if arguments.is_empty() {
return Err(ParserError::InvalidNumberOfArguments {
@@ -117,7 +117,7 @@ impl FunctionDefinition {
arguments.remove(0);
}
if identifier.inner.contains(
era_compiler_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER,
revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_EXCEPTION_HANDLER,
) && !arguments.is_empty()
{
return Err(ParserError::InvalidNumberOfArguments {
@@ -192,7 +192,7 @@ impl FunctionDefinition {
///
pub fn get_llvm_attributes(
identifier: &Identifier,
) -> Result<BTreeSet<era_compiler_llvm_context::EraVMAttribute>, Error> {
) -> Result<BTreeSet<revive_llvm_context::EraVMAttribute>, Error> {
let mut valid_attributes = BTreeSet::new();
let llvm_begin = identifier.inner.find(Self::LLVM_ATTRIBUTE_PREFIX);
@@ -209,7 +209,7 @@ impl FunctionDefinition {
let mut invalid_attributes = BTreeSet::new();
for value in attribute_string.split('_') {
match era_compiler_llvm_context::EraVMAttribute::try_from(value) {
match revive_llvm_context::EraVMAttribute::try_from(value) {
Ok(attribute) => valid_attributes.insert(attribute),
Err(value) => invalid_attributes.insert(value),
};
@@ -227,13 +227,13 @@ impl FunctionDefinition {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for FunctionDefinition
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for FunctionDefinition
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn declare(
&mut self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
let argument_types: Vec<_> = self
.arguments
@@ -248,7 +248,7 @@ where
argument_types,
self.result.len(),
self.identifier
.starts_with(era_compiler_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX),
.starts_with(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX),
);
let function = context.add_function(
@@ -257,7 +257,7 @@ where
self.result.len(),
Some(inkwell::module::Linkage::Private),
)?;
era_compiler_llvm_context::EraVMFunction::set_attributes(
revive_llvm_context::EraVMFunction::set_attributes(
context.llvm(),
function.borrow().declaration(),
self.attributes.clone().into_iter().collect(),
@@ -265,22 +265,22 @@ where
);
function
.borrow_mut()
.set_yul_data(era_compiler_llvm_context::EraVMFunctionYulData::default());
.set_yul_data(revive_llvm_context::EraVMFunctionYulData::default());
Ok(())
}
fn into_llvm(
mut self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
context.set_current_function(self.identifier.as_str())?;
let r#return = context.current_function().borrow().r#return();
context.set_basic_block(context.current_function().borrow().entry_block());
match r#return {
era_compiler_llvm_context::EraVMFunctionReturn::None => {}
era_compiler_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
revive_llvm_context::EraVMFunctionReturn::None => {}
revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
let identifier = self.result.pop().expect("Always exists");
let r#type = identifier.r#type.unwrap_or_default();
context.build_store(pointer, r#type.into_llvm(context).const_zero())?;
@@ -289,7 +289,7 @@ where
.borrow_mut()
.insert_stack_pointer(identifier.inner, pointer);
}
era_compiler_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => {
revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => {
for (index, identifier) in self.result.into_iter().enumerate() {
let r#type = identifier.r#type.unwrap_or_default().into_llvm(context);
let pointer = context.build_gep(
@@ -328,10 +328,10 @@ where
.insert_stack_pointer(argument.inner.clone(), pointer);
if self
.identifier
.starts_with(era_compiler_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
.starts_with(revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX)
&& matches!(
context.current_function().borrow().r#return(),
era_compiler_llvm_context::EraVMFunctionReturn::Compound { .. }
revive_llvm_context::EraVMFunctionReturn::Compound { .. }
)
&& context.is_system_mode()
{
@@ -357,21 +357,21 @@ where
context.set_basic_block(context.current_function().borrow().return_block());
match context.current_function().borrow().r#return() {
era_compiler_llvm_context::EraVMFunctionReturn::None => {
revive_llvm_context::EraVMFunctionReturn::None => {
context.build_return(None);
}
era_compiler_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
revive_llvm_context::EraVMFunctionReturn::Primitive { pointer } => {
let return_value = context.build_load(pointer, "return_value")?;
context.build_return(Some(&return_value));
}
era_compiler_llvm_context::EraVMFunctionReturn::Compound { pointer, .. }
revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. }
if context.current_function().borrow().name().starts_with(
era_compiler_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX,
revive_llvm_context::EraVMFunction::ZKSYNC_NEAR_CALL_ABI_PREFIX,
) =>
{
context.build_return(Some(&pointer.value));
}
era_compiler_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => {
revive_llvm_context::EraVMFunctionReturn::Compound { pointer, .. } => {
let return_value = context.build_load(pointer, "return_value")?;
context.build_return(Some(&return_value));
}
@@ -56,13 +56,13 @@ impl IfConditional {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for IfConditional
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for IfConditional
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn into_llvm(
self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
let condition = self
.condition
@@ -183,35 +183,35 @@ impl Object {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Object
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Object
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn declare(
&mut self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
let mut entry = era_compiler_llvm_context::EraVMEntryFunction::default();
let mut entry = revive_llvm_context::EraVMEntryFunction::default();
entry.declare(context)?;
let mut runtime = era_compiler_llvm_context::EraVMRuntime::new(
era_compiler_llvm_context::EraVMAddressSpace::Heap,
let mut runtime = revive_llvm_context::EraVMRuntime::new(
revive_llvm_context::EraVMAddressSpace::Heap,
);
runtime.declare(context)?;
era_compiler_llvm_context::EraVMDeployCodeFunction::new(
era_compiler_llvm_context::EraVMDummyLLVMWritable::default(),
revive_llvm_context::EraVMDeployCodeFunction::new(
revive_llvm_context::EraVMDummyLLVMWritable::default(),
)
.declare(context)?;
era_compiler_llvm_context::EraVMRuntimeCodeFunction::new(
era_compiler_llvm_context::EraVMDummyLLVMWritable::default(),
revive_llvm_context::EraVMRuntimeCodeFunction::new(
revive_llvm_context::EraVMDummyLLVMWritable::default(),
)
.declare(context)?;
for name in [
era_compiler_llvm_context::EraVMRuntime::FUNCTION_DEPLOY_CODE,
era_compiler_llvm_context::EraVMRuntime::FUNCTION_RUNTIME_CODE,
era_compiler_llvm_context::EraVMRuntime::FUNCTION_ENTRY,
revive_llvm_context::EraVMRuntime::FUNCTION_DEPLOY_CODE,
revive_llvm_context::EraVMRuntime::FUNCTION_RUNTIME_CODE,
revive_llvm_context::EraVMRuntime::FUNCTION_ENTRY,
]
.into_iter()
{
@@ -219,7 +219,7 @@ where
.get_function(name)
.expect("Always exists")
.borrow_mut()
.set_yul_data(era_compiler_llvm_context::EraVMFunctionYulData::default());
.set_yul_data(revive_llvm_context::EraVMFunctionYulData::default());
}
entry.into_llvm(context)?;
@@ -229,13 +229,13 @@ where
fn into_llvm(
self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
if self.identifier.ends_with("_deployed") {
era_compiler_llvm_context::EraVMRuntimeCodeFunction::new(self.code)
revive_llvm_context::EraVMRuntimeCodeFunction::new(self.code)
.into_llvm(context)?;
} else {
era_compiler_llvm_context::EraVMDeployCodeFunction::new(self.code)
revive_llvm_context::EraVMDeployCodeFunction::new(self.code)
.into_llvm(context)?;
}
@@ -244,8 +244,8 @@ where
object.into_llvm(context)?;
}
None => {
let runtime = era_compiler_llvm_context::EraVMRuntime::new(
era_compiler_llvm_context::EraVMAddressSpace::Heap,
let runtime = revive_llvm_context::EraVMRuntime::new(
revive_llvm_context::EraVMAddressSpace::Heap,
);
runtime.into_llvm(context)?;
}
@@ -128,13 +128,13 @@ impl Switch {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Switch
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Switch
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn into_llvm(
self,
context: &mut era_compiler_llvm_context::EraVMContext<D>,
context: &mut revive_llvm_context::EraVMContext<D>,
) -> anyhow::Result<()> {
let scrutinee = self.expression.into_llvm(context)?;
@@ -99,13 +99,13 @@ impl VariableDeclaration {
}
}
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for VariableDeclaration
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for VariableDeclaration
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
fn into_llvm<'ctx>(
mut self,
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
) -> anyhow::Result<()> {
if self.bindings.len() == 1 {
let identifier = self.bindings.remove(0);
+2 -2
View File
@@ -73,10 +73,10 @@ impl Type {
///
pub fn into_llvm<'ctx, D>(
self,
context: &era_compiler_llvm_context::EraVMContext<'ctx, D>,
context: &revive_llvm_context::EraVMContext<'ctx, D>,
) -> inkwell::types::IntType<'ctx>
where
D: era_compiler_llvm_context::EraVMDependency + Clone,
D: revive_llvm_context::EraVMDependency + Clone,
{
match self {
Self::Bool => context.integer_type(revive_common::BIT_LENGTH_BOOLEAN),