- Timestamp:
- Apr 13, 2022, 2:55:51 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 365c8dcb
- Parents:
- 6b06abe
- Location:
- src/AST
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/AST/Convert.cpp ¶
r6b06abe r4ec9513 951 951 } 952 952 953 const ast::Expr * visit( const ast::DimensionExpr * node ) override final { 954 auto expr = visitBaseExpr( node, new DimensionExpr( node->name ) ); 955 this->node = expr; 956 return nullptr; 957 } 958 953 959 const ast::Expr * visit( const ast::AsmExpr * node ) override final { 954 960 auto expr = visitBaseExpr( node, … … 2463 2469 2464 2470 virtual void visit( const DimensionExpr * old ) override final { 2465 // DimensionExpr gets desugared away in Validate. 2466 // As long as new-AST passes don't use it, this cheap-cheerful error 2467 // detection helps ensure that these occurrences have been compiled 2468 // away, as expected. To move the DimensionExpr boundary downstream 2469 // or move the new-AST translation boundary upstream, implement 2470 // DimensionExpr in the new AST and implement a conversion. 2471 (void) old; 2472 assert(false && "DimensionExpr should not be present at new-AST boundary"); 2471 this->node = visitBaseExpr( old, 2472 new ast::DimensionExpr( old->location, old->name ) 2473 ); 2473 2474 } 2474 2475 -
TabularUnified src/AST/Expr.hpp ¶
r6b06abe r4ec9513 604 604 }; 605 605 606 class DimensionExpr final : public Expr { 607 public: 608 std::string name; 609 610 DimensionExpr( const CodeLocation & loc, std::string name ) 611 : Expr( loc ), name( name ) {} 612 613 const Expr * accept( Visitor & v ) const override { return v.visit( this ); } 614 private: 615 DimensionExpr * clone() const override { return new DimensionExpr{ *this }; } 616 MUTATE_FRIEND 617 }; 618 606 619 /// A GCC "asm constraint operand" used in an asm statement, e.g. `[output] "=f" (result)`. 607 620 /// https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints -
TabularUnified src/AST/Fwd.hpp ¶
r6b06abe r4ec9513 84 84 class CommaExpr; 85 85 class TypeExpr; 86 class DimensionExpr; 86 87 class AsmExpr; 87 88 class ImplicitCopyCtorExpr; -
TabularUnified src/AST/Pass.hpp ¶
r6b06abe r4ec9513 184 184 const ast::Expr * visit( const ast::CommaExpr * ) override final; 185 185 const ast::Expr * visit( const ast::TypeExpr * ) override final; 186 const ast::Expr * visit( const ast::DimensionExpr * ) override final; 186 187 const ast::Expr * visit( const ast::AsmExpr * ) override final; 187 188 const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * ) override final; -
TabularUnified src/AST/Pass.impl.hpp ¶
r6b06abe r4ec9513 575 575 __pass::symtab::addId( core, 0, func ); 576 576 if ( __visit_children() ) { 577 // parameter declarations 577 maybe_accept( node, &FunctionDecl::type_params ); 578 maybe_accept( node, &FunctionDecl::assertions ); 578 579 maybe_accept( node, &FunctionDecl::params ); 579 580 maybe_accept( node, &FunctionDecl::returns ); 580 // type params and assertions 581 maybe_accept( node, &FunctionDecl::type_params ); 582 maybe_accept( node, &FunctionDecl::assertions ); 581 maybe_accept( node, &FunctionDecl::type ); 583 582 // First remember that we are now within a function. 584 583 ValueGuard< bool > oldInFunction( inFunction ); … … 1522 1521 1523 1522 //-------------------------------------------------------------------------- 1523 // DimensionExpr 1524 template< typename core_t > 1525 const ast::Expr * ast::Pass< core_t >::visit( const ast::DimensionExpr * node ) { 1526 VISIT_START( node ); 1527 1528 if ( __visit_children() ) { 1529 guard_symtab guard { *this }; 1530 maybe_accept( node, &DimensionExpr::result ); 1531 } 1532 1533 VISIT_END( Expr, node ); 1534 } 1535 1536 //-------------------------------------------------------------------------- 1524 1537 // AsmExpr 1525 1538 template< typename core_t > … … 1859 1872 1860 1873 if ( __visit_children() ) { 1861 // xxx - should PointerType visit/mutate dimension?1874 maybe_accept( node, &PointerType::dimension ); 1862 1875 maybe_accept( node, &PointerType::base ); 1863 1876 } -
TabularUnified src/AST/Pass.proto.hpp ¶
r6b06abe r4ec9513 26 26 27 27 struct PureVisitor; 28 29 template<typename node_t> 30 node_t * deepCopy( const node_t * localRoot ); 28 31 29 32 namespace __pass { … … 396 399 static inline auto addStructFwd( core_t & core, int, const ast::StructDecl * decl ) -> decltype( core.symtab.addStruct( decl ), void() ) { 397 400 ast::StructDecl * fwd = new ast::StructDecl( decl->location, decl->name ); 398 fwd->params = decl->params; 401 for ( const auto & param : decl->params ) { 402 fwd->params.push_back( deepCopy( param.get() ) ); 403 } 399 404 core.symtab.addStruct( fwd ); 400 405 } … … 405 410 template<typename core_t> 406 411 static inline auto addUnionFwd( core_t & core, int, const ast::UnionDecl * decl ) -> decltype( core.symtab.addUnion( decl ), void() ) { 407 UnionDecl * fwd = new UnionDecl( decl->location, decl->name ); 408 fwd->params = decl->params; 412 ast::UnionDecl * fwd = new ast::UnionDecl( decl->location, decl->name ); 413 for ( const auto & param : decl->params ) { 414 fwd->params.push_back( deepCopy( param.get() ) ); 415 } 409 416 core.symtab.addUnion( fwd ); 410 417 } -
TabularUnified src/AST/Print.cpp ¶
r6b06abe r4ec9513 1101 1101 } 1102 1102 1103 virtual const ast::Expr * visit( const ast::DimensionExpr * node ) override final { 1104 os << "Type-Sys Value: " << node->name; 1105 postprint( node ); 1106 1107 return node; 1108 } 1109 1103 1110 virtual const ast::Expr * visit( const ast::AsmExpr * node ) override final { 1104 1111 os << "Asm Expression:" << endl; -
TabularUnified src/AST/Visitor.hpp ¶
r6b06abe r4ec9513 76 76 virtual const ast::Expr * visit( const ast::CommaExpr * ) = 0; 77 77 virtual const ast::Expr * visit( const ast::TypeExpr * ) = 0; 78 virtual const ast::Expr * visit( const ast::DimensionExpr * ) = 0; 78 79 virtual const ast::Expr * visit( const ast::AsmExpr * ) = 0; 79 80 virtual const ast::Expr * visit( const ast::ImplicitCopyCtorExpr * ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.