Changes in / [c0f9efe:b69233ac]
- Location:
- src/AST
- Files:
-
- 2 edited
-
Convert.cpp (modified) (22 diffs)
-
Type.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rc0f9efe rb69233ac 1075 1075 } 1076 1076 1077 const ast::Type * visitType( const ast::Type * node, Type * type ) {1078 // Some types do this in their constructor so add a check.1079 if ( !node->attributes.empty() && type->attributes.empty() ) {1080 type->attributes = get<Attribute>().acceptL( node->attributes );1081 }1082 this->node = type;1083 return nullptr;1084 }1085 1086 1077 const ast::Type * visit( const ast::VoidType * node ) override final { 1087 return visitType( node, new VoidType{ cv( node ) } ); 1078 this->node = new VoidType{ cv( node ) }; 1079 return nullptr; 1088 1080 } 1089 1081 … … 1094 1086 Validate::SizeType = type; 1095 1087 } 1096 return visitType( node, type ); 1088 this->node = type; 1089 return nullptr; 1097 1090 } 1098 1091 1099 1092 const ast::Type * visit( const ast::PointerType * node ) override final { 1100 return visitType( node,new PointerType{1093 this->node = new PointerType{ 1101 1094 cv( node ), 1102 1095 get<Type>().accept1( node->base ), … … 1104 1097 (bool)node->isVarLen, 1105 1098 (bool)node->isStatic 1106 } ); 1099 }; 1100 return nullptr; 1107 1101 } 1108 1102 1109 1103 const ast::Type * visit( const ast::ArrayType * node ) override final { 1110 return visitType( node,new ArrayType{1104 this->node = new ArrayType{ 1111 1105 cv( node ), 1112 1106 get<Type>().accept1( node->base ), … … 1114 1108 (bool)node->isVarLen, 1115 1109 (bool)node->isStatic 1116 } ); 1110 }; 1111 return nullptr; 1117 1112 } 1118 1113 1119 1114 const ast::Type * visit( const ast::ReferenceType * node ) override final { 1120 return visitType( node,new ReferenceType{1115 this->node = new ReferenceType{ 1121 1116 cv( node ), 1122 1117 get<Type>().accept1( node->base ) 1123 } ); 1118 }; 1119 return nullptr; 1124 1120 } 1125 1121 1126 1122 const ast::Type * visit( const ast::QualifiedType * node ) override final { 1127 return visitType( node,new QualifiedType{1123 this->node = new QualifiedType{ 1128 1124 cv( node ), 1129 1125 get<Type>().accept1( node->parent ), 1130 1126 get<Type>().accept1( node->child ) 1131 } ); 1127 }; 1128 return nullptr; 1132 1129 } 1133 1130 … … 1140 1137 ty->parameters = get<DeclarationWithType>().acceptL( node->params ); 1141 1138 ty->forall = get<TypeDecl>().acceptL( node->forall ); 1142 return visitType( node, ty ); 1143 } 1144 1145 const ast::Type * postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) { 1139 this->node = ty; 1140 return nullptr; 1141 } 1142 1143 void postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) { 1146 1144 ty->forall = get<TypeDecl>().acceptL( old->forall ); 1147 1145 ty->parameters = get<Expression>().acceptL( old->params ); 1148 1146 ty->hoistType = old->hoistType; 1149 return visitType( old, ty );1150 1147 } 1151 1148 … … 1165 1162 }; 1166 1163 } 1167 return postvisit( node, ty ); 1164 postvisit( node, ty ); 1165 this->node = ty; 1166 return nullptr; 1168 1167 } 1169 1168 … … 1183 1182 }; 1184 1183 } 1185 return postvisit( node, ty ); 1184 postvisit( node, ty ); 1185 this->node = ty; 1186 return nullptr; 1186 1187 } 1187 1188 … … 1201 1202 }; 1202 1203 } 1203 return postvisit( node, ty ); 1204 postvisit( node, ty ); 1205 this->node = ty; 1206 return nullptr; 1204 1207 } 1205 1208 … … 1219 1222 }; 1220 1223 } 1221 return postvisit( node, ty ); 1224 postvisit( node, ty ); 1225 this->node = ty; 1226 return nullptr; 1222 1227 } 1223 1228 … … 1239 1244 }; 1240 1245 } 1241 return postvisit( node, ty ); 1246 postvisit( node, ty ); 1247 this->node = ty; 1248 return nullptr; 1242 1249 } 1243 1250 1244 1251 const ast::Type * visit( const ast::TupleType * node ) override final { 1245 return visitType( node,new TupleType{1252 this->node = new TupleType{ 1246 1253 cv( node ), 1247 1254 get<Type>().acceptL( node->types ) 1248 1255 // members generated by TupleType c'tor 1249 } ); 1256 }; 1257 return nullptr; 1250 1258 } 1251 1259 1252 1260 const ast::Type * visit( const ast::TypeofType * node ) override final { 1253 return visitType( node,new TypeofType{1261 this->node = new TypeofType{ 1254 1262 cv( node ), 1255 1263 get<Expression>().accept1( node->expr ), 1256 1264 (bool)node->kind 1257 } ); 1265 }; 1266 return nullptr; 1258 1267 } 1259 1268 1260 1269 const ast::Type * visit( const ast::VarArgsType * node ) override final { 1261 return visitType( node, new VarArgsType{ cv( node ) } ); 1270 this->node = new VarArgsType{ cv( node ) }; 1271 return nullptr; 1262 1272 } 1263 1273 1264 1274 const ast::Type * visit( const ast::ZeroType * node ) override final { 1265 return visitType( node, new ZeroType{ cv( node ) } ); 1275 this->node = new ZeroType{ cv( node ) }; 1276 return nullptr; 1266 1277 } 1267 1278 1268 1279 const ast::Type * visit( const ast::OneType * node ) override final { 1269 return visitType( node, new OneType{ cv( node ) } ); 1270 } 1271 1272 const ast::Type * visit( const ast::GlobalScopeType * node ) override final { 1273 return visitType( node, new GlobalScopeType{} ); 1280 this->node = new OneType{ cv( node ) }; 1281 return nullptr; 1282 } 1283 1284 const ast::Type * visit( const ast::GlobalScopeType * ) override final { 1285 this->node = new GlobalScopeType{}; 1286 return nullptr; 1274 1287 } 1275 1288 … … 2429 2442 } 2430 2443 2431 void visitType( Type * old, ast::Type * type ) {2432 // Some types do this in their constructor so add a check.2433 if ( !old->attributes.empty() && type->attributes.empty() ) {2434 type->attributes = GET_ACCEPT_V(attributes, Attribute);2435 }2436 this->node = type;2437 }2438 2439 2444 virtual void visit( VoidType * old ) override final { 2440 visitType( old, new ast::VoidType{ cv( old ) } );2445 this->node = new ast::VoidType{ cv( old ) }; 2441 2446 } 2442 2447 … … 2447 2452 sizeType = type; 2448 2453 } 2449 visitType( old, type );2454 this->node = type; 2450 2455 } 2451 2456 2452 2457 virtual void visit( PointerType * old ) override final { 2453 visitType( old,new ast::PointerType{2458 this->node = new ast::PointerType{ 2454 2459 GET_ACCEPT_1( base, Type ), 2455 2460 GET_ACCEPT_1( dimension, Expr ), … … 2457 2462 (ast::DimensionFlag)old->isStatic, 2458 2463 cv( old ) 2459 } );2464 }; 2460 2465 } 2461 2466 2462 2467 virtual void visit( ArrayType * old ) override final { 2463 visitType( old,new ast::ArrayType{2468 this->node = new ast::ArrayType{ 2464 2469 GET_ACCEPT_1( base, Type ), 2465 2470 GET_ACCEPT_1( dimension, Expr ), … … 2467 2472 (ast::DimensionFlag)old->isStatic, 2468 2473 cv( old ) 2469 } );2474 }; 2470 2475 } 2471 2476 2472 2477 virtual void visit( ReferenceType * old ) override final { 2473 visitType( old,new ast::ReferenceType{2478 this->node = new ast::ReferenceType{ 2474 2479 GET_ACCEPT_1( base, Type ), 2475 2480 cv( old ) 2476 } );2481 }; 2477 2482 } 2478 2483 2479 2484 virtual void visit( QualifiedType * old ) override final { 2480 visitType( old,new ast::QualifiedType{2485 this->node = new ast::QualifiedType{ 2481 2486 GET_ACCEPT_1( parent, Type ), 2482 2487 GET_ACCEPT_1( child, Type ), 2483 2488 cv( old ) 2484 } );2489 }; 2485 2490 } 2486 2491 … … 2493 2498 ty->params = GET_ACCEPT_V( parameters, DeclWithType ); 2494 2499 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2495 visitType( old, ty );2500 this->node = ty; 2496 2501 } 2497 2502 … … 2500 2505 ty->params = GET_ACCEPT_V( parameters, Expr ); 2501 2506 ty->hoistType = old->hoistType; 2502 visitType( old, ty );2503 2507 } 2504 2508 … … 2519 2523 } 2520 2524 postvisit( old, ty ); 2525 this->node = ty; 2521 2526 } 2522 2527 … … 2537 2542 } 2538 2543 postvisit( old, ty ); 2544 this->node = ty; 2539 2545 } 2540 2546 … … 2555 2561 } 2556 2562 postvisit( old, ty ); 2563 this->node = ty; 2557 2564 } 2558 2565 … … 2573 2580 } 2574 2581 postvisit( old, ty ); 2582 this->node = ty; 2575 2583 } 2576 2584 … … 2593 2601 } 2594 2602 postvisit( old, ty ); 2603 this->node = ty; 2595 2604 } 2596 2605 2597 2606 virtual void visit( TupleType * old ) override final { 2598 visitType( old,new ast::TupleType{2607 this->node = new ast::TupleType{ 2599 2608 GET_ACCEPT_V( types, Type ), 2600 2609 // members generated by TupleType c'tor 2601 2610 cv( old ) 2602 } );2611 }; 2603 2612 } 2604 2613 2605 2614 virtual void visit( TypeofType * old ) override final { 2606 visitType( old,new ast::TypeofType{2615 this->node = new ast::TypeofType{ 2607 2616 GET_ACCEPT_1( expr, Expr ), 2608 2617 (ast::TypeofType::Kind)old->is_basetypeof, 2609 2618 cv( old ) 2610 } );2619 }; 2611 2620 } 2612 2621 … … 2616 2625 2617 2626 virtual void visit( VarArgsType * old ) override final { 2618 visitType( old, new ast::VarArgsType{ cv( old ) } );2627 this->node = new ast::VarArgsType{ cv( old ) }; 2619 2628 } 2620 2629 2621 2630 virtual void visit( ZeroType * old ) override final { 2622 visitType( old, new ast::ZeroType{ cv( old ) } );2631 this->node = new ast::ZeroType{ cv( old ) }; 2623 2632 } 2624 2633 2625 2634 virtual void visit( OneType * old ) override final { 2626 visitType( old, new ast::OneType{ cv( old ) } );2627 } 2628 2629 virtual void visit( GlobalScopeType * old) override final {2630 visitType( old, new ast::GlobalScopeType{} );2635 this->node = new ast::OneType{ cv( old ) }; 2636 } 2637 2638 virtual void visit( GlobalScopeType * ) override final { 2639 this->node = new ast::GlobalScopeType{}; 2631 2640 } 2632 2641 -
src/AST/Type.hpp
rc0f9efe rb69233ac 39 39 std::vector<ptr<Attribute>> attributes; 40 40 41 Type( CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 41 Type( CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 42 42 : qualifiers(q), attributes(std::move(as)) {} 43 43 … … 270 270 ForallList forall; 271 271 272 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {}, 272 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {}, 273 273 std::vector<ptr<Attribute>> && as = {} ) 274 274 : Type(q, std::move(as)), forall(std::move(fs)) {} 275 276 ParameterizedType( CV::Qualifiers q, std::vector<ptr<Attribute>> && as = {} ) 275 276 ParameterizedType( CV::Qualifiers q, std::vector<ptr<Attribute>> && as = {} ) 277 277 : Type(q, std::move(as)), forall() {} 278 278
Note:
See TracChangeset
for help on using the changeset viewer.