source: src/ResolvExpr/Unify.h @ daf4c89

Last change on this file since daf4c89 was 251ce80, checked in by Fangren Yu <f37yu@…>, 18 months ago

remove reference to symbol table in unify

  • Property mode set to 100644
File size: 4.0 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 : 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
27class Type;
28class TypeInstType;
29namespace SymTab {
30        class Indexer;
31}
32
33namespace ast {
34        class SymbolTable;
35        class Type;
36}
37
38namespace ResolvExpr {
39
40bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
41bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
42bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
43bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common );
44
45bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env );
46bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env );
47
48inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) {
49        TypeEnvironment env;
50        return typesCompatible( t1, t2, indexer, env );
51}
52
53inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) {
54        TypeEnvironment env;
55        return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env );
56}
57
58bool 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
63bool 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
68bool 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
73bool 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
79bool typesCompatible(
80        const ast::Type *, const ast::Type *, 
81        const ast::TypeEnvironment & env = {} );
82
83bool 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.
89Type * extractResultType( FunctionType * functionType );
90/// Creates or extracts the type represented by returns in a `FunctionType`.
91ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func );
92
93std::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: //
Note: See TracBrowser for help on using the repository browser.