use normal style for comments

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-05-01 16:12:32 +02:00
parent 72515254fe
commit 426f673b0a
184 changed files with 3 additions and 1789 deletions
@@ -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,
-17
View File
@@ -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,