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 /sml/trunk/src/ml-nlffigen/main.sml
ViewVC logotype

Diff of /sml/trunk/src/ml-nlffigen/main.sml

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

revision 828, Fri May 11 18:32:07 2001 UTC revision 840, Fri Jun 15 19:05:19 2001 UTC
# Line 7  Line 7 
7   *)   *)
8  structure Main = struct  structure Main = struct
9    local    local
10    
11        fun tgt (n, sz, sh, cc) =
12            { name  = n, sizes = sz, shift = sh, stdcall = cc }
13    
14        val default_target =
15            tgt (DefaultName.name,
16                 DefaultSizes.sizes, DefaultEndian.shift, DefaultCC.stdcall)
17    
18        val target_table =
19            [tgt ("sparc-unix",
20                  SizesSparc.sizes, EndianBig.shift, CC_ccall.stdcall),
21             tgt ("x86-unix",
22                 SizesX86.sizes, EndianLittle.shift, CC_ccall.stdcall),
23             tgt ("x86-win32",
24                  SizesX86.sizes, EndianLittle.shift, CC_stdcall.stdcall)
25             (* needs to be extended ... *)
26             ]
27    
28        fun find_target tg =
29            case List.find (fn x => tg = #name x) target_table of
30                SOME t => t
31              | NONE => raise Fail (concat ["unknown target: " ^ tg])
32    
33      fun main0 (arg0, args) = let      fun main0 (arg0, args) = let
34          fun substitute (tmpl, s, t) = let          fun substitute (tmpl, s, t) = let
35              fun loop ([], a) = String.implode (rev a)              fun loop ([], a) = String.implode (rev a)
# Line 51  Line 74 
74                | l => finish (rev l)                | l => finish (rev l)
75          end          end
76          fun proc ([hfile],          fun proc ([hfile],
77                    sgf, stf, cmf, sgn, stn, asu, wid, lsp) =                    sgf, stf, cmf, sgn, stn, asu, wid, lsp, t) =
78              let val ifile = OS.FileSys.tmpName ()              let val ifile = OS.FileSys.tmpName ()
79                  val cpp_tmpl = getOpt (OS.Process.getEnv "FFIGEN_CPP",                  val cpp_tmpl = getOpt (OS.Process.getEnv "FFIGEN_CPP",
80                                         "gcc -E -U__GNUC__ %s > %t")                                         "gcc -E -U__GNUC__ %s > %t")
# Line 75  Line 98 
98                            strname = stn,                            strname = stn,
99                            allSU = asu,                            allSU = asu,
100                            lambdasplit = lsp,                            lambdasplit = lsp,
101                            wid = getOpt (wid, 75) }                            wid = getOpt (wid, 75),
102                              target = t }
103                  handle e => (OS.FileSys.remove ifile handle _ => (); raise e);                  handle e => (OS.FileSys.remove ifile handle _ => (); raise e);
104                  OS.FileSys.remove ifile handle _ => ();                  OS.FileSys.remove ifile handle _ => ();
105                  OS.Process.success                  OS.Process.success
106              end              end
107            | proc ("-sigfile" :: f :: l, _, stf, cmf, sgn, stn, asu, wid, lsp) =            | proc ("-sigfile" :: f :: l,
108              proc (l, SOME f, stf, cmf, sgn, stn, asu, wid, lsp)                    _, stf, cmf, sgn, stn, asu, wid, lsp, t) =
109            | proc ("-strfile" :: f :: l, sgf, _, cmf, sgn, stn, asu, wid, lsp) =              proc (l, SOME f, stf, cmf, sgn, stn, asu, wid, lsp, t)
110              proc (l, sgf, SOME f, cmf, sgn, stn, asu, wid, lsp)            | proc ("-strfile" :: f :: l,
111            | proc ("-cmfile" :: f :: l, sgf, stf, _, sgn, stn, asu, wid, lsp) =                    sgf, _, cmf, sgn, stn, asu, wid, lsp, t) =
112              proc (l, sgf, stf, SOME f, sgn, stn, asu, wid, lsp)              proc (l, sgf, SOME f, cmf, sgn, stn, asu, wid, lsp, t)
113            | proc ("-signame" :: n :: l, sgf, stf, cmf, _, stn, asu, wid, lsp) =            | proc ("-cmfile" :: f :: l,
114              proc (l, sgf, stf, cmf, SOME n, stn, asu, wid, lsp)                    sgf, stf, _, sgn, stn, asu, wid, lsp, t) =
115            | proc ("-strname" :: n :: l, sgf, stf, cmf, sgn, _, asu, wid, lsp) =              proc (l, sgf, stf, SOME f, sgn, stn, asu, wid, lsp, t)
116              proc (l, sgf, stf, cmf, sgn, SOME n, asu, wid, lsp)            | proc ("-signame" :: n :: l,
117            | proc ("-allSU" :: l, sgf, stf, cmf, sgn, stn, _, wid, lsp) =                    sgf, stf, cmf, _, stn, asu, wid, lsp, t) =
118              proc (l, sgf, stf, cmf, sgn, stn, true, wid, lsp)              proc (l, sgf, stf, cmf, SOME n, stn, asu, wid, lsp, t)
119            | proc ("-width" :: i :: l, sgf, stf, cmf, sgn, stn, asu, _, lsp) =            | proc ("-strname" :: n :: l,
120              proc (l, sgf, stf, cmf, sgn, stn, asu, Int.fromString i, lsp)                    sgf, stf, cmf, sgn, _, asu, wid, lsp, t) =
121                proc (l, sgf, stf, cmf, sgn, SOME n, asu, wid, lsp, t)
122              | proc ("-allSU" :: l,
123                      sgf, stf, cmf, sgn, stn, _, wid, lsp, t) =
124                proc (l, sgf, stf, cmf, sgn, stn, true, wid, lsp, t)
125              | proc ("-width" :: i :: l,
126                      sgf, stf, cmf, sgn, stn, asu, _, lsp, t) =
127                proc (l, sgf, stf, cmf, sgn, stn, asu, Int.fromString i, lsp, t)
128            | proc ("-lambdasplit" :: s :: l,            | proc ("-lambdasplit" :: s :: l,
129                    sgf, stf, cmf, sgn, stn, asu, wid, _) =                    sgf, stf, cmf, sgn, stn, asu, wid, _, t) =
130              proc (l, sgf, stf, cmf, sgn, stn, asu, wid, SOME s)              proc (l, sgf, stf, cmf, sgn, stn, asu, wid, SOME s, t)
131              | proc ("-target" :: tg :: l,
132                      sgf, stf, cmf, sgn, stn, asu, wid, lsp, _) =
133                proc (l, sgf, stf, cmf, sgn, stn, asu, wid, lsp, find_target tg)
134            | proc _ =            | proc _ =
135              raise Fail              raise Fail
136               (concat ["usage: ", arg0,               (concat ["usage: ", arg0,
137                 " \\\n\t[-sigfile sigfile] [-strfile strfile] [-cmfile cmfile] \                 " \\\n\t[-sigfile sigfile] [-strfile strfile] [-cmfile cmfile] \
138                 \ \\\n\t[-signame signame] [-strname strname] [-allSU] \                 \ \\\n\t[-signame signame] [-strname strname] [-allSU] \
139                 \ \\\n\t[-width linewidth] [-lambdasplit spec] \              \ \\\n\t[-width linewidth] [-lambdasplit spec] [-target arch-os] \
140                 \ \\\n    idlfile"])                 \ \\\n    idlfile"])
141      in      in
142          proc (args, NONE, NONE, NONE, NONE, NONE, false, NONE, NONE)          proc (args, NONE, NONE, NONE, NONE, NONE, false, NONE, NONE,
143                  default_target)
144      end      end
145    in    in
146      fun main args = main0 args      fun main args = main0 args

Legend:
Removed from v.828  
changed lines
  Added in v.840

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