1996-11-29 08:55:09 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Objective Caml *)
|
|
|
|
(* *)
|
|
|
|
(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* Objective Caml port by John Malecki and Xavier Leroy *)
|
|
|
|
(* *)
|
|
|
|
(* 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. *)
|
1996-11-29 08:55:09 -08:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
(* To print values *)
|
|
|
|
|
|
|
|
open Misc
|
|
|
|
open Obj
|
2000-03-06 14:12:09 -08:00
|
|
|
open Format
|
1997-02-25 06:40:10 -08:00
|
|
|
open Parser_aux
|
1996-11-29 08:55:09 -08:00
|
|
|
open Path
|
|
|
|
open Types
|
|
|
|
|
1997-01-05 06:04:06 -08:00
|
|
|
(* To name printed and ellipsed values *)
|
|
|
|
|
|
|
|
let named_values =
|
1997-03-22 12:16:52 -08:00
|
|
|
(Hashtbl.create 29 : (int, Debugcom.Remote_value.t * type_expr) Hashtbl.t)
|
1997-01-05 06:04:06 -08:00
|
|
|
let next_name = ref 1
|
|
|
|
|
|
|
|
let reset_named_values () =
|
|
|
|
Hashtbl.clear named_values;
|
|
|
|
next_name := 1
|
|
|
|
|
|
|
|
let name_value v ty =
|
|
|
|
let name = !next_name in
|
|
|
|
incr next_name;
|
|
|
|
Hashtbl.add named_values name (v, ty);
|
|
|
|
name
|
|
|
|
|
|
|
|
let find_named_value name =
|
|
|
|
Hashtbl.find named_values name
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let check_depth ppf depth obj ty =
|
1997-02-19 08:09:23 -08:00
|
|
|
if depth <= 0 then begin
|
|
|
|
let n = name_value obj ty in
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "$%i" n;
|
1997-02-19 08:09:23 -08:00
|
|
|
false
|
|
|
|
end else true
|
|
|
|
|
1997-03-22 12:16:52 -08:00
|
|
|
module Printer = Genprintval.Make(Debugcom.Remote_value)
|
1996-11-29 08:55:09 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let install_printer path ty ppf fn =
|
1997-03-22 12:16:52 -08:00
|
|
|
Printer.install_printer path ty
|
|
|
|
(function remote_val ->
|
|
|
|
try
|
|
|
|
fn (Obj.repr (Debugcom.Remote_value.obj remote_val))
|
|
|
|
with
|
|
|
|
Debugcom.Marshalling_error ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "<cannot fetch remote object>")
|
1996-11-29 08:55:09 -08:00
|
|
|
|
1997-03-22 12:16:52 -08:00
|
|
|
let remove_printer = Printer.remove_printer
|
1996-11-29 08:55:09 -08:00
|
|
|
|
1997-03-22 12:16:52 -08:00
|
|
|
let max_printer_depth = ref 20
|
|
|
|
let max_printer_steps = ref 300
|
1997-01-05 06:04:06 -08:00
|
|
|
|
1997-03-23 07:23:31 -08:00
|
|
|
let print_exception = Printer.print_exception
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let print_value max_depth env obj (ppf : Format.formatter) ty =
|
1997-03-22 12:16:52 -08:00
|
|
|
Printer.print_value !max_printer_steps max_depth
|
2000-03-06 14:12:09 -08:00
|
|
|
(check_depth ppf) env obj ppf ty
|
1997-01-05 06:04:06 -08:00
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let print_named_value max_depth exp env obj ppf ty =
|
|
|
|
let print_value_name ppf = function
|
|
|
|
| E_ident lid ->
|
|
|
|
Printtyp.longident ppf lid
|
1997-02-25 06:40:10 -08:00
|
|
|
| E_name n ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "$%i" n
|
1997-02-25 06:40:10 -08:00
|
|
|
| _ ->
|
|
|
|
let n = name_value obj ty in
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "$%i" n in
|
|
|
|
Printtyp.reset_and_mark_loops ty;
|
|
|
|
fprintf ppf "@[<2>%a :@ %a@ =@ %a@]@."
|
|
|
|
print_value_name exp
|
|
|
|
Printtyp.type_expr ty
|
|
|
|
(print_value max_depth env obj) ty
|
|
|
|
|