Back to Code Contracts Developer Documentation
Architecture Overview
The code implementing Code Contracts Transformation Specification is found in Dynamic Frame Condition Checking (DFCC)
We go over each class and explain how it works in relation to others.
The dfcct class is the main entry point into the transformation.
The method dfcct::transform_goto_model first separates the functions of the goto model in different groups (functions to instrument, pure contract symbols from which to generate code, functions to check against contracts, functions to replace with contracts) and applies the transformation to the whole goto model, by scheduling the translation passes described in Code Contracts Transformation Specification :
- Generating GOTO Functions From Contract Clauses is applied to all contracts to check or replace;
- Dynamic Frame Condition Checking is applied to all library or user-defined goto functions;
- Proof Harness Intrumentation is applied to the harness function;
- Checking a Contract Against a Function is applied to the function to be checked against a contract;
- Replacing a Function by a Contract is applied to each function to be replaced by a contract;
Each of these translation passes is implemented in a specific class:
The following classes contain utility methods:
- dfcc_utilst : Provides basic utility methods to the other classes such as locating a function symbol, adding a parameter to a function symbol, cloning or renaming a function symbol, creating fresh symbols, inlining a function body, etc.
- dfcc_libraryt : Provides a C++ interface to access C library functions defined in cprover_contracts.c. Using this class it is possible to load the library symbols and post-process them with loop unrolling or inlining, etc.