package mopsa

  1. Overview
  2. Docs
MOPSA: A Modular and Open Platform for Static Analysis using Abstract Interpretation

Install

Dune Dependency

Authors

Maintainers

Sources

mopsa-analyzer-v1.1.tar.gz
md5=fdee20e988343751de440b4f6b67c0f4
sha512=f5cbf1328785d3f5ce40155dada2d95e5de5cce4f084ea30cfb04d1ab10cc9403a26cfb3fa55d0f9da72244482130fdb89c286a9aed0d640bba46b7c00e09500

doc/ast/Ast/Constant/index.html

Module Ast.ConstantSource

Constant

This module allows adding new constants to the extensible Mopsa AST.

To add a new constant, first extend type constant with a new variant constructor. For instance,

  type constant += C_int of int

adds a new constructor for integer constants.

The new constant needs to be registered by declaring a comparison and pretty-printing functions. For the previous example, the registration is as follows:

  let () = register_constant {
      compare = (fun next c1 c2 ->
          match c1, c2 with
          | C_int n1, C_int n2 -> compare n1 n2
          | _ -> next n1 n2
        );
      print = (fun next fmt c ->
          match c with
          | C_int n -> Format.pp_print_int fmt n
          | _ -> next fmt c
        );
    }

Any registered constant can be compared and printed with functions compare_constant and pp_constant.

Sourcetype constant = ..

Extensible constants

Sourceval compare_constant : constant -> constant -> int

compare_constant c1 c2 provides a total order between any pair c1 and c2 of registered constants

Sourceval pp_constant : Stdlib.Format.formatter -> constant -> unit

pp_constant fmt c pretty-prints a registered constant c with formatter fmt

Registration

Sourceval register_constant : constant Mopsa_utils.TypeExt.info -> unit

register_constant info registers a new constant with a comparison function info.compare and a pretty-printer info.print

Sourceval register_constant_compare : constant Mopsa_utils.TypeExt.compare -> unit

register_constant_compare compare registers a new comparison function for constants

Sourceval register_constant_pp : constant Mopsa_utils.TypeExt.print -> unit

register_constant_compare compare registers a new pretty-printer for constants

Common constants

Sourcetype constant +=
  1. | C_top of Typ.typ
  2. | C_bool of bool
OCaml

Innovation. Community. Security.