Skip to content

Commit

Permalink
[lang0] Definition has optional indirectFreeNames
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Apr 5, 2024
1 parent 859dae7 commit fcc2fa1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
`utils/setPop`

# lang0

> 支持直接递归函数与相互递归函数,不能判断等价的地方就不判断。
[lang0] add a pass to handle `checkOccur`
[lang0] `expIndirectFreeNames`

[lang0] `checkOccur` -- a pass to create `FnRecursive` from `Fn`

- check occur to create `FnRecursive` instead of `Fn`
- only in the same module for now

[lang0] `equivalent` -- `FnRecursive`
Expand Down
1 change: 1 addition & 0 deletions src/lang0/definition/Definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export type Definition = {
name: string
exp: Exp
freeNames: Set<string>
indirectFreeNames?: Set<string>
cache?: Value
}
18 changes: 18 additions & 0 deletions src/lang0/exp/expIndirectFreeNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Mod } from "../mod/Mod.js"
import { modOwnDefinitions } from "../mod/modOwnDefinitions.js"
import type { Exp } from "./Exp.js"
import { expFreeNames } from "./expFreeNames.js"

export function expIndirectFreeNames(mod: Mod, exp: Exp): Set<string> {
const freeNames = expFreeNames(new Set(), exp)
const ownDefinitions = modOwnDefinitions(mod)

const remainingNames = freeNames
const indirectFreeNames = new Set<string>()

while (remainingNames.size > 0) {
//
}

return indirectFreeNames
}

0 comments on commit fcc2fa1

Please sign in to comment.