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 2760 - (view) (download)

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 : blume 1011 fun Sgn m s =
38 :     Bind (P.SYM (P.SGN, s), m)
39 :     fun Str m s =
40 :     Bind (P.SYM (P.STR, s), m)
41 :     fun Fct m s =
42 :     Bind (P.SYM (P.FCT, s), m)
43 : blume 977 fun Syms m sl =
44 :     Bind (P.SYMS sl, m)
45 :     fun Imp m (l, ss) =
46 :     Bind (P.IMPORT { lib = l, syms = ss }, m)
47 :     fun Com m (s, e, ss, n) =
48 :     Bind (P.COMPILE { src = (s, n), env = e, syms = ss }, m)
49 :     fun Fil m (e, ss) =
50 :     Bind (P.FILTER { env = e, syms = ss }, m)
51 :     fun Mer m el =
52 :     Bind (P.MERGE el, m)
53 :    
54 :     val imports = List.tabulate (nlibs, varname)
55 :    
56 :     fun Exp (i, d) e =
57 :     P.GRAPH { imports = imports, defs = rev d, export = e }
58 :     in
59 : blume 1011 gt { Ops = { Sgn = Sgn, Str = Str, Fct = Fct,
60 :     Exp = Exp, Syms = Syms,
61 : blume 977 Imp = Imp, Com = Com, Fil = Fil, Mer = Mer },
62 :     Misc = (nlibs, []) }
63 :     imports
64 :     end
65 :     end
66 :     end

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