source: src/ResolvExpr/CandidateFinder.hpp @ 4bb5d36

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since 4bb5d36 was 39d8950, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Thread global information through resolution. Non-top-level calls to the resolver have a bit of a hack but improvements would require changes to the Pass helpers.

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[99d4584]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// CandidateFinder.hpp --
8//
9// Author           : Aaron B. Moss
10// Created On       : Wed Jun 5 14:30:00 2019
[cf32116]11// Last Modified By : Andrew Beach
[39d8950]12// Last Modified On : Wed Mar 16 15:22:00 2022
13// Update Count     : 3
[99d4584]14//
15
16#pragma once
17
18#include "Candidate.hpp"
19#include "ResolvMode.h"
20#include "AST/Fwd.hpp"
[396037d]21#include "AST/Node.hpp"
[99d4584]22#include "AST/SymbolTable.hpp"
23#include "AST/TypeEnvironment.hpp"
24
25namespace ResolvExpr {
26
[39d8950]27struct ResolveContext;
28
[99d4584]29/// Data to perform expression resolution
30struct CandidateFinder {
[c8e4d2f8]31        CandidateList candidates;          ///< List of candidate resolutions
[39d8950]32        const ResolveContext & context;  ///< Information about where the canditates are being found.
[c8e4d2f8]33        const ast::TypeEnvironment & env;  ///< Substitutions performed in this resolution
34        ast::ptr< ast::Type > targetType;  ///< Target type for resolution
[e5c3811]35        std::set< std::string > otypeKeys;  /// different type may map to same key
[c8e4d2f8]36
[cf32116]37        CandidateFinder(
[39d8950]38                const ResolveContext & context, const ast::TypeEnvironment & env,
[c8e4d2f8]39                const ast::Type * tt = nullptr )
[39d8950]40        : candidates(), context( context ), env( env ), targetType( tt ) {}
[99d4584]41
42        /// Fill candidates with feasible resolutions for `expr`
43        void find( const ast::Expr * expr, ResolvMode mode = {} );
[1389810]44        bool pruneCandidates( CandidateList & candidates, CandidateList & out, std::vector<std::string> & errors );
[2773ab8]45
46        /// Runs new candidate finder on each element in xs, returning the list of finders
47        std::vector< CandidateFinder > findSubExprs( const std::vector< ast::ptr< ast::Expr > > & xs );
48
49        using value_type = CandidateList::value_type;
50        using iterator = CandidateList::iterator;
51        using const_iterator = CandidateList::const_iterator;
52
53        iterator begin() { return candidates.begin(); }
54        const_iterator begin() const { return candidates.begin(); }
[cf32116]55
[2773ab8]56        iterator end() { return candidates.end(); }
57        const_iterator end() const { return candidates.end(); }
[99d4584]58};
59
[b69233ac]60/// Computes conversion cost between two types
[cf32116]61Cost computeConversionCost(
62        const ast::Type * argType, const ast::Type * paramType, bool argIsLvalue,
63        const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );
[b69233ac]64
[99d4584]65} // namespace ResolvExpr
66
67// Local Variables: //
68// tab-width: 4 //
69// mode: c++ //
70// compile-command: "make install" //
71// End: //
Note: See TracBrowser for help on using the repository browser.