feat(solc): add is_empty fn for structs of Options (#2195)

This commit is contained in:
Matthias Seitz 2023-02-27 21:24:48 +01:00 committed by GitHub
parent 936fbcd287
commit f1a8a216a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 0 deletions

View File

@ -683,6 +683,23 @@ pub struct OptimizerDetails {
pub yul_details: Option<YulDetails>,
}
// === impl OptimizerDetails ===
impl OptimizerDetails {
/// Returns true if no settings are set.
pub fn is_empty(&self) -> bool {
self.peephole.is_none() &&
self.inliner.is_none() &&
self.jumpdest_remover.is_none() &&
self.order_literals.is_none() &&
self.deduplicate.is_none() &&
self.cse.is_none() &&
self.constant_optimizer.is_none() &&
self.yul.is_none() &&
self.yul_details.as_ref().map(|yul| yul.is_empty()).unwrap_or(true)
}
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct YulDetails {
@ -696,6 +713,15 @@ pub struct YulDetails {
pub optimizer_steps: Option<String>,
}
// === impl YulDetails ===
impl YulDetails {
/// Returns true if no settings are set.
pub fn is_empty(&self) -> bool {
self.stack_allocation.is_none() && self.optimizer_steps.is_none()
}
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum EvmVersion {
Homestead,