compiler/AST/foralls.cpp
// Like in build.cpp, here for ForallStmt.
Like in build.cpp, here for ForallStmt.
Like in build . cpp here for ForallStmt .
static BlockStmt*
buildFollowLoop(VarSymbol* iter,
                VarSymbol* leadIdxCopy,
                VarSymbol* followIter,
                VarSymbol* followIdx,
                BlockStmt* loopBody,
                Expr*      ref,
                bool       fast,
                bool       zippered) {
  BlockStmt* followBlock = new BlockStmt();
  ForLoop*   followBody  = new ForLoop(followIdx, followIter, loopBody, zippered,  false);
  followBlock->insertAtTail(new DefExpr(followIter));
  if (fast) {
    if (zippered) {
      followBlock->insertAtTail("'move'(%S, _getIteratorZip(_toFastFollowerZip(%S, %S)))", followIter, iter, leadIdxCopy);
    } else {
      followBlock->insertAtTail("'move'(%S, _getIterator(_toFastFollower(%S, %S)))",       followIter, iter, leadIdxCopy);
    }
  } else {
    if (zippered) {
      followBlock->insertAtTail("'move'(%S, _getIteratorZip(_toFollowerZip(%S, %S)))",     followIter, iter, leadIdxCopy);
    } else {
      followBlock->insertAtTail("'move'(%S, _getIterator(_toFollower(%S, %S)))",           followIter, iter, leadIdxCopy);
    }
  }
  followBlock->insertAtTail(new DeferStmt(new CallExpr("_freeIterator", followIter)));
  ref->insertAfter(followBlock); 
  normalize(followBlock);
  followBlock->remove();
  if (followIdx->defPoint == NULL) {
    followBlock->insertAtTail(new DefExpr(followIdx));
  } else {
    followBlock->insertAtTail(followIdx->defPoint);
  }
  followBlock->insertAtTail("{TYPE 'move'(%S, iteratorIndex(%S)) }", followIdx, followIter);
  followBlock->insertAtTail(followBody);
  return followBlock;
}
static BlockStmt * buildFollowLoop ( VarSymbol * iter , VarSymbol * leadIdxCopy , VarSymbol * followIter , VarSymbol * followIdx , BlockStmt * loopBody , Expr * ref , bool fast , bool zippered ) { BlockStmt * followBlock = new BlockStmt ( ) ; ForLoop * followBody = new ForLoop ( followIdx , followIter , loopBody , zippered , false ) ; followBlock -> insertAtTail ( new DefExpr ( followIter ) ) ; if ( fast ) { if ( zippered ) { followBlock -> insertAtTail ( " " , followIter , iter , leadIdxCopy ) ; } else { followBlock -> insertAtTail ( " " , followIter , iter , leadIdxCopy ) ; } } else { if ( zippered ) { followBlock -> insertAtTail ( " " , followIter , iter , leadIdxCopy ) ; } else { followBlock -> insertAtTail ( " " , followIter , iter , leadIdxCopy ) ; } } followBlock -> insertAtTail ( new DeferStmt ( new CallExpr ( " " , followIter ) ) ) ; ref -> insertAfter ( followBlock ) ; normalize ( followBlock ) ; followBlock -> remove ( ) ; if ( followIdx -> defPoint == NULL ) { followBlock -> insertAtTail ( new DefExpr ( followIdx ) ) ; } else { followBlock -> insertAtTail ( followIdx -> defPoint ) ; } followBlock -> insertAtTail ( " " , followIdx , followIter ) ; followBlock -> insertAtTail ( followBody ) ; return followBlock ; }
Like in build.cpp, here for ForallStmt.
Like in build . cpp here for ForallStmt .
/*forall*/ // not needed: //destructureIndices(followBody, indices, new SymExpr(followIdx), false); // otherwise it wouldn't normalize // followIdx has a defPoint in the non-fast case // and no defPoint in the fast case i.e. for fastFollowIdx.