From 832d0d4ee3a1c099b72f52e4ebfff8204522ca51 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 29 Apr 2018 22:51:01 -0700 Subject: [PATCH] Add more debug jank entries --- schala-lang/src/lib.rs | 14 ++++++-------- schala-repl/src/language.rs | 5 +++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index a124b1f..504add8 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -43,7 +43,6 @@ impl Schala { fn tokenizing_stage(_handle: &mut Schala, input: &str, comp: Option<&mut UnfinishedComputation>) -> Result, ()> { let tokens = tokenizing::tokenize(input); comp.map(|comp| { - println!("This should only be evaluated when debugging tokens and not other times!!!"); let token_string = tokens.iter().map(|t| format!("{:?}", t.token_type, t.offset.0, t.offset.1)).join(", "); comp.add_artifact(TraceArtifact::new("tokens", token_string)); }); @@ -63,7 +62,11 @@ fn parsing_stage(_handle: &mut Schala, input: Vec, comp: Opti fn symbol_table_stage(handle: &mut Schala, input: parsing::AST, comp: Option<&mut UnfinishedComputation>) -> Result { match handle.type_context.add_top_level_types(&input) { - Ok(()) => Ok(input), + Ok(()) => { + let text = handle.type_context.debug_symbol_table(); + comp.map(|comp| comp.add_artifact(TraceArtifact::new("symbol_table", text))); + Ok(input) + }, Err(msg) => Err(msg) } } @@ -71,12 +74,7 @@ fn symbol_table_stage(handle: &mut Schala, input: parsing::AST, comp: Option<&mu fn typechecking_stage(handle: &mut Schala, input: parsing::AST, comp: Option<&mut UnfinishedComputation>) -> Result { match handle.type_context.type_check_ast(&input) { Ok(ty) => { - println!("FINAL TYPE: {:?}", ty); - /* - if options.debug.type_checking { - evaluation.add_artifact(TraceArtifact::new("type_check", format!("{:?}", ty))); - } - */ + comp.map(|comp| comp.add_artifact(TraceArtifact::new("type_check", format!("{:?}", ty)))); Ok(input) }, Err(msg) => Err(msg) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 53f6f4d..c844ba3 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -207,12 +207,13 @@ macro_rules! pass_chain_helper { (($state:expr, $comp:expr, $options:expr); $input:expr, $pass:path $(, $rest:path)*) => { { let pass_name = stringify!($pass); - println!("Running pass {}", pass_name); let output = { let debug_pointer: Option<&mut UnfinishedComputation> = { //TODO this is janky fix it let debug_condition = ($options.debug.tokens && pass_name == "tokenizing_stage") - || ($options.debug.parse_tree && pass_name == "parsing_stage"); + || ($options.debug.parse_tree && pass_name == "parsing_stage") + || ($options.debug.symbol_table && pass_name == "symbol_table_stage") + || (pass_name == "typechecking_stage"); if debug_condition { Some(&mut $comp) } else { None } }; $pass($state, $input, debug_pointer)