home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / compiler / Tr_const.sml < prev    next >
Encoding:
Text File  |  1996-07-03  |  722 b   |  26 lines  |  [TEXT/R*ch]

  1. local
  2.   open Obj Const Symtable;
  3. in
  4.  
  5. (* To translate a structured constant into an object. *)
  6.  
  7. fun translStructuredConst (ATOMsc(INTscon i)) = repr i
  8.   | translStructuredConst (ATOMsc(CHARscon c)) = repr c
  9.   | translStructuredConst (ATOMsc(REALscon f)) = repr f
  10.   | translStructuredConst (ATOMsc(STRINGscon s)) = repr s
  11.   | translStructuredConst (BLOCKsc(tag, comps)) =
  12.       let val res = obj_block (intOfTag tag) (List.length comps) in
  13.         fillStructuredConst 0 res comps;
  14.         res
  15.       end
  16.   | translStructuredConst (QUOTEsc (ref v)) = v
  17.  
  18. and fillStructuredConst n obj = fn
  19.     [] => ()
  20.   | cst::rest =>
  21.       (set_obj_field obj n (translStructuredConst cst);
  22.        fillStructuredConst (n+1) obj rest)
  23. ;
  24.  
  25. end;
  26.