File: c-debug.sml

package info (click to toggle)
mlton 20100608-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 34,980 kB
  • ctags: 69,089
  • sloc: ansic: 18,421; lisp: 2,879; makefile: 1,570; sh: 1,325; pascal: 256; asm: 97
file content (29 lines) | stat: -rw-r--r-- 828 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(* c-debug.sml
 * 2005 Matthew Fluet (mfluet@acm.org)
 *  Adapted for MLton.
 *)

(*
 * Encoding C's type system in SML.  This module provides the "public"
 * view of the implementation.
 *
 * DEBUG VERSION with CHECKED POINTER DEREFERENCING.
 * 
 *   (C) 2002, Lucent Technologies, Bell Laboratories
 *
 * author: Matthias Blume (blume@research.bell-labs.com)
 *)
structure C_Debug : C_DEBUG = struct
    (* first of all, we look mostly like structure C... *)
    open C

    (* ... but then, we also check for NULL pointers... *)
    exception NullPointer

    (* ... which means that we have to re-implement some things: *)
    structure Ptr = struct
        open Ptr
        val |*! = fn p => if isNull' p then raise NullPointer else |*! p
        val |*| = fn p => if isNull p then raise NullPointer else |*| p
    end
end