|
|
1.1 ! root 1: (* Copyright 1989 by AT&T Bell Laboratories *) ! 2: (* basecoder.sml ! 3: * ! 4: * J.H. Reppy ! 5: * Cornell University ! 6: * Ithaca, NY 14850 ! 7: * [email protected] ! 8: * ! 9: * HISTORY: ! 10: * 11/20/89 created ! 11: *) ! 12: ! 13: signature BASECODER = ! 14: sig ! 15: datatype label = Label of {id : int, addr : int ref} ! 16: ! 17: val newLabel : unit -> label ! 18: val addrOf : label -> int ! 19: val nameOf : label -> string ! 20: ! 21: end (* signature BASECODER *) ! 22: ! 23: ! 24: structure BaseCoder : BASECODER = ! 25: struct ! 26: ! 27: datatype label = Label of {id : int, addr : int ref} ! 28: ! 29: local ! 30: val cnt = ref 0 ! 31: in ! 32: fun nextId () = (!cnt before ((inc cnt) handle Overflow => cnt := 0)) ! 33: end ! 34: ! 35: fun newLabel () = Label{id= nextId(), addr= ref 0} ! 36: ! 37: fun addrOf (Label{addr, ...}) = !addr ! 38: fun nameOf (Label{id, ...}) = "L" ^ (makestring id) ! 39: ! 40: end (* structure BaseCoder *)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.