mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-05-01 13:27:55 +00:00
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user