CBMC
Loading...
Searching...
No Matches
json_goto_functions.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: JSON goto_functions deserialization
4
5Author: Michael Tautschnig
6
7\*******************************************************************/
8
11
12#include "json_goto_functions.h"
13
15#include <util/json.h>
16
18
19#include "json_goto_function.h"
20
22 const jsont &json,
23 goto_functionst &goto_functions)
24{
25 if(!json.is_object())
26 {
28 "goto_functions_from_json: JSON input must be an object"};
29 }
30
32 const auto it = json_object.find("functions");
33
34 if(it == json_object.end())
35 {
37 "goto_functions_from_json: JSON object must have key 'functions'"};
38 }
39
40 if(!it->second.is_array())
41 {
43 "goto_functions_from_json: JSON functions must be an array"};
44 }
45
46 const json_arrayt &json_functions = to_json_array(it->second);
47
48 for(const auto &function : json_functions)
49 {
50 if(!function.is_object())
51 {
53 "goto_functions_from_json: JSON function must be an object"};
54 }
55
56 const json_objectt &json_function = to_json_object(function);
57 auto name_it = json_function.find("name");
58
59 if(name_it == json_function.end() || !name_it->second.is_string())
60 {
62 "goto_functions_from_json: JSON function object must have key 'name' "
63 "mapping to a string"};
64 }
65 const auto function_name = name_it->second.value;
66
68 goto_functions.function_map[function_name] = std::move(goto_function);
69 }
70
71 goto_functions.update();
72}
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.
A collection of goto functions.
function_mapt function_map
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
Definition json.h:27
Goto Programs with Functions.
json_objectt & to_json_object(jsont &json)
Definition json.h:442
json_arrayt & to_json_array(jsont &json)
Definition json.h:424
goto_functiont goto_function_from_json(const json_objectt &json)
Deserialize a goto_functiont from JSON.
JSON goto_function deserialization.
void goto_functions_from_json(const jsont &json, goto_functionst &goto_functions)
Deserialize goto_functionst from JSON.
JSON goto_functions deserialization.
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)