comparison src/name_js.sml @ 2251:25874084bf1f

Make Mono.file a record for readability upon extension.
author Ziv Scully <ziv@mit.edu>
date Sun, 13 Sep 2015 17:02:17 -0400
parents 8958b580d026
children e843a04499d4
comparison
equal deleted inserted replaced
2250:c275bbc41194 2251:25874084bf1f
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
90 case #1 d of 90 case #1 d of
91 DVal (_, n, _, _, _) => IS.add (dontName, n) 91 DVal (_, n, _, _, _) => IS.add (dontName, n)
92 | DValRec vis => foldl (fn ((_, n, _, _, _), dontName) => IS.add (dontName, n)) dontName vis 92 | DValRec vis => foldl (fn ((_, n, _, _, _), dontName) => IS.add (dontName, n)) dontName vis
93 | _ => dontName 93 | _ => dontName
94 else 94 else
95 dontName) IS.empty (#1 file) 95 dontName) IS.empty (#decls file)
96 96
97 val (ds, _) = ListUtil.foldlMapConcat (fn (d, nextName) => 97 val (ds, _) = ListUtil.foldlMapConcat (fn (d, nextName) =>
98 let 98 let
99 val (d, (nextName, newDs)) = 99 val (d, (nextName, newDs)) =
100 U.Decl.foldMapB {typ = fn x => x, 100 U.Decl.foldMapB {typ = fn x => x,
124 let 124 let
125 val loc = #2 e' 125 val loc = #2 e'
126 126
127 val vs = freeVars e' 127 val vs = freeVars e'
128 val vs = IS.listItems vs 128 val vs = IS.listItems vs
129 129
130 val x = "script" ^ Int.toString nextName 130 val x = "script" ^ Int.toString nextName
131 131
132 val un = (TRecord [], loc) 132 val un = (TRecord [], loc)
133 val s = (TFfi ("Basis", "string"), loc) 133 val s = (TFfi ("Basis", "string"), loc)
134 val base = (TFun (un, s), loc) 134 val base = (TFun (un, s), loc)
135 val t = foldl (fn (n, t) => (TFun (#2 (List.nth (env, n)), t), loc)) base vs 135 val t = foldl (fn (n, t) => (TFun (#2 (List.nth (env, n)), t), loc)) base vs
136 val e' = squish vs e' 136 val e' = squish vs e'
163 [] => [d] 163 [] => [d]
164 | _ => case #1 d of 164 | _ => case #1 d of
165 DValRec vis => [(DValRec (vis @ newDs), #2 d)] 165 DValRec vis => [(DValRec (vis @ newDs), #2 d)]
166 | _ => List.revAppend (map (fn vi => (DVal vi, #2 d)) newDs, [d]), 166 | _ => List.revAppend (map (fn vi => (DVal vi, #2 d)) newDs, [d]),
167 nextName) 167 nextName)
168 end) (U.File.maxName file + 1) (#1 file) 168 end) (U.File.maxName file + 1) (#decls file)
169 in 169 in
170 (ds, #2 file) 170 {decls = ds, sideInfo = #sideInfo file}
171 end 171 end
172 172
173 end 173 end