compiler/passes/normalize.cpp
// The type-expr is known to be a CallExpr with a query definition
The type-expr is known to be a CallExpr with a query definition
The type - expr is known to be a CallExpr with a query definition
static void expandQueryForGenericTypeSpecifier(FnSymbol*  fn,
                                               ArgSymbol* formal) {
  BlockStmt*            typeExpr  = formal->typeExpr;
  Expr*                 tail      = typeExpr->body.tail;
  CallExpr*             call      = toCallExpr(tail);
  std::vector<SymExpr*> symExprs;
  collectSymExprs(fn, symExprs);
  BaseAST* queried = formal;
  if (formal->variableExpr) {
    queried = new CallExpr(PRIM_QUERY, formal, new_IntSymbol(2));
    addToWhereClause(fn, formal, new CallExpr(PRIM_IS_STAR_TUPLE_TYPE, formal));
  }
  expandQueryForGenericTypeSpecifier(fn, symExprs, formal, call, queried);
  Expr* usetype = NULL;
  if (TypeSymbol* ts = getTypeForSpecialConstructor(call)) {
    usetype = new SymExpr(ts);
  } else if (call->baseExpr) {
    usetype = call->baseExpr->remove();
  } else {
    usetype = call->remove();
    INT_ASSERT(!doesCallContainGenericActual(call));
  }
  formal->typeExpr->replace(new BlockStmt(usetype));
  formal->addFlag(FLAG_MARKED_GENERIC);
}
static void expandQueryForGenericTypeSpecifier ( FnSymbol * fn , ArgSymbol * formal ) { BlockStmt * typeExpr = formal -> typeExpr ; Expr * tail = typeExpr -> body . tail ; CallExpr * call = toCallExpr ( tail ) ; std :: vector < SymExpr * > symExprs ; collectSymExprs ( fn , symExprs ) ; BaseAST * queried = formal ; if ( formal -> variableExpr ) { queried = new CallExpr ( PRIM_QUERY , formal , new_IntSymbol ( 2 ) ) ; addToWhereClause ( fn , formal , new CallExpr ( PRIM_IS_STAR_TUPLE_TYPE , formal ) ) ; } expandQueryForGenericTypeSpecifier ( fn , symExprs , formal , call , queried ) ; Expr * usetype = NULL ; if ( TypeSymbol * ts = getTypeForSpecialConstructor ( call ) ) { usetype = new SymExpr ( ts ) ; } else if ( call -> baseExpr ) { usetype = call -> baseExpr -> remove ( ) ; } else { usetype = call -> remove ( ) ; INT_ASSERT ( ! doesCallContainGenericActual ( call ) ) ; } formal -> typeExpr -> replace ( new BlockStmt ( usetype ) ) ; formal -> addFlag ( FLAG_MARKED_GENERIC ) ; }
The type-expr is known to be a CallExpr with a query definition
The type - expr is known to be a CallExpr with a query definition
// Queries access the 1st tuple element for varargs functions // 1 is the size field, 2 is the index of the first tuple field // Add check that passed tuple is homogeneous // Remove the queries from the formal argument type