Skip to content

Commit

Permalink
Add --all(-generics|-monos) flags to monos command
Browse files Browse the repository at this point in the history
With an additional -a shortcut for the simple --all flag that combines
listing all generics and monomorphizations

Also extends tests accordingly

Relates to rustwasm#109
  • Loading branch information
userzimmermann committed Aug 20, 2018
1 parent e3f04f8 commit fbc5090
Show file tree
Hide file tree
Showing 6 changed files with 688 additions and 3 deletions.
43 changes: 40 additions & 3 deletions opt/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,24 @@ pub struct Monos {
max_generics: u32,

/// The maximum number of individual monomorphizations to list for each
/// generic function.
/// listed generic function.
#[structopt(short = "n", long = "max-monos", default_value = "10")]
max_monos: u32,

/// List all generics and all of their individual monomorphizations.
/// If combined with -g then monomorphizations are hidden.
/// Overrides -m <max_generics> and -n <max_monos>
#[structopt(short = "a", long = "all")]
all_generics_and_monos: bool,

/// List all generics. Overrides -m <max_generics>
#[structopt(long = "all-generics")]
all_generics: bool,

/// List all individual monomorphizations for each listed generic
/// function. Overrides -n <max_monos>
#[structopt(long = "all-monos")]
all_monos: bool,
}

impl Default for Monos {
Expand All @@ -385,6 +400,10 @@ impl Default for Monos {
only_generics: false,
max_generics: 10,
max_monos: 10,

all_generics_and_monos: false,
all_generics: false,
all_monos: false,
}
}
}
Expand All @@ -403,13 +422,21 @@ impl Monos {

/// The maximum number of generics to list.
pub fn max_generics(&self) -> u32 {
self.max_generics
if self.all_generics_and_monos || self.all_generics {
u32::MAX
} else {
self.max_generics
}
}

/// The maximum number of individual monomorphizations to list for each
/// generic function.
pub fn max_monos(&self) -> u32 {
self.max_monos
if self.all_generics_and_monos || self.all_monos {
u32::MAX
} else {
self.max_monos
}
}

/// Set whether to hide individual monomorphizations and only show the
Expand All @@ -421,12 +448,22 @@ impl Monos {
/// Set the maximum number of generics to list.
pub fn set_max_generics(&mut self, max: u32) {
self.max_generics = max;
self.all_generics = false;
if self.all_generics_and_monos {
self.all_generics_and_monos = false;
self.all_monos = true;
}
}

/// Set the maximum number of individual monomorphizations to list for each
/// generic function.
pub fn set_max_monos(&mut self, max: u32) {
self.max_monos = max;
self.all_monos = false;
if self.all_generics_and_monos {
self.all_generics_and_monos = false;
self.all_generics = true;
}
}
}

Expand Down
Loading

0 comments on commit fbc5090

Please sign in to comment.