-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Define VerificationCtx * Define trait VerificationPass
- Loading branch information
Showing
4 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! Verification context | ||
|
||
use sonatina_ir::{ControlFlowGraph, Function}; | ||
|
||
use crate::{error::ErrorData, ErrorStack}; | ||
|
||
pub struct VerificationCtx<'a> { | ||
pub func: &'a Function, | ||
pub cfg: ControlFlowGraph, | ||
pub error_stack: ErrorStack, | ||
} | ||
|
||
impl<'a> VerificationCtx<'a> { | ||
pub fn new(func: &'a Function) -> Self { | ||
let mut cfg = ControlFlowGraph::new(); | ||
cfg.compute(func); | ||
|
||
Self { | ||
func, | ||
cfg, | ||
error_stack: ErrorStack::default(), | ||
} | ||
} | ||
|
||
pub fn report_nonfatal(&mut self, errs: &[ErrorData]) { | ||
for e in errs { | ||
let _err_ref = self.error_stack.push(*e); | ||
} | ||
} | ||
|
||
pub fn report_fatal(&mut self, e: ErrorData) { | ||
self.error_stack.fatal_error = Some(e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
pub mod ctx; | ||
pub mod error; | ||
pub mod error_stack; | ||
pub mod pass; | ||
|
||
pub use ctx::VerificationCtx; | ||
pub use error_stack::ErrorStack; | ||
pub use pass::VerificationPass; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//! Verification pass | ||
|
||
use crate::VerificationCtx; | ||
|
||
pub trait VerificationPass { | ||
fn run(&mut self, ctx: VerificationCtx); | ||
} |