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/system/smlnj/init/init.cmi
ViewVC logotype

Annotation of /sml/trunk/src/system/smlnj/init/init.cmi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 592 - (view) (download)

1 : blume 573 #
2 :     # spec.cmi
3 :     #
4 : blume 592 # (C) 2000 Lucent Technologies, Bell Laboratories
5 : blume 573 #
6 :     # Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7 :     #
8 :     # This is the specification for how to build the "init group".
9 : blume 592 # The main purpose of the init group is to tie in the runtime system
10 :     # and to build the pervasive environment. The pervasive enviroment
11 :     # must contain a binding of the "special" structure named "_Core".
12 : blume 573 # Because of its special nature, the init group cannot be described as
13 :     # an ordinary CM library. Instead, it is built from the DAG description
14 :     # in this file. The bootstrap compiler turns the init group into an
15 : blume 592 # ordinary stable group. The boot process fetches the pervasive
16 : blume 573 # environment from that stable library.
17 :     #
18 : blume 592 # In addition to the pervasive environments, the init group can (and does)
19 : blume 573 # also export additional definitions. These can be accessed by client code
20 :     # (such as the implementation of the Basis library) by simply listing
21 :     # "init.cmi : cm" in their respective library description files. (Since CM
22 :     # does not automatically recognize the member class of ".cmi" files, the
23 :     # class "cm" must be given explicitly.) Clients who want to access "init.cmi"
24 :     # must be in possession of the privilege named "primitive".
25 :     #
26 :     # The specification is basically a DAG: "bind" statements define
27 :     # named environments which are the results of compiling the files on the
28 :     # right-hand side of "=" wrt. a combination of the environments given
29 :     # in parentheses.
30 :     #
31 :     # Format of this file:
32 :     # - The file is processed on a line-by-line basis.
33 :     # - Empty lines and lines beginning with "#" are ignored.
34 :     # - Actual whitespace, "=", ",", "(", and ")" are all counted as whitespace.
35 :     # (this means that the syntactic sugar you see below is really just
36 :     # sugar for the human eye; the program that processes this file can
37 :     # do without it)
38 :     # - A line that says "nosplit" disables cross-module inlining (aka
39 :     # "lambda-splitting") until the next line that says "split".
40 :     # - The (single) "rts-placeholder" line acts mostly like a "bind" line.
41 :     # Its purpose is to specify the module that plays the role of a
42 :     # placeholder for the runtime system.
43 : blume 592 # - A "bind-core" line acts like a "bind" line, but it has an additional
44 :     # first argument which must be the name of a structure bound at top-level
45 :     # by the named .sml file. CM replaces these bindings by corresponding
46 :     # bindings of the internal structure symbol "_Core".
47 :     # - "bind" lines (as well as "bind-core" lines and the "rts-placeholder"
48 :     # line) must be in topological order (i.e., they cannot access environment
49 :     # names that are being defined later).
50 : blume 573 # - The last line that gets processed is the "return" line.
51 : blume 592 # It must specify at least one environment name, namely the one that is
52 :     # used as the system-wide "pervasive" environment.
53 : blume 573 # For any additional name n the exports of the module that was bound
54 :     # (by "bind") to n are added to the exports of the init group.
55 :     # These exports can be accessed by clients that explicitly list init.cmi
56 :     # in their own description files.
57 :     # Note: Since some clients need direct access to the core environment,
58 : blume 592 # the name "core" is also listed. This "core" (as opposed to "xcore"
59 :     # has a binding for structure "Core" which can be accessed directly
60 :     # from SML source code.)
61 : blume 573 # - There is one pre-defined name ("primitive") that refers to the
62 :     # Environment.primEnv. It must not be "exported" by the "return" line.
63 :     #
64 : blume 592 # Note that a binding for structure _Core is necessary ALMOST EVERYWHERE.
65 :     # Therefore, it is necessary that the pervasive environment has such a
66 :     # binding. For files of this initial group (which do not yet have the
67 :     # benefit of being able to access the pervasive environment), a trivial
68 :     # member "xcore" is used to supply _Core.
69 : blume 573
70 :     #### END OF EXPLANATION, SPEC STARTS HERE...
71 :    
72 :     # Turn off splitting. It would confuse the compiler because the following
73 :     # files are not actually loaded at boot time.
74 :     nosplit
75 :    
76 : blume 592 # The "signature" of the runtime system. (No _Core yet.)
77 : blume 573 bind asig = assembly.sig (primitive)
78 :    
79 : blume 592 # The placeholder for the runtime system. (No _Core yet.)
80 : blume 573 rts-placeholder rts = dummy.sml (asig, primitive)
81 :    
82 :     # We can now turn the cross-module optimizer on (when available)...
83 :     split
84 :    
85 :     # This defines the core environment to be used everywhere else...
86 : blume 592 # (This binds the structure symbol "Core", which is not yet the one that
87 :     # is used implicitly by the compiler. Of course, "core.sml" itself cannot
88 :     # yet have access to _Core.)
89 : blume 573 bind core = core.sml (rts, asig, primitive)
90 :    
91 : blume 592 # Now we make the binding for structure _Core for use by the remaining
92 :     # members of the init group. (Everybody else in the world gets access to
93 :     # _Core via the pervasive env.)
94 :     # The "bind-core" line says that its first argument ("xCore") should be
95 :     # re-written as "_Core" before compilation. This rewriting is done
96 :     # internally after the parser has already completed. Normally, there is
97 :     # no way of referring explicitly to a structure named _Core.
98 :     bind-core (xCore) xcore = xcore.sml (core)
99 :    
100 : blume 573 # The rest of the DAG...
101 : blume 592 # (Everybody implicitly depends on xcore to have access to _Core.)
102 :     bind built-in = built-in.sml (core, primitive, xcore)
103 :     bind pp = pre-perv.sml (built-in, xcore)
104 :     bind ps = pre-string.sml (core, built-in, pp, xcore)
105 :     bind ss-sig = substring.sig (pp, built-in, xcore)
106 :     bind ss = substring.sml (ss-sig, pp, ps, core, built-in, xcore)
107 :     bind print-hook = print-hook.sml (built-in, xcore)
108 :     bind use-hook = use-hook.sml (built-in, xcore)
109 :     bind exn-info-hook = exn-info-hook.sml (built-in, xcore)
110 :     bind init-utils = init-utils.sml (ps ss-sig ss, xcore)
111 : blume 573
112 :     # Building the "pervasive" environment. This file should be
113 :     # kept as small as possible and only bind non-modular things
114 :     # (i.e., top-level types and values).
115 : blume 592 # Make sure everybody else in the world gets access to structure _Core...
116 :     bind-core (xCore) pervasive = pervasive.sml (core, ps, ss, pp, print-hook, use-hook, exn-info-hook, built-in, xcore)
117 : blume 573
118 :     # Report the results to the world...
119 : blume 592 return (pervasive) built-in print-hook use-hook exn-info-hook core init-utils

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