Mercurial > urweb
comparison src/main.mlton.sml @ 2209:0ca11d57c175
Cleans up interface (it's now a command line option) and renames project to "sqlcache" in the all-one-word style. Still has issues to do with concurrency, retrying transactions, and foreign function calls that either rely on state or have side effects.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Sat, 31 May 2014 03:08:16 -0400 |
parents | 057b08253a75 |
children | 639e62ca2530 |
comparison
equal
deleted
inserted
replaced
2208:cb74460f046a | 2209:0ca11d57c175 |
---|---|
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 |
45 Elaborate.dumpTypes := false; | 45 Elaborate.dumpTypes := false; |
46 Elaborate.dumpTypesOnError := false; | 46 Elaborate.dumpTypesOnError := false; |
47 Elaborate.unifyMore := false; | 47 Elaborate.unifyMore := false; |
48 Compiler.dumpSource := false; | 48 Compiler.dumpSource := false; |
49 Compiler.doIflow := false; | 49 Compiler.doIflow := false; |
50 Compiler.doSqlcache := false; | |
50 Demo.noEmacs := false; | 51 Demo.noEmacs := false; |
51 Settings.setDebug false) | 52 Settings.setDebug false) |
52 | 53 |
53 val () = Compiler.beforeC := MLton.GC.pack | 54 val () = Compiler.beforeC := MLton.GC.pack |
54 | 55 |
62 raise Code OS.Process.success) | 63 raise Code OS.Process.success) |
63 | 64 |
64 fun doArgs args = | 65 fun doArgs args = |
65 case args of | 66 case args of |
66 [] => () | 67 [] => () |
67 | "-version" :: rest => | 68 | "-version" :: rest => |
68 printVersion () | 69 printVersion () |
69 | "-numeric-version" :: rest => | 70 | "-numeric-version" :: rest => |
70 printNumericVersion () | 71 printNumericVersion () |
71 | "-css" :: rest => | 72 | "-css" :: rest => |
72 (css := true; | 73 (css := true; |
156 | "-sigfile" :: name :: rest => | 157 | "-sigfile" :: name :: rest => |
157 (Settings.setSigFile (SOME name); | 158 (Settings.setSigFile (SOME name); |
158 doArgs rest) | 159 doArgs rest) |
159 | "-iflow" :: rest => | 160 | "-iflow" :: rest => |
160 (Compiler.doIflow := true; | 161 (Compiler.doIflow := true; |
162 doArgs rest) | |
163 | "-sqlcache" :: rest => | |
164 (Compiler.doSqlcache := true; | |
161 doArgs rest) | 165 doArgs rest) |
162 | "-moduleOf" :: fname :: _ => | 166 | "-moduleOf" :: fname :: _ => |
163 (print (Compiler.moduleOf fname ^ "\n"); | 167 (print (Compiler.moduleOf fname ^ "\n"); |
164 raise Code OS.Process.success) | 168 raise Code OS.Process.success) |
165 | "-noEmacs" :: rest => | 169 | "-noEmacs" :: rest => |
304 val oldStderr = Posix.IO.dup Posix.FileSys.stderr | 308 val oldStderr = Posix.IO.dup Posix.FileSys.stderr |
305 in | 309 in |
306 (* Redirect the daemon's output to the socket. *) | 310 (* Redirect the daemon's output to the socket. *) |
307 redirect Posix.FileSys.stdout; | 311 redirect Posix.FileSys.stdout; |
308 redirect Posix.FileSys.stderr; | 312 redirect Posix.FileSys.stderr; |
309 | 313 |
310 loop' ("", []); | 314 loop' ("", []); |
311 Socket.close sock; | 315 Socket.close sock; |
312 | 316 |
313 Posix.IO.dup2 {old = oldStdout, new = Posix.FileSys.stdout}; | 317 Posix.IO.dup2 {old = oldStdout, new = Posix.FileSys.stdout}; |
314 Posix.IO.dup2 {old = oldStderr, new = Posix.FileSys.stderr}; | 318 Posix.IO.dup2 {old = oldStderr, new = Posix.FileSys.stderr}; |
323 Socket.bind (listen, UnixSock.toAddr socket); | 327 Socket.bind (listen, UnixSock.toAddr socket); |
324 Socket.listen (listen, 1); | 328 Socket.listen (listen, 1); |
325 loop () | 329 loop () |
326 end) | 330 end) |
327 | ["daemon", "stop"] => | 331 | ["daemon", "stop"] => |
328 (OS.FileSys.remove socket handle OS.SysErr _ => OS.Process.exit OS.Process.success) | 332 (OS.FileSys.remove socket handle OS.SysErr _ => OS.Process.exit OS.Process.success) |
329 | args => | 333 | args => |
330 let | 334 let |
331 val sock = UnixSock.Strm.socket () | 335 val sock = UnixSock.Strm.socket () |
332 | 336 |
333 fun wait () = | 337 fun wait () = |