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 : Aaron B. Moss |
---|
12 | // Last Modified On : Mon Jun 18 11:58:00 2018 |
---|
13 | // Update Count : 4 |
---|
14 | // |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | #include <list> // for list |
---|
19 | |
---|
20 | #include "Common/utility.h" // for deleteAll |
---|
21 | #include "SynTree/Declaration.h" // for TypeDecl, TypeDecl::Data |
---|
22 | #include "TypeEnvironment.h" // for AssertionSet, OpenVarSet |
---|
23 | #include "WidenMode.h" // for WidenMode |
---|
24 | |
---|
25 | class Type; |
---|
26 | class TypeInstType; |
---|
27 | namespace SymTab { |
---|
28 | class Indexer; |
---|
29 | } // namespace SymTab |
---|
30 | |
---|
31 | namespace ResolvExpr { |
---|
32 | bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); |
---|
33 | bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); |
---|
34 | bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); |
---|
35 | bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer, Type *&common ); |
---|
36 | |
---|
37 | template< typename Iterator1, typename Iterator2 > |
---|
38 | 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 ) { |
---|
39 | for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { |
---|
40 | Type *commonType = 0; |
---|
41 | if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { |
---|
42 | return false; |
---|
43 | } // if |
---|
44 | commonTypes.push_back( commonType ); |
---|
45 | } // for |
---|
46 | if ( list1Begin != list1End || list2Begin != list2End ) { |
---|
47 | return false; |
---|
48 | } else { |
---|
49 | return true; |
---|
50 | } // if |
---|
51 | } |
---|
52 | |
---|
53 | template< typename Iterator1, typename Iterator2 > |
---|
54 | bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { |
---|
55 | std::list< Type* > commonTypes; |
---|
56 | return unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ); |
---|
57 | } |
---|
58 | |
---|
59 | } // namespace ResolvExpr |
---|
60 | |
---|
61 | // Local Variables: // |
---|
62 | // tab-width: 4 // |
---|
63 | // mode: c++ // |
---|
64 | // compile-command: "make install" // |
---|
65 | // End: // |
---|