Changeset 4ec9513
- Timestamp:
- Apr 13, 2022, 2:55:51 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 365c8dcb
- Parents:
- 6b06abe
- Files:
-
- 6 added
- 13 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
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 -
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 -
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; -
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; -
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 } -
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 } -
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; -
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; -
src/Common/CodeLocationTools.cpp
r6b06abe r4ec9513 147 147 macro(CommaExpr, Expr) \ 148 148 macro(TypeExpr, Expr) \ 149 macro(DimensionExpr, Expr) \ 149 150 macro(AsmExpr, Expr) \ 150 151 macro(ImplicitCopyCtorExpr, Expr) \ -
src/InitTweak/GenInit.cc
r6b06abe r4ec9513 402 402 retVal->location, "?{}", retVal, stmt->expr ); 403 403 assertf( ctorStmt, 404 "ReturnFixer: genCtorDtor returned n llptr: %s / %s",404 "ReturnFixer: genCtorDtor returned nullptr: %s / %s", 405 405 toString( retVal ).c_str(), 406 406 toString( stmt->expr ).c_str() ); 407 407 stmtsToAddBefore.push_back( ctorStmt ); 408 408 409 409 // Return the retVal object. … … 421 421 void genInit( ast::TranslationUnit & transUnit ) { 422 422 ast::Pass<HoistArrayDimension_NoResolve_New>::run( transUnit ); 423 ast::Pass<ReturnFixer_New>::run( transUnit ); 424 } 425 426 void fixReturnStatements( ast::TranslationUnit & transUnit ) { 423 427 ast::Pass<ReturnFixer_New>::run( transUnit ); 424 428 } -
src/InitTweak/GenInit.h
r6b06abe r4ec9513 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Oct 22 16:08:00 202113 // Update Count : 612 // Last Modified On : Fri Mar 18 14:22:00 2022 13 // Update Count : 7 14 14 // 15 15 … … 31 31 /// Converts return statements into copy constructor calls on the hidden return variable 32 32 void fixReturnStatements( std::list< Declaration * > & translationUnit ); 33 void fixReturnStatements( ast::TranslationUnit & translationUnit ); 33 34 34 35 /// generates a single ctor/dtor statement using objDecl as the 'this' parameter and arg as the optional argument -
src/Validate/module.mk
r6b06abe r4ec9513 22 22 Validate/ForallPointerDecay.cpp \ 23 23 Validate/ForallPointerDecay.hpp \ 24 Validate/GenericParameter.cpp \ 25 Validate/GenericParameter.hpp \ 24 26 Validate/HandleAttributes.cc \ 25 27 Validate/HandleAttributes.h \ … … 28 30 Validate/LabelAddressFixer.cpp \ 29 31 Validate/LabelAddressFixer.hpp \ 32 Validate/ReturnCheck.cpp \ 33 Validate/ReturnCheck.hpp \ 30 34 Validate/FindSpecialDeclsNew.cpp \ 31 35 Validate/FindSpecialDecls.cc \ -
src/main.cc
r6b06abe r4ec9513 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Mar 11 10:39:00 202213 // Update Count : 67 112 // Last Modified On : Wed Apr 13 11:11:00 2022 13 // Update Count : 672 14 14 // 15 15 … … 75 75 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... 76 76 #include "Validate/Autogen.hpp" // for autogenerateRoutines 77 #include "Validate/GenericParameter.hpp" // for fillGenericParameters, tr... 77 78 #include "Validate/FindSpecialDecls.h" // for findGlobalDecls 78 79 #include "Validate/ForallPointerDecay.hpp" // for decayForallPointers … … 80 81 #include "Validate/InitializerLength.hpp" // for setLengthFromInitializer 81 82 #include "Validate/LabelAddressFixer.hpp" // for fixLabelAddresses 83 #include "Validate/ReturnCheck.hpp" // for checkReturnStatements 82 84 #include "Virtual/ExpandCasts.h" // for expandCasts 83 85 … … 327 329 PASS( "Validate-A", SymTab::validate_A( translationUnit ) ); 328 330 PASS( "Validate-B", SymTab::validate_B( translationUnit ) ); 329 PASS( "Validate-C", SymTab::validate_C( translationUnit ) );330 331 331 332 CodeTools::fillLocations( translationUnit ); … … 341 342 342 343 forceFillCodeLocations( transUnit ); 344 345 // Check as early as possible. Can't happen before 346 // LinkReferenceToType, observed failing when attempted 347 // before eliminateTypedef 348 PASS( "Validate Generic Parameters", Validate::fillGenericParameters( transUnit ) ); 349 350 PASS( "Translate Dimensions", Validate::translateDimensionParameters( transUnit ) ); 351 PASS( "Check Function Returns", Validate::checkReturnStatements( transUnit ) ); 352 353 // Must happen before Autogen. 354 PASS( "Fix Return Statements", InitTweak::fixReturnStatements( transUnit ) ); 343 355 344 356 PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords( transUnit ) ); … … 426 438 translationUnit = convert( move( transUnit ) ); 427 439 } else { 440 PASS( "Validate-C", SymTab::validate_C( translationUnit ) ); 428 441 PASS( "Validate-D", SymTab::validate_D( translationUnit ) ); 429 442 PASS( "Validate-E", SymTab::validate_E( translationUnit ) );
Note: See TracChangeset
for help on using the changeset viewer.