Skip to content

Commit

Permalink
Merge pull request #2696 from tokiwa-software/dfa_use_super_lifeTime
Browse files Browse the repository at this point in the history
dfa: simplify `DFA.lifeTime()` using `super.lifeTime()`
  • Loading branch information
michaellilltokiwa authored Mar 8, 2024
2 parents 66825a4 + eadc178 commit b65cd32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/dev/flang/fuir/FUIR.java
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ public LifeTime lifeTime(int cl, boolean pre)
case Intrinsic -> LifeTime.Undefined;
case Field -> LifeTime.Call;
case Routine -> LifeTime.Unknown;
case Native -> LifeTime.Unknown;
case Native -> LifeTime.Undefined;
});

return result;
Expand Down
28 changes: 5 additions & 23 deletions src/dev/flang/fuir/analysis/dfa/DFA.java
Original file line number Diff line number Diff line change
Expand Up @@ -977,29 +977,11 @@ public boolean clazzNeedsCode(int cl)
*/
public LifeTime lifeTime(int cl, boolean pre)
{
var result =
pre ? (switch (clazzKind(cl))
{
case Choice -> LifeTime.Undefined;
case Abstract ,
Intrinsic ,
Field ,
Routine ,
Native -> currentEscapes(cl, pre) ? LifeTime.Unknown :
LifeTime.Call;
})
: (switch (clazzKind(cl))
{
case Abstract -> LifeTime.Undefined;
case Choice -> LifeTime.Undefined;
case Intrinsic -> LifeTime.Undefined;
case Field -> LifeTime.Call;
case Routine -> currentEscapes(cl, pre) ? LifeTime.Unknown :
LifeTime.Call;
case Native -> LifeTime.Undefined;
});

return result;
return
pre || (clazzKind(cl) != FeatureKind.Routine)
? super.lifeTime(cl, pre)
: currentEscapes(cl, pre) ? LifeTime.Unknown :
LifeTime.Call;
}


Expand Down

0 comments on commit b65cd32

Please sign in to comment.