Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /pgraph/releases/release-110.66/reconstruct.sml
ViewVC logotype

Annotation of /pgraph/releases/release-110.66/reconstruct.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 977 - (view) (download)
Original Path: sml/trunk/src/cm/pgraph/reconstruct.sml

1 : blume 977 (* reconstruct.sml
2 :     *
3 :     * (C) 2001 Lucent Technologies, Bell Labs
4 :     *
5 :     * author: Matthias Blume (blume@research.bell-labs.com)
6 :     *)
7 :     local structure P = PortableGraph in
8 :     structure ReconstructPortable :> sig
9 :    
10 :     type lib type env type sym type syms type misc
11 :     type graph = P.graph
12 :     type context = (lib, env, sym, syms, graph, misc) PGOps.context
13 :    
14 :     val reconstruct : (context -> lib list -> graph) * int -> graph
15 :     end = struct
16 :    
17 :     type lib = P.varname
18 :     type env = P.varname
19 :     type sym = P.varname
20 :     type syms = P.varname
21 :     type misc = int * P.def list
22 :     type graph = P.graph
23 :     type context = (lib, env, sym, syms, graph, misc) PGOps.context
24 :    
25 :     fun reconstruct (gt, nlibs) = let
26 :    
27 :     fun varname i = "v" ^ Int.toString i
28 :    
29 :     fun Bind (r, (i, d)) = let
30 :     val v = varname i
31 :     val i' = i + 1
32 :     val d' = P.DEF { lhs = v, rhs = r } :: d
33 :     in
34 :     ((i', d'), v)
35 :     end
36 :    
37 :     fun Sym m (ns, s) =
38 :     Bind (P.SYM (ns, s), m)
39 :     fun Syms m sl =
40 :     Bind (P.SYMS sl, m)
41 :     fun Imp m (l, ss) =
42 :     Bind (P.IMPORT { lib = l, syms = ss }, m)
43 :     fun Com m (s, e, ss, n) =
44 :     Bind (P.COMPILE { src = (s, n), env = e, syms = ss }, m)
45 :     fun Fil m (e, ss) =
46 :     Bind (P.FILTER { env = e, syms = ss }, m)
47 :     fun Mer m el =
48 :     Bind (P.MERGE el, m)
49 :    
50 :     val imports = List.tabulate (nlibs, varname)
51 :    
52 :     fun Exp (i, d) e =
53 :     P.GRAPH { imports = imports, defs = rev d, export = e }
54 :     in
55 :     gt { Ops = { Sym = Sym, Exp = Exp, Syms = Syms,
56 :     Imp = Imp, Com = Com, Fil = Fil, Mer = Mer },
57 :     Misc = (nlibs, []) }
58 :     imports
59 :     end
60 :     end
61 :     end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0