Changeset 66f8528 for src/ResolvExpr
- Timestamp:
- Dec 15, 2016, 5:16:42 PM (8 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:
- 43385ca, f7ff3fb
- Parents:
- 5802a4f (diff), 596f987b (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. - Location:
- src/ResolvExpr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/CommonType.cc ¶
r5802a4f r66f8528 42 42 virtual void visit( OneType *oneType ); 43 43 44 void getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer ); 44 45 template< typename RefType > void handleRefType( RefType *inst, Type *other ); 45 46 … … 143 144 } 144 145 145 /// true if a common type for t must be a complete type 146 bool requiredComplete( Type * t ) { 147 if ( TypeInstType * inst = dynamic_cast< TypeInstType * > ( t ) ) { 148 return inst->get_baseType()->isComplete(); 146 void CommonType::getCommonWithVoidPointer( PointerType* voidPointer, PointerType* otherPointer ) { 147 if ( TypeInstType* var = dynamic_cast< TypeInstType* >( otherPointer->get_base() ) ) { 148 OpenVarSet::const_iterator entry = openVars.find( var->get_name() ); 149 if ( entry != openVars.end() ) { 150 AssertionSet need, have; 151 WidenMode widen( widenFirst, widenSecond ); 152 if ( entry != openVars.end() && ! bindVar(var, voidPointer->get_base(), entry->second, env, need, have, openVars, widen, indexer ) ) return; 153 } 149 154 } 150 return false; 155 result = voidPointer->clone(); 156 result->get_qualifiers() += otherPointer->get_qualifiers(); 151 157 } 152 158 153 159 void CommonType::visit( PointerType *pointerType ) { 154 160 if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) { 155 // Note: relationship between formal and actual types is antisymmetric 156 // void free(void *); 157 // forall(otype T) void foo(T *); 158 // 159 // should be able to pass T* to free, but should not be able to pass a void* to foo. 160 // because of this, the requiredComplete check occurs only on the first, since it corresponds 161 // to the formal parameter type (though this may be incorrect in some cases, in which case 162 // perhaps the widen mode needs to incorporate another bit for whether this is a formal or actual context) 163 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) && ! requiredComplete( pointerType->get_base() ) ) { 164 result = otherPointer->clone(); 165 result->get_qualifiers() += pointerType->get_qualifiers(); 161 if ( widenFirst && dynamic_cast< VoidType* >( otherPointer->get_base() ) && ! isFtype(pointerType->get_base(), indexer) ) { 162 getCommonWithVoidPointer( otherPointer, pointerType ); 166 163 } else if ( widenSecond && dynamic_cast< VoidType* >( pointerType->get_base() ) && ! isFtype(otherPointer->get_base(), indexer) ) { 167 result = pointerType->clone(); 168 result->get_qualifiers() += otherPointer->get_qualifiers(); 164 getCommonWithVoidPointer( pointerType, otherPointer ); 169 165 } else if ( ( pointerType->get_base()->get_qualifiers() >= otherPointer->get_base()->get_qualifiers() || widenFirst ) 170 166 && ( pointerType->get_base()->get_qualifiers() <= otherPointer->get_base()->get_qualifiers() || widenSecond ) ) { … … 256 252 result->get_qualifiers() += zeroType->get_qualifiers(); 257 253 } 254 } else if ( widenSecond && dynamic_cast< OneType* >( type2 ) ) { 255 result = new BasicType( zeroType->get_qualifiers(), BasicType::SignedInt ); 256 result->get_qualifiers() += type2->get_qualifiers(); 258 257 } 259 258 } … … 267 266 result->get_qualifiers() += oneType->get_qualifiers(); 268 267 } 268 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) { 269 result = new BasicType( oneType->get_qualifiers(), BasicType::SignedInt ); 270 result->get_qualifiers() += type2->get_qualifiers(); 269 271 } 270 272 } -
TabularUnified src/ResolvExpr/Resolver.cc ¶
r5802a4f r66f8528 404 404 template< typename AggrInst > 405 405 TypeSubstitution makeGenericSubstitutuion( AggrInst * inst ) { 406 assert( inst ); 407 assert( inst->get_baseParameters() ); 406 408 std::list< TypeDecl * > baseParams = *inst->get_baseParameters(); 407 409 std::list< Expression * > typeSubs = inst->get_parameters(); … … 444 446 445 447 void Resolver::resolveAggrInit( ReferenceToType * inst, InitIterator & init, InitIterator & initEnd ) { 446 447 448 if ( StructInstType * sit = dynamic_cast< StructInstType * >( inst ) ) { 448 449 TypeSubstitution sub = makeGenericSubstitutuion( sit ); … … 455 456 } 456 457 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) { 457 TypeSubstitution sub = makeGenericSubstitutuion( sit );458 TypeSubstitution sub = makeGenericSubstitutuion( uit ); 458 459 UnionDecl * un = uit->get_baseUnion(); 459 460 // only resolve to the first member of a union -
TabularUnified src/ResolvExpr/Unify.cc ¶
r5802a4f r66f8528 31 31 32 32 namespace ResolvExpr { 33 struct WidenMode {34 WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}35 WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }36 WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }37 WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }38 WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }39 operator bool() { return widenFirst && widenSecond; }40 41 bool widenFirst : 1, widenSecond : 1;42 };43 33 44 34 class Unify : public Visitor { -
TabularUnified src/ResolvExpr/Unify.h ¶
r5802a4f r66f8528 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Unify.h -- 7 // Unify.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 27 27 28 28 namespace ResolvExpr { 29 struct WidenMode { 30 WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {} 31 WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; } 32 WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; } 33 WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; } 34 WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; } 35 operator bool() { return widenFirst && widenSecond; } 36 37 bool widenFirst : 1, widenSecond : 1; 38 }; 39 40 bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 29 41 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 30 42 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
Note: See TracChangeset
for help on using the changeset viewer.