| [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 | 
|---|
| [e563edf] | 11 | // Last Modified By : Andrew Beach | 
|---|
|  | 12 | // Last Modified On : Tue Jan 17 11:12:00 2023 | 
|---|
|  | 13 | // Update Count     : 5 | 
|---|
| [a32b204] | 14 | // | 
|---|
| [51b73452] | 15 |  | 
|---|
| [6b0b624] | 16 | #pragma once | 
|---|
| [51b73452] | 17 |  | 
|---|
| [ea6332d] | 18 | #include <list>                   // for list | 
|---|
|  | 19 |  | 
|---|
| [f474e91] | 20 | #include "AST/Node.hpp"             // for ptr | 
|---|
| [d76c588] | 21 | #include "AST/TypeEnvironment.hpp"  // for TypeEnvironment, AssertionSet, OpenVarSet | 
|---|
| [ea6332d] | 22 | #include "Common/utility.h"       // for deleteAll | 
|---|
|  | 23 | #include "SynTree/Declaration.h"  // for TypeDecl, TypeDecl::Data | 
|---|
|  | 24 | #include "TypeEnvironment.h"      // for AssertionSet, OpenVarSet | 
|---|
| [d76c588] | 25 | #include "WidenMode.h"              // for WidenMode | 
|---|
| [ea6332d] | 26 |  | 
|---|
|  | 27 | class Type; | 
|---|
|  | 28 | class TypeInstType; | 
|---|
|  | 29 | namespace SymTab { | 
|---|
| [d76c588] | 30 | class Indexer; | 
|---|
|  | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 | namespace ast { | 
|---|
|  | 34 | class SymbolTable; | 
|---|
|  | 35 | class Type; | 
|---|
|  | 36 | } | 
|---|
| [51b73452] | 37 |  | 
|---|
|  | 38 | namespace ResolvExpr { | 
|---|
| [e563edf] | 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, const ast::SymbolTable & symtab ); | 
|---|
|  | 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, const ast::SymbolTable & symtab, 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, const ast::SymbolTable & symtab ); | 
|---|
|  | 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, const ast::SymbolTable & symtab, | 
|---|
|  | 77 | ast::ptr<ast::Type> & common ); | 
|---|
|  | 78 |  | 
|---|
|  | 79 | bool typesCompatible( | 
|---|
|  | 80 | const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, | 
|---|
|  | 81 | const ast::TypeEnvironment & env = {} ); | 
|---|
|  | 82 |  | 
|---|
|  | 83 | bool typesCompatibleIgnoreQualifiers( | 
|---|
|  | 84 | const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, | 
|---|
|  | 85 | const ast::TypeEnvironment & env = {} ); | 
|---|
| [d76c588] | 86 |  | 
|---|
| [7b5694d] | 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 |  | 
|---|
| [51b73452] | 97 | } // namespace ResolvExpr | 
|---|
|  | 98 |  | 
|---|
| [a32b204] | 99 | // Local Variables: // | 
|---|
|  | 100 | // tab-width: 4 // | 
|---|
|  | 101 | // mode: c++ // | 
|---|
|  | 102 | // compile-command: "make install" // | 
|---|
|  | 103 | // End: // | 
|---|