comparison src/compiler.sml @ 1089:f1647f16097d

Convenience libifying; allow more NULLs with globals
author Adam Chlipala <adamc@hcoop.net>
date Thu, 24 Dec 2009 15:49:52 -0500
parents 8e240c007442
children e77079953308
comparison
equal deleted inserted replaced
1088:5f72a66402f7 1089:f1647f16097d
268 structure M = BinaryMapFn(struct 268 structure M = BinaryMapFn(struct
269 type ord_key = string 269 type ord_key = string
270 val compare = String.compare 270 val compare = String.compare
271 end) 271 end)
272 272
273 val pathmap = ref (M.insert (M.empty, "", Config.libUr))
274
275 fun addPath (k, v) = pathmap := M.insert (!pathmap, k, v)
276
273 fun parseUrp' accLibs fname = 277 fun parseUrp' accLibs fname =
274 let 278 let
275 val pathmap = ref (M.insert (M.empty, "", Config.libUr)) 279 val pathmap = ref (!pathmap)
276 val bigLibs = ref [] 280 val bigLibs = ref []
277 281
278 fun pu filename = 282 fun pu filename =
279 let 283 let
280 val dir = OS.Path.dir filename 284 val dir = OS.Path.dir filename
301 val fname = pathify fname 305 val fname = pathify fname
302 in 306 in
303 OS.Path.concat (dir, fname) 307 OS.Path.concat (dir, fname)
304 handle OS.Path.Path => fname 308 handle OS.Path.Path => fname
305 end 309 end
310
311 fun libify path =
312 (if Posix.FileSys.access (path ^ ".urp", []) then
313 path
314 else
315 path ^ "/lib")
316 handle SysErr => path
317
318 fun libify' path =
319 (if Posix.FileSys.access (relify path ^ ".urp", []) then
320 path
321 else
322 path ^ "/lib")
323 handle SysErr => path
306 324
307 val absDir = OS.Path.mkAbsolute {path = dir, relativeTo = OS.FileSys.getDir ()} 325 val absDir = OS.Path.mkAbsolute {path = dir, relativeTo = OS.FileSys.getDir ()}
308 326
309 fun relifyA fname = 327 fun relifyA fname =
310 OS.Path.mkAbsolute {path = pathify fname, relativeTo = absDir} 328 OS.Path.mkAbsolute {path = pathify fname, relativeTo = absDir}
557 in 575 in
558 fkind := {action = Settings.Deny, kind = kind, pattern = pattern} :: !fkind 576 fkind := {action = Settings.Deny, kind = kind, pattern = pattern} :: !fkind
559 end 577 end
560 | _ => ErrorMsg.error "Bad 'deny' syntax") 578 | _ => ErrorMsg.error "Bad 'deny' syntax")
561 | "library" => if accLibs then 579 | "library" => if accLibs then
562 libs := pu (relify arg) :: !libs 580 libs := pu (libify (relify arg)) :: !libs
563 else 581 else
564 bigLibs := arg :: !bigLibs 582 bigLibs := libify' arg :: !bigLibs
565 | "path" => 583 | "path" =>
566 (case String.fields (fn ch => ch = #"=") arg of 584 (case String.fields (fn ch => ch = #"=") arg of
567 [n, v] => pathmap := M.insert (!pathmap, n, v) 585 [n, v] => pathmap := M.insert (!pathmap, n, v)
568 | _ => ErrorMsg.error "path argument not of the form name=value'") 586 | _ => ErrorMsg.error "path argument not of the form name=value'")
569 | _ => ErrorMsg.error ("Unrecognized command '" ^ cmd ^ "'"); 587 | _ => ErrorMsg.error ("Unrecognized command '" ^ cmd ^ "'");