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 /sml/trunk/src/cm/tools/main/core-tools.sig
ViewVC logotype

Annotation of /sml/trunk/src/cm/tools/main/core-tools.sig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1137 - (view) (download) (as text)

1 : blume 742 (*
2 :     * The common core of both public and private interface to CM's tools
3 :     * mechanism.
4 :     *
5 :     * (C) 2000 Lucent Technologies, Bell Laboratories
6 :     *
7 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
8 :     *)
9 :     signature CORETOOLS = sig
10 :    
11 :     (* We don't make classes abstract. It doesn't look like there
12 :     * would be much point to it. *)
13 :     type class = string
14 :    
15 :     (* We keep source paths abstract. Tool writers should not mess
16 :     * with their internals.
17 :     * The function that makes a srcpath from a string is passed as
18 :     * part of the input specification (type "spec"). Which function
19 :     * is originally being passed depends on which syntax was used for
20 :     * this member in its .cm-file. Most tools will want to work on
21 :     * native pathname syntax (function "outdated" -- see below -- depends
22 :     * on native syntax!). In these cases the tool should first convert
23 :     * the name to a srcpath and then get the native string back by
24 :     * applying "nativeSpec". *)
25 :     type srcpath
26 :     type presrcpath
27 :    
28 :     type rebindings = { anchor: string, value: presrcpath } list
29 :    
30 : blume 756 (* get the spec (i.e., relative to the directory context) of a path: *)
31 : blume 742 val nativeSpec : srcpath -> string
32 : blume 756 (* same for presrcpath... *)
33 :     val nativePreSpec : presrcpath -> string
34 : blume 742
35 : blume 756 (* make a srcpath from a presrcpath, checking that the "at least one
36 :     * arc" rule is satisfied... *)
37 : blume 742 val srcpath : presrcpath -> srcpath
38 :    
39 : blume 756 (* augment a presrcpath with extra arcs; the new path has inherits
40 :     * the context (i.e., any anchoring) from the original one... *)
41 :     val augment : presrcpath -> string list -> presrcpath
42 :    
43 : blume 742 exception ToolError of { tool: string, msg: string }
44 :    
45 : blume 756 type pathmaker = unit -> presrcpath
46 : blume 742
47 : blume 756 (* a file-name specification *)
48 :     type fnspec = { name: string, mkpath: pathmaker }
49 :    
50 : blume 742 (* case-by-case parameters that can be passed to tools... *)
51 :     datatype toolopt =
52 : blume 756 STRING of fnspec
53 : blume 742 | SUBOPTS of { name: string, opts: toolopts }
54 :     withtype toolopts = toolopt list
55 :    
56 :     type tooloptcvt = toolopts option -> toolopts option
57 :    
58 :     (* A member specification consists of the actual string, an optional
59 :     * class name, (optional) tool options, a function to convert a
60 :     * string to its corresponding srcpath, and information about whether
61 :     * or not this source is an "original" source or a derived source
62 :     * (i.e., output of some tool). *)
63 :     type spec = { name: string,
64 :     mkpath: pathmaker,
65 :     class: class option,
66 :     opts: toolopts option,
67 :     derived: bool }
68 :    
69 :     type setup = string option * string option (* (pre, post) *)
70 :    
71 : blume 818 type splitting = int option option (* see ....Control.LambdaSplitting... *)
72 :    
73 : blume 986 type smlparams =
74 :     { share: Sharing.request,
75 :     setup: setup,
76 :     split: splitting,
77 : blume 1137 noguid: bool,
78 : blume 986 locl: bool }
79 :    
80 :     type cmparams =
81 :     { version: Version.t option,
82 :     rebindings: rebindings }
83 :    
84 : blume 742 (* The goal of applying tools to members is to obtain an "expansion",
85 :     * i.e., a list of ML-files and a list of .cm-files. We also
86 :     * obtain a list of "sources". This is used to implement CM.sources,
87 :     * i.e., to generate dependency information etc. *)
88 :     type expansion =
89 : blume 986 { smlfiles: (srcpath * smlparams) list,
90 :     cmfiles: (srcpath * cmparams) list,
91 : blume 742 sources: (srcpath * { class: class, derived: bool}) list }
92 :    
93 :     (* A partial expansion is an expansion with a list of things yet to be
94 :     * expanded... *)
95 :     type partial_expansion = expansion * spec list
96 :    
97 :     (* A rule takes a spec and a rulecontext where the name contained
98 :     * in the spec -- if relative -- is considered relative to the directory
99 :     * of the corresponding description file. In general,
100 :     * when coding a rule one would write a rule function and pass it to
101 :     * the context, which will temporarily change the current working
102 :     * directory to the one that holds the description file ("the context").
103 :     * If this is not necessary for the rule to work correctly, then
104 :     * one can simply ignore the context (this saves system call overhead
105 :     * during dependency analysis).
106 :     * If the rule yields a genuine partial expansion (where the resulting
107 :     * spec list is not empty), then it must pass the proper "path maker"
108 :     * along with each new name. For most cases this will be the given
109 :     * "native path maker" because most rules work on native path names.
110 :     * Some rules, however, might want to use the same convention for
111 :     * derived specs that was used for the original spec. *)
112 :     type rulefn = unit -> partial_expansion
113 :     type rulecontext = rulefn -> partial_expansion
114 : blume 756 type rule = { spec: spec,
115 :     native2pathmaker: string -> pathmaker,
116 :     context: rulecontext,
117 : blume 873 defaultClassOf: fnspec -> class option,
118 :     sysinfo: { symval: string -> int option,
119 :     archos: string } } ->
120 : blume 756 partial_expansion
121 : blume 742
122 :     (* install a class *)
123 :     val registerClass : class * rule -> unit
124 :    
125 :     (* classifiers are used when the class is not given explicitly *)
126 :     datatype classifier =
127 :     SFX_CLASSIFIER of string -> class option
128 : blume 756 | GEN_CLASSIFIER of { name: string, mkfname: unit -> string } ->
129 :     class option
130 : blume 742
131 :     (* make a classifier which looks for a specific file name suffix *)
132 :     val stdSfxClassifier : { sfx: string , class: class } -> classifier
133 :    
134 :     (* two standard ways of dealing with filename extensions...
135 :     * (Tool options can be calculated from the options that we have.) *)
136 :     datatype extensionStyle =
137 :     EXTEND of (string * class option * tooloptcvt) list
138 :     | REPLACE of string list * (string * class option * tooloptcvt) list
139 :    
140 :     (* perform filename extension *)
141 :     val extend : extensionStyle ->
142 :     (string * toolopts option) ->
143 :     (string * class option * toolopts option) list
144 :    
145 :     (* check for outdated files; the pathname strings must be in
146 :     * native syntax! *)
147 :     val outdated : string -> string list * string -> bool
148 :    
149 :     (* Alternative way of checking for outdated-ness using a "witness"
150 :     * file. The idea is that if both tgt (target) and wtn (witness)
151 :     * exist, then tgt is considered outdated if wtn is older than src.
152 :     * Otherwise, if tgt exists but wtn does not, then tgt is considered
153 :     * outdated if it is older than src. If tgt does not exist, it is
154 :     * always considered outdated. *)
155 :     val outdated' : string ->
156 :     { src: string, wtn: string, tgt: string } -> bool
157 :    
158 :     (* open output file; make all necessary directories for it *)
159 :     val openTextOut : string -> TextIO.outstream
160 :    
161 :     (* make all directories leading up to a given file; the file itself
162 :     * is to be left alone *)
163 :     val makeDirs : string -> unit
164 :    
165 :     (* install a classifier *)
166 :     val registerClassifier : classifier -> unit
167 :    
168 :     (* grab all named options... *)
169 :     val parseOptions :
170 :     { tool : string, keywords : string list, options : toolopts } ->
171 :     { matches : string -> toolopts option, restoptions : string list }
172 :     end

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