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