compiler/passes/normalize.cpp
// query - the just-created PRIM_QUERY to add to the ast somewhere
// actual - the actual argument to the nested type constructor
the just-created PRIM_QUERY to add to the ast somewhere
actual - the actual argument to the nested type constructor
the just - created PRIM_QUERY to add to the ast somewhere actual - the actual argument to the nested type constructor
static void expandQueryForActual(FnSymbol*  fn,
                                 std::vector<SymExpr*>& symExprs,
                                 ArgSymbol* formal,
                                 CallExpr* call,
                                 CallExpr* query,
                                 Expr* actual) {
  CallExpr* subcall = toCallExpr(actual);
  if (isGenericActual(actual)) {
    if (DefExpr* def = toDefExpr(actual)) {
      replaceQueryUses(formal, def, query, symExprs);
    } else if (SymExpr* se = toSymExpr(actual)) {
      TypeSymbol* ts = toTypeSymbol(se->symbol());
      INT_ASSERT(ts);
      Expr* subtype = new SymExpr(ts);
      addToWhereClause(fn, formal,
                       new CallExpr(PRIM_IS_SUBTYPE_ALLOW_VALUES,
                                    subtype, query->copy()));
    } else {
      INT_ASSERT("case not handled");
    }
  } else if (subcall && doesCallContainGenericActual(subcall)) {
    Expr* subtype = NULL;
    if (TypeSymbol* ts = getTypeForSpecialConstructor(subcall)) {
      subtype = new SymExpr(ts);
    } else if (subcall->baseExpr) {
      subtype = subcall->baseExpr->copy();
    } else {
      subtype = subcall->copy();
      INT_ASSERT(!doesCallContainGenericActual(subcall));
    }
    addToWhereClause(fn, formal,
                     new CallExpr(PRIM_IS_SUBTYPE_ALLOW_VALUES,
                                  subtype, query->copy()));
    expandQueryForGenericTypeSpecifier(fn, symExprs, formal,
                                       subcall, query);
  } else {
    addToWhereClause(fn, formal,
                     new CallExpr("==", actual->copy(), query));
  }
}
static void expandQueryForActual ( FnSymbol * fn , std :: vector < SymExpr * > & symExprs , ArgSymbol * formal , CallExpr * call , CallExpr * query , Expr * actual ) { CallExpr * subcall = toCallExpr ( actual ) ; if ( isGenericActual ( actual ) ) { if ( DefExpr * def = toDefExpr ( actual ) ) { replaceQueryUses ( formal , def , query , symExprs ) ; } else if ( SymExpr * se = toSymExpr ( actual ) ) { TypeSymbol * ts = toTypeSymbol ( se -> symbol ( ) ) ; INT_ASSERT ( ts ) ; Expr * subtype = new SymExpr ( ts ) ; addToWhereClause ( fn , formal , new CallExpr ( PRIM_IS_SUBTYPE_ALLOW_VALUES , subtype , query -> copy ( ) ) ) ; } else { INT_ASSERT ( " " ) ; } } else if ( subcall && doesCallContainGenericActual ( subcall ) ) { Expr * subtype = NULL ; if ( TypeSymbol * ts = getTypeForSpecialConstructor ( subcall ) ) { subtype = new SymExpr ( ts ) ; } else if ( subcall -> baseExpr ) { subtype = subcall -> baseExpr -> copy ( ) ; } else { subtype = subcall -> copy ( ) ; INT_ASSERT ( ! doesCallContainGenericActual ( subcall ) ) ; } addToWhereClause ( fn , formal , new CallExpr ( PRIM_IS_SUBTYPE_ALLOW_VALUES , subtype , query -> copy ( ) ) ) ; expandQueryForGenericTypeSpecifier ( fn , symExprs , formal , subcall , query ) ; } else { addToWhereClause ( fn , formal , new CallExpr ( " " , actual -> copy ( ) , query ) ) ; } }
query - the just-created PRIM_QUERY to add to the ast somewhere
actual - the actual argument to the nested type constructor
query - the just - created PRIM_QUERY to add to the ast somewhere actual - the actual argument to the nested type constructor
// Add check that actual type satisfies // Recurse to handle any nested DefExprs // Add check that formal type/param matches actual