Changeset e14d169
- Timestamp:
- Oct 16, 2023, 1:56:40 PM (14 months ago)
- Branches:
- master
- Children:
- 4d2d7e27, 52a5262e
- Parents:
- 6bd9f9e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/BoxNew.cpp
r6bd9f9e re14d169 376 376 ast::Expr const * postvisit( ast::AddressExpr const * expr ); 377 377 ast::ReturnStmt const * previsit( ast::ReturnStmt const * stmt ); 378 void previsit( ast::PointerType const * type );379 void previsit( ast::FunctionType const * type );380 378 381 379 void beginScope(); … … 553 551 554 552 ast::FunctionDecl const * CallAdapter::previsit( ast::FunctionDecl const * decl ) { 553 // Prevent type declaration information from leaking out. 554 GuardScope( scopeTypeVars ); 555 555 556 if ( nullptr == decl->stmts ) { 556 // This may keep TypeDecls we don't ever want from sneaking in.557 // Not visiting child nodes might just be faster.558 GuardScope( scopeTypeVars );559 557 return decl; 560 558 } 561 559 562 GuardScope( scopeTypeVars );563 560 GuardValue( retval ); 564 561 … … 687 684 688 685 assert( typeSubs ); 689 ast::Type const * concRetType = replaceWithConcrete( dynRetType, *typeSubs );690 // Used to use dynRetType instead of concRetType; this changed so that691 // the correct type parameters are passed for return types (it should be692 // the concrete type's parameters, not the formal type's).693 686 ast::vector<ast::Expr>::iterator argIt = 694 687 passTypeVars( mutExpr, function ); … … 768 761 } 769 762 return stmt; 770 }771 772 void CallAdapter::previsit( ast::PointerType const * type ) {773 GuardScope( scopeTypeVars );774 makeTypeVarMap( type, scopeTypeVars );775 }776 777 void CallAdapter::previsit( ast::FunctionType const * type ) {778 GuardScope( scopeTypeVars );779 makeTypeVarMap( type, scopeTypeVars );780 763 } 781 764 … … 1595 1578 PolyGenericCalculator(); 1596 1579 1597 void previsit( ast::ObjectDecl const * decl );1598 1580 void previsit( ast::FunctionDecl const * decl ); 1599 1581 void previsit( ast::TypedefDecl const * decl ); … … 1602 1584 ast::StructDecl const * previsit( ast::StructDecl const * decl ); 1603 1585 ast::UnionDecl const * previsit( ast::UnionDecl const * decl ); 1604 void previsit( ast::PointerType const * type );1605 void previsit( ast::FunctionType const * type );1606 1586 ast::DeclStmt const * previsit( ast::DeclStmt const * stmt ); 1607 1587 ast::Expr const * postvisit( ast::MemberExpr const * expr ); … … 1639 1619 /// adding the type variables from the provided type. 1640 1620 void beginTypeScope( ast::Type const * ); 1641 /// Enters a new scope for known layouts and offsets, and queues exit calls.1642 void beginGenericScope();1643 1621 1644 1622 /// Set of generic type layouts known in the current scope, … … 1652 1630 /// If the argument of an AddressExpr is MemberExpr, it is stored here. 1653 1631 ast::MemberExpr const * addrMember = nullptr; 1654 /// Used to avoid recursing too deep in type declarations.1655 bool expect_func_type = false;1656 1632 }; 1657 1633 … … 1675 1651 } 1676 1652 1677 void PolyGenericCalculator::previsit( ast::ObjectDecl const * decl ) {1678 beginTypeScope( decl->type );1679 }1680 1681 1653 void PolyGenericCalculator::previsit( ast::FunctionDecl const * decl ) { 1682 beginGenericScope();1654 GuardScope( *this ); 1683 1655 beginTypeScope( decl->type ); 1684 1656 } … … 1742 1714 } 1743 1715 1744 void PolyGenericCalculator::previsit( ast::PointerType const * type ) {1745 beginTypeScope( type );1746 }1747 1748 void PolyGenericCalculator::previsit( ast::FunctionType const * type ) {1749 beginTypeScope( type );1750 1751 GuardValue( expect_func_type );1752 GuardScope( *this );1753 1754 // The other functions type we will see in this scope are probably1755 // function parameters they don't help us with the layout and offsets so1756 // don't mark them as known in this scope.1757 expect_func_type = false;1758 }1759 1760 //void PolyGenericCalculator::previsit( ast::DeclStmt const * stmt ) {1761 1716 ast::DeclStmt const * PolyGenericCalculator::previsit( ast::DeclStmt const * stmt ) { 1762 1717 ast::ObjectDecl const * decl = stmt->decl.as<ast::ObjectDecl>(); … … 2248 2203 } 2249 2204 2250 void PolyGenericCalculator::beginGenericScope() {2251 GuardScope( *this );2252 // We expect the first function type see to be the type relating to this2253 // scope but any further type is probably some unrelated function pointer2254 // keep track of whrich is the first.2255 GuardValue( expect_func_type ) = true;2256 }2257 2258 2205 // -------------------------------------------------------------------------- 2259 /// No common theme found.2206 /// Removes unneeded or incorrect type information. 2260 2207 /// * Replaces initialization of polymorphic values with alloca. 2261 2208 /// * Replaces declaration of dtype/ftype with appropriate void expression.
Note: See TracChangeset
for help on using the changeset viewer.