Skip to content

Commit

Permalink
sema: minor optimization for assignment analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 12, 2024
1 parent 40f088c commit 113a4e4
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions std/jule/sema/scope.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1365,33 +1365,30 @@ impl scopeChecker {
}
self.scope.Stmts = append(self.scope.Stmts, &Assign{L: lm, R: rm, Op: a.Setter})

if a.Setter.Id != TokenId.Eq {
mut strct := l.Kind.Struct()
if strct != nil {
self.checkStructureAssignOp(strct, a, r)
ret
if a.Setter.Id == TokenId.Eq {
mut checker := assignTypeChecker{
s: self.s,
dest: l.Kind,
d: r,
errorToken: a.Setter,
}
id := a.Setter.Id
a.Setter.Id = removeEqFromOp(a.Setter.Id)
mut solver := binaryEval.new(eval, a.Setter)
r = solver.solveExplicit(l, r)
a.Setter.Id = id
if r == nil {
ret
if checker.check() {
rm.Model = r.Model
lm.Model = l.Model
}
ret
}

mut checker := assignTypeChecker{
s: self.s,
dest: l.Kind,
d: r,
errorToken: a.Setter,
}
if checker.check() {
rm.Model = r.Model
lm.Model = l.Model
mut strct := l.Kind.Struct()
if strct != nil {
self.checkStructureAssignOp(strct, a, r)
ret
}
id := a.Setter.Id
a.Setter.Id = removeEqFromOp(a.Setter.Id)
mut solver := binaryEval.new(eval, a.Setter)
solver.l, solver.r = l, r
_ = solver.evalOp()
a.Setter.Id = id
}

fn processEndPartOfMultiAssign(mut self, mut &st: &MultiAssign,
Expand Down

0 comments on commit 113a4e4

Please sign in to comment.