Updated codegen

This commit is contained in:
2026-05-28 11:36:28 +02:00
parent e09c7926e5
commit 3444f93546
2 changed files with 8 additions and 9 deletions
+7 -5
View File
@@ -4,10 +4,6 @@ pub mod top_level;
use mist_parser::ast::*;
pub fn get_mutable(mutable: bool) -> String {
if mutable { "mut " } else { "" }.to_string()
}
pub struct Context {
pub expr_ensure_semicolon: bool,
}
@@ -239,7 +235,13 @@ impl GenRust for Pattern {
fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) {
match self {
Self::Id(id) => cg.add(&id.get_rust()),
Self::Path(path) => cg.add(&path.get_rust()),
Self::Path(mutable, path) => {
if *mutable {
cg.add("mut ");
};
cg.add(&path.get_rust())
}
Self::Literal(lit) => lit.gen_rust(ctx, cg),
Self::Struct(path, ids) => {