Skip to content

Commit b25bdfe

Browse files
committed
Updates requested in the PR.
1 parent 0c11a5e commit b25bdfe

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
@@ -331,37 +331,38 @@ This stage concludes the *analysis-independent* program transformations.
331331
To be documented.
332332

333333

334-
\section section-goto-binary Binary Represenration
334+
\section section-goto-binary Binary Representation
335335

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

340340
\subsection subsection-goto-binary-serialisation Serialisation
341341

342342
The serialisation is implemented in C++ modules:
343343
- `write_goto_binary.h`
344344
- `write_goto_binary.cpp`
345345

346-
To serialise a `goto_modelt` instance `gm` to a stream `ostr` call the function `write_goto_binary`, e.g. `write_goto_binary(ostr, gm)`.
346+
To serialise a `::goto_modelt` instance `gm` to a stream `ostr` call the
347+
function `::write_goto_binary`, e.g. `write_goto_binary(ostr, gm)`.
347348

348-
The content of the written stream will have this strucutre:
349+
The content of the written stream will have this structure:
349350
- The header:
350351
- A magic number: byte `0x7f` followed by 3 characters `GBF`.
351-
- A version number written in the 7-bit encoding. Currently, only version `4` is supported.
352+
- A version number written in the 7-bit encoding (see [number serialisation](\ref irep-serialization-numbers)). Currently, only version `4` is supported.
352353
- The symbol table:
353354
- The number of symbols in the table in the 7-bit encoding.
354355
- The array of individual symbols in the table. Each written symbol `s` has this structure:
355-
- The `irept` instance `s.type`.
356-
- The `irept` instance `s.value`.
357-
- The `irept` instance `s.location`.
356+
- The `::irept` instance `s.type`.
357+
- The `::irept` instance `s.value`.
358+
- The `::irept` instance `s.location`.
358359
- The string `s.name`.
359360
- The string `s.module`.
360361
- The string `s.base_name`.
361362
- The string `s.mode`.
362363
- The string `s.pretty_name`.
363364
- The number `0` in the 7-bit encoding.
364-
- 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):
365+
- 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):
365366
- `s.is_weak`
366367
- `s.is_type`
367368
- `s.is_property`
@@ -381,33 +382,33 @@ The content of the written stream will have this strucutre:
381382
- `s.is_volatile`
382383
- The functions with bodies, i.e. those missing a body are skipped.
383384
- The number of functions with bodies in the 7-bit encoding.
384-
- The array of individual function with bodies. Each written function has this structure:
385+
- The array of individual functions with bodies. Each written function has this structure:
385386
- The string with the name of the function.
386387
- The number of instructions in the body of the function in the 7-bit encoding.
387-
- The array of individual instruction in function's body. Each written instruction `I` has this structure:
388-
- The `irept` instance `I.code`, i.e. data of the instruction, like arguments.
388+
- The array of individual instructions in function's body. Each written instruction `I` has this structure:
389+
- The `::irept` instance `I.code`, i.e. data of the instruction, like arguments.
389390
- The string `I.function`, i.e. the name of the function this instruction belongs to.
390-
- The `irept` instance `I.source_location`, i.e. the reference to the original source code (file, line).
391+
- The `::irept` instance `I.source_location`, i.e. the reference to the original source code (file, line).
391392
- The word in the 7-bit encoding `I.type`, i.e. the op-code of the instruction.
392-
- The `irept` instance `I.guard`.
393+
- The `::irept` instance `I.guard`.
393394
- The empty string (representing former `I.event`).
394395
- The word in the 7-bit encoding `I.target_number`, i.e. the jump target to this instruction from other instructions.
395396
- The word in the 7-bit encoding `I.targets.size()`, i.e. the count of jump targets from this instruction.
396397
- The array of individual jump targets from this instruction, each written as a word in the 7-bit encoding.
397398
- The word in the 7-bit encoding `I.labels.size()`.
398399
- The array of individual labels, each written as a word in the 7-bit encoding.
399400

