1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Pretty-print lists of instructions *)
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
open Format
|
1995-05-04 03:15:53 -07:00
|
|
|
open Lambda
|
|
|
|
open Instruct
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let instruction ppf = function
|
|
|
|
| Klabel lbl -> fprintf ppf "L%i:" lbl
|
|
|
|
| Kacc n -> fprintf ppf "\tacc %i" n
|
|
|
|
| Kenvacc n -> fprintf ppf "\tenvacc %i" n
|
|
|
|
| Kpush -> fprintf ppf "\tpush"
|
|
|
|
| Kpop n -> fprintf ppf "\tpop %i" n
|
|
|
|
| Kassign n -> fprintf ppf "\tassign %i" n
|
|
|
|
| Kpush_retaddr lbl -> fprintf ppf "\tpush_retaddr L%i" lbl
|
|
|
|
| Kapply n -> fprintf ppf "\tapply %i" n
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kappterm(n, m) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "\tappterm %i, %i" n m
|
|
|
|
| Kreturn n -> fprintf ppf "\treturn %i" n
|
|
|
|
| Krestart -> fprintf ppf "\trestart"
|
|
|
|
| Kgrab n -> fprintf ppf "\tgrab %i" n
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kclosure(lbl, n) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "\tclosure L%i, %i" lbl n
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kclosurerec(lbls, n) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "\tclosurerec";
|
|
|
|
List.iter (fun lbl -> fprintf ppf " %i" lbl) lbls;
|
|
|
|
fprintf ppf ", %i" n
|
|
|
|
| Koffsetclosure n -> fprintf ppf "\toffsetclosure %i" n
|
2000-03-13 08:49:01 -08:00
|
|
|
| Kgetglobal id -> fprintf ppf "\tgetglobal %a" Ident.print id
|
|
|
|
| Ksetglobal id -> fprintf ppf "\tsetglobal %a" Ident.print id
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kconst cst ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "@[<10>\tconst@ %a@]" Printlambda.structured_constant cst
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kmakeblock(n, m) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "\tmakeblock %i, %i" n m
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kmakefloatblock(n) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "\tmakefloatblock %i" n
|
|
|
|
| Kgetfield n -> fprintf ppf "\tgetfield %i" n
|
|
|
|
| Ksetfield n -> fprintf ppf "\tsetfield %i" n
|
|
|
|
| Kgetfloatfield n -> fprintf ppf "\tgetfloatfield %i" n
|
|
|
|
| Ksetfloatfield n -> fprintf ppf "\tsetfloatfield %i" n
|
|
|
|
| Kvectlength -> fprintf ppf "\tvectlength"
|
|
|
|
| Kgetvectitem -> fprintf ppf "\tgetvectitem"
|
|
|
|
| Ksetvectitem -> fprintf ppf "\tsetvectitem"
|
|
|
|
| Kgetstringchar -> fprintf ppf "\tgetstringchar"
|
|
|
|
| Ksetstringchar -> fprintf ppf "\tsetstringchar"
|
|
|
|
| Kbranch lbl -> fprintf ppf "\tbranch L%i" lbl
|
|
|
|
| Kbranchif lbl -> fprintf ppf "\tbranchif L%i" lbl
|
|
|
|
| Kbranchifnot lbl -> fprintf ppf "\tbranchifnot L%i" lbl
|
|
|
|
| Kstrictbranchif lbl -> fprintf ppf "\tstrictbranchif L%i" lbl
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kstrictbranchifnot lbl ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "\tstrictbranchifnot L%i" lbl
|
1995-06-18 07:44:56 -07:00
|
|
|
| Kswitch(consts, blocks) ->
|
2000-02-08 12:00:06 -08:00
|
|
|
let labels ppf labs =
|
2000-03-06 14:12:09 -08:00
|
|
|
Array.iter (fun lbl -> fprintf ppf "@ %i" lbl) labs in
|
|
|
|
fprintf ppf "@[<10>\tswitch%a/%a@]" labels consts labels blocks
|
|
|
|
| Kboolnot -> fprintf ppf "\tboolnot"
|
|
|
|
| Kpushtrap lbl -> fprintf ppf "\tpushtrap L%i" lbl
|
|
|
|
| Kpoptrap -> fprintf ppf "\tpoptrap"
|
|
|
|
| Kraise -> fprintf ppf "\traise"
|
2001-02-19 04:28:04 -08:00
|
|
|
| Kreraise -> fprintf ppf "\treraise"
|
2000-03-06 14:12:09 -08:00
|
|
|
| Kcheck_signals -> fprintf ppf "\tcheck_signals"
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kccall(s, n) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "\tccall %s, %i" s n
|
|
|
|
| Knegint -> fprintf ppf "\tnegint"
|
|
|
|
| Kaddint -> fprintf ppf "\taddint"
|
|
|
|
| Ksubint -> fprintf ppf "\tsubint"
|
|
|
|
| Kmulint -> fprintf ppf "\tmulint"
|
|
|
|
| Kdivint -> fprintf ppf "\tdivint"
|
|
|
|
| Kmodint -> fprintf ppf "\tmodint"
|
|
|
|
| Kandint -> fprintf ppf "\tandint"
|
|
|
|
| Korint -> fprintf ppf "\torint"
|
|
|
|
| Kxorint -> fprintf ppf "\txorint"
|
|
|
|
| Klslint -> fprintf ppf "\tlslint"
|
|
|
|
| Klsrint -> fprintf ppf "\tlsrint"
|
|
|
|
| Kasrint -> fprintf ppf "\tasrint"
|
|
|
|
| Kintcomp Ceq -> fprintf ppf "\teqint"
|
|
|
|
| Kintcomp Cneq -> fprintf ppf "\tneqint"
|
|
|
|
| Kintcomp Clt -> fprintf ppf "\tltint"
|
|
|
|
| Kintcomp Cgt -> fprintf ppf "\tgtint"
|
|
|
|
| Kintcomp Cle -> fprintf ppf "\tleint"
|
|
|
|
| Kintcomp Cge -> fprintf ppf "\tgeint"
|
|
|
|
| Koffsetint n -> fprintf ppf "\toffsetint %i" n
|
|
|
|
| Koffsetref n -> fprintf ppf "\toffsetref %i" n
|
|
|
|
| Kisint -> fprintf ppf "\tisint"
|
2000-10-02 07:18:05 -07:00
|
|
|
| Kisout -> fprintf ppf "\tisout"
|
2000-03-06 14:12:09 -08:00
|
|
|
| Kgetmethod -> fprintf ppf "\tgetmethod"
|
|
|
|
| Kstop -> fprintf ppf "\tstop"
|
|
|
|
| Kevent ev -> fprintf ppf "\tevent %i" ev.ev_char
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2000-02-08 12:00:06 -08:00
|
|
|
let rec instruction_list ppf = function
|
1995-05-04 03:15:53 -07:00
|
|
|
[] -> ()
|
|
|
|
| Klabel lbl :: il ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "L%i:%a" lbl instruction_list il
|
1995-05-04 03:15:53 -07:00
|
|
|
| instr :: il ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "%a@ %a" instruction instr instruction_list il
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let instrlist ppf il =
|
|
|
|
fprintf ppf "@[<v 0>%a@]" instruction_list il
|