Changes in src/GenPoly/GenPoly.cc [3df4cd9:c97b448]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/GenPoly.cc
r3df4cd9 rc97b448 48 48 } 49 49 50 bool hasPolyParams( const std::vector<ast::ptr<ast::Expr>> & params, const ast::TypeSubstitution * env ) { 51 for ( auto ¶m : params ) { 52 auto paramType = param.as<ast::TypeExpr>(); 53 assertf( paramType, "Aggregate parameters should be type expressions" ); 54 if ( isPolyType( paramType->type, env ) ) return true; 50 bool hasPolyParams( const std::vector<ast::ptr<ast::Expr>> & params, const ast::TypeSubstitution * env) { 51 for (auto ¶m : params) { 52 auto paramType = param.strict_as<ast::TypeExpr>(); 53 if (isPolyType(paramType->type, env)) return true; 55 54 } 56 55 return false; … … 63 62 assertf(paramType, "Aggregate parameters should be type expressions"); 64 63 if ( isPolyType( paramType->get_type(), tyVars, env ) ) return true; 65 }66 return false;67 }68 69 bool hasPolyParams( const std::vector<ast::ptr<ast::Expr>> & params, const TypeVarMap & typeVars, const ast::TypeSubstitution * env ) {70 for ( auto & param : params ) {71 auto paramType = param.as<ast::TypeExpr>();72 assertf( paramType, "Aggregate parameters should be type expressions" );73 if ( isPolyType( paramType->type, typeVars, env ) ) return true;74 64 } 75 65 return false; … … 195 185 } 196 186 187 const ast::Type * isPolyType(const ast::Type * type, const TyVarMap & tyVars, const ast::TypeSubstitution * env) { 188 type = replaceTypeInst( type, env ); 189 190 if ( auto typeInst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 191 if ( tyVars.contains( typeInst->typeString() ) ) return type; 192 } else if ( auto arrayType = dynamic_cast< const ast::ArrayType * >( type ) ) { 193 return isPolyType( arrayType->base, env ); 194 } else if ( auto structType = dynamic_cast< const ast::StructInstType* >( type ) ) { 195 if ( hasPolyParams( structType->params, env ) ) return type; 196 } else if ( auto unionType = dynamic_cast< const ast::UnionInstType* >( type ) ) { 197 if ( hasPolyParams( unionType->params, env ) ) return type; 198 } 199 return nullptr; 200 } 201 197 202 const ast::Type * isPolyType( const ast::Type * type, 198 203 const TypeVarMap & typeVars, const ast::TypeSubstitution * subst ) { … … 202 207 if ( typeVars.contains( *inst ) ) return type; 203 208 } else if ( auto array = dynamic_cast< const ast::ArrayType * >( type ) ) { 204 return isPolyType( array->base, typeVars,subst );209 return isPolyType( array->base, subst ); 205 210 } else if ( auto sue = dynamic_cast< const ast::StructInstType * >( type ) ) { 206 if ( hasPolyParams( sue->params, typeVars,subst ) ) return type;211 if ( hasPolyParams( sue->params, subst ) ) return type; 207 212 } else if ( auto sue = dynamic_cast< const ast::UnionInstType * >( type ) ) { 208 if ( hasPolyParams( sue->params, typeVars,subst ) ) return type;213 if ( hasPolyParams( sue->params, subst ) ) return type; 209 214 } 210 215 return nullptr;
Note: See TracChangeset
for help on using the changeset viewer.