Skip to content

Commit

Permalink
compiler: fix code generation for postfix statements which uses map l…
Browse files Browse the repository at this point in the history
…ookup as lvalue
  • Loading branch information
mertcandav committed Jan 16, 2025
1 parent 6478089 commit 754e592
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/julec/obj/cxx/scope.jule
Original file line number Diff line number Diff line change
Expand Up @@ -557,17 +557,10 @@ impl scopeCoder {
identCoder.label(self.oc.Buf, uintptr(gt.Label))
}

fn postfix(mut &self, mut p: &sema::Postfix) {
self.oc.write("(")
self.oc.ec.possibleRefExpr(p.Expr)
self.oc.write(")")
self.oc.write(p.Op)
}

fn assignLeft(mut &self, mut &model: sema::Expr) {
match type model {
fn tryMapSet(mut &self, m: sema::Expr): (ok: bool) {
match type m {
| &sema::IndexingExpr:
mut iem := (&sema::IndexingExpr)(model)
mut iem := (&sema::IndexingExpr)(m)
_map := iem.Expr.Type.Map()
if _map == nil {
break
Expand All @@ -590,9 +583,26 @@ impl scopeCoder {
self.oc.write("), ")
self.oc.ec.possibleRefExpr(iem.Index.Model)
self.oc.write("))")
ret
ok = true
}
ret
}

fn postfix(mut &self, mut p: &sema::Postfix) {
self.oc.write("(")
ok := self.tryMapSet(p.Expr)
if !ok {
self.oc.ec.possibleRefExpr(p.Expr)
}
self.oc.write(")")
self.oc.write(p.Op)
}

fn assignLeft(mut &self, mut &model: sema::Expr) {
ok := self.tryMapSet(model)
if !ok {
self.oc.ec.possibleRefExpr(model)
}
self.oc.ec.possibleRefExpr(model)
}

fn shl(mut &self, mut a: &sema::Assign) {
Expand Down

0 comments on commit 754e592

Please sign in to comment.