summaryrefslogtreecommitdiff
path: root/src/compiler.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2016-02-07 20:41:34 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2016-02-07 20:41:34 -0500
commit7b379c724999c4b415b1c3826db748450c7a6571 (patch)
tree08d7b9d994d351f9480e09f06170f3daf77e8549 /src/compiler.sml
parent5579b84a97cb942fdfd4c4898793f9de95bc03d1 (diff)
Finish removing PWild; only load a library once, even if referenced multiple times in a .urp tree
Diffstat (limited to 'src/compiler.sml')
-rw-r--r--src/compiler.sml36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index e269c8b9..7580c5e4 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -1,4 +1,4 @@
-(* Copyright (c) 2008-2012, 2014, Adam Chlipala
+(* Copyright (c) 2008-2012, 2014, 2016, Adam Chlipala
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -412,6 +412,14 @@ fun inputCommentableLine inf =
val lastUrp = ref ""
+structure SK = struct
+type ord_key = string
+val compare = String.compare
+end
+
+structure SS = BinarySetFn(SK)
+structure SM = BinaryMapFn(SK)
+
fun parseUrp' accLibs fname =
(lastUrp := fname;
if not (Posix.FileSys.access (fname ^ ".urp", []) orelse Posix.FileSys.access (fname ^ "/lib.urp", []))
@@ -459,6 +467,7 @@ fun parseUrp' accLibs fname =
let
val pathmap = ref (!pathmap)
val bigLibs = ref []
+ val libSet = ref SS.empty
fun pu filename =
let
@@ -822,10 +831,19 @@ fun parseUrp' accLibs fname =
fkind := {action = Settings.Deny, kind = kind, pattern = pattern} :: !fkind
end
| _ => ErrorMsg.error "Bad 'deny' syntax")
- | "library" => if accLibs then
- libs := pu (libify (relify arg)) :: !libs
- else
- bigLibs := libify' arg :: !bigLibs
+ | "library" =>
+ if accLibs then
+ let
+ val arg = libify (relify arg)
+ in
+ if SS.member (!libSet, arg) then
+ ()
+ else
+ (libs := pu arg :: !libs;
+ libSet := SS.add (!libSet, arg))
+ end
+ else
+ bigLibs := libify' arg :: !bigLibs
| "path" =>
(case String.fields (fn ch => ch = #"=") arg of
[n, v] => ((pathmap := M.insert (!pathmap, n, OS.Path.mkAbsolute {path = v, relativeTo = dir}))
@@ -936,14 +954,6 @@ fun addModuleRoot (k, v) = moduleRoots :=
relativeTo = OS.FileSys.getDir ()},
v) :: !moduleRoots
-structure SK = struct
-type ord_key = string
-val compare = String.compare
-end
-
-structure SS = BinarySetFn(SK)
-structure SM = BinaryMapFn(SK)
-
exception MissingFile of string
val parse = {