CBMC
statement_list_parse_tree.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Statement List Language Parse Tree
4 
5 Author: Matthias Weiss, matthias.weiss@diffblue.com
6 
7 \*******************************************************************/
8 
11 
13 
15  const var_declarationt &declaration)
16 {
17  var_input.push_back(declaration);
18 }
19 
21  const var_declarationt &declaration)
22 {
23  var_inout.push_back(declaration);
24 }
25 
27  const var_declarationt &declaration)
28 {
29  var_output.push_back(declaration);
30 }
31 
33  const var_declarationt &declaration)
34 {
35  var_constant.push_back(declaration);
36 }
37 
39  const var_declarationt &declaration)
40 {
41  var_temp.push_back(declaration);
42 }
43 
45  const var_declarationt &declaration)
46 {
47  var_static.push_back(declaration);
48 }
49 
51 {
52  networks.push_back(network);
53 }
54 
56 {
57  if(value.empty())
58  title.reset();
59  else
60  title = value;
61 }
62 
64 {
65  set_title(title);
66 }
67 
69  const instructiont &inst)
70 {
71  instructions.push_back(inst);
72 }
73 
75  const irep_idt &name,
76  const std::string &version)
77  : name(name), version(version)
78 {
79 }
80 
82  const irep_idt &name,
83  const std::string &version)
84  : tia_modulet(name, version)
85 {
86 }
87 
89 {
90  function_blocks.push_back(std::move(block));
91 }
92 
94 {
95  functions.push_back(std::move(function));
96 }
97 
99 {
100  function_blocks.clear();
101  functions.clear();
102  tags.clear();
103 }
104 
106 {
107  function_blocks.swap(other.function_blocks);
108  functions.swap(other.functions);
109  tags.swap(other.tags);
110 }
111 
113  const irep_idt &name,
114  const std::string &version,
115  const typet &return_type)
116  : tia_modulet(name, version), return_type(return_type)
117 {
118 }
119 
121 {
122  tokens.push_back(token);
123 }
124 
126  const symbol_exprt &symbol)
127  : variable(symbol)
128 {
129 }
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
typet
The type of an expression, extends irept.
Definition: type.h:28
statement_list_parse_treet::tia_modulet::add_var_temp_entry
void add_var_temp_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of temp variables.
Definition: statement_list_parse_tree.cpp:38
statement_list_parse_treet::networkt::set_title
void set_title(const std::string &value)
Sets the title of the network to a specific value.
Definition: statement_list_parse_tree.cpp:55
statement_list_parse_treet::var_declarationt
Struct for a single variable declaration in Statement List.
Definition: statement_list_parse_tree.h:28
statement_list_parse_treet::tia_modulet::var_input
var_declarationst var_input
Input variable declarations.
Definition: statement_list_parse_tree.h:87
statement_list_parse_treet::tia_modulet::add_var_constant_entry
void add_var_constant_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of constant variables.
Definition: statement_list_parse_tree.cpp:32
statement_list_parse_treet::instructiont
Represents a regular Statement List instruction which consists out of one or more codet tokens.
Definition: statement_list_parse_tree.h:43
statement_list_parse_treet::tia_modulet
Base element of all modules in the Totally Integrated Automation (TIA) portal by Siemens.
Definition: statement_list_parse_tree.h:79
statement_list_parse_treet::function_blockt::add_var_static_entry
void add_var_static_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of static variables.
Definition: statement_list_parse_tree.cpp:44
symbol_exprt
Expression to hold a symbol (variable)
Definition: std_expr.h:112
statement_list_parse_treet::tia_modulet::add_var_output_entry
void add_var_output_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of output variables.
Definition: statement_list_parse_tree.cpp:26
statement_list_parse_treet::function_blockt
Structure for a simple function block in Statement List.
Definition: statement_list_parse_tree.h:146
statement_list_parse_treet::tia_modulet::add_network
void add_network(networkt &network)
Adds a network to the function.
Definition: statement_list_parse_tree.cpp:50
statement_list_parse_treet::networkt::networkt
networkt()=default
statement_list_parse_treet::add_function
void add_function(functiont &function)
Adds a function to the parse tree.
Definition: statement_list_parse_tree.cpp:93
statement_list_parse_treet::swap
void swap(statement_list_parse_treet &other)
Swaps the contents of the parse tree with the parameter.
Definition: statement_list_parse_tree.cpp:105
statement_list_parse_treet::tia_modulet::add_var_inout_entry
void add_var_inout_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of inout variables.
Definition: statement_list_parse_tree.cpp:20
statement_list_parse_treet::function_blockt::function_blockt
function_blockt(const irep_idt &name, const std::string &version)
Create the function block name with a specific version.
Definition: statement_list_parse_tree.cpp:81
statement_list_parse_treet::function_blocks
function_blockst function_blocks
List of function blocks this parse tree includes.
Definition: statement_list_parse_tree.h:173
statement_list_parse_tree.h
statement_list_parse_treet::tia_modulet::add_var_input_entry
void add_var_input_entry(const var_declarationt &declaration)
Adds a variable declaration to the list of input variables.
Definition: statement_list_parse_tree.cpp:14
statement_list_parse_treet::functiont::functiont
functiont(const irep_idt &name, const std::string &version, const typet &return_type)
Create the function name with a specific version and a return_value.
Definition: statement_list_parse_tree.cpp:112
statement_list_parse_treet
Intermediate representation of a parsed Statement List file before converting it into a goto program.
Definition: statement_list_parse_tree.h:20
statement_list_parse_treet::var_declarationt::var_declarationt
var_declarationt(const symbol_exprt &symbol)
Creates a new.
Definition: statement_list_parse_tree.cpp:125
statement_list_parse_treet::clear
void clear()
Removes all functions and function blocks from the parse tree.
Definition: statement_list_parse_tree.cpp:98
statement_list_parse_treet::instructiont::add_token
void add_token(const codet &token)
Adds a codet element to the list of all tokens.
Definition: statement_list_parse_tree.cpp:120
statement_list_parse_treet::tags
std::vector< symbol_exprt > tags
List of tags that were included in the source.
Definition: statement_list_parse_tree.h:177
statement_list_parse_treet::networkt::add_instruction
void add_instruction(const instructiont &inst)
Adds an instruction to the network.
Definition: statement_list_parse_tree.cpp:68
statement_list_parse_treet::functiont
Structure for a simple function in Statement List.
Definition: statement_list_parse_tree.h:127
statement_list_parse_treet::tia_modulet::tia_modulet
tia_modulet(const irep_idt &name, const std::string &version)
Create the module name with a specific version.
Definition: statement_list_parse_tree.cpp:74
statement_list_parse_treet::functions
functionst functions
List of functions this parse tree includes.
Definition: statement_list_parse_tree.h:175
statement_list_parse_treet::networkt
Representation of a network in Siemens TIA.
Definition: statement_list_parse_tree.h:58
statement_list_parse_treet::add_function_block
void add_function_block(function_blockt &block)
Adds a function block to the parse tree.
Definition: statement_list_parse_tree.cpp:88
codet
Data structure for representing an arbitrary statement in a program.
Definition: std_code_base.h:28