Files
revive/crates/solc-json-interface/src/standard_json/input/settings/optimizer/details.rs
T
xermicus 497dae2494 factor out solc JSON interface crate (#264)
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>
2025-03-20 17:11:40 +01:00

60 lines
1.6 KiB
Rust

//! The `solc --standard-json` input settings optimizer details.
use serde::Deserialize;
use serde::Serialize;
/// The `solc --standard-json` input settings optimizer details.
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Details {
/// Whether the pass is enabled.
pub peephole: bool,
/// Whether the pass is enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub inliner: Option<bool>,
/// Whether the pass is enabled.
pub jumpdest_remover: bool,
/// Whether the pass is enabled.
pub order_literals: bool,
/// Whether the pass is enabled.
pub deduplicate: bool,
/// Whether the pass is enabled.
pub cse: bool,
/// Whether the pass is enabled.
pub constant_optimizer: bool,
}
impl Details {
/// A shortcut constructor.
pub fn new(
peephole: bool,
inliner: Option<bool>,
jumpdest_remover: bool,
order_literals: bool,
deduplicate: bool,
cse: bool,
constant_optimizer: bool,
) -> Self {
Self {
peephole,
inliner,
jumpdest_remover,
order_literals,
deduplicate,
cse,
constant_optimizer,
}
}
/// Creates a set of disabled optimizations.
pub fn disabled(version: &semver::Version) -> Self {
let inliner = if version >= &semver::Version::new(0, 8, 5) {
Some(false)
} else {
None
};
Self::new(false, inliner, false, false, false, false, false)
}
}