[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
|
---|
| 11 | // Last Modified By : Aaron B. Moss
|
---|
| 12 | // Last Modified On : Wed Jun 5 14:30:00 2019
|
---|
| 13 | // Update Count : 1
|
---|
| 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 {
|
---|
| 29 | CandidateList candidates; ///< List of candidate resolutions
|
---|
| 30 | const ast::SymbolTable & symtab; ///< Symbol table to lookup candidates
|
---|
| 31 | const ast::TypeEnvironment & env; ///< Substitutions performed in this resolution
|
---|
[396037d] | 32 | ast::ptr< ast::Type > targetType = nullptr; ///< Target type for resolution
|
---|
[99d4584] | 33 |
|
---|
| 34 | CandidateFinder( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env )
|
---|
| 35 | : candidates(), symtab( symtab ), env( env ) {}
|
---|
| 36 |
|
---|
| 37 | /// Fill candidates with feasible resolutions for `expr`
|
---|
| 38 | void find( const ast::Expr * expr, ResolvMode mode = {} );
|
---|
[2773ab8] | 39 |
|
---|
| 40 | /// Runs new candidate finder on each element in xs, returning the list of finders
|
---|
| 41 | std::vector< CandidateFinder > findSubExprs( const std::vector< ast::ptr< ast::Expr > > & xs );
|
---|
| 42 |
|
---|
| 43 | using value_type = CandidateList::value_type;
|
---|
| 44 | using iterator = CandidateList::iterator;
|
---|
| 45 | using const_iterator = CandidateList::const_iterator;
|
---|
| 46 |
|
---|
| 47 | iterator begin() { return candidates.begin(); }
|
---|
| 48 | const_iterator begin() const { return candidates.begin(); }
|
---|
| 49 |
|
---|
| 50 | iterator end() { return candidates.end(); }
|
---|
| 51 | const_iterator end() const { return candidates.end(); }
|
---|
[99d4584] | 52 | };
|
---|
| 53 |
|
---|
| 54 | } // namespace ResolvExpr
|
---|
| 55 |
|
---|
| 56 | // Local Variables: //
|
---|
| 57 | // tab-width: 4 //
|
---|
| 58 | // mode: c++ //
|
---|
| 59 | // compile-command: "make install" //
|
---|
| 60 | // End: //
|
---|