Ignore:
Timestamp:
Jul 26, 2019, 6:39:42 AM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
be53b87
Parents:
f673c13c
Message:

remove attribute expression '@'name mechanism

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rf673c13c r033ff37  
    1010// Created On       : Sat May 16 23:52:08 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov  1 21:00:56 2018
    13 // Update Count     : 35
     12// Last Modified On : Thu Jul 25 22:37:46 2019
     13// Update Count     : 37
    1414//
    1515
     
    7979                void postvisit( OffsetofExpr * offsetofExpr );
    8080                void postvisit( OffsetPackExpr * offsetPackExpr );
    81                 void postvisit( AttrExpr * attrExpr );
    8281                void postvisit( LogicalExpr * logicalExpr );
    8382                void postvisit( ConditionalExpr * conditionalExpr );
     
    14041403        }
    14051404
    1406         namespace {
    1407                 void resolveAttr( SymTab::Indexer::IdData data, const FunctionType * function, Type * argType, const TypeEnvironment &env, AlternativeFinder & finder ) {
    1408                         // assume no polymorphism
    1409                         // assume no implicit conversions
    1410                         assert( function->parameters.size() == 1 );
    1411                         PRINT(
    1412                                 std::cerr << "resolvAttr: funcDecl is ";
    1413                                 data.id->print( std::cerr );
    1414                                 std::cerr << " argType is ";
    1415                                 argType->print( std::cerr );
    1416                                 std::cerr << std::endl;
    1417                         )
    1418                         const SymTab::Indexer & indexer = finder.get_indexer();
    1419                         AltList & alternatives = finder.get_alternatives();
    1420                         if ( typesCompatibleIgnoreQualifiers( argType, function->parameters.front()->get_type(), indexer, env ) ) {
    1421                                 Cost cost = Cost::zero;
    1422                                 Expression * newExpr = data.combine( cost );
    1423                                 alternatives.push_back( Alternative{
    1424                                         new AttrExpr{ newExpr, argType->clone() }, env, OpenVarSet{},
    1425                                         AssertionList{}, Cost::zero, cost } );
    1426                                 for ( DeclarationWithType * retVal : function->returnVals ) {
    1427                                         alternatives.back().expr->result = retVal->get_type()->clone();
    1428                                 } // for
    1429                         } // if
    1430                 }
    1431         }
    1432 
    1433         void AlternativeFinder::Finder::postvisit( AttrExpr * attrExpr ) {
    1434                 // assume no 'pointer-to-attribute'
    1435                 NameExpr * nameExpr = dynamic_cast< NameExpr* >( attrExpr->get_attr() );
    1436                 assert( nameExpr );
    1437                 std::list< SymTab::Indexer::IdData > attrList;
    1438                 indexer.lookupId( nameExpr->get_name(), attrList );
    1439                 if ( attrExpr->get_isType() || attrExpr->get_expr() ) {
    1440                         for ( auto & data : attrList ) {
    1441                                 const DeclarationWithType * id = data.id;
    1442                                 // check if the type is function
    1443                                 if ( const FunctionType * function = dynamic_cast< const FunctionType * >( id->get_type() ) ) {
    1444                                         // assume exactly one parameter
    1445                                         if ( function->parameters.size() == 1 ) {
    1446                                                 if ( attrExpr->get_isType() ) {
    1447                                                         resolveAttr( data, function, attrExpr->get_type(), env, altFinder);
    1448                                                 } else {
    1449                                                         AlternativeFinder finder( indexer, env );
    1450                                                         finder.find( attrExpr->get_expr() );
    1451                                                         for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) {
    1452                                                                 if ( choice->expr->get_result()->size() == 1 ) {
    1453                                                                         resolveAttr(data, function, choice->expr->get_result(), choice->env, altFinder );
    1454                                                                 } // fi
    1455                                                         } // for
    1456                                                 } // if
    1457                                         } // if
    1458                                 } // if
    1459                         } // for
    1460                 } else {
    1461                         for ( auto & data : attrList ) {
    1462                                 Cost cost = Cost::zero;
    1463                                 Expression * newExpr = data.combine( cost );
    1464                                 alternatives.push_back( Alternative{
    1465                                         newExpr, env, OpenVarSet{}, AssertionList{}, Cost::zero, cost } );
    1466                                 renameTypes( alternatives.back().expr );
    1467                         } // for
    1468                 } // if
    1469         }
    1470 
    14711405        void AlternativeFinder::Finder::postvisit( LogicalExpr * logicalExpr ) {
    14721406                AlternativeFinder firstFinder( indexer, env );
Note: See TracChangeset for help on using the changeset viewer.