air_codegen_winter/
lib.rs

1use air_ir::Air;
2use codegen::{Impl, Scope};
3
4mod air;
5mod imports;
6
7// GENERATE RUST CODE FOR WINTERFELL AIR
8// ================================================================================================
9
10/// CodeGenerator is used to generate a Rust implementation of the Winterfell STARK prover library's
11/// Air trait. The generated Air expresses the constraints specified by the AirIR used to build the
12/// CodeGenerator.
13pub struct CodeGenerator;
14impl air_ir::CodeGenerator for CodeGenerator {
15    type Output = String;
16
17    fn generate(&self, ir: &Air) -> anyhow::Result<Self::Output> {
18        let mut scope = Scope::new();
19
20        // add winterfell imports.
21        imports::add_imports(&mut scope);
22
23        // add an Air struct and Winterfell Air trait implementation for the provided AirIR.
24        air::add_air(&mut scope, ir);
25
26        Ok(scope.to_string())
27    }
28}