comparison src/jscomp.sml @ 574:ac947e2f29ff

Trivial use of a source
author Adam Chlipala <adamc@hcoop.net>
date Sun, 21 Dec 2008 12:56:39 -0500
parents 57018f21cd5c
children 3d56940120b1
comparison
equal deleted inserted replaced
572:57018f21cd5c 574:ac947e2f29ff
32 structure EM = ErrorMsg 32 structure EM = ErrorMsg
33 structure E = MonoEnv 33 structure E = MonoEnv
34 structure U = MonoUtil 34 structure U = MonoUtil
35 35
36 val funcs = [(("Basis", "alert"), "alert"), 36 val funcs = [(("Basis", "alert"), "alert"),
37 (("Basis", "htmlifyString"), "escape")] 37 (("Basis", "htmlifyString"), "escape"),
38 (("Basis", "new_client_source"), "sc")]
38 39
39 structure FM = BinaryMapFn(struct 40 structure FM = BinaryMapFn(struct
40 type ord_key = string * string 41 type ord_key = string * string
41 fun compare ((m1, x1), (m2, x2)) = 42 fun compare ((m1, x1), (m2, x2)) =
42 Order.join (String.compare (m1, m2), 43 Order.join (String.compare (m1, m2),
83 | ENextval _ => 0 84 | ENextval _ => 0
84 | EUnurlify _ => 0 85 | EUnurlify _ => 0
85 | EJavaScript _ => 0 86 | EJavaScript _ => 0
86 | ESignalReturn e => varDepth e 87 | ESignalReturn e => varDepth e
87 | ESignalBind (e1, e2) => Int.max (varDepth e1, varDepth e2) 88 | ESignalBind (e1, e2) => Int.max (varDepth e1, varDepth e2)
89 | ESignalSource e => varDepth e
88 90
89 fun strcat loc es = 91 fun strcat loc es =
90 case es of 92 case es of
91 [] => (EPrim (Prim.String ""), loc) 93 [] => (EPrim (Prim.String ""), loc)
92 | [x] => x 94 | [x] => x
166 end 168 end
167 169
168 | EFfi k => 170 | EFfi k =>
169 let 171 let
170 val name = case ffi k of 172 val name = case ffi k of
171 NONE => (EM.errorAt loc "Unsupported FFI identifier in JavaScript"; 173 NONE => (EM.errorAt loc ("Unsupported FFI identifier " ^ #2 k ^ " in JavaScript");
172 "ERROR") 174 "ERROR")
173 | SOME s => s 175 | SOME s => s
174 in 176 in
175 (str name, st) 177 (str name, st)
176 end 178 end
177 | EFfiApp (m, x, args) => 179 | EFfiApp (m, x, args) =>
178 let 180 let
179 val name = case ffi (m, x) of 181 val name = case ffi (m, x) of
180 NONE => (EM.errorAt loc "Unsupported FFI function in JavaScript"; 182 NONE => (EM.errorAt loc ("Unsupported FFI function " ^ x ^ " in JavaScript");
181 "ERROR") 183 "ERROR")
182 | SOME s => s 184 | SOME s => s
183 in 185 in
184 case args of 186 case args of
185 [] => (str (name ^ "()"), st) 187 [] => (str (name ^ "()"), st)
364 str ",", 366 str ",",
365 e2, 367 e2,
366 str ")"], 368 str ")"],
367 st) 369 st)
368 end 370 end
371 | ESignalSource e =>
372 let
373 val (e, st) = jsE inner (e, st)
374 in
375 (strcat [str "ss(",
376 e,
377 str ")"],
378 st)
379 end
369 end 380 end
370 in 381 in
371 jsE 382 jsE
372 end 383 end
373 384