@ -31,16 +31,14 @@ type tindex = int
type transition = { source : vindex ; target : vindex ; label : ToplAst . label option }
type transition = { source : vindex ; target : vindex ; label : ToplAst . label option }
(* * - INV1: Array.length states = Array.length outgoing = Array.length nondets
(* * - INV1: Array.length transitions = Array.length skips
- INV2 : Array . length transitions = Array . length skips
- INV2 : each index of [ transitions ] occurs exactly once in one of [ outgoing ] ' s lists
- INV3 : each index of [ transitions ] occurs exactly once in one of [ outgoing ] ' s lists
- INV3 : max_args is the maximum length of the arguments list in a label on a transition
- INV4 : max_args is the maximum length of the arguments list in a label on a transition
The fields marked as redundant are computed from the others ( when the automaton is built ) , and
The fields marked as redundant are computed from the others ( when the automaton is built ) , and
are cached for speed . * )
are cached for speed . * )
type t =
type t =
{ states : vname array
{ states : vname array
; nondets : bool array (* redundant *)
; transitions : transition array
; transitions : transition array
; skips : bool array (* redundant *)
; skips : bool array (* redundant *)
; outgoing : tindex list array
; outgoing : tindex list array
@ -76,7 +74,7 @@ let make properties =
Array . of_list ( List . dedup_and_sort ~ compare : Vname . compare ( List . concat_map ~ f properties ) )
Array . of_list ( List . dedup_and_sort ~ compare : Vname . compare ( List . concat_map ~ f properties ) )
in
in
Array . iteri ~ f : ( fun i ( p , v ) -> tt " state[%d]=(%s,%s)@ \n " i p v ) states ;
Array . iteri ~ f : ( fun i ( p , v ) -> tt " state[%d]=(%s,%s)@ \n " i p v ) states ;
let vindex_opt , vindex = index_in ( module Vname . Table ) states in
let _ vindex_opt , vindex = index_in ( module Vname . Table ) states in
let vindex = vindex " vertex " in
let vindex = vindex " vertex " in
let transitions : transition array =
let transitions : transition array =
let f p =
let f p =
@ -118,30 +116,12 @@ let make properties =
| > Array . max_elt ~ compare : Int . compare
| > Array . max_elt ~ compare : Int . compare
| > Option . value ~ default : 0 | > succ
| > Option . value ~ default : 0 | > succ
in
in
let nondets : bool array =
let vcount = Array . length states in
let a = Array . create ~ len : vcount false in
let f ToplAst . { nondet ; name ; _ } =
let set_nondet state =
match vindex_opt ( name , state ) with
| Some i ->
a . ( i ) <- true
| None ->
L . user_warning
" TOPL: %s declared as nondet, but it appears in no transition of property %s " state
name
in
List . iter ~ f : set_nondet nondet
in
List . iter ~ f properties ;
a
in
let skips : bool array =
let skips : bool array =
(* TODO ( rgrigore ) : Rename "anys"? *)
(* TODO ( rgrigore ) : Rename "anys"? *)
let is_skip { label } = Option . is_none label in
let is_skip { label } = Option . is_none label in
Array . map ~ f : is_skip transitions
Array . map ~ f : is_skip transitions
in
in
{ states ; nondets; transitions; skips ; outgoing ; vindex ; max_args }
{ states ; transitions ; skips ; outgoing ; vindex ; max_args }
let vname a i = a . states . ( i )
let vname a i = a . states . ( i )