| 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-item.h" |
| 20 |
#include "optional.h" |
| 21 |
|
| 22 |
namespace Rust { |
| 23 |
namespace HIR { |
| 24 |
|
| 25 |
TypeParam::TypeParam ( |
| 26 |
Analysis::NodeMapping mappings, Identifier type_representation, |
| 27 |
location_t locus, |
| 28 |
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, |
| 29 |
tl::optional<std::unique_ptr<Type>> type, AST::AttrVec outer_attrs) |
| 30 |
: GenericParam (mappings), outer_attrs (std::move (outer_attrs)), |
| 31 |
type_representation (std::move (type_representation)), |
| 32 |
type_param_bounds (std::move (type_param_bounds)), type (std::move (type)), |
| 33 |
locus (locus) |
| 34 |
{} |
| 35 |
|
| 36 |
TypeParam::TypeParam (TypeParam const &other) |
| 37 |
: GenericParam (other.mappings), outer_attrs (other.outer_attrs), |
| 38 |
type_representation (other.type_representation), locus (other.locus) |
| 39 |
{ |
| 40 |
// guard to prevent null pointer dereference |
| 41 |
if (other.has_type ()) |
| 42 |
type = {other.type.value ()->clone_type ()}; |
| 43 |
else |
| 44 |
type = tl::nullopt; |
| 45 |
|
| 46 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 47 |
for (const auto &e : other.type_param_bounds) |
| 48 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 49 |
} |
| 50 |
|
| 51 |
TypeParam & |
| 52 |
TypeParam::operator= (TypeParam const &other) |
| 53 |
{ |
| 54 |
type_representation = other.type_representation; |
| 55 |
outer_attrs = other.outer_attrs; |
| 56 |
locus = other.locus; |
| 57 |
mappings = other.mappings; |
| 58 |
|
| 59 |
// guard to prevent null pointer dereference |
| 60 |
if (other.has_type ()) |
| 61 |
type = {other.type.value ()->clone_type ()}; |
| 62 |
else |
| 63 |
type = tl::nullopt; |
| 64 |
|
| 65 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 66 |
for (const auto &e : other.type_param_bounds) |
| 67 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 68 |
|
| 69 |
return *this; |
| 70 |
} |
| 71 |
|
| 72 |
Analysis::NodeMapping |
| 73 |
TypeParam::get_type_mappings () const |
| 74 |
{ |
| 75 |
rust_assert (type.has_value ()); |
| 76 |
return type.value ()->get_mappings (); |
| 77 |
} |
| 78 |
|
| 79 |
std::vector<std::unique_ptr<TypeParamBound>> & |
| 80 |
TypeParam::get_type_param_bounds () |
| 81 |
{ |
| 82 |
return type_param_bounds; |
| 83 |
} |
| 84 |
|
| 85 |
TypeBoundWhereClauseItem::TypeBoundWhereClauseItem ( |
| 86 |
Analysis::NodeMapping mappings, std::vector<LifetimeParam> for_lifetimes, |
| 87 |
std::unique_ptr<Type> bound_type, |
| 88 |
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, |
| 89 |
location_t locus) |
| 90 |
: for_lifetimes (std::move (for_lifetimes)), |
| 91 |
bound_type (std::move (bound_type)), |
| 92 |
type_param_bounds (std::move (type_param_bounds)), |
| 93 |
mappings (std::move (mappings)), locus (locus) |
| 94 |
{} |
| 95 |
|
| 96 |
TypeBoundWhereClauseItem::TypeBoundWhereClauseItem ( |
| 97 |
TypeBoundWhereClauseItem const &other) |
| 98 |
: for_lifetimes (other.for_lifetimes), |
| 99 |
bound_type (other.bound_type->clone_type ()), mappings (other.mappings) |
| 100 |
{ |
| 101 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 102 |
for (const auto &e : other.type_param_bounds) |
| 103 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 104 |
} |
| 105 |
|
| 106 |
TypeBoundWhereClauseItem & |
| 107 |
TypeBoundWhereClauseItem::operator= (TypeBoundWhereClauseItem const &other) |
| 108 |
{ |
| 109 |
mappings = other.mappings; |
| 110 |
for_lifetimes = other.for_lifetimes; |
| 111 |
bound_type = other.bound_type->clone_type (); |
| 112 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 113 |
for (const auto &e : other.type_param_bounds) |
| 114 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 115 |
|
| 116 |
return *this; |
| 117 |
} |
| 118 |
|
| 119 |
std::vector<std::unique_ptr<TypeParamBound>> & |
| 120 |
TypeBoundWhereClauseItem::get_type_param_bounds () |
| 121 |
{ |
| 122 |
return type_param_bounds; |
| 123 |
} |
| 124 |
|
| 125 |
SelfParam::SelfParam (Analysis::NodeMapping mappings, |
| 126 |
ImplicitSelfKind self_kind, |
| 127 |
tl::optional<Lifetime> lifetime, Type *type) |
| 128 |
: self_kind (self_kind), lifetime (std::move (lifetime)), type (type), |
| 129 |
mappings (mappings) |
| 130 |
{} |
| 131 |
|
| 132 |
SelfParam::SelfParam (Analysis::NodeMapping mappings, |
| 133 |
std::unique_ptr<Type> type, bool is_mut, location_t locus) |
| 134 |
: self_kind (is_mut ? ImplicitSelfKind::MUT : ImplicitSelfKind::IMM), |
| 135 |
lifetime (tl::nullopt), type (std::move (type)), locus (locus), |
| 136 |
mappings (mappings) |
| 137 |
{} |
| 138 |
|
| 139 |
SelfParam::SelfParam (Analysis::NodeMapping mappings, |
| 140 |
tl::optional<Lifetime> lifetime, bool is_mut, |
| 141 |
location_t locus) |
| 142 |
: self_kind (is_mut ? ImplicitSelfKind::MUT_REF : ImplicitSelfKind::IMM_REF), |
| 143 |
lifetime (std::move (lifetime)), locus (locus), mappings (mappings) |
| 144 |
{} |
| 145 |
|
| 146 |
SelfParam::SelfParam (SelfParam const &other) |
| 147 |
: self_kind (other.self_kind), lifetime (other.lifetime), locus (other.locus), |
| 148 |
mappings (other.mappings) |
| 149 |
{ |
| 150 |
if (other.type != nullptr) |
| 151 |
type = other.type->clone_type (); |
| 152 |
} |
| 153 |
|
| 154 |
SelfParam & |
| 155 |
SelfParam::operator= (SelfParam const &other) |
| 156 |
{ |
| 157 |
if (other.type != nullptr) |
| 158 |
type = other.type->clone_type (); |
| 159 |
|
| 160 |
self_kind = other.self_kind; |
| 161 |
lifetime = other.lifetime; |
| 162 |
locus = other.locus; |
| 163 |
mappings = other.mappings; |
| 164 |
|
| 165 |
return *this; |
| 166 |
} |
| 167 |
|
| 168 |
Mutability |
| 169 |
SelfParam::get_mut () const |
| 170 |
{ |
| 171 |
return (self_kind == ImplicitSelfKind::MUT |
| 172 |
|| self_kind == ImplicitSelfKind::MUT_REF) |
| 173 |
? Mutability::Mut |
| 174 |
: Mutability::Imm; |
| 175 |
} |
| 176 |
|
| 177 |
bool |
| 178 |
SelfParam::is_mut () const |
| 179 |
{ |
| 180 |
return self_kind == ImplicitSelfKind::MUT |
| 181 |
|| self_kind == ImplicitSelfKind::MUT_REF; |
| 182 |
} |
| 183 |
|
| 184 |
bool |
| 185 |
SelfParam::is_ref () const |
| 186 |
{ |
| 187 |
return self_kind == ImplicitSelfKind::IMM_REF |
| 188 |
|| self_kind == ImplicitSelfKind::MUT_REF; |
| 189 |
} |
| 190 |
|
| 191 |
FunctionParam::FunctionParam (Analysis::NodeMapping mappings, |
| 192 |
std::unique_ptr<Pattern> param_name, |
| 193 |
std::unique_ptr<Type> param_type, |
| 194 |
location_t locus) |
| 195 |
: param_name (std::move (param_name)), type (std::move (param_type)), |
| 196 |
locus (locus), mappings (mappings) |
| 197 |
{} |
| 198 |
|
| 199 |
FunctionParam::FunctionParam (FunctionParam const &other) |
| 200 |
: param_name (other.param_name->clone_pattern ()), |
| 201 |
type (other.type->clone_type ()), locus (other.locus), |
| 202 |
mappings (other.mappings) |
| 203 |
{} |
| 204 |
|
| 205 |
FunctionParam & |
| 206 |
FunctionParam::operator= (FunctionParam const &other) |
| 207 |
{ |
| 208 |
param_name = other.param_name->clone_pattern (); |
| 209 |
type = other.type->clone_type (); |
| 210 |
locus = other.locus; |
| 211 |
mappings = other.mappings; |
| 212 |
|
| 213 |
return *this; |
| 214 |
} |
| 215 |
|
| 216 |
VisItem & |
| 217 |
VisItem::operator= (VisItem const &other) |
| 218 |
{ |
| 219 |
Item::operator= (other); |
| 220 |
visibility = other.visibility; |
| 221 |
// outer_attrs = other.outer_attrs; |
| 222 |
|
| 223 |
return *this; |
| 224 |
} |
| 225 |
|
| 226 |
VisItem::VisItem (VisItem const &other) |
| 227 |
: Item (other), visibility (other.visibility) |
| 228 |
{} |
| 229 |
|
| 230 |
Module::Module (Analysis::NodeMapping mappings, Identifier module_name, |
| 231 |
location_t locus, std::vector<std::unique_ptr<Item>> items, |
| 232 |
Visibility visibility, AST::AttrVec inner_attrs, |
| 233 |
AST::AttrVec outer_attrs) |
| 234 |
: VisItem (std::move (mappings), std::move (visibility), |
| 235 |
std::move (outer_attrs)), |
| 236 |
WithInnerAttrs (std::move (inner_attrs)), module_name (module_name), |
| 237 |
locus (locus), items (std::move (items)) |
| 238 |
{} |
| 239 |
|
| 240 |
Module::Module (Module const &other) |
| 241 |
: VisItem (other), WithInnerAttrs (other.inner_attrs), module_name ("") |
| 242 |
{ |
| 243 |
items.reserve (other.items.size ()); |
| 244 |
for (const auto &e : other.items) |
| 245 |
items.push_back (e->clone_item ()); |
| 246 |
} |
| 247 |
|
| 248 |
Module & |
| 249 |
Module::operator= (Module const &other) |
| 250 |
{ |
| 251 |
VisItem::operator= (other); |
| 252 |
inner_attrs = other.inner_attrs; |
| 253 |
|
| 254 |
items.reserve (other.items.size ()); |
| 255 |
for (const auto &e : other.items) |
| 256 |
items.push_back (e->clone_item ()); |
| 257 |
|
| 258 |
return *this; |
| 259 |
} |
| 260 |
|
| 261 |
Function::Function (Analysis::NodeMapping mappings, Identifier function_name, |
| 262 |
FunctionQualifiers qualifiers, |
| 263 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 264 |
std::vector<FunctionParam> function_params, |
| 265 |
std::unique_ptr<Type> return_type, WhereClause where_clause, |
| 266 |
std::unique_ptr<BlockExpr> function_body, Visibility vis, |
| 267 |
AST::AttrVec outer_attrs, tl::optional<SelfParam> self, |
| 268 |
Defaultness defaultness, location_t locus) |
| 269 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 270 |
qualifiers (std::move (qualifiers)), |
| 271 |
function_name (std::move (function_name)), |
| 272 |
generic_params (std::move (generic_params)), |
| 273 |
function_params (std::move (function_params)), |
| 274 |
return_type (std::move (return_type)), |
| 275 |
where_clause (std::move (where_clause)), |
| 276 |
function_body (std::move (function_body)), self (std::move (self)), |
| 277 |
locus (locus), defaultness (defaultness) |
| 278 |
{} |
| 279 |
|
| 280 |
Function::Function (Function const &other) |
| 281 |
: VisItem (other), qualifiers (other.qualifiers), |
| 282 |
function_name (other.function_name), |
| 283 |
function_params (other.function_params), where_clause (other.where_clause), |
| 284 |
function_body (other.function_body->clone_block_expr ()), self (other.self), |
| 285 |
locus (other.locus), defaultness (other.defaultness) |
| 286 |
{ |
| 287 |
// guard to prevent null dereference (always required) |
| 288 |
if (other.return_type != nullptr) |
| 289 |
return_type = other.return_type->clone_type (); |
| 290 |
else |
| 291 |
return_type = nullptr; |
| 292 |
|
| 293 |
generic_params.reserve (other.generic_params.size ()); |
| 294 |
for (const auto &e : other.generic_params) |
| 295 |
generic_params.push_back (e->clone_generic_param ()); |
| 296 |
} |
| 297 |
|
| 298 |
Function & |
| 299 |
Function::operator= (Function const &other) |
| 300 |
{ |
| 301 |
VisItem::operator= (other); |
| 302 |
function_name = other.function_name; |
| 303 |
qualifiers = other.qualifiers; |
| 304 |
function_params = other.function_params; |
| 305 |
|
| 306 |
// guard to prevent null dereference (always required) |
| 307 |
if (other.return_type != nullptr) |
| 308 |
return_type = other.return_type->clone_type (); |
| 309 |
else |
| 310 |
return_type = nullptr; |
| 311 |
|
| 312 |
where_clause = other.where_clause; |
| 313 |
function_body = other.function_body->clone_block_expr (); |
| 314 |
locus = other.locus; |
| 315 |
self = other.self; |
| 316 |
|
| 317 |
defaultness = other.defaultness; |
| 318 |
|
| 319 |
generic_params.reserve (other.generic_params.size ()); |
| 320 |
for (const auto &e : other.generic_params) |
| 321 |
generic_params.push_back (e->clone_generic_param ()); |
| 322 |
|
| 323 |
return *this; |
| 324 |
} |
| 325 |
|
| 326 |
TypeAlias::TypeAlias (Analysis::NodeMapping mappings, Identifier new_type_name, |
| 327 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 328 |
WhereClause where_clause, |
| 329 |
std::unique_ptr<Type> existing_type, Visibility vis, |
| 330 |
AST::AttrVec outer_attrs, location_t locus) |
| 331 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 332 |
new_type_name (std::move (new_type_name)), |
| 333 |
generic_params (std::move (generic_params)), |
| 334 |
where_clause (std::move (where_clause)), |
| 335 |
existing_type (std::move (existing_type)), locus (locus) |
| 336 |
{} |
| 337 |
|
| 338 |
TypeAlias::TypeAlias (TypeAlias const &other) |
| 339 |
: VisItem (other), new_type_name (other.new_type_name), |
| 340 |
where_clause (other.where_clause), |
| 341 |
existing_type (other.existing_type->clone_type ()), locus (other.locus) |
| 342 |
{ |
| 343 |
generic_params.reserve (other.generic_params.size ()); |
| 344 |
for (const auto &e : other.generic_params) |
| 345 |
generic_params.push_back (e->clone_generic_param ()); |
| 346 |
} |
| 347 |
|
| 348 |
TypeAlias & |
| 349 |
TypeAlias::operator= (TypeAlias const &other) |
| 350 |
{ |
| 351 |
VisItem::operator= (other); |
| 352 |
new_type_name = other.new_type_name; |
| 353 |
where_clause = other.where_clause; |
| 354 |
existing_type = other.existing_type->clone_type (); |
| 355 |
locus = other.locus; |
| 356 |
|
| 357 |
generic_params.reserve (other.generic_params.size ()); |
| 358 |
for (const auto &e : other.generic_params) |
| 359 |
generic_params.push_back (e->clone_generic_param ()); |
| 360 |
|
| 361 |
return *this; |
| 362 |
} |
| 363 |
|
| 364 |
StructField::StructField (Analysis::NodeMapping mappings, Identifier field_name, |
| 365 |
std::unique_ptr<Type> field_type, Visibility vis, |
| 366 |
location_t locus, AST::AttrVec outer_attrs) |
| 367 |
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), |
| 368 |
field_name (std::move (field_name)), field_type (std::move (field_type)), |
| 369 |
mappings (mappings), locus (locus) |
| 370 |
{} |
| 371 |
|
| 372 |
StructField::StructField (StructField const &other) |
| 373 |
: outer_attrs (other.outer_attrs), visibility (other.visibility), |
| 374 |
field_name (other.field_name), field_type (other.field_type->clone_type ()), |
| 375 |
mappings (other.mappings) |
| 376 |
{} |
| 377 |
|
| 378 |
StructField & |
| 379 |
StructField::operator= (StructField const &other) |
| 380 |
{ |
| 381 |
field_name = other.field_name; |
| 382 |
field_type = other.field_type->clone_type (); |
| 383 |
visibility = other.visibility; |
| 384 |
outer_attrs = other.outer_attrs; |
| 385 |
mappings = other.mappings; |
| 386 |
|
| 387 |
return *this; |
| 388 |
} |
| 389 |
|
| 390 |
TupleField::TupleField (Analysis::NodeMapping mapping, |
| 391 |
std::unique_ptr<Type> field_type, Visibility vis, |
| 392 |
location_t locus, AST::AttrVec outer_attrs) |
| 393 |
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)), |
| 394 |
field_type (std::move (field_type)), locus (locus), mappings (mapping) |
| 395 |
{} |
| 396 |
|
| 397 |
TupleField::TupleField (TupleField const &other) |
| 398 |
: outer_attrs (other.outer_attrs), visibility (other.visibility), |
| 399 |
field_type (other.field_type->clone_type ()), locus (other.locus), |
| 400 |
mappings (other.mappings) |
| 401 |
{} |
| 402 |
|
| 403 |
TupleField & |
| 404 |
TupleField::operator= (TupleField const &other) |
| 405 |
{ |
| 406 |
field_type = other.field_type->clone_type (); |
| 407 |
visibility = other.visibility; |
| 408 |
outer_attrs = other.outer_attrs; |
| 409 |
locus = other.locus; |
| 410 |
mappings = other.mappings; |
| 411 |
|
| 412 |
return *this; |
| 413 |
} |
| 414 |
|
| 415 |
TupleStruct::TupleStruct ( |
| 416 |
Analysis::NodeMapping mappings, std::vector<TupleField> fields, |
| 417 |
Identifier struct_name, |
| 418 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 419 |
WhereClause where_clause, Visibility vis, AST::AttrVec outer_attrs, |
| 420 |
location_t locus) |
| 421 |
: Struct (std::move (mappings), std::move (struct_name), |
| 422 |
std::move (generic_params), std::move (where_clause), |
| 423 |
std::move (vis), locus, std::move (outer_attrs)), |
| 424 |
fields (std::move (fields)) |
| 425 |
{} |
| 426 |
|
| 427 |
EnumItem::EnumItem (Analysis::NodeMapping mappings, Identifier variant_name, |
| 428 |
AST::AttrVec outer_attrs, location_t locus) |
| 429 |
: Item (std::move (mappings), std::move (outer_attrs)), |
| 430 |
variant_name (std::move (variant_name)), locus (locus) |
| 431 |
{} |
| 432 |
|
| 433 |
EnumItemTuple::EnumItemTuple (Analysis::NodeMapping mappings, |
| 434 |
Identifier variant_name, |
| 435 |
std::vector<TupleField> tuple_fields, |
| 436 |
AST::AttrVec outer_attrs, location_t locus) |
| 437 |
: EnumItem (std::move (mappings), std::move (variant_name), |
| 438 |
std::move (outer_attrs), locus), |
| 439 |
tuple_fields (std::move (tuple_fields)) |
| 440 |
{} |
| 441 |
|
| 442 |
EnumItemStruct::EnumItemStruct (Analysis::NodeMapping mappings, |
| 443 |
Identifier variant_name, |
| 444 |
std::vector<StructField> struct_fields, |
| 445 |
AST::AttrVec outer_attrs, location_t locus) |
| 446 |
: EnumItem (std::move (mappings), std::move (variant_name), |
| 447 |
std::move (outer_attrs), locus), |
| 448 |
struct_fields (std::move (struct_fields)) |
| 449 |
{} |
| 450 |
|
| 451 |
EnumItemDiscriminant::EnumItemDiscriminant (Analysis::NodeMapping mappings, |
| 452 |
Identifier variant_name, |
| 453 |
std::unique_ptr<Expr> expr, |
| 454 |
AST::AttrVec outer_attrs, |
| 455 |
location_t locus) |
| 456 |
: EnumItem (std::move (mappings), std::move (variant_name), |
| 457 |
std::move (outer_attrs), locus), |
| 458 |
expression (std::move (expr)) |
| 459 |
{} |
| 460 |
|
| 461 |
EnumItemDiscriminant::EnumItemDiscriminant (EnumItemDiscriminant const &other) |
| 462 |
: EnumItem (other), expression (other.expression->clone_expr ()) |
| 463 |
{} |
| 464 |
|
| 465 |
EnumItemDiscriminant & |
| 466 |
EnumItemDiscriminant::operator= (EnumItemDiscriminant const &other) |
| 467 |
{ |
| 468 |
EnumItem::operator= (other); |
| 469 |
expression = other.expression->clone_expr (); |
| 470 |
// variant_name = other.variant_name; |
| 471 |
// outer_attrs = other.outer_attrs; |
| 472 |
|
| 473 |
return *this; |
| 474 |
} |
| 475 |
|
| 476 |
Enum::Enum (Analysis::NodeMapping mappings, Identifier enum_name, |
| 477 |
Visibility vis, |
| 478 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 479 |
WhereClause where_clause, |
| 480 |
std::vector<std::unique_ptr<EnumItem>> items, |
| 481 |
AST::AttrVec outer_attrs, location_t locus) |
| 482 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 483 |
enum_name (std::move (enum_name)), |
| 484 |
generic_params (std::move (generic_params)), |
| 485 |
where_clause (std::move (where_clause)), items (std::move (items)), |
| 486 |
locus (locus) |
| 487 |
{} |
| 488 |
|
| 489 |
Enum::Enum (Enum const &other) |
| 490 |
: VisItem (other), enum_name (other.enum_name), |
| 491 |
where_clause (other.where_clause), locus (other.locus) |
| 492 |
{ |
| 493 |
generic_params.reserve (other.generic_params.size ()); |
| 494 |
for (const auto &e : other.generic_params) |
| 495 |
generic_params.push_back (e->clone_generic_param ()); |
| 496 |
|
| 497 |
items.reserve (other.items.size ()); |
| 498 |
for (const auto &e : other.items) |
| 499 |
items.push_back (e->clone_enum_item ()); |
| 500 |
} |
| 501 |
|
| 502 |
Enum & |
| 503 |
Enum::operator= (Enum const &other) |
| 504 |
{ |
| 505 |
VisItem::operator= (other); |
| 506 |
enum_name = other.enum_name; |
| 507 |
where_clause = other.where_clause; |
| 508 |
locus = other.locus; |
| 509 |
|
| 510 |
generic_params.reserve (other.generic_params.size ()); |
| 511 |
for (const auto &e : other.generic_params) |
| 512 |
generic_params.push_back (e->clone_generic_param ()); |
| 513 |
|
| 514 |
items.reserve (other.items.size ()); |
| 515 |
for (const auto &e : other.items) |
| 516 |
items.push_back (e->clone_enum_item ()); |
| 517 |
|
| 518 |
return *this; |
| 519 |
} |
| 520 |
|
| 521 |
Union::Union (Analysis::NodeMapping mappings, Identifier union_name, |
| 522 |
Visibility vis, |
| 523 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 524 |
WhereClause where_clause, std::vector<StructField> variants, |
| 525 |
AST::AttrVec outer_attrs, location_t locus) |
| 526 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 527 |
union_name (std::move (union_name)), |
| 528 |
generic_params (std::move (generic_params)), |
| 529 |
where_clause (std::move (where_clause)), variants (std::move (variants)), |
| 530 |
locus (locus) |
| 531 |
{} |
| 532 |
|
| 533 |
Union::Union (Union const &other) |
| 534 |
: VisItem (other), union_name (other.union_name), |
| 535 |
where_clause (other.where_clause), variants (other.variants), |
| 536 |
locus (other.locus) |
| 537 |
{ |
| 538 |
generic_params.reserve (other.generic_params.size ()); |
| 539 |
for (const auto &e : other.generic_params) |
| 540 |
generic_params.push_back (e->clone_generic_param ()); |
| 541 |
} |
| 542 |
|
| 543 |
Union & |
| 544 |
Union::operator= (Union const &other) |
| 545 |
{ |
| 546 |
VisItem::operator= (other); |
| 547 |
union_name = other.union_name; |
| 548 |
where_clause = other.where_clause; |
| 549 |
variants = other.variants; |
| 550 |
locus = other.locus; |
| 551 |
|
| 552 |
generic_params.reserve (other.generic_params.size ()); |
| 553 |
for (const auto &e : other.generic_params) |
| 554 |
generic_params.push_back (e->clone_generic_param ()); |
| 555 |
|
| 556 |
return *this; |
| 557 |
} |
| 558 |
|
| 559 |
ConstantItem::ConstantItem (Analysis::NodeMapping mappings, Identifier ident, |
| 560 |
Visibility vis, std::unique_ptr<Type> type, |
| 561 |
std::unique_ptr<Expr> const_expr, |
| 562 |
AST::AttrVec outer_attrs, location_t locus) |
| 563 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 564 |
identifier (std::move (ident)), type (std::move (type)), |
| 565 |
const_expr (std::move (const_expr)), locus (locus) |
| 566 |
{} |
| 567 |
|
| 568 |
ConstantItem::ConstantItem (ConstantItem const &other) |
| 569 |
: VisItem (other), identifier (other.identifier), |
| 570 |
type (other.type->clone_type ()), |
| 571 |
const_expr (other.const_expr->clone_expr ()), locus (other.locus) |
| 572 |
{} |
| 573 |
|
| 574 |
ConstantItem & |
| 575 |
ConstantItem::operator= (ConstantItem const &other) |
| 576 |
{ |
| 577 |
VisItem::operator= (other); |
| 578 |
identifier = other.identifier; |
| 579 |
type = other.type->clone_type (); |
| 580 |
const_expr = other.const_expr->clone_expr (); |
| 581 |
locus = other.locus; |
| 582 |
|
| 583 |
return *this; |
| 584 |
} |
| 585 |
|
| 586 |
StaticItem::StaticItem (Analysis::NodeMapping mappings, Identifier name, |
| 587 |
Mutability mut, std::unique_ptr<Type> type, |
| 588 |
std::unique_ptr<Expr> expr, Visibility vis, |
| 589 |
AST::AttrVec outer_attrs, location_t locus) |
| 590 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 591 |
mut (mut), name (std::move (name)), type (std::move (type)), |
| 592 |
expr (std::move (expr)), locus (locus) |
| 593 |
{} |
| 594 |
|
| 595 |
StaticItem::StaticItem (StaticItem const &other) |
| 596 |
: VisItem (other), mut (other.mut), name (other.name), |
| 597 |
type (other.type->clone_type ()), expr (other.expr->clone_expr ()), |
| 598 |
locus (other.locus) |
| 599 |
{} |
| 600 |
|
| 601 |
StaticItem & |
| 602 |
StaticItem::operator= (StaticItem const &other) |
| 603 |
{ |
| 604 |
VisItem::operator= (other); |
| 605 |
name = other.name; |
| 606 |
mut = other.mut; |
| 607 |
type = other.type->clone_type (); |
| 608 |
expr = other.expr->clone_expr (); |
| 609 |
locus = other.locus; |
| 610 |
|
| 611 |
return *this; |
| 612 |
} |
| 613 |
|
| 614 |
TraitFunctionDecl::TraitFunctionDecl ( |
| 615 |
Identifier function_name, FunctionQualifiers qualifiers, |
| 616 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 617 |
tl::optional<SelfParam> self, std::vector<FunctionParam> function_params, |
| 618 |
std::unique_ptr<Type> return_type, WhereClause where_clause) |
| 619 |
: qualifiers (std::move (qualifiers)), |
| 620 |
function_name (std::move (function_name)), |
| 621 |
generic_params (std::move (generic_params)), |
| 622 |
function_params (std::move (function_params)), |
| 623 |
return_type (std::move (return_type)), |
| 624 |
where_clause (std::move (where_clause)), self (std::move (self)) |
| 625 |
{} |
| 626 |
|
| 627 |
TraitFunctionDecl::TraitFunctionDecl (TraitFunctionDecl const &other) |
| 628 |
: qualifiers (other.qualifiers), function_name (other.function_name), |
| 629 |
function_params (other.function_params), |
| 630 |
return_type (other.return_type->clone_type ()), |
| 631 |
where_clause (other.where_clause), self (other.self) |
| 632 |
{ |
| 633 |
generic_params.reserve (other.generic_params.size ()); |
| 634 |
for (const auto &e : other.generic_params) |
| 635 |
generic_params.push_back (e->clone_generic_param ()); |
| 636 |
} |
| 637 |
|
| 638 |
TraitFunctionDecl & |
| 639 |
TraitFunctionDecl::operator= (TraitFunctionDecl const &other) |
| 640 |
{ |
| 641 |
function_name = other.function_name; |
| 642 |
qualifiers = other.qualifiers; |
| 643 |
function_params = other.function_params; |
| 644 |
return_type = other.return_type->clone_type (); |
| 645 |
where_clause = other.where_clause; |
| 646 |
self = other.self; |
| 647 |
|
| 648 |
generic_params.reserve (other.generic_params.size ()); |
| 649 |
for (const auto &e : other.generic_params) |
| 650 |
generic_params.push_back (e->clone_generic_param ()); |
| 651 |
|
| 652 |
return *this; |
| 653 |
} |
| 654 |
|
| 655 |
TraitItemFunc::TraitItemFunc (Analysis::NodeMapping mappings, |
| 656 |
TraitFunctionDecl decl, |
| 657 |
std::unique_ptr<BlockExpr> block_expr, |
| 658 |
AST::AttrVec outer_attrs, location_t locus) |
| 659 |
: TraitItem (mappings), outer_attrs (std::move (outer_attrs)), |
| 660 |
decl (std::move (decl)), block_expr (std::move (block_expr)), locus (locus) |
| 661 |
{} |
| 662 |
|
| 663 |
TraitItemFunc::TraitItemFunc (TraitItemFunc const &other) |
| 664 |
: TraitItem (other.mappings), outer_attrs (other.outer_attrs), |
| 665 |
decl (other.decl), locus (other.locus) |
| 666 |
{ |
| 667 |
if (other.block_expr != nullptr) |
| 668 |
block_expr = other.block_expr->clone_block_expr (); |
| 669 |
} |
| 670 |
|
| 671 |
TraitItemFunc & |
| 672 |
TraitItemFunc::operator= (TraitItemFunc const &other) |
| 673 |
{ |
| 674 |
TraitItem::operator= (other); |
| 675 |
outer_attrs = other.outer_attrs; |
| 676 |
decl = other.decl; |
| 677 |
locus = other.locus; |
| 678 |
mappings = other.mappings; |
| 679 |
if (other.block_expr != nullptr) |
| 680 |
block_expr = other.block_expr->clone_block_expr (); |
| 681 |
|
| 682 |
return *this; |
| 683 |
} |
| 684 |
|
| 685 |
TraitItemConst::TraitItemConst (Analysis::NodeMapping mappings, Identifier name, |
| 686 |
std::unique_ptr<Type> type, |
| 687 |
std::unique_ptr<Expr> expr, |
| 688 |
AST::AttrVec outer_attrs, location_t locus) |
| 689 |
: TraitItem (mappings), outer_attrs (std::move (outer_attrs)), |
| 690 |
name (std::move (name)), type (std::move (type)), expr (std::move (expr)), |
| 691 |
locus (locus) |
| 692 |
{} |
| 693 |
|
| 694 |
TraitItemConst::TraitItemConst (TraitItemConst const &other) |
| 695 |
: TraitItem (other.mappings), outer_attrs (other.outer_attrs), |
| 696 |
name (other.name), type (other.type->clone_type ()), |
| 697 |
expr (other.expr->clone_expr ()), locus (other.locus) |
| 698 |
{} |
| 699 |
|
| 700 |
TraitItemConst & |
| 701 |
TraitItemConst::operator= (TraitItemConst const &other) |
| 702 |
{ |
| 703 |
TraitItem::operator= (other); |
| 704 |
outer_attrs = other.outer_attrs; |
| 705 |
name = other.name; |
| 706 |
type = other.type->clone_type (); |
| 707 |
expr = other.expr->clone_expr (); |
| 708 |
locus = other.locus; |
| 709 |
mappings = other.mappings; |
| 710 |
|
| 711 |
return *this; |
| 712 |
} |
| 713 |
|
| 714 |
TraitItemType::TraitItemType ( |
| 715 |
Analysis::NodeMapping mappings, Identifier name, |
| 716 |
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, |
| 717 |
AST::AttrVec outer_attrs, location_t locus) |
| 718 |
: TraitItem (mappings), outer_attrs (std::move (outer_attrs)), |
| 719 |
name (std::move (name)), type_param_bounds (std::move (type_param_bounds)), |
| 720 |
locus (locus) |
| 721 |
{} |
| 722 |
|
| 723 |
TraitItemType::TraitItemType (TraitItemType const &other) |
| 724 |
: TraitItem (other.mappings), outer_attrs (other.outer_attrs), |
| 725 |
name (other.name), locus (other.locus) |
| 726 |
{ |
| 727 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 728 |
for (const auto &e : other.type_param_bounds) |
| 729 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 730 |
} |
| 731 |
|
| 732 |
TraitItemType & |
| 733 |
TraitItemType::operator= (TraitItemType const &other) |
| 734 |
{ |
| 735 |
TraitItem::operator= (other); |
| 736 |
outer_attrs = other.outer_attrs; |
| 737 |
name = other.name; |
| 738 |
locus = other.locus; |
| 739 |
mappings = other.mappings; |
| 740 |
|
| 741 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 742 |
for (const auto &e : other.type_param_bounds) |
| 743 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 744 |
|
| 745 |
return *this; |
| 746 |
} |
| 747 |
|
| 748 |
Trait::Trait (Analysis::NodeMapping mappings, Identifier name, |
| 749 |
Unsafety unsafety, |
| 750 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 751 |
std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds, |
| 752 |
WhereClause where_clause, |
| 753 |
std::vector<std::unique_ptr<TraitItem>> trait_items, |
| 754 |
Visibility vis, AST::AttrVec outer_attrs, location_t locus) |
| 755 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 756 |
unsafety (unsafety), name (std::move (name)), |
| 757 |
generic_params (std::move (generic_params)), |
| 758 |
type_param_bounds (std::move (type_param_bounds)), |
| 759 |
where_clause (std::move (where_clause)), |
| 760 |
trait_items (std::move (trait_items)), locus (locus) |
| 761 |
{} |
| 762 |
|
| 763 |
Trait::Trait (Trait const &other) |
| 764 |
: VisItem (other), unsafety (other.unsafety), name (other.name), |
| 765 |
where_clause (other.where_clause), locus (other.locus) |
| 766 |
{ |
| 767 |
generic_params.reserve (other.generic_params.size ()); |
| 768 |
for (const auto &e : other.generic_params) |
| 769 |
generic_params.push_back (e->clone_generic_param ()); |
| 770 |
|
| 771 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 772 |
for (const auto &e : other.type_param_bounds) |
| 773 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 774 |
|
| 775 |
trait_items.reserve (other.trait_items.size ()); |
| 776 |
for (const auto &e : other.trait_items) |
| 777 |
trait_items.push_back (e->clone_trait_item ()); |
| 778 |
} |
| 779 |
|
| 780 |
Trait & |
| 781 |
Trait::operator= (Trait const &other) |
| 782 |
{ |
| 783 |
VisItem::operator= (other); |
| 784 |
name = other.name; |
| 785 |
unsafety = other.unsafety; |
| 786 |
where_clause = other.where_clause; |
| 787 |
locus = other.locus; |
| 788 |
|
| 789 |
generic_params.reserve (other.generic_params.size ()); |
| 790 |
for (const auto &e : other.generic_params) |
| 791 |
generic_params.push_back (e->clone_generic_param ()); |
| 792 |
|
| 793 |
type_param_bounds.reserve (other.type_param_bounds.size ()); |
| 794 |
for (const auto &e : other.type_param_bounds) |
| 795 |
type_param_bounds.push_back (e->clone_type_param_bound ()); |
| 796 |
|
| 797 |
trait_items.reserve (other.trait_items.size ()); |
| 798 |
for (const auto &e : other.trait_items) |
| 799 |
trait_items.push_back (e->clone_trait_item ()); |
| 800 |
|
| 801 |
return *this; |
| 802 |
} |
| 803 |
|
| 804 |
ImplBlock::ImplBlock (Analysis::NodeMapping mappings, |
| 805 |
std::vector<std::unique_ptr<ImplItem>> impl_items, |
| 806 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 807 |
std::unique_ptr<Type> impl_type, |
| 808 |
std::unique_ptr<TypePath> trait_ref, |
| 809 |
WhereClause where_clause, BoundPolarity polarity, |
| 810 |
Visibility vis, AST::AttrVec inner_attrs, |
| 811 |
AST::AttrVec outer_attrs, location_t locus, bool unsafe) |
| 812 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 813 |
WithInnerAttrs (std::move (inner_attrs)), |
| 814 |
generic_params (std::move (generic_params)), |
| 815 |
impl_type (std::move (impl_type)), trait_ref (std::move (trait_ref)), |
| 816 |
where_clause (std::move (where_clause)), polarity (polarity), locus (locus), |
| 817 |
impl_items (std::move (impl_items)), unsafe (unsafe) |
| 818 |
{} |
| 819 |
|
| 820 |
ImplBlock::ImplBlock (ImplBlock const &other) |
| 821 |
: VisItem (other), WithInnerAttrs (other.inner_attrs), |
| 822 |
impl_type (other.impl_type->clone_type ()), |
| 823 |
where_clause (other.where_clause), polarity (other.polarity), |
| 824 |
locus (other.locus), unsafe (other.unsafe) |
| 825 |
{ |
| 826 |
generic_params.reserve (other.generic_params.size ()); |
| 827 |
for (const auto &e : other.generic_params) |
| 828 |
generic_params.push_back (e->clone_generic_param ()); |
| 829 |
|
| 830 |
impl_items.reserve (other.impl_items.size ()); |
| 831 |
for (const auto &e : other.impl_items) |
| 832 |
impl_items.push_back (e->clone_inherent_impl_item ()); |
| 833 |
} |
| 834 |
|
| 835 |
ImplBlock & |
| 836 |
ImplBlock::operator= (ImplBlock const &other) |
| 837 |
{ |
| 838 |
VisItem::operator= (other); |
| 839 |
impl_type = other.impl_type->clone_type (); |
| 840 |
where_clause = other.where_clause; |
| 841 |
polarity = other.polarity; |
| 842 |
inner_attrs = other.inner_attrs; |
| 843 |
locus = other.locus; |
| 844 |
unsafe = other.unsafe; |
| 845 |
|
| 846 |
generic_params.reserve (other.generic_params.size ()); |
| 847 |
for (const auto &e : other.generic_params) |
| 848 |
generic_params.push_back (e->clone_generic_param ()); |
| 849 |
|
| 850 |
impl_items.reserve (other.impl_items.size ()); |
| 851 |
for (const auto &e : other.impl_items) |
| 852 |
impl_items.push_back (e->clone_inherent_impl_item ()); |
| 853 |
|
| 854 |
return *this; |
| 855 |
} |
| 856 |
|
| 857 |
ExternalItem::ExternalItem (Analysis::NodeMapping mappings, |
| 858 |
Identifier item_name, Visibility vis, |
| 859 |
AST::AttrVec outer_attrs, location_t locus) |
| 860 |
: mappings (mappings), outer_attrs (std::move (outer_attrs)), |
| 861 |
visibility (std::move (vis)), item_name (std::move (item_name)), |
| 862 |
locus (locus) |
| 863 |
{} |
| 864 |
|
| 865 |
ExternalItem::ExternalItem (ExternalItem const &other) |
| 866 |
: mappings (other.mappings), outer_attrs (other.outer_attrs), |
| 867 |
visibility (other.visibility), item_name (other.item_name), |
| 868 |
locus (other.locus) |
| 869 |
{} |
| 870 |
|
| 871 |
ExternalItem & |
| 872 |
ExternalItem::operator= (ExternalItem const &other) |
| 873 |
{ |
| 874 |
mappings = other.mappings; |
| 875 |
item_name = other.item_name; |
| 876 |
visibility = other.visibility; |
| 877 |
outer_attrs = other.outer_attrs; |
| 878 |
locus = other.locus; |
| 879 |
|
| 880 |
return *this; |
| 881 |
} |
| 882 |
|
| 883 |
ExternalStaticItem::ExternalStaticItem (Analysis::NodeMapping mappings, |
| 884 |
Identifier item_name, |
| 885 |
std::unique_ptr<Type> item_type, |
| 886 |
Mutability mut, Visibility vis, |
| 887 |
AST::AttrVec outer_attrs, |
| 888 |
location_t locus) |
| 889 |
: ExternalItem (std::move (mappings), std::move (item_name), std::move (vis), |
| 890 |
std::move (outer_attrs), locus), |
| 891 |
mut (mut), item_type (std::move (item_type)) |
| 892 |
{} |
| 893 |
|
| 894 |
ExternalStaticItem::ExternalStaticItem (ExternalStaticItem const &other) |
| 895 |
: ExternalItem (other), mut (other.mut), |
| 896 |
item_type (other.item_type->clone_type ()) |
| 897 |
{} |
| 898 |
|
| 899 |
ExternalStaticItem & |
| 900 |
ExternalStaticItem::operator= (ExternalStaticItem const &other) |
| 901 |
{ |
| 902 |
ExternalItem::operator= (other); |
| 903 |
item_type = other.item_type->clone_type (); |
| 904 |
mut = other.mut; |
| 905 |
|
| 906 |
return *this; |
| 907 |
} |
| 908 |
|
| 909 |
NamedFunctionParam::NamedFunctionParam (Analysis::NodeMapping mappings, |
| 910 |
Identifier name, |
| 911 |
std::unique_ptr<Type> param_type) |
| 912 |
: name (std::move (name)), param_type (std::move (param_type)), |
| 913 |
mappings (std::move (mappings)) |
| 914 |
{} |
| 915 |
|
| 916 |
NamedFunctionParam::NamedFunctionParam (NamedFunctionParam const &other) |
| 917 |
: name (other.name), param_type (other.param_type->clone_type ()), |
| 918 |
mappings (other.mappings) |
| 919 |
{} |
| 920 |
|
| 921 |
NamedFunctionParam & |
| 922 |
NamedFunctionParam::operator= (NamedFunctionParam const &other) |
| 923 |
{ |
| 924 |
mappings = other.mappings; |
| 925 |
name = other.name; |
| 926 |
param_type = other.param_type->clone_type (); |
| 927 |
// has_name = other.has_name; |
| 928 |
|
| 929 |
return *this; |
| 930 |
} |
| 931 |
|
| 932 |
ExternalFunctionItem::ExternalFunctionItem ( |
| 933 |
Analysis::NodeMapping mappings, Identifier item_name, |
| 934 |
std::vector<std::unique_ptr<GenericParam>> generic_params, |
| 935 |
std::unique_ptr<Type> return_type, WhereClause where_clause, |
| 936 |
std::vector<NamedFunctionParam> function_params, bool has_variadics, |
| 937 |
Visibility vis, AST::AttrVec outer_attrs, location_t locus) |
| 938 |
: ExternalItem (std::move (mappings), std::move (item_name), std::move (vis), |
| 939 |
std::move (outer_attrs), locus), |
| 940 |
generic_params (std::move (generic_params)), |
| 941 |
return_type (std::move (return_type)), |
| 942 |
where_clause (std::move (where_clause)), |
| 943 |
function_params (std::move (function_params)), has_variadics (has_variadics) |
| 944 |
{} |
| 945 |
|
| 946 |
ExternalFunctionItem::ExternalFunctionItem (ExternalFunctionItem const &other) |
| 947 |
: ExternalItem (other), where_clause (other.where_clause), |
| 948 |
function_params (other.function_params), has_variadics (other.has_variadics) |
| 949 |
{ |
| 950 |
if (other.return_type) |
| 951 |
return_type = other.return_type->clone_type (); |
| 952 |
|
| 953 |
generic_params.reserve (other.generic_params.size ()); |
| 954 |
for (const auto &e : other.generic_params) |
| 955 |
generic_params.push_back (e->clone_generic_param ()); |
| 956 |
} |
| 957 |
|
| 958 |
ExternalFunctionItem & |
| 959 |
ExternalFunctionItem::operator= (ExternalFunctionItem const &other) |
| 960 |
{ |
| 961 |
ExternalItem::operator= (other); |
| 962 |
|
| 963 |
where_clause = other.where_clause; |
| 964 |
function_params = other.function_params; |
| 965 |
has_variadics = other.has_variadics; |
| 966 |
|
| 967 |
if (other.return_type) |
| 968 |
return_type = other.return_type->clone_type (); |
| 969 |
|
| 970 |
generic_params.reserve (other.generic_params.size ()); |
| 971 |
for (const auto &e : other.generic_params) |
| 972 |
generic_params.push_back (e->clone_generic_param ()); |
| 973 |
|
| 974 |
return *this; |
| 975 |
} |
| 976 |
|
| 977 |
ExternalTypeItem::ExternalTypeItem (Analysis::NodeMapping mappings, |
| 978 |
Identifier item_name, Visibility vis, |
| 979 |
location_t locus) |
| 980 |
: ExternalItem (std::move (mappings), std::move (item_name), |
| 981 |
Visibility (std::move (vis)), |
| 982 |
/* FIXME: Is that correct? */ |
| 983 |
{}, locus) |
| 984 |
{} |
| 985 |
|
| 986 |
ExternalTypeItem::ExternalTypeItem (ExternalTypeItem const &other) |
| 987 |
: ExternalItem (other) |
| 988 |
{} |
| 989 |
|
| 990 |
ExternBlock::ExternBlock ( |
| 991 |
Analysis::NodeMapping mappings, ABI abi, |
| 992 |
std::vector<std::unique_ptr<ExternalItem>> extern_items, Visibility vis, |
| 993 |
AST::AttrVec inner_attrs, AST::AttrVec outer_attrs, location_t locus) |
| 994 |
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)), |
| 995 |
WithInnerAttrs (std::move (inner_attrs)), abi (abi), |
| 996 |
extern_items (std::move (extern_items)), locus (locus) |
| 997 |
{} |
| 998 |
|
| 999 |
ExternBlock::ExternBlock (ExternBlock const &other) |
| 1000 |
: VisItem (other), WithInnerAttrs (other.inner_attrs), abi (other.abi), |
| 1001 |
locus (other.locus) |
| 1002 |
{ |
| 1003 |
extern_items.reserve (other.extern_items.size ()); |
| 1004 |
for (const auto &e : other.extern_items) |
| 1005 |
extern_items.push_back (e->clone_external_item ()); |
| 1006 |
} |
| 1007 |
|
| 1008 |
ExternBlock & |
| 1009 |
ExternBlock::operator= (ExternBlock const &other) |
| 1010 |
{ |
| 1011 |
VisItem::operator= (other); |
| 1012 |
abi = other.abi; |
| 1013 |
inner_attrs = other.inner_attrs; |
| 1014 |
locus = other.locus; |
| 1015 |
|
| 1016 |
extern_items.reserve (other.extern_items.size ()); |
| 1017 |
for (const auto &e : other.extern_items) |
| 1018 |
extern_items.push_back (e->clone_external_item ()); |
| 1019 |
|
| 1020 |
return *this; |
| 1021 |
} |
| 1022 |
|
| 1023 |
} // namespace HIR |
| 1024 |
} // namespace Rust |