source: src/ResolvExpr/Unify.h @ a4943d8c

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 a4943d8c was 66f8528, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Merge branch 'master' into tuples

Conflicts:

src/ResolvExpr/CommonType.cc
src/tests/.expect/32/extension.txt
src/tests/.expect/32/gccExtensions.txt
src/tests/.expect/64/declarationSpecifier.txt
src/tests/.expect/64/extension.txt
src/tests/.expect/64/gccExtensions.txt
src/tests/.expect/castError.txt
src/tests/Makefile.am

  • Property mode set to 100644
File size: 3.6 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 : Peter A. Buhr
12// Last Modified On : Sun May 17 13:10:34 2015
13// Update Count     : 2
14//
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"
26#include "Common/utility.h"
27
28namespace ResolvExpr {
29        struct WidenMode {
30                WidenMode( bool widenFirst, bool widenSecond ): widenFirst( widenFirst ), widenSecond( widenSecond ) {}
31                WidenMode &operator|=( const WidenMode &other ) { widenFirst |= other.widenFirst; widenSecond |= other.widenSecond; return *this; }
32                WidenMode &operator&=( const WidenMode &other ) { widenFirst &= other.widenFirst; widenSecond &= other.widenSecond; return *this; }
33                WidenMode operator|( const WidenMode &other ) { WidenMode newWM( *this ); newWM |= other; return newWM; }
34                WidenMode operator&( const WidenMode &other ) { WidenMode newWM( *this ); newWM &= other; return newWM; }
35                operator bool() { return widenFirst && widenSecond; }
36
37                bool widenFirst : 1, widenSecond : 1;
38        };
39
40        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 );
41        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
42        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
43        bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
44
45        template< typename Iterator1, typename Iterator2 >
46        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 ) {
47                for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {
48                        Type *commonType = 0;
49                        if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
50                                return false;
51                        } // if
52                        commonTypes.push_back( commonType );
53                } // for
54                if ( list1Begin != list1End || list2Begin != list2End ) {
55                        return false;
56                } else {
57                        return true;
58                } // if
59        }
60
61        template< typename Iterator1, typename Iterator2 >
62        bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
63                std::list< Type* > commonTypes;
64                if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
65                        deleteAll( commonTypes );
66                        return true;
67                } else {
68                        return false;
69                } // if
70        }
71
72} // namespace ResolvExpr
73
74#endif // UNIFY_H
75
76// Local Variables: //
77// tab-width: 4 //
78// mode: c++ //
79// compile-command: "make install" //
80// End: //
Note: See TracBrowser for help on using the repository browser.