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 / Pr_zam.sml < prev    next >
Encoding:
Text File  |  1996-07-03  |  2.5 KB  |  96 lines  |  [TEXT/R*ch]

  1. local
  2.   open Obj Fnlib Config Mixture Const Instruct Asynt Pr_lam;
  3. in
  4.  
  5. val printZamInstr = fn
  6.     Kquote sc =>
  7.       printStrConst sc
  8.   | Kget_global (qualid, stamp) =>
  9.       (msgString "get_global "; printQualId qualid;
  10.        msgString "/"; msgInt stamp)
  11.   | Kset_global (qualid, stamp) =>
  12.       (msgString "set_global "; printQualId qualid;
  13.        msgString "/"; msgInt stamp)
  14.   | Kaccess i =>
  15.       (msgString "access "; msgInt i)
  16.   | Kgrab =>
  17.       msgString "grab"
  18.   | Kpush =>
  19.       msgString "push"
  20.   | Kpushmark =>
  21.       msgString "pushmark"
  22.   | Klet =>
  23.       msgString "let"
  24.   | Kendlet i =>
  25.       (msgString "endlet "; msgInt i)
  26.   | Kapply =>
  27.       msgString "apply"
  28.   | Ktermapply =>
  29.       msgString "termapply"
  30.   | Kcheck_signals =>
  31.       msgString "check_signals"
  32.   | Kreturn =>
  33.       msgString "return"
  34.   | Kclosure i =>
  35.       (msgString "closure "; msgInt i)
  36.   | Kletrec1 i =>
  37.       (msgString "letrec1 "; msgInt i)
  38.   | Kmakeblock(ct, i) =>
  39.       (msgString "makeblock "; printCTag ct; msgString " ";
  40.        msgInt i)
  41.   | Kprim prim =>
  42.       printPrim prim
  43.   | Kpushtrap i =>
  44.       (msgString "pushtrap "; msgInt i)
  45.   | Kpoptrap =>
  46.       msgString "poptrap"
  47.   | Klabel i =>
  48.       (msgString "label "; msgInt i)
  49.   | Kbranch i =>
  50.       (msgString "branch "; msgInt i)
  51.   | Kbranchif i =>
  52.       (msgString "branchif "; msgInt i)
  53.   | Kbranchifnot i =>
  54.       (msgString "branchifnot "; msgInt i)
  55.   | Kstrictbranchif i =>
  56.       (msgString "strictbranchif "; msgInt i)
  57.   | Kstrictbranchifnot i =>
  58.       (msgString "strictbranchifnot "; msgInt i)
  59.   | Ktest(tst, i) =>
  60.       (msgString "test:"; printBoolTest tst;
  61.        msgString " "; msgInt i)
  62.   | Kbranchinterval(i1, i2, i3, i4) =>
  63.       (msgString "branchinterval "; msgInt i1;
  64.        msgString " "; msgInt i2;
  65.        msgString " "; msgInt i3;
  66.        msgString " "; msgInt i4)
  67.   | Kswitch v =>
  68.       let val () = msgString "switch "
  69.           val len = Array.length v
  70.       in
  71.         for (fn i =>
  72.                (msgInt (Array.sub(v, i-1));
  73.                 if i < len then msgString " " else ()))
  74.             1 len
  75.       end
  76. ;
  77.  
  78. fun printZamSeq zams = printSeq printZamInstr "; " zams;
  79.  
  80. fun printZamPhrase
  81.         { kph_is_pure=is_pure, kph_inits=inits, kph_funcs=funcs } =
  82. (
  83.   msgIBlock 0;
  84.   msgString "***kph_is_pure*** = ";
  85.   msgString (if is_pure then "true;" else "false;");
  86.   msgEOL();
  87.   msgString "***kph_inits*** = ";
  88.   printSeq printZamInstr "; " inits;
  89.   msgEOL(); msgString "***kph_funcs*** = ";
  90.   printSeq printZamInstr "; " funcs;
  91.   msgEOL();
  92.   msgEBlock()
  93. );
  94.  
  95. end;
  96.