cprover
json_symbol_table.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: JSON symbol table deserialization
4
5
Author: Chris Smowton, chris.smowton@diffblue.com
6
7
\*******************************************************************/
8
9
#include "
json_symbol_table.h
"
10
#include "
json_symbol.h
"
11
12
#include <
util/exception_utils.h
>
13
#include <
util/json.h
>
14
#include <
util/symbol_table.h
>
15
16
void
symbol_table_from_json
(
const
jsont
&in,
symbol_tablet
&symbol_table)
17
{
18
if
(!in.
is_array
())
19
throw
deserialization_exceptiont
(
20
"symbol_table_from_json: JSON input must be an array"
);
21
for
(
const
auto
&js_symbol : in.
array
)
22
{
23
symbolt
deserialized =
symbol_from_json
(js_symbol);
24
if
(symbol_table.
add
(deserialized))
25
throw
deserialization_exceptiont
(
26
"symbol_table_from_json: duplicate symbol name '"
+
27
id2string
(deserialized.
name
) +
"'"
);
28
}
29
}
exception_utils.h
symbol_tablet
The symbol table.
Definition:
symbol_table.h:19
deserialization_exceptiont
Thrown when failing to deserialize a value from some low level format, like JSON or raw bytes.
Definition:
exception_utils.h:72
jsont
Definition:
json.h:23
id2string
const std::string & id2string(const irep_idt &d)
Definition:
irep.h:44
symbol_table_baset::add
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
Definition:
symbol_table_base.cpp:18
jsont::array
arrayt array
Definition:
json.h:129
symbolt
Symbol table entry.
Definition:
symbol.h:27
jsont::is_array
bool is_array() const
Definition:
json.h:54
json.h
symbol_table.h
Author: Diffblue Ltd.
symbolt::name
irep_idt name
The unique identifier.
Definition:
symbol.h:40
symbol_from_json
symbolt symbol_from_json(const jsont &in)
Deserialise a json object to a symbolt.
Definition:
json_symbol.cpp:45
json_symbol_table.h
symbol_table_from_json
void symbol_table_from_json(const jsont &in, symbol_tablet &symbol_table)
Definition:
json_symbol_table.cpp:16
json_symbol.h
json-symtab-language
json_symbol_table.cpp
Generated by
1.8.17