mirror of
https://github.com/imjasonh/nescript
synced 2026-07-09 17:28:00 +00:00
M2: Wire IR pipeline, add Coin Cavern example and integration tests
Pipeline: - main.rs now runs IR lowering and optimization before codegen - IR is built and optimized but output still uses AST-based codegen (IR-based codegen is a future improvement) Coin Cavern example (examples/coin_cavern.ne): - 3-state game: Title → Playing → GameOver - Functions (clamp_x), constants, gravity physics, coin collection - Demonstrates most M2 language features Integration tests (14 total, 7 new): - program_with_functions: functions with params and return values - program_with_while_loop: while loops compile correctly - program_with_fast_slow_vars: placement hints accepted - program_with_multi_state_transitions: 3-state cycle - coin_cavern_compiles: full Coin Cavern example - ir_pipeline_produces_ir: validates IR lowering + optimizer - error_test_recursion_detected: E0402 for recursive functions https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
parent
192d9c5c3d
commit
0dc06f7f1a
3 changed files with 287 additions and 5 deletions
|
|
@ -4,7 +4,9 @@ use std::path::PathBuf;
|
|||
use nescript::analyzer;
|
||||
use nescript::codegen::CodeGen;
|
||||
use nescript::errors::render_diagnostics;
|
||||
use nescript::ir;
|
||||
use nescript::linker::Linker;
|
||||
use nescript::optimizer;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "nescript", about = "NEScript compiler — NES game development")]
|
||||
|
|
@ -87,7 +89,11 @@ fn compile(input: &PathBuf) -> Result<Vec<u8>, ()> {
|
|||
return Err(());
|
||||
}
|
||||
|
||||
// Code generation
|
||||
// IR lowering and optimization
|
||||
let mut ir_program = ir::lower(&program, &analysis);
|
||||
optimizer::optimize(&mut ir_program);
|
||||
|
||||
// Code generation (still AST-based for M2; IR codegen comes in M3)
|
||||
let codegen = CodeGen::new(&analysis.var_allocations, &program.constants);
|
||||
let instructions = codegen.generate(&program);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue