Ignore:
Timestamp:
May 17, 2015, 1:19:35 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
0dd3a2f
Parents:
b87a5ed
Message:

licencing: second groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/GenPoly/Specialize.cc

    rb87a5ed ra32b204  
    6161needsSpecialization( Type *formalType, Type *actualType, TypeSubstitution *env )
    6262{
    63   if( env ) {
     63  if ( env ) {
    6464    using namespace ResolvExpr;
    6565    OpenVarSet openVars, closedVars;
     
    6767    findOpenVars( formalType, openVars, closedVars, need, have, false );
    6868    findOpenVars( actualType, openVars, closedVars, need, have, true );
    69     for( OpenVarSet::const_iterator openVar = openVars.begin(); openVar != openVars.end(); ++openVar ) {
     69    for ( OpenVarSet::const_iterator openVar = openVars.begin(); openVar != openVars.end(); ++openVar ) {
    7070      Type *boundType = env->lookup( openVar->first );
    71       if( !boundType ) continue;
    72       if( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( boundType ) ) {
    73         if( closedVars.find( typeInst->get_name() ) == closedVars.end() ) {
     71      if ( ! boundType ) continue;
     72      if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( boundType ) ) {
     73        if ( closedVars.find( typeInst->get_name() ) == closedVars.end() ) {
    7474          return true;
    7575        }
     
    8787Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams )
    8888{
    89   if( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
     89  if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) {
    9090    PointerType *ptrType;
    9191    FunctionType *funType;
    92     if( ( ptrType = dynamic_cast< PointerType* >( formalType ) ) && ( funType = dynamic_cast< FunctionType* >( ptrType->get_base() ) ) ) {
     92    if ( ( ptrType = dynamic_cast< PointerType* >( formalType ) ) && ( funType = dynamic_cast< FunctionType* >( ptrType->get_base() ) ) ) {
    9393      FunctionType *newType = funType->clone();
    94       if( env ) {
     94      if ( env ) {
    9595        TypeSubstitution newEnv( *env );
    9696        // it is important to replace only occurrences of type variables that occur free in the
     
    103103      UniqueName paramNamer( paramPrefix );
    104104      ApplicationExpr *appExpr = new ApplicationExpr( actual );
    105       for( std::list< DeclarationWithType* >::iterator param = thunkFunc->get_functionType()->get_parameters().begin(); param != thunkFunc->get_functionType()->get_parameters().end(); ++param ) {
     105      for ( std::list< DeclarationWithType* >::iterator param = thunkFunc->get_functionType()->get_parameters().begin(); param != thunkFunc->get_functionType()->get_parameters().end(); ++param ) {
    106106        (*param)->set_name( paramNamer.newName() );
    107107        appExpr->get_args().push_back( new VariableExpr( *param ) );
    108108      }
    109109      appExpr->set_env( maybeClone( env ) );
    110       if( inferParams ) {
     110      if ( inferParams ) {
    111111        appExpr->get_inferParams() = *inferParams;
    112112      }
     
    123123     
    124124      Statement *appStmt;
    125       if( funType->get_returnVals().empty() ) {
     125      if ( funType->get_returnVals().empty() ) {
    126126        appStmt = new ExprStmt( noLabels, appExpr );
    127127      } else {
     
    143143{
    144144  // create thunks for the explicit parameters
    145   assert( !appExpr->get_function()->get_results().empty() );
     145  assert( ! appExpr->get_function()->get_results().empty() );
    146146  PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() );
    147147  assert( pointer );
     
    149149  std::list< DeclarationWithType* >::iterator formal;
    150150  std::list< Expression* >::iterator actual;
    151   for( formal = function->get_parameters().begin(), actual = appExpr->get_args().begin(); formal != function->get_parameters().end() && actual != appExpr->get_args().end(); ++formal, ++actual ) {
     151  for ( formal = function->get_parameters().begin(), actual = appExpr->get_args().begin(); formal != function->get_parameters().end() && actual != appExpr->get_args().end(); ++formal, ++actual ) {
    152152    *actual = doSpecialization( (*formal)->get_type(), *actual, &appExpr->get_inferParams() );
    153153  }
     
    161161 
    162162  // create thunks for the inferred parameters
    163   for( InferredParams::iterator inferParam = appExpr->get_inferParams().begin(); inferParam != appExpr->get_inferParams().end(); ++inferParam ) {
     163  for ( InferredParams::iterator inferParam = appExpr->get_inferParams().begin(); inferParam != appExpr->get_inferParams().end(); ++inferParam ) {
    164164    inferParam->second.expr = doSpecialization( inferParam->second.formalType, inferParam->second.expr, &appExpr->get_inferParams() );
    165165  }
Note: See TracChangeset for help on using the changeset viewer.