Import Upstream version 20180207
[hcoop/debian/mlton.git] / mlton / closure-convert / lambda-free.sig
CommitLineData
7f918cf1
CE
1(* Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9signature LAMBDA_FREE_STRUCTS =
10 sig
11 include SXML
12 end
13
14signature LAMBDA_FREE =
15 sig
16 include LAMBDA_FREE_STRUCTS
17
18 structure Status:
19 sig
20 type t
21
22 val init: t
23 end
24 (*
25 * When called, descends the entire program and attaches a property
26 * to each lambda primExp in the program. Then, you can use
27 * lambdaFree to get free variables of that lambda.
28 * For lambdas bound in a Fun dec, lambdaFree gives the union of the
29 * frees of the entire group of mutually recursive functions. Hence,
30 * lambdaFree for every lambda in a single Fun dec is the same.
31 * Furthermore, for a lambda bound in a Fun dec, lambdaRec gives
32 * the list of other funs bound in the same dec that the lambda refers
33 * to. For example:
34 *
35 * val rec f = fn x => ... y ... g ... f ...
36 * and g = fn z => ... f ... w ...
37 *
38 * lambdaFree(fn x =>) = [y, w]
39 * lambdaFree(fn z =>) = [y, w]
40 * lambdaRec(fn x =>) = [g, f]
41 * lambdaRec(fn z =>) = [f]
42 *)
43 val lambdaFree:
44 {program: Program.t,
45 overflow: Var.t,
46 varInfo: Var.t -> {frees: Var.t list ref ref,
47 status: Status.t ref},
48 lambdaInfo: Lambda.t -> {frees: Var.t vector ref,
49 recs: Var.t vector ref}}
50 -> unit
51 end