Ignore:
Timestamp:
Jan 10, 2019, 3:50:34 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
d97c3a4
Parents:
aeb8f70 (diff), 08222c7 (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.
git-author:
Aaron Moss <a3moss@…> (01/10/19 14:46:09)
git-committer:
Aaron Moss <a3moss@…> (01/10/19 15:50:34)
Message:

Merge remote-tracking branch 'plg/master' into deferred_resn

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    raeb8f70 re99e43f  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sat May 16 23:52:08 2015
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Fri Oct -5 10:01:00 2018
    13 // Update Count     : 34
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Nov  1 21:00:56 2018
     13// Update Count     : 35
    1414//
    1515
     
    500500                                needAssertions[ *assert ].isUsed = true;
    501501                        }
    502 ///     needAssertions.insert( needAssertions.end(), (*tyvar)->get_assertions().begin(), (*tyvar)->get_assertions().end() );
    503                 }
    504         }
    505 
    506 //      template< typename ForwardIterator, typename OutputIterator >
    507 //      void inferRecursive( ForwardIterator begin, ForwardIterator end, const Alternative &newAlt, OpenVarSet &openVars, const SymTab::Indexer &decls, const AssertionSet &newNeed, int level, const SymTab::Indexer &indexer, OutputIterator out ) {
    508 //              if ( newAlt.cost == Cost::infinity ) return; // don't proceed down this dead end
    509 //              if ( begin == end ) {
    510 //                      if ( newNeed.empty() ) {
    511 //                              PRINT(
    512 //                                      std::cerr << "all assertions satisfied, output alternative: ";
    513 //                                      newAlt.print( std::cerr );
    514 //                                      std::cerr << std::endl;
    515 //                              );
    516 //                              *out++ = newAlt;
    517 //                              return;
    518 //                      } else if ( level >= recursionLimit ) {
    519 //                              SemanticError( newAlt.expr->location, "Too many recursive assertions" );
    520 //                      } else {
    521 //                              AssertionSet newerNeed;
    522 //                              PRINT(
    523 //                                      std::cerr << "recursing with new set:" << std::endl;
    524 //                                      printAssertionSet( newNeed, std::cerr, 8 );
    525 //                              )
    526 //                              inferRecursive( newNeed.begin(), newNeed.end(), newAlt, openVars, decls, newerNeed, level+1, indexer, out );
    527 //                              return;
    528 //                      }
    529 //              }
    530 
    531 //              ForwardIterator cur = begin++;
    532 //              if ( ! cur->second.isUsed ) {
    533 //                      inferRecursive( begin, end, newAlt, openVars, decls, newNeed, level, indexer, out );
    534 //                      return; // xxx - should this continue? previously this wasn't here, and it looks like it should be
    535 //              }
    536 //              DeclarationWithType *curDecl = cur->first;
    537 
    538 //              PRINT(
    539 //                      std::cerr << "inferRecursive: assertion is ";
    540 //                      curDecl->print( std::cerr );
    541 //                      std::cerr << std::endl;
    542 //              )
    543 //              std::list< SymTab::Indexer::IdData > candidates;
    544 //              decls.lookupId( curDecl->get_name(), candidates );
    545 // ///   if ( candidates.empty() ) { std::cerr << "no candidates!" << std::endl; }
    546 //              for ( const auto & data : candidates ) {
    547 //                      DeclarationWithType * candidate = data.id;
    548 //                      PRINT(
    549 //                              std::cerr << "inferRecursive: candidate is ";
    550 //                              candidate->print( std::cerr );
    551 //                              std::cerr << std::endl;
    552 //                      )
    553 
    554 //                      AssertionSet newHave, newerNeed( newNeed );
    555 //                      TypeEnvironment newEnv( newAlt.env );
    556 //                      OpenVarSet newOpenVars( openVars );
    557 //                      Type *adjType = candidate->get_type()->clone();
    558 //                      adjustExprType( adjType, newEnv, indexer );
    559 //                      renameTyVars( adjType );
    560 //                      PRINT(
    561 //                              std::cerr << "unifying ";
    562 //                              curDecl->get_type()->print( std::cerr );
    563 //                              std::cerr << " with ";
    564 //                              adjType->print( std::cerr );
    565 //                              std::cerr << std::endl;
    566 //                      )
    567 //                      if ( unify( curDecl->get_type(), adjType, newEnv, newerNeed, newHave, newOpenVars, indexer ) ) {
    568 //                              PRINT(
    569 //                                      std::cerr << "success!" << std::endl;
    570 //                              )
    571 //                              SymTab::Indexer newDecls( decls );
    572 //                              addToIndexer( newHave, newDecls );
    573 //                              Alternative newerAlt( newAlt );
    574 //                              newerAlt.env = newEnv;
    575 //                              assertf( candidate->get_uniqueId(), "Assertion candidate does not have a unique ID: %s", toString( candidate ).c_str() );
    576 
    577 //                              // everything with an empty idChain was pulled in by the current assertion.
    578 //                              // add current assertion's idChain + current assertion's ID so that the correct inferParameters can be found.
    579 //                              for ( auto & a : newerNeed ) {
    580 //                                      if ( a.second.idChain.empty() ) {
    581 //                                              a.second.idChain = cur->second.idChain;
    582 //                                              a.second.idChain.push_back( curDecl->get_uniqueId() );
    583 //                                      }
    584 //                              }
    585 
    586 //                              Expression *varExpr = data.combine( newerAlt.cvtCost );
    587 //                              delete varExpr->get_result();
    588 //                              varExpr->set_result( adjType->clone() );
    589 //                              PRINT(
    590 //                                      std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " ";
    591 //                                      curDecl->print( std::cerr );
    592 //                                      std::cerr << " with declaration " << candidate->get_uniqueId() << " ";
    593 //                                      candidate->print( std::cerr );
    594 //                                      std::cerr << std::endl;
    595 //                              )
    596 //                              // follow the current assertion's ID chain to find the correct set of inferred parameters to add the candidate to (i.e. the set of inferred parameters belonging to the entity which requested the assertion parameter).
    597 //                              InferredParams * inferParameters = &newerAlt.expr->inferParams;
    598 //                              for ( UniqueId id : cur->second.idChain ) {
    599 //                                      inferParameters = (*inferParameters)[ id ].inferParams.get();
    600 //                              }
    601 //                              // XXX: this is a memory leak, but adjType can't be deleted because it might contain assertions
    602 //                              (*inferParameters)[ curDecl->get_uniqueId() ] = ParamEntry( candidate->get_uniqueId(), adjType->clone(), curDecl->get_type()->clone(), varExpr );
    603 //                              inferRecursive( begin, end, newerAlt, newOpenVars, newDecls, newerNeed, level, indexer, out );
    604 //                      } else {
    605 //                              delete adjType;
    606 //                      }
    607 //              }
    608 //      }
     502                }
     503        }
    609504
    610505        /// Unique identifier for matching expression resolutions to their requesting expression
     
    613508        template< typename OutputIterator >
    614509        void AlternativeFinder::Finder::inferParameters( Alternative &newAlt, OutputIterator out ) {
    615                 // SymTab::Indexer decls( indexer );
    616                 // addToIndexer( have, decls );
    617                 // AssertionSet newNeed;
    618                 // PRINT(
    619                 //      std::cerr << "env is: " << std::endl;
    620                 //      newAlt.env.print( std::cerr, 0 );
    621                 //      std::cerr << std::endl;
    622                 // )
    623 
    624                 // inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, 0, indexer, out );
    625 
    626510                // Set need bindings for any unbound assertions
    627511                UniqueId crntResnSlot = 0;  // matching ID for this expression's assertions
     
    13731257                /// Gets name from untyped member expression (member must be NameExpr)
    13741258                const std::string& get_member_name( UntypedMemberExpr *memberExpr ) {
     1259                        if ( dynamic_cast< ConstantExpr * >( memberExpr->get_member() ) ) {
     1260                                SemanticError( memberExpr, "Indexed access to struct fields unsupported: " );
     1261                        } // if
    13751262                        NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() );
    13761263                        assert( nameExpr );
Note: See TracChangeset for help on using the changeset viewer.