mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 21:01:01 +00:00
use normal style for comments
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The inner JSON legacy assembly code element.
|
||||
//!
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -9,9 +7,7 @@ use serde::Serialize;
|
||||
|
||||
use crate::evmla::assembly::Assembly;
|
||||
|
||||
///
|
||||
/// The inner JSON legacy assembly code element.
|
||||
///
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
pub enum Data {
|
||||
@@ -24,9 +20,7 @@ pub enum Data {
|
||||
}
|
||||
|
||||
impl Data {
|
||||
///
|
||||
/// Returns the inner assembly reference if it is present.
|
||||
///
|
||||
pub fn get_assembly(&self) -> Option<&Assembly> {
|
||||
match self {
|
||||
Self::Assembly(ref assembly) => Some(assembly),
|
||||
@@ -34,9 +28,7 @@ impl Data {
|
||||
Self::Path(_) => None,
|
||||
}
|
||||
}
|
||||
///
|
||||
/// Returns the inner assembly mutable reference if it is present.
|
||||
///
|
||||
pub fn get_assembly_mut(&mut self) -> Option<&mut Assembly> {
|
||||
match self {
|
||||
Self::Assembly(ref mut assembly) => Some(assembly),
|
||||
@@ -45,9 +37,7 @@ impl Data {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Get the list of missing deployable libraries.
|
||||
///
|
||||
pub fn get_missing_libraries(&self) -> HashSet<String> {
|
||||
match self {
|
||||
Self::Assembly(assembly) => assembly.get_missing_libraries(),
|
||||
@@ -56,9 +46,7 @@ impl Data {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Gets the contract `keccak256` hash.
|
||||
///
|
||||
pub fn keccak256(&self) -> String {
|
||||
match self {
|
||||
Self::Assembly(assembly) => assembly.keccak256(),
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
//!
|
||||
//! Translates the CODECOPY use cases.
|
||||
//!
|
||||
|
||||
///
|
||||
/// Translates the contract hash copying.
|
||||
///
|
||||
pub fn contract_hash<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
offset: inkwell::values::IntValue<'ctx>,
|
||||
@@ -26,9 +22,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Translates the library marker copying.
|
||||
///
|
||||
pub fn library_marker<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
offset: u64,
|
||||
@@ -46,9 +40,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Translates the static data copying.
|
||||
///
|
||||
pub fn static_data<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
destination: inkwell::values::IntValue<'ctx>,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
//!
|
||||
//! Translates the jump operations.
|
||||
//!
|
||||
|
||||
///
|
||||
/// Translates the unconditional jump.
|
||||
///
|
||||
pub fn unconditional<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
destination: num::BigUint,
|
||||
@@ -28,9 +24,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Translates the conditional jump.
|
||||
///
|
||||
pub fn conditional<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
destination: num::BigUint,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The EVM instruction.
|
||||
//!
|
||||
|
||||
pub mod codecopy;
|
||||
pub mod jump;
|
||||
@@ -14,9 +12,7 @@ use serde::Serialize;
|
||||
|
||||
use self::name::Name;
|
||||
|
||||
///
|
||||
/// The EVM instruction.
|
||||
///
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct Instruction {
|
||||
/// The opcode or tag identifier.
|
||||
@@ -34,9 +30,7 @@ pub struct Instruction {
|
||||
}
|
||||
|
||||
impl Instruction {
|
||||
///
|
||||
/// Returns the number of input stack arguments.
|
||||
///
|
||||
pub const fn input_size(&self, version: &semver::Version) -> usize {
|
||||
match self.name {
|
||||
Name::POP => 1,
|
||||
@@ -135,9 +129,7 @@ impl Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the number of output stack arguments.
|
||||
///
|
||||
pub const fn output_size(&self) -> usize {
|
||||
match self.name {
|
||||
Name::PUSH => 1,
|
||||
@@ -285,9 +277,7 @@ impl Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Replaces the instruction data aliases with the actual data.
|
||||
///
|
||||
pub fn replace_data_aliases(
|
||||
instructions: &mut [Self],
|
||||
mapping: &BTreeMap<String, String>,
|
||||
@@ -323,9 +313,7 @@ impl Instruction {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Initializes an `INVALID` instruction to terminate an invalid unreachable block part.
|
||||
///
|
||||
pub fn invalid(previous: &Self) -> Self {
|
||||
Self {
|
||||
name: Name::INVALID,
|
||||
@@ -337,9 +325,7 @@ impl Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Initializes a recursive function `Call` instruction.
|
||||
///
|
||||
pub fn recursive_call(
|
||||
name: String,
|
||||
entry_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
@@ -366,9 +352,7 @@ impl Instruction {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Initializes a recursive function `Return` instruction.
|
||||
///
|
||||
pub fn recursive_return(input_size: usize, previous: &Self) -> Self {
|
||||
Self {
|
||||
name: Name::RecursiveReturn { input_size },
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The EVM instruction name.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The EVM instruction name.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
//!
|
||||
//! Translates the stack memory operations.
|
||||
//!
|
||||
|
||||
use inkwell::values::BasicValue;
|
||||
|
||||
///
|
||||
/// Translates the ordinar value push.
|
||||
///
|
||||
pub fn push<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
value: String,
|
||||
@@ -25,9 +21,7 @@ where
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
///
|
||||
/// Translates the block tag label push.
|
||||
///
|
||||
pub fn push_tag<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
value: String,
|
||||
@@ -42,9 +36,7 @@ where
|
||||
Ok(result.as_basic_value_enum())
|
||||
}
|
||||
|
||||
///
|
||||
/// Translates the stack memory duplicate.
|
||||
///
|
||||
pub fn dup<'ctx, D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
offset: usize,
|
||||
@@ -68,9 +60,7 @@ where
|
||||
Ok(value)
|
||||
}
|
||||
|
||||
///
|
||||
/// Translates the stack memory swap.
|
||||
///
|
||||
pub fn swap<D>(
|
||||
context: &mut revive_llvm_context::EraVMContext<D>,
|
||||
offset: usize,
|
||||
@@ -103,9 +93,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Translates the stack memory pop.
|
||||
///
|
||||
pub fn pop<D>(_context: &mut revive_llvm_context::EraVMContext<D>) -> anyhow::Result<()>
|
||||
where
|
||||
D: revive_llvm_context::EraVMDependency + Clone,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --asm-json` output.
|
||||
//!
|
||||
|
||||
pub mod data;
|
||||
pub mod instruction;
|
||||
@@ -19,9 +17,7 @@ use self::data::Data;
|
||||
use self::instruction::name::Name as InstructionName;
|
||||
use self::instruction::Instruction;
|
||||
|
||||
///
|
||||
/// The JSON assembly.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Assembly {
|
||||
/// The metadata string.
|
||||
@@ -46,36 +42,27 @@ pub struct Assembly {
|
||||
}
|
||||
|
||||
impl Assembly {
|
||||
///
|
||||
/// Gets the contract `keccak256` hash.
|
||||
///
|
||||
pub fn keccak256(&self) -> String {
|
||||
let json = serde_json::to_vec(self).expect("Always valid");
|
||||
revive_llvm_context::eravm_utils::keccak256(json.as_slice())
|
||||
}
|
||||
|
||||
///
|
||||
/// Sets the full contract path.
|
||||
///
|
||||
pub fn set_full_path(&mut self, full_path: String) {
|
||||
self.full_path = Some(full_path);
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the full contract path if it is set, or `<undefined>` otherwise.
|
||||
///
|
||||
/// # Panics
|
||||
/// If the `full_path` has not been set.
|
||||
///
|
||||
pub fn full_path(&self) -> &str {
|
||||
self.full_path
|
||||
.as_deref()
|
||||
.unwrap_or_else(|| panic!("The full path of some contracts is unset"))
|
||||
}
|
||||
|
||||
///
|
||||
/// Get the list of missing deployable libraries.
|
||||
///
|
||||
pub fn get_missing_libraries(&self) -> HashSet<String> {
|
||||
let mut missing_libraries = HashSet::new();
|
||||
if let Some(code) = self.code.as_ref() {
|
||||
@@ -94,9 +81,7 @@ impl Assembly {
|
||||
missing_libraries
|
||||
}
|
||||
|
||||
///
|
||||
/// Replaces the deploy code dependencies with full contract path and returns the list.
|
||||
///
|
||||
pub fn deploy_dependencies_pass(
|
||||
&mut self,
|
||||
full_path: &str,
|
||||
@@ -144,9 +129,7 @@ impl Assembly {
|
||||
Ok(index_path_mapping)
|
||||
}
|
||||
|
||||
///
|
||||
/// Replaces the runtime code dependencies with full contract path and returns the list.
|
||||
///
|
||||
pub fn runtime_dependencies_pass(
|
||||
&mut self,
|
||||
full_path: &str,
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
//!
|
||||
//! The Ethereal IR entry function link.
|
||||
//!
|
||||
|
||||
use inkwell::values::BasicValue;
|
||||
|
||||
use crate::evmla::ethereal_ir::EtherealIR;
|
||||
|
||||
///
|
||||
/// The Ethereal IR entry function link.
|
||||
///
|
||||
/// The link represents branching between the deploy and runtime code.
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EntryLink {
|
||||
/// The code part type.
|
||||
@@ -18,9 +13,7 @@ pub struct EntryLink {
|
||||
}
|
||||
|
||||
impl EntryLink {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(code_type: revive_llvm_context::EraVMCodeType) -> Self {
|
||||
Self { code_type }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The Ethereal IR block element.
|
||||
//!
|
||||
|
||||
pub mod stack;
|
||||
|
||||
@@ -13,9 +11,7 @@ use crate::evmla::assembly::instruction::Instruction;
|
||||
use self::stack::element::Element as StackElement;
|
||||
use self::stack::Stack;
|
||||
|
||||
///
|
||||
/// The Ethereal IR block element.
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Element {
|
||||
/// The Solidity compiler version.
|
||||
@@ -31,9 +27,7 @@ pub struct Element {
|
||||
}
|
||||
|
||||
impl Element {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(solc_version: semver::Version, instruction: Instruction) -> Self {
|
||||
let input_size = instruction.input_size(&solc_version);
|
||||
let output_size = instruction.output_size();
|
||||
@@ -47,9 +41,7 @@ impl Element {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Pops the specified number of arguments, converted into their LLVM values.
|
||||
///
|
||||
fn pop_arguments_llvm<'ctx, D>(
|
||||
&mut self,
|
||||
context: &mut revive_llvm_context::EraVMContext<'ctx, D>,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
//!
|
||||
//! The Ethereal IR block element stack element.
|
||||
//!
|
||||
|
||||
///
|
||||
/// The Ethereal IR block element stack element.
|
||||
///
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Element {
|
||||
/// The runtime value.
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
//!
|
||||
//! The Ethereal IR block element stack.
|
||||
//!
|
||||
|
||||
pub mod element;
|
||||
|
||||
use self::element::Element;
|
||||
|
||||
///
|
||||
/// The Ethereal IR block element stack.
|
||||
///
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Stack {
|
||||
/// The stack elements.
|
||||
@@ -19,36 +15,27 @@ impl Stack {
|
||||
/// The default stack size.
|
||||
pub const DEFAULT_STACK_SIZE: usize = 16;
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
elements: Vec::with_capacity(Self::DEFAULT_STACK_SIZE),
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self {
|
||||
elements: Vec::with_capacity(capacity),
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new_with_elements(elements: Vec<Element>) -> Self {
|
||||
Self { elements }
|
||||
}
|
||||
|
||||
///
|
||||
/// The stack state hash, which acts as a block identifier.
|
||||
///
|
||||
/// Each block clone has its own initial stack state, which uniquely identifies the block.
|
||||
///
|
||||
pub fn hash(&self) -> md5::Digest {
|
||||
let mut hash_context = md5::Context::new();
|
||||
for element in self.elements.iter() {
|
||||
@@ -60,32 +47,24 @@ impl Stack {
|
||||
hash_context.compute()
|
||||
}
|
||||
|
||||
///
|
||||
/// Pushes an element onto the stack.
|
||||
///
|
||||
pub fn push(&mut self, element: Element) {
|
||||
self.elements.push(element);
|
||||
}
|
||||
|
||||
///
|
||||
/// Appends another stack on top of this one.
|
||||
///
|
||||
pub fn append(&mut self, other: &mut Self) {
|
||||
self.elements.append(&mut other.elements);
|
||||
}
|
||||
|
||||
///
|
||||
/// Pops a stack element.
|
||||
///
|
||||
pub fn pop(&mut self) -> anyhow::Result<Element> {
|
||||
self.elements
|
||||
.pop()
|
||||
.ok_or_else(|| anyhow::anyhow!("Stack underflow"))
|
||||
}
|
||||
|
||||
///
|
||||
/// Pops the tag from the top.
|
||||
///
|
||||
pub fn pop_tag(&mut self) -> anyhow::Result<num::BigUint> {
|
||||
match self.elements.pop() {
|
||||
Some(Element::Tag(tag)) => Ok(tag),
|
||||
@@ -94,9 +73,7 @@ impl Stack {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Swaps two stack elements.
|
||||
///
|
||||
pub fn swap(&mut self, index: usize) -> anyhow::Result<()> {
|
||||
if self.elements.len() < index + 1 {
|
||||
anyhow::bail!("Stack underflow");
|
||||
@@ -108,9 +85,7 @@ impl Stack {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Duplicates a stack element.
|
||||
///
|
||||
pub fn dup(&mut self, index: usize) -> anyhow::Result<Element> {
|
||||
if self.elements.len() < index {
|
||||
anyhow::bail!("Stack underflow");
|
||||
@@ -119,16 +94,12 @@ impl Stack {
|
||||
Ok(self.elements[self.elements.len() - index].to_owned())
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the stack length.
|
||||
///
|
||||
pub fn len(&self) -> usize {
|
||||
self.elements.len()
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an emptiness flag.
|
||||
///
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.elements.len() == 0
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The Ethereal IR block.
|
||||
//!
|
||||
|
||||
pub mod element;
|
||||
|
||||
@@ -14,9 +12,7 @@ use crate::evmla::assembly::instruction::Instruction;
|
||||
use self::element::stack::Stack as ElementStack;
|
||||
use self::element::Element;
|
||||
|
||||
///
|
||||
/// The Ethereal IR block.
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Block {
|
||||
/// The Solidity compiler version.
|
||||
@@ -43,9 +39,7 @@ impl Block {
|
||||
/// The predecessors hashset initial capacity.
|
||||
pub const PREDECESSORS_HASHSET_DEFAULT_CAPACITY: usize = 4;
|
||||
|
||||
///
|
||||
/// Assembles a block from the sequence of instructions.
|
||||
///
|
||||
pub fn try_from_instructions(
|
||||
solc_version: semver::Version,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
@@ -109,9 +103,7 @@ impl Block {
|
||||
Ok((block, cursor))
|
||||
}
|
||||
|
||||
///
|
||||
/// Inserts a predecessor tag.
|
||||
///
|
||||
pub fn insert_predecessor(
|
||||
&mut self,
|
||||
key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The Ethereal IR function.
|
||||
//!
|
||||
|
||||
pub mod block;
|
||||
pub mod queue_element;
|
||||
@@ -37,9 +35,7 @@ use self::queue_element::QueueElement;
|
||||
use self::r#type::Type;
|
||||
use self::visited_element::VisitedElement;
|
||||
|
||||
///
|
||||
/// The Ethereal IR function.
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Function {
|
||||
/// The Solidity compiler version.
|
||||
@@ -55,9 +51,7 @@ pub struct Function {
|
||||
}
|
||||
|
||||
impl Function {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(solc_version: semver::Version, r#type: Type) -> Self {
|
||||
let name = match r#type {
|
||||
Type::Initial => EtherealIR::DEFAULT_ENTRY_FUNCTION_NAME.to_string(),
|
||||
@@ -77,9 +71,7 @@ impl Function {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Runs the function block traversal.
|
||||
///
|
||||
pub fn traverse(
|
||||
&mut self,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
@@ -143,9 +135,7 @@ impl Function {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Consumes the entry or a conditional block attached to another one.
|
||||
///
|
||||
fn consume_block(
|
||||
&mut self,
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
@@ -219,12 +209,9 @@ impl Function {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Processes an instruction, returning an error, if there is an invalid stack state.
|
||||
///
|
||||
/// The blocks with an invalid stack state are considered being partially unreachable, and
|
||||
/// the invalid part is truncated after terminating with an `INVALID` instruction.
|
||||
///
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn handle_instruction(
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
@@ -993,9 +980,7 @@ impl Function {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Updates the stack data with input and output data.
|
||||
///
|
||||
fn update_io_data(
|
||||
block_stack: &mut Stack,
|
||||
block_element: &mut BlockElement,
|
||||
@@ -1017,9 +1002,7 @@ impl Function {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Handles the recursive function call.
|
||||
///
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn handle_recursive_function_call(
|
||||
recursive_function: &RecursiveFunction,
|
||||
@@ -1095,9 +1078,7 @@ impl Function {
|
||||
Ok((return_address, stack_output))
|
||||
}
|
||||
|
||||
///
|
||||
/// Pushes a block into the function.
|
||||
///
|
||||
fn insert_block(&mut self, mut block: Block) -> &mut Block {
|
||||
let key = block.key.clone();
|
||||
|
||||
@@ -1120,11 +1101,8 @@ impl Function {
|
||||
.expect("Always exists")
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks whether the tag value actually references an existing block.
|
||||
///
|
||||
/// Checks both deploy and runtime code.
|
||||
///
|
||||
fn is_tag_value_valid(
|
||||
blocks: &HashMap<revive_llvm_context::EraVMFunctionBlockKey, Block>,
|
||||
tag: &num::BigUint,
|
||||
@@ -1138,9 +1116,7 @@ impl Function {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Finalizes the function data.
|
||||
///
|
||||
fn finalize(&mut self) {
|
||||
for (_tag, blocks) in self.blocks.iter() {
|
||||
for block in blocks.iter() {
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
//!
|
||||
//! The Ethereal IR block queue element.
|
||||
//!
|
||||
|
||||
use crate::evmla::ethereal_ir::function::block::element::stack::Stack;
|
||||
|
||||
///
|
||||
/// The Ethereal IR block queue element.
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct QueueElement {
|
||||
/// The block key.
|
||||
@@ -18,9 +14,7 @@ pub struct QueueElement {
|
||||
}
|
||||
|
||||
impl QueueElement {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
predecessor: Option<(revive_llvm_context::EraVMFunctionBlockKey, usize)>,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
//!
|
||||
//! The Ethereal IR function type.
|
||||
//!
|
||||
|
||||
///
|
||||
/// The Ethereal IR function type.
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Type {
|
||||
/// The initial function, combining deploy and runtime code.
|
||||
@@ -23,16 +19,12 @@ pub enum Type {
|
||||
}
|
||||
|
||||
impl Type {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new_initial() -> Self {
|
||||
Self::Initial
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new_recursive(
|
||||
name: String,
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
//!
|
||||
//! The Ethereal IR block visited element.
|
||||
//!
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
///
|
||||
/// The Ethereal IR block visited element.
|
||||
///
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct VisitedElement {
|
||||
/// The block key.
|
||||
@@ -16,9 +12,7 @@ pub struct VisitedElement {
|
||||
}
|
||||
|
||||
impl VisitedElement {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
block_key: revive_llvm_context::EraVMFunctionBlockKey,
|
||||
stack_hash: md5::Digest,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The Ethereal IR of the EVM bytecode.
|
||||
//!
|
||||
|
||||
pub mod entry_link;
|
||||
pub mod function;
|
||||
@@ -16,18 +14,14 @@ use self::function::block::Block;
|
||||
use self::function::r#type::Type as FunctionType;
|
||||
use self::function::Function;
|
||||
|
||||
///
|
||||
/// The Ethereal IR of the EVM bytecode.
|
||||
///
|
||||
/// The Ethereal IR (EthIR) is a special IR between the EVM legacy assembly and LLVM IR. It is
|
||||
/// created to facilitate the translation and provide an additional environment for applying some
|
||||
/// transformations, duplicating parts of the call and control flow graphs, tracking the
|
||||
/// data flow, and a few more algorithms of static analysis.
|
||||
///
|
||||
/// The most important feature of EthIR is flattening the block tags and duplicating blocks for
|
||||
/// each of initial states of the stack. The LLVM IR supports only static control flow, so the
|
||||
/// stack state must be known all the way throughout the program.
|
||||
///
|
||||
#[derive(Debug)]
|
||||
pub struct EtherealIR {
|
||||
/// The Solidity compiler version.
|
||||
@@ -47,9 +41,7 @@ impl EtherealIR {
|
||||
/// The blocks hashmap initial capacity.
|
||||
pub const BLOCKS_HASHMAP_DEFAULT_CAPACITY: usize = 64;
|
||||
|
||||
///
|
||||
/// Assembles a sequence of functions from the sequence of instructions.
|
||||
///
|
||||
pub fn new(
|
||||
solc_version: semver::Version,
|
||||
extra_metadata: ExtraMetadata,
|
||||
@@ -73,9 +65,7 @@ impl EtherealIR {
|
||||
})
|
||||
}
|
||||
|
||||
///
|
||||
/// Gets blocks for the specified type of the contract code.
|
||||
///
|
||||
pub fn get_blocks(
|
||||
solc_version: semver::Version,
|
||||
code_type: revive_llvm_context::EraVMCodeType,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The EVM legacy assembly compiling tools.
|
||||
//!
|
||||
|
||||
pub mod assembly;
|
||||
pub mod ethereal_ir;
|
||||
|
||||
Reference in New Issue
Block a user