File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ use ast_parser:: parse_ast_ctx;
2+ use astoir:: { run_astoir_hir, run_astoir_mir} ;
3+ use lexer:: lexer:: lexer_parse_file;
4+
5+ use crate :: { cli:: IRLayer , quietlyquit_if_errors} ;
6+
7+ pub fn run_check ( path : String , layer : IRLayer ) {
8+ let lexer = lexer_parse_file ( & path) ;
9+ quietlyquit_if_errors ! ( ) ;
10+
11+ let ast = parse_ast_ctx ( & lexer. unwrap ( ) ) ;
12+ quietlyquit_if_errors ! ( ) ;
13+
14+ match layer {
15+ IRLayer :: HIR => {
16+ let hir = run_astoir_hir ( ast. unwrap ( ) ) ;
17+ quietlyquit_if_errors ! ( ) ;
18+ }
19+
20+ IRLayer :: MIR => {
21+ let mir = run_astoir_mir ( ast. unwrap ( ) ) ;
22+ quietlyquit_if_errors ! ( ) ;
23+ }
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ pub mod check;
2+
3+ #[ macro_export]
4+ macro_rules! quietlyquit_if_errors {
5+ ( ) => {
6+ if ( diagnostics:: has_diagnostics( ) ) {
7+ diagnostics:: dump_diagnostics( ) ;
8+ std:: process:: exit( 445 ) ;
9+ }
10+ } ;
11+ }
Original file line number Diff line number Diff line change 1+ use std:: time:: Instant ;
2+
13use clap:: Parser ;
24
35use crate :: {
46 cli:: { CLICommand , Cli } ,
7+ cmds:: check:: run_check,
58 version:: { GIT_HASH , VERSION } ,
69} ;
710
811pub mod cli;
12+ pub mod cmds;
913pub mod version;
1014
1115fn main ( ) {
@@ -16,6 +20,21 @@ fn main() {
1620 println ! ( "Quickfall v{} (commit {})" , VERSION , GIT_HASH ) ;
1721 }
1822
23+ CLICommand :: Check { input, layer } => {
24+ let start = Instant :: now ( ) ;
25+ let count = input. len ( ) ;
26+
27+ for file in input {
28+ run_check ( file, layer) ;
29+ }
30+
31+ println ! (
32+ "No problems could be found in the {} provided files! Checked in {:?}" ,
33+ count,
34+ start. elapsed( )
35+ )
36+ }
37+
1938 _ => todo ! ( ) ,
2039 }
2140}
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ pub fn dump_diagnostics() {
7070 } )
7171}
7272
73+ pub fn has_diagnostics ( ) -> bool {
74+ DIAGNOSTIC_CONTAINER . with_borrow ( |f| return !f. diagnostics . is_empty ( ) )
75+ }
76+
7377pub fn move_current_diagnostic_pos ( pos : SpanPosition ) {
7478 CURR_DIAGNOSTIC_POS . with_borrow_mut ( |f| {
7579 * f = Some ( pos) ;
You can’t perform that action at this time.
0 commit comments