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

SCM Repository

[smlnj] Diff of /pgraph/releases/release-110.62/gen-sml.sml
ViewVC logotype

Diff of /pgraph/releases/release-110.62/gen-sml.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 975, Wed Oct 31 20:22:44 2001 UTC revision 977, Wed Nov 14 16:53:16 2001 UTC
# Line 1  Line 1 
1    (* gen-sml.sml
2     *
3     * Generate SML source code for a given library.
4     *
5     * (C) 2001 Lucent Technologies, Bell Labs
6     *
7     * author: Matthias Blume (blume@research.bell-labs.com)
8     *)
9  local structure P = PortableGraph in  local structure P = PortableGraph in
10  structure GenSML : sig  structure GenSML : sig
11      type typ = string      type typ = string
# Line 8  Line 16 
16      exception ImportMismatch      exception ImportMismatch
17    
18      val gen : { graph: P.graph,      val gen : { graph: P.graph,
19                  srcname: string -> string,                  nativesrc: string -> string,
20                  importstructs: string list,                  importstructs: string list,
21                  outstream: TextIO.outstream,                  outstream: TextIO.outstream,
22                  exportprefix: string } -> unit                  exportprefix: string } -> unit
# Line 46  Line 54 
54    
55      fun gen args = let      fun gen args = let
56          val { graph = P.GRAPH { imports, defs, export },          val { graph = P.GRAPH { imports, defs, export },
57                srcname,                nativesrc,
58                importstructs,                importstructs,
59                outstream = outs,                outstream = outs,
60                exportprefix } = args                exportprefix } = args
# Line 87  Line 95 
95                      NONE => raise Unbound lib                      NONE => raise Unbound lib
96                    | SOME n => n                    | SOME n => n
97              fun fmt ((ns, n), (_, n')) =              fun fmt ((ns, n), (_, n')) =
98                  out [ns, " ", n', " = ", lstruct, "__", n, "\n"]                  out [ns, " ", n', " = ", lstruct, n, "\n"]
99          in          in
100              genexport (ss, fmt)              genexport (ss, fmt)
101          end          end
# Line 95  Line 103 
103          fun genimport ((ns, n), (_, n')) =          fun genimport ((ns, n), (_, n')) =
104              out ["    ", ns, " ", n, " = ", n', "\n"]              out ["    ", ns, " ", n, " = ", n', "\n"]
105    
106          fun compile (src, e, oss) = let          fun compile (src, native, e, oss) = let
107              fun fmt ((ns, n), (_, n')) =              fun fmt ((ns, n), (_, n')) =
108                  out [ns, " ", n', " = ", n, "\n"]                  out [ns, " ", n', " = ", n, "\n"]
109              fun copyfile src = let              fun copyfile src = let
110                  val ins = TextIO.openIn (srcname src)                  val ins = TextIO.openIn (if native then src else nativesrc src)
111                  fun copy () =                  fun copy () =
112                      case TextIO.input ins of                      case TextIO.input ins of
113                          "" => TextIO.closeIn ins                          "" => TextIO.closeIn ins
# Line 157  Line 165 
165                            end                            end
166                          | P.IMPORT { lib, syms } =>                          | P.IMPORT { lib, syms } =>
167                            ENV (import (lib, getSYMS syms))                            ENV (import (lib, getSYMS syms))
168                          | P.COMPILE { src, env, syms, native } =>                          | P.COMPILE { src = (src, native), env, syms } =>
169                            ENV (compile (src, getENV env, getSYMS syms))                            ENV (compile (src, native, getENV env, getSYMS syms))
170                          | P.FILTER { env, syms } =>                          | P.FILTER { env, syms } =>
171                            ENV (filter (getENV env, getSYMS syms))                            ENV (filter (getENV env, getSYMS syms))
172                          | P.MERGE el => let                          | P.MERGE el => let
# Line 175  Line 183 
183          val ee = getENV dm export          val ee = getENV dm export
184    
185          fun libexport ((ns, n), (_, n')) =          fun libexport ((ns, n), (_, n')) =
186              out [ns, " ", exportprefix, "__", n, " = ", n', "\n"]              out [ns, " ", exportprefix, n, " = ", n', "\n"]
187    
188      in      in
189          out ["in\n"];          out ["in\n"];

Legend:
Removed from v.975  
changed lines
  Added in v.977

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