- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/GenericParameter.cpp
rf02f546 rcaf06aa 16 16 #include "GenericParameter.hpp" 17 17 18 #include "AST/Copy.hpp" 18 19 #include "AST/Decl.hpp" 19 20 #include "AST/Expr.hpp" … … 164 165 165 166 struct TranslateDimensionCore : 166 public WithNoIdSymbolTable, public ast::WithGuards, 167 public ast::WithVisitorRef<TranslateDimensionCore> { 167 public WithNoIdSymbolTable, public ast::WithGuards { 168 168 169 169 // SUIT: Struct- or Union- InstType … … 190 190 191 191 const ast::TypeDecl * postvisit( const ast::TypeDecl * decl ); 192 const ast::Type * postvisit( const ast::FunctionType * type );193 const ast::Type * postvisit( const ast::TypeInstType * type );194 195 192 const ast::Expr * postvisit( const ast::DimensionExpr * expr ); 196 193 const ast::Expr * postvisit( const ast::Expr * expr ); … … 198 195 }; 199 196 200 // Declaration of type variable: forall( [N] ) -> forall( N & | sized( N ) )201 197 const ast::TypeDecl * TranslateDimensionCore::postvisit( 202 198 const ast::TypeDecl * decl ) { … … 210 206 } 211 207 return decl; 212 }213 214 // Makes postvisit( TypeInstType ) get called on the entries of the function declaration's type's forall list.215 // Pass.impl.hpp's visit( FunctionType ) does not consider the forall entries to be child nodes.216 // Workaround is: during the current TranslateDimension pass, manually visit down there.217 const ast::Type * TranslateDimensionCore::postvisit(218 const ast::FunctionType * type ) {219 visitor->maybe_accept( type, &ast::FunctionType::forall );220 return type;221 }222 223 // Use of type variable, assuming `forall( [N] )` in scope: void (*)( foo( /*dimension*/ N ) & ) -> void (*)( foo( /*dtype*/ N ) & )224 const ast::Type * TranslateDimensionCore::postvisit(225 const ast::TypeInstType * type ) {226 if ( type->kind == ast::TypeDecl::Dimension ) {227 auto mutType = ast::mutate( type );228 mutType->kind = ast::TypeDecl::Dtype;229 return mutType;230 }231 return type;232 208 } 233 209
Note:
See TracChangeset
for help on using the changeset viewer.