compiler/AST/foralls.cpp
// Replaces 'origSE' in the tree with the result.
Replaces 'origSE' in the tree with the result.
Replaces ' origSE ' in the tree with the result .
static CallExpr* buildForallParIterCall(ForallStmt* pfs, SymExpr* origSE)
{
  CallExpr* iterCall = NULL;
  if (origSE->symbol()->type->symbol->hasFlag(FLAG_ITERATOR_RECORD)) {
    if (ArgSymbol* origArg = toArgSymbol(origSE->symbol())) {
      FnSymbol* iterator = getTheIteratorFnFromIteratorRec(origArg->type);
      USR_FATAL_CONT(origSE, "a forall loop over a formal argument corresponding to a for/forall/promoted expression or an iterator call is not implemented");
      USR_PRINT(iterator, "the actual argument is here");
      USR_STOP();
    }
    CallExpr* origIterCall = toCallExpr(findDefOfTemp(origSE));
    INT_ASSERT(origIterCall);
    FnSymbol* origTarget = origIterCall->resolvedFunction();
    INT_ASSERT(origTarget);
    const char* targetName = origTarget->name;
    const int forallExprNameLen = strlen(astr_forallexpr);
    if (!strncmp(targetName, astr_forallexpr, forallExprNameLen)) {
      targetName = astr(astr_loopexpr_iter, targetName + forallExprNameLen);
    }
    if (acceptUnmodifiedIterCall(pfs, origIterCall)) {
      iterCall = origIterCall;
      iterCall->remove();
    } else {
      iterCall = origIterCall->copy();
      iterCall->baseExpr = new UnresolvedSymExpr(targetName);
    }
  } else {
    iterCall = new CallExpr("these", gMethodToken, origSE->copy());
  }
  origSE->replace(iterCall);
  return iterCall;
}
static CallExpr * buildForallParIterCall ( ForallStmt * pfs , SymExpr * origSE ) { CallExpr * iterCall = NULL ; if ( origSE -> symbol ( ) -> type -> symbol -> hasFlag ( FLAG_ITERATOR_RECORD ) ) { if ( ArgSymbol * origArg = toArgSymbol ( origSE -> symbol ( ) ) ) { FnSymbol * iterator = getTheIteratorFnFromIteratorRec ( origArg -> type ) ; USR_FATAL_CONT ( origSE , " " ) ; USR_PRINT ( iterator , " " ) ; USR_STOP ( ) ; } CallExpr * origIterCall = toCallExpr ( findDefOfTemp ( origSE ) ) ; INT_ASSERT ( origIterCall ) ; FnSymbol * origTarget = origIterCall -> resolvedFunction ( ) ; INT_ASSERT ( origTarget ) ; const char * targetName = origTarget -> name ; const int forallExprNameLen = strlen ( astr_forallexpr ) ; if ( ! strncmp ( targetName , astr_forallexpr , forallExprNameLen ) ) { targetName = astr ( astr_loopexpr_iter , targetName + forallExprNameLen ) ; } if ( acceptUnmodifiedIterCall ( pfs , origIterCall ) ) { iterCall = origIterCall ; iterCall -> remove ( ) ; } else { iterCall = origIterCall -> copy ( ) ; iterCall -> baseExpr = new UnresolvedSymExpr ( targetName ) ; } } else { iterCall = new CallExpr ( " " , gMethodToken , origSE -> copy ( ) ) ; } origSE -> replace ( iterCall ) ; return iterCall ; }
Replaces 'origSE' in the tree with the result.
Replaces ' origSE ' in the tree with the result .
// Our iterable expression is an iterator call. // What to do if we do not find it? // a forall loop over a (possibly zippered) forall expression, ex.: //  test/reductions/deitz/test_maxloc_reduce_wmikanik_bug2.chpl // Not an iterator call, so add a call to these().