From 7a67890227ad5759a933a31b81352bbf6e5bfd86 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 20 Mar 2019 00:04:02 -0700 Subject: [PATCH] List-passes --- schala-repl/src/repl/mod.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index 899c2b7..0c2b527 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -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 = passes.iter() + let passes_directives: Vec = 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![