(
ctx: Context<'gc>,
source: &'gc str,
)
| 10 | mod optimizer; |
| 11 | |
| 12 | pub fn compile<'gc>( |
| 13 | ctx: Context<'gc>, |
| 14 | source: &'gc str, |
| 15 | ) -> Result<BTreeMap<ChunkId, Gc<'gc, Function<'gc>>>, VmError> { |
| 16 | let mut parser = Parser::new(ctx, source); |
| 17 | let program = parser.parse()?; |
| 18 | #[cfg(feature = "debug")] |
| 19 | println!("AST: {}", program); |
| 20 | #[cfg(feature = "optimizer")] |
| 21 | let optimizer = optimizer::ChunkOptimizer::new(); |
| 22 | |
| 23 | CodeGen::generate(program, ctx).map(|chunks| { |
| 24 | chunks |
| 25 | .into_iter() |
| 26 | .map(|(id, function)| { |
| 27 | #[cfg(feature = "optimizer")] |
| 28 | let mut function = function; |
| 29 | #[cfg(feature = "optimizer")] |
| 30 | optimizer.optimize(&mut function.chunk); |
| 31 | (id, Gc::new(&ctx, function)) |
| 32 | }) |
| 33 | .collect() |
| 34 | }) |
| 35 | } |
no test coverage detected