annotate src/pathcheck.sml @ 692:09df0c85f306

Fix overzealous Marshalcheck; garbage-collect string-embedded closures when no dyns are active
author Adam Chlipala <adamc@hcoop.net>
date Sat, 04 Apr 2009 12:54:39 -0400
parents 56aaa1941dad
children 70cbdcf5989b
rev   line source
adamc@377 1 (* Copyright (c) 2008, Adam Chlipala
adamc@377 2 * All rights reserved.
adamc@377 3 *
adamc@377 4 * Redistribution and use in source and binary forms, with or without
adamc@377 5 * modification, are permitted provided that the following conditions are met:
adamc@377 6 *
adamc@377 7 * - Redistributions of source code must retain the above copyright notice,
adamc@377 8 * this list of conditions and the following disclaimer.
adamc@377 9 * - Redistributions in binary form must reproduce the above copyright notice,
adamc@377 10 * this list of conditions and the following disclaimer in the documentation
adamc@377 11 * and/or other materials provided with the distribution.
adamc@377 12 * - The names of contributors may not be used to endorse or promote products
adamc@377 13 * derived from this software without specific prior written permission.
adamc@377 14 *
adamc@377 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
adamc@377 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
adamc@377 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
adamc@377 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
adamc@377 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
adamc@377 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
adamc@377 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
adamc@377 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
adamc@377 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
adamc@377 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
adamc@377 25 * POSSIBILITY OF SUCH DAMAGE.
adamc@377 26 *)
adamc@377 27
adamc@377 28 structure PathCheck :> PATH_CHECK = struct
adamc@377 29
adamc@377 30 open Mono
adamc@377 31
adamc@377 32 structure E = ErrorMsg
adamc@377 33
adamc@377 34 structure SS = BinarySetFn(struct
adamc@377 35 type ord_key = string
adamc@377 36 val compare = String.compare
adamc@377 37 end)
adamc@377 38
adamc@377 39 fun checkDecl ((d, loc), (funcs, rels)) =
adamc@377 40 let
adamc@377 41 fun doRel s =
adamc@377 42 (if SS.member (rels, s) then
adamc@377 43 E.errorAt loc ("Duplicate table/sequence path " ^ s)
adamc@377 44 else
adamc@377 45 ();
adamc@377 46 (funcs, SS.add (rels, s)))
adamc@377 47 in
adamc@377 48 case d of
adamc@609 49 DExport (_, s, _, _, _) =>
adamc@377 50 (if SS.member (funcs, s) then
adamc@377 51 E.errorAt loc ("Duplicate function path " ^ s)
adamc@377 52 else
adamc@377 53 ();
adamc@377 54 (SS.add (funcs, s), rels))
adamc@377 55
adamc@377 56 | DTable (s, _) => doRel s
adamc@377 57 | DSequence s => doRel s
adamc@377 58
adamc@377 59 | _ => (funcs, rels)
adamc@377 60 end
adamc@377 61
adamc@377 62 fun check ds = ignore (foldl checkDecl (SS.empty, SS.empty) ds)
adamc@377 63
adamc@377 64 end