Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/GenPoly.cc

    r69911c11 rffad73a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec 15 16:11:18 2015
    13 // Update Count     : 13
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Tue Nov 24 15:23:08 2015
     13// Update Count     : 11
    1414//
    1515
     
    6868
    6969        namespace {
    70                 /// Checks a parameter list for polymorphic parameters; will substitute according to env if present
    71                 bool hasPolyParams( std::list< Expression* >& params, const TypeSubstitution *env ) {
    72                         for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) {
    73                                 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param );
    74                                 assert(paramType && "Aggregate parameters should be type expressions");
    75                                 if ( isPolyType( paramType->get_type(), env ) ) return true;
    76                         }
    77                         return false;
    78                 }
    79 
    80                 /// Checks a parameter list for polymorphic parameters from tyVars; will substitute according to env if present
     70                /// Checks a parameter list for polymorphic parameters
    8171                bool hasPolyParams( std::list< Expression* >& params, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    8272                        for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) {
     
    8878                }
    8979        }
    90 
    91         Type *isPolyType( Type *type, const TypeSubstitution *env ) {
    92                 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
    93                         if ( env ) {
    94                                 if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    95                                         return isPolyType( newType, env );
    96                                 } // if
    97                         } // if
    98                         return type;
    99                 } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {
    100                         if ( hasPolyParams( structType->get_parameters(), env ) ) return type;
    101                 } else if ( UnionInstType *unionType = dynamic_cast< UnionInstType* >( type ) ) {
    102                         if ( hasPolyParams( unionType->get_parameters(), env ) ) return type;
    103                 }
    104                 return 0;
    105         }
    10680       
    10781        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    108                 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
     82                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) {
    10983                        if ( env ) {
    11084                                if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
     
    12397        }
    12498
    125         Type *isPolyPtr( Type *type, const TypeSubstitution *env ) {
    126                 if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
    127                         return isPolyType( ptr->get_base(), env );
    128                 } else if ( env ) {
    129                         if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) {
    130                                 if ( Type *newType = env->lookup( typeInst->get_name() ) ) {
    131                                         return isPolyPtr( newType, env );
    132                                 } // if
    133                         } // if
    134                 } // if
    135                 return 0;
    136         }
    137        
    13899        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    139100                if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) {
     
    149110        }
    150111
    151         FunctionType * getFunctionType( Type *ty ) {
    152                 PointerType *ptrType;
    153                 if ( ( ptrType = dynamic_cast< PointerType* >( ty ) ) ) {
    154                         return dynamic_cast< FunctionType* >( ptrType->get_base() ); // pointer if FunctionType, NULL otherwise
    155                 } else {
    156                         return dynamic_cast< FunctionType* >( ty ); // pointer if FunctionType, NULL otherwise
    157                 }
    158         }
    159 
    160112        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) {
    161113                for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
     
    166118
    167119        std::string sizeofName( Type *ty ) {
    168                 return std::string( "_sizeof_" ) + SymTab::Mangler::mangleType( ty );
     120                return std::string( "_sizeof_" ) + SymTab::Mangler::mangle( ty, false, false );
    169121        }
    170122
    171123        std::string alignofName( Type *ty ) {
    172                 return std::string( "_alignof_" ) + SymTab::Mangler::mangleType( ty );
     124                return std::string( "_alignof_" ) + SymTab::Mangler::mangle( ty, false, false );
    173125        }
    174126} // namespace GenPoly
Note: See TracChangeset for help on using the changeset viewer.