constants and static #102

This commit is contained in:
2026-07-02 06:51:04 +02:00
parent 493c668495
commit 5346cd05be
5 changed files with 55 additions and 1 deletions
+22
View File
@@ -191,6 +191,28 @@ impl GenRust for TopLevelKind {
fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) {
match self {
Self::ModAttribute => {}
Self::ConstDecl(decl) => {
cg.add("const ");
decl.decl.gen_rust(ctx, cg);
if let Some(init) = &decl.init {
cg.add(" = ");
init.gen_rust(ctx, cg);
}
cg.add(";");
}
Self::StaticDecl(decl) => {
cg.add("static ");
decl.decl.gen_rust(ctx, cg);
if let Some(init) = &decl.init {
cg.add(" = ");
init.gen_rust(ctx, cg);
}
cg.add(";");
}
Self::Import(vis, path) => {
cg.addln(&format!("{}use {};", vis.get_rust(), path.get_rust()))
}