source: translator/ResolvExpr/Unify.h @ 93885663

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 93885663 was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: Unify.h,v 1.4 2005/08/29 20:14:16 rcbilson Exp $
5 *
6 */
7
8#ifndef UNIFY_H
9#define UNIFY_H
10
11#include <map>
12#include <list>
13#include "SynTree/SynTree.h"
14#include "SynTree/Type.h"
15#include "SynTree/Declaration.h"
16#include "SymTab/Indexer.h"
17#include "TypeEnvironment.h"
18#include "utility.h"
19
20namespace ResolvExpr {
21
22bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
23bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
24bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
25
26template< typename Iterator1, typename Iterator2 >
27bool
28unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) {
29  for( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {
30    Type *commonType = 0;
31    if( !unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {
32      return false;
33    }
34    commonTypes.push_back( commonType );
35  }
36  if( list1Begin != list1End || list2Begin != list2End ) {
37    return false;
38  } else {
39    return true;
40  }
41}
42
43template< typename Iterator1, typename Iterator2 >
44bool
45unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {
46  std::list< Type* > commonTypes;
47  if( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {
48    deleteAll( commonTypes );
49    return true;
50  } else {
51    return false;
52  }
53}
54
55} // namespace ResolvExpr
56
57#endif /* #ifndef UNIFY_H */
Note: See TracBrowser for help on using the repository browser.