[fine] Methods!

This commit is contained in:
John Doty 2024-01-24 09:03:45 -08:00
parent 2839b43f6d
commit 0c69758b11
5 changed files with 352 additions and 95 deletions

View file

@ -263,7 +263,7 @@ fn assert_eval_ok(tree: &SyntaxTree, lines: &Lines, expected: &str) {
let semantics = Semantics::new(tree, lines);
let module = compile(&semantics);
let mut context = Context::new(module);
let mut context = Context::new(module.clone());
context.init().expect("Unable to initialize module");
match eval_export_fn(&mut context, "test", &[]) {
@ -278,7 +278,24 @@ fn assert_eval_ok(tree: &SyntaxTree, lines: &Lines, expected: &str) {
);
}
Err(e) => {
semantic_panic!(&semantics, None, "error occurred while running: {:?}", e);
semantics.dump_compiler_state(None);
let mut actual = String::new();
let _ = dump_module(&mut actual, &module);
eprintln!("{actual}");
for frame in e.stack.iter() {
eprintln!("{:?}", frame.func());
eprint!(" (");
for arg in frame.args().iter() {
eprint!("{:?},", arg);
}
eprintln!(") @ {}", frame.pc());
}
eprintln!();
panic!("error occurred while running: {:?}", e.code);
}
}
}