Changes in src/GenPoly/GenPoly.cc [c2ad3c9:bfae637]
- File:
-
- 1 edited
-
src/GenPoly/GenPoly.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/GenPoly.cc
rc2ad3c9 rbfae637 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenPoly.cc -- 7 // GenPoly.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed May 25 13:39:21 201611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 15 16:11:18 2015 13 13 // Update Count : 13 14 14 // … … 66 66 } 67 67 68 Type* replaceTypeInst( Type* type, const TypeSubstitution* env ) {69 if ( ! env ) return type;70 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( type ) ) {71 Type *newType = env->lookup( typeInst->get_name() );72 if ( newType ) return newType;73 }74 return type;75 }76 77 68 Type *isPolyType( Type *type, const TypeSubstitution *env ) { 78 type = replaceTypeInst( type, env );79 80 69 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 70 if ( env ) { 71 if ( Type *newType = env->lookup( typeInst->get_name() ) ) { 72 return isPolyType( newType, env ); 73 } // if 74 } // if 81 75 return type; 82 76 } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) { … … 87 81 return 0; 88 82 } 89 83 90 84 Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) { 91 type = replaceTypeInst( type, env );92 93 85 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 86 if ( env ) { 87 if ( Type *newType = env->lookup( typeInst->get_name() ) ) { 88 return isPolyType( newType, tyVars, env ); 89 } // if 90 } // if 94 91 if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) { 95 92 return type; … … 104 101 105 102 Type *isPolyPtr( Type *type, const TypeSubstitution *env ) { 106 type = replaceTypeInst( type, env );107 108 103 if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) { 109 104 return isPolyType( ptr->get_base(), env ); 110 } 111 return 0; 112 } 113 105 } else if ( env ) { 106 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) { 107 if ( Type *newType = env->lookup( typeInst->get_name() ) ) { 108 return isPolyPtr( newType, env ); 109 } // if 110 } // if 111 } // if 112 return 0; 113 } 114 114 115 Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) { 115 type = replaceTypeInst( type, env );116 117 116 if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) { 118 117 return isPolyType( ptr->get_base(), tyVars, env ); 119 } 118 } else if ( env ) { 119 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) { 120 if ( Type *newType = env->lookup( typeInst->get_name() ) ) { 121 return isPolyPtr( newType, tyVars, env ); 122 } // if 123 } // if 124 } // if 120 125 return 0; 121 126 } … … 127 132 128 133 while ( true ) { 129 type = replaceTypeInst( type, env );130 131 134 if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) { 132 135 type = ptr->get_base(); 133 136 ++(*levels); 137 } else if ( env ) { 138 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) { 139 if ( Type *newType = env->lookup( typeInst->get_name() ) ) { 140 type = newType; 141 } else break; 142 } else break; 134 143 } else break; 135 144 } … … 137 146 return isPolyType( type, env ); 138 147 } 139 148 140 149 Type * hasPolyBase( Type *type, const TyVarMap &tyVars, int *levels, const TypeSubstitution *env ) { 141 150 int dummy; … … 144 153 145 154 while ( true ) { 146 type = replaceTypeInst( type, env );147 148 155 if ( PointerType *ptr = dynamic_cast< PointerType *>( type ) ) { 149 156 type = ptr->get_base(); 150 157 ++(*levels); 158 } else if ( env ) { 159 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( type ) ) { 160 if ( Type *newType = env->lookup( typeInst->get_name() ) ) { 161 type = newType; 162 } else break; 163 } else break; 151 164 } else break; 152 165 } … … 172 185 if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( expr ) ) { 173 186 return varExpr; 174 } else if ( MemberExpr *memberExpr = dynamic_cast< MemberExpr* >( expr ) ) {175 expr = memberExpr->get_aggregate();176 187 } else if ( AddressExpr *addressExpr = dynamic_cast< AddressExpr* >( expr ) ) { 177 188 expr = addressExpr->get_arg(); … … 181 192 if ( ! fn || fn->get_name() != std::string("*?") ) return 0; 182 193 expr = *untypedExpr->begin_args(); 183 } else if ( CommaExpr *commaExpr = dynamic_cast< CommaExpr* >( expr ) ) {184 // copy constructors insert comma exprs, look at second argument which contains the variable185 expr = commaExpr->get_arg2();186 continue;187 194 } else break; 188 195 … … 202 209 } 203 210 } 204 211 205 212 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) { 206 213 for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
Note:
See TracChangeset
for help on using the changeset viewer.