400-
An important propery of the serialisation is that each serialised `irept`
401+
An important propery of the serialisation is that each serialised `::irept`
401402
instance occurs in the stream exactly once. Namely, in the position of
402-
its first serialisation query. All other such queries save only hash
403-
code (i.e. reference) of the `irept` instance.
403+
its first serialisation query. All other such queries save only a hash
404+
code (i.e. reference) of the `::irept` instance.
404405

405-
The similar strategy is used for serialisation of string constants
406-
shared amongst `irept` instances. Such a string is fully saved only in
407-
the first serialisation query of an `irept` instance it appears in and
408-
all other queries only save its integer has code.
406+
A similar strategy is used for serialisation of string constants
407+
shared amongst `::irept` instances. Such a string is fully saved only in
408+
the first serialisation query of an `::irept` instance it appears in and
409+
all other queries only save its integer hash code.
409410

410-
Details about serialisation of `irept` instances, strings, and words in
411+
Details about serialisation of `::irept` instances, strings, and words in
411412
7-bit encoding can be found [here](\ref irep-serialization).
412413

413414
\subsection subsection-goto-binary-deserialisation Deserialisation
@@ -418,29 +419,30 @@ The deserialisation is implemented in C++ modules:
418419
- `read_bin_goto_object.h`
419420
- `read_bin_goto_object.cpp`
420421

421-
First two modules are responsible for location of the stream with the
422+
The first two modules are responsible for location of the stream with the
422423
serialised data within a passed file. And the remaining two modules
423-
perform the actual deserialisation of `goto_modelt` instance from
424+
perform the actual deserialisation of a `::goto_modelt` instance from
424425
the located stream.
425426

426-
To deserialise a `goto_modelt` instance `gm` from a file `/some/path/name.gbf`
427-
call the function `read_goto_binary`, e.g.
427+
To deserialise a `::goto_modelt` instance `gm` from a file
428+
`/some/path/name.gbf` call the function `::read_goto_binary`, e.g.
428429
`read_goto_binary("/some/path/name.gbf", gm, message_handler)`, where
429-
`message_handler` must be an instance of `message_handlert` and serves
430+
`message_handler` must be an instance of `::message_handlert` and serves
430431
for reporting issues during the process.
431432

432433
The passed binary file is assumed to have the same structure as described in
433434
the [previous subsection](\ref subsection-goto-binary-serialisation).
434435
The process of the deserialisation does not involve any seeking in the file.
435-
The content is read linearly from the beginning to the end. `irept` instances
436-
and their string constats are deserialised into the memory only once at their
437-
first occurreces in the stream. All subsequent deserialisation queries are
438-
resolved as in-memory references to the `irept` instances and/or strings.
436+
The content is read linearly from the beginning to the end. `::irept` instances
437+
and their string constants are deserialised into the memory only once at their
438+
first occurrences in the stream. All subsequent deserialisation queries are
439+
resolved as in-memory references to already deserialised the `::irept`
440+
instances and/or strings, based on hash code matching.
439441

440442
NOTE: The first deserialisation is detected so that the loaded hash code
441443
is new. That implies that the full definition follows right after the hash.
442444

443-
Details about serialisation of `irept` instances, strings, and words in
445+
Details about serialisation of `::irept` instances, strings, and words in
444446
7-bit encoding can be found [here](\ref irep-serialization).
445447

446448
\subsubsection subsection-goto-binary-deserialisation-from-elf Deserialisation from ELF image
@@ -450,24 +452,24 @@ One can decide to store the serialised stream as a separate section, named
450452
automatic detection of that section in an ELF file and the deserialisation
451453
will be automatically started from that section.
452454

453-
For reading the ELF images there is used an instance of `elf_readert`
455+
For reading the ELF images there is used an instance of `::elf_readert`
454456
implemented in the C++ module:
455457
- `elf_reader.h`
456458
- `elf_reader.cpp`
457459

458-
\subsubsection subsection-goto-binary-deserialisation-from-mac-o-fat-image Deserialisation from Mac-O fat image
460+
\subsubsection subsection-goto-binary-deserialisation-from-mach-o-fat-image Deserialisation from Mach-O fat image
459461

