module Make (
T
:
TermInner.S
)
(
Arg
:
ARG
)
(
State
:
sig
end
)
: sig
.. end
type
term = T.t
type
ty = T.t
type
t
A stateful object used for traversing a problem, eventually
building a new list of statements
type
dispatch = {
}
val create : ?size:int ->
?max_depth:int ->
env:(term, ty) Env.t ->
state:State.t -> dispatch:dispatch -> unit -> t
create a new traversal object.
env
: the environment in which symbols are defined
dispatch
: how to deal with definitions of symbols.
Fields that are not specified are dealt with generically
val env : t -> (term, ty) Env.t
val state : t -> State.t
val has_processed : t -> ID.t -> Arg.t -> bool
Has mark_processed
already been called with those arguments?
val mark_processed : t -> ID.t -> Arg.t -> unit
To be used by callbacks in dispatch
to indicate that some additional
IDs have been processed (e.g. the conversion functions of copy types)
val processed : t -> (ID.t * Arg.t) Sequence.t
All processed pairs
val call_dep : t -> depth:int -> ID.t -> Arg.t -> unit
call_dep t id arg
is to be called during term traversal (typically,
in dispatch.do_term
) to indicate the will of traversing the
pair (id,arg)
exception CannotTraverse
val traverse_stmt : ?after_env:((term, ty) Env.t -> unit) ->
t ->
(term, ty) Statement.t -> unit
Traverse the given statement, adding its translation to the result,
updating the environment, etc.
Raises CannotTraverse
if get_statements
was called already
after_env
: called once the environment is updated, but
before the statment is actually traversed
val get_statements : t ->
(term, ty) Statement.t CCVector.vector
get_statements t
sorts topologically and merges the pieces of statements
previously added by push_rec
, push_pred
, etc. and
returns a valid list of statements.
Once get_statements
has been called, traverse_stmt
will
raise
val max_depth_reached : t -> bool