mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 08:51:02 +00:00
use normal style for comments
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM bytecode.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM bytecode.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Bytecode {
|
||||
@@ -16,17 +12,13 @@ pub struct Bytecode {
|
||||
}
|
||||
|
||||
impl Bytecode {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(object: String) -> Self {
|
||||
Self { object }
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM deployed bytecode.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeployedBytecode {
|
||||
@@ -35,9 +27,7 @@ pub struct DeployedBytecode {
|
||||
}
|
||||
|
||||
impl DeployedBytecode {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(object: String) -> Self {
|
||||
Self { object }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM extra metadata.
|
||||
//!
|
||||
|
||||
pub mod recursive_function;
|
||||
|
||||
@@ -9,9 +7,7 @@ use serde::Serialize;
|
||||
|
||||
use self::recursive_function::RecursiveFunction;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM extra metadata.
|
||||
///
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExtraMetadata {
|
||||
@@ -21,9 +17,7 @@ pub struct ExtraMetadata {
|
||||
}
|
||||
|
||||
impl ExtraMetadata {
|
||||
///
|
||||
/// Returns the recursive function reference for the specified tag.
|
||||
///
|
||||
pub fn get(
|
||||
&self,
|
||||
block_key: &revive_llvm_context::EraVMFunctionBlockKey,
|
||||
|
||||
-4
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM recursive function.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM recursive function.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RecursiveFunction {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM data.
|
||||
//!
|
||||
|
||||
pub mod bytecode;
|
||||
pub mod extra_metadata;
|
||||
@@ -16,11 +14,8 @@ use self::bytecode::Bytecode;
|
||||
use self::bytecode::DeployedBytecode;
|
||||
use self::extra_metadata::ExtraMetadata;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM data.
|
||||
///
|
||||
/// It is replaced by EraVM data after compiling.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EVM {
|
||||
@@ -44,9 +39,7 @@ pub struct EVM {
|
||||
}
|
||||
|
||||
impl EVM {
|
||||
///
|
||||
/// Sets the EraVM assembly and bytecode.
|
||||
///
|
||||
pub fn modify(&mut self, assembly_text: String, bytecode: String) {
|
||||
self.assembly_text = Some(assembly_text);
|
||||
self.bytecode = Some(Bytecode::new(bytecode));
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract.
|
||||
//!
|
||||
|
||||
pub mod evm;
|
||||
|
||||
@@ -12,9 +10,7 @@ use serde::Serialize;
|
||||
|
||||
use self::evm::EVM;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Contract {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output error.
|
||||
//!
|
||||
|
||||
pub mod source_location;
|
||||
|
||||
@@ -11,9 +9,7 @@ use serde::Serialize;
|
||||
|
||||
use self::source_location::SourceLocation;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output error.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Error {
|
||||
@@ -34,9 +30,7 @@ pub struct Error {
|
||||
}
|
||||
|
||||
impl Error {
|
||||
///
|
||||
/// Returns the `ecrecover` function usage warning.
|
||||
///
|
||||
pub fn message_ecrecover(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -59,9 +53,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the `<address payable>`'s `send` and `transfer` methods usage error.
|
||||
///
|
||||
pub fn message_send_and_transfer(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -87,9 +79,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the `extcodesize` instruction usage warning.
|
||||
///
|
||||
pub fn message_extcodesize(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -114,9 +104,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the `origin` instruction usage warning.
|
||||
///
|
||||
pub fn message_tx_origin(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -139,9 +127,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the internal function pointer usage error.
|
||||
///
|
||||
pub fn message_internal_function_pointer(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -161,9 +147,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Appends the contract path to the message..
|
||||
///
|
||||
pub fn push_contract_path(&mut self, path: &str) {
|
||||
self.formatted_message
|
||||
.push_str(format!("\n--> {path}\n").as_str());
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output error source location.
|
||||
//!
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output error source location.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SourceLocation {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output.
|
||||
//!
|
||||
|
||||
pub mod contract;
|
||||
pub mod error;
|
||||
@@ -27,9 +25,7 @@ use self::contract::Contract;
|
||||
use self::error::Error as SolcStandardJsonOutputError;
|
||||
use self::source::Source;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Output {
|
||||
/// The file-contract hashmap.
|
||||
@@ -53,9 +49,7 @@ pub struct Output {
|
||||
}
|
||||
|
||||
impl Output {
|
||||
///
|
||||
/// Converts the `solc` JSON output into a convenient project.
|
||||
///
|
||||
pub fn try_to_project(
|
||||
&mut self,
|
||||
source_code_files: BTreeMap<String, String>,
|
||||
@@ -144,9 +138,7 @@ impl Output {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Removes EVM artifacts to prevent their accidental usage.
|
||||
///
|
||||
pub fn remove_evm(&mut self) {
|
||||
if let Some(files) = self.contracts.as_mut() {
|
||||
for (_, file) in files.iter_mut() {
|
||||
@@ -159,9 +151,7 @@ impl Output {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Traverses the AST and returns the list of additional errors and warnings.
|
||||
///
|
||||
pub fn preprocess_ast(
|
||||
&mut self,
|
||||
version: &SolcVersion,
|
||||
@@ -196,9 +186,7 @@ impl Output {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// The pass, which replaces with dependency indexes with actual data.
|
||||
///
|
||||
fn preprocess_dependencies(&mut self) -> anyhow::Result<()> {
|
||||
let files = match self.contracts.as_mut() {
|
||||
Some(files) => files,
|
||||
@@ -242,9 +230,7 @@ impl Output {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Preprocesses an assembly JSON structure dependency data map.
|
||||
///
|
||||
fn preprocess_dependency_level(
|
||||
full_path: &str,
|
||||
assembly: &mut Assembly,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output source.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@@ -10,9 +8,7 @@ use crate::solc::standard_json::output::error::Error as SolcStandardJsonOutputEr
|
||||
use crate::solc::version::Version as SolcVersion;
|
||||
use crate::warning::Warning;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output source.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Source {
|
||||
@@ -23,9 +19,7 @@ pub struct Source {
|
||||
}
|
||||
|
||||
impl Source {
|
||||
///
|
||||
/// Checks the AST node for the `ecrecover` function usage.
|
||||
///
|
||||
pub fn check_ecrecover(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -46,9 +40,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `<address payable>`'s `send` and `transfer` methods usage.
|
||||
///
|
||||
pub fn check_send_and_transfer(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -70,9 +62,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `extcodesize` assembly instruction usage.
|
||||
///
|
||||
pub fn check_assembly_extcodesize(
|
||||
ast: &serde_json::Value,
|
||||
) -> Option<SolcStandardJsonOutputError> {
|
||||
@@ -96,9 +86,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `origin` assembly instruction usage.
|
||||
///
|
||||
pub fn check_assembly_origin(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -120,9 +108,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `tx.origin` value usage.
|
||||
///
|
||||
pub fn check_tx_origin(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -146,9 +132,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the internal function pointers value usage.
|
||||
///
|
||||
pub fn check_internal_function_pointer(
|
||||
ast: &serde_json::Value,
|
||||
) -> Option<SolcStandardJsonOutputError> {
|
||||
@@ -174,9 +158,7 @@ impl Source {
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the list of messages for some specific parts of the AST.
|
||||
///
|
||||
pub fn get_messages(
|
||||
ast: &serde_json::Value,
|
||||
version: &SolcVersion,
|
||||
@@ -240,9 +222,7 @@ impl Source {
|
||||
messages
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the name of the last contract.
|
||||
///
|
||||
pub fn last_contract_name(&self) -> anyhow::Result<String> {
|
||||
self.ast
|
||||
.as_ref()
|
||||
|
||||
Reference in New Issue
Block a user