| [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
 | 
|---|
 | 12 | // Last Modified On : Tue Oct  1  9:51:00 2019
 | 
|---|
 | 13 | // Update Count     : 2
 | 
|---|
| [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 | 
 | 
|---|
 | 25 | namespace ResolvExpr {
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | /// Data to perform expression resolution
 | 
|---|
 | 28 | struct CandidateFinder {
 | 
|---|
| [c8e4d2f8] | 29 |         CandidateList candidates;          ///< List of candidate resolutions
 | 
|---|
| [9ea38de] | 30 |         const ast::SymbolTable & localSyms;   ///< Symbol table to lookup candidates
 | 
|---|
| [c8e4d2f8] | 31 |         const ast::TypeEnvironment & env;  ///< Substitutions performed in this resolution
 | 
|---|
 | 32 |         ast::ptr< ast::Type > targetType;  ///< Target type for resolution
 | 
|---|
| [e5c3811] | 33 |         std::set< std::string > otypeKeys;  /// different type may map to same key
 | 
|---|
| [c8e4d2f8] | 34 | 
 | 
|---|
| [cf32116] | 35 |         CandidateFinder(
 | 
|---|
 | 36 |                 const ast::SymbolTable & syms, const ast::TypeEnvironment & env,
 | 
|---|
| [c8e4d2f8] | 37 |                 const ast::Type * tt = nullptr )
 | 
|---|
| [9ea38de] | 38 |         : candidates(), localSyms( syms ), env( env ), targetType( tt ) {}
 | 
|---|
| [99d4584] | 39 | 
 | 
|---|
 | 40 |         /// Fill candidates with feasible resolutions for `expr`
 | 
|---|
 | 41 |         void find( const ast::Expr * expr, ResolvMode mode = {} );
 | 
|---|
| [1389810] | 42 |         bool pruneCandidates( CandidateList & candidates, CandidateList & out, std::vector<std::string> & errors );
 | 
|---|
| [2773ab8] | 43 | 
 | 
|---|
 | 44 |         /// Runs new candidate finder on each element in xs, returning the list of finders
 | 
|---|
 | 45 |         std::vector< CandidateFinder > findSubExprs( const std::vector< ast::ptr< ast::Expr > > & xs );
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 |         using value_type = CandidateList::value_type;
 | 
|---|
 | 48 |         using iterator = CandidateList::iterator;
 | 
|---|
 | 49 |         using const_iterator = CandidateList::const_iterator;
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 |         iterator begin() { return candidates.begin(); }
 | 
|---|
 | 52 |         const_iterator begin() const { return candidates.begin(); }
 | 
|---|
| [cf32116] | 53 | 
 | 
|---|
| [2773ab8] | 54 |         iterator end() { return candidates.end(); }
 | 
|---|
 | 55 |         const_iterator end() const { return candidates.end(); }
 | 
|---|
| [99d4584] | 56 | };
 | 
|---|
 | 57 | 
 | 
|---|
| [b69233ac] | 58 | /// Computes conversion cost between two types
 | 
|---|
| [cf32116] | 59 | Cost computeConversionCost(
 | 
|---|
 | 60 |         const ast::Type * argType, const ast::Type * paramType, bool argIsLvalue,
 | 
|---|
 | 61 |         const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );
 | 
|---|
| [b69233ac] | 62 | 
 | 
|---|
| [99d4584] | 63 | } // namespace ResolvExpr
 | 
|---|
 | 64 | 
 | 
|---|
 | 65 | // Local Variables: //
 | 
|---|
 | 66 | // tab-width: 4 //
 | 
|---|
 | 67 | // mode: c++ //
 | 
|---|
 | 68 | // compile-command: "make install" //
 | 
|---|
 | 69 | // End: //
 | 
|---|