source: src/ResolvExpr/Unify.h @ 59310bf

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 59310bf was 6b0b624, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

change #ifndef to #pragma once

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[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//
[66f8528]7// Unify.h --
[a32b204]8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 13:09:04 2015
11// Last Modified By : Peter A. Buhr
[6b0b624]12// Last Modified On : Fri Jul 21 23:09:34 2017
13// Update Count     : 3
[a32b204]14//
[51b7345]15
[6b0b624]16#pragma once
[51b7345]17
18#include <map>
19#include <list>
20#include "SynTree/SynTree.h"
21#include "SynTree/Type.h"
22#include "SynTree/Declaration.h"
23#include "SymTab/Indexer.h"
24#include "TypeEnvironment.h"
[d3b7937]25#include "Common/utility.h"
[51b7345]26
27namespace ResolvExpr {
[a2a77af]28        struct WidenMode {
29                WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}
30                WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }
31                WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }
32                WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }
33                WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
34                operator bool() { return widenFirst && widenSecond; }
35
36                bool widenFirst : 1, widenSecond : 1;
37        };
[66f8528]38
39        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 );
[a32b204]40        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
41        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
42        bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
[51b7345]43
[a32b204]44        template< typename Iterator1, typename Iterator2 >
45        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 ) {
46                for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {
47                        Type *commonType = 0;
48                        if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
49                                return false;
50                        } // if
51                        commonTypes.push_back( commonType );
52                } // for
53                if ( list1Begin != list1End || list2Begin != list2End ) {
54                        return false;
55                } else {
56                        return true;
57                } // if
58        }
59
60        template< typename Iterator1, typename Iterator2 >
61        bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
62                std::list< Type* > commonTypes;
63                if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
64                        deleteAll( commonTypes );
65                        return true;
66                } else {
67                        return false;
68                } // if
69        }
[51b7345]70
71} // namespace ResolvExpr
72
[a32b204]73// Local Variables: //
74// tab-width: 4 //
75// mode: c++ //
76// compile-command: "make install" //
77// End: //
Note: See TracBrowser for help on using the repository browser.