- Timestamp:
- Sep 9, 2024, 6:16:09 PM (5 weeks ago)
- Branches:
- master
- Children:
- aa14aafe
- Parents:
- d93b813 (diff), f5dbc8d (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:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.cpp
rd93b813 r3d618a0 276 276 // --- SizeofExpr 277 277 278 SizeofExpr::SizeofExpr( const CodeLocation & loc, const Expr * e )279 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {}280 281 278 SizeofExpr::SizeofExpr( const CodeLocation & loc, const Type * t ) 282 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( nullptr ),type( t ) {}279 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( t ) {} 283 280 284 281 // --- CountExpr … … 292 289 // --- AlignofExpr 293 290 294 AlignofExpr::AlignofExpr( const CodeLocation & loc, const Expr * e )295 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( e ), type( nullptr ) {}296 297 291 AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * t ) 298 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), expr( nullptr ),type( t ) {}292 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( t ) {} 299 293 300 294 // --- OffsetofExpr -
src/AST/Expr.hpp
rd93b813 r3d618a0 480 480 class SizeofExpr final : public Expr { 481 481 public: 482 ptr<Type> type; 483 484 SizeofExpr( const CodeLocation & loc, const Type * t ); 485 486 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 487 private: 488 SizeofExpr * clone() const override { return new SizeofExpr{ *this }; } 489 MUTATE_FRIEND 490 }; 491 492 class CountExpr final : public Expr { 493 public: 482 494 ptr<Expr> expr; 483 495 ptr<Type> type; 484 496 485 SizeofExpr( const CodeLocation & loc, const Expr * e );486 SizeofExpr( const CodeLocation & loc, const Type * t );487 // deliberately no disambiguating overload for nullptr_t488 489 const Expr * accept( Visitor & v ) const override { return v.visit( this ); }490 private:491 SizeofExpr * clone() const override { return new SizeofExpr{ *this }; }492 MUTATE_FRIEND493 };494 495 class CountExpr final : public Expr {496 public:497 ptr<Expr> expr;498 ptr<Type> type;499 500 497 CountExpr( const CodeLocation & loc, const Expr * t ); 501 498 CountExpr( const CodeLocation & loc, const Type * t ); … … 510 507 class AlignofExpr final : public Expr { 511 508 public: 512 ptr<Expr> expr;513 509 ptr<Type> type; 514 510 515 AlignofExpr( const CodeLocation & loc, const Expr * e );516 511 AlignofExpr( const CodeLocation & loc, const Type * t ); 517 // deliberately no disambiguating overload for nullptr_t518 512 519 513 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/Pass.hpp
rd93b813 r3d618a0 342 342 /// set visit_children false of all child nodes should be ignored 343 343 struct WithShortCircuiting { 344 bool visit_children ;344 bool visit_children = true; 345 345 }; 346 346 -
src/AST/Pass.impl.hpp
rd93b813 r3d618a0 1319 1319 maybe_accept( node, &SizeofExpr::result ); 1320 1320 } 1321 if ( node->type ) { 1322 maybe_accept( node, &SizeofExpr::type ); 1323 } else { 1324 maybe_accept( node, &SizeofExpr::expr ); 1325 } 1321 maybe_accept( node, &SizeofExpr::type ); 1326 1322 } 1327 1323 … … 1359 1355 maybe_accept( node, &AlignofExpr::result ); 1360 1356 } 1361 if ( node->type ) { 1362 maybe_accept( node, &AlignofExpr::type ); 1363 } else { 1364 maybe_accept( node, &AlignofExpr::expr ); 1365 } 1357 maybe_accept( node, &AlignofExpr::type ); 1366 1358 } 1367 1359 -
src/AST/Print.cpp
rd93b813 r3d618a0 1152 1152 os << "Sizeof Expression on: "; 1153 1153 ++indent; 1154 node->type->accept( *this ); 1155 --indent; 1156 postprint( node ); 1157 1158 return node; 1159 } 1160 1161 virtual const ast::Expr * visit( const ast::CountExpr * node ) override final { 1162 os << "Count Expression on: "; 1163 ++indent; 1154 1164 if ( node->type ) node->type->accept( *this ); 1155 1165 else safe_print( node->expr ); 1156 1166 --indent; 1157 1167 postprint( node ); 1158 1159 return node;1160 }1161 1162 virtual const ast::Expr * visit( const ast::CountExpr * node ) override final {1163 os << "Count Expression on: ";1164 ++indent;1165 if ( node->type ) node->type->accept( *this );1166 else safe_print( node->expr );1167 --indent;1168 postprint( node );1169 1168 return node; 1170 1169 } … … 1173 1172 os << "Alignof Expression on: "; 1174 1173 ++indent; 1175 if ( node->type ) node->type->accept( *this ); 1176 else safe_print( node->expr ); 1174 node->type->accept( *this ); 1177 1175 --indent; 1178 1176 postprint( node ); -
src/AST/Util.cpp
rd93b813 r3d618a0 104 104 } 105 105 assertf( false, "Member not found." ); 106 }107 108 template<typename node_t>109 void oneOfExprOrType( const node_t * node ) {110 if ( node->expr ) {111 assertf( node->expr && !node->type, "Exactly one of expr or type should be set." );112 } else {113 assertf( !node->expr && node->type, "Exactly one of expr or type should be set." );114 }115 106 } 116 107 … … 159 150 previsit( (const ParseNode *)node ); 160 151 memberMatchesAggregate( node ); 161 }162 163 void previsit( const SizeofExpr * node ) {164 previsit( (const ParseNode *)node );165 oneOfExprOrType( node );166 }167 168 void previsit( const AlignofExpr * node ) {169 previsit( (const ParseNode *)node );170 oneOfExprOrType( node );171 152 } 172 153
Note: See TracChangeset
for help on using the changeset viewer.