Mercurial > urweb
comparison src/compiler.sml @ 1732:4a03aa3251cb
Initial support for reusing elaboration results
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 29 Apr 2012 13:17:31 -0400 |
parents | 7b9775d4a8ce |
children | ab24a7cb2a64 |
comparison
equal
deleted
inserted
replaced
1731:27e731a65934 | 1732:4a03aa3251cb |
---|---|
915 last = ErrorMsg.dummyPos} | 915 last = ErrorMsg.dummyPos} |
916 | 916 |
917 val sgn = (Source.SgnConst (#func parseUrs urs), loc) | 917 val sgn = (Source.SgnConst (#func parseUrs urs), loc) |
918 in | 918 in |
919 checkErrors (); | 919 checkErrors (); |
920 (Source.DFfiStr (mname, sgn), loc) | 920 (Source.DFfiStr (mname, sgn, OS.FileSys.modTime urs), loc) |
921 end | 921 end |
922 | 922 |
923 val defed = ref SS.empty | 923 val defed = ref SS.empty |
924 val fulls = ref SS.empty | 924 val fulls = ref SS.empty |
925 | 925 |
942 val loc = {file = ur, | 942 val loc = {file = ur, |
943 first = ErrorMsg.dummyPos, | 943 first = ErrorMsg.dummyPos, |
944 last = ErrorMsg.dummyPos} | 944 last = ErrorMsg.dummyPos} |
945 | 945 |
946 val ds = #func parseUr ur | 946 val ds = #func parseUr ur |
947 val d = (Source.DStr (mname, sgnO, (Source.StrConst ds, loc)), loc) | 947 val d = (Source.DStr (mname, sgnO, SOME (OS.FileSys.modTime ur), (Source.StrConst ds, loc)), loc) |
948 | 948 |
949 val fname = OS.Path.mkCanonical fname | 949 val fname = OS.Path.mkCanonical fname |
950 val d = case List.find (fn (root, name) => | 950 val d = case List.find (fn (root, name) => |
951 String.isPrefix (root ^ "/") fname) mrs of | 951 String.isPrefix (root ^ "/") fname) mrs of |
952 NONE => d | 952 NONE => d |
1000 loc), | 1000 loc), |
1001 part), loc) | 1001 part), loc) |
1002 else | 1002 else |
1003 (Source.StrVar part, loc) | 1003 (Source.StrVar part, loc) |
1004 in | 1004 in |
1005 (Source.DStr (part, NONE, imp), | 1005 (Source.DStr (part, NONE, NONE, imp), |
1006 loc) :: ds | 1006 loc) :: ds |
1007 end | 1007 end |
1008 else | 1008 else |
1009 ds) [] (!fulls) | 1009 ds) [] (!fulls) |
1010 in | 1010 in |
1011 defed := SS.add (!defed, this); | 1011 defed := SS.add (!defed, this); |
1012 (Source.DStr (piece, NONE, | 1012 (Source.DStr (piece, NONE, NONE, |
1013 (Source.StrConst (if old then | 1013 (Source.StrConst (if old then |
1014 simOpen () | 1014 simOpen () |
1015 @ [makeD this pieces] | 1015 @ [makeD this pieces] |
1016 else | 1016 else |
1017 [makeD this pieces]), loc)), | 1017 [makeD this pieces]), loc)), |
1090 fun clibFile s = OS.Path.joinDirFile {dir = Config.libC, | 1090 fun clibFile s = OS.Path.joinDirFile {dir = Config.libC, |
1091 file = s} | 1091 file = s} |
1092 | 1092 |
1093 val elaborate = { | 1093 val elaborate = { |
1094 func = fn file => let | 1094 func = fn file => let |
1095 val basis = #func parseUrs (libFile "basis.urs") | 1095 val basisF = libFile "basis.urs" |
1096 val topSgn = #func parseUrs (libFile "top.urs") | 1096 val topF = libFile "top.urs" |
1097 val topStr = #func parseUr (libFile "top.ur") | 1097 val topF' = libFile "top.ur" |
1098 | |
1099 val basis = #func parseUrs basisF | |
1100 val topSgn = #func parseUrs topF | |
1101 val topStr = #func parseUr topF' | |
1102 | |
1103 val tm1 = OS.FileSys.modTime topF | |
1104 val tm2 = OS.FileSys.modTime topF' | |
1098 in | 1105 in |
1099 Elaborate.elabFile basis topStr topSgn ElabEnv.empty file | 1106 Elaborate.elabFile basis (OS.FileSys.modTime basisF) |
1107 topStr topSgn (if Time.< (tm1, tm2) then tm2 else tm1) | |
1108 ElabEnv.empty file | |
1100 end, | 1109 end, |
1101 print = ElabPrint.p_file ElabEnv.empty | 1110 print = ElabPrint.p_file ElabEnv.empty |
1102 } | 1111 } |
1103 | 1112 |
1104 val toElaborate = transform elaborate "elaborate" o toParse | 1113 val toElaborate = transform elaborate "elaborate" o toParse |