mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-27 06:58:00 +00:00
Generated
+26
-26
@@ -672,30 +672,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "era-compiler-llvm-context"
|
||||
version = "1.4.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hex",
|
||||
"inkwell",
|
||||
"itertools 0.12.1",
|
||||
"md5",
|
||||
"num",
|
||||
"once_cell",
|
||||
"pallet-contracts-pvm-llapi",
|
||||
"regex",
|
||||
"revive-builtins",
|
||||
"revive-common",
|
||||
"revive-linker",
|
||||
"revive-stdlib",
|
||||
"semver 1.0.22",
|
||||
"serde",
|
||||
"sha2",
|
||||
"sha3",
|
||||
"zkevm_opcode_defs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.8"
|
||||
@@ -1670,10 +1646,10 @@ dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-sol-types",
|
||||
"env_logger",
|
||||
"era-compiler-llvm-context",
|
||||
"hex",
|
||||
"polkavm",
|
||||
"revive-differential",
|
||||
"revive-llvm-context",
|
||||
"revive-solidity",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1694,13 +1670,36 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revive-llvm-context"
|
||||
version = "1.4.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hex",
|
||||
"inkwell",
|
||||
"itertools 0.12.1",
|
||||
"md5",
|
||||
"num",
|
||||
"once_cell",
|
||||
"pallet-contracts-pvm-llapi",
|
||||
"regex",
|
||||
"revive-builtins",
|
||||
"revive-common",
|
||||
"revive-linker",
|
||||
"revive-stdlib",
|
||||
"semver 1.0.22",
|
||||
"serde",
|
||||
"sha2",
|
||||
"sha3",
|
||||
"zkevm_opcode_defs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revive-solidity"
|
||||
version = "1.4.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"colored",
|
||||
"era-compiler-llvm-context",
|
||||
"hex",
|
||||
"inkwell",
|
||||
"md5",
|
||||
@@ -1712,6 +1711,7 @@ dependencies = [
|
||||
"rayon",
|
||||
"regex",
|
||||
"revive-common",
|
||||
"revive-llvm-context",
|
||||
"semver 1.0.22",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -14,7 +14,7 @@ env_logger = { workspace = true }
|
||||
|
||||
revive-solidity = { path = "../solidity" }
|
||||
revive-differential = { path = "../differential" }
|
||||
era-compiler-llvm-context = { path = "../llvm-context" }
|
||||
revive-llvm-context = { path = "../llvm-context" }
|
||||
|
||||
[dev-dependencies]
|
||||
sha1 = { workspace = true }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"ERC20": 53186,
|
||||
"Baseline": 3912,
|
||||
"Fibonacci": 5971,
|
||||
"Flipper": 4354,
|
||||
"Computation": 7380
|
||||
"Computation": 7380,
|
||||
"Fibonacci": 5971
|
||||
}
|
||||
@@ -53,7 +53,7 @@ pub fn compile_blob_with_options(
|
||||
Default::default(),
|
||||
None,
|
||||
pipeline,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
solc_optimizer_enabled,
|
||||
)
|
||||
.expect("source should compile")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "era-compiler-llvm-context"
|
||||
name = "revive-llvm-context"
|
||||
version = "1.4.1"
|
||||
authors = [
|
||||
"Oleksandr Zarudnyi <a.zarudnyy@matterlabs.dev>",
|
||||
|
||||
@@ -38,7 +38,7 @@ md5 = { workspace = true }
|
||||
inkwell = { workspace = true }
|
||||
|
||||
revive-common = { path = "../common" }
|
||||
era-compiler-llvm-context = { path = "../llvm-context" }
|
||||
revive-llvm-context = { path = "../llvm-context" }
|
||||
|
||||
|
||||
[target.'cfg(target_env = "musl")'.dependencies]
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct Contract {
|
||||
/// The auxiliary identifier. Used to identify Yul objects.
|
||||
pub identifier: String,
|
||||
/// The LLVM module build.
|
||||
pub build: era_compiler_llvm_context::EraVMBuild,
|
||||
pub build: revive_llvm_context::EraVMBuild,
|
||||
/// The metadata JSON.
|
||||
pub metadata_json: serde_json::Value,
|
||||
/// The factory dependencies.
|
||||
@@ -37,7 +37,7 @@ impl Contract {
|
||||
pub fn new(
|
||||
path: String,
|
||||
identifier: String,
|
||||
build: era_compiler_llvm_context::EraVMBuild,
|
||||
build: revive_llvm_context::EraVMBuild,
|
||||
metadata_json: serde_json::Value,
|
||||
factory_dependencies: HashSet<String>,
|
||||
) -> Self {
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
/// Translates the contract hash copying.
|
||||
///
|
||||
pub fn contract_hash<'ctx, D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
offset: inkwell::values::IntValue<'ctx>,
|
||||
value: inkwell::values::IntValue<'ctx>,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let offset = context.builder().build_int_add(
|
||||
offset,
|
||||
@@ -21,7 +21,7 @@ where
|
||||
"datacopy_contract_hash_offset",
|
||||
)?;
|
||||
|
||||
era_compiler_llvm_context::eravm_evm_memory::store(context, offset, value)?;
|
||||
revive_llvm_context::eravm_evm_memory::store(context, offset, value)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -30,14 +30,14 @@ where
|
||||
/// Translates the library marker copying.
|
||||
///
|
||||
pub fn library_marker<D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
offset: u64,
|
||||
value: u64,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
era_compiler_llvm_context::eravm_evm_memory::store_byte(
|
||||
revive_llvm_context::eravm_evm_memory::store_byte(
|
||||
context,
|
||||
context.field_const(offset),
|
||||
context.field_const(value),
|
||||
@@ -50,12 +50,12 @@ where
|
||||
/// Translates the static data copying.
|
||||
///
|
||||
pub fn static_data<'ctx, D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
destination: inkwell::values::IntValue<'ctx>,
|
||||
source: &str,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let mut offset = 0;
|
||||
for (index, chunk) in source
|
||||
@@ -76,7 +76,7 @@ where
|
||||
format!("datacopy_destination_index_{index}").as_str(),
|
||||
)?;
|
||||
let datacopy_value = context.field_const_str_hex(value_string.as_str());
|
||||
era_compiler_llvm_context::eravm_evm_memory::store(
|
||||
revive_llvm_context::eravm_evm_memory::store(
|
||||
context,
|
||||
datacopy_destination,
|
||||
datacopy_value,
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
/// Translates the unconditional jump.
|
||||
///
|
||||
pub fn unconditional<D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
destination: num::BigUint,
|
||||
stack_hash: md5::Digest,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let code_type = context
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?;
|
||||
let block_key = era_compiler_llvm_context::EraVMFunctionBlockKey::new(code_type, destination);
|
||||
let block_key = revive_llvm_context::EraVMFunctionBlockKey::new(code_type, destination);
|
||||
|
||||
let block = context
|
||||
.current_function()
|
||||
@@ -32,24 +32,24 @@ where
|
||||
/// Translates the conditional jump.
|
||||
///
|
||||
pub fn conditional<D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
destination: num::BigUint,
|
||||
stack_hash: md5::Digest,
|
||||
stack_height: usize,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let code_type = context
|
||||
.code_type()
|
||||
.ok_or_else(|| anyhow::anyhow!("The contract code part type is undefined"))?;
|
||||
let block_key = era_compiler_llvm_context::EraVMFunctionBlockKey::new(code_type, destination);
|
||||
let block_key = revive_llvm_context::EraVMFunctionBlockKey::new(code_type, destination);
|
||||
|
||||
let condition_pointer = context.evmla().stack[stack_height]
|
||||
.to_llvm()
|
||||
.into_pointer_value();
|
||||
let condition = context.build_load(
|
||||
era_compiler_llvm_context::EraVMPointer::new_stack_field(context, condition_pointer),
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(context, condition_pointer),
|
||||
format!("conditional_{block_key}_condition").as_str(),
|
||||
)?;
|
||||
let condition = context.builder().build_int_compare(
|
||||
|
||||
@@ -342,11 +342,11 @@ impl Instruction {
|
||||
///
|
||||
pub fn recursive_call(
|
||||
name: String,
|
||||
entry_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
entry_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
stack_hash: md5::Digest,
|
||||
input_size: usize,
|
||||
output_size: usize,
|
||||
return_address: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
return_address: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
previous: &Self,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -374,7 +374,7 @@ pub enum Name {
|
||||
/// The called function name.
|
||||
name: String,
|
||||
/// The called function key.
|
||||
entry_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
entry_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
/// The stack state hash after return.
|
||||
stack_hash: md5::Digest,
|
||||
/// The input size.
|
||||
@@ -382,7 +382,7 @@ pub enum Name {
|
||||
/// The output size.
|
||||
output_size: usize,
|
||||
/// The return address.
|
||||
return_address: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
return_address: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
},
|
||||
/// The recursive function return instruction.
|
||||
#[serde(skip)]
|
||||
|
||||
@@ -8,11 +8,11 @@ use inkwell::values::BasicValue;
|
||||
/// Translates the ordinar value push.
|
||||
///
|
||||
pub fn push<'ctx, D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
value: String,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let result = context
|
||||
.field_type()
|
||||
@@ -29,11 +29,11 @@ where
|
||||
/// Translates the block tag label push.
|
||||
///
|
||||
pub fn push_tag<'ctx, D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
value: String,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let result = context
|
||||
.field_type()
|
||||
@@ -46,17 +46,17 @@ where
|
||||
/// Translates the stack memory duplicate.
|
||||
///
|
||||
pub fn dup<'ctx, D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
offset: usize,
|
||||
height: usize,
|
||||
original: &mut Option<String>,
|
||||
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let element = &context.evmla().stack[height - offset - 1];
|
||||
let value = context.build_load(
|
||||
era_compiler_llvm_context::EraVMPointer::new_stack_field(
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
context,
|
||||
element.to_llvm().into_pointer_value(),
|
||||
),
|
||||
@@ -72,22 +72,22 @@ where
|
||||
/// Translates the stack memory swap.
|
||||
///
|
||||
pub fn swap<D>(
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
offset: usize,
|
||||
height: usize,
|
||||
) -> anyhow::Result<()>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let top_element = context.evmla().stack[height - 1].to_owned();
|
||||
let top_pointer = era_compiler_llvm_context::EraVMPointer::new_stack_field(
|
||||
let top_pointer = revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
context,
|
||||
top_element.to_llvm().into_pointer_value(),
|
||||
);
|
||||
let top_value = context.build_load(top_pointer, format!("swap{offset}_top_value").as_str())?;
|
||||
|
||||
let swap_element = context.evmla().stack[height - offset - 1].to_owned();
|
||||
let swap_pointer = era_compiler_llvm_context::EraVMPointer::new_stack_field(
|
||||
let swap_pointer = revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
context,
|
||||
swap_element.to_llvm().into_pointer_value(),
|
||||
);
|
||||
@@ -106,9 +106,9 @@ where
|
||||
///
|
||||
/// Translates the stack memory pop.
|
||||
///
|
||||
pub fn pop<D>(_context: &mut era_compiler_llvm_context::EraVMContext<D>) -> anyhow::Result<()>
|
||||
pub fn pop<D>(_context: &mut revive_llvm_context::EraVMContext<D>) -> anyhow::Result<()>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ impl Assembly {
|
||||
///
|
||||
pub fn keccak256(&self) -> String {
|
||||
let json = serde_json::to_vec(self).expect("Always valid");
|
||||
era_compiler_llvm_context::eravm_utils::keccak256(json.as_slice())
|
||||
revive_llvm_context::eravm_utils::keccak256(json.as_slice())
|
||||
}
|
||||
|
||||
///
|
||||
@@ -197,28 +197,28 @@ impl Assembly {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Assembly
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Assembly
|
||||
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)?;
|
||||
|
||||
@@ -231,7 +231,7 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
mut self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
let full_path = self.full_path().to_owned();
|
||||
|
||||
@@ -240,7 +240,7 @@ where
|
||||
}
|
||||
let deploy_code_blocks = EtherealIR::get_blocks(
|
||||
context.evmla().version.to_owned(),
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
self.code
|
||||
.as_deref()
|
||||
.ok_or_else(|| anyhow::anyhow!("Deploy code instructions not found"))?,
|
||||
@@ -267,7 +267,7 @@ where
|
||||
};
|
||||
let runtime_code_blocks = EtherealIR::get_blocks(
|
||||
context.evmla().version.to_owned(),
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
runtime_code_instructions.as_slice(),
|
||||
)?;
|
||||
|
||||
@@ -282,12 +282,12 @@ where
|
||||
ethereal_ir.declare(context)?;
|
||||
ethereal_ir.into_llvm(context)?;
|
||||
|
||||
era_compiler_llvm_context::EraVMDeployCodeFunction::new(EntryLink::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMDeployCodeFunction::new(EntryLink::new(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
))
|
||||
.into_llvm(context)?;
|
||||
era_compiler_llvm_context::EraVMRuntimeCodeFunction::new(EntryLink::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMRuntimeCodeFunction::new(EntryLink::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
))
|
||||
.into_llvm(context)?;
|
||||
|
||||
|
||||
@@ -14,25 +14,25 @@ use crate::evmla::ethereal_ir::EtherealIR;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EntryLink {
|
||||
/// The code part type.
|
||||
pub code_type: era_compiler_llvm_context::EraVMCodeType,
|
||||
pub code_type: revive_llvm_context::EraVMCodeType,
|
||||
}
|
||||
|
||||
impl EntryLink {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(code_type: era_compiler_llvm_context::EraVMCodeType) -> Self {
|
||||
pub fn new(code_type: revive_llvm_context::EraVMCodeType) -> Self {
|
||||
Self { code_type }
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for EntryLink
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for EntryLink
|
||||
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 target = context
|
||||
.get_function(EtherealIR::DEFAULT_ENTRY_FUNCTION_NAME)
|
||||
@@ -40,10 +40,10 @@ where
|
||||
.borrow()
|
||||
.declaration();
|
||||
let is_deploy_code = match self.code_type {
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy => context
|
||||
revive_llvm_context::EraVMCodeType::Deploy => context
|
||||
.integer_type(revive_common::BIT_LENGTH_BOOLEAN)
|
||||
.const_int(1, false),
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime => context
|
||||
revive_llvm_context::EraVMCodeType::Runtime => context
|
||||
.integer_type(revive_common::BIT_LENGTH_BOOLEAN)
|
||||
.const_int(0, false),
|
||||
};
|
||||
|
||||
@@ -52,10 +52,10 @@ impl Element {
|
||||
///
|
||||
fn pop_arguments_llvm<'ctx, D>(
|
||||
&mut self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<'ctx, D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
) -> Vec<inkwell::values::BasicValueEnum<'ctx>>
|
||||
where
|
||||
D: era_compiler_llvm_context::EraVMDependency + Clone,
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
{
|
||||
let input_size = self.instruction.input_size(&context.evmla().version);
|
||||
let output_size = self.instruction.output_size();
|
||||
@@ -67,7 +67,7 @@ impl Element {
|
||||
.into_pointer_value();
|
||||
let value = context
|
||||
.build_load(
|
||||
era_compiler_llvm_context::EraVMPointer::new_stack_field(context, pointer),
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(context, pointer),
|
||||
format!("argument_{index}").as_str(),
|
||||
)
|
||||
.unwrap();
|
||||
@@ -77,13 +77,13 @@ impl Element {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Element
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Element
|
||||
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 mut original = self.instruction.value.clone();
|
||||
|
||||
@@ -135,7 +135,7 @@ where
|
||||
)
|
||||
.map(Some),
|
||||
InstructionName::PUSH_ContractHash => {
|
||||
era_compiler_llvm_context::eravm_evm_create::contract_hash(
|
||||
revive_llvm_context::eravm_evm_create::contract_hash(
|
||||
context,
|
||||
self.instruction
|
||||
.value
|
||||
@@ -144,7 +144,7 @@ where
|
||||
.map(|argument| Some(argument.value))
|
||||
}
|
||||
InstructionName::PUSH_ContractHashSize => {
|
||||
era_compiler_llvm_context::eravm_evm_create::header_size(
|
||||
revive_llvm_context::eravm_evm_create::header_size(
|
||||
context,
|
||||
self.instruction
|
||||
.value
|
||||
@@ -433,7 +433,7 @@ where
|
||||
|
||||
InstructionName::ADD => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -442,7 +442,7 @@ where
|
||||
}
|
||||
InstructionName::SUB => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -451,7 +451,7 @@ where
|
||||
}
|
||||
InstructionName::MUL => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -460,7 +460,7 @@ where
|
||||
}
|
||||
InstructionName::DIV => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -469,7 +469,7 @@ where
|
||||
}
|
||||
InstructionName::MOD => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -478,7 +478,7 @@ where
|
||||
}
|
||||
InstructionName::SDIV => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -487,7 +487,7 @@ where
|
||||
}
|
||||
InstructionName::SMOD => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -497,7 +497,7 @@ where
|
||||
|
||||
InstructionName::LT => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -507,7 +507,7 @@ where
|
||||
}
|
||||
InstructionName::GT => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -517,7 +517,7 @@ where
|
||||
}
|
||||
InstructionName::EQ => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -527,7 +527,7 @@ where
|
||||
}
|
||||
InstructionName::ISZERO => {
|
||||
let arguments = self.pop_arguments_llvm(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),
|
||||
@@ -537,7 +537,7 @@ where
|
||||
}
|
||||
InstructionName::SLT => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -547,7 +547,7 @@ where
|
||||
}
|
||||
InstructionName::SGT => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -558,7 +558,7 @@ where
|
||||
|
||||
InstructionName::OR => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -567,7 +567,7 @@ where
|
||||
}
|
||||
InstructionName::XOR => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -576,7 +576,7 @@ where
|
||||
}
|
||||
InstructionName::NOT => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -585,7 +585,7 @@ where
|
||||
}
|
||||
InstructionName::AND => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -594,7 +594,7 @@ where
|
||||
}
|
||||
InstructionName::SHL => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -603,7 +603,7 @@ where
|
||||
}
|
||||
InstructionName::SHR => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -612,7 +612,7 @@ where
|
||||
}
|
||||
InstructionName::SAR => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -621,7 +621,7 @@ where
|
||||
}
|
||||
InstructionName::BYTE => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -631,7 +631,7 @@ where
|
||||
|
||||
InstructionName::ADDMOD => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -641,7 +641,7 @@ where
|
||||
}
|
||||
InstructionName::MULMOD => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -651,7 +651,7 @@ where
|
||||
}
|
||||
InstructionName::EXP => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -660,7 +660,7 @@ where
|
||||
}
|
||||
InstructionName::SIGNEXTEND => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -670,7 +670,7 @@ where
|
||||
|
||||
InstructionName::SHA3 | InstructionName::KECCAK256 => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -680,7 +680,7 @@ where
|
||||
|
||||
InstructionName::MLOAD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_memory::load(
|
||||
revive_llvm_context::eravm_evm_memory::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -688,7 +688,7 @@ where
|
||||
}
|
||||
InstructionName::MSTORE => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -697,7 +697,7 @@ where
|
||||
}
|
||||
InstructionName::MSTORE8 => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -706,16 +706,16 @@ where
|
||||
}
|
||||
InstructionName::MCOPY => {
|
||||
let arguments = self.pop_arguments_llvm(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",
|
||||
@@ -733,7 +733,7 @@ where
|
||||
|
||||
InstructionName::SLOAD => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_storage::load(
|
||||
revive_llvm_context::eravm_evm_storage::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -741,7 +741,7 @@ where
|
||||
}
|
||||
InstructionName::SSTORE => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -767,7 +767,7 @@ where
|
||||
.get_or_allocate_immutable(key.as_str());
|
||||
|
||||
let index = context.field_const(offset as u64);
|
||||
era_compiler_llvm_context::eravm_evm_immutable::load(context, index).map(Some)
|
||||
revive_llvm_context::eravm_evm_immutable::load(context, index).map(Some)
|
||||
}
|
||||
InstructionName::ASSIGNIMMUTABLE => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
@@ -781,7 +781,7 @@ where
|
||||
|
||||
let index = context.field_const(offset as u64);
|
||||
let value = arguments.pop().expect("Always exists").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)
|
||||
}
|
||||
|
||||
@@ -790,12 +790,12 @@ where
|
||||
.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 => {
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_calldata::load(
|
||||
revive_llvm_context::eravm_evm_calldata::load(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -808,11 +808,11 @@ where
|
||||
.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -823,11 +823,11 @@ where
|
||||
.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(),
|
||||
@@ -835,8 +835,8 @@ where
|
||||
)
|
||||
.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(),
|
||||
@@ -851,10 +851,10 @@ where
|
||||
.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!()
|
||||
}
|
||||
}
|
||||
@@ -887,18 +887,18 @@ where
|
||||
match context.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::copy(
|
||||
revive_llvm_context::EraVMCodeType::Deploy => {
|
||||
revive_llvm_context::eravm_evm_calldata::copy(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
arguments[1].into_int_value(),
|
||||
arguments[2].into_int_value(),
|
||||
)
|
||||
}
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime => {
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
let calldata_size =
|
||||
era_compiler_llvm_context::eravm_evm_calldata::size(context)?;
|
||||
era_compiler_llvm_context::eravm_evm_calldata::copy(
|
||||
revive_llvm_context::eravm_evm_calldata::size(context)?;
|
||||
revive_llvm_context::eravm_evm_calldata::copy(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
calldata_size.into_int_value(),
|
||||
@@ -912,11 +912,11 @@ where
|
||||
}
|
||||
InstructionName::PUSHSIZE => Ok(Some(context.field_const(0).as_basic_value_enum())),
|
||||
InstructionName::RETURNDATASIZE => {
|
||||
era_compiler_llvm_context::eravm_evm_return_data::size(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_return_data::size(context).map(Some)
|
||||
}
|
||||
InstructionName::RETURNDATACOPY => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -926,7 +926,7 @@ where
|
||||
}
|
||||
InstructionName::EXTCODESIZE => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_ext_code::size(
|
||||
revive_llvm_context::eravm_evm_ext_code::size(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -934,7 +934,7 @@ where
|
||||
}
|
||||
InstructionName::EXTCODEHASH => {
|
||||
let arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_ext_code::hash(
|
||||
revive_llvm_context::eravm_evm_ext_code::hash(
|
||||
context,
|
||||
arguments[0].into_int_value(),
|
||||
)
|
||||
@@ -943,7 +943,7 @@ where
|
||||
|
||||
InstructionName::RETURN => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -952,7 +952,7 @@ where
|
||||
}
|
||||
InstructionName::REVERT => {
|
||||
let arguments = self.pop_arguments_llvm(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(),
|
||||
@@ -960,15 +960,15 @@ where
|
||||
.map(|_| None)
|
||||
}
|
||||
InstructionName::STOP => {
|
||||
era_compiler_llvm_context::eravm_evm_return::stop(context).map(|_| None)
|
||||
revive_llvm_context::eravm_evm_return::stop(context).map(|_| None)
|
||||
}
|
||||
InstructionName::INVALID => {
|
||||
era_compiler_llvm_context::eravm_evm_return::invalid(context).map(|_| None)
|
||||
revive_llvm_context::eravm_evm_return::invalid(context).map(|_| None)
|
||||
}
|
||||
|
||||
InstructionName::LOG0 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -981,7 +981,7 @@ where
|
||||
}
|
||||
InstructionName::LOG1 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -994,7 +994,7 @@ where
|
||||
}
|
||||
InstructionName::LOG2 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -1007,7 +1007,7 @@ where
|
||||
}
|
||||
InstructionName::LOG3 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -1020,7 +1020,7 @@ where
|
||||
}
|
||||
InstructionName::LOG4 => {
|
||||
let mut arguments = self.pop_arguments_llvm(context);
|
||||
era_compiler_llvm_context::eravm_evm_event::log(
|
||||
revive_llvm_context::eravm_evm_event::log(
|
||||
context,
|
||||
arguments.remove(0).into_int_value(),
|
||||
arguments.remove(0).into_int_value(),
|
||||
@@ -1045,7 +1045,7 @@ where
|
||||
|
||||
todo!()
|
||||
/*
|
||||
era_compiler_llvm_context::eravm_evm_call::default(
|
||||
revive_llvm_context::eravm_evm_call::default(
|
||||
context,
|
||||
context.llvm_runtime().far_call,
|
||||
gas,
|
||||
@@ -1070,7 +1070,7 @@ where
|
||||
let output_offset = arguments.remove(0).into_int_value();
|
||||
let output_size = arguments.remove(0).into_int_value();
|
||||
|
||||
era_compiler_llvm_context::eravm_evm_call::default(
|
||||
revive_llvm_context::eravm_evm_call::default(
|
||||
context,
|
||||
context.llvm_runtime().static_call,
|
||||
gas,
|
||||
@@ -1094,7 +1094,7 @@ where
|
||||
let output_offset = arguments.remove(0).into_int_value();
|
||||
let output_size = arguments.remove(0).into_int_value();
|
||||
|
||||
era_compiler_llvm_context::eravm_evm_call::default(
|
||||
revive_llvm_context::eravm_evm_call::default(
|
||||
context,
|
||||
context.llvm_runtime().delegate_call,
|
||||
gas,
|
||||
@@ -1116,7 +1116,7 @@ where
|
||||
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,
|
||||
@@ -1132,7 +1132,7 @@ where
|
||||
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,
|
||||
@@ -1146,44 +1146,44 @@ where
|
||||
InstructionName::CALLER => todo!(),
|
||||
|
||||
InstructionName::CALLVALUE => {
|
||||
era_compiler_llvm_context::eravm_evm_ether_gas::value(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_ether_gas::value(context).map(Some)
|
||||
}
|
||||
InstructionName::GAS => {
|
||||
era_compiler_llvm_context::eravm_evm_ether_gas::gas(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_ether_gas::gas(context).map(Some)
|
||||
}
|
||||
InstructionName::BALANCE => {
|
||||
let arguments = self.pop_arguments_llvm(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)
|
||||
}
|
||||
InstructionName::SELFBALANCE => todo!(),
|
||||
|
||||
InstructionName::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)
|
||||
}
|
||||
InstructionName::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)
|
||||
}
|
||||
InstructionName::ORIGIN => {
|
||||
era_compiler_llvm_context::eravm_evm_contract_context::origin(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_contract_context::origin(context).map(Some)
|
||||
}
|
||||
InstructionName::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)
|
||||
}
|
||||
InstructionName::TIMESTAMP => {
|
||||
era_compiler_llvm_context::eravm_evm_contract_context::block_timestamp(context)
|
||||
revive_llvm_context::eravm_evm_contract_context::block_timestamp(context)
|
||||
.map(Some)
|
||||
}
|
||||
InstructionName::NUMBER => {
|
||||
era_compiler_llvm_context::eravm_evm_contract_context::block_number(context)
|
||||
revive_llvm_context::eravm_evm_contract_context::block_number(context)
|
||||
.map(Some)
|
||||
}
|
||||
InstructionName::BLOCKHASH => {
|
||||
let arguments = self.pop_arguments_llvm(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)
|
||||
}
|
||||
InstructionName::BLOBHASH => {
|
||||
@@ -1191,19 +1191,19 @@ where
|
||||
anyhow::bail!("The `BLOBHASH` instruction is not supported until zkVM v1.5.0");
|
||||
}
|
||||
InstructionName::DIFFICULTY | InstructionName::PREVRANDAO => {
|
||||
era_compiler_llvm_context::eravm_evm_contract_context::difficulty(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_contract_context::difficulty(context).map(Some)
|
||||
}
|
||||
InstructionName::COINBASE => {
|
||||
era_compiler_llvm_context::eravm_evm_contract_context::coinbase(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_contract_context::coinbase(context).map(Some)
|
||||
}
|
||||
InstructionName::BASEFEE => {
|
||||
era_compiler_llvm_context::eravm_evm_contract_context::basefee(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_contract_context::basefee(context).map(Some)
|
||||
}
|
||||
InstructionName::BLOBBASEFEE => {
|
||||
anyhow::bail!("The `BLOBBASEFEE` instruction is not supported until zkVM v1.5.0");
|
||||
}
|
||||
InstructionName::MSIZE => {
|
||||
era_compiler_llvm_context::eravm_evm_contract_context::msize(context).map(Some)
|
||||
revive_llvm_context::eravm_evm_contract_context::msize(context).map(Some)
|
||||
}
|
||||
|
||||
InstructionName::CALLCODE => {
|
||||
@@ -1252,7 +1252,7 @@ where
|
||||
.to_llvm()
|
||||
.into_pointer_value();
|
||||
context.build_store(
|
||||
era_compiler_llvm_context::EraVMPointer::new_stack_field(
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(
|
||||
context, pointer,
|
||||
),
|
||||
value,
|
||||
@@ -1269,9 +1269,9 @@ where
|
||||
format!("return_value_element_{}", index).as_str(),
|
||||
)
|
||||
.expect("Always exists");
|
||||
let pointer = era_compiler_llvm_context::EraVMPointer::new(
|
||||
let pointer = revive_llvm_context::EraVMPointer::new(
|
||||
context.field_type(),
|
||||
era_compiler_llvm_context::EraVMAddressSpace::Stack,
|
||||
revive_llvm_context::EraVMAddressSpace::Stack,
|
||||
context.evmla().stack
|
||||
[self.stack.elements.len() - output_size + index]
|
||||
.to_llvm()
|
||||
@@ -1300,12 +1300,12 @@ where
|
||||
arguments.pop();
|
||||
|
||||
match context.current_function().borrow().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 } => {
|
||||
assert_eq!(arguments.len(), 1);
|
||||
context.build_store(pointer, arguments.remove(0))?;
|
||||
}
|
||||
era_compiler_llvm_context::EraVMFunctionReturn::Compound {
|
||||
revive_llvm_context::EraVMFunctionReturn::Compound {
|
||||
pointer, ..
|
||||
} => {
|
||||
for (index, argument) in arguments.into_iter().enumerate() {
|
||||
@@ -1335,7 +1335,7 @@ where
|
||||
.to_llvm()
|
||||
.into_pointer_value();
|
||||
context.build_store(
|
||||
era_compiler_llvm_context::EraVMPointer::new_stack_field(context, pointer),
|
||||
revive_llvm_context::EraVMPointer::new_stack_field(context, pointer),
|
||||
result,
|
||||
)?;
|
||||
context.evmla_mut().stack[self.stack.elements.len() - 1].original = original;
|
||||
|
||||
@@ -22,13 +22,13 @@ pub struct Block {
|
||||
/// The Solidity compiler version.
|
||||
pub solc_version: semver::Version,
|
||||
/// The block key.
|
||||
pub key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
pub key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
/// The block instance.
|
||||
pub instance: Option<usize>,
|
||||
/// The block elements relevant to the stack consistency.
|
||||
pub elements: Vec<Element>,
|
||||
/// The block predecessors.
|
||||
pub predecessors: HashSet<(era_compiler_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
pub predecessors: HashSet<(revive_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
/// The initial stack state.
|
||||
pub initial_stack: ElementStack,
|
||||
/// The stack.
|
||||
@@ -48,7 +48,7 @@ impl Block {
|
||||
///
|
||||
pub fn try_from_instructions(
|
||||
solc_version: semver::Version,
|
||||
code_type: era_compiler_llvm_context::EraVMCodeType,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
slice: &[Instruction],
|
||||
) -> anyhow::Result<(Self, usize)> {
|
||||
let mut cursor = 0;
|
||||
@@ -69,7 +69,7 @@ impl Block {
|
||||
|
||||
let mut block = Self {
|
||||
solc_version: solc_version.clone(),
|
||||
key: era_compiler_llvm_context::EraVMFunctionBlockKey::new(code_type, tag),
|
||||
key: revive_llvm_context::EraVMFunctionBlockKey::new(code_type, tag),
|
||||
instance: None,
|
||||
elements: Vec::with_capacity(Self::ELEMENTS_VECTOR_DEFAULT_CAPACITY),
|
||||
predecessors: HashSet::with_capacity(Self::PREDECESSORS_HASHSET_DEFAULT_CAPACITY),
|
||||
@@ -114,20 +114,20 @@ impl Block {
|
||||
///
|
||||
pub fn insert_predecessor(
|
||||
&mut self,
|
||||
key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
instance: usize,
|
||||
) {
|
||||
self.predecessors.insert((key, instance));
|
||||
}
|
||||
}
|
||||
|
||||
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<()> {
|
||||
context.set_code_type(self.key.code_type);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ pub struct Function {
|
||||
/// The function name.
|
||||
pub name: String,
|
||||
/// The separately labelled blocks.
|
||||
pub blocks: BTreeMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Vec<Block>>,
|
||||
pub blocks: BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Vec<Block>>,
|
||||
/// The function type.
|
||||
pub r#type: Type,
|
||||
/// The function stack size.
|
||||
@@ -82,8 +82,8 @@ impl Function {
|
||||
///
|
||||
pub fn traverse(
|
||||
&mut self,
|
||||
blocks: &HashMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
) -> anyhow::Result<()> {
|
||||
@@ -92,8 +92,8 @@ impl Function {
|
||||
match self.r#type {
|
||||
Type::Initial => {
|
||||
for code_type in [
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
] {
|
||||
self.consume_block(
|
||||
blocks,
|
||||
@@ -102,7 +102,7 @@ impl Function {
|
||||
visited_functions,
|
||||
&mut visited_blocks,
|
||||
QueueElement::new(
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
num::BigUint::zero(),
|
||||
),
|
||||
@@ -148,8 +148,8 @@ impl Function {
|
||||
///
|
||||
fn consume_block(
|
||||
&mut self,
|
||||
blocks: &HashMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
visited_blocks: &mut BTreeSet<VisitedElement>,
|
||||
@@ -227,11 +227,11 @@ impl Function {
|
||||
///
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn handle_instruction(
|
||||
blocks: &HashMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
code_type: era_compiler_llvm_context::EraVMCodeType,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
instance: usize,
|
||||
block_stack: &mut Stack,
|
||||
block_element: &mut BlockElement,
|
||||
@@ -260,13 +260,13 @@ impl Function {
|
||||
.ok_or_else(|| anyhow::anyhow!("Destination tag is missing"))?
|
||||
{
|
||||
Element::Tag(destination) if destination > &num::BigUint::from(u32::MAX) => {
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
destination.to_owned() - num::BigUint::from(1u64 << 32),
|
||||
)
|
||||
}
|
||||
Element::Tag(destination) => {
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
destination.to_owned(),
|
||||
)
|
||||
@@ -324,13 +324,13 @@ impl Function {
|
||||
.ok_or_else(|| anyhow::anyhow!("Destination tag is missing"))?
|
||||
{
|
||||
Element::Tag(destination) if destination > &num::BigUint::from(u32::MAX) => {
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
destination.to_owned() - num::BigUint::from(1u64 << 32),
|
||||
)
|
||||
}
|
||||
Element::Tag(destination) => {
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
destination.to_owned(),
|
||||
)
|
||||
@@ -360,7 +360,7 @@ impl Function {
|
||||
} => {
|
||||
let tag: num::BigUint = tag.parse().expect("Always valid");
|
||||
let block_key =
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(code_type, tag);
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(code_type, tag);
|
||||
|
||||
queue_element.predecessor = Some((queue_element.block_key.clone(), instance));
|
||||
queue_element.block_key = block_key.clone();
|
||||
@@ -1023,16 +1023,16 @@ impl Function {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn handle_recursive_function_call(
|
||||
recursive_function: &RecursiveFunction,
|
||||
blocks: &HashMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
functions: &mut BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Self>,
|
||||
extra_metadata: &ExtraMetadata,
|
||||
visited_functions: &mut BTreeSet<VisitedElement>,
|
||||
block_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
block_stack: &mut Stack,
|
||||
block_element: &mut BlockElement,
|
||||
version: &semver::Version,
|
||||
) -> anyhow::Result<(
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
revive_llvm_context::EraVMFunctionBlockKey,
|
||||
Vec<Element>,
|
||||
)> {
|
||||
let return_address_offset = block_stack.elements.len() - 2 - recursive_function.input_size;
|
||||
@@ -1041,7 +1041,7 @@ impl Function {
|
||||
|
||||
let return_address = match block_stack.elements[return_address_offset] {
|
||||
Element::Tag(ref return_address) => {
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
block_key.code_type,
|
||||
return_address.to_owned(),
|
||||
)
|
||||
@@ -1126,14 +1126,14 @@ impl Function {
|
||||
/// Checks both deploy and runtime code.
|
||||
///
|
||||
fn is_tag_value_valid(
|
||||
blocks: &HashMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
tag: &num::BigUint,
|
||||
) -> bool {
|
||||
blocks.contains_key(&era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
blocks.contains_key(&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
tag & num::BigUint::from(u32::MAX),
|
||||
)) || blocks.contains_key(&era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
)) || blocks.contains_key(&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
tag & num::BigUint::from(u32::MAX),
|
||||
))
|
||||
}
|
||||
@@ -1157,13 +1157,13 @@ impl Function {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Function
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Function
|
||||
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 (function_type, output_size) = match self.r#type {
|
||||
Type::Initial => {
|
||||
@@ -1202,7 +1202,7 @@ where
|
||||
Some(inkwell::module::Linkage::Private),
|
||||
)?;
|
||||
function.borrow_mut().set_evmla_data(
|
||||
era_compiler_llvm_context::EraVMFunctionEVMLAData::new(self.stack_size),
|
||||
revive_llvm_context::EraVMFunctionEVMLAData::new(self.stack_size),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
@@ -1210,7 +1210,7 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
context.set_current_function(self.name.as_str())?;
|
||||
|
||||
@@ -1220,8 +1220,8 @@ where
|
||||
let mut stack_hashes = vec![block.initial_stack.hash()];
|
||||
stack_hashes.extend_from_slice(block.extra_hashes.as_slice());
|
||||
let evmla_data =
|
||||
era_compiler_llvm_context::EraVMFunctionBlockEVMLAData::new(stack_hashes);
|
||||
let mut block = era_compiler_llvm_context::EraVMFunctionBlock::new(inner);
|
||||
revive_llvm_context::EraVMFunctionBlockEVMLAData::new(stack_hashes);
|
||||
let mut block = revive_llvm_context::EraVMFunctionBlock::new(inner);
|
||||
block.set_evmla_data(evmla_data);
|
||||
context
|
||||
.current_function()
|
||||
@@ -1253,7 +1253,7 @@ where
|
||||
_ => context.field_const(0).as_basic_value_enum(),
|
||||
};
|
||||
context.build_store(pointer, value)?;
|
||||
stack_variables.push(era_compiler_llvm_context::EraVMArgument::new(
|
||||
stack_variables.push(revive_llvm_context::EraVMArgument::new(
|
||||
pointer.value.as_basic_value_enum(),
|
||||
));
|
||||
}
|
||||
@@ -1267,15 +1267,15 @@ where
|
||||
.get_nth_param(0)
|
||||
.into_int_value();
|
||||
let deploy_code_block = context.current_function().borrow().evmla().find_block(
|
||||
&era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
num::BigUint::zero(),
|
||||
),
|
||||
&Stack::default().hash(),
|
||||
)?;
|
||||
let runtime_code_block = context.current_function().borrow().evmla().find_block(
|
||||
&era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
&revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
num::BigUint::zero(),
|
||||
),
|
||||
&Stack::default().hash(),
|
||||
@@ -1321,14 +1321,14 @@ 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, .. } => {
|
||||
let return_value = context.build_load(pointer, "return_value")?;
|
||||
context.build_return(Some(&return_value));
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ use crate::evmla::ethereal_ir::function::block::element::stack::Stack;
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct QueueElement {
|
||||
/// The block key.
|
||||
pub block_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
pub block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
/// The block predecessor.
|
||||
pub predecessor: Option<(era_compiler_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
pub predecessor: Option<(revive_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
/// The predecessor's last stack state.
|
||||
pub stack: Stack,
|
||||
}
|
||||
@@ -22,8 +22,8 @@ impl QueueElement {
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
block_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
predecessor: Option<(era_compiler_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
predecessor: Option<(revive_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
stack: Stack,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -14,7 +14,7 @@ pub enum Type {
|
||||
/// The function name.
|
||||
name: String,
|
||||
/// The function initial block key.
|
||||
block_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
/// The size of stack input (in cells or 256-bit words).
|
||||
input_size: usize,
|
||||
/// The size of stack output (in cells or 256-bit words).
|
||||
@@ -35,7 +35,7 @@ impl Type {
|
||||
///
|
||||
pub fn new_recursive(
|
||||
name: String,
|
||||
block_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
input_size: usize,
|
||||
output_size: usize,
|
||||
) -> Self {
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::cmp::Ordering;
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct VisitedElement {
|
||||
/// The block key.
|
||||
pub block_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
pub block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
/// The initial stack state hash.
|
||||
pub stack_hash: md5::Digest,
|
||||
}
|
||||
@@ -20,7 +20,7 @@ impl VisitedElement {
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
block_key: era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
stack_hash: md5::Digest,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -40,20 +40,20 @@ impl Ord for VisitedElement {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
match (self.block_key.code_type, other.block_key.code_type) {
|
||||
(
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
) => Ordering::Less,
|
||||
(
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
) => Ordering::Greater,
|
||||
(
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
revive_llvm_context::EraVMCodeType::Deploy,
|
||||
)
|
||||
| (
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
revive_llvm_context::EraVMCodeType::Runtime,
|
||||
) => {
|
||||
let tag_comparison = self.block_key.tag.cmp(&other.block_key.tag);
|
||||
if tag_comparison == Ordering::Equal {
|
||||
|
||||
@@ -37,7 +37,7 @@ pub struct EtherealIR {
|
||||
/// The all-inlined function.
|
||||
pub entry_function: Function,
|
||||
/// The recursive functions.
|
||||
pub recursive_functions: BTreeMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Function>,
|
||||
pub recursive_functions: BTreeMap<revive_llvm_context::EraVMFunctionBlockKey, Function>,
|
||||
}
|
||||
|
||||
impl EtherealIR {
|
||||
@@ -53,7 +53,7 @@ impl EtherealIR {
|
||||
pub fn new(
|
||||
solc_version: semver::Version,
|
||||
extra_metadata: ExtraMetadata,
|
||||
blocks: HashMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
blocks: HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
) -> anyhow::Result<Self> {
|
||||
let mut entry_function = Function::new(solc_version.clone(), FunctionType::new_initial());
|
||||
let mut recursive_functions = BTreeMap::new();
|
||||
@@ -78,9 +78,9 @@ impl EtherealIR {
|
||||
///
|
||||
pub fn get_blocks(
|
||||
solc_version: semver::Version,
|
||||
code_type: era_compiler_llvm_context::EraVMCodeType,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
instructions: &[Instruction],
|
||||
) -> anyhow::Result<HashMap<era_compiler_llvm_context::EraVMFunctionBlockKey, Block>> {
|
||||
) -> anyhow::Result<HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>> {
|
||||
let mut blocks = HashMap::with_capacity(Self::BLOCKS_HASHMAP_DEFAULT_CAPACITY);
|
||||
let mut offset = 0;
|
||||
|
||||
@@ -91,7 +91,7 @@ impl EtherealIR {
|
||||
&instructions[offset..],
|
||||
)?;
|
||||
blocks.insert(
|
||||
era_compiler_llvm_context::EraVMFunctionBlockKey::new(
|
||||
revive_llvm_context::EraVMFunctionBlockKey::new(
|
||||
code_type,
|
||||
block.key.tag.clone(),
|
||||
),
|
||||
@@ -104,13 +104,13 @@ impl EtherealIR {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for EtherealIR
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for EtherealIR
|
||||
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<()> {
|
||||
self.entry_function.declare(context)?;
|
||||
|
||||
@@ -123,7 +123,7 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
context.evmla_mut().stack = vec![];
|
||||
|
||||
|
||||
+13
-13
@@ -54,10 +54,10 @@ use std::path::PathBuf;
|
||||
pub fn yul(
|
||||
input_files: &[PathBuf],
|
||||
solc: &mut SolcCompiler,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
let path = match input_files.len() {
|
||||
1 => input_files.first().expect("Always exists"),
|
||||
@@ -99,10 +99,10 @@ pub fn yul(
|
||||
///
|
||||
pub fn llvm_ir(
|
||||
input_files: &[PathBuf],
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
let path = match input_files.len() {
|
||||
1 => input_files.first().expect("Always exists"),
|
||||
@@ -132,7 +132,7 @@ pub fn llvm_ir(
|
||||
pub fn zkasm(
|
||||
input_files: &[PathBuf],
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
let path = match input_files.len() {
|
||||
1 => input_files.first().expect("Always exists"),
|
||||
@@ -145,7 +145,7 @@ pub fn zkasm(
|
||||
|
||||
let project = Project::try_from_zkasm_path(path)?;
|
||||
|
||||
let optimizer_settings = era_compiler_llvm_context::OptimizerSettings::none();
|
||||
let optimizer_settings = revive_llvm_context::OptimizerSettings::none();
|
||||
let build = project.compile(
|
||||
optimizer_settings,
|
||||
false,
|
||||
@@ -167,7 +167,7 @@ pub fn standard_output(
|
||||
solc: &mut SolcCompiler,
|
||||
evm_version: Option<revive_common::EVMVersion>,
|
||||
solc_optimizer_enabled: bool,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
force_evmla: bool,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
@@ -176,7 +176,7 @@ pub fn standard_output(
|
||||
allow_paths: Option<String>,
|
||||
remappings: Option<BTreeSet<String>>,
|
||||
suppressed_warnings: Option<Vec<Warning>>,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
let solc_version = solc.version()?;
|
||||
let solc_pipeline = SolcPipeline::new(&solc_version, force_evmla);
|
||||
@@ -262,7 +262,7 @@ pub fn standard_json(
|
||||
base_path: Option<String>,
|
||||
include_paths: Vec<String>,
|
||||
allow_paths: Option<String>,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<()> {
|
||||
let solc_version = solc.version()?;
|
||||
let solc_pipeline = SolcPipeline::new(&solc_version, force_evmla);
|
||||
@@ -276,11 +276,11 @@ pub fn standard_json(
|
||||
.collect();
|
||||
|
||||
let optimizer_settings =
|
||||
era_compiler_llvm_context::OptimizerSettings::try_from(&solc_input.settings.optimizer)?;
|
||||
revive_llvm_context::OptimizerSettings::try_from(&solc_input.settings.optimizer)?;
|
||||
|
||||
let include_metadata_hash = match solc_input.settings.metadata {
|
||||
Some(ref metadata) => {
|
||||
metadata.bytecode_hash != Some(era_compiler_llvm_context::EraVMMetadataHash::None)
|
||||
metadata.bytecode_hash != Some(revive_llvm_context::EraVMMetadataHash::None)
|
||||
}
|
||||
None => true,
|
||||
};
|
||||
@@ -343,7 +343,7 @@ pub fn combined_json(
|
||||
solc: &mut SolcCompiler,
|
||||
evm_version: Option<revive_common::EVMVersion>,
|
||||
solc_optimizer_enabled: bool,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
force_evmla: bool,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
@@ -352,7 +352,7 @@ pub fn combined_json(
|
||||
allow_paths: Option<String>,
|
||||
remappings: Option<BTreeSet<String>>,
|
||||
suppressed_warnings: Option<Vec<Warning>>,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
output_directory: Option<PathBuf>,
|
||||
overwrite: bool,
|
||||
) -> anyhow::Result<()> {
|
||||
|
||||
@@ -26,9 +26,9 @@ pub struct Input {
|
||||
/// Enables the test bytecode encoding.
|
||||
pub enable_test_encoding: bool,
|
||||
/// The optimizer settings.
|
||||
pub optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
pub optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
/// The debug output config.
|
||||
pub debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
pub debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
}
|
||||
|
||||
impl Input {
|
||||
@@ -41,8 +41,8 @@ impl Input {
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
enable_test_encoding: bool,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> Self {
|
||||
Self {
|
||||
contract,
|
||||
|
||||
@@ -38,20 +38,20 @@ impl EVMLA {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for EVMLA
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for EVMLA
|
||||
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<()> {
|
||||
self.assembly.declare(context)
|
||||
}
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
self.assembly.into_llvm(context)
|
||||
}
|
||||
|
||||
@@ -81,13 +81,13 @@ impl IR {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for IR
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for IR
|
||||
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<()> {
|
||||
match self {
|
||||
Self::Yul(inner) => inner.declare(context),
|
||||
@@ -99,7 +99,7 @@ where
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
match self {
|
||||
Self::Yul(inner) => inner.into_llvm(context),
|
||||
|
||||
@@ -39,20 +39,20 @@ impl Yul {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D> era_compiler_llvm_context::EraVMWriteLLVM<D> for Yul
|
||||
impl<D> revive_llvm_context::EraVMWriteLLVM<D> for Yul
|
||||
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<()> {
|
||||
self.object.declare(context)
|
||||
}
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
self.object.into_llvm(context)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct Metadata {
|
||||
/// The EraVM compiler version.
|
||||
pub zk_version: semver::Version,
|
||||
/// The EraVM compiler optimizer settings.
|
||||
pub optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
pub optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
@@ -32,7 +32,7 @@ impl Metadata {
|
||||
solc_version: semver::Version,
|
||||
solc_zkvm_edition: Option<semver::Version>,
|
||||
zk_version: semver::Version,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
) -> Self {
|
||||
Self {
|
||||
solc_metadata,
|
||||
|
||||
@@ -11,7 +11,7 @@ use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use sha3::Digest;
|
||||
|
||||
use era_compiler_llvm_context::EraVMWriteLLVM;
|
||||
use revive_llvm_context::EraVMWriteLLVM;
|
||||
|
||||
use crate::build::contract::Contract as ContractBuild;
|
||||
use crate::project::Project;
|
||||
@@ -91,13 +91,13 @@ impl Contract {
|
||||
pub fn compile(
|
||||
mut self,
|
||||
project: Project,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<ContractBuild> {
|
||||
let llvm = inkwell::context::Context::create();
|
||||
let optimizer = era_compiler_llvm_context::Optimizer::new(optimizer_settings);
|
||||
let optimizer = revive_llvm_context::Optimizer::new(optimizer_settings);
|
||||
|
||||
let version = project.version.clone();
|
||||
let identifier = self.identifier().to_owned();
|
||||
@@ -129,7 +129,7 @@ impl Contract {
|
||||
.map_err(|error| anyhow::anyhow!(error.to_string()))?
|
||||
}
|
||||
IR::ZKASM(ref zkasm) => {
|
||||
let build = era_compiler_llvm_context::eravm_build_assembly_text(
|
||||
let build = revive_llvm_context::eravm_build_assembly_text(
|
||||
self.path.as_str(),
|
||||
zkasm.source.as_str(),
|
||||
metadata_hash,
|
||||
@@ -145,7 +145,7 @@ impl Contract {
|
||||
}
|
||||
_ => llvm.create_module(self.path.as_str()),
|
||||
};
|
||||
let mut context = era_compiler_llvm_context::EraVMContext::new(
|
||||
let mut context = revive_llvm_context::EraVMContext::new(
|
||||
&llvm,
|
||||
module,
|
||||
optimizer,
|
||||
@@ -153,15 +153,15 @@ impl Contract {
|
||||
include_metadata_hash,
|
||||
debug_config,
|
||||
);
|
||||
context.set_solidity_data(era_compiler_llvm_context::EraVMContextSolidityData::default());
|
||||
context.set_solidity_data(revive_llvm_context::EraVMContextSolidityData::default());
|
||||
match self.ir {
|
||||
IR::Yul(_) => {
|
||||
let yul_data = era_compiler_llvm_context::EraVMContextYulData::new(is_system_mode);
|
||||
let yul_data = revive_llvm_context::EraVMContextYulData::new(is_system_mode);
|
||||
context.set_yul_data(yul_data);
|
||||
}
|
||||
IR::EVMLA(_) => {
|
||||
let evmla_data =
|
||||
era_compiler_llvm_context::EraVMContextEVMLAData::new(version.default);
|
||||
revive_llvm_context::EraVMContextEVMLAData::new(version.default);
|
||||
context.set_evmla_data(evmla_data);
|
||||
}
|
||||
IR::LLVMIR(_) => {}
|
||||
@@ -206,18 +206,18 @@ impl Contract {
|
||||
|
||||
impl<D> EraVMWriteLLVM<D> for Contract
|
||||
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<()> {
|
||||
self.ir.declare(context)
|
||||
}
|
||||
|
||||
fn into_llvm(
|
||||
self,
|
||||
context: &mut era_compiler_llvm_context::EraVMContext<D>,
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
) -> anyhow::Result<()> {
|
||||
self.ir.into_llvm(context)
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ impl Project {
|
||||
///
|
||||
pub fn compile(
|
||||
self,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
bytecode_encoding_testing: bool,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Build> {
|
||||
let project = self.clone();
|
||||
let results: BTreeMap<String, anyhow::Result<ContractBuild>> = self
|
||||
@@ -230,7 +230,7 @@ impl Project {
|
||||
let source_hash = sha3::Keccak256::digest(source_code.as_bytes()).into();
|
||||
|
||||
let source_version =
|
||||
SolcVersion::new_simple(era_compiler_llvm_context::eravm_const::LLVM_VERSION);
|
||||
SolcVersion::new_simple(revive_llvm_context::eravm_const::LLVM_VERSION);
|
||||
let path = path.to_string_lossy().to_string();
|
||||
|
||||
let mut project_contracts = BTreeMap::new();
|
||||
@@ -262,7 +262,7 @@ impl Project {
|
||||
let source_hash = sha3::Keccak256::digest(source_code.as_bytes()).into();
|
||||
|
||||
let source_version =
|
||||
SolcVersion::new_simple(era_compiler_llvm_context::eravm_const::ZKEVM_VERSION);
|
||||
SolcVersion::new_simple(revive_llvm_context::eravm_const::ZKEVM_VERSION);
|
||||
let path = path.to_string_lossy().to_string();
|
||||
|
||||
let mut project_contracts = BTreeMap::new();
|
||||
@@ -285,14 +285,14 @@ impl Project {
|
||||
}
|
||||
}
|
||||
|
||||
impl era_compiler_llvm_context::EraVMDependency for Project {
|
||||
impl revive_llvm_context::EraVMDependency for Project {
|
||||
fn compile(
|
||||
project: Self,
|
||||
identifier: &str,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
is_system_mode: bool,
|
||||
include_metadata_hash: bool,
|
||||
debug_config: Option<era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<String> {
|
||||
let contract_path = project.resolve_path(identifier)?;
|
||||
let contract = project
|
||||
|
||||
@@ -13,14 +13,14 @@ use serde::Serialize;
|
||||
pub struct Metadata {
|
||||
/// The bytecode hash mode.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub bytecode_hash: Option<era_compiler_llvm_context::EraVMMetadataHash>,
|
||||
pub bytecode_hash: Option<revive_llvm_context::EraVMMetadataHash>,
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(bytecode_hash: era_compiler_llvm_context::EraVMMetadataHash) -> Self {
|
||||
pub fn new(bytecode_hash: revive_llvm_context::EraVMMetadataHash) -> Self {
|
||||
Self {
|
||||
bytecode_hash: Some(bytecode_hash),
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ impl Optimizer {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&Optimizer> for era_compiler_llvm_context::OptimizerSettings {
|
||||
impl TryFrom<&Optimizer> for revive_llvm_context::OptimizerSettings {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(value: &Optimizer) -> Result<Self, Self::Error> {
|
||||
|
||||
@@ -26,18 +26,18 @@ impl ExtraMetadata {
|
||||
///
|
||||
pub fn get(
|
||||
&self,
|
||||
block_key: &era_compiler_llvm_context::EraVMFunctionBlockKey,
|
||||
block_key: &revive_llvm_context::EraVMFunctionBlockKey,
|
||||
) -> Option<&RecursiveFunction> {
|
||||
for function in self.recursive_functions.iter() {
|
||||
match block_key.code_type {
|
||||
era_compiler_llvm_context::EraVMCodeType::Deploy => {
|
||||
revive_llvm_context::EraVMCodeType::Deploy => {
|
||||
if let Some(creation_tag) = function.creation_tag {
|
||||
if num::BigUint::from(creation_tag) == block_key.tag {
|
||||
return Some(function);
|
||||
}
|
||||
}
|
||||
}
|
||||
era_compiler_llvm_context::EraVMCodeType::Runtime => {
|
||||
revive_llvm_context::EraVMCodeType::Runtime => {
|
||||
if let Some(runtime_tag) = function.runtime_tag {
|
||||
if num::BigUint::from(runtime_tag) == block_key.tag {
|
||||
return Some(function);
|
||||
|
||||
@@ -62,7 +62,7 @@ impl Output {
|
||||
libraries: BTreeMap<String, BTreeMap<String, String>>,
|
||||
pipeline: SolcPipeline,
|
||||
solc_version: &SolcVersion,
|
||||
debug_config: Option<&era_compiler_llvm_context::DebugConfig>,
|
||||
debug_config: Option<&revive_llvm_context::DebugConfig>,
|
||||
) -> anyhow::Result<Project> {
|
||||
if let SolcPipeline::EVMLA = pipeline {
|
||||
self.preprocess_dependencies()?;
|
||||
|
||||
@@ -37,7 +37,7 @@ pub fn build_solidity(
|
||||
libraries: BTreeMap<String, BTreeMap<String, String>>,
|
||||
remappings: Option<BTreeSet<String>>,
|
||||
pipeline: SolcPipeline,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
) -> anyhow::Result<SolcStandardJsonOutput> {
|
||||
build_solidity_with_options(
|
||||
sources,
|
||||
@@ -57,13 +57,13 @@ pub fn build_solidity_with_options(
|
||||
libraries: BTreeMap<String, BTreeMap<String, String>>,
|
||||
remappings: Option<BTreeSet<String>>,
|
||||
pipeline: SolcPipeline,
|
||||
optimizer_settings: era_compiler_llvm_context::OptimizerSettings,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
solc_optimizer_enabled: bool,
|
||||
) -> anyhow::Result<SolcStandardJsonOutput> {
|
||||
check_dependencies();
|
||||
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
era_compiler_llvm_context::initialize_target(era_compiler_llvm_context::Target::PVM);
|
||||
revive_llvm_context::initialize_target(revive_llvm_context::Target::PVM);
|
||||
let _ = crate::process::EXECUTABLE.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let mut solc = SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME.to_owned())?;
|
||||
@@ -112,7 +112,7 @@ pub fn build_solidity_with_options_evm(
|
||||
check_dependencies();
|
||||
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
era_compiler_llvm_context::initialize_target(era_compiler_llvm_context::Target::PVM);
|
||||
revive_llvm_context::initialize_target(revive_llvm_context::Target::PVM);
|
||||
let _ = crate::process::EXECUTABLE.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let mut solc = SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME.to_owned())?;
|
||||
@@ -165,7 +165,7 @@ pub fn build_solidity_and_detect_missing_libraries(
|
||||
check_dependencies();
|
||||
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
era_compiler_llvm_context::initialize_target(era_compiler_llvm_context::Target::PVM);
|
||||
revive_llvm_context::initialize_target(revive_llvm_context::Target::PVM);
|
||||
let _ = crate::process::EXECUTABLE.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let mut solc = SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME.to_owned())?;
|
||||
@@ -210,8 +210,8 @@ pub fn build_yul(source_code: &str) -> anyhow::Result<()> {
|
||||
check_dependencies();
|
||||
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
era_compiler_llvm_context::initialize_target(era_compiler_llvm_context::Target::PVM);
|
||||
let optimizer_settings = era_compiler_llvm_context::OptimizerSettings::none();
|
||||
revive_llvm_context::initialize_target(revive_llvm_context::Target::PVM);
|
||||
let optimizer_settings = revive_llvm_context::OptimizerSettings::none();
|
||||
|
||||
let project =
|
||||
Project::try_from_yul_string(PathBuf::from("test.yul").as_path(), source_code, None)?;
|
||||
|
||||
@@ -54,7 +54,7 @@ fn default() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Build failure");
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ contract Test {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
|
||||
@@ -87,7 +87,7 @@ contract Test {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::EVMLA,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
assert!(
|
||||
|
||||
@@ -57,7 +57,7 @@ fn optimizer() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::none(),
|
||||
revive_llvm_context::OptimizerSettings::none(),
|
||||
)
|
||||
.expect("Build failure");
|
||||
let build_optimized_for_cycles = super::build_solidity(
|
||||
@@ -65,7 +65,7 @@ fn optimizer() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Build failure");
|
||||
let build_optimized_for_size = super::build_solidity(
|
||||
@@ -73,7 +73,7 @@ fn optimizer() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::size(),
|
||||
revive_llvm_context::OptimizerSettings::size(),
|
||||
)
|
||||
.expect("Build failure");
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ fn default() {
|
||||
BTreeMap::new(),
|
||||
Some(remappings),
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ contract Test {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ contract FixedCodeCopy {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
@@ -76,7 +76,7 @@ fn callcode_evmla() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::EVMLA,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
@@ -92,7 +92,7 @@ fn callcode_yul() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
@@ -150,7 +150,7 @@ fn extcodecopy_evmla() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::EVMLA,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
@@ -166,7 +166,7 @@ fn extcodecopy_yul() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
@@ -200,7 +200,7 @@ fn selfdestruct_evmla() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::EVMLA,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
@@ -216,7 +216,7 @@ fn selfdestruct_yul() {
|
||||
BTreeMap::new(),
|
||||
None,
|
||||
SolcPipeline::Yul,
|
||||
era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
revive_llvm_context::OptimizerSettings::cycles(),
|
||||
)
|
||||
.expect("Test failure");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -50,7 +50,7 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
.build_global()
|
||||
.expect("Thread pool configuration failure");
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
era_compiler_llvm_context::initialize_target(era_compiler_llvm_context::Target::PVM); // TODO: pass from CLI
|
||||
revive_llvm_context::initialize_target(revive_llvm_context::Target::PVM); // TODO: pass from CLI
|
||||
|
||||
if arguments.recursive_process {
|
||||
return revive_solidity::run_process();
|
||||
@@ -59,7 +59,7 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
let debug_config = match arguments.debug_output_directory {
|
||||
Some(ref debug_output_directory) => {
|
||||
std::fs::create_dir_all(debug_output_directory.as_path())?;
|
||||
Some(era_compiler_llvm_context::DebugConfig::new(
|
||||
Some(revive_llvm_context::DebugConfig::new(
|
||||
debug_output_directory.to_owned(),
|
||||
))
|
||||
}
|
||||
@@ -87,8 +87,8 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
};
|
||||
|
||||
let mut optimizer_settings = match arguments.optimization {
|
||||
Some(mode) => era_compiler_llvm_context::OptimizerSettings::try_from_cli(mode)?,
|
||||
None => era_compiler_llvm_context::OptimizerSettings::cycles(),
|
||||
Some(mode) => revive_llvm_context::OptimizerSettings::try_from_cli(mode)?,
|
||||
None => revive_llvm_context::OptimizerSettings::cycles(),
|
||||
};
|
||||
if arguments.fallback_to_optimizing_for_size {
|
||||
optimizer_settings.enable_fallback_to_size();
|
||||
@@ -102,8 +102,8 @@ fn main_inner() -> anyhow::Result<()> {
|
||||
let include_metadata_hash = match arguments.metadata_hash {
|
||||
Some(metadata_hash) => {
|
||||
let metadata =
|
||||
era_compiler_llvm_context::EraVMMetadataHash::from_str(metadata_hash.as_str())?;
|
||||
metadata != era_compiler_llvm_context::EraVMMetadataHash::None
|
||||
revive_llvm_context::EraVMMetadataHash::from_str(metadata_hash.as_str())?;
|
||||
metadata != revive_llvm_context::EraVMMetadataHash::None
|
||||
}
|
||||
None => true,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user