package bap-std

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Visitor. Visits AST providing lots of hooks.

For each AST constructor C the visitor provides three methods: enter_C, visit_C, leave_C. The default implementation for enter_C and leave_C is to return its argument. The default implementation for visit_C is the following: 1. call enter_C 2. visit all children 3. call leave_C.

It is recommended to override enter_C method if you only need to visit C constructor without changing a way you're visiting the tree.

For example, to collect all resolved jumps one could write the following function:

let collect_calls bil = (object(self)
  inherit [Word.t list] visitor
  method! enter_int x js = if in_jmp then x :: js else js
end)#run bil []

The default entry point of the visitor is method run, but you can use any other method as well, for example, if you do not have a statement at all and want to visit expression.

inherit 'a Exp.visitor
inherit state

Default entry point

method run : t list -> 'a -> 'a

Default entry point

method enter_stmt : t -> 'a -> 'a

Statements

method visit_stmt : t -> 'a -> 'a
method leave_stmt : t -> 'a -> 'a
method enter_move : var -> exp -> 'a -> 'a

Move(var,exp)

method visit_move : var -> exp -> 'a -> 'a
method leave_move : var -> exp -> 'a -> 'a
method enter_jmp : exp -> 'a -> 'a

Jmp exp

method visit_jmp : exp -> 'a -> 'a
method leave_jmp : exp -> 'a -> 'a
method enter_while : cond:exp -> t list -> 'a -> 'a

While (cond,bil)

method visit_while : cond:exp -> t list -> 'a -> 'a
method leave_while : cond:exp -> t list -> 'a -> 'a
method enter_if : cond:exp -> yes:t list -> no:t list -> 'a -> 'a

If (cond,yes,no)

method visit_if : cond:exp -> yes:t list -> no:t list -> 'a -> 'a
method leave_if : cond:exp -> yes:t list -> no:t list -> 'a -> 'a
method enter_cpuexn : int -> 'a -> 'a

CpuExn n

method visit_cpuexn : int -> 'a -> 'a
method leave_cpuexn : int -> 'a -> 'a
method enter_special : string -> 'a -> 'a

Special string

method visit_special : string -> 'a -> 'a
method leave_special : string -> 'a -> 'a
OCaml

Innovation. Community. Security.