Mercurial > urweb
comparison src/compiler.sml @ 183:c0ea24dcb86f
Optimizing 'case' in Mono_reduce
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 03 Aug 2008 13:30:27 -0400 |
parents | 80192edca30d |
children | 88d46972de53 |
comparison
equal
deleted
inserted
replaced
182:d11754ffe252 | 183:c0ea24dcb86f |
---|---|
420 (Print.print (CjrPrint.p_file CjrEnv.empty file); | 420 (Print.print (CjrPrint.p_file CjrEnv.empty file); |
421 print "\n")) | 421 print "\n")) |
422 handle CjrEnv.UnboundNamed n => | 422 handle CjrEnv.UnboundNamed n => |
423 print ("Unbound named " ^ Int.toString n ^ "\n") | 423 print ("Unbound named " ^ Int.toString n ^ "\n") |
424 | 424 |
425 fun compileC {cname, oname, ename} = | |
426 let | |
427 val compile = "gcc -O3 -I include -c " ^ cname ^ " -o " ^ oname | |
428 val link = "gcc -pthread -O3 clib/lacweb.o " ^ oname ^ " clib/driver.o -o " ^ ename | |
429 in | |
430 if not (OS.Process.isSuccess (OS.Process.system compile)) then | |
431 print "C compilation failed\n" | |
432 else if not (OS.Process.isSuccess (OS.Process.system link)) then | |
433 print "C linking failed\n" | |
434 else | |
435 print "Success\n" | |
436 end | |
437 | |
425 fun compile job = | 438 fun compile job = |
426 case cjrize job of | 439 case cjrize job of |
427 NONE => print "Laconic compilation failed\n" | 440 NONE => print "Laconic compilation failed\n" |
428 | SOME file => | 441 | SOME file => |
429 let | 442 let |
430 val cname = "/tmp/lacweb.c" | 443 val cname = "/tmp/lacweb.c" |
431 val oname = "/tmp/lacweb.o" | 444 val oname = "/tmp/lacweb.o" |
432 val ename = "/tmp/webapp" | 445 val ename = "/tmp/webapp" |
433 | |
434 val compile = "gcc -O3 -I include -c " ^ cname ^ " -o " ^ oname | |
435 val link = "gcc -pthread -O3 clib/lacweb.o " ^ oname ^ " clib/driver.o -o " ^ ename | |
436 | 446 |
437 val outf = TextIO.openOut cname | 447 val outf = TextIO.openOut cname |
438 val s = TextIOPP.openOut {dst = outf, wid = 80} | 448 val s = TextIOPP.openOut {dst = outf, wid = 80} |
439 in | 449 in |
440 Print.fprint s (CjrPrint.p_file CjrEnv.empty file); | 450 Print.fprint s (CjrPrint.p_file CjrEnv.empty file); |
441 TextIO.closeOut outf; | 451 TextIO.closeOut outf; |
442 | 452 |
443 if not (OS.Process.isSuccess (OS.Process.system compile)) then | 453 compileC {cname = cname, oname = oname, ename = ename} |
444 print "C compilation failed\n" | |
445 else if not (OS.Process.isSuccess (OS.Process.system link)) then | |
446 print "C linking failed\n" | |
447 else | |
448 print "Success\n" | |
449 end | 454 end |
450 | 455 |
451 end | 456 end |