Broken - some pass abstraction work
This commit is contained in:
parent
3597ad4eef
commit
5e48eb2dee
@ -65,8 +65,8 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream
|
|||||||
let mut chain = pass_chain![self, options; #(#passes),* ];
|
let mut chain = pass_chain![self, options; #(#passes),* ];
|
||||||
chain(input)
|
chain(input)
|
||||||
}
|
}
|
||||||
fn get_passes(&self) -> Vec<String> {
|
fn get_passes(&self) -> Vec<PassDescriptor> {
|
||||||
vec![ #(#pass_names.to_string()),* ]
|
vec![ #(PassDescriptor { name: #pass_names.to_string(), debug_options: vec![] }),* ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ fn parsing(_handle: &mut Schala, input: Vec<tokenizing::Token>, comp: Option<&mu
|
|||||||
Some(ref s) if s == "compact" => comp.add_artifact(TraceArtifact::new("ast", format!("{:?}", ast))),
|
Some(ref s) if s == "compact" => comp.add_artifact(TraceArtifact::new("ast", format!("{:?}", ast))),
|
||||||
Some(ref s) if s == "expanded" => comp.add_artifact(TraceArtifact::new("ast", format!("{:#?}", ast))),
|
Some(ref s) if s == "expanded" => comp.add_artifact(TraceArtifact::new("ast", format!("{:#?}", ast))),
|
||||||
Some(ref s) if s == "trace" => comp.add_artifact(TraceArtifact::new_parse_trace(trace)),
|
Some(ref s) if s == "trace" => comp.add_artifact(TraceArtifact::new_parse_trace(trace)),
|
||||||
Some(ref x) => println!("Bad parsing option: {}", x),
|
Some(ref x) => println!("Bad parsing debug option: {}", x),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
ast.map_err(|err| err.msg)
|
ast.map_err(|err| err.msg)
|
||||||
|
@ -10,6 +10,12 @@ pub struct EvalOptions {
|
|||||||
pub debug_passes: HashMap<String, PassDebugDescriptor>,
|
pub debug_passes: HashMap<String, PassDebugDescriptor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Hash, PartialEq)]
|
||||||
|
pub struct PassDescriptor {
|
||||||
|
pub name: String,
|
||||||
|
pub debug_options: Vec<String>
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct PassDebugDescriptor {
|
pub struct PassDebugDescriptor {
|
||||||
pub opts: Vec<String>,
|
pub opts: Vec<String>,
|
||||||
@ -127,7 +133,7 @@ pub trait ProgrammingLanguageInterface {
|
|||||||
|
|
||||||
fn get_language_name(&self) -> String;
|
fn get_language_name(&self) -> String;
|
||||||
fn get_source_file_suffix(&self) -> String;
|
fn get_source_file_suffix(&self) -> String;
|
||||||
fn get_passes(&self) -> Vec<String> {
|
fn get_passes(&self) -> Vec<PassDescriptor> {
|
||||||
vec![]
|
vec![]
|
||||||
}
|
}
|
||||||
fn handle_custom_interpreter_directives(&mut self, _commands: &Vec<&str>) -> Option<String> {
|
fn handle_custom_interpreter_directives(&mut self, _commands: &Vec<&str>) -> Option<String> {
|
||||||
|
@ -112,7 +112,7 @@ fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInte
|
|||||||
source_file.read_to_string(&mut buffer).unwrap();
|
source_file.read_to_string(&mut buffer).unwrap();
|
||||||
|
|
||||||
for pass in debug_passes.into_iter() {
|
for pass in debug_passes.into_iter() {
|
||||||
if let Some(_) = language.get_passes().iter().find(|stage_name| **stage_name == pass) {
|
if let Some(_) = language.get_passes().iter().find(|desc| desc.name == pass) {
|
||||||
options.debug_passes.insert(pass, PassDebugDescriptor { opts: vec![] });
|
options.debug_passes.insert(pass, PassDebugDescriptor { opts: vec![] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,8 +335,8 @@ impl 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, None)).collect(), 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, None)).collect(), None),
|
CommandTree::NonTerminal(format!("hide"), passes.iter().map(|p| CommandTree::term(&p.name, None)).collect(), 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),
|
||||||
@ -436,12 +436,12 @@ impl Repl {
|
|||||||
match commands.get(1) {
|
match commands.get(1) {
|
||||||
Some(&"passes") => Some(
|
Some(&"passes") => Some(
|
||||||
passes.into_iter()
|
passes.into_iter()
|
||||||
.map(|p| {
|
.map(|desc| {
|
||||||
if self.options.debug_passes.contains_key(&p) {
|
if self.options.debug_passes.contains_key(&desc.name) {
|
||||||
let color = "green";
|
let color = "green";
|
||||||
format!("*{}", p.color(color))
|
format!("*{}", desc.name.color(color))
|
||||||
} else {
|
} else {
|
||||||
p
|
desc.name
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.intersperse(format!(" -> "))
|
.intersperse(format!(" -> "))
|
||||||
@ -453,16 +453,16 @@ impl Repl {
|
|||||||
None => return Some(format!("Must specify a stage to debug")),
|
None => return Some(format!("Must specify a stage to debug")),
|
||||||
};
|
};
|
||||||
let pass_opt = commands.get(3);
|
let pass_opt = commands.get(3);
|
||||||
if let Some(stage) = passes.iter().find(|stage_name| **stage_name == debug_pass) {
|
if let Some(desc) = passes.iter().find(|desc| desc.name == debug_pass) {
|
||||||
let mut opts = vec![];
|
let mut opts = vec![];
|
||||||
if let Some(opt) = pass_opt {
|
if let Some(opt) = pass_opt {
|
||||||
opts.push(opt.to_string());
|
opts.push(opt.to_string());
|
||||||
}
|
}
|
||||||
let msg = format!("{} debug for stage {}", if show { "Enabling" } else { "Disabling" }, debug_pass);
|
let msg = format!("{} debug for pass {}", if show { "Enabling" } else { "Disabling" }, debug_pass);
|
||||||
if show {
|
if show {
|
||||||
self.options.debug_passes.insert(stage.clone(), PassDebugDescriptor { opts });
|
self.options.debug_passes.insert(desc.name.clone(), PassDebugDescriptor { opts });
|
||||||
} else {
|
} else {
|
||||||
self.options.debug_passes.remove(stage);
|
self.options.debug_passes.remove(&desc.name);
|
||||||
}
|
}
|
||||||
Some(msg)
|
Some(msg)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user