mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-12 16:21:05 +00:00
use normal style for comments
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The contract EVM legacy assembly source code.
|
||||
//!
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -10,9 +8,7 @@ use serde::Serialize;
|
||||
use crate::evmla::assembly::Assembly;
|
||||
use crate::solc::standard_json::output::contract::evm::extra_metadata::ExtraMetadata;
|
||||
|
||||
///
|
||||
/// The contract EVM legacy assembly source code.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
@@ -22,17 +18,13 @@ pub struct EVMLA {
|
||||
}
|
||||
|
||||
impl EVMLA {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(mut assembly: Assembly, extra_metadata: ExtraMetadata) -> Self {
|
||||
assembly.extra_metadata = Some(extra_metadata);
|
||||
Self { assembly }
|
||||
}
|
||||
|
||||
///
|
||||
/// Get the list of missing deployable libraries.
|
||||
///
|
||||
pub fn get_missing_libraries(&self) -> HashSet<String> {
|
||||
self.assembly.get_missing_libraries()
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The contract LLVM IR source code.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The contract LLVM IR source code.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct LLVMIR {
|
||||
@@ -18,9 +14,7 @@ pub struct LLVMIR {
|
||||
}
|
||||
|
||||
impl LLVMIR {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(path: String, source: String) -> Self {
|
||||
Self { path, source }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The contract source code.
|
||||
//!
|
||||
|
||||
pub mod evmla;
|
||||
pub mod llvm_ir;
|
||||
@@ -21,9 +19,7 @@ use self::llvm_ir::LLVMIR;
|
||||
use self::yul::Yul;
|
||||
use self::zkasm::ZKASM;
|
||||
|
||||
///
|
||||
/// The contract source code.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
@@ -40,37 +36,27 @@ pub enum IR {
|
||||
}
|
||||
|
||||
impl IR {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new_yul(source_code: String, object: Object) -> Self {
|
||||
Self::Yul(Yul::new(source_code, object))
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new_evmla(assembly: Assembly, extra_metadata: ExtraMetadata) -> Self {
|
||||
Self::EVMLA(EVMLA::new(assembly, extra_metadata))
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new_llvm_ir(path: String, source: String) -> Self {
|
||||
Self::LLVMIR(LLVMIR::new(path, source))
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new_zkasm(path: String, source: String) -> Self {
|
||||
Self::ZKASM(ZKASM::new(path, source))
|
||||
}
|
||||
|
||||
///
|
||||
/// Get the list of missing deployable libraries.
|
||||
///
|
||||
pub fn get_missing_libraries(&self) -> HashSet<String> {
|
||||
match self {
|
||||
Self::Yul(inner) => inner.get_missing_libraries(),
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The contract Yul source code.
|
||||
//!
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -9,9 +7,7 @@ use serde::Serialize;
|
||||
|
||||
use crate::yul::parser::statement::object::Object;
|
||||
|
||||
///
|
||||
/// The contract Yul source code.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Yul {
|
||||
/// The Yul source code.
|
||||
@@ -21,9 +17,7 @@ pub struct Yul {
|
||||
}
|
||||
|
||||
impl Yul {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(source_code: String, object: Object) -> Self {
|
||||
Self {
|
||||
source_code,
|
||||
@@ -31,9 +25,7 @@ impl Yul {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Get the list of missing deployable libraries.
|
||||
///
|
||||
pub fn get_missing_libraries(&self) -> HashSet<String> {
|
||||
self.object.get_missing_libraries()
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The contract EraVM assembly source code.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The contract EraVM assembly source code.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub struct ZKASM {
|
||||
@@ -18,9 +14,7 @@ pub struct ZKASM {
|
||||
}
|
||||
|
||||
impl ZKASM {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(path: String, source: String) -> Self {
|
||||
Self { path, source }
|
||||
}
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
//!
|
||||
//! The Solidity contract metadata.
|
||||
//!
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The Solidity contract metadata.
|
||||
///
|
||||
/// Is used to append the metadata hash to the contract bytecode.
|
||||
///
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct Metadata {
|
||||
/// The `solc` metadata.
|
||||
@@ -24,9 +19,7 @@ pub struct Metadata {
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
solc_metadata: serde_json::Value,
|
||||
solc_version: semver::Version,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The contract data.
|
||||
//!
|
||||
|
||||
pub mod ir;
|
||||
pub mod metadata;
|
||||
@@ -20,9 +18,7 @@ use crate::solc::version::Version as SolcVersion;
|
||||
use self::ir::IR;
|
||||
use self::metadata::Metadata;
|
||||
|
||||
///
|
||||
/// The contract data.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Contract {
|
||||
/// The absolute file path.
|
||||
@@ -34,9 +30,7 @@ pub struct Contract {
|
||||
}
|
||||
|
||||
impl Contract {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
path: String,
|
||||
source_hash: [u8; revive_common::BYTE_LENGTH_FIELD],
|
||||
@@ -58,12 +52,10 @@ impl Contract {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the contract identifier, which is:
|
||||
/// - the Yul object identifier for Yul
|
||||
/// - the full contract path for EVM legacy assembly
|
||||
/// - the module name for LLVM IR
|
||||
///
|
||||
pub fn identifier(&self) -> &str {
|
||||
match self.ir {
|
||||
IR::Yul(ref yul) => yul.object.identifier.as_str(),
|
||||
@@ -73,9 +65,7 @@ impl Contract {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Extract factory dependencies.
|
||||
///
|
||||
pub fn drain_factory_dependencies(&mut self) -> HashSet<String> {
|
||||
match self.ir {
|
||||
IR::Yul(ref mut yul) => yul.object.factory_dependencies.drain().collect(),
|
||||
@@ -85,9 +75,7 @@ impl Contract {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Compiles the specified contract, setting its build artifacts.
|
||||
///
|
||||
pub fn compile(
|
||||
mut self,
|
||||
project: Project,
|
||||
@@ -196,9 +184,7 @@ impl Contract {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Get the list of missing deployable libraries.
|
||||
///
|
||||
pub fn get_missing_libraries(&self) -> HashSet<String> {
|
||||
self.ir.get_missing_libraries()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The processed input data.
|
||||
//!
|
||||
|
||||
pub mod contract;
|
||||
|
||||
@@ -27,9 +25,7 @@ use crate::yul::parser::statement::object::Object;
|
||||
|
||||
use self::contract::Contract;
|
||||
|
||||
///
|
||||
/// The processes input data.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Project {
|
||||
/// The source code version.
|
||||
@@ -43,9 +39,7 @@ pub struct Project {
|
||||
}
|
||||
|
||||
impl Project {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
version: SolcVersion,
|
||||
contracts: BTreeMap<String, Contract>,
|
||||
@@ -64,9 +58,7 @@ impl Project {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Compiles all contracts, returning their build artifacts.
|
||||
///
|
||||
pub fn compile(
|
||||
self,
|
||||
optimizer_settings: revive_llvm_context::OptimizerSettings,
|
||||
@@ -141,9 +133,7 @@ impl Project {
|
||||
Ok(build)
|
||||
}
|
||||
|
||||
///
|
||||
/// Get the list of missing deployable libraries.
|
||||
///
|
||||
pub fn get_missing_libraries(&self) -> MissingLibraries {
|
||||
let deployed_libraries = self
|
||||
.libraries
|
||||
@@ -168,9 +158,7 @@ impl Project {
|
||||
MissingLibraries::new(missing_deployable_libraries)
|
||||
}
|
||||
|
||||
///
|
||||
/// Parses the Yul source code file and returns the source data.
|
||||
///
|
||||
pub fn try_from_yul_path(
|
||||
path: &Path,
|
||||
solc_validator: Option<&SolcCompiler>,
|
||||
@@ -180,11 +168,8 @@ impl Project {
|
||||
Self::try_from_yul_string(path, source_code.as_str(), solc_validator)
|
||||
}
|
||||
|
||||
///
|
||||
/// Parses the test Yul source code string and returns the source data.
|
||||
///
|
||||
/// Only for integration testing purposes.
|
||||
///
|
||||
pub fn try_from_yul_string(
|
||||
path: &Path,
|
||||
source_code: &str,
|
||||
@@ -221,9 +206,7 @@ impl Project {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Parses the LLVM IR source code file and returns the source data.
|
||||
///
|
||||
pub fn try_from_llvm_ir_path(path: &Path) -> anyhow::Result<Self> {
|
||||
let source_code = std::fs::read_to_string(path)
|
||||
.map_err(|error| anyhow::anyhow!("LLVM IR file {:?} reading error: {}", path, error))?;
|
||||
@@ -252,9 +235,7 @@ impl Project {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Parses the EraVM assembly source code file and returns the source data.
|
||||
///
|
||||
pub fn try_from_zkasm_path(path: &Path) -> anyhow::Result<Self> {
|
||||
let source_code = std::fs::read_to_string(path).map_err(|error| {
|
||||
anyhow::anyhow!("EraVM assembly file {:?} reading error: {}", path, error)
|
||||
|
||||
Reference in New Issue
Block a user