Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGenericNew.cpp

    r04db9f6 r251ce80  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // InstantiateGenericNew.cpp -- Create concrete instances of generic types.
     7// InstantiateGenericNew.cpp --
    88//
    99// Author           : Andrew Beach
     
    335335ast::Expr const * FixDtypeStatic::postvisit( ast::MemberExpr const * expr ) {
    336336        ast::ptr<ast::Type> const & type = expr->aggregate->result;
    337         if ( auto inst = type.as<ast::StructInstType>() ) {
    338                 if ( !inst->params.empty() ) return fixMemberExpr( inst, expr );
     337        if ( !isGenericType( type ) ) {
     338                return expr;
     339        } else if ( auto inst = type.as<ast::StructInstType>() ) {
     340                return fixMemberExpr( inst, expr );
    339341        } else if ( auto inst = type.as<ast::UnionInstType>() ) {
    340                 if ( !inst->params.empty() ) return fixMemberExpr( inst, expr );
     342                return fixMemberExpr( inst, expr );
    341343        }
    342344        return expr;
     
    449451        ast::Expr const * postvisit( ast::MemberExpr const * expr );
    450452        ast::Expr const * postvisit( ast::Expr const * expr );
    451         ast::Designation const * postvisit( ast::Designation const * );
    452 
    453         void previsit( ast::ParseNode const * node ) {
    454                 GuardValue( location ) = &node->location;
    455         }
     453        void previsit( ast::ParseNode const * node );
     454
    456455        void previsit( ast::FunctionType const * ) {
    457456                GuardValue( inFunctionType ) = true;
     
    629628}
    630629
    631 // This attempts to figure out what the final name of the field will be.
    632 // Pretty printing can cause this to become incorrect.
    633 std::string getPrintName( ast::DeclWithType const * decl ) {
    634         return ( decl->linkage.is_mangled )
    635                 ? decl->scopedMangleName() : decl->name;
    636 }
    637 
    638 ast::Designation const * GenericInstantiator::postvisit(
    639                 ast::Designation const * designation ) {
    640         // Disconnect designator names from their fields.
    641         // It is now incorrect to point at the generic definition where the used
    642         // type now is replaced with a concrete instance. Ideally, new variable
    643         // expressions would point at fields in the concrete instances, but that
    644         // is work and that information should not be needed this late in
    645         // compilation.
    646 
    647         // Modify all designations, even if not needed.
    648         auto mutNode = mutate( designation );
    649         for ( ast::ptr<ast::Expr> & designator : mutNode->designators ) {
    650                 if ( auto var = designator.as<ast::VariableExpr>() ) {
    651                         designator = new ast::NameExpr(
    652                                 var->location, getPrintName( var->var ) );
    653                 }
    654         }
    655         return mutNode;
     630void GenericInstantiator::previsit( ast::ParseNode const * node ) {
     631        GuardValue( location ) = &node->location;
    656632}
    657633
Note: See TracChangeset for help on using the changeset viewer.