source: src/ResolvExpr/Unify.h @ 2bfc6b2

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 2bfc6b2 was d286cf68, checked in by Aaron Moss <a3moss@…>, 6 years ago

Fix TypeEnvironment? bind algorithms

  • Property mode set to 100644
File size: 3.0 KB
Line 
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
25class Type;
26class TypeInstType;
27namespace SymTab {
28class Indexer;
29}  // namespace SymTab
30
31namespace 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                if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
57                        deleteAll( commonTypes );
58                        return true;
59                } else {
60                        return false;
61                } // if
62        }
63
64} // namespace ResolvExpr
65
66// Local Variables: //
67// tab-width: 4 //
68// mode: c++ //
69// compile-command: "make install" //
70// End: //
Note: See TracBrowser for help on using the repository browser.