Branch data Line data Source code
1 : : // Copyright (C) 2020-2024 Free Software Foundation, Inc.
2 : :
3 : : // This file is part of GCC.
4 : :
5 : : // GCC is free software; you can redistribute it and/or modify it under
6 : : // the terms of the GNU General Public License as published by the Free
7 : : // Software Foundation; either version 3, or (at your option) any later
8 : : // version.
9 : :
10 : : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 : : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 : : // for more details.
14 : :
15 : : // You should have received a copy of the GNU General Public License
16 : : // along with GCC; see the file COPYING3. If not see
17 : : // <http://www.gnu.org/licenses/>.
18 : :
19 : : #include "rust-hir-expr.h"
20 : : #include "rust-operators.h"
21 : : #include "rust-hir-stmt.h"
22 : :
23 : : namespace Rust {
24 : : namespace HIR {
25 : :
26 : 113314 : Expr::Expr (Analysis::NodeMapping mappings, AST::AttrVec outer_attribs)
27 : 113314 : : outer_attrs (std::move (outer_attribs)), mappings (std::move (mappings))
28 : 113314 : {}
29 : :
30 : 89045 : ExprWithoutBlock::ExprWithoutBlock (Analysis::NodeMapping mappings,
31 : 0 : AST::AttrVec outer_attribs)
32 : 89045 : : Expr (std::move (mappings), std::move (outer_attribs))
33 : 89045 : {}
34 : :
35 : 36 : LoopLabel::LoopLabel (Analysis::NodeMapping mapping, Lifetime loop_label,
36 : 36 : location_t locus)
37 : 36 : : label (std::move (loop_label)), locus (locus), mappings (mapping)
38 : 36 : {}
39 : :
40 : 24269 : ExprWithBlock::ExprWithBlock (Analysis::NodeMapping mappings,
41 : 0 : AST::AttrVec outer_attrs)
42 : 24269 : : Expr (std::move (mappings), std::move (outer_attrs))
43 : 24269 : {}
44 : :
45 : 1127 : LiteralExpr::LiteralExpr (Analysis::NodeMapping mappings,
46 : : std::string value_as_string, Literal::LitType type,
47 : : PrimitiveCoreType type_hint, location_t locus,
48 : 1127 : AST::AttrVec outer_attrs)
49 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
50 : 1127 : literal (std::move (value_as_string), type, type_hint), locus (locus)
51 : 1127 : {}
52 : :
53 : 16442 : LiteralExpr::LiteralExpr (Analysis::NodeMapping mappings, Literal literal,
54 : 16442 : location_t locus, AST::AttrVec outer_attrs)
55 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
56 : 16442 : literal (std::move (literal)), locus (locus)
57 : 16442 : {}
58 : :
59 : 15036 : OperatorExpr::OperatorExpr (Analysis::NodeMapping mappings,
60 : : std::unique_ptr<Expr> main_or_left_expr,
61 : 0 : AST::AttrVec outer_attribs, location_t locus)
62 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
63 : 15036 : locus (locus), main_or_left_expr (std::move (main_or_left_expr))
64 : 15036 : {}
65 : :
66 : 96 : OperatorExpr::OperatorExpr (OperatorExpr const &other)
67 : 96 : : ExprWithoutBlock (other), locus (other.locus),
68 : 96 : main_or_left_expr (other.main_or_left_expr->clone_expr ())
69 : 96 : {}
70 : :
71 : : OperatorExpr &
72 : 0 : OperatorExpr::operator= (OperatorExpr const &other)
73 : : {
74 : 0 : ExprWithoutBlock::operator= (other);
75 : 0 : main_or_left_expr = other.main_or_left_expr->clone_expr ();
76 : 0 : locus = other.locus;
77 : : // outer_attrs = other.outer_attrs;
78 : :
79 : 0 : return *this;
80 : : }
81 : :
82 : 1411 : BorrowExpr::BorrowExpr (Analysis::NodeMapping mappings,
83 : : std::unique_ptr<Expr> borrow_lvalue, Mutability mut,
84 : 1411 : bool raw, AST::AttrVec outer_attribs, location_t locus)
85 : : : OperatorExpr (std::move (mappings), std::move (borrow_lvalue),
86 : : std::move (outer_attribs), locus),
87 : 1411 : mut (mut), raw (raw)
88 : 1411 : {}
89 : :
90 : 1864 : DereferenceExpr::DereferenceExpr (Analysis::NodeMapping mappings,
91 : : std::unique_ptr<Expr> deref_lvalue,
92 : 1864 : AST::AttrVec outer_attribs, location_t locus)
93 : : : OperatorExpr (std::move (mappings), std::move (deref_lvalue),
94 : 1864 : std::move (outer_attribs), locus)
95 : 1864 : {}
96 : :
97 : 0 : ErrorPropagationExpr::ErrorPropagationExpr (
98 : : Analysis::NodeMapping mappings, std::unique_ptr<Expr> potential_error_value,
99 : 0 : AST::AttrVec outer_attribs, location_t locus)
100 : : : OperatorExpr (std::move (mappings), std::move (potential_error_value),
101 : 0 : std::move (outer_attribs), locus)
102 : 0 : {}
103 : :
104 : 377 : NegationExpr::NegationExpr (Analysis::NodeMapping mappings,
105 : : std::unique_ptr<Expr> negated_value,
106 : : ExprType expr_kind, AST::AttrVec outer_attribs,
107 : 377 : location_t locus)
108 : : : OperatorExpr (std::move (mappings), std::move (negated_value),
109 : : std::move (outer_attribs), locus),
110 : 377 : expr_type (expr_kind)
111 : 377 : {}
112 : :
113 : 3154 : ArithmeticOrLogicalExpr::ArithmeticOrLogicalExpr (
114 : : Analysis::NodeMapping mappings, std::unique_ptr<Expr> left_value,
115 : 3154 : std::unique_ptr<Expr> right_value, ExprType expr_kind, location_t locus)
116 : 3154 : : OperatorExpr (std::move (mappings), std::move (left_value), AST::AttrVec (),
117 : : locus),
118 : 3154 : expr_type (expr_kind), right_expr (std::move (right_value))
119 : 3154 : {}
120 : :
121 : 46 : ArithmeticOrLogicalExpr::ArithmeticOrLogicalExpr (
122 : 46 : ArithmeticOrLogicalExpr const &other)
123 : 46 : : OperatorExpr (other), expr_type (other.expr_type),
124 : 46 : right_expr (other.right_expr->clone_expr ())
125 : 46 : {}
126 : :
127 : : ArithmeticOrLogicalExpr &
128 : 0 : ArithmeticOrLogicalExpr::operator= (ArithmeticOrLogicalExpr const &other)
129 : : {
130 : 0 : OperatorExpr::operator= (other);
131 : : // main_or_left_expr = other.main_or_left_expr->clone_expr();
132 : 0 : right_expr = other.right_expr->clone_expr ();
133 : 0 : expr_type = other.expr_type;
134 : :
135 : 0 : return *this;
136 : : }
137 : :
138 : 1106 : ComparisonExpr::ComparisonExpr (Analysis::NodeMapping mappings,
139 : : std::unique_ptr<Expr> left_value,
140 : : std::unique_ptr<Expr> right_value,
141 : 1106 : ExprType comparison_kind, location_t locus)
142 : 1106 : : OperatorExpr (std::move (mappings), std::move (left_value), AST::AttrVec (),
143 : : locus),
144 : 1106 : expr_type (comparison_kind), right_expr (std::move (right_value))
145 : 1106 : {}
146 : :
147 : 0 : ComparisonExpr::ComparisonExpr (ComparisonExpr const &other)
148 : 0 : : OperatorExpr (other), expr_type (other.expr_type),
149 : 0 : right_expr (other.right_expr->clone_expr ())
150 : 0 : {}
151 : :
152 : : ComparisonExpr &
153 : 0 : ComparisonExpr::operator= (ComparisonExpr const &other)
154 : : {
155 : 0 : OperatorExpr::operator= (other);
156 : : // main_or_left_expr = other.main_or_left_expr->clone_expr();
157 : 0 : right_expr = other.right_expr->clone_expr ();
158 : 0 : expr_type = other.expr_type;
159 : : // outer_attrs = other.outer_attrs;
160 : :
161 : 0 : return *this;
162 : : }
163 : :
164 : 323 : LazyBooleanExpr::LazyBooleanExpr (Analysis::NodeMapping mappings,
165 : : std::unique_ptr<Expr> left_bool_expr,
166 : : std::unique_ptr<Expr> right_bool_expr,
167 : 323 : ExprType expr_kind, location_t locus)
168 : : : OperatorExpr (std::move (mappings), std::move (left_bool_expr),
169 : 323 : AST::AttrVec (), locus),
170 : 323 : expr_type (expr_kind), right_expr (std::move (right_bool_expr))
171 : 323 : {}
172 : :
173 : 0 : LazyBooleanExpr::LazyBooleanExpr (LazyBooleanExpr const &other)
174 : 0 : : OperatorExpr (other), expr_type (other.expr_type),
175 : 0 : right_expr (other.right_expr->clone_expr ())
176 : 0 : {}
177 : :
178 : : LazyBooleanExpr &
179 : 0 : LazyBooleanExpr::operator= (LazyBooleanExpr const &other)
180 : : {
181 : 0 : OperatorExpr::operator= (other);
182 : : // main_or_left_expr = other.main_or_left_expr->clone_expr();
183 : 0 : right_expr = other.right_expr->clone_expr ();
184 : 0 : expr_type = other.expr_type;
185 : :
186 : 0 : return *this;
187 : : }
188 : :
189 : 4620 : TypeCastExpr::TypeCastExpr (Analysis::NodeMapping mappings,
190 : : std::unique_ptr<Expr> expr_to_cast,
191 : : std::unique_ptr<Type> type_to_cast_to,
192 : 4620 : location_t locus)
193 : : : OperatorExpr (std::move (mappings), std::move (expr_to_cast),
194 : 4620 : AST::AttrVec (), locus),
195 : 4620 : type_to_convert_to (std::move (type_to_cast_to))
196 : 4620 : {}
197 : :
198 : 0 : TypeCastExpr::TypeCastExpr (TypeCastExpr const &other)
199 : : : OperatorExpr (other),
200 : 0 : type_to_convert_to (other.type_to_convert_to->clone_type ())
201 : 0 : {}
202 : :
203 : : TypeCastExpr &
204 : 0 : TypeCastExpr::operator= (TypeCastExpr const &other)
205 : : {
206 : 0 : OperatorExpr::operator= (other);
207 : : // main_or_left_expr = other.main_or_left_expr->clone_expr();
208 : 0 : type_to_convert_to = other.type_to_convert_to->clone_type ();
209 : :
210 : 0 : return *this;
211 : : }
212 : :
213 : 1940 : AssignmentExpr::AssignmentExpr (Analysis::NodeMapping mappings,
214 : : std::unique_ptr<Expr> value_to_assign_to,
215 : : std::unique_ptr<Expr> value_to_assign,
216 : 1940 : location_t locus)
217 : : : OperatorExpr (std::move (mappings), std::move (value_to_assign_to),
218 : 1940 : AST::AttrVec (), locus),
219 : 1940 : right_expr (std::move (value_to_assign))
220 : 1940 : {}
221 : :
222 : 0 : AssignmentExpr::AssignmentExpr (AssignmentExpr const &other)
223 : 0 : : OperatorExpr (other), right_expr (other.right_expr->clone_expr ())
224 : 0 : {}
225 : :
226 : : AssignmentExpr &
227 : 0 : AssignmentExpr::operator= (AssignmentExpr const &other)
228 : : {
229 : 0 : OperatorExpr::operator= (other);
230 : : // main_or_left_expr = other.main_or_left_expr->clone_expr();
231 : 0 : right_expr = other.right_expr->clone_expr ();
232 : : // outer_attrs = other.outer_attrs;
233 : :
234 : 0 : return *this;
235 : : }
236 : :
237 : 241 : CompoundAssignmentExpr::CompoundAssignmentExpr (
238 : : Analysis::NodeMapping mappings, std::unique_ptr<Expr> value_to_assign_to,
239 : 241 : std::unique_ptr<Expr> value_to_assign, ExprType expr_kind, location_t locus)
240 : : : OperatorExpr (std::move (mappings), std::move (value_to_assign_to),
241 : 241 : AST::AttrVec (), locus),
242 : 241 : expr_type (expr_kind), right_expr (std::move (value_to_assign))
243 : 241 : {}
244 : :
245 : 0 : CompoundAssignmentExpr::CompoundAssignmentExpr (
246 : 0 : CompoundAssignmentExpr const &other)
247 : 0 : : OperatorExpr (other), expr_type (other.expr_type),
248 : 0 : right_expr (other.right_expr->clone_expr ())
249 : 0 : {}
250 : :
251 : : CompoundAssignmentExpr &
252 : 0 : CompoundAssignmentExpr::operator= (CompoundAssignmentExpr const &other)
253 : : {
254 : 0 : OperatorExpr::operator= (other);
255 : : // main_or_left_expr = other.main_or_left_expr->clone_expr();
256 : 0 : right_expr = other.right_expr->clone_expr ();
257 : 0 : expr_type = other.expr_type;
258 : : // outer_attrs = other.outer_attrs;
259 : :
260 : 0 : return *this;
261 : : }
262 : :
263 : 250 : GroupedExpr::GroupedExpr (Analysis::NodeMapping mappings,
264 : : std::unique_ptr<Expr> parenthesised_expr,
265 : : AST::AttrVec inner_attribs,
266 : 250 : AST::AttrVec outer_attribs, location_t locus)
267 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
268 : : WithInnerAttrs (std::move (inner_attribs)),
269 : 250 : expr_in_parens (std::move (parenthesised_expr)), locus (locus)
270 : 250 : {}
271 : :
272 : 0 : GroupedExpr::GroupedExpr (GroupedExpr const &other)
273 : 0 : : ExprWithoutBlock (other), WithInnerAttrs (other.inner_attrs),
274 : 0 : expr_in_parens (other.expr_in_parens->clone_expr ()), locus (other.locus)
275 : 0 : {}
276 : :
277 : : GroupedExpr &
278 : 0 : GroupedExpr::operator= (GroupedExpr const &other)
279 : : {
280 : 0 : ExprWithoutBlock::operator= (other);
281 : 0 : inner_attrs = other.inner_attrs;
282 : 0 : expr_in_parens = other.expr_in_parens->clone_expr ();
283 : 0 : locus = other.locus;
284 : : // outer_attrs = other.outer_attrs;
285 : :
286 : 0 : return *this;
287 : : }
288 : :
289 : 275 : ArrayElemsValues::ArrayElemsValues (Analysis::NodeMapping mappings,
290 : 275 : std::vector<std::unique_ptr<Expr>> elems)
291 : 275 : : ArrayElems (mappings), values (std::move (elems))
292 : 275 : {}
293 : :
294 : 0 : ArrayElemsValues::ArrayElemsValues (ArrayElemsValues const &other)
295 : 0 : : ArrayElems (other)
296 : : {
297 : 0 : values.reserve (other.values.size ());
298 : 0 : for (const auto &e : other.values)
299 : 0 : values.push_back (e->clone_expr ());
300 : 0 : }
301 : :
302 : : ArrayElemsValues &
303 : 0 : ArrayElemsValues::operator= (ArrayElemsValues const &other)
304 : : {
305 : 0 : values.reserve (other.values.size ());
306 : 0 : for (const auto &e : other.values)
307 : 0 : values.push_back (e->clone_expr ());
308 : :
309 : 0 : return *this;
310 : : }
311 : :
312 : 131 : ArrayElemsCopied::ArrayElemsCopied (Analysis::NodeMapping mappings,
313 : : std::unique_ptr<Expr> copied_elem,
314 : 131 : std::unique_ptr<Expr> copy_amount)
315 : 131 : : ArrayElems (mappings), elem_to_copy (std::move (copied_elem)),
316 : 131 : num_copies (std::move (copy_amount))
317 : 131 : {}
318 : :
319 : 0 : ArrayElemsCopied::ArrayElemsCopied (ArrayElemsCopied const &other)
320 : 0 : : ArrayElems (other), elem_to_copy (other.elem_to_copy->clone_expr ()),
321 : 0 : num_copies (other.num_copies->clone_expr ())
322 : 0 : {}
323 : :
324 : : ArrayElemsCopied &
325 : 0 : ArrayElemsCopied::operator= (ArrayElemsCopied const &other)
326 : : {
327 : 0 : elem_to_copy = other.elem_to_copy->clone_expr ();
328 : 0 : num_copies = other.num_copies->clone_expr ();
329 : :
330 : 0 : return *this;
331 : : }
332 : :
333 : 406 : ArrayExpr::ArrayExpr (Analysis::NodeMapping mappings,
334 : : std::unique_ptr<ArrayElems> array_elems,
335 : : AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
336 : 406 : location_t locus)
337 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
338 : : WithInnerAttrs (std::move (inner_attribs)),
339 : 406 : internal_elements (std::move (array_elems)), locus (locus)
340 : 406 : {}
341 : :
342 : 0 : ArrayExpr::ArrayExpr (ArrayExpr const &other)
343 : 0 : : ExprWithoutBlock (other), WithInnerAttrs (other.inner_attrs),
344 : 0 : locus (other.locus)
345 : : {
346 : 0 : if (other.has_array_elems ())
347 : 0 : internal_elements = other.internal_elements->clone_array_elems ();
348 : 0 : }
349 : :
350 : : ArrayExpr &
351 : 0 : ArrayExpr::operator= (ArrayExpr const &other)
352 : : {
353 : 0 : ExprWithoutBlock::operator= (other);
354 : 0 : inner_attrs = other.inner_attrs;
355 : 0 : if (other.has_array_elems ())
356 : 0 : internal_elements = other.internal_elements->clone_array_elems ();
357 : 0 : locus = other.locus;
358 : : // outer_attrs = other.outer_attrs;
359 : :
360 : 0 : return *this;
361 : : }
362 : :
363 : 237 : ArrayIndexExpr::ArrayIndexExpr (Analysis::NodeMapping mappings,
364 : : std::unique_ptr<Expr> array_expr,
365 : : std::unique_ptr<Expr> array_index_expr,
366 : 237 : AST::AttrVec outer_attribs, location_t locus)
367 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
368 : 237 : array_expr (std::move (array_expr)),
369 : 237 : index_expr (std::move (array_index_expr)), locus (locus)
370 : 237 : {}
371 : :
372 : 0 : ArrayIndexExpr::ArrayIndexExpr (ArrayIndexExpr const &other)
373 : 0 : : ExprWithoutBlock (other), array_expr (other.array_expr->clone_expr ()),
374 : 0 : index_expr (other.index_expr->clone_expr ()), locus (other.locus)
375 : 0 : {}
376 : :
377 : : ArrayIndexExpr &
378 : 0 : ArrayIndexExpr::operator= (ArrayIndexExpr const &other)
379 : : {
380 : 0 : ExprWithoutBlock::operator= (other);
381 : 0 : array_expr = other.array_expr->clone_expr ();
382 : 0 : index_expr = other.index_expr->clone_expr ();
383 : : // outer_attrs = other.outer_attrs;
384 : 0 : locus = other.locus;
385 : :
386 : 0 : return *this;
387 : : }
388 : :
389 : 579 : TupleExpr::TupleExpr (Analysis::NodeMapping mappings,
390 : : std::vector<std::unique_ptr<Expr>> tuple_elements,
391 : : AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
392 : 579 : location_t locus)
393 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
394 : : WithInnerAttrs (std::move (inner_attribs)),
395 : 579 : tuple_elems (std::move (tuple_elements)), locus (locus)
396 : 579 : {}
397 : :
398 : 0 : TupleExpr::TupleExpr (TupleExpr const &other)
399 : 0 : : ExprWithoutBlock (other), WithInnerAttrs (other.inner_attrs),
400 : 0 : locus (other.locus)
401 : : {
402 : 0 : tuple_elems.reserve (other.tuple_elems.size ());
403 : 0 : for (const auto &e : other.tuple_elems)
404 : 0 : tuple_elems.push_back (e->clone_expr ());
405 : 0 : }
406 : :
407 : : TupleExpr &
408 : 0 : TupleExpr::operator= (TupleExpr const &other)
409 : : {
410 : 0 : ExprWithoutBlock::operator= (other);
411 : 0 : inner_attrs = other.inner_attrs;
412 : 0 : locus = other.locus;
413 : :
414 : 0 : tuple_elems.reserve (other.tuple_elems.size ());
415 : 0 : for (const auto &e : other.tuple_elems)
416 : 0 : tuple_elems.push_back (e->clone_expr ());
417 : :
418 : 0 : return *this;
419 : : }
420 : :
421 : 880 : TupleIndexExpr::TupleIndexExpr (Analysis::NodeMapping mappings,
422 : : std::unique_ptr<Expr> tuple_expr,
423 : : TupleIndex index, AST::AttrVec outer_attribs,
424 : 880 : location_t locus)
425 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
426 : 880 : tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus)
427 : 880 : {}
428 : :
429 : 0 : TupleIndexExpr::TupleIndexExpr (TupleIndexExpr const &other)
430 : 0 : : ExprWithoutBlock (other), tuple_expr (other.tuple_expr->clone_expr ()),
431 : 0 : tuple_index (other.tuple_index), locus (other.locus)
432 : 0 : {}
433 : :
434 : : TupleIndexExpr &
435 : 0 : TupleIndexExpr::operator= (TupleIndexExpr const &other)
436 : : {
437 : 0 : ExprWithoutBlock::operator= (other);
438 : 0 : tuple_expr = other.tuple_expr->clone_expr ();
439 : 0 : tuple_index = other.tuple_index;
440 : 0 : locus = other.locus;
441 : : // outer_attrs = other.outer_attrs;
442 : :
443 : 0 : return *this;
444 : : }
445 : :
446 : 1161 : StructExpr::StructExpr (Analysis::NodeMapping mappings,
447 : : PathInExpression struct_path,
448 : 0 : AST::AttrVec outer_attribs)
449 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
450 : 1161 : struct_name (std::move (struct_path))
451 : 1161 : {}
452 : :
453 : 1161 : StructExprStruct::StructExprStruct (Analysis::NodeMapping mappings,
454 : : PathInExpression struct_path,
455 : : AST::AttrVec inner_attribs,
456 : : AST::AttrVec outer_attribs,
457 : 63 : location_t locus)
458 : : : StructExpr (std::move (mappings), std::move (struct_path),
459 : : std::move (outer_attribs)),
460 : 1161 : WithInnerAttrs (std::move (inner_attribs)), locus (locus)
461 : 1161 : {}
462 : :
463 : 72 : StructBase::StructBase (std::unique_ptr<Expr> base_struct_ptr)
464 : 72 : : base_struct (std::move (base_struct_ptr))
465 : 72 : {}
466 : :
467 : 0 : StructBase::StructBase (StructBase const &other)
468 : : {
469 : : /* HACK: gets around base_struct pointer being null (e.g. if no struct base
470 : : * exists) */
471 : 0 : if (other.base_struct != nullptr)
472 : 0 : other.base_struct->clone_expr ();
473 : 0 : }
474 : :
475 : : StructBase &
476 : 0 : StructBase::operator= (StructBase const &other)
477 : : {
478 : 0 : base_struct = other.base_struct->clone_expr ();
479 : :
480 : 0 : return *this;
481 : : }
482 : :
483 : 2686 : StructExprField::StructExprField (Analysis::NodeMapping mapping,
484 : 2686 : location_t locus)
485 : 2686 : : mappings (mapping), locus (locus)
486 : 2686 : {}
487 : :
488 : 234 : StructExprFieldIdentifier::StructExprFieldIdentifier (
489 : 234 : Analysis::NodeMapping mapping, Identifier field_identifier, location_t locus)
490 : 234 : : StructExprField (mapping, locus), field_name (std::move (field_identifier))
491 : 234 : {}
492 : :
493 : 2452 : StructExprFieldWithVal::StructExprFieldWithVal (
494 : : Analysis::NodeMapping mapping, std::unique_ptr<Expr> field_value,
495 : 2452 : location_t locus)
496 : 2452 : : StructExprField (mapping, locus), value (std::move (field_value))
497 : 2452 : {}
498 : :
499 : 0 : StructExprFieldWithVal::StructExprFieldWithVal (
500 : 0 : StructExprFieldWithVal const &other)
501 : 0 : : StructExprField (other.mappings, other.locus),
502 : 0 : value (other.value->clone_expr ())
503 : 0 : {}
504 : :
505 : : StructExprFieldWithVal &
506 : 0 : StructExprFieldWithVal::operator= (StructExprFieldWithVal const &other)
507 : : {
508 : 0 : value = other.value->clone_expr ();
509 : 0 : mappings = other.mappings;
510 : 0 : locus = other.locus;
511 : :
512 : 0 : return *this;
513 : : }
514 : :
515 : 2400 : StructExprFieldIdentifierValue::StructExprFieldIdentifierValue (
516 : : Analysis::NodeMapping mapping, Identifier field_identifier,
517 : 2400 : std::unique_ptr<Expr> field_value, location_t locus)
518 : : : StructExprFieldWithVal (mapping, std::move (field_value), locus),
519 : 2400 : field_name (std::move (field_identifier))
520 : 2400 : {}
521 : :
522 : 52 : StructExprFieldIndexValue::StructExprFieldIndexValue (
523 : : Analysis::NodeMapping mapping, TupleIndex tuple_index,
524 : 52 : std::unique_ptr<Expr> field_value, location_t locus)
525 : : : StructExprFieldWithVal (mapping, std::move (field_value), locus),
526 : 52 : index (tuple_index)
527 : 52 : {}
528 : :
529 : 1098 : StructExprStructFields::StructExprStructFields (
530 : : Analysis::NodeMapping mappings, PathInExpression struct_path,
531 : : std::vector<std::unique_ptr<StructExprField>> expr_fields, location_t locus,
532 : : tl::optional<std::unique_ptr<StructBase>> base_struct,
533 : : AST::AttrVec inner_attribs = AST::AttrVec (),
534 : 1098 : AST::AttrVec outer_attribs = AST::AttrVec ())
535 : : : StructExprStruct (std::move (mappings), std::move (struct_path),
536 : : std::move (inner_attribs), std::move (outer_attribs),
537 : : locus),
538 : 1098 : fields (std::move (expr_fields)), struct_base (std::move (base_struct))
539 : 1098 : {}
540 : :
541 : 0 : StructExprStructFields::StructExprStructFields (
542 : 0 : StructExprStructFields const &other)
543 : : : StructExprStruct (other),
544 : 0 : struct_base (other.has_struct_base ()
545 : 0 : ? tl::optional<std::unique_ptr<StructBase>> (
546 : 0 : std::make_unique<StructBase> (*other.struct_base.value ()))
547 : : : tl::nullopt),
548 : 0 : union_index (other.union_index)
549 : : {
550 : 0 : fields.reserve (other.fields.size ());
551 : 0 : for (const auto &e : other.fields)
552 : 0 : fields.push_back (e->clone_struct_expr_field ());
553 : 0 : }
554 : :
555 : : StructExprStructFields &
556 : 0 : StructExprStructFields::operator= (StructExprStructFields const &other)
557 : : {
558 : 0 : StructExprStruct::operator= (other);
559 : 0 : struct_base = other.has_struct_base ()
560 : 0 : ? tl::optional<std::unique_ptr<StructBase>> (
561 : 0 : std::make_unique<StructBase> (*other.struct_base.value ()))
562 : 0 : : tl::nullopt;
563 : 0 : union_index = other.union_index;
564 : :
565 : 0 : fields.reserve (other.fields.size ());
566 : 0 : for (const auto &e : other.fields)
567 : 0 : fields.push_back (e->clone_struct_expr_field ());
568 : :
569 : 0 : return *this;
570 : : }
571 : :
572 : 0 : StructExprStructBase::StructExprStructBase (Analysis::NodeMapping mappings,
573 : : PathInExpression struct_path,
574 : : StructBase base_struct,
575 : : AST::AttrVec inner_attribs,
576 : : AST::AttrVec outer_attribs,
577 : 0 : location_t locus)
578 : : : StructExprStruct (std::move (mappings), std::move (struct_path),
579 : : std::move (inner_attribs), std::move (outer_attribs),
580 : : locus),
581 : 0 : struct_base (std::move (base_struct))
582 : 0 : {}
583 : :
584 : 10057 : CallExpr::CallExpr (Analysis::NodeMapping mappings,
585 : : std::unique_ptr<Expr> function_expr,
586 : : std::vector<std::unique_ptr<Expr>> function_params,
587 : 10057 : AST::AttrVec outer_attribs, location_t locus)
588 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
589 : 10057 : function (std::move (function_expr)), params (std::move (function_params)),
590 : 10057 : locus (locus)
591 : 10057 : {}
592 : :
593 : 10 : CallExpr::CallExpr (CallExpr const &other)
594 : 20 : : ExprWithoutBlock (other), function (other.function->clone_expr ()),
595 : 10 : locus (other.locus)
596 : : /*, params(other.params),*/ {
597 : 10 : params.reserve (other.params.size ());
598 : 10 : for (const auto &e : other.params)
599 : 0 : params.push_back (e->clone_expr ());
600 : 10 : }
601 : :
602 : : CallExpr &
603 : 0 : CallExpr::operator= (CallExpr const &other)
604 : : {
605 : 0 : ExprWithoutBlock::operator= (other);
606 : 0 : function = other.function->clone_expr ();
607 : 0 : locus = other.locus;
608 : : // params = other.params;
609 : : // outer_attrs = other.outer_attrs;
610 : :
611 : 0 : params.reserve (other.params.size ());
612 : 0 : for (const auto &e : other.params)
613 : 0 : params.push_back (e->clone_expr ());
614 : :
615 : 0 : return *this;
616 : : }
617 : :
618 : 1564 : MethodCallExpr::MethodCallExpr (
619 : : Analysis::NodeMapping mappings, std::unique_ptr<Expr> call_receiver,
620 : : PathExprSegment method_path, std::vector<std::unique_ptr<Expr>> method_params,
621 : 1564 : AST::AttrVec outer_attribs, location_t locus)
622 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
623 : 1564 : receiver (std::move (call_receiver)), method_name (std::move (method_path)),
624 : 1564 : params (std::move (method_params)), locus (locus)
625 : 1564 : {}
626 : :
627 : 0 : MethodCallExpr::MethodCallExpr (MethodCallExpr const &other)
628 : 0 : : ExprWithoutBlock (other), receiver (other.receiver->clone_expr ()),
629 : 0 : method_name (other.method_name), locus (other.locus)
630 : : /*, params(other.params),*/ {
631 : 0 : params.reserve (other.params.size ());
632 : 0 : for (const auto &e : other.params)
633 : 0 : params.push_back (e->clone_expr ());
634 : 0 : }
635 : :
636 : : MethodCallExpr &
637 : 0 : MethodCallExpr::operator= (MethodCallExpr const &other)
638 : : {
639 : 0 : ExprWithoutBlock::operator= (other);
640 : 0 : receiver = other.receiver->clone_expr ();
641 : 0 : method_name = other.method_name;
642 : 0 : locus = other.locus;
643 : : // params = other.params;
644 : : // outer_attrs = other.outer_attrs;
645 : :
646 : 0 : params.reserve (other.params.size ());
647 : 0 : for (const auto &e : other.params)
648 : 0 : params.push_back (e->clone_expr ());
649 : :
650 : 0 : return *this;
651 : : }
652 : :
653 : 2511 : FieldAccessExpr::FieldAccessExpr (Analysis::NodeMapping mappings,
654 : : std::unique_ptr<Expr> field_access_receiver,
655 : : Identifier field_name,
656 : 2511 : AST::AttrVec outer_attribs, location_t locus)
657 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
658 : 2511 : receiver (std::move (field_access_receiver)),
659 : 2511 : field (std::move (field_name)), locus (locus)
660 : 2511 : {}
661 : :
662 : 0 : FieldAccessExpr::FieldAccessExpr (FieldAccessExpr const &other)
663 : 0 : : ExprWithoutBlock (other), receiver (other.receiver->clone_expr ()),
664 : 0 : field (other.field), locus (other.locus)
665 : 0 : {}
666 : :
667 : : FieldAccessExpr &
668 : 0 : FieldAccessExpr::operator= (FieldAccessExpr const &other)
669 : : {
670 : 0 : ExprWithoutBlock::operator= (other);
671 : 0 : receiver = other.receiver->clone_expr ();
672 : 0 : field = other.field;
673 : 0 : locus = other.locus;
674 : : // outer_attrs = other.outer_attrs;
675 : :
676 : 0 : return *this;
677 : : }
678 : :
679 : 57 : ClosureParam::ClosureParam (std::unique_ptr<Pattern> param_pattern,
680 : : location_t locus, std::unique_ptr<Type> param_type,
681 : 57 : std::vector<AST::Attribute> outer_attrs)
682 : 57 : : outer_attrs (std::move (outer_attrs)), pattern (std::move (param_pattern)),
683 : 57 : type (std::move (param_type)), locus (locus)
684 : 57 : {}
685 : :
686 : 0 : ClosureParam::ClosureParam (ClosureParam const &other)
687 : 0 : : pattern (other.pattern->clone_pattern ())
688 : : {
689 : : // guard to protect from null pointer dereference
690 : 0 : if (other.pattern != nullptr)
691 : 0 : pattern = other.pattern->clone_pattern ();
692 : 0 : if (other.type != nullptr)
693 : 0 : type = other.type->clone_type ();
694 : 0 : }
695 : :
696 : : ClosureParam &
697 : 0 : ClosureParam::operator= (ClosureParam const &other)
698 : : {
699 : 0 : outer_attrs = other.outer_attrs;
700 : :
701 : : // guard to protect from null pointer dereference
702 : 0 : if (other.pattern != nullptr)
703 : 0 : pattern = other.pattern->clone_pattern ();
704 : : else
705 : 0 : pattern = nullptr;
706 : 0 : if (other.type != nullptr)
707 : 0 : type = other.type->clone_type ();
708 : : else
709 : 0 : type = nullptr;
710 : :
711 : 0 : return *this;
712 : : }
713 : :
714 : 61 : ClosureExpr::ClosureExpr (Analysis::NodeMapping mappings,
715 : : std::vector<ClosureParam> closure_params,
716 : : std::unique_ptr<Type> closure_return_type,
717 : : std::unique_ptr<Expr> closure_expr, bool has_move,
718 : 61 : AST::AttrVec outer_attribs, location_t locus)
719 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
720 : 61 : has_move (has_move), params (std::move (closure_params)), locus (locus),
721 : 61 : return_type (std::move (closure_return_type)),
722 : 61 : expr (std::move (closure_expr))
723 : 61 : {}
724 : :
725 : 0 : ClosureExpr::ClosureExpr (ClosureExpr const &other)
726 : 0 : : ExprWithoutBlock (other.get_mappings (), other.get_outer_attrs ())
727 : : {
728 : 0 : return_type
729 : 0 : = other.has_return_type () ? other.return_type->clone_type () : nullptr;
730 : 0 : expr = other.expr->clone_expr ();
731 : 0 : params = other.params;
732 : 0 : has_move = other.has_move;
733 : 0 : }
734 : :
735 : : ClosureExpr &
736 : 0 : ClosureExpr::operator= (ClosureExpr const &other)
737 : : {
738 : 0 : mappings = other.mappings;
739 : 0 : return_type
740 : 0 : = other.has_return_type () ? other.return_type->clone_type () : nullptr;
741 : 0 : expr = other.expr->clone_expr ();
742 : 0 : params = other.params;
743 : 0 : has_move = other.has_move;
744 : :
745 : 0 : return *this;
746 : : }
747 : :
748 : 19160 : BlockExpr::BlockExpr (Analysis::NodeMapping mappings,
749 : : std::vector<std::unique_ptr<Stmt>> block_statements,
750 : : std::unique_ptr<Expr> block_expr, bool tail_reachable,
751 : : AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
752 : : tl::optional<LoopLabel> label, location_t start_locus,
753 : 19160 : location_t end_locus)
754 : : : ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
755 : : WithInnerAttrs (std::move (inner_attribs)),
756 : 19160 : statements (std::move (block_statements)), expr (std::move (block_expr)),
757 : 19160 : tail_reachable (tail_reachable), label (std::move (label)),
758 : 19160 : start_locus (start_locus), end_locus (end_locus)
759 : 19160 : {}
760 : :
761 : 44 : BlockExpr::BlockExpr (BlockExpr const &other)
762 : : : ExprWithBlock (other), /*statements(other.statements),*/
763 : 44 : WithInnerAttrs (other.inner_attrs), label (other.label),
764 : 44 : start_locus (other.start_locus), end_locus (other.end_locus)
765 : : {
766 : : // guard to protect from null pointer dereference
767 : 44 : if (other.expr != nullptr)
768 : 42 : expr = other.expr->clone_expr ();
769 : :
770 : 44 : statements.reserve (other.statements.size ());
771 : 50 : for (const auto &e : other.statements)
772 : 6 : statements.push_back (e->clone_stmt ());
773 : 44 : }
774 : :
775 : : BlockExpr &
776 : 0 : BlockExpr::operator= (BlockExpr const &other)
777 : : {
778 : 0 : ExprWithBlock::operator= (other);
779 : : // statements = other.statements;
780 : 0 : expr = other.expr->clone_expr ();
781 : 0 : inner_attrs = other.inner_attrs;
782 : 0 : start_locus = other.end_locus;
783 : 0 : end_locus = other.end_locus;
784 : : // outer_attrs = other.outer_attrs;
785 : :
786 : 0 : statements.reserve (other.statements.size ());
787 : 0 : for (const auto &e : other.statements)
788 : 0 : statements.push_back (e->clone_stmt ());
789 : :
790 : 0 : return *this;
791 : : }
792 : :
793 : 12 : ContinueExpr::ContinueExpr (Analysis::NodeMapping mappings, location_t locus,
794 : : tl::optional<Lifetime> label,
795 : 12 : AST::AttrVec outer_attribs)
796 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
797 : 12 : label (std::move (label)), locus (locus)
798 : 12 : {}
799 : :
800 : 94 : BreakExpr::BreakExpr (Analysis::NodeMapping mappings, location_t locus,
801 : : tl::optional<Lifetime> break_label,
802 : : std::unique_ptr<Expr> expr_in_break,
803 : 94 : AST::AttrVec outer_attribs)
804 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
805 : 188 : label (std::move (break_label)), break_expr (std::move (expr_in_break)),
806 : 94 : locus (locus)
807 : 94 : {}
808 : :
809 : 0 : BreakExpr::BreakExpr (BreakExpr const &other)
810 : 0 : : ExprWithoutBlock (other), label (other.label), locus (other.locus)
811 : : {
812 : : // guard to protect from null pointer dereference
813 : 0 : if (other.break_expr != nullptr)
814 : 0 : break_expr = other.break_expr->clone_expr ();
815 : 0 : }
816 : :
817 : : BreakExpr &
818 : 0 : BreakExpr::operator= (BreakExpr const &other)
819 : : {
820 : 0 : ExprWithoutBlock::operator= (other);
821 : 0 : label = other.label;
822 : 0 : break_expr = other.break_expr->clone_expr ();
823 : 0 : locus = other.locus;
824 : : // outer_attrs = other.outer_attrs;
825 : :
826 : 0 : return *this;
827 : : }
828 : :
829 : 94 : RangeExpr::RangeExpr (Analysis::NodeMapping mappings, location_t locus)
830 : 94 : : ExprWithoutBlock (std::move (mappings), AST::AttrVec ()), locus (locus)
831 : 94 : {}
832 : :
833 : 70 : RangeFromToExpr::RangeFromToExpr (Analysis::NodeMapping mappings,
834 : : std::unique_ptr<Expr> range_from,
835 : : std::unique_ptr<Expr> range_to,
836 : 70 : location_t locus)
837 : 70 : : RangeExpr (std::move (mappings), locus), from (std::move (range_from)),
838 : 70 : to (std::move (range_to))
839 : 70 : {}
840 : :
841 : 0 : RangeFromToExpr::RangeFromToExpr (RangeFromToExpr const &other)
842 : 0 : : RangeExpr (other), from (other.from->clone_expr ()),
843 : 0 : to (other.to->clone_expr ())
844 : 0 : {}
845 : :
846 : : RangeFromToExpr &
847 : 0 : RangeFromToExpr::operator= (RangeFromToExpr const &other)
848 : : {
849 : 0 : RangeExpr::operator= (other);
850 : 0 : from = other.from->clone_expr ();
851 : 0 : to = other.to->clone_expr ();
852 : :
853 : 0 : return *this;
854 : : }
855 : :
856 : 8 : RangeFromExpr::RangeFromExpr (Analysis::NodeMapping mappings,
857 : : std::unique_ptr<Expr> range_from,
858 : 8 : location_t locus)
859 : 8 : : RangeExpr (std::move (mappings), locus), from (std::move (range_from))
860 : 8 : {}
861 : :
862 : 0 : RangeFromExpr::RangeFromExpr (RangeFromExpr const &other)
863 : 0 : : RangeExpr (other), from (other.from->clone_expr ())
864 : 0 : {}
865 : :
866 : : RangeFromExpr &
867 : 0 : RangeFromExpr::operator= (RangeFromExpr const &other)
868 : : {
869 : 0 : RangeExpr::operator= (other);
870 : 0 : from = other.from->clone_expr ();
871 : :
872 : 0 : return *this;
873 : : }
874 : :
875 : 8 : RangeToExpr::RangeToExpr (Analysis::NodeMapping mappings,
876 : 8 : std::unique_ptr<Expr> range_to, location_t locus)
877 : 8 : : RangeExpr (std::move (mappings), locus), to (std::move (range_to))
878 : 8 : {}
879 : :
880 : 0 : RangeToExpr::RangeToExpr (RangeToExpr const &other)
881 : 0 : : RangeExpr (other), to (other.to->clone_expr ())
882 : 0 : {}
883 : :
884 : : RangeToExpr &
885 : 0 : RangeToExpr::operator= (RangeToExpr const &other)
886 : : {
887 : 0 : RangeExpr::operator= (other);
888 : 0 : to = other.to->clone_expr ();
889 : :
890 : 0 : return *this;
891 : : }
892 : :
893 : 0 : RangeFullExpr::RangeFullExpr (Analysis::NodeMapping mappings, location_t locus)
894 : 0 : : RangeExpr (std::move (mappings), locus)
895 : 0 : {}
896 : :
897 : 8 : RangeFromToInclExpr::RangeFromToInclExpr (Analysis::NodeMapping mappings,
898 : : std::unique_ptr<Expr> range_from,
899 : : std::unique_ptr<Expr> range_to,
900 : 8 : location_t locus)
901 : 8 : : RangeExpr (std::move (mappings), locus), from (std::move (range_from)),
902 : 8 : to (std::move (range_to))
903 : 8 : {}
904 : :
905 : 0 : RangeFromToInclExpr::RangeFromToInclExpr (RangeFromToInclExpr const &other)
906 : 0 : : RangeExpr (other), from (other.from->clone_expr ()),
907 : 0 : to (other.to->clone_expr ())
908 : 0 : {}
909 : :
910 : : RangeFromToInclExpr &
911 : 0 : RangeFromToInclExpr::operator= (RangeFromToInclExpr const &other)
912 : : {
913 : 0 : RangeExpr::operator= (other);
914 : 0 : from = other.from->clone_expr ();
915 : 0 : to = other.to->clone_expr ();
916 : :
917 : 0 : return *this;
918 : : }
919 : :
920 : 0 : RangeToInclExpr::RangeToInclExpr (Analysis::NodeMapping mappings,
921 : : std::unique_ptr<Expr> range_to,
922 : 0 : location_t locus)
923 : 0 : : RangeExpr (std::move (mappings), locus), to (std::move (range_to))
924 : 0 : {}
925 : :
926 : 0 : RangeToInclExpr::RangeToInclExpr (RangeToInclExpr const &other)
927 : 0 : : RangeExpr (other), to (other.to->clone_expr ())
928 : 0 : {}
929 : :
930 : : RangeToInclExpr &
931 : 0 : RangeToInclExpr::operator= (RangeToInclExpr const &other)
932 : : {
933 : 0 : RangeExpr::operator= (other);
934 : 0 : to = other.to->clone_expr ();
935 : :
936 : 0 : return *this;
937 : : }
938 : :
939 : 557 : ReturnExpr::ReturnExpr (Analysis::NodeMapping mappings, location_t locus,
940 : : std::unique_ptr<Expr> returned_expr,
941 : 557 : AST::AttrVec outer_attribs)
942 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
943 : 557 : return_expr (std::move (returned_expr)), locus (locus)
944 : 557 : {}
945 : :
946 : 0 : ReturnExpr::ReturnExpr (ReturnExpr const &other)
947 : 0 : : ExprWithoutBlock (other), locus (other.locus)
948 : : {
949 : : // guard to protect from null pointer dereference
950 : 0 : if (other.return_expr != nullptr)
951 : 0 : return_expr = other.return_expr->clone_expr ();
952 : 0 : }
953 : :
954 : : ReturnExpr &
955 : 0 : ReturnExpr::operator= (ReturnExpr const &other)
956 : : {
957 : 0 : ExprWithoutBlock::operator= (other);
958 : 0 : return_expr = other.return_expr->clone_expr ();
959 : 0 : locus = other.locus;
960 : : // outer_attrs = other.outer_attrs;
961 : :
962 : 0 : return *this;
963 : : }
964 : :
965 : 3434 : UnsafeBlockExpr::UnsafeBlockExpr (Analysis::NodeMapping mappings,
966 : : std::unique_ptr<BlockExpr> block_expr,
967 : 3434 : AST::AttrVec outer_attribs, location_t locus)
968 : : : ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
969 : 3434 : expr (std::move (block_expr)), locus (locus)
970 : 3434 : {}
971 : :
972 : 0 : UnsafeBlockExpr::UnsafeBlockExpr (UnsafeBlockExpr const &other)
973 : 0 : : ExprWithBlock (other), expr (other.expr->clone_block_expr ()),
974 : 0 : locus (other.locus)
975 : 0 : {}
976 : :
977 : : UnsafeBlockExpr &
978 : 0 : UnsafeBlockExpr::operator= (UnsafeBlockExpr const &other)
979 : : {
980 : 0 : ExprWithBlock::operator= (other);
981 : 0 : expr = other.expr->clone_block_expr ();
982 : 0 : locus = other.locus;
983 : : // outer_attrs = other.outer_attrs;
984 : :
985 : 0 : return *this;
986 : : }
987 : :
988 : 194 : BaseLoopExpr::BaseLoopExpr (Analysis::NodeMapping mappings,
989 : : std::unique_ptr<BlockExpr> loop_block,
990 : : location_t locus,
991 : : tl::optional<LoopLabel> loop_label,
992 : 0 : AST::AttrVec outer_attribs)
993 : : : ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
994 : 388 : loop_label (std::move (loop_label)), loop_block (std::move (loop_block)),
995 : 194 : locus (locus)
996 : 194 : {}
997 : :
998 : 0 : BaseLoopExpr::BaseLoopExpr (BaseLoopExpr const &other)
999 : 0 : : ExprWithBlock (other), loop_label (other.loop_label),
1000 : 0 : loop_block (other.loop_block->clone_block_expr ()), locus (other.locus)
1001 : 0 : {}
1002 : :
1003 : : BaseLoopExpr &
1004 : 0 : BaseLoopExpr::operator= (BaseLoopExpr const &other)
1005 : : {
1006 : 0 : ExprWithBlock::operator= (other);
1007 : 0 : loop_block = other.loop_block->clone_block_expr ();
1008 : 0 : loop_label = other.loop_label;
1009 : 0 : locus = other.locus;
1010 : : // outer_attrs = other.outer_attrs;
1011 : :
1012 : 0 : return *this;
1013 : : }
1014 : :
1015 : 124 : LoopExpr::LoopExpr (Analysis::NodeMapping mappings,
1016 : : std::unique_ptr<BlockExpr> loop_block, location_t locus,
1017 : : tl::optional<LoopLabel> loop_label,
1018 : 124 : AST::AttrVec outer_attribs)
1019 : : : BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
1020 : 156 : std::move (loop_label), std::move (outer_attribs))
1021 : 124 : {}
1022 : :
1023 : 70 : WhileLoopExpr::WhileLoopExpr (Analysis::NodeMapping mappings,
1024 : : std::unique_ptr<Expr> loop_condition,
1025 : : std::unique_ptr<BlockExpr> loop_block,
1026 : : location_t locus,
1027 : : tl::optional<LoopLabel> loop_label,
1028 : 70 : AST::AttrVec outer_attribs)
1029 : : : BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
1030 : : std::move (loop_label), std::move (outer_attribs)),
1031 : 74 : condition (std::move (loop_condition))
1032 : 70 : {}
1033 : :
1034 : 0 : WhileLoopExpr::WhileLoopExpr (WhileLoopExpr const &other)
1035 : 0 : : BaseLoopExpr (other), condition (other.condition->clone_expr ())
1036 : 0 : {}
1037 : :
1038 : : WhileLoopExpr &
1039 : 0 : WhileLoopExpr::operator= (WhileLoopExpr const &other)
1040 : : {
1041 : 0 : BaseLoopExpr::operator= (other);
1042 : 0 : condition = other.condition->clone_expr ();
1043 : : // loop_block = other.loop_block->clone_block_expr();
1044 : : // loop_label = other.loop_label;
1045 : : // outer_attrs = other.outer_attrs;
1046 : :
1047 : 0 : return *this;
1048 : : }
1049 : :
1050 : 0 : WhileLetLoopExpr::WhileLetLoopExpr (
1051 : : Analysis::NodeMapping mappings,
1052 : : std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
1053 : : std::unique_ptr<Expr> condition, std::unique_ptr<BlockExpr> loop_block,
1054 : : location_t locus, tl::optional<LoopLabel> loop_label,
1055 : 0 : AST::AttrVec outer_attribs)
1056 : : : BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
1057 : : std::move (loop_label), std::move (outer_attribs)),
1058 : 0 : match_arm_patterns (std::move (match_arm_patterns)),
1059 : 0 : condition (std::move (condition))
1060 : 0 : {}
1061 : :
1062 : 0 : WhileLetLoopExpr::WhileLetLoopExpr (WhileLetLoopExpr const &other)
1063 : : : BaseLoopExpr (other),
1064 : 0 : /*match_arm_patterns(other.match_arm_patterns),*/ condition (
1065 : 0 : other.condition->clone_expr ())
1066 : : {
1067 : 0 : match_arm_patterns.reserve (other.match_arm_patterns.size ());
1068 : 0 : for (const auto &e : other.match_arm_patterns)
1069 : 0 : match_arm_patterns.push_back (e->clone_pattern ());
1070 : 0 : }
1071 : :
1072 : : WhileLetLoopExpr &
1073 : 0 : WhileLetLoopExpr::operator= (WhileLetLoopExpr const &other)
1074 : : {
1075 : 0 : BaseLoopExpr::operator= (other);
1076 : : // match_arm_patterns = other.match_arm_patterns;
1077 : 0 : condition = other.condition->clone_expr ();
1078 : : // loop_block = other.loop_block->clone_block_expr();
1079 : : // loop_label = other.loop_label;
1080 : : // outer_attrs = other.outer_attrs;
1081 : :
1082 : 0 : match_arm_patterns.reserve (other.match_arm_patterns.size ());
1083 : 0 : for (const auto &e : other.match_arm_patterns)
1084 : 0 : match_arm_patterns.push_back (e->clone_pattern ());
1085 : :
1086 : 0 : return *this;
1087 : : }
1088 : :
1089 : 974 : IfExpr::IfExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> condition,
1090 : 399 : std::unique_ptr<BlockExpr> if_block, location_t locus)
1091 : 974 : : ExprWithBlock (std::move (mappings), AST::AttrVec ()),
1092 : 974 : condition (std::move (condition)), if_block (std::move (if_block)),
1093 : 974 : locus (locus)
1094 : 974 : {}
1095 : :
1096 : 0 : IfExpr::IfExpr (IfExpr const &other)
1097 : 0 : : ExprWithBlock (other), condition (other.condition->clone_expr ()),
1098 : 0 : if_block (other.if_block->clone_block_expr ()), locus (other.locus)
1099 : 0 : {}
1100 : :
1101 : : IfExpr &
1102 : 0 : IfExpr::operator= (IfExpr const &other)
1103 : : {
1104 : 0 : ExprWithBlock::operator= (other);
1105 : 0 : condition = other.condition->clone_expr ();
1106 : 0 : if_block = other.if_block->clone_block_expr ();
1107 : 0 : locus = other.locus;
1108 : :
1109 : 0 : return *this;
1110 : : }
1111 : :
1112 : 575 : IfExprConseqElse::IfExprConseqElse (Analysis::NodeMapping mappings,
1113 : : std::unique_ptr<Expr> condition,
1114 : : std::unique_ptr<BlockExpr> if_block,
1115 : : std::unique_ptr<ExprWithBlock> else_block,
1116 : 575 : location_t locus)
1117 : : : IfExpr (std::move (mappings), std::move (condition), std::move (if_block),
1118 : : locus),
1119 : 575 : else_block (std::move (else_block))
1120 : 575 : {}
1121 : :
1122 : 0 : IfExprConseqElse::IfExprConseqElse (IfExprConseqElse const &other)
1123 : 0 : : IfExpr (other), else_block (other.else_block->clone_expr_with_block ())
1124 : 0 : {}
1125 : :
1126 : : IfExprConseqElse &
1127 : 0 : IfExprConseqElse::operator= (IfExprConseqElse const &other)
1128 : : {
1129 : 0 : IfExpr::operator= (other);
1130 : : // condition = other.condition->clone_expr();
1131 : : // if_block = other.if_block->clone_block_expr();
1132 : 0 : else_block = other.else_block->clone_expr_with_block ();
1133 : :
1134 : 0 : return *this;
1135 : : }
1136 : :
1137 : 1122 : MatchArm::MatchArm (std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
1138 : : location_t locus, std::unique_ptr<Expr> guard_expr,
1139 : 1122 : AST::AttrVec outer_attrs)
1140 : 1122 : : outer_attrs (std::move (outer_attrs)),
1141 : 1122 : match_arm_patterns (std::move (match_arm_patterns)),
1142 : 1122 : guard_expr (std::move (guard_expr)), locus (locus)
1143 : 1122 : {}
1144 : :
1145 : 2483 : MatchArm::MatchArm (MatchArm const &other) : outer_attrs (other.outer_attrs)
1146 : : {
1147 : : // guard to protect from null pointer dereference
1148 : 2483 : if (other.guard_expr != nullptr)
1149 : 0 : guard_expr = other.guard_expr->clone_expr ();
1150 : :
1151 : 2483 : match_arm_patterns.reserve (other.match_arm_patterns.size ());
1152 : 4966 : for (const auto &e : other.match_arm_patterns)
1153 : 2483 : match_arm_patterns.push_back (e->clone_pattern ());
1154 : :
1155 : 2483 : locus = other.locus;
1156 : 2483 : }
1157 : :
1158 : : MatchArm &
1159 : 0 : MatchArm::operator= (MatchArm const &other)
1160 : : {
1161 : 0 : outer_attrs = other.outer_attrs;
1162 : :
1163 : 0 : if (other.guard_expr != nullptr)
1164 : 0 : guard_expr = other.guard_expr->clone_expr ();
1165 : :
1166 : 0 : match_arm_patterns.clear ();
1167 : 0 : match_arm_patterns.reserve (other.match_arm_patterns.size ());
1168 : 0 : for (const auto &e : other.match_arm_patterns)
1169 : 0 : match_arm_patterns.push_back (e->clone_pattern ());
1170 : :
1171 : 0 : return *this;
1172 : : }
1173 : :
1174 : 1122 : MatchCase::MatchCase (Analysis::NodeMapping mappings, MatchArm arm,
1175 : 1122 : std::unique_ptr<Expr> expr)
1176 : 1122 : : mappings (mappings), arm (std::move (arm)), expr (std::move (expr))
1177 : 1122 : {}
1178 : :
1179 : 0 : MatchCase::MatchCase (const MatchCase &other)
1180 : 0 : : mappings (other.mappings), arm (other.arm), expr (other.expr->clone_expr ())
1181 : 0 : {}
1182 : :
1183 : : MatchCase &
1184 : 0 : MatchCase::operator= (const MatchCase &other)
1185 : : {
1186 : 0 : mappings = other.mappings;
1187 : 0 : arm = other.arm;
1188 : 0 : expr = other.expr->clone_expr ();
1189 : :
1190 : 0 : return *this;
1191 : : }
1192 : :
1193 : 507 : MatchExpr::MatchExpr (Analysis::NodeMapping mappings,
1194 : : std::unique_ptr<Expr> branch_value,
1195 : : std::vector<MatchCase> match_arms,
1196 : : AST::AttrVec inner_attrs, AST::AttrVec outer_attrs,
1197 : 507 : location_t locus)
1198 : : : ExprWithBlock (std::move (mappings), std::move (outer_attrs)),
1199 : : WithInnerAttrs (std::move (inner_attrs)),
1200 : 507 : branch_value (std::move (branch_value)),
1201 : 507 : match_arms (std::move (match_arms)), locus (locus)
1202 : 507 : {}
1203 : :
1204 : 0 : MatchExpr::MatchExpr (MatchExpr const &other)
1205 : 0 : : ExprWithBlock (other), WithInnerAttrs (other.inner_attrs),
1206 : 0 : branch_value (other.branch_value->clone_expr ()),
1207 : 0 : match_arms (other.match_arms), locus (other.locus)
1208 : : {
1209 : : /*match_arms.reserve (other.match_arms.size ());
1210 : : for (const auto &e : other.match_arms)
1211 : : match_arms.push_back (e->clone_match_case ());*/
1212 : 0 : }
1213 : :
1214 : : MatchExpr &
1215 : 0 : MatchExpr::operator= (MatchExpr const &other)
1216 : : {
1217 : 0 : ExprWithBlock::operator= (other);
1218 : 0 : branch_value = other.branch_value->clone_expr ();
1219 : 0 : inner_attrs = other.inner_attrs;
1220 : 0 : match_arms = other.match_arms;
1221 : : // outer_attrs = other.outer_attrs;
1222 : 0 : locus = other.locus;
1223 : :
1224 : : /*match_arms.reserve (other.match_arms.size ());
1225 : : for (const auto &e : other.match_arms)
1226 : : match_arms.push_back (e->clone_match_case ());*/
1227 : :
1228 : 0 : return *this;
1229 : : }
1230 : :
1231 : 0 : AwaitExpr::AwaitExpr (Analysis::NodeMapping mappings,
1232 : : std::unique_ptr<Expr> awaited_expr,
1233 : 0 : AST::AttrVec outer_attrs, location_t locus)
1234 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
1235 : 0 : awaited_expr (std::move (awaited_expr)), locus (locus)
1236 : 0 : {}
1237 : :
1238 : 0 : AwaitExpr::AwaitExpr (AwaitExpr const &other)
1239 : 0 : : ExprWithoutBlock (other), awaited_expr (other.awaited_expr->clone_expr ()),
1240 : 0 : locus (other.locus)
1241 : 0 : {}
1242 : :
1243 : : AwaitExpr &
1244 : 0 : AwaitExpr::operator= (AwaitExpr const &other)
1245 : : {
1246 : 0 : ExprWithoutBlock::operator= (other);
1247 : 0 : awaited_expr = other.awaited_expr->clone_expr ();
1248 : 0 : locus = other.locus;
1249 : :
1250 : 0 : return *this;
1251 : : }
1252 : :
1253 : 0 : AsyncBlockExpr::AsyncBlockExpr (Analysis::NodeMapping mappings,
1254 : : std::unique_ptr<BlockExpr> block_expr,
1255 : : bool has_move, AST::AttrVec outer_attrs,
1256 : 0 : location_t locus)
1257 : : : ExprWithBlock (std::move (mappings), std::move (outer_attrs)),
1258 : 0 : has_move (has_move), block_expr (std::move (block_expr)), locus (locus)
1259 : 0 : {}
1260 : :
1261 : 0 : AsyncBlockExpr::AsyncBlockExpr (AsyncBlockExpr const &other)
1262 : 0 : : ExprWithBlock (other), has_move (other.has_move),
1263 : 0 : block_expr (other.block_expr->clone_block_expr ()), locus (other.locus)
1264 : 0 : {}
1265 : :
1266 : : AsyncBlockExpr &
1267 : 0 : AsyncBlockExpr::operator= (AsyncBlockExpr const &other)
1268 : : {
1269 : 0 : ExprWithBlock::operator= (other);
1270 : 0 : has_move = other.has_move;
1271 : 0 : block_expr = other.block_expr->clone_block_expr ();
1272 : 0 : locus = other.locus;
1273 : :
1274 : 0 : return *this;
1275 : : }
1276 : :
1277 : 255 : OperatorExprMeta::OperatorExprMeta (HIR::CompoundAssignmentExpr &expr)
1278 : 255 : : node_mappings (expr.get_mappings ()),
1279 : 255 : lvalue_mappings (expr.get_expr ().get_mappings ()),
1280 : 255 : locus (expr.get_locus ())
1281 : 255 : {}
1282 : :
1283 : 3282 : OperatorExprMeta::OperatorExprMeta (HIR::ArithmeticOrLogicalExpr &expr)
1284 : 3282 : : node_mappings (expr.get_mappings ()),
1285 : 3282 : lvalue_mappings (expr.get_expr ().get_mappings ()),
1286 : 3282 : locus (expr.get_locus ())
1287 : 3282 : {}
1288 : :
1289 : 391 : OperatorExprMeta::OperatorExprMeta (HIR::NegationExpr &expr)
1290 : 391 : : node_mappings (expr.get_mappings ()),
1291 : 391 : lvalue_mappings (expr.get_expr ().get_mappings ()),
1292 : 391 : locus (expr.get_locus ())
1293 : 391 : {}
1294 : :
1295 : 1914 : OperatorExprMeta::OperatorExprMeta (HIR::DereferenceExpr &expr)
1296 : 1914 : : node_mappings (expr.get_mappings ()),
1297 : 1914 : lvalue_mappings (expr.get_expr ().get_mappings ()),
1298 : 1914 : locus (expr.get_locus ())
1299 : 1914 : {}
1300 : :
1301 : 128 : OperatorExprMeta::OperatorExprMeta (HIR::ArrayIndexExpr &expr)
1302 : 128 : : node_mappings (expr.get_mappings ()),
1303 : 128 : lvalue_mappings (expr.get_array_expr ().get_mappings ()),
1304 : 128 : locus (expr.get_locus ())
1305 : 128 : {}
1306 : :
1307 : 1157 : OperatorExprMeta::OperatorExprMeta (HIR::ComparisonExpr &expr)
1308 : 1157 : : node_mappings (expr.get_mappings ()),
1309 : 1157 : lvalue_mappings (expr.get_expr ().get_mappings ()),
1310 : 1157 : locus (expr.get_locus ())
1311 : 1157 : {}
1312 : :
1313 : 0 : AnonConst::AnonConst (NodeId id, std::unique_ptr<Expr> expr)
1314 : 0 : : id (id), expr (std::move (expr))
1315 : : {
1316 : 0 : rust_assert (this->expr != nullptr);
1317 : 0 : }
1318 : :
1319 : 0 : AnonConst::AnonConst (const AnonConst &other)
1320 : : {
1321 : 0 : id = other.id;
1322 : 0 : expr = other.expr->clone_expr ();
1323 : 0 : }
1324 : :
1325 : : AnonConst
1326 : 0 : AnonConst::operator= (const AnonConst &other)
1327 : : {
1328 : 0 : id = other.id;
1329 : 0 : expr = other.expr->clone_expr ();
1330 : 0 : return *this;
1331 : : }
1332 : :
1333 : 13 : InlineAsmOperand::In::In (
1334 : : const tl::optional<struct AST::InlineAsmRegOrRegClass> ®,
1335 : 13 : std::unique_ptr<Expr> expr)
1336 : 13 : : reg (reg), expr (std::move (expr))
1337 : : {
1338 : 13 : rust_assert (this->expr != nullptr);
1339 : 13 : }
1340 : :
1341 : 113 : InlineAsmOperand::In::In (const struct In &other)
1342 : : {
1343 : 113 : reg = other.reg;
1344 : :
1345 : 113 : expr = other.expr->clone_expr ();
1346 : 113 : }
1347 : :
1348 : : InlineAsmOperand::In
1349 : 0 : InlineAsmOperand::In::operator= (const struct In &other)
1350 : : {
1351 : 0 : reg = other.reg;
1352 : 0 : expr = other.expr->clone_expr ();
1353 : :
1354 : 0 : return *this;
1355 : : }
1356 : :
1357 : 20 : InlineAsmOperand::Out::Out (
1358 : : tl::optional<struct AST::InlineAsmRegOrRegClass> ®, bool late,
1359 : 20 : std::unique_ptr<Expr> expr)
1360 : 20 : : reg (reg), late (late), expr (std::move (expr))
1361 : : {
1362 : 20 : rust_assert (this->expr != nullptr);
1363 : 20 : }
1364 : :
1365 : 162 : InlineAsmOperand::Out::Out (const struct Out &other)
1366 : : {
1367 : 162 : reg = other.reg;
1368 : 162 : late = other.late;
1369 : 162 : expr = other.expr->clone_expr ();
1370 : 162 : }
1371 : :
1372 : : InlineAsmOperand::Out
1373 : 0 : InlineAsmOperand::Out::operator= (const struct Out &other)
1374 : : {
1375 : 0 : reg = other.reg;
1376 : 0 : late = other.late;
1377 : 0 : expr = other.expr->clone_expr ();
1378 : 0 : return *this;
1379 : : }
1380 : :
1381 : 0 : InlineAsmOperand::InOut::InOut (
1382 : : tl::optional<struct AST::InlineAsmRegOrRegClass> ®, bool late,
1383 : 0 : std::unique_ptr<Expr> expr)
1384 : 0 : : reg (reg), late (late), expr (std::move (expr))
1385 : : {
1386 : 0 : rust_assert (this->expr != nullptr);
1387 : 0 : }
1388 : :
1389 : 0 : InlineAsmOperand::InOut::InOut (const struct InOut &other)
1390 : : {
1391 : 0 : reg = other.reg;
1392 : 0 : late = other.late;
1393 : 0 : expr = other.expr->clone_expr ();
1394 : 0 : }
1395 : :
1396 : : InlineAsmOperand::InOut
1397 : 0 : InlineAsmOperand::InOut::operator= (const struct InOut &other)
1398 : : {
1399 : 0 : reg = other.reg;
1400 : 0 : late = other.late;
1401 : 0 : expr = other.expr->clone_expr ();
1402 : :
1403 : 0 : return *this;
1404 : : }
1405 : :
1406 : 0 : InlineAsmOperand::SplitInOut::SplitInOut (
1407 : : tl::optional<struct AST::InlineAsmRegOrRegClass> ®, bool late,
1408 : 0 : std::unique_ptr<Expr> in_expr, std::unique_ptr<Expr> out_expr)
1409 : 0 : : reg (reg), late (late), in_expr (std::move (in_expr)),
1410 : 0 : out_expr (std::move (out_expr))
1411 : : {
1412 : 0 : rust_assert (this->in_expr != nullptr);
1413 : 0 : rust_assert (this->out_expr != nullptr);
1414 : 0 : }
1415 : :
1416 : 0 : InlineAsmOperand::SplitInOut::SplitInOut (const struct SplitInOut &other)
1417 : : {
1418 : 0 : reg = other.reg;
1419 : 0 : late = other.late;
1420 : 0 : in_expr = other.in_expr->clone_expr ();
1421 : 0 : out_expr = other.out_expr->clone_expr ();
1422 : 0 : }
1423 : :
1424 : : InlineAsmOperand::SplitInOut
1425 : 0 : InlineAsmOperand::SplitInOut::operator= (const struct SplitInOut &other)
1426 : : {
1427 : 0 : reg = other.reg;
1428 : 0 : late = other.late;
1429 : 0 : in_expr = other.in_expr->clone_expr ();
1430 : 0 : out_expr = other.out_expr->clone_expr ();
1431 : :
1432 : 0 : return *this;
1433 : : }
1434 : :
1435 : 0 : InlineAsmOperand::Sym::Sym (std::unique_ptr<Expr> expr)
1436 : 0 : : expr (std::move (expr))
1437 : : {
1438 : 0 : rust_assert (this->expr != nullptr);
1439 : 0 : }
1440 : :
1441 : 0 : InlineAsmOperand::Sym::Sym (const struct Sym &other)
1442 : : {
1443 : 0 : expr = std::unique_ptr<Expr> (other.expr->clone_expr ());
1444 : 0 : }
1445 : :
1446 : : InlineAsmOperand::Sym
1447 : 0 : InlineAsmOperand::Sym::operator= (const struct Sym &other)
1448 : : {
1449 : 0 : expr = std::unique_ptr<Expr> (other.expr->clone_expr ());
1450 : 0 : return *this;
1451 : : }
1452 : :
1453 : 0 : InlineAsmOperand::Label::Label (tl::optional<std::string> label_name,
1454 : 0 : std::unique_ptr<Expr> expr)
1455 : 0 : : expr (std::move (expr))
1456 : : {
1457 : 0 : rust_assert (this->expr != nullptr);
1458 : 0 : if (label_name.has_value ())
1459 : 0 : this->label_name = label_name.value ();
1460 : 0 : }
1461 : :
1462 : 0 : InlineAsmOperand::Label::Label (const struct Label &other)
1463 : : {
1464 : 0 : expr = std::unique_ptr<Expr> (other.expr->clone_expr ());
1465 : 0 : }
1466 : :
1467 : : InlineAsmOperand::Label
1468 : 0 : InlineAsmOperand::Label::operator= (const struct Label &other)
1469 : : {
1470 : 0 : expr = std::unique_ptr<Expr> (other.expr->clone_expr ());
1471 : 0 : return *this;
1472 : : }
1473 : :
1474 : 36 : InlineAsm::InlineAsm (location_t locus, bool is_global_asm,
1475 : : std::vector<AST::InlineAsmTemplatePiece> template_,
1476 : : std::vector<AST::TupleTemplateStr> template_strs,
1477 : : std::vector<HIR::InlineAsmOperand> operands,
1478 : : std::vector<AST::TupleClobber> clobber_abi,
1479 : : std::set<AST::InlineAsmOption> options,
1480 : : Analysis::NodeMapping mappings,
1481 : 36 : AST::AttrVec outer_attribs)
1482 : : : ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
1483 : 36 : locus (locus), is_global_asm (is_global_asm),
1484 : 36 : template_ (std::move (template_)),
1485 : 36 : template_strs (std::move (template_strs)), operands (std::move (operands)),
1486 : 36 : clobber_abi (std::move (clobber_abi)), options (std::move (options))
1487 : 36 : {}
1488 : :
1489 : : } // namespace HIR
1490 : : } // namespace Rust
|