Debian Codegraph @

gcc/rust/hir/tree/rust-hir-expr.cc

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