Changeset fc12f05 for src/ResolvExpr/PolyCost.cc
- Timestamp:
- Nov 13, 2023, 3:43:43 AM (23 months ago)
- Branches:
- master
- Children:
- 25f2798
- Parents:
- 0030b508 (diff), 2174191 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/PolyCost.cc
r0030b508 rfc12f05 18 18 #include "AST/Type.hpp" 19 19 #include "AST/TypeEnvironment.hpp" 20 #include "Common/PassVisitor.h"21 #include "SymTab/Indexer.h" // for Indexer22 #include "SynTree/Type.h" // for TypeInstType, Type23 #include "TypeEnvironment.h" // for EqvClass, TypeEnvironment24 20 25 21 namespace ResolvExpr { 26 struct PolyCost {27 PolyCost( const TypeEnvironment &env, const SymTab::Indexer &indexer );28 29 void previsit( TypeInstType * aggregateUseType );30 int result;31 const TypeEnvironment &tenv;32 const SymTab::Indexer &indexer;33 };34 35 int polyCost( Type *type, const TypeEnvironment & env, const SymTab::Indexer &indexer ) {36 PassVisitor<PolyCost> coster( env, indexer );37 type->accept( coster );38 return (coster.pass.result > 0) ? 1 : 0;39 }40 41 PolyCost::PolyCost( const TypeEnvironment & env, const SymTab::Indexer & indexer ) : result( 0 ), tenv( env ), indexer( indexer ) {42 }43 44 void PolyCost::previsit(TypeInstType * typeInst) {45 if ( const EqvClass *eqvClass = tenv.lookup( typeInst->name ) ) {46 if ( eqvClass->type ) {47 if ( TypeInstType * otherTypeInst = dynamic_cast< TypeInstType* >( eqvClass->type ) ) {48 if ( indexer.lookupType( otherTypeInst->name ) ) {49 // bound to opaque type50 result += 1;51 } // if52 } else {53 // bound to concrete type54 result += 1;55 } // if56 } // if57 } // if58 }59 22 60 23 // TODO: When the old PolyCost is torn out get rid of the _new suffix.
Note:
See TracChangeset
for help on using the changeset viewer.