Add a location to verifier error messages.

The verifier reports the 'location' of an error message as a reference
to the entity that has a problem. This uses the 'AnyEntity' type to
refer to instructions/values/ebbs etc.

Also add an err! macro similar to the one used by the parser.
This commit is contained in:
Jakob Stoklund Olesen
2016-09-12 14:17:54 -07:00
parent 45559a21c1
commit 49202bf21b
4 changed files with 53 additions and 18 deletions

View File

@@ -259,7 +259,7 @@ impl Job {
// Should we run the verifier before this test?
if !context.verified && test.needs_verifier() {
try!(verify_function(&func));
try!(verify_function(&func).map_err(|e| e.to_string()));
context.verified = true;
}

View File

@@ -41,7 +41,7 @@ fn verifier_tests_from_source(function_source: &str) {
let result = Verifier::new(&func).run();
match verifier_results[i] {
Some(ref re) => {
assert_eq!(re.is_match(&result.err().unwrap()), true);
assert_eq!(re.is_match(&result.err().unwrap().message), true);
},
None => {
assert_eq!(result, Ok(()));

View File

@@ -1,4 +1,4 @@
function test(i32) { ; Err(terminating)
function test(i32) { ; Err(terminator)
ebb0(v0: i32):
jump ebb1
return