Changeset a180ded
- Timestamp:
- Dec 18, 2017, 3:24:40 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ce7ed2c
- Parents:
- 103b264
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/PolyCost.cc
r103b264 ra180ded 14 14 // 15 15 16 #include "Common/PassVisitor.h" 16 17 #include "SymTab/Indexer.h" // for Indexer 17 18 #include "SynTree/Type.h" // for TypeInstType, Type 18 #include "SynTree/Visitor.h" // for Visitor19 19 #include "TypeEnvironment.h" // for EqvClass, TypeEnvironment 20 20 21 21 namespace ResolvExpr { 22 class PolyCost : public Visitor { 23 public: 22 struct PolyCost { 24 23 PolyCost( const TypeEnvironment &env, const SymTab::Indexer &indexer ); 25 int get_result() const { return result; } 26 private: 27 virtual void visit(TypeInstType *aggregateUseType); 24 25 void previsit( TypeInstType * aggregateUseType ); 28 26 int result; 29 const TypeEnvironment & env;27 const TypeEnvironment &tenv; 30 28 const SymTab::Indexer &indexer; 31 29 }; 32 30 33 31 int polyCost( Type *type, const TypeEnvironment & env, const SymTab::Indexer &indexer ) { 34 P olyCostcoster( env, indexer );32 PassVisitor<PolyCost> coster( env, indexer ); 35 33 type->accept( coster ); 36 return coster. get_result();34 return coster.pass.result; 37 35 } 38 36 39 PolyCost::PolyCost( const TypeEnvironment & env, const SymTab::Indexer & indexer ) : result( 0 ), env( env ), indexer( indexer ) {37 PolyCost::PolyCost( const TypeEnvironment & env, const SymTab::Indexer & indexer ) : result( 0 ), tenv( env ), indexer( indexer ) { 40 38 } 41 39 42 void PolyCost:: visit(TypeInstType * typeInst) {40 void PolyCost::previsit(TypeInstType * typeInst) { 43 41 EqvClass eqvClass; 44 if ( env.lookup( typeInst->name, eqvClass ) ) {42 if ( tenv.lookup( typeInst->name, eqvClass ) ) { 45 43 if ( eqvClass.type ) { 46 44 if ( TypeInstType * otherTypeInst = dynamic_cast< TypeInstType* >( eqvClass.type ) ) {
Note: See TracChangeset
for help on using the changeset viewer.