- Timestamp:
- Jun 20, 2019, 1:45:01 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 54dd994
- Parents:
- 1e5dedc4 (diff), c0f9efe (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/AST
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r1e5dedc4 r3c6e417 993 993 const ast::Expr * visit( const ast::UniqueExpr * node ) override final { 994 994 auto rslt = new UniqueExpr( 995 get<Expression>().accept1(node->expr) 995 get<Expression>().accept1(node->expr), 996 node->id 996 997 ); 997 998 … … 1074 1075 } 1075 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 1076 1086 const ast::Type * visit( const ast::VoidType * node ) override final { 1077 this->node = new VoidType{ cv( node ) }; 1078 return nullptr; 1087 return visitType( node, new VoidType{ cv( node ) } ); 1079 1088 } 1080 1089 … … 1085 1094 Validate::SizeType = type; 1086 1095 } 1087 this->node = type; 1088 return nullptr; 1096 return visitType( node, type ); 1089 1097 } 1090 1098 1091 1099 const ast::Type * visit( const ast::PointerType * node ) override final { 1092 this->node =new PointerType{1100 return visitType( node, new PointerType{ 1093 1101 cv( node ), 1094 1102 get<Type>().accept1( node->base ), … … 1096 1104 (bool)node->isVarLen, 1097 1105 (bool)node->isStatic 1098 }; 1099 return nullptr; 1106 } ); 1100 1107 } 1101 1108 1102 1109 const ast::Type * visit( const ast::ArrayType * node ) override final { 1103 this->node =new ArrayType{1110 return visitType( node, new ArrayType{ 1104 1111 cv( node ), 1105 1112 get<Type>().accept1( node->base ), … … 1107 1114 (bool)node->isVarLen, 1108 1115 (bool)node->isStatic 1109 }; 1110 return nullptr; 1116 } ); 1111 1117 } 1112 1118 1113 1119 const ast::Type * visit( const ast::ReferenceType * node ) override final { 1114 this->node =new ReferenceType{1120 return visitType( node, new ReferenceType{ 1115 1121 cv( node ), 1116 1122 get<Type>().accept1( node->base ) 1117 }; 1118 return nullptr; 1123 } ); 1119 1124 } 1120 1125 1121 1126 const ast::Type * visit( const ast::QualifiedType * node ) override final { 1122 this->node =new QualifiedType{1127 return visitType( node, new QualifiedType{ 1123 1128 cv( node ), 1124 1129 get<Type>().accept1( node->parent ), 1125 1130 get<Type>().accept1( node->child ) 1126 }; 1127 return nullptr; 1131 } ); 1128 1132 } 1129 1133 … … 1136 1140 ty->parameters = get<DeclarationWithType>().acceptL( node->params ); 1137 1141 ty->forall = get<TypeDecl>().acceptL( node->forall ); 1138 this->node = ty; 1139 return nullptr; 1140 } 1141 1142 void postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) { 1142 return visitType( node, ty ); 1143 } 1144 1145 const ast::Type * postvisit( const ast::ReferenceToType * old, ReferenceToType * ty ) { 1143 1146 ty->forall = get<TypeDecl>().acceptL( old->forall ); 1144 1147 ty->parameters = get<Expression>().acceptL( old->params ); 1145 1148 ty->hoistType = old->hoistType; 1149 return visitType( old, ty ); 1146 1150 } 1147 1151 … … 1161 1165 }; 1162 1166 } 1163 postvisit( node, ty ); 1164 this->node = ty; 1165 return nullptr; 1167 return postvisit( node, ty ); 1166 1168 } 1167 1169 … … 1181 1183 }; 1182 1184 } 1183 postvisit( node, ty ); 1184 this->node = ty; 1185 return nullptr; 1185 return postvisit( node, ty ); 1186 1186 } 1187 1187 … … 1201 1201 }; 1202 1202 } 1203 postvisit( node, ty ); 1204 this->node = ty; 1205 return nullptr; 1203 return postvisit( node, ty ); 1206 1204 } 1207 1205 … … 1221 1219 }; 1222 1220 } 1223 postvisit( node, ty ); 1224 this->node = ty; 1225 return nullptr; 1221 return postvisit( node, ty ); 1226 1222 } 1227 1223 … … 1243 1239 }; 1244 1240 } 1245 postvisit( node, ty ); 1246 this->node = ty; 1247 return nullptr; 1241 return postvisit( node, ty ); 1248 1242 } 1249 1243 1250 1244 const ast::Type * visit( const ast::TupleType * node ) override final { 1251 this->node =new TupleType{1245 return visitType( node, new TupleType{ 1252 1246 cv( node ), 1253 1247 get<Type>().acceptL( node->types ) 1254 1248 // members generated by TupleType c'tor 1255 }; 1256 return nullptr; 1249 } ); 1257 1250 } 1258 1251 1259 1252 const ast::Type * visit( const ast::TypeofType * node ) override final { 1260 this->node =new TypeofType{1253 return visitType( node, new TypeofType{ 1261 1254 cv( node ), 1262 1255 get<Expression>().accept1( node->expr ), 1263 1256 (bool)node->kind 1264 }; 1265 return nullptr; 1257 } ); 1266 1258 } 1267 1259 1268 1260 const ast::Type * visit( const ast::VarArgsType * node ) override final { 1269 this->node = new VarArgsType{ cv( node ) }; 1270 return nullptr; 1261 return visitType( node, new VarArgsType{ cv( node ) } ); 1271 1262 } 1272 1263 1273 1264 const ast::Type * visit( const ast::ZeroType * node ) override final { 1274 this->node = new ZeroType{ cv( node ) }; 1275 return nullptr; 1265 return visitType( node, new ZeroType{ cv( node ) } ); 1276 1266 } 1277 1267 1278 1268 const ast::Type * visit( const ast::OneType * node ) override final { 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; 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{} ); 1286 1274 } 1287 1275 … … 2367 2355 auto rslt = new ast::UniqueExpr( 2368 2356 old->location, 2369 GET_ACCEPT_1(expr, Expr) 2357 GET_ACCEPT_1(expr, Expr), 2358 old->get_id() 2370 2359 ); 2371 2360 rslt->object = GET_ACCEPT_1(object, ObjectDecl); … … 2440 2429 } 2441 2430 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 2442 2439 virtual void visit( VoidType * old ) override final { 2443 this->node = new ast::VoidType{ cv( old ) };2440 visitType( old, new ast::VoidType{ cv( old ) } ); 2444 2441 } 2445 2442 … … 2450 2447 sizeType = type; 2451 2448 } 2452 this->node = type;2449 visitType( old, type ); 2453 2450 } 2454 2451 2455 2452 virtual void visit( PointerType * old ) override final { 2456 this->node =new ast::PointerType{2453 visitType( old, new ast::PointerType{ 2457 2454 GET_ACCEPT_1( base, Type ), 2458 2455 GET_ACCEPT_1( dimension, Expr ), … … 2460 2457 (ast::DimensionFlag)old->isStatic, 2461 2458 cv( old ) 2462 } ;2459 } ); 2463 2460 } 2464 2461 2465 2462 virtual void visit( ArrayType * old ) override final { 2466 this->node =new ast::ArrayType{2463 visitType( old, new ast::ArrayType{ 2467 2464 GET_ACCEPT_1( base, Type ), 2468 2465 GET_ACCEPT_1( dimension, Expr ), … … 2470 2467 (ast::DimensionFlag)old->isStatic, 2471 2468 cv( old ) 2472 } ;2469 } ); 2473 2470 } 2474 2471 2475 2472 virtual void visit( ReferenceType * old ) override final { 2476 this->node =new ast::ReferenceType{2473 visitType( old, new ast::ReferenceType{ 2477 2474 GET_ACCEPT_1( base, Type ), 2478 2475 cv( old ) 2479 } ;2476 } ); 2480 2477 } 2481 2478 2482 2479 virtual void visit( QualifiedType * old ) override final { 2483 this->node =new ast::QualifiedType{2480 visitType( old, new ast::QualifiedType{ 2484 2481 GET_ACCEPT_1( parent, Type ), 2485 2482 GET_ACCEPT_1( child, Type ), 2486 2483 cv( old ) 2487 } ;2484 } ); 2488 2485 } 2489 2486 … … 2496 2493 ty->params = GET_ACCEPT_V( parameters, DeclWithType ); 2497 2494 ty->forall = GET_ACCEPT_V( forall, TypeDecl ); 2498 this->node = ty;2495 visitType( old, ty ); 2499 2496 } 2500 2497 … … 2503 2500 ty->params = GET_ACCEPT_V( parameters, Expr ); 2504 2501 ty->hoistType = old->hoistType; 2502 visitType( old, ty ); 2505 2503 } 2506 2504 … … 2521 2519 } 2522 2520 postvisit( old, ty ); 2523 this->node = ty;2524 2521 } 2525 2522 … … 2540 2537 } 2541 2538 postvisit( old, ty ); 2542 this->node = ty;2543 2539 } 2544 2540 … … 2559 2555 } 2560 2556 postvisit( old, ty ); 2561 this->node = ty;2562 2557 } 2563 2558 … … 2578 2573 } 2579 2574 postvisit( old, ty ); 2580 this->node = ty;2581 2575 } 2582 2576 … … 2599 2593 } 2600 2594 postvisit( old, ty ); 2601 this->node = ty;2602 2595 } 2603 2596 2604 2597 virtual void visit( TupleType * old ) override final { 2605 this->node =new ast::TupleType{2598 visitType( old, new ast::TupleType{ 2606 2599 GET_ACCEPT_V( types, Type ), 2607 2600 // members generated by TupleType c'tor 2608 2601 cv( old ) 2609 } ;2602 } ); 2610 2603 } 2611 2604 2612 2605 virtual void visit( TypeofType * old ) override final { 2613 this->node =new ast::TypeofType{2606 visitType( old, new ast::TypeofType{ 2614 2607 GET_ACCEPT_1( expr, Expr ), 2615 2608 (ast::TypeofType::Kind)old->is_basetypeof, 2616 2609 cv( old ) 2617 } ;2610 } ); 2618 2611 } 2619 2612 … … 2623 2616 2624 2617 virtual void visit( VarArgsType * old ) override final { 2625 this->node = new ast::VarArgsType{ cv( old ) };2618 visitType( old, new ast::VarArgsType{ cv( old ) } ); 2626 2619 } 2627 2620 2628 2621 virtual void visit( ZeroType * old ) override final { 2629 this->node = new ast::ZeroType{ cv( old ) };2622 visitType( old, new ast::ZeroType{ cv( old ) } ); 2630 2623 } 2631 2624 2632 2625 virtual void visit( OneType * old ) override final { 2633 this->node = new ast::OneType{ cv( old ) };2634 } 2635 2636 virtual void visit( GlobalScopeType * ) override final {2637 this->node = new ast::GlobalScopeType{};2626 visitType( old, new ast::OneType{ cv( old ) } ); 2627 } 2628 2629 virtual void visit( GlobalScopeType * old ) override final { 2630 visitType( old, new ast::GlobalScopeType{} ); 2638 2631 } 2639 2632 -
src/AST/Expr.hpp
r1e5dedc4 r3c6e417 47 47 48 48 ParamEntry() : decl( 0 ), declptr( nullptr ), actualType( nullptr ), formalType( nullptr ), expr( nullptr ) {} 49 ParamEntry( UniqueId id, Decl * declptr, Type* actual, Type* formal, Expr* e ) 49 ParamEntry( 50 UniqueId id, const Decl * declptr, const Type * actual, const Type * formal, 51 const Expr * e ) 50 52 : decl( id ), declptr( declptr ), actualType( actual ), formalType( formal ), expr( e ) {} 51 53 }; … … 129 131 case Params: return data.inferParams; 130 132 } 133 assert(!"unreachable"); 131 134 return *((InferredParams*)nullptr); 132 135 } … … 138 141 assert(!"Mode was not already Params"); 139 142 return *((InferredParams*)nullptr); 143 } 144 145 void set_inferParams( InferredParams && ps ) { 146 switch(mode) { 147 case Slots: 148 data.resnSlots.~ResnSlots(); 149 // fallthrough 150 case Empty: 151 new(&data.inferParams) InferredParams{ std::move( ps ) }; 152 mode = Params; 153 break; 154 case Params: 155 data.inferParams = std::move( ps ); 156 break; 157 } 140 158 } 141 159 -
src/AST/Type.hpp
r1e5dedc4 r3c6e417 37 37 public: 38 38 CV::Qualifiers qualifiers; 39 40 Type( CV::Qualifiers q = {} ) : qualifiers(q) {} 39 std::vector<ptr<Attribute>> attributes; 40 41 Type( CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 42 : qualifiers(q), attributes(std::move(as)) {} 41 43 42 44 bool is_const() const { return qualifiers.is_const; } … … 268 270 ForallList forall; 269 271 270 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {} ) 271 : Type(q), forall(std::move(fs)) {} 272 ParameterizedType( CV::Qualifiers q ) : Type(q), forall() {} 272 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {}, 273 std::vector<ptr<Attribute>> && as = {} ) 274 : Type(q, std::move(as)), forall(std::move(fs)) {} 275 276 ParameterizedType( CV::Qualifiers q, std::vector<ptr<Attribute>> && as = {} ) 277 : Type(q, std::move(as)), forall() {} 273 278 274 279 private: … … 311 316 public: 312 317 std::vector<ptr<Expr>> params; 313 std::vector<ptr<Attribute>> attributes;314 318 std::string name; 315 319 bool hoistType = false; … … 317 321 ReferenceToType( const std::string& n, CV::Qualifiers q = {}, 318 322 std::vector<ptr<Attribute>> && as = {} ) 319 : ParameterizedType(q ), params(), attributes(std::move(as)), name(n) {}323 : ParameterizedType(q, std::move(as)), params(), name(n) {} 320 324 321 325 /// Gets aggregate declaration this type refers to -
src/AST/TypeEnvironment.hpp
r1e5dedc4 r3c6e417 215 215 std::ostream & operator<<( std::ostream & out, const TypeEnvironment & env ); 216 216 217 } 217 } // namespace ast 218 218 219 219 // Local Variables: // -
src/AST/porting.md
r1e5dedc4 r3c6e417 302 302 * `ExplodedActual.h` => `ExplodedArg.hpp` 303 303 304 `polyCost` 305 * switched order of `env`, `symtab` parameters for better consistency 306 307 `findMinCost` 308 * pulled out conversion cost promotion into separate `promoteCvtCost` function 309 310 `resolveAssertions` => `satisfyAssertions` 311 * `ResolveAssertions.h` => `SatisfyAssertions.hpp` 312 * `Resn*` => `Sat*` 313 304 314 [1] https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Type-Attributes.html#Type-Attributes 305 315
Note: See TracChangeset
for help on using the changeset viewer.