Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | LambdaFree |
2 | ========== | |
3 | ||
4 | <:LambdaFree:> is an analysis pass for the <:SXML:> | |
5 | <:IntermediateLanguage:>, invoked from <:ClosureConvert:>. | |
6 | ||
7 | == Description == | |
8 | ||
9 | This pass descends the entire <:SXML:> program and attaches a property | |
10 | to each `Lambda` `PrimExp.t` in the program. Then, you can use | |
11 | `lambdaFree` and `lambdaRec` to get free variables of that `Lambda`. | |
12 | ||
13 | == Implementation == | |
14 | ||
15 | * <!ViewGitFile(mlton,master,mlton/closure-convert/lambda-free.sig)> | |
16 | * <!ViewGitFile(mlton,master,mlton/closure-convert/lambda-free.fun)> | |
17 | ||
18 | == Details and Notes == | |
19 | ||
20 | For `Lambda`-s bound in a `Fun` dec, `lambdaFree` gives the union of | |
21 | the frees of the entire group of mutually recursive functions. Hence, | |
22 | `lambdaFree` for every `Lambda` in a single `Fun` dec is the same. | |
23 | Furthermore, for a `Lambda` bound in a `Fun` dec, `lambdaRec` gives | |
24 | the list of other functions bound in the same dec defining that | |
25 | `Lambda`. | |
26 | ||
27 | For example: | |
28 | ---- | |
29 | val rec f = fn x => ... y ... g ... f ... | |
30 | and g = fn z => ... f ... w ... | |
31 | ---- | |
32 | ||
33 | ---- | |
34 | lambdaFree(fn x =>) = [y, w] | |
35 | lambdaFree(fn z =>) = [y, w] | |
36 | lambdaRec(fn x =>) = [g, f] | |
37 | lambdaRec(fn z =>) = [f] | |
38 | ---- |