mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 05:38:00 +00:00
497dae2494
The differential testing framework will make a second consumer. There seems to be no re-usable Rust crate for this. But we already have everything here, just needs a small refactor to make it fully re-usable. - Mostly decouple the solc JSON-input-output interface types from the `solidity` frontend crate - Expose the JSON-input-output interface types in a dedicated crate --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
//! The `solc --standard-json` input settings optimizer.
|
|
|
|
pub mod details;
|
|
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use self::details::Details;
|
|
|
|
/// The `solc --standard-json` input settings optimizer.
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct Optimizer {
|
|
/// Whether the optimizer is enabled.
|
|
pub enabled: bool,
|
|
/// The optimization mode string.
|
|
#[serde(skip_serializing)]
|
|
pub mode: Option<char>,
|
|
/// The `solc` optimizer details.
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub details: Option<Details>,
|
|
/// Whether to try to recompile with -Oz if the bytecode is too large.
|
|
#[serde(skip_serializing)]
|
|
pub fallback_to_optimizing_for_size: Option<bool>,
|
|
}
|
|
|
|
impl Optimizer {
|
|
/// A shortcut constructor.
|
|
pub fn new(
|
|
enabled: bool,
|
|
mode: Option<char>,
|
|
version: &semver::Version,
|
|
fallback_to_optimizing_for_size: bool,
|
|
) -> Self {
|
|
Self {
|
|
enabled,
|
|
mode,
|
|
details: Some(Details::disabled(version)),
|
|
fallback_to_optimizing_for_size: Some(fallback_to_optimizing_for_size),
|
|
}
|
|
}
|
|
|
|
/// Sets the necessary defaults.
|
|
pub fn normalize(&mut self, version: &semver::Version) {
|
|
self.details = if version >= &semver::Version::new(0, 5, 5) {
|
|
Some(Details::disabled(version))
|
|
} else {
|
|
None
|
|
};
|
|
}
|
|
}
|