@@ -28,36 +28,24 @@ static void copy_parent(
28
28
const irep_idt &arg_name,
29
29
exprt &block)
30
30
{
31
- block.operands ().push_back (codet ());
32
-
33
- codet &code=to_code (block.operands ().back ());
34
- code.add_source_location ()=source_location;
35
-
36
- code.set_statement (ID_assign);
37
- code.operands ().push_back (exprt (ID_dereference));
38
-
39
- code.op0 ().operands ().push_back (exprt (" explicit-typecast" ));
40
-
41
- exprt &op0=code.op0 ().op0 ();
42
-
43
- op0.operands ().push_back (exprt (" cpp-this" ));
44
- op0.type ()=
45
- pointer_type (cpp_namet (parent_base_name, source_location).as_type ());
31
+ exprt op0 (
32
+ " explicit-typecast" ,
33
+ pointer_type (cpp_namet (parent_base_name, source_location).as_type ()));
34
+ op0.copy_to_operands (exprt (" cpp-this" ));
46
35
op0.add_source_location ()=source_location;
47
36
48
- code.operands ().push_back (exprt (" explicit-typecast" ));
49
- exprt &op1=code.op1 ();
50
-
51
- op1.type () =
52
- pointer_type (cpp_namet (parent_base_name, source_location).as_type ());
37
+ exprt op1 (
38
+ " explicit-typecast" ,
39
+ pointer_type (cpp_namet (parent_base_name, source_location).as_type ()));
53
40
op1.type ().set (ID_C_reference, true );
54
41
op1.type ().subtype ().set (ID_C_constant, true );
55
-
56
- op1.operands ().push_back (exprt (ID_cpp_name));
57
- op1.op0 ().get_sub ().push_back (irept (ID_name));
58
- op1.op0 ().get_sub ().back ().set (ID_identifier, arg_name);
59
- op1.op0 ().get_sub ().back ().set (ID_C_source_location, source_location);
42
+ op1.get_sub ().push_back (cpp_namet (arg_name, source_location));
60
43
op1.add_source_location ()=source_location;
44
+
45
+ code_assignt code (dereference_exprt (op0), op1);
46
+ code.add_source_location () = source_location;
47
+
48
+ block.operands ().push_back (code);
61
49
}
62
50
63
51
// / \param member_base_name: name of a member
@@ -69,39 +57,22 @@ static void copy_member(
69
57
const irep_idt &arg_name,
70
58
exprt &block)
71
59
{
72
- block.operands ().push_back (exprt (ID_code));
73
- exprt &code=block.operands ().back ();
60
+ cpp_namet op0 (member_base_name, source_location);
74
61
75
- code.set (ID_statement, ID_expression);
76
- code.add (ID_type)=typet (ID_code);
77
- code.operands ().push_back (exprt (ID_side_effect));
78
- code.op0 ().set (ID_statement, ID_assign);
79
- code.op0 ().operands ().push_back (exprt (ID_cpp_name));
80
- code.add_source_location ()=source_location;
81
-
82
- exprt &op0=code.op0 ().op0 ();
83
- op0.add_source_location ()=source_location;
84
-
85
- op0.get_sub ().push_back (irept (ID_name));
86
- op0.get_sub ().back ().set (ID_identifier, member_base_name);
87
- op0.get_sub ().back ().set (ID_C_source_location, source_location);
88
-
89
- code.op0 ().operands ().push_back (exprt (ID_member));
62
+ exprt op1 (ID_member);
63
+ op1.add (ID_component_cpp_name, cpp_namet (member_base_name, source_location));
64
+ op1.copy_to_operands (cpp_namet (arg_name, source_location).as_expr ());
65
+ op1.add_source_location ()=source_location;
90
66
91
- exprt &op1=code.op0 ().op1 ();
67
+ side_effect_exprt assign (ID_assign, typet (), source_location);
68
+ assign.copy_to_operands (op0.as_expr ());
69
+ assign.op0 ().add_source_location () = source_location;
70
+ assign.copy_to_operands (op1);
92
71
93
- op1.add (ID_component_cpp_name).id (ID_cpp_name);
94
- op1.add (ID_component_cpp_name).get_sub ().push_back (irept (ID_name));
95
- op1.add (ID_component_cpp_name).get_sub ().back ().set (
96
- ID_identifier, member_base_name);
97
- op1.add (ID_component_cpp_name).get_sub ().back ().set (
98
- ID_C_source_location, source_location);
72
+ code_expressiont code (assign);
73
+ code.add_source_location () = source_location;
99
74
100
- op1.operands ().push_back (exprt (ID_cpp_name));
101
- op1.op0 ().get_sub ().push_back (irept (ID_name));
102
- op1.op0 ().get_sub ().back ().set (ID_identifier, arg_name);
103
- op1.op0 ().get_sub ().back ().set (ID_C_source_location, source_location);
104
- op1.add_source_location ()=source_location;
75
+ block.operands ().push_back (code);
105
76
}
106
77
107
78
// / \param member_base_name: name of array member
@@ -116,44 +87,27 @@ static void copy_array(
116
87
exprt &block)
117
88
{
118
89
// Build the index expression
119
- exprt constant= from_integer (i, index_type ());
90
+ const exprt constant = from_integer (i, index_type ());
120
91
121
- block.operands ().push_back (exprt (ID_code));
122
- exprt &code=block.operands ().back ();
123
- code.add_source_location ()=source_location;
124
-
125
- code.set (ID_statement, ID_expression);
126
- code.add (ID_type)=typet (ID_code);
127
- code.operands ().push_back (exprt (ID_side_effect));
128
- code.op0 ().set (ID_statement, ID_assign);
129
- code.op0 ().operands ().push_back (exprt (ID_index));
130
- exprt &op0=code.op0 ().op0 ();
131
- op0.operands ().push_back (exprt (ID_cpp_name));
132
- op0.add_source_location ()=source_location;
92
+ const cpp_namet array (member_base_name, source_location);
133
93
134
- op0. op0 (). get_sub (). push_back ( irept (ID_name) );
135
- op0. op0 (). get_sub (). back (). set (ID_identifier, member_base_name);
136
- op0. op0 (). get_sub (). back (). set (ID_C_source_location , source_location);
137
- op0 .copy_to_operands (constant );
94
+ exprt member (ID_member );
95
+ member. add (
96
+ ID_component_cpp_name, cpp_namet (member_base_name , source_location) );
97
+ member .copy_to_operands (cpp_namet (arg_name, source_location). as_expr () );
138
98
139
- code. op0 (). operands (). push_back ( exprt (ID_index) );
99
+ side_effect_exprt assign (ID_assign, typet (), source_location );
140
100
141
- exprt &op1=code.op0 ().op1 ();
142
- op1.operands ().push_back (exprt (ID_member));
143
- op1.op0 ().add (ID_component_cpp_name).id (ID_cpp_name);
144
- op1.op0 ().add (ID_component_cpp_name).get_sub ().push_back (irept (ID_name));
145
- op1.op0 ().add (ID_component_cpp_name).get_sub ().back ().set (
146
- ID_identifier, member_base_name);
147
- op1.op0 ().add (ID_component_cpp_name).get_sub ().back ().set (
148
- ID_C_source_location, source_location);
101
+ assign.copy_to_operands (index_exprt (array.as_expr (), constant));
102
+ assign.op0 ().add_source_location () = source_location;
149
103
150
- op1.op0 ().operands ().push_back (exprt (ID_cpp_name));
151
- op1.op0 ().op0 ().get_sub ().push_back (irept (ID_name));
152
- op1.op0 ().op0 ().get_sub ().back ().set (ID_identifier, arg_name);
153
- op1.op0 ().op0 ().get_sub ().back ().set (ID_C_source_location, source_location);
154
- op1.copy_to_operands (constant);
104
+ assign.copy_to_operands (index_exprt (member, constant));
105
+ assign.op1 ().add_source_location () = source_location;
155
106
156
- op1.add_source_location ()=source_location;
107
+ code_expressiont code (assign);
108
+ code.add_source_location () = source_location;
109
+
110
+ block.operands ().push_back (code);
157
111
}
158
112
159
113
// / Generate code for implicit default constructors
0 commit comments