Changes in src/AST/Convert.cpp [1ae47de:1e5dedc4]
- File:
-
- 1 edited
-
src/AST/Convert.cpp (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r1ae47de r1e5dedc4 993 993 const ast::Expr * visit( const ast::UniqueExpr * node ) override final { 994 994 auto rslt = new UniqueExpr( 995 get<Expression>().accept1(node->expr), 996 node->id 995 get<Expression>().accept1(node->expr) 997 996 ); 998 997 … … 1075 1074 } 1076 1075 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 1076 const ast::Type * visit( const ast::VoidType * node ) override final { 1087 return visitType( node, new VoidType{ cv( node ) } ); 1077 this->node = new VoidType{ cv( node ) }; 1078 return nullptr; 1088 1079 } 1089 1080 … … 1094 1085 Validate::SizeType = type; 1095 1086 } 1096 return visitType( node, type ); 1087 this->node = type; 1088 return nullptr; 1097 1089 } 1098 1090 1099 1091 const ast::Type * visit( const ast::PointerType * node ) override final { 1100 return visitType( node,new PointerType{1092 this->node = new PointerType{ 1101 1093 cv( node ), 1102 1094 get<Type>().accept1( node->base ), … … 1104 1096 (bool)node->isVarLen, 1105 1097 (bool)node->isStatic 1106 } ); 1098 }; 1099 return nullptr; 1107 1100 } 1108 1101 1109 1102 const ast::Type * visit( const ast::ArrayType * node ) override final { 1110 return visitType( node,new ArrayType{1103 this->node = new ArrayType{ 1111 1104 cv( node ), 1112 1105 get<Type>().accept1( node->base ), … … 1114 1107 (bool)node->isVarLen, 1115 1108 (bool)node->isStatic 1116 } ); 1109 }; 1110 return nullptr; 1117 1111 } 1118 1112 1119 1113 const ast::Type * visit( const ast::ReferenceType * node ) override final { 1120 return visitType( node,new ReferenceType{1114 this->node = new ReferenceType{ 1121 1115 cv( node ), 1122 1116 get<Type>().accept1( node->base ) 1123 } ); 1117 }; 1118 return nullptr; 1124 1119 } 1125 1120 1126 1121 const ast::Type * visit( const ast::QualifiedType * node ) override final { 1127 return visitType( node,new QualifiedType{1122 this->node = new QualifiedType{ 1128 1123 cv( node ), 1129 1124 get<Type>().accept1( node->parent ), 1130 1125 get<Type>().accept1( node->child ) 1131 } ); 1126 }; 1127 return nullptr; 1132 1128 } 1133 1129 … … 1140 1136 ty->parameters = get<DeclarationWithType>().acceptL( node->params ); 1141 1137 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 ) { 1138 this->node = ty; 1139 return nullptr; 1140 } 1141 1142 void postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) { 1146 1143 ty->forall = get<TypeDecl>().acceptL( old->forall ); 1147 1144 ty->parameters = get<Expression>().acceptL( old->params ); 1148 1145 ty->hoistType = old->hoistType; 1149 return visitType( old, ty );1150 1146 } 1151 1147 … … 1165 1161 }; 1166 1162 } 1167 return postvisit( node, ty ); 1163 postvisit( node, ty ); 1164 this->node = ty; 1165 return nullptr; 1168 1166 } 1169 1167 … … 1183 1181 }; 1184 1182 } 1185 return postvisit( node, ty ); 1183 postvisit( node, ty ); 1184 this->node = ty; 1185 return nullptr; 1186 1186 } 1187 1187 … … 1201 1201 }; 1202 1202 } 1203 return postvisit( node, ty ); 1203 postvisit( node, ty ); 1204 this->node = ty; 1205 return nullptr; 1204 1206 } 1205 1207 … … 1219 1221 }; 1220 1222 } 1221 return postvisit( node, ty ); 1223 postvisit( node, ty ); 1224 this->node = ty; 1225 return nullptr; 1222 1226 } 1223 1227 … … 1239 1243 }; 1240 1244 } 1241 return postvisit( node, ty ); 1245 postvisit( node, ty ); 1246 this->node = ty; 1247 return nullptr; 1242 1248 } 1243 1249 1244 1250 const ast::Type * visit( const ast::TupleType * node ) override final { 1245 return visitType( node,new TupleType{1251 this->node = new TupleType{ 1246 1252 cv( node ), 1247 1253 get<Type>().acceptL( node->types ) 1248 1254 // members generated by TupleType c'tor 1249 } ); 1255 }; 1256 return nullptr; 1250 1257 } 1251 1258 1252 1259 const ast::Type * visit( const ast::TypeofType * node ) override final { 1253 return visitType( node,new TypeofType{1260 this->node = new TypeofType{ 1254 1261 cv( node ), 1255 1262 get<Expression>().accept1( node->expr ), 1256 1263 (bool)node->kind 1257 } ); 1264 }; 1265 return nullptr; 1258 1266 } 1259 1267 1260 1268 const ast::Type * visit( const ast::VarArgsType * node ) override final { 1261 return visitType( node, new VarArgsType{ cv( node ) } ); 1269 this->node = new VarArgsType{ cv( node ) }; 1270 return nullptr; 1262 1271 } 1263 1272 1264 1273 const ast::Type * visit( const ast::ZeroType * node ) override final { 1265 return visitType( node, new ZeroType{ cv( node ) } ); 1274 this->node = new ZeroType{ cv( node ) }; 1275 return nullptr; 1266 1276 } 1267 1277 1268 1278 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{} ); 1279 this->node = new OneType{ cv( node ) }; 1280 return nullptr; 1281 } 1282 1283 const ast::Type * visit( const ast::GlobalScopeType * ) override final { 1284 this->node = new GlobalScopeType{}; 1285 return nullptr; 1274 1286 } 1275 1287 … … 1895 1907 }; 1896 1908 stmt->orElse = { 1897 GET_ACCEPT_1( timeout.statement, Stmt),1898 GET_ACCEPT_1( timeout.condition, Expr),1909 GET_ACCEPT_1(orelse.statement, Stmt), 1910 GET_ACCEPT_1(orelse.condition, Expr), 1899 1911 }; 1900 1912 … … 2355 2367 auto rslt = new ast::UniqueExpr( 2356 2368 old->location, 2357 GET_ACCEPT_1(expr, Expr), 2358 old->get_id() 2369 GET_ACCEPT_1(expr, Expr) 2359 2370 ); 2360 2371 rslt->object = GET_ACCEPT_1(object, ObjectDecl); … … 2429 2440 } 2430 2441 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 2442 virtual void visit( VoidType * old ) override final { 2440 visitType( old, new ast::VoidType{ cv( old ) } );2443 this->node = new ast::VoidType{ cv( old ) }; 2441 2444 } 2442 2445 … … 2447 2450 sizeType = type; 2448 2451 } 2449 visitType( old, type );2452 this->node = type; 2450 2453 } 2451 2454 2452 2455 virtual void visit( PointerType * old ) override final { 2453 visitType( old,new ast::PointerType{2456 this->node = new ast::PointerType{ 2454 2457 GET_ACCEPT_1( base, Type ), 2455 2458 GET_ACCEPT_1( dimension, Expr ), … … 2457 2460 (ast::DimensionFlag)old->isStatic, 2458 2461 cv( old ) 2459 } );2462 }; 2460 2463 } 2461 2464 2462 2465 virtual void visit( ArrayType * old ) override final { 2463 visitType( old,new ast::ArrayType{2466 this->node = new ast::ArrayType{ 2464 2467 GET_ACCEPT_1( base, Type ), 2465 2468 GET_ACCEPT_1( dimension, Expr ), … … 2467 2470 (ast::DimensionFlag)old->isStatic, 2468 2471 cv( old ) 2469 } );2472 }; 2470 2473 } 2471 2474 2472 2475 virtual void visit( ReferenceType * old ) override final { 2473 visitType( old,new ast::ReferenceType{2476 this->node = new ast::ReferenceType{ 2474 2477 GET_ACCEPT_1( base, Type ), 2475 2478 cv( old ) 2476 } );2479 }; 2477 2480 } 2478 2481 2479 2482 virtual void visit( QualifiedType * old ) override final { 2480 visitType( old,new ast::QualifiedType{2483 this->node = new ast::QualifiedType{ 2481 2484 GET_ACCEPT_1( parent, Type ), 2482 2485 GET_ACCEPT_1( child, Type ), 2483 2486 cv( old ) 2484 } );2487 }; 2485 2488 } 2486 2489 … … 2493 2496 ty->params = GET_ACCEPT_V( parameters, DeclWithType ); 2494 2497 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2495 visitType( old, ty );2498 this->node = ty; 2496 2499 } 2497 2500 … … 2500 2503 ty->params = GET_ACCEPT_V( parameters, Expr ); 2501 2504 ty->hoistType = old->hoistType; 2502 visitType( old, ty );2503 2505 } 2504 2506 … … 2519 2521 } 2520 2522 postvisit( old, ty ); 2523 this->node = ty; 2521 2524 } 2522 2525 … … 2537 2540 } 2538 2541 postvisit( old, ty ); 2542 this->node = ty; 2539 2543 } 2540 2544 … … 2555 2559 } 2556 2560 postvisit( old, ty ); 2561 this->node = ty; 2557 2562 } 2558 2563 … … 2573 2578 } 2574 2579 postvisit( old, ty ); 2580 this->node = ty; 2575 2581 } 2576 2582 … … 2593 2599 } 2594 2600 postvisit( old, ty ); 2601 this->node = ty; 2595 2602 } 2596 2603 2597 2604 virtual void visit( TupleType * old ) override final { 2598 visitType( old,new ast::TupleType{2605 this->node = new ast::TupleType{ 2599 2606 GET_ACCEPT_V( types, Type ), 2600 2607 // members generated by TupleType c'tor 2601 2608 cv( old ) 2602 } );2609 }; 2603 2610 } 2604 2611 2605 2612 virtual void visit( TypeofType * old ) override final { 2606 visitType( old,new ast::TypeofType{2613 this->node = new ast::TypeofType{ 2607 2614 GET_ACCEPT_1( expr, Expr ), 2608 2615 (ast::TypeofType::Kind)old->is_basetypeof, 2609 2616 cv( old ) 2610 } );2617 }; 2611 2618 } 2612 2619 … … 2616 2623 2617 2624 virtual void visit( VarArgsType * old ) override final { 2618 visitType( old, new ast::VarArgsType{ cv( old ) } );2625 this->node = new ast::VarArgsType{ cv( old ) }; 2619 2626 } 2620 2627 2621 2628 virtual void visit( ZeroType * old ) override final { 2622 visitType( old, new ast::ZeroType{ cv( old ) } );2629 this->node = new ast::ZeroType{ cv( old ) }; 2623 2630 } 2624 2631 2625 2632 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{} );2633 this->node = new ast::OneType{ cv( old ) }; 2634 } 2635 2636 virtual void visit( GlobalScopeType * ) override final { 2637 this->node = new ast::GlobalScopeType{}; 2631 2638 } 2632 2639
Note:
See TracChangeset
for help on using the changeset viewer.