Skip to content

Commit

Permalink
sema: optimize variable reference collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jun 22, 2024
1 parent 3a9ae62 commit 0e91fbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,10 @@ impl Eval {
sc.owner.Refers.Push(ref)
}
|:
if self.owner != nil && !self.owner.Refers.Exist[T](ref) {
// Push reference to owner if global.
if self.owner != nil &&
self.owner.Scope == nil &&
!self.owner.Refers.Exist[T](ref) {
self.owner.Refers.Push(ref)
}
}
Expand Down Expand Up @@ -572,7 +575,8 @@ impl Eval {
// Appends depend to depends if there is no illegal cycle.
// Returns true if e.owner is nil.
fn checkIllegalCycles(mut self, mut &v: &Var, decl_token: &Token): (ok: bool) {
if self.owner == nil {
// Skip cycle checking if owner is nil or not global.
if self.owner == nil || self.owner.Scope != nil {
ret true
}

Expand Down

0 comments on commit 0e91fbf

Please sign in to comment.