Skip to content

Commit

Permalink
move lowering stage after validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mhasel committed Oct 24, 2024
1 parent 0c1227d commit 933e5ef
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions compiler/plc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,24 @@ pub fn compile_with_options(compile_options: CompilationContext) -> Result<()> {
// 1. Parse, 2. Index and 3. Resolve / Annotate
let annotated_project = pipelines::ParsedProject::parse(&ctxt, project, &mut diagnostician)?
.index(ctxt.provider())
.annotate(ctxt.provider())
// 4. AST-lowering, re-index and re-resolve
.lower(ctxt.provider());
.annotate(ctxt.provider());

// 4. Validate
annotated_project.validate(&ctxt, &mut diagnostician).map_err(|e| {
if compile_parameters.output_ast {
println!("{:#?}", annotated_project.units);
}
e
})?;

// 5. AST-lowering, re-index and re-resolve
let annotated_project = annotated_project.lower(ctxt.provider());

if compile_parameters.output_ast {
println!("{:#?}", annotated_project.units);
return Ok(());
}

// 5. Validate
annotated_project.validate(&ctxt, &mut diagnostician)?;

if let Some((location, format)) =
compile_parameters.hardware_config.as_ref().zip(compile_parameters.config_format())
{
Expand Down

0 comments on commit 933e5ef

Please sign in to comment.