CBMC
Loading...
Searching...
No Matches
json_symbol_table.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: JSON symbol table deserialization
4
5Author: Chris Smowton, chris.smowton@diffblue.com
6
7\*******************************************************************/
8
9#include "json_symbol_table.h"
10
12#include <util/json.h>
14
15#include "json_symbol.h"
16
17void symbol_table_from_json(const jsont &in, symbol_table_baset &symbol_table)
18{
19 if(!in.is_object())
20 {
22 "symbol_table_from_json: JSON input must be an object");
23 }
24
26 const auto it = json_object.find("symbolTable");
27
28 if(it == json_object.end())
29 {
31 "symbol_table_from_json: JSON object must have key `symbolTable`");
32 }
33
34 if(!it->second.is_object())
35 {
37 "symbol_table_from_json: JSON symbol table must be an object");
38 }
39
41
42 for(const auto &pair : json_symbol_table)
43 {
44 const jsont &json_symbol = pair.second;
45
47
48 if(symbol_table.add(symbol))
50 "symbol_table_from_json: duplicate symbol name `" +
51 id2string(symbol.name) + "`");
52 }
53
55}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
Thrown when failing to deserialize a value from some low level format, like JSON or raw bytes.
Definition json.h:27
bool is_object() const
Definition json.h:56
The symbol table base class interface.
virtual void validate(const validation_modet vm=validation_modet::INVARIANT) const =0
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
Symbol table entry.
Definition symbol.h:28
irep_idt name
The unique identifier.
Definition symbol.h:40
const std::string & id2string(const irep_idt &d)
Definition irep.h:44
json_objectt & to_json_object(jsont &json)
Definition json.h:442
symbolt symbol_from_json(const jsont &in)
Deserialise a json object to a symbolt.
void symbol_table_from_json(const jsont &in, symbol_table_baset &symbol_table)
Author: Diffblue Ltd.