|
|
1.1 ! root 1: (* Copyright 1989 by AT&T Bell Laboratories *) ! 2: signature STAMP = ! 3: sig ! 4: type state ! 5: val new : int * int -> state ! 6: val current : state -> int * int ! 7: val move : state * (int * int) -> unit ! 8: val set : state * int * int -> unit ! 9: val newTyc : state -> int ! 10: val newStr : state -> int ! 11: val newRecord : int -> int ! 12: val base : int ! 13: val fixed : int -> bool ! 14: val bound : int -> bool ! 15: val global : state ! 16: val newSig : unit -> int ! 17: end ! 18: ! 19: structure Stamp : STAMP = ! 20: struct ! 21: ! 22: type state = {tycCount : int ref, strCount : int ref} ! 23: ! 24: fun new(t: int, s: int) = {tycCount = ref t, strCount = ref s} ! 25: ! 26: fun current({tycCount,strCount}: state) = (!tycCount, !strCount) ! 27: ! 28: fun set({tycCount,strCount}: state, t: int, s: int) = ! 29: (tycCount := t; strCount := s) ! 30: ! 31: fun move({tycCount,strCount}: state, (t: int, s: int)) = ! 32: (tycCount := !tycCount + t; strCount := !strCount + s) ! 33: ! 34: fun newTyc({tycCount,...}: state) = ! 35: !tycCount before inc tycCount ! 36: ! 37: fun newStr({strCount,...}: state) = ! 38: !strCount before inc strCount ! 39: ! 40: ! 41: val base = 1000000 ! 42: ! 43: fun fixed s = s >= base ! 44: ! 45: fun bound s = s < base ! 46: ! 47: fun newRecord(n:int) = base + (n mod base) ! 48: (* this allows a slight possibility that two distinct record tycons may ! 49: be given the same stamp *) ! 50: ! 51: val global = new(2*base, 2*base) ! 52: ! 53: ! 54: (* signature stamp generator *) ! 55: ! 56: val sigCount = ref(1) ! 57: fun newSig () = !sigCount before inc sigCount ! 58: ! 59: end (* structure Stamp *)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.