compiler/resolution/wrappers.cpp
/* Collect the substitutions that the function implementing the promotion
   will use. The substitutions map from the formal to
   the relevant actual type - or, in the event of a defaulted argument,
   to itself.
 */
Collect the substitutions that the function implementing the promotion
will use. The substitutions map from the formal to
the relevant actual type - or, in the event of a defaulted argument,
to itself.
Collect the substitutions that the function implementing the promotion will use . The substitutions map from the formal to the relevant actual type - or in the event of a defaulted argument to itself .
PromotionInfo::PromotionInfo(FnSymbol* fn,
                             CallInfo& info,
                             std::vector<ArgSymbol*>& actualFormals) :
  fn(fn),
  wrapperFn(NULL),
  zippered(false)
{
  int numActuals = actualFormals.size();
  for (int j = 0; j < numActuals; j++) {
    Symbol* actual     = info.actuals.v[j];
    Symbol* formal     = actualFormals[j];
    Type*   actualType = actual->type;
    bool    promotes   = false;
    if (isRecordWrappedType(actualType) == true) {
      makeRefType(actualType);
      actualType = actualType->refType;
    }
    if (canDispatch(actualType, actual, formal->type, fn, &promotes)) {
      if (promotes == true) {
        this->subs.put(formal, actualType->symbol);
      }
    }
  }
  for_formals(formal, fn) {
    TypeSymbol* promotedType = NULL;
    bool defaulted = false;
    if (TypeSymbol* ts = toTypeSymbol(this->subs.get(formal))) {
      promotedType = ts;
    } else {
      bool actualProvidedForFormal = false;
      for_vector(ArgSymbol, arg, actualFormals) {
        if (arg == formal) {
          actualProvidedForFormal = true;
          break;
        }
      }
      if (!actualProvidedForFormal)
        defaulted = true;
    }
    this->promotedType.push_back(promotedType);
    this->defaulted.push_back(defaulted);
    if (defaulted) {
      this->subs.put(formal, formal);
    }
  }
}
PromotionInfo :: PromotionInfo ( FnSymbol * fn , CallInfo & info , std :: vector < ArgSymbol * > & actualFormals ) : fn ( fn ) , wrapperFn ( NULL ) , zippered ( false ) { int numActuals = actualFormals . size ( ) ; for ( int j = 0 ; j < numActuals ; j ++ ) { Symbol * actual = info . actuals . v [ j ] ; Symbol * formal = actualFormals [ j ] ; Type * actualType = actual -> type ; bool promotes = false ; if ( isRecordWrappedType ( actualType ) == true ) { makeRefType ( actualType ) ; actualType = actualType -> refType ; } if ( canDispatch ( actualType , actual , formal -> type , fn , & promotes ) ) { if ( promotes == true ) { this -> subs . put ( formal , actualType -> symbol ) ; } } } for_formals ( formal , fn ) { TypeSymbol * promotedType = NULL ; bool defaulted = false ; if ( TypeSymbol * ts = toTypeSymbol ( this -> subs . get ( formal ) ) ) { promotedType = ts ; } else { bool actualProvidedForFormal = false ; for_vector ( ArgSymbol , arg , actualFormals ) { if ( arg == formal ) { actualProvidedForFormal = true ; break ; } } if ( ! actualProvidedForFormal ) defaulted = true ; } this -> promotedType . push_back ( promotedType ) ; this -> defaulted . push_back ( defaulted ) ; if ( defaulted ) { this -> subs . put ( formal , formal ) ; } } }
Collect the substitutions that the function implementing the promotion
will use.
Collect the substitutions that the function implementing the promotion will use .
// these are established later along with wrapperFormals // this formal is promoted (we just added it to subs in the above loop) // For defaulted arguments, add something to subs to indicate that. // This is just so the cached promotion wrapper is different when // there is a different set of defaulted args.