Skip to content

Commit 157f9dd

Browse files
committed
finish
1 parent c31beeb commit 157f9dd

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Lean/Compiler/LCNF/JoinPoints.lean

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ private def addDependency (src : FVarId) (target : FVarId) : FindM Unit := do
116116
cs.modify target fun targetInfo =>
117117
{ targetInfo with associated := targetInfo.associated.insert src }
118118

119+
@[inline]
120+
private def withFnBody (decl : FunDecl) (x : FindM α) : FindM α :=
121+
withReader (fun ctx => {
122+
ctx with
123+
definitionDepth := ctx.definitionDepth + 1,
124+
currentFunction := some decl.fvarId }) do
125+
x
126+
127+
@[inline]
128+
private def withFnDefined (decl : FunDecl) (x : FindM α) : FindM α :=
129+
withReader (fun ctx => {
130+
ctx with
131+
scope := ctx.scope.insert decl.fvarId ctx.definitionDepth }) do
132+
x
133+
119134
/--
120135
Find all `fun` declarations that qualify as a join point, that is:
121136
- are always fully applied
@@ -176,12 +191,9 @@ where
176191
go k
177192
| .fun decl k => do
178193
addCandidate decl.fvarId decl.getArity
179-
withReader (fun ctx => {
180-
ctx with
181-
definitionDepth := ctx.definitionDepth + 1,
182-
currentFunction := some decl.fvarId }) do
194+
withFnBody decl do
183195
go decl.value
184-
withReader (fun ctx => { ctx with scope := ctx.scope.insert decl.fvarId ctx.definitionDepth }) do
196+
withFnDefined decl do
185197
go k
186198
| .jp decl k => do
187199
go decl.value

0 commit comments

Comments
 (0)