File: events.ml

package info (click to toggle)
ocaml 5.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,419; asm: 5,462; makefile: 3,684; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (52 lines) | stat: -rw-r--r-- 1,994 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*           Jerome Vouillon, projet Cristal, INRIA Rocquencourt          *)
(*           OCaml port by John Malecki and Xavier Leroy                  *)
(*                                                                        *)
(*   Copyright 1996 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

(********************************* Events ******************************)

open Instruct

type code_event =
  { ev_frag : int;
    ev_ev : Instruct.debug_event }

let get_pos ev =
  match ev.ev_kind with
  | Event_before -> ev.ev_loc.Location.loc_start
  | Event_after _ -> ev.ev_loc.Location.loc_end
  | _ -> ev.ev_loc.Location.loc_start


(*** Current events. ***)

(* Event at current position *)
let current_event =
  ref (None : code_event option)

(* Current position in source. *)
(* Raise `Not_found' if not on an event (beginning or end of program). *)
let get_current_event () =
  match !current_event with
  | None -> raise Not_found
  | Some ev -> ev

let current_event_is_before () =
  match !current_event with
    None ->
      raise Not_found
  | Some {ev_ev = {ev_kind = Event_before}} ->
      true
  | _ ->
      false