compiler/resolution/wrappers.cpp
// A wrapper that mimics the state during default_arg creation, so that we can
// share code with that implementation.
A wrapper that mimics the state during default_arg creation, so that we can
share code with that implementation.
A wrapper that mimics the state during default_arg creation so that we can share code with that implementation .
static void insertRuntimeTypeDefaultWrapper(FnSymbol* fn,
                                            ArgSymbol* formal,
                                            CallExpr* call,
                                            SymExpr* curActual) {
  SymbolMap copyMap;
  int i = 1;
  for_formals(form, fn) {
    if (form != formal) {
      Expr* actExpr = call->get(i);
      SymExpr* actSym = NULL;
      if (SymExpr* se = toSymExpr(actExpr)) {
        actSym = se;
      } else if (NamedExpr* ne = toNamedExpr(actExpr)) {
        actSym = toSymExpr(ne->actual);
      }
      copyMap.put(form, actSym->symbol());
    }
    i++;
  }
  BlockStmt* body = new BlockStmt(BLOCK_SCOPELESS);
  call->getStmtExpr()->insertBefore(body);
  Symbol* newSym = insertRuntimeTypeDefault(fn, formal, call, body, copyMap, curActual->symbol());
  copyMap.put(formal, newSym);
  update_symbols(body, &copyMap);
  normalize(body);
  resolveBlockStmt(body);
  reset_ast_loc(body, call);
  body->flattenAndRemove();
  curActual->replace(new SymExpr(newSym));
}
static void insertRuntimeTypeDefaultWrapper ( FnSymbol * fn , ArgSymbol * formal , CallExpr * call , SymExpr * curActual ) { SymbolMap copyMap ; int i = 1 ; for_formals ( form , fn ) { if ( form != formal ) { Expr * actExpr = call -> get ( i ) ; SymExpr * actSym = NULL ; if ( SymExpr * se = toSymExpr ( actExpr ) ) { actSym = se ; } else if ( NamedExpr * ne = toNamedExpr ( actExpr ) ) { actSym = toSymExpr ( ne -> actual ) ; } copyMap . put ( form , actSym -> symbol ( ) ) ; } i ++ ; } BlockStmt * body = new BlockStmt ( BLOCK_SCOPELESS ) ; call -> getStmtExpr ( ) -> insertBefore ( body ) ; Symbol * newSym = insertRuntimeTypeDefault ( fn , formal , call , body , copyMap , curActual -> symbol ( ) ) ; copyMap . put ( formal , newSym ) ; update_symbols ( body , & copyMap ) ; normalize ( body ) ; resolveBlockStmt ( body ) ; reset_ast_loc ( body , call ) ; body -> flattenAndRemove ( ) ; curActual -> replace ( new SymExpr ( newSym ) ) ; }
A wrapper that mimics the state during default_arg creation, so that we can
share code with that implementation.
A wrapper that mimics the state during default_arg creation so that we can share code with that implementation .