source: src/ResolvExpr/CandidateFinder.hpp @ 297b796

Last change on this file since 297b796 was 7aa209e7, checked in by Andrew Beach <ajbeach@…>, 7 months ago

Fixing some whitespace around a recent merge. That lead to some general clean-up, including removing tailing whitespace and removing some unneeded dependences.

  • Property mode set to 100644
File size: 3.2 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// CandidateFinder.hpp --
8//
9// Author           : Aaron B. Moss
10// Created On       : Wed Jun 5 14:30:00 2019
11// Last Modified By : Andrew Beach
12// Last Modified On : Wed Mar 16 15:22:00 2022
13// Update Count     : 3
14//
15
16#pragma once
17
18#include "Candidate.hpp"
19#include "ResolveMode.hpp"
20#include "AST/Fwd.hpp"
21#include "AST/Node.hpp"
22#include "AST/SymbolTable.hpp"
23#include "AST/TypeEnvironment.hpp"
24
25namespace ResolvExpr {
26
27struct ResolveContext;
28
29/// Data to perform expression resolution
30struct CandidateFinder {
31        CandidateList candidates;          ///< List of candidate resolutions
32        const ResolveContext & context;    ///< Information about where the canditates are being found.
33        const ast::TypeEnvironment & env;  ///< Substitutions performed in this resolution
34        ast::ptr< ast::Type > targetType;  ///< Target type for resolution
35        bool strictMode = false;           ///< If set to true, requires targetType to be exact match (inside return cast)
36        bool allowVoid = false;            ///< If set to true, allow void-returning function calls (only top level, cast to void and first in comma)
37        std::set< std::string > otypeKeys; ///< different type may map to same key
38
39        CandidateFinder(
40                const ResolveContext & context, const ast::TypeEnvironment & env,
41                const ast::Type * tt = nullptr )
42        : candidates(), context( context ), env( env ), targetType( tt ) {}
43
44        /// Fill candidates with feasible resolutions for `expr`
45        void find( const ast::Expr * expr, ResolveMode mode = {} );
46        bool pruneCandidates( CandidateList & candidates, CandidateList & out, std::vector<std::string> & errors );
47
48        /// Runs new candidate finder on each element in xs, returning the list of finders
49        std::vector< CandidateFinder > findSubExprs( const std::vector< ast::ptr< ast::Expr > > & xs );
50
51        using value_type = CandidateList::value_type;
52        using iterator = CandidateList::iterator;
53        using const_iterator = CandidateList::const_iterator;
54
55        iterator begin() { return candidates.begin(); }
56        const_iterator begin() const { return candidates.begin(); }
57
58        iterator end() { return candidates.end(); }
59        const_iterator end() const { return candidates.end(); }
60};
61
62/// Computes conversion cost between two types
63Cost computeConversionCost(
64        const ast::Type * argType, const ast::Type * paramType, bool argIsLvalue,
65        const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );
66
67/// Create an expression that preforms reference to rvalue conversion on
68/// the given expression and update the cost of the expression.
69const ast::Expr * referenceToRvalueConversion(
70        const ast::Expr * expr, Cost & cost );
71
72/// Get the valueE application that returns the enum's value.
73const ast::Expr * getValueEnumCall( const ast::Expr * expr,
74        const ResolveContext & context, const ast::TypeEnvironment & env );
75
76/// Wrap an expression to convert the result to a conditional result.
77const ast::Expr * createCondExpr( const ast::Expr * expr );
78
79} // namespace ResolvExpr
80
81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.