1
1
# Central Data Structures
2
2
3
3
The following is some light technical documentation of the major data structures
4
- represented in the input transformation to Intermediate Representation (IR) inside
4
+ used in the input transformation to Intermediate Representation (IR) inside
5
5
CBMC and the assorted CProver tools.
6
6
7
7
## goto_modelt
8
8
9
- The ` goto_modelt ` is the main data structure that CBMC (and the other tools) use to
10
- represent GOTO-IR (the ` GOTO ` Intermediate Representation).
9
+ The ` goto_modelt ` is the main data structure that CBMC (and the other tools) used
10
+ for the GOTO-IR (the ` GOTO ` Intermediate Representation).
11
11
12
- A ` goto_modelt ` is effectively a product type , consisting of:
12
+ A ` goto_modelt ` is effectively a pair , consisting of:
13
13
14
- * A list of GOTO functions (pseudocode: ` type goto_functionst = list<goto_functiont> ` )
15
- * A symbol table containing symbol references for the symbols contained in the
16
- GOTO functions (pseudocode: ` type symbol_tablet = map<identifier, symbolt> ` ).
14
+ * A list of GOTO functions,
15
+ * A symbol table containing symbol references for the symbols contained in the GOTO functions.
16
+
17
+ In pseudocode, the type looks this:
18
+
19
+ ``` js
20
+ type goto_modelt {
21
+ type goto_functionst = list< goto_functiont>
22
+ type symbol_tablet = map< identifier, symbolt>
23
+ }
24
+ ```
17
25
18
26
The abstract interface of ` goto_modelt ` is outlined in the file
19
27
[ ` src/goto-programs/abstract_goto_model.h ` ] ( ../../src/goto-programs/abstract_goto_model.h ) .
20
28
21
29
## goto_functiont
22
30
23
- A ` goto_functiont ` is also a product type . It's designed to represent a function
24
- at the IR level, and effectively it's the following ADT (in pseudocode):
31
+ A ` goto_functiont ` is also defined as a pair . It's designed to represent a function
32
+ at the IR level, and effectively it's the following data type (in pseudocode):
25
33
26
34
``` js
27
35
type goto_functiont {
@@ -30,17 +38,20 @@ type goto_functiont {
30
38
}
31
39
```
32
40
33
- Of the two types listed above, the ` parameters ` one should be self-documenting,
34
- (the values of these are later looked up in the symbol table), so we're going to
35
- focus next on the type ` goto_programt `
41
+ The ` goto_programt ` denoting the ` body ` of the function will be the subject of
42
+ a more elaborate explanation in the next section.
43
+
44
+ The ` parameters ` subcomponent is a list of identifiers that are to be looked-up
45
+ in the symbol-table for their values.
36
46
37
47
## goto_programt
38
48
39
- A ` goto_programt ` is a container of GOTO-IR instructions. In pseudocode, it would
49
+ A ` goto_programt ` is a list of GOTO-IR instructions. In pseudocode, it would
40
50
look like ` type goto_programt = list<goto_instructiont> ` .
41
51
42
- An instruction (` goto_instructiont ` ) is another product type, describing a GOTO level
43
- instruction with the following 3 component subtypes, again in pseudocode:
52
+ An instruction (` goto_instructiont ` ) is a triple (an element with three subcomponents),
53
+ describing a GOTO level instruction with the following 3 component subtypes,
54
+ again in pseudocode:
44
55
45
56
``` js
46
57
type goto_instructiont {
@@ -50,18 +61,17 @@ type goto_instructiont {
50
61
}
51
62
```
52
63
53
- The above subtypes are just illustrative , so we will provide some extra explanation for
54
- these :
64
+ The pseudocode subtypes above require some more elaboration , so we will provide some extra
65
+ detail to illuminate some details at the code level :
55
66
56
67
* The ` instruction_type ` above corresponds to the ` goto_program_instruction_typet ` type
57
68
listed in [ ` goto_program.h ` ] ( ../../src/goto-programs/goto_program.h )
58
- * For illustration purposes, some instruction types are ` assign ` , ` function_call ` , ` return ` ,
59
- etc.
69
+ * Some illustrative instruction types are ` assign ` , ` function_call ` , ` return ` , etc.
60
70
* The ` instruction ` is a statement represented by a ` goto_instruction_codet ` .
61
- * A ` goto_instruction_codet ` is a ` codet ` (a data structure broadly representing a statement
62
- inside CBMC) that contains the actual GOTO-IR instruction .
71
+ * A ` goto_instruction_codet ` is an alias of ` codet ` (a data structure broadly representing
72
+ a statement inside CBMC) that contains the actual code to be executed .
63
73
* You can distinguish different statements by inspecting the ` irep ` element ` ID_statement ` .
64
- * The ` guard ` is an ` exprt ` (A CBMC data structure broadly representing an expression)
74
+ * The ` guard ` is an ` exprt ` (a data structure broadly representing an expression inside CBMC )
65
75
that is expected to have type ` bool ` .
66
76
* This is optional - not every instruction is expected to have a ` guard ` associated with it.
67
77
@@ -72,8 +82,7 @@ Another important data structure that needs to be discussed at this point is
72
82
73
83
This is an ` irept ` . ` irep ` s are the central data structure that model most entities inside
74
84
CBMC and the assorted tools - effectively a node/map like data structure that forms a hierachical
75
- tree that ends up modeling graphs like ASTs, CFGs, etc. (This will be further discussed in
76
- a dedicated page).
85
+ tree that ends up modeling graphs like ASTs, CFGs, etc.
77
86
78
87
` source_locationt ` are attached into various ` exprt ` s (the data structure representing
79
88
various expressions, usually the result of some early processing, e.g. the result of the
0 commit comments