Changeset 63d1ebe for src/GenPoly
- Timestamp:
- Oct 27, 2022, 11:43:10 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 0026d67
- Parents:
- a167c70c
- Location:
- src/GenPoly
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/GenPoly.cc
ra167c70c r63d1ebe 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Oct 7 15:25:00 202213 // Update Count : 1 612 // Last Modified On : Mon Oct 24 15:19:00 2022 13 // Update Count : 17 14 14 // 15 15 … … 194 194 195 195 if ( auto inst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 196 if ( typeVars.find( inst->typeString()) != typeVars.end() ) return type;196 if ( typeVars.find( *inst ) != typeVars.end() ) return type; 197 197 } else if ( auto array = dynamic_cast< const ast::ArrayType * >( type ) ) { 198 198 return isPolyType( array->base, subst ); … … 227 227 228 228 if ( auto inst = dynamic_cast<ast::TypeInstType const *>( type ) ) { 229 auto var = typeVars.find( inst->name);229 auto var = typeVars.find( *inst ); 230 230 if ( var != typeVars.end() && var->second.isComplete ) { 231 231 … … 784 784 785 785 void addToTypeVarMap( const ast::TypeInstType * type, TypeVarMap & typeVars ) { 786 typeVars.insert( type->typeString(), ast::TypeDecl::Data( type->base ) );786 typeVars.insert( *type, ast::TypeDecl::Data( type->base ) ); 787 787 } 788 788 … … 816 816 } 817 817 818 void printTypeVarMap( std::ostream &os, const TypeVarMap & typeVars ) {819 for ( auto const & pair : typeVars ) {820 os << pair.first << " (" << pair.second << ") ";821 } // for822 os << std::endl;823 }824 825 818 } // namespace GenPoly 826 819 -
src/GenPoly/GenPoly.h
ra167c70c r63d1ebe 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Oct 7 15:06:00 202213 // Update Count : 912 // Last Modified On : Mon Oct 24 15:18:00 2022 13 // Update Count : 11 14 14 // 15 15 … … 22 22 #include "AST/Decl.hpp" // for TypeDecl::Data 23 23 #include "AST/Fwd.hpp" // for ApplicationExpr, BaseInstType, Func... 24 #include "AST/Type.hpp" // for TypeInstType::TypeEnvKey 24 25 #include "SymTab/Mangler.h" // for Mangler 25 26 #include "SynTree/Declaration.h" // for TypeDecl::Data, AggregateDecl, Type... … … 28 29 namespace GenPoly { 29 30 30 // TODO Via some tricks this works for ast::TypeDecl::Data as well.31 31 typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap; 32 using TypeVarMap = ErasableScopedMap< std::string, ast::TypeDecl::Data >;32 using TypeVarMap = ErasableScopedMap< ast::TypeInstType::TypeEnvKey, ast::TypeDecl::Data >; 33 33 34 34 /// Replaces a TypeInstType by its referrent in the environment, if applicable 35 35 Type* replaceTypeInst( Type* type, const TypeSubstitution* env ); 36 const ast::Type * replaceTypeInst( const ast::Type *, const ast::TypeSubstitution * ); 36 37 37 38 /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided … … 53 54 /// true iff function has dynamic-layout return type under the type variable map generated from its forall-parameters 54 55 ReferenceToType *isDynRet( FunctionType *function ); 56 const ast::BaseInstType *isDynRet( const ast::FunctionType * func ); 55 57 56 58 /// A function needs an adapter if it returns a dynamic-layout value or if any of its parameters have dynamic-layout type … … 112 114 /// Prints type variable map 113 115 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ); 114 void printTypeVarMap( std::ostream &os, const TypeVarMap & typeVars );115 116 116 117 /// Gets the mangled name of this type; alias for SymTab::Mangler::mangleType(). … … 128 129 /// Gets the name of the layout function for a given aggregate type, given its declaration 129 130 inline std::string layoutofName( AggregateDecl *decl ) { return std::string( "_layoutof_" ) + decl->get_name(); } 131 inline std::string layoutofName( ast::AggregateDecl const * decl ) { 132 return std::string( "_layoutof_" ) + decl->name; 133 } 130 134 131 135 } // namespace GenPoly -
src/GenPoly/ScrubTyVars.cc
ra167c70c r63d1ebe 195 195 } 196 196 197 auto typeVar = typeVars->find( type->name );197 auto typeVar = typeVars->find( *type ); 198 198 if ( typeVar == typeVars->end() ) { 199 199 return type;
Note:
See TracChangeset
for help on using the changeset viewer.