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
|
|
|
open Lambda
|
|
|
|
|
1996-11-29 10:36:42 -08:00
|
|
|
type compilation_env =
|
|
|
|
{ ce_stack: int Ident.tbl;
|
1998-04-06 02:15:55 -07:00
|
|
|
ce_heap: int Ident.tbl;
|
|
|
|
ce_rec: int Ident.tbl }
|
1997-06-16 06:34:34 -07:00
|
|
|
|
1996-11-29 10:36:42 -08:00
|
|
|
type debug_event =
|
|
|
|
{ mutable ev_pos: int; (* Position in bytecode *)
|
1997-02-19 08:08:05 -08:00
|
|
|
ev_module: string; (* Name of defining module *)
|
1996-11-29 10:36:42 -08:00
|
|
|
ev_char: int; (* Location in source file *)
|
|
|
|
ev_kind: debug_event_kind; (* Before/after event *)
|
1997-06-16 06:34:34 -07:00
|
|
|
ev_info: debug_event_info; (* Extra information *)
|
1996-11-29 10:36:42 -08:00
|
|
|
ev_typenv: Env.summary; (* Typing environment *)
|
|
|
|
ev_compenv: compilation_env; (* Compilation environment *)
|
1997-03-27 12:53:30 -08:00
|
|
|
ev_stacksize: int; (* Size of stack frame *)
|
1997-06-16 06:34:34 -07:00
|
|
|
ev_repr: debug_event_repr } (* Position of the representative *)
|
1996-11-29 10:36:42 -08:00
|
|
|
|
|
|
|
and debug_event_kind =
|
|
|
|
Event_before
|
1997-06-16 06:34:34 -07:00
|
|
|
| Event_after of Types.type_expr
|
|
|
|
| Event_pseudo
|
|
|
|
|
|
|
|
and debug_event_info =
|
|
|
|
Event_function
|
1997-03-30 11:41:38 -08:00
|
|
|
| Event_return of int
|
1997-06-16 06:34:34 -07:00
|
|
|
| Event_other
|
1997-03-27 12:53:30 -08:00
|
|
|
|
|
|
|
and debug_event_repr =
|
|
|
|
Event_none
|
|
|
|
| Event_parent of int ref
|
|
|
|
| Event_child of int ref
|
1996-11-29 10:36:42 -08:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
type label = int (* Symbolic code labels *)
|
|
|
|
|
|
|
|
type instruction =
|
|
|
|
Klabel of label
|
|
|
|
| Kacc of int
|
|
|
|
| Kenvacc of int
|
|
|
|
| Kpush
|
|
|
|
| Kpop of int
|
|
|
|
| Kassign of int
|
|
|
|
| Kpush_retaddr of label
|
|
|
|
| Kapply of int (* number of arguments *)
|
|
|
|
| Kappterm of int * int (* number of arguments, slot size *)
|
|
|
|
| Kreturn of int (* slot size *)
|
|
|
|
| Krestart
|
|
|
|
| Kgrab of int (* number of arguments *)
|
|
|
|
| Kclosure of label * int
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kclosurerec of label list * int
|
|
|
|
| Koffsetclosure of int
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kgetglobal of Ident.t
|
|
|
|
| Ksetglobal of Ident.t
|
|
|
|
| Kconst of structured_constant
|
|
|
|
| Kmakeblock of int * int (* size, tag *)
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kmakefloatblock of int
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kgetfield of int
|
|
|
|
| Ksetfield of int
|
1998-04-06 02:15:55 -07:00
|
|
|
| Kgetfloatfield of int
|
|
|
|
| Ksetfloatfield of int
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kvectlength
|
|
|
|
| Kgetvectitem
|
|
|
|
| Ksetvectitem
|
|
|
|
| Kgetstringchar
|
|
|
|
| Ksetstringchar
|
|
|
|
| Kbranch of label
|
|
|
|
| Kbranchif of label
|
|
|
|
| Kbranchifnot of label
|
|
|
|
| Kstrictbranchif of label
|
|
|
|
| Kstrictbranchifnot of label
|
1995-06-18 07:44:56 -07:00
|
|
|
| Kswitch of label array * label array
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kboolnot
|
|
|
|
| Kpushtrap of label
|
|
|
|
| Kpoptrap
|
2001-11-26 04:47:03 -08:00
|
|
|
| Kraise
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kcheck_signals
|
|
|
|
| Kccall of string * int
|
|
|
|
| Knegint | Kaddint | Ksubint | Kmulint | Kdivint | Kmodint
|
|
|
|
| Kandint | Korint | Kxorint | Klslint | Klsrint | Kasrint
|
|
|
|
| Kintcomp of comparison
|
|
|
|
| Koffsetint of int
|
|
|
|
| Koffsetref of int
|
1999-12-06 08:59:24 -08:00
|
|
|
| Kisint
|
2000-10-02 07:18:05 -07:00
|
|
|
| Kisout
|
1996-04-22 04:15:41 -07:00
|
|
|
| Kgetmethod
|
1996-11-29 10:36:42 -08:00
|
|
|
| Kevent of debug_event
|
1995-05-04 03:15:53 -07:00
|
|
|
| Kstop
|
|
|
|
|
|
|
|
let immed_min = -0x40000000
|
|
|
|
and immed_max = 0x3FFFFFFF
|
|
|
|
|
|
|
|
(* Actually the abstract machine accomodates -0x80000000 to 0x7FFFFFFF,
|
|
|
|
but these numbers overflow the Caml type int if the compiler runs on
|
|
|
|
a 32-bit processor. *)
|