39 lines
1.1 KiB
Markdown
39 lines
1.1 KiB
Markdown
- [x] downgrade stage
|
|
- [ ] resolve stage
|
|
- [ ] dynamic attr resolution
|
|
- [ ] import resolution
|
|
- [ ] static path resolution
|
|
- [ ] eval stage
|
|
- [ ] dynamic path resolution
|
|
- [ ] graph update
|
|
- [ ] stack storage
|
|
|
|
依赖类型:
|
|
1. 强依赖 (x!)
|
|
- builtins.toString x => x!
|
|
- x + y => x! y!
|
|
- { x = 1; ${sym} = 2; } => sym!
|
|
2. 弱依赖 a.k.a. thunk (x?)
|
|
- builtins.seq x y => x! y?
|
|
3. 递归依赖 (x!!)
|
|
- builtins.deepSeq x y => x!! y?
|
|
|
|
e.g.
|
|
- let a? = { inherit a?; }; in a! => a!
|
|
- a! => { a = <THUNK> }
|
|
- f: let x? = f! x?; in x! => f! x!
|
|
- let ret? = (self: { x? = 1; y? = self.x! + 1; }) ret?; in ret.y! => ret! x! y!
|
|
|
|
工作流程:
|
|
1. string -> AST
|
|
2. AST -> HIR (alloc ExprId)
|
|
3. HIR -> LIR (resolve var, build graph)
|
|
4. LIR -> Value
|
|
|
|
为每个值分配 ID 的难点在于对动态表达式的引用。
|
|
动态表达式有:
|
|
- 依赖于函数参数的表达式
|
|
- 依赖于 with 的表达式
|
|
- 依赖于动态表达式的表达式
|
|
而这些表达式在每一次分配 ValueId 时指向的 ValueId 都不同,因此需要追踪这些变量。
|