mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-27 05:59:52 +00:00
Separate compilation and linker phases (#376)
Separate between compilation and linker phases to allow deploy time linking and back-porting era compiler changes to fix #91. Unlinked contract binaries (caused by missing libraries or missing factory dependencies in turn) are emitted as raw ELF object. Few drive by fixes: - #98 - A compiler panic on missing libraries definitions. - Fixes some incosistent type forwarding in JSON output (empty string vs. null object). - Remove the unused fallback for size optimization setting. - Remove the broken `--lvm-ir` mode. - CI workflow fixes. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> Signed-off-by: xermicus <bigcyrill@hotmail.com> Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
1 parent
13faedf08a
commit
94ec34c4d5
169 files changed
+6288
-5206
No files matched your search
@@ -0,0 +1,115 @@
|
||||
//! The `solc --combined-json` expected output selection flag.
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The solc `--combind-json` invalid selector message.
|
||||
pub const MESSAGE_SELECTOR_INVALID: &str = "Invalid option to --combined-json";
|
||||
|
||||
/// The `solc --combined-json` expected output selection flag.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Selector {
|
||||
/// The ABI JSON.
|
||||
#[serde(rename = "abi")]
|
||||
ABI,
|
||||
/// The function signature hashes JSON.
|
||||
#[serde(rename = "hashes")]
|
||||
Hashes,
|
||||
/// The metadata.
|
||||
#[serde(rename = "metadata")]
|
||||
Metadata,
|
||||
/// The developer documentation.
|
||||
#[serde(rename = "devdoc")]
|
||||
Devdoc,
|
||||
/// The user documentation.
|
||||
#[serde(rename = "userdoc")]
|
||||
Userdoc,
|
||||
/// The storage layout.
|
||||
#[serde(rename = "storage-layout")]
|
||||
StorageLayout,
|
||||
/// The transient storage layout.
|
||||
#[serde(rename = "transient-storage-layout")]
|
||||
TransientStorageLayout,
|
||||
/// The AST JSON.
|
||||
#[serde(rename = "ast")]
|
||||
AST,
|
||||
/// The EVM assembly.
|
||||
#[serde(rename = "asm")]
|
||||
ASM,
|
||||
|
||||
/// The assembly.
|
||||
#[serde(rename = "assembly", skip_serializing)]
|
||||
Assembly,
|
||||
|
||||
/// The deploy bytecode.
|
||||
#[serde(rename = "bin", skip_serializing)]
|
||||
Bytecode,
|
||||
/// The runtime bytecode.
|
||||
#[serde(rename = "bin-runtime", skip_serializing)]
|
||||
BytecodeRuntime,
|
||||
}
|
||||
|
||||
impl Selector {
|
||||
/// Converts the comma-separated CLI argument into an array of flags.
|
||||
pub fn from_cli(format: &str) -> Vec<anyhow::Result<Self>> {
|
||||
format
|
||||
.split(',')
|
||||
.map(|flag| Self::from_str(flag.trim()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Whether the selector is available in `solc`.
|
||||
pub fn is_source_solc(&self) -> bool {
|
||||
!matches!(
|
||||
self,
|
||||
Self::Assembly | Self::Bytecode | Self::BytecodeRuntime
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Selector {
|
||||
type Err = anyhow::Error;
|
||||
|
||||
fn from_str(string: &str) -> Result<Self, Self::Err> {
|
||||
match string {
|
||||
"abi" => Ok(Self::ABI),
|
||||
"hashes" => Ok(Self::Hashes),
|
||||
"metadata" => Ok(Self::Metadata),
|
||||
"devdoc" => Ok(Self::Devdoc),
|
||||
"userdoc" => Ok(Self::Userdoc),
|
||||
"storage-layout" => Ok(Self::StorageLayout),
|
||||
"transient-storage-layout" => Ok(Self::TransientStorageLayout),
|
||||
"ast" => Ok(Self::AST),
|
||||
"asm" => Ok(Self::ASM),
|
||||
|
||||
"bin" => Ok(Self::Bytecode),
|
||||
"bin-runtime" => Ok(Self::BytecodeRuntime),
|
||||
|
||||
"assembly" => Ok(Self::Assembly),
|
||||
|
||||
selector => anyhow::bail!("{MESSAGE_SELECTOR_INVALID}: {selector}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Selector {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::ABI => write!(f, "abi"),
|
||||
Self::Hashes => write!(f, "hashes"),
|
||||
Self::Metadata => write!(f, "metadata"),
|
||||
Self::Devdoc => write!(f, "devdoc"),
|
||||
Self::Userdoc => write!(f, "userdoc"),
|
||||
Self::StorageLayout => write!(f, "storage-layout"),
|
||||
Self::TransientStorageLayout => write!(f, "transient-storage-layout"),
|
||||
Self::AST => write!(f, "ast"),
|
||||
Self::ASM => write!(f, "asm"),
|
||||
|
||||
Self::Bytecode => write!(f, "bin"),
|
||||
Self::BytecodeRuntime => write!(f, "bin-runtime"),
|
||||
|
||||
Self::Assembly => write!(f, "assembly"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user