List-passes

This commit is contained in:
greg 2019-03-20 00:04:02 -07:00
parent 04253543e9
commit 7a67890227

View File

@ -194,12 +194,12 @@ impl Repl {
fn get_directives(&mut self) -> CommandTree {
let language_state = self.get_cur_language_state();
let passes = match language_state.request_meta(LangMetaRequest::StageNames) {
let pass_names = match language_state.request_meta(LangMetaRequest::StageNames) {
LangMetaResponse::StageNames(names) => names,
_ => vec![],
};
let passes_directives: Vec<CommandTree> = passes.iter()
let passes_directives: Vec<CommandTree> = pass_names.iter()
.map(|pass_name| { CommandTree::term(pass_name, None) })
.collect();
@ -216,9 +216,24 @@ impl Repl {
Some(repl.print_help_message(cmds))
})),
CommandTree::nonterm("debug",
Some("show or hide pass debug info for a given pass, or display the names of all passes, or turn timing on/off"),
Some("Configure debug information"),
vec![
CommandTree::term("passes", None),
CommandTree::term_with_function("list-passes", Some("List all registered compiler passes"), Box::new(|repl: &mut Repl, cmds: &[&str]| {
let language_state = repl.get_cur_language_state();
let pass_names = match language_state.request_meta(LangMetaRequest::StageNames) {
LangMetaResponse::StageNames(names) => names,
_ => vec![],
};
let mut buf = String::new();
for pass in pass_names.iter().map(|name| Some(name)).intersperse(None) {
match pass {
Some(pass) => write!(buf, "{}", pass).unwrap(),
None => write!(buf, " -> ").unwrap(),
}
}
Some(buf)
})),
CommandTree::nonterm("show", None, passes_directives.clone()),
CommandTree::nonterm("hide", None, passes_directives.clone()),
CommandTree::nonterm("timing", None, vec![