mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 23:51:06 +00:00
resolc crate (#328)
- Factor the YUL crate out of `revive-solidity`. - `revive-solidity` is in reality not a Solidity implementation but the revive solidity compiler driver (`resolc`). By renaming we not only get this straight but also a binary with the same name as the crate which should be less confusing. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
//! The Solidity compiler version.
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
/// The Solidity compiler version.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Version {
|
||||
/// The long version string.
|
||||
pub long: String,
|
||||
/// The short `semver`.
|
||||
pub default: semver::Version,
|
||||
/// The L2 revision additional versioning.
|
||||
pub l2_revision: Option<semver::Version>,
|
||||
}
|
||||
|
||||
impl Version {
|
||||
/// A shortcut constructor.
|
||||
pub fn new(
|
||||
long: String,
|
||||
default: semver::Version,
|
||||
l2_revision: Option<semver::Version>,
|
||||
) -> Self {
|
||||
Self {
|
||||
long,
|
||||
default,
|
||||
l2_revision,
|
||||
}
|
||||
}
|
||||
|
||||
/// A shortcut constructor for a simple version.
|
||||
pub fn new_simple(version: semver::Version) -> Self {
|
||||
Self {
|
||||
long: version.to_string(),
|
||||
default: version,
|
||||
l2_revision: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn validate(self, include_paths: &[String]) -> anyhow::Result<Self> {
|
||||
if self.default < super::FIRST_SUPPORTED_VERSION {
|
||||
anyhow::bail!(
|
||||
"`solc` versions <{} are not supported, found {}",
|
||||
super::FIRST_SUPPORTED_VERSION,
|
||||
self.default
|
||||
);
|
||||
}
|
||||
if self.default > super::LAST_SUPPORTED_VERSION {
|
||||
anyhow::bail!(
|
||||
"`solc` versions >{} are not supported, found {}",
|
||||
super::LAST_SUPPORTED_VERSION,
|
||||
self.default
|
||||
);
|
||||
}
|
||||
if !include_paths.is_empty() && self.default < super::FIRST_INCLUDE_PATH_VERSION {
|
||||
anyhow::bail!("--include-path is not supported in solc {}", self.default);
|
||||
}
|
||||
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user