home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / compiler / Smlexc.sml < prev    next >
Encoding:
Text File  |  1997-08-18  |  2.0 KB  |  58 lines  |  [TEXT/R*ch]

  1. (* Predefined SML exceptions *)
  2.  
  3. local
  4.     open Obj Const;
  5. in
  6.  
  7. (* SML exceptions *)
  8.  
  9. val exnTag = obj_tag(repr (let exception DUMMY in DUMMY end));
  10. val exnTagName   = ({qual="General", id="(Exception)"}, 0);
  11. val bindTagName  = ({qual="General", id="Bind"}, 0);
  12. val matchTagName = ({qual="General", id="Match"}, 0);
  13.  
  14. val predefExceptions = [
  15.   ("Bind",     (({qual="general", id="Bind"},      2), 0)),
  16.   ("Chr",      (({qual="general", id="Chr"},       3), 0)),
  17.   ("Div",      (({qual="general", id="Div"},       4), 0)),
  18.   ("Domain",   (({qual="general", id="Domain"},    5), 0)),
  19.   ("Match",    (({qual="general", id="Match"},     6), 0)),
  20.   ("Ord",      (({qual="general", id="Ord"},       7), 0)),
  21.   ("Overflow", (({qual="general", id="Overflow"},  8), 0)),
  22.   ("Out_of_memory",
  23.             (({qual="exc",     id="Out_of_memory"}, 1), 0)),
  24.   ("Invalid_argument",
  25.             (({qual="exc",     id="Invalid_argument"}, 2), 1)),
  26.   ("Fail",  (({qual="exc",     id="Failure"},     3), 1)),
  27.   ("Subscript",
  28.             (({qual="exc",     id="Not_found"},   4), 0)),
  29.   ("Size",  (({qual="io",      id="End_of_file"}, 1), 0)),
  30.   ("SysErr",(({qual="sys",     id="Sys_error"},   1), 1)),
  31.   ("Interrupt",
  32.             (({qual="sys",    id="Break"},     2), 0)),
  33.   ("Graphic_failure",
  34.             (({qual="graphics", id="Graphic_failure"}, 1), 1))
  35. ];
  36.  
  37. local 
  38.     open Config Mixture Types
  39.  
  40.     fun decode_string (v : obj) = (magic_obj v : string);
  41. in
  42.     val type_of_syserror_exn = (* Must match actual type of OS.SysErr *)
  43.     type_pair type_string (type_option type_syserror);
  44.  
  45.     val type_of_io_exn =       (* Must match actual type of IO.Io     *)
  46.     type_rigid_record 
  47.     [(STRINGlab "cause",    type_exn), 
  48.      (STRINGlab "function", type_string),
  49.      (STRINGlab "name",     type_string)];
  50.  
  51.     fun exnArgType {qual="General", id="SysErr"} = SOME type_of_syserror_exn
  52.       | exnArgType {qual="OS",      id="SysErr"} = SOME type_of_syserror_exn
  53.       | exnArgType {qual="General", id="Io"}     = SOME type_of_io_exn
  54.       | exnArgType _                             = NONE
  55.  
  56. end
  57. end;
  58.