Changes in src/AST/TypeSubstitution.hpp [3e5dd913:361bf01]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/TypeSubstitution.hpp
r3e5dd913 r361bf01 69 69 } 70 70 71 void add( const TypeInstType * formalType, const Type *actualType ); 72 void add( const TypeInstType::TypeEnvKey & key, const Type *actualType ); 71 void add( std::string formalType, const Type *actualType ); 73 72 void add( const TypeSubstitution &other ); 74 void remove( const TypeInstType *formalType );75 const Type *lookup( const TypeInstType *formalType ) const;73 void remove( std::string formalType ); 74 const Type *lookup( std::string formalType ) const; 76 75 bool empty() const; 76 77 void addVar( std::string formalExpr, const Expr *actualExpr ); 77 78 78 79 template< typename FormalIterator, typename ActualIterator > … … 100 101 friend class Pass; 101 102 102 typedef std::unordered_map< TypeInstType::TypeEnvKey, ptr<Type> > TypeEnvType; 103 typedef std::unordered_map< std::string, ptr<Type> > TypeEnvType; 104 typedef std::unordered_map< std::string, ptr<Expr> > VarEnvType; 103 105 TypeEnvType typeEnv; 106 VarEnvType varEnv; 104 107 105 108 public: … … 110 113 auto end() const -> decltype( typeEnv. end() ) { return typeEnv. end(); } 111 114 115 auto beginVar() -> decltype( varEnv.begin() ) { return varEnv.begin(); } 116 auto endVar() -> decltype( varEnv. end() ) { return varEnv. end(); } 117 auto beginVar() const -> decltype( varEnv.begin() ) { return varEnv.begin(); } 118 auto endVar() const -> decltype( varEnv. end() ) { return varEnv. end(); } 112 119 }; 113 120 114 // this is the only place where type parameters outside a function formal may be substituted.115 121 template< typename FormalIterator, typename ActualIterator > 116 122 void TypeSubstitution::add( FormalIterator formalBegin, FormalIterator formalEnd, ActualIterator actualBegin ) { … … 123 129 if ( const TypeExpr *actual = actualIt->template as<TypeExpr>() ) { 124 130 if ( formal->name != "" ) { 125 typeEnv[ formal ] = actual->type;131 typeEnv[ formal->name ] = actual->type; 126 132 } // if 127 133 } else { … … 129 135 } // if 130 136 } else { 131 137 // TODO: type check the formal and actual parameters 138 if ( (*formalIt)->name != "" ) { 139 varEnv[ (*formalIt)->name ] = *actualIt; 140 } // if 132 141 } // if 133 142 } // for 134 143 } 135 136 137 144 138 145 template< typename FormalIterator, typename ActualIterator > … … 140 147 add( formalBegin, formalEnd, actualBegin ); 141 148 } 142 143 149 144 150 } // namespace ast … … 158 164 159 165 const Type * postvisit( const TypeInstType * aggregateUseType ); 166 const Expr * postvisit( const NameExpr * nameExpr ); 160 167 161 168 /// Records type variable bindings from forall-statements 162 169 void previsit( const FunctionType * type ); 163 170 /// Records type variable bindings from forall-statements and instantiations of generic types 164 //void handleAggregateType( const BaseInstType * type );165 166 //void previsit( const StructInstType * aggregateUseType );167 //void previsit( const UnionInstType * aggregateUseType );171 void handleAggregateType( const BaseInstType * type ); 172 173 void previsit( const StructInstType * aggregateUseType ); 174 void previsit( const UnionInstType * aggregateUseType ); 168 175 169 176 const TypeSubstitution & sub; 170 177 int subCount = 0; 171 178 bool freeOnly; 172 typedef std::unordered_set< TypeInstType::TypeEnvKey> BoundVarsType;179 typedef std::unordered_set< std::string > BoundVarsType; 173 180 BoundVarsType boundVars; 174 181
Note: See TracChangeset
for help on using the changeset viewer.