slang_frontend/semantic_analysis/
semantic_analyzer.rs1use crate::semantic_analysis::ErrorCollector;
2use slang_error::CompileResult;
3use slang_ir::ast::Statement;
4use slang_shared::CompilationContext;
5
6use super::analyzer_modules::core::CoreAnalyzer;
7use super::analyzer_modules::native_functions;
8
9pub fn execute(statements: &[Statement], context: &mut CompilationContext) -> CompileResult<()> {
19 let mut analyzer = CoreAnalyzer::new(context);
20 native_functions::register_native_functions(analyzer.context()); let mut error_collector = ErrorCollector::new();
23
24 for stmt in statements {
25 if let Err(error) = analyzer.analyze_statement(stmt) {
26 error_collector.add_semantic_error(error, analyzer.context());
27 }
28 }
29
30 if error_collector.has_errors() {
31 Err(error_collector.into_errors())
32 } else {
33 Ok(())
34 }
35}
36