- Timestamp:
- Jan 23, 2025, 12:09:40 PM (3 months ago)
- Branches:
- master
- Children:
- 9e72bae3
- Parents:
- 829821c
- Location:
- src/AST
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/AST/Expr.cpp ¶
r829821c r857b5f9 283 283 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( t ) {} 284 284 285 // --- CountExpr286 287 CountExpr::CountExpr( const CodeLocation & loc, const Expr * e )288 : Expr( loc, new BasicType( BasicKind::LongUnsignedInt) ), expr(e), type( nullptr ) {}289 290 CountExpr::CountExpr( const CodeLocation & loc, const Type * t )291 : Expr( loc, new BasicType( BasicKind::LongUnsignedInt) ), expr(nullptr), type( t ) {}292 293 285 // --- AlignofExpr 294 286 295 287 AlignofExpr::AlignofExpr( const CodeLocation & loc, const Type * t ) 296 288 : Expr( loc, new BasicType{ BasicKind::LongUnsignedInt } ), type( t ) {} 289 290 // --- CountofExpr 291 292 CountofExpr::CountofExpr( const CodeLocation & loc, const Type * t ) 293 : Expr( loc, new BasicType( BasicKind::LongUnsignedInt) ), type( t ) {} 297 294 298 295 // --- OffsetofExpr -
TabularUnified src/AST/Expr.hpp ¶
r829821c r857b5f9 490 490 }; 491 491 492 class CountExpr final : public Expr {493 public:494 ptr<Expr> expr;495 ptr<Type> type;496 497 CountExpr( const CodeLocation & loc, const Expr * t );498 CountExpr( const CodeLocation & loc, const Type * t );499 500 const Expr * accept( Visitor & v )const override { return v.visit( this ); }501 private:502 CountExpr * clone() const override { return new CountExpr( *this ); }503 MUTATE_FRIEND504 };505 506 492 /// alignof expression, e.g. `alignof(int)`, `alignof 3+4` 507 493 class AlignofExpr final : public Expr { … … 514 500 private: 515 501 AlignofExpr * clone() const override { return new AlignofExpr{ *this }; } 502 MUTATE_FRIEND 503 }; 504 505 /// countof expression, e.g. `countof(AnEnum)`, `countof pred(Head)` 506 class CountofExpr final : public Expr { 507 public: 508 ptr<Type> type; 509 510 CountofExpr( const CodeLocation & loc, const Type * t ); 511 512 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 513 private: 514 CountofExpr * clone() const override { return new CountofExpr( *this ); } 516 515 MUTATE_FRIEND 517 516 }; -
TabularUnified src/AST/Fwd.hpp ¶
r829821c r857b5f9 86 86 class ConstantExpr; 87 87 class SizeofExpr; 88 class CountExpr;89 88 class AlignofExpr; 89 class CountofExpr; 90 90 class UntypedOffsetofExpr; 91 91 class OffsetofExpr; -
TabularUnified src/AST/Pass.hpp ¶
r829821c r857b5f9 173 173 const ast::Expr * visit( const ast::ConstantExpr * ) override final; 174 174 const ast::Expr * visit( const ast::SizeofExpr * ) override final; 175 const ast::Expr * visit( const ast::CountExpr * ) override final;176 175 const ast::Expr * visit( const ast::AlignofExpr * ) override final; 176 const ast::Expr * visit( const ast::CountofExpr * ) override final; 177 177 const ast::Expr * visit( const ast::UntypedOffsetofExpr * ) override final; 178 178 const ast::Expr * visit( const ast::OffsetofExpr * ) override final; -
TabularUnified src/AST/Pass.impl.hpp ¶
r829821c r857b5f9 1350 1350 1351 1351 //-------------------------------------------------------------------------- 1352 // CountExpr1353 template< typename core_t >1354 const ast::Expr * ast::Pass< core_t >::visit( const ast::CountExpr * node ) {1355 VISIT_START( node );1356 if ( __visit_children() ) {1357 {1358 guard_symtab guard { *this };1359 maybe_accept( node, &CountExpr::result );1360 }1361 if ( node->type ) {1362 maybe_accept( node, &CountExpr::type );1363 } else {1364 maybe_accept( node, &CountExpr::expr );1365 }1366 }1367 VISIT_END( Expr, node );1368 }1369 1370 //--------------------------------------------------------------------------1371 1352 // AlignofExpr 1372 1353 template< typename core_t > … … 1380 1361 } 1381 1362 maybe_accept( node, &AlignofExpr::type ); 1363 } 1364 1365 VISIT_END( Expr, node ); 1366 } 1367 1368 //-------------------------------------------------------------------------- 1369 // CountofExpr 1370 template< typename core_t > 1371 const ast::Expr * ast::Pass< core_t >::visit( const ast::CountofExpr * node ) { 1372 VISIT_START( node ); 1373 1374 if ( __visit_children() ) { 1375 { 1376 guard_symtab guard { *this }; 1377 maybe_accept( node, &CountofExpr::result ); 1378 } 1379 maybe_accept( node, &CountofExpr::type ); 1382 1380 } 1383 1381 -
TabularUnified src/AST/Print.cpp ¶
r829821c r857b5f9 1207 1207 } 1208 1208 1209 virtual const ast::Expr * visit( const ast::Count Expr * node ) override final {1209 virtual const ast::Expr * visit( const ast::CountofExpr * node ) override final { 1210 1210 os << "Count Expression on: "; 1211 1211 ++indent; 1212 if ( node->type ) node->type->accept( *this ); 1213 else safe_print( node->expr ); 1212 safe_print( node->type ); 1214 1213 --indent; 1215 1214 postprint( node ); -
TabularUnified src/AST/Visitor.hpp ¶
r829821c r857b5f9 76 76 virtual const ast::Expr * visit( const ast::ConstantExpr * ) = 0; 77 77 virtual const ast::Expr * visit( const ast::SizeofExpr * ) = 0; 78 virtual const ast::Expr * visit( const ast::CountExpr * ) = 0;79 78 virtual const ast::Expr * visit( const ast::AlignofExpr * ) = 0; 79 virtual const ast::Expr * visit( const ast::CountofExpr * ) = 0; 80 80 virtual const ast::Expr * visit( const ast::UntypedOffsetofExpr * ) = 0; 81 81 virtual const ast::Expr * visit( const ast::OffsetofExpr * ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.