460-
One can decide to store the serialised stream into Mac-O fat image as a
462+
One can decide to store the serialised stream into Mach-O fat image as a
461463
separate non-empty section with flags `CPU_TYPE_HPPA` and
462464
`CPU_SUBTYPE_HPPA_7100LC`. Then the deserialisation has a support of
463-
automatic detection of that section in a Mac-O fat image, extraction
465+
automatic detection of that section in a Mach-O fat image, extraction
464466
of the section from the emage into a temporary file (this is done by
465467
calling `lipo` utility with `-thin hppa7100LC` option), and the
466468
deserialisation will be automatically started from that temporary
467469
file.
468470

469-
For reading the Mac-O fat images there is used an instance of
470-
`osx_fat_readert` implemented in the C++ module:
471+
For reading the Mach-O fat images there is used an instance of
472+
`::osx_fat_readert` implemented in the C++ module:
471473
- `osx_fat_reader.h`
472474
- `osx_fat_reader.cpp`
473475

@@ -476,25 +478,25 @@ on a MacOS machine.
476478

477479
\subsubsection subsection-goto-binary-is-binary-file Checking file type
478480

479-
You can use function `is_goto_binary` to check whether a passed file contains
480-
a sederialised `goto_modelt` instance or not. This is done by checking the
481+
You can use function `::is_goto_binary` to check whether a passed file contains
482+
a deserialised `::goto_modelt` instance or not. This is done by checking the
481483
magic number of the stream (see subsection
482484
[Serialisation](\ref subsection-goto-binary-serialisation)). However, in the
483-
case when the deserialised data were stored into ELF or Mac-O fat image, then
485+
case when the deserialised data were stored into ELF or Mach-O fat image, then
484486
only the check for presence of the concrete section in the image is performed.
485487

486488
\subsubsection subsection-goto-binary-deserialisation-linking Linking Goto Models
487489

488490
Similar to linking of object files together by C/C++ linker, the module
489-
provides linking of a dereserialised `goto_modelt` instance into a given
490-
(i.e. previously deserialised or otherwise created) `goto_modelt` instance.
491+
provides linking of a dereserialised `::goto_modelt` instance into a given
492+
(i.e. previously deserialised or otherwise created) `::goto_modelt` instance.
491493

492-
This is implemented in function `read_object_and_link`. The function first
493-
deserialises the passed file into a temporary `goto_modelt` instance, and
494+
This is implemented in function `::read_object_and_link`. The function first
495+
deserialises the passed file into a temporary `::goto_modelt` instance, and
494496
then it performs 'linking' of the temporary into a passed destination
495-
`goto_modelt` instance.
497+
`::goto_modelt` instance.
496498

497-
Details about linking of `goto_modelt` instances can be found
499+
Details about linking of `::goto_modelt` instances can be found
498500
[here](\ref section-linking-goto-models).
499501

500502

src/util/README.md

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

300300
\subsubsection irep-serialization-numbers Serialization of Numbers
301301

302-
A number is serialiased in 7-bit encoding. For example. given a 2-byte
303-
number in base 2, like `10101010 01010101`, then it is save in 3 bytes,
302+
A number is serialiased in 7-bit encoding. For example, given a 2-byte
303+
number in base 2, like `10101010 01010101`, then it is saves in 3 bytes,
304304
where each byte takes only 7 bits from the number, reading from the
305305
left. The 8th bit in each output byte is set to 1 except in the last
306-
byte, where the bit is 0. That 0 bit indicates the end of the end
306+
byte, where the bit is 0. That 0 bit indicates the end of the
307307
encoding of the number. So, the output bytes look like this:
308308
`11010101 11010100 00000010`.
309309

310-
This is implmented in the function `write_gb_word`.
310+
This is implmented in the function `::write_gb_word`.
311311

312312
The deserialisation does the oposite process and it is implemented in
313313
`irep_serializationt::read_gb_word`.
@@ -318,10 +318,10 @@ A string is encoded as classic 0-terminated C string. However,
318318
characters `0` and `\\` are escaped by writing additional `\\`
319319
before them.
320320

321-
This is implmented in the function `write_gb_string` and the
321+
This is implmented in the function `::write_gb_string` and the
322322
deserialisation is implemented in `irep_serializationt::read_gb_string`.
323323

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

0 commit comments

Comments
 (0)