Skip to content

Commit

Permalink
compiler: fix code generation for drop semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Sep 14, 2024
1 parent f648fc0 commit dcae6df
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/julec/obj/cxx/scope.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1591,22 +1591,34 @@ impl dropHandler {
self.sc.oc.ec.possibleRefExpr(m)
self.sc.oc.write(");")
}

fn varStep(mut &self, mut &v: &Var): bool {
if v.Constant {
// skip constants
ret true
}
if v.RetOrder != -2 {
if self.f&dropFlag.RetVars != dropFlag.RetVars {
// skip return variable if flag not passed
ret true
}
}
self.dropVar(v)
ret true
}

fn commonStep(mut &self, i: int, mut &stmt: Stmt): bool {
match type stmt {
| &Var:
mut v := (&Var)(stmt)
if v.Constant {
// skip constants
ret true
}
if v.RetOrder != -2 {
if self.f&dropFlag.RetVars != dropFlag.RetVars {
// skip return variable if flag not passed
ret true
ret self.varStep(v)
| &MultiAssign:
mut ma := (&MultiAssign)(stmt)
for (_, mut v) in ma.Decls {
if !self.varStep(v) {
ret false
}
}
self.dropVar(v)
}
ret true
}
Expand Down

0 comments on commit dcae6df

Please sign in to comment.