| [a32b204] | 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 | //
|
|---|
| [51b73452] | 15 |
|
|---|
| 16 | #ifndef UNIFY_H
|
|---|
| 17 | #define UNIFY_H
|
|---|
| 18 |
|
|---|
| 19 | #include <map>
|
|---|
| 20 | #include <list>
|
|---|
| 21 | #include "SynTree/SynTree.h"
|
|---|
| 22 | #include "SynTree/Type.h"
|
|---|
| 23 | #include "SynTree/Declaration.h"
|
|---|
| 24 | #include "SymTab/Indexer.h"
|
|---|
| 25 | #include "TypeEnvironment.h"
|
|---|
| [d3b7937] | 26 | #include "Common/utility.h"
|
|---|
| [51b73452] | 27 |
|
|---|
| 28 | namespace ResolvExpr {
|
|---|
| [a32b204] | 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 );
|
|---|
| [51b73452] | 32 |
|
|---|
| [a32b204] | 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 | }
|
|---|
| 48 |
|
|---|
| 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 | }
|
|---|
| [51b73452] | 59 |
|
|---|
| 60 | } // namespace ResolvExpr
|
|---|
| 61 |
|
|---|
| [a32b204] | 62 | #endif // UNIFY_H
|
|---|
| 63 |
|
|---|
| 64 | // Local Variables: //
|
|---|
| 65 | // tab-width: 4 //
|
|---|
| 66 | // mode: c++ //
|
|---|
| 67 | // compile-command: "make install" //
|
|---|
| 68 | // End: //
|
|---|