Fixed some bugs

This commit is contained in:
2026-05-21 14:04:12 +02:00
parent 8703ac4254
commit f2257a4e81
3 changed files with 18 additions and 6 deletions
+15
View File
@@ -68,6 +68,14 @@ impl GenRust for Literal {
impl GenRust for Expression { impl GenRust for Expression {
fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) { fn gen_rust(&self, ctx: &mut Context, cg: &mut RustCodegen) {
let ensure_semicolon = if ctx.expr_ensure_semicolon {
ctx.expr_ensure_semicolon = false;
true
} else {
false
};
match self { match self {
Expression::Path(path) => cg.add(&path.get_rust()), Expression::Path(path) => cg.add(&path.get_rust()),
Expression::Literal(literal) => literal.gen_rust(ctx, cg), Expression::Literal(literal) => literal.gen_rust(ctx, cg),
@@ -90,6 +98,11 @@ impl GenRust for Expression {
rhs.gen_rust(ctx, cg); rhs.gen_rust(ctx, cg);
} }
} }
if ensure_semicolon {
ctx.expr_ensure_semicolon = true;
cg.add(";");
}
} }
} }
@@ -175,6 +188,8 @@ impl GenRust for Postfix {
expr.gen_rust(ctx, cg); expr.gen_rust(ctx, cg);
cg.add(","); cg.add(",");
} }
cg.add("}");
} }
Postfix::Index(idx) => { Postfix::Index(idx) => {
-3
View File
@@ -363,9 +363,6 @@ impl GenRust for TopLevelKind {
(fields, &constructor.item).gen_rust(ctx, cg); (fields, &constructor.item).gen_rust(ctx, cg);
cg.indent -= 1;
cg.add_indentedln("}\n");
for item in items.clone() { for item in items.clone() {
match item { match item {
ClassItem::ImplDecl(_) => {} ClassItem::ImplDecl(_) => {}
+2 -2
View File
@@ -12,9 +12,9 @@ pub struct Task {
} }
pub Task create_task(str* name) { pub Task create_task(str* name) {
return Task { Task {
name: name.to_string(), name: name.to_string(),
state: TaskState::Pending, state: TaskState::Pending,
executions: 0, executions: 0,
}; }
} }