Skip to content

Commit 16027ae

Browse files
committed
Change the wording to closer correspond to C++ types and concepts
1 parent bb77328 commit 16027ae

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

doc/architectural/central-data-structures.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
# Central Data Structures
22

33
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
55
CBMC and the assorted CProver tools.
66

77
## goto_modelt
88

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).
1111

12-
A `goto_modelt` is effectively a product type, consisting of:
12+
A `goto_modelt` is effectively a pair, consisting of:
1313

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+
```
1725

1826
The abstract interface of `goto_modelt` is outlined in the file
1927
[`src/goto-programs/abstract_goto_model.h`](../../src/goto-programs/abstract_goto_model.h).
2028

2129
## goto_functiont
2230

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):
2533

2634
```js
2735
type goto_functiont {
@@ -30,17 +38,20 @@ type goto_functiont {
3038
}
3139
```
3240

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.
3646

3747
## goto_programt
3848

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
4050
look like `type goto_programt = list<goto_instructiont>`.
4151

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:
4455

4556
```js
4657
type goto_instructiont {
@@ -50,18 +61,17 @@ type goto_instructiont {
5061
}
5162
```
5263

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:
5566

5667
* The `instruction_type` above corresponds to the `goto_program_instruction_typet` type
5768
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.
6070
* 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.
6373
* 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)
6575
that is expected to have type `bool`.
6676
* This is optional - not every instruction is expected to have a `guard` associated with it.
6777

@@ -72,8 +82,7 @@ Another important data structure that needs to be discussed at this point is
7282

7383
This is an `irept`. `irep`s are the central data structure that model most entities inside
7484
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.
7786

7887
`source_locationt` are attached into various `exprt`s (the data structure representing
7988
various expressions, usually the result of some early processing, e.g. the result of the

0 commit comments

Comments
 (0)