Some codegen work to make pass options work

This commit is contained in:
greg 2018-07-15 23:44:20 -07:00
parent 4ca57e4aea
commit 1d2f1624a1
2 changed files with 21 additions and 3 deletions

View File

@ -169,7 +169,7 @@ macro_rules! pass_chain_helper {
let output = { let output = {
let ref debug_map = $options.debug_passes; let ref debug_map = $options.debug_passes;
let debug_handle = match debug_map.get(pass_name) { 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; let ptr = &mut $comp;
ptr.cur_debug_options = opts.clone(); ptr.cur_debug_options = opts.clone();
Some(ptr) Some(ptr)

View File

@ -132,6 +132,7 @@ fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInte
} }
} }
#[derive(Clone)]
enum CommandTree { enum CommandTree {
Terminal(String, Option<String>), Terminal(String, Option<String>),
NonTerminal(String, Vec<CommandTree>, Option<String>), NonTerminal(String, Vec<CommandTree>, Option<String>),
@ -329,14 +330,31 @@ impl Repl {
fn get_directives(&self) -> CommandTree { fn get_directives(&self) -> CommandTree {
let ref passes = self.get_cur_language().get_passes(); let ref passes = self.get_cur_language().get_passes();
let passes_directives: Vec<CommandTree> = 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<CommandTree> = pass_descriptor.debug_options.iter()
.map(|o| CommandTree::term(o, None)).collect();
CommandTree::NonTerminal(
name.clone(),
sub_opts,
None
)
}
}).collect();
CommandTree::Top(vec![ CommandTree::Top(vec![
CommandTree::term("exit", Some("exit the REPL")), CommandTree::term("exit", Some("exit the REPL")),
CommandTree::term("quit", Some("exit the REPL")), CommandTree::term("quit", Some("exit the REPL")),
CommandTree::term("help", Some("Print this help message")), CommandTree::term("help", Some("Print this help message")),
CommandTree::NonTerminal(format!("debug"), vec![ CommandTree::NonTerminal(format!("debug"), vec![
CommandTree::term("passes", None), CommandTree::term("passes", None),
CommandTree::NonTerminal(format!("show"), passes.iter().map(|p| CommandTree::term(&p.name, None)).collect(), None), CommandTree::NonTerminal(format!("show"), passes_directives.clone(), None),
CommandTree::NonTerminal(format!("hide"), passes.iter().map(|p| CommandTree::term(&p.name, None)).collect(), 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"))), ], Some(format!("show or hide pass info for a given pass, or display the names of all passes"))),
CommandTree::NonTerminal(format!("lang"), vec![ CommandTree::NonTerminal(format!("lang"), vec![
CommandTree::term("next", None), CommandTree::term("next", None),