Changeset cf34e82


Ignore:
Timestamp:
Oct 3, 2023, 5:31:59 PM (11 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
2261bcc, 3cbe320
Parents:
11ab0b4a (diff), 1ee0a4da (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.h

    r11ab0b4a rcf34e82  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Box.h --
     7// Box.h -- Implement polymorphic function calls and types.
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:23:52 2017
    13 // Update Count     : 6
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Oct  6 13:37:00 2022
     13// Update Count     : 7
    1414//
    1515
     
    1919
    2020class Declaration;
     21namespace ast {
     22        class TranslationUnit;
     23}
    2124
    2225namespace GenPoly {
    2326        /// boxes polymorphic function calls
    2427        void box( std::list< Declaration* >& translationUnit );
     28void box( ast::TranslationUnit & translationUnit );
    2529} // namespace GenPoly
    2630
  • src/GenPoly/InstantiateGenericNew.cpp

    r11ab0b4a rcf34e82  
    335335ast::Expr const * FixDtypeStatic::postvisit( ast::MemberExpr const * expr ) {
    336336        ast::ptr<ast::Type> const & type = expr->aggregate->result;
    337         if ( !isGenericType( type ) ) {
    338                 return expr;
    339         } else if ( auto inst = type.as<ast::StructInstType>() ) {
    340                 return fixMemberExpr( inst, expr );
     337        if ( auto inst = type.as<ast::StructInstType>() ) {
     338                if ( !inst->params.empty() ) return fixMemberExpr( inst, expr );
    341339        } else if ( auto inst = type.as<ast::UnionInstType>() ) {
    342                 return fixMemberExpr( inst, expr );
     340                if ( !inst->params.empty() ) return fixMemberExpr( inst, expr );
    343341        }
    344342        return expr;
     
    451449        ast::Expr const * postvisit( ast::MemberExpr const * expr );
    452450        ast::Expr const * postvisit( ast::Expr const * expr );
    453         void previsit( ast::ParseNode const * node );
    454 
     451        ast::Designation const * postvisit( ast::Designation const * );
     452
     453        void previsit( ast::ParseNode const * node ) {
     454                GuardValue( location ) = &node->location;
     455        }
    455456        void previsit( ast::FunctionType const * ) {
    456457                GuardValue( inFunctionType ) = true;
     
    628629}
    629630
    630 void GenericInstantiator::previsit( ast::ParseNode const * node ) {
    631         GuardValue( location ) = &node->location;
     631// This attempts to figure out what the final name of the field will be.
     632// Pretty printing can cause this to become incorrect.
     633std::string getPrintName( ast::DeclWithType const * decl ) {
     634        return ( decl->linkage.is_mangled )
     635                ? decl->scopedMangleName() : decl->name;
     636}
     637
     638ast::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;
    632656}
    633657
  • src/GenPoly/module.mk

    r11ab0b4a rcf34e82  
    2222
    2323SRC += $(SRC_GENPOLY) \
     24        GenPoly/BoxNew.cpp \
    2425        GenPoly/Box.cc \
    2526        GenPoly/Box.h \
  • src/main.cc

    r11ab0b4a rcf34e82  
    419419
    420420                PASS( "Convert L-Value", GenPoly::convertLvalue, transUnit );
     421                DUMP( bboxp, std::move( transUnit ) );
     422                PASS( "Box", GenPoly::box, transUnit );
    421423
    422424                translationUnit = convert( std::move( transUnit ) );
    423 
    424                 DUMP( bboxp, translationUnit );
    425                 PASS( "Box", GenPoly::box, translationUnit );
    426425
    427426                PASS( "Link-Once", CodeGen::translateLinkOnce, translationUnit );
Note: See TracChangeset for help on using the changeset viewer.