Changeset b067d9b for src/ResolvExpr/typeops.h
- Timestamp:
- Oct 29, 2019, 4:01:24 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 773db65, 9421f3d8
- Parents:
- 7951100 (diff), 8364209 (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/typeops.h
r7951100 rb067d9b 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 07:28:22 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:36:18 201713 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Aug 8 16:36:00 2019 13 // Update Count : 5 14 14 // 15 15 … … 18 18 #include <vector> 19 19 20 #include "Cost.h" 21 #include "TypeEnvironment.h" 22 #include "WidenMode.h" 23 #include "AST/Fwd.hpp" 24 #include "AST/Node.hpp" 25 #include "AST/SymbolTable.hpp" 26 #include "AST/Type.hpp" 27 #include "AST/TypeEnvironment.hpp" 20 28 #include "SynTree/SynTree.h" 21 29 #include "SynTree/Type.h" 22 #include "SymTab/Indexer.h" 23 #include "Cost.h" 24 #include "TypeEnvironment.h" 30 31 namespace SymTab { 32 class Indexer; 33 } 25 34 26 35 namespace ResolvExpr { … … 54 63 // in AdjustExprType.cc 55 64 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function 56 void adjustExprType( Type *& type, const TypeEnvironment &env, const SymTab::Indexer &indexer );65 void adjustExprType( Type *& type, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 57 66 58 67 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function using empty TypeEnvironment and Indexer … … 60 69 61 70 template< typename ForwardIterator > 62 void adjustExprTypeList( ForwardIterator begin, ForwardIterator end, const TypeEnvironment & env, const SymTab::Indexer &indexer ) {71 void adjustExprTypeList( ForwardIterator begin, ForwardIterator end, const TypeEnvironment & env, const SymTab::Indexer & indexer ) { 63 72 while ( begin != end ) { 64 73 adjustExprType( *begin++, env, indexer ); … … 66 75 } 67 76 77 /// Replaces array types with equivalent pointer, and function types with a pointer-to-function 78 const ast::Type * adjustExprType( 79 const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab ); 80 68 81 // in CastCost.cc 69 Cost castCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 82 Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue, 83 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 84 Cost castCost( 85 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 86 const ast::TypeEnvironment & env ); 70 87 71 88 // in ConversionCost.cc 72 Cost conversionCost( Type *src, Type *dest, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 89 Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue, 90 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 91 Cost conversionCost( 92 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 93 const ast::TypeEnvironment & env ); 94 95 // in AlternativeFinder.cc 96 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue, 97 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 73 98 74 99 // in PtrsAssignable.cc 75 int ptrsAssignable( Type *src, Type *dest, const TypeEnvironment &env ); 100 int ptrsAssignable( const Type * src, const Type * dest, const TypeEnvironment & env ); 101 int ptrsAssignable( const ast::Type * src, const ast::Type * dst, 102 const ast::TypeEnvironment & env ); 76 103 77 104 // in PtrsCastable.cc 78 int ptrsCastable( Type *src, Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer ); 105 int ptrsCastable( const Type * src, const Type * dest, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 106 int ptrsCastable( 107 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 108 const ast::TypeEnvironment & env ); 79 109 80 110 // in Unify.cc 81 bool isFtype( Type *type ); 82 bool typesCompatible( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 83 bool typesCompatibleIgnoreQualifiers( Type *, Type *, const SymTab::Indexer &indexer, const TypeEnvironment &env ); 84 85 inline bool typesCompatible( Type *t1, Type *t2, const SymTab::Indexer &indexer ) { 111 bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 112 bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 113 114 inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 86 115 TypeEnvironment env; 87 116 return typesCompatible( t1, t2, indexer, env ); 88 117 } 89 118 90 inline bool typesCompatibleIgnoreQualifiers( Type *t1, Type *t2, const SymTab::Indexer &indexer ) {119 inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 91 120 TypeEnvironment env; 92 121 return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env ); 93 122 } 94 123 124 bool typesCompatible( 125 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 126 const ast::TypeEnvironment & env = {} ); 127 128 bool typesCompatibleIgnoreQualifiers( 129 const ast::Type *, const ast::Type *, const ast::SymbolTable &, 130 const ast::TypeEnvironment & env = {} ); 131 95 132 /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value. 96 133 Type * extractResultType( FunctionType * functionType ); 134 /// Creates or extracts the type represented by the list of returns in a `FunctionType`. 135 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ); 97 136 98 137 // in CommonType.cc 99 Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars ); 138 Type * commonType( Type * type1, Type * type2, bool widenFirst, bool widenSecond, const SymTab::Indexer & indexer, TypeEnvironment & env, const OpenVarSet & openVars ); 139 ast::ptr< ast::Type > commonType( 140 const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2, WidenMode widen, 141 const ast::SymbolTable & symtab, ast::TypeEnvironment & env, const ast::OpenVarSet & open ); 100 142 101 143 // in PolyCost.cc 102 int polyCost( Type *type, const TypeEnvironment &env, const SymTab::Indexer &indexer ); 144 int polyCost( Type * type, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 145 int polyCost( 146 const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 147 148 // in SpecCost.cc 149 int specCost( Type * type ); 150 int specCost( const ast::Type * type ); 103 151 104 152 // in Occurs.cc 105 bool occurs( Type *type, std::string varName, const TypeEnvironment &env ); 153 bool occurs( const Type * type, const std::string & varName, const TypeEnvironment & env ); 154 // new AST version in TypeEnvironment.cpp (only place it was used in old AST) 155 156 template<typename Iter> 157 bool occursIn( Type* ty, Iter begin, Iter end, const TypeEnvironment & env ) { 158 while ( begin != end ) { 159 if ( occurs( ty, *begin, env ) ) return true; 160 ++begin; 161 } 162 return false; 163 } 106 164 107 165 // in AlternativeFinder.cc 108 166 void referenceToRvalueConversion( Expression *& expr, Cost & cost ); 109 110 // flatten tuple type into list of types 167 // in CandidateFinder.cpp 168 const ast::Expr * referenceToRvalueConversion( const ast::Expr * expr, Cost & cost ); 169 170 /// flatten tuple type into list of types 111 171 template< typename OutputIterator > 112 172 void flatten( Type * type, OutputIterator out ) { … … 119 179 } 120 180 } 181 182 /// flatten tuple type into existing list of types 183 static inline void flatten( 184 const ast::Type * type, std::vector< ast::ptr< ast::Type > > & out 185 ) { 186 if ( auto tupleType = dynamic_cast< const ast::TupleType * >( type ) ) { 187 for ( const ast::Type * t : tupleType->types ) { 188 flatten( t, out ); 189 } 190 } else { 191 out.emplace_back( type ); 192 } 193 } 194 195 /// flatten tuple type into list of types 196 static inline std::vector< ast::ptr< ast::Type > > flatten( const ast::Type * type ) { 197 std::vector< ast::ptr< ast::Type > > out; 198 out.reserve( type->size() ); 199 flatten( type, out ); 200 return out; 201 } 202 203 // in TypeEnvironment.cc 204 bool isFtype( const Type * type ); 121 205 } // namespace ResolvExpr 206 207 namespace ast { 208 // in TypeEnvironment.cpp 209 bool isFtype( const ast::Type * type ); 210 } // namespace ast 122 211 123 212 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.