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 : Andrew Beach |
---|
12 | // Last Modified On : Tue Jan 17 11:12:00 2023 |
---|
13 | // Update Count : 5 |
---|
14 | // |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | #include <list> // for list |
---|
19 | |
---|
20 | #include "AST/Node.hpp" // for ptr |
---|
21 | #include "AST/TypeEnvironment.hpp" // for TypeEnvironment, AssertionSet, OpenVarSet |
---|
22 | #include "Common/utility.h" // for deleteAll |
---|
23 | #include "SynTree/Declaration.h" // for TypeDecl, TypeDecl::Data |
---|
24 | #include "TypeEnvironment.h" // for AssertionSet, OpenVarSet |
---|
25 | #include "WidenMode.h" // for WidenMode |
---|
26 | |
---|
27 | class Type; |
---|
28 | class TypeInstType; |
---|
29 | namespace SymTab { |
---|
30 | class Indexer; |
---|
31 | } |
---|
32 | |
---|
33 | namespace ast { |
---|
34 | class SymbolTable; |
---|
35 | class Type; |
---|
36 | } |
---|
37 | |
---|
38 | namespace ResolvExpr { |
---|
39 | |
---|
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 ); |
---|
43 | bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common ); |
---|
44 | |
---|
45 | bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); |
---|
46 | bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); |
---|
47 | |
---|
48 | inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { |
---|
49 | TypeEnvironment env; |
---|
50 | return typesCompatible( t1, t2, indexer, env ); |
---|
51 | } |
---|
52 | |
---|
53 | inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { |
---|
54 | TypeEnvironment env; |
---|
55 | return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env ); |
---|
56 | } |
---|
57 | |
---|
58 | bool unify( |
---|
59 | const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, |
---|
60 | ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, |
---|
61 | ast::OpenVarSet & open ); |
---|
62 | |
---|
63 | bool unify( |
---|
64 | const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, |
---|
65 | ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, |
---|
66 | ast::OpenVarSet & open, ast::ptr<ast::Type> & common ); |
---|
67 | |
---|
68 | bool unifyExact( |
---|
69 | const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, |
---|
70 | ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, |
---|
71 | WidenMode widen ); |
---|
72 | |
---|
73 | bool unifyInexact( |
---|
74 | const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, |
---|
75 | ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, |
---|
76 | const ast::OpenVarSet & open, WidenMode widen, |
---|
77 | ast::ptr<ast::Type> & common ); |
---|
78 | |
---|
79 | bool typesCompatible( |
---|
80 | const ast::Type *, const ast::Type *, |
---|
81 | const ast::TypeEnvironment & env = {} ); |
---|
82 | |
---|
83 | bool typesCompatibleIgnoreQualifiers( |
---|
84 | const ast::Type *, const ast::Type *, |
---|
85 | const ast::TypeEnvironment & env = {} ); |
---|
86 | |
---|
87 | /// Creates the type represented by the list of returnVals in a FunctionType. |
---|
88 | /// The caller owns the return value. |
---|
89 | Type * extractResultType( FunctionType * functionType ); |
---|
90 | /// Creates or extracts the type represented by returns in a `FunctionType`. |
---|
91 | ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ); |
---|
92 | |
---|
93 | std::vector<ast::ptr<ast::Type>> flattenList( |
---|
94 | const std::vector<ast::ptr<ast::Type>> & src, ast::TypeEnvironment & env |
---|
95 | ); |
---|
96 | |
---|
97 | } // namespace ResolvExpr |
---|
98 | |
---|
99 | // Local Variables: // |
---|
100 | // tab-width: 4 // |
---|
101 | // mode: c++ // |
---|
102 | // compile-command: "make install" // |
---|
103 | // End: // |
---|