Changeset a32b204 for translator/ResolvExpr/Unify.h
- Timestamp:
- May 17, 2015, 1:19:35 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 0dd3a2f
- Parents:
- b87a5ed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/ResolvExpr/Unify.h
rb87a5ed ra32b204 1 /* 2 * This file is part of the Cforall project 3 * 4 * $Id: Unify.h,v 1.4 2005/08/29 20:14:16 rcbilson Exp $ 5 * 6 */ 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // Unify.h -- 8 // 9 // Author : Richard C. Bilson 10 // Created On : Sun May 17 13:09:04 2015 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 17 13:10:34 2015 13 // Update Count : 2 14 // 7 15 8 16 #ifndef UNIFY_H … … 19 27 20 28 namespace ResolvExpr { 29 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 30 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 31 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 21 32 22 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 23 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 24 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 33 template< typename Iterator1, typename Iterator2 > 34 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) { 35 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { 36 Type *commonType = 0; 37 if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 38 return false; 39 } // if 40 commonTypes.push_back( commonType ); 41 } // for 42 if ( list1Begin != list1End || list2Begin != list2End ) { 43 return false; 44 } else { 45 return true; 46 } // if 47 } 25 48 26 template< typename Iterator1, typename Iterator2 > 27 bool 28 unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) { 29 for( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { 30 Type *commonType = 0; 31 if( !unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 32 return false; 33 } 34 commonTypes.push_back( commonType ); 35 } 36 if( list1Begin != list1End || list2Begin != list2End ) { 37 return false; 38 } else { 39 return true; 40 } 41 } 42 43 template< typename Iterator1, typename Iterator2 > 44 bool 45 unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 46 std::list< Type* > commonTypes; 47 if( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 48 deleteAll( commonTypes ); 49 return true; 50 } else { 51 return false; 52 } 53 } 49 template< typename Iterator1, typename Iterator2 > 50 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 51 std::list< Type* > commonTypes; 52 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 53 deleteAll( commonTypes ); 54 return true; 55 } else { 56 return false; 57 } // if 58 } 54 59 55 60 } // namespace ResolvExpr 56 61 57 #endif /* #ifndef UNIFY_H */ 62 #endif // UNIFY_H 63 64 // Local Variables: // 65 // tab-width: 4 // 66 // mode: c++ // 67 // compile-command: "make install" // 68 // End: //
Note: See TracChangeset
for help on using the changeset viewer.