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
|
1999-11-08 09:06:33 -08:00
|
|
|
open Formatmsg
|
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
|
|
|
|
|
1997-02-19 08:09:23 -08:00
|
|
|
let check_depth depth obj ty =
|
|
|
|
if depth <= 0 then begin
|
|
|
|
let n = name_value obj ty in
|
|
|
|
print_char '$'; print_int n;
|
|
|
|
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
|
|
|
|
1997-03-22 12:16:52 -08:00
|
|
|
let install_printer path ty fn =
|
|
|
|
Printer.install_printer path ty
|
|
|
|
(function remote_val ->
|
|
|
|
try
|
|
|
|
fn (Obj.repr (Debugcom.Remote_value.obj remote_val))
|
|
|
|
with
|
|
|
|
Debugcom.Marshalling_error ->
|
|
|
|
print_string "<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
|
|
|
|
|
1997-03-22 12:16:52 -08:00
|
|
|
let print_value max_depth obj ty env =
|
|
|
|
Printer.print_value !max_printer_steps max_depth
|
|
|
|
check_depth env obj ty
|
1997-01-05 06:04:06 -08:00
|
|
|
|
1997-02-25 06:40:10 -08:00
|
|
|
let print_named_value max_depth exp obj ty env =
|
1997-02-26 07:07:57 -08:00
|
|
|
open_box 2;
|
1997-02-25 06:40:10 -08:00
|
|
|
begin match exp with
|
|
|
|
E_ident lid ->
|
|
|
|
Printtyp.longident lid
|
|
|
|
| E_name n ->
|
|
|
|
print_char '$'; print_int n
|
|
|
|
| _ ->
|
|
|
|
let n = name_value obj ty in
|
|
|
|
print_char '$'; print_int n
|
|
|
|
end;
|
1997-03-13 14:25:22 -08:00
|
|
|
Printtyp.reset (); Printtyp.mark_loops ty;
|
1997-01-05 06:04:06 -08:00
|
|
|
print_string " :"; print_space(); Printtyp.type_expr ty;
|
|
|
|
print_space(); print_string "="; print_space();
|
|
|
|
print_value max_depth obj ty env;
|
|
|
|
close_box();
|
|
|
|
print_newline()
|