Skip to content

Commit 988e26c

Browse files
committed
Updates requested in the PR.
1 parent 5003672 commit 988e26c

File tree

2 files changed

+56
-54
lines changed

2 files changed

+56
-54
lines changed

src/goto-programs/README.md

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -379,37 +379,38 @@ This stage concludes the *analysis-independent* program transformations.
379379
To be documented.
380380

381381

382-
\section section-goto-binary Binary Represenration
382+
\section section-goto-binary Binary Representation
383383

384-
An instance of `goto_modelt` can be serialised to a binary stream (which is
384+
An instance of `::goto_modelt` can be serialised to a binary stream (which is
385385
typically a file on the disk), and later deserialised from that stream back to
386-
an equivalent `goto_modelt` instance.
386+
an equivalent `::goto_modelt` instance.
387387

388388
\subsection subsection-goto-binary-serialisation Serialisation
389389

390390
The serialisation is implemented in C++ modules:
391391
- `write_goto_binary.h`
392392
- `write_goto_binary.cpp`
393393

394-
To serialise a `goto_modelt` instance `gm` to a stream `ostr` call the function `write_goto_binary`, e.g. `write_goto_binary(ostr, gm)`.
394+
To serialise a `::goto_modelt` instance `gm` to a stream `ostr` call the
395+
function `::write_goto_binary`, e.g. `write_goto_binary(ostr, gm)`.
395396

396-
The content of the written stream will have this strucutre:
397+
The content of the written stream will have this structure:
397398
- The header:
398399
- A magic number: byte `0x7f` followed by 3 characters `GBF`.
399-
- A version number written in the 7-bit encoding. Currently, only version `4` is supported.
400+
- A version number written in the 7-bit encoding (see [number serialisation](\ref irep-serialization-numbers)). Currently, only version `4` is supported.
400401
- The symbol table:
401402
- The number of symbols in the table in the 7-bit encoding.
402403
- The array of individual symbols in the table. Each written symbol `s` has this structure:
403-
- The `irept` instance `s.type`.
404-
- The `irept` instance `s.value`.
405-
- The `irept` instance `s.location`.
404+
- The `::irept` instance `s.type`.
405+
- The `::irept` instance `s.value`.
406+
- The `::irept` instance `s.location`.
406407
- The string `s.name`.
407408
- The string `s.module`.
408409
- The string `s.base_name`.
409410
- The string `s.mode`.
410411
- The string `s.pretty_name`.
411412
- The number `0` in the 7-bit encoding.
412-
- The flags word in the 7-bit encoding. The bits in the flags word correspond to the following `bool` fields (from the most significant bit):
413+
- The flags word in the 7-bit encoding. The bits in the flags word correspond to the following `Boolean` fields (from the most significant bit):
413414
- `s.is_weak`
414415
- `s.is_type`
415416
- `s.is_property`
@@ -429,33 +430,33 @@ The content of the written stream will have this strucutre:
429430
- `s.is_volatile`
430431
- The functions with bodies, i.e. those missing a body are skipped.
431432
- The number of functions with bodies in the 7-bit encoding.
432-
- The array of individual function with bodies. Each written function has this structure:
433+
- The array of individual functions with bodies. Each written function has this structure:
433434
- The string with the name of the function.
434435
- The number of instructions in the body of the function in the 7-bit encoding.
435-
- The array of individual instruction in function's body. Each written instruction `I` has this structure:
436-
- The `irept` instance `I.code`, i.e. data of the instruction, like arguments.
436+
- The array of individual instructions in function's body. Each written instruction `I` has this structure:
437+
- The `::irept` instance `I.code`, i.e. data of the instruction, like arguments.
437438
- The string `I.function`, i.e. the name of the function this instruction belongs to.
438-
- The `irept` instance `I.source_location`, i.e. the reference to the original source code (file, line).
439+
- The `::irept` instance `I.source_location`, i.e. the reference to the original source code (file, line).
439440
- The word in the 7-bit encoding `I.type`, i.e. the op-code of the instruction.
440-
- The `irept` instance `I.guard`.
441+
- The `::irept` instance `I.guard`.
441442
- The empty string (representing former `I.event`).
442443
- The word in the 7-bit encoding `I.target_number`, i.e. the jump target to this instruction from other instructions.
443444
- The word in the 7-bit encoding `I.targets.size()`, i.e. the count of jump targets from this instruction.
444445
- The array of individual jump targets from this instruction, each written as a word in the 7-bit encoding.
445446
- The word in the 7-bit encoding `I.labels.size()`.
446447
- The array of individual labels, each written as a word in the 7-bit encoding.
447448

448-
An important propery of the serialisation is that each serialised `irept`
449+
An important propery of the serialisation is that each serialised `::irept`
449450
instance occurs in the stream exactly once. Namely, in the position of
450-
its first serialisation query. All other such queries save only hash
451-
code (i.e. reference) of the `irept` instance.
451+
its first serialisation query. All other such queries save only a hash
452+
code (i.e. reference) of the `::irept` instance.
452453

453-
The similar strategy is used for serialisation of string constants
454-
shared amongst `irept` instances. Such a string is fully saved only in
455-
the first serialisation query of an `irept` instance it appears in and
456-
all other queries only save its integer has code.
454+
A similar strategy is used for serialisation of string constants
455+
shared amongst `::irept` instances. Such a string is fully saved only in
456+
the first serialisation query of an `::irept` instance it appears in and
457+
all other queries only save its integer hash code.
457458

458-
Details about serialisation of `irept` instances, strings, and words in
459+
Details about serialisation of `::irept` instances, strings, and words in
459460
7-bit encoding can be found [here](\ref irep-serialization).
460461

461462
\subsection subsection-goto-binary-deserialisation Deserialisation
@@ -466,29 +467,30 @@ The deserialisation is implemented in C++ modules:
466467
- `read_bin_goto_object.h`
467468
- `read_bin_goto_object.cpp`
468469

469-
First two modules are responsible for location of the stream with the
470+
The first two modules are responsible for location of the stream with the
470471
serialised data within a passed file. And the remaining two modules
471-
perform the actual deserialisation of `goto_modelt` instance from
472+
perform the actual deserialisation of a `::goto_modelt` instance from
472473
the located stream.
473474

474-
To deserialise a `goto_modelt` instance `gm` from a file `/some/path/name.gbf`
475-
call the function `read_goto_binary`, e.g.
475+
To deserialise a `::goto_modelt` instance `gm` from a file
476+
`/some/path/name.gbf` call the function `::read_goto_binary`, e.g.
476477
`read_goto_binary("/some/path/name.gbf", gm, message_handler)`, where
477-
`message_handler` must be an instance of `message_handlert` and serves
478+
`message_handler` must be an instance of `::message_handlert` and serves
478479
for reporting issues during the process.
479480

480481
The passed binary file is assumed to have the same structure as described in
481482
the [previous subsection](\ref subsection-goto-binary-serialisation).
482483
The process of the deserialisation does not involve any seeking in the file.
483-
The content is read linearly from the beginning to the end. `irept` instances
484-
and their string constats are deserialised into the memory only once at their
485-
first occurreces in the stream. All subsequent deserialisation queries are
486-
resolved as in-memory references to the `irept` instances and/or strings.
484+
The content is read linearly from the beginning to the end. `::irept` instances
485+
and their string constants are deserialised into the memory only once at their
486+
first occurrences in the stream. All subsequent deserialisation queries are
487+
resolved as in-memory references to already deserialised the `::irept`
488+
instances and/or strings, based on hash code matching.
487489

488490
NOTE: The first deserialisation is detected so that the loaded hash code
489491
is new. That implies that the full definition follows right after the hash.
490492

491-
Details about serialisation of `irept` instances, strings, and words in
493+
Details about serialisation of `::irept` instances, strings, and words in
492494
7-bit encoding can be found [here](\ref irep-serialization).
493495

494496
\subsubsection subsection-goto-binary-deserialisation-from-elf Deserialisation from ELF image
@@ -498,24 +500,24 @@ One can decide to store the serialised stream as a separate section, named
498500
automatic detection of that section in an ELF file and the deserialisation
499501
will be automatically started from that section.
500502

501-
For reading the ELF images there is used an instance of `elf_readert`
503+
For reading the ELF images there is used an instance of `::elf_readert`
502504
implemented in the C++ module:
503505
- `elf_reader.h`
504506
- `elf_reader.cpp`
505507

506-
\subsubsection subsection-goto-binary-deserialisation-from-mac-o-fat-image Deserialisation from Mac-O fat image
508+
\subsubsection subsection-goto-binary-deserialisation-from-mach-o-fat-image Deserialisation from Mach-O fat image
507509

508-
One can decide to store the serialised stream into Mac-O fat image as a
510+
One can decide to store the serialised stream into Mach-O fat image as a
509511
separate non-empty section with flags `CPU_TYPE_HPPA` and
510512
`CPU_SUBTYPE_HPPA_7100LC`. Then the deserialisation has a support of
511-
automatic detection of that section in a Mac-O fat image, extraction
513+
automatic detection of that section in a Mach-O fat image, extraction
512514
of the section from the emage into a temporary file (this is done by
513515
calling `lipo` utility with `-thin hppa7100LC` option), and the
514516
deserialisation will be automatically started from that temporary
515517
file.
516518

517-
For reading the Mac-O fat images there is used an instance of
518-
`osx_fat_readert` implemented in the C++ module:
519+
For reading the Mach-O fat images there is used an instance of
520+
`::osx_fat_readert` implemented in the C++ module:
519521
- `osx_fat_reader.h`
520522
- `osx_fat_reader.cpp`
521523

@@ -524,25 +526,25 @@ on a MacOS machine.
524526

525527
\subsubsection subsection-goto-binary-is-binary-file Checking file type
526528

527-
You can use function `is_goto_binary` to check whether a passed file contains
528-
a sederialised `goto_modelt` instance or not. This is done by checking the
529+
You can use function `::is_goto_binary` to check whether a passed file contains
530+
a deserialised `::goto_modelt` instance or not. This is done by checking the
529531
magic number of the stream (see subsection
530532
[Serialisation](\ref subsection-goto-binary-serialisation)). However, in the
531-
case when the deserialised data were stored into ELF or Mac-O fat image, then
533+
case when the deserialised data were stored into ELF or Mach-O fat image, then
532534
only the check for presence of the concrete section in the image is performed.
533535

534536
\subsubsection subsection-goto-binary-deserialisation-linking Linking Goto Models
535537

536538
Similar to linking of object files together by C/C++ linker, the module
537-
provides linking of a dereserialised `goto_modelt` instance into a given
538-
(i.e. previously deserialised or otherwise created) `goto_modelt` instance.
539+
provides linking of a dereserialised `::goto_modelt` instance into a given
540+
(i.e. previously deserialised or otherwise created) `::goto_modelt` instance.
539541

540-
This is implemented in function `read_object_and_link`. The function first
541-
deserialises the passed file into a temporary `goto_modelt` instance, and
542+
This is implemented in function `::read_object_and_link`. The function first
543+
deserialises the passed file into a temporary `::goto_modelt` instance, and
542544
then it performs 'linking' of the temporary into a passed destination
543-
`goto_modelt` instance.
545+
`::goto_modelt` instance.
544546

545-
Details about linking of `goto_modelt` instances can be found
547+
Details about linking of `::goto_modelt` instances can be found
546548
[here](\ref section-linking-goto-models).
547549

548550

src/util/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ This is implemented in C++ modules:
162162

163163
\subsubsection irep-serialization-numbers Serialization of Numbers
164164

165-
A number is serialiased in 7-bit encoding. For example. given a 2-byte
166-
number in base 2, like `10101010 01010101`, then it is save in 3 bytes,
165+
A number is serialiased in 7-bit encoding. For example, given a 2-byte
166+
number in base 2, like `10101010 01010101`, then it is saves in 3 bytes,
167167
where each byte takes only 7 bits from the number, reading from the
168168
left. The 8th bit in each output byte is set to 1 except in the last
169-
byte, where the bit is 0. That 0 bit indicates the end of the end
169+
byte, where the bit is 0. That 0 bit indicates the end of the
170170
encoding of the number. So, the output bytes look like this:
171171
`11010101 11010100 00000010`.
172172

173-
This is implmented in the function `write_gb_word`.
173+
This is implmented in the function `::write_gb_word`.
174174

175175
The deserialisation does the oposite process and it is implemented in
176176
`irep_serializationt::read_gb_word`.
@@ -181,10 +181,10 @@ A string is encoded as classic 0-terminated C string. However,
181181
characters `0` and `\\` are escaped by writing additional `\\`
182182
before them.
183183

184-
This is implmented in the function `write_gb_string` and the
184+
This is implmented in the function `::write_gb_string` and the
185185
deserialisation is implemented in `irep_serializationt::read_gb_string`.
186186

187-
Each string which is stored inside an `irept` instance is saved (meaining
187+
Each string which is stored inside an `::irept` instance is saved (meaining
188188
its characters) into the ouptut stream, only in the first serialisation
189189
query of the string. In that case, before the string there is also saved
190190
a computed integer hash code of the string. Then, all subsequent

0 commit comments

Comments
 (0)