From 1d2f1624a18073e497230fb873832d0390e58e8d Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 15 Jul 2018 23:44:20 -0700 Subject: [PATCH] Some codegen work to make pass options work --- schala-repl/src/language.rs | 2 +- schala-repl/src/lib.rs | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 1808d3a..8473231 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -169,7 +169,7 @@ macro_rules! pass_chain_helper { let output = { let ref debug_map = $options.debug_passes; let debug_handle = match debug_map.get(pass_name) { - Some(PassDebugOptionsDescriptor { opts }) => { //(Some(&mut $comp), Some(opts.clone())), + Some(PassDebugOptionsDescriptor { opts }) => { let ptr = &mut $comp; ptr.cur_debug_options = opts.clone(); Some(ptr) diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index 2382b5b..872bfd1 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -132,6 +132,7 @@ fn run_noninteractive(filename: &str, languages: Vec), NonTerminal(String, Vec, Option), @@ -329,14 +330,31 @@ impl Repl { fn get_directives(&self) -> CommandTree { let ref passes = self.get_cur_language().get_passes(); + + let passes_directives: Vec = passes.iter() + .map(|pass_descriptor| { + let name = &pass_descriptor.name; + if pass_descriptor.debug_options.len() == 0 { + CommandTree::term(name, None) + } else { + let sub_opts: Vec = pass_descriptor.debug_options.iter() + .map(|o| CommandTree::term(o, None)).collect(); + CommandTree::NonTerminal( + name.clone(), + sub_opts, + None + ) + } + }).collect(); + CommandTree::Top(vec![ CommandTree::term("exit", Some("exit the REPL")), CommandTree::term("quit", Some("exit the REPL")), CommandTree::term("help", Some("Print this help message")), CommandTree::NonTerminal(format!("debug"), vec![ CommandTree::term("passes", None), - CommandTree::NonTerminal(format!("show"), passes.iter().map(|p| CommandTree::term(&p.name, None)).collect(), None), - CommandTree::NonTerminal(format!("hide"), passes.iter().map(|p| CommandTree::term(&p.name, None)).collect(), None), + CommandTree::NonTerminal(format!("show"), passes_directives.clone(), None), + CommandTree::NonTerminal(format!("hide"), passes_directives.clone(), None), ], Some(format!("show or hide pass info for a given pass, or display the names of all passes"))), CommandTree::NonTerminal(format!("lang"), vec![ CommandTree::term("next", None),