added asset management spec

This commit is contained in:
Nilton Constantino
2026-01-22 08:28:32 +00:00
parent 549d210d7e
commit dac80ff3cb
10 changed files with 15 additions and 959 deletions
@@ -70,8 +70,8 @@ impl Codegen {
}
}
// Find tick function (should be in the first program, which is the entry)
let mut tick_fn_name = None;
// Find frame function (should be in the first program, which is the entry)
let mut frame_fn_name = None;
if let Some((_, _, entry_program)) = programs.first() {
for item in &entry_program.body {
let f_opt = match item {
@@ -88,8 +88,8 @@ impl Codegen {
if let Some(f) = f_opt {
if let Some(ident) = &f.id {
if ident.name == "tick" {
tick_fn_name = Some(ident.name.to_string());
if ident.name == "frame" {
frame_fn_name = Some(ident.name.to_string());
break;
}
}
@@ -97,11 +97,11 @@ impl Codegen {
}
}
let tick_fn_name = tick_fn_name.ok_or_else(|| anyhow!("export function tick() not found in entry file"))?;
let frame_fn_name = frame_fn_name.ok_or_else(|| anyhow!("export function frame() not found in entry file"))?;
// Entry point: loop calling tick
// Entry point: loop calling frame
self.emit_label("entry".to_string());
self.emit_op(OpCode::Call, vec![Operand::Label(tick_fn_name), Operand::U32(0)], Span::default());
self.emit_op(OpCode::Call, vec![Operand::Label(frame_fn_name), Operand::U32(0)], Span::default());
self.emit_op(OpCode::Pop, vec![], Span::default());
self.emit_op(OpCode::FrameSync, vec![], Span::default());
self.emit_op(OpCode::Jmp, vec![Operand::Label("entry".to_string())], Span::default());