Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 2012 Matthew Fluet. |
2 | * Copyright (C) 1999-2005 Henry Cejtin, Matthew Fluet, Suresh | |
3 | * Jagannathan, and Stephen Weeks. | |
4 | * Copyright (C) 1997-2000 NEC Research Institute. | |
5 | * | |
6 | * MLton is released under a BSD-style license. | |
7 | * See the file MLton-LICENSE for details. | |
8 | *) | |
9 | ||
10 | functor ElaboratePrograms (S: ELABORATE_PROGRAMS_STRUCTS): ELABORATE_PROGRAMS = | |
11 | struct | |
12 | ||
13 | open S | |
14 | ||
15 | local | |
16 | open Control.Elaborate | |
17 | in | |
18 | val resolveScope = fn () => current resolveScope | |
19 | end | |
20 | ||
21 | structure ElaborateModules = ElaborateModules (structure Ast = Ast | |
22 | structure CoreML = CoreML | |
23 | structure Decs = Decs | |
24 | structure Env = Env) | |
25 | ||
26 | fun elaborateProgram (program, {env = E: Env.t}) = | |
27 | let | |
28 | val Ast.Program.T decs = Ast.Program.coalesce program | |
29 | fun elabTopdec d = ElaborateModules.elaborateTopdec (d, {env = E}) | |
30 | val decs = | |
31 | List.fold (decs, Decs.empty, fn (ds, decs) => | |
32 | List.fold (ds, decs, fn (d, decs) => | |
33 | Decs.append (decs, elabTopdec d))) | |
34 | val () = | |
35 | case resolveScope () of | |
36 | Control.Elaborate.ResolveScope.Program => | |
37 | (ElaborateModules.reportUnresolvedFlexRecords () | |
38 | ; ElaborateModules.resolveOverloads ()) | |
39 | | _ => () | |
40 | in | |
41 | decs | |
42 | end | |
43 | ||
44 | end |