source: src/ResolvExpr/CandidatePrinter.cpp @ 065de93

Last change on this file since 065de93 was c92bdcc, checked in by Andrew Beach <ajbeach@…>, 6 months ago

Updated the rest of the names in src/ (except for the generated files).

  • Property mode set to 100644
File size: 1.6 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// CandidatePrinter.cpp -- Print expression canditates.
8//
9// Author           : Andrew Beach
10// Created On       : Tue Nov  9  9:54:00 2021
11// Last Modified By : Andrew Beach
12// Last Modified On : Wed Mar 16 13:56:00 2022
13// Update Count     : 1
14//
15
16#include "CandidatePrinter.hpp"
17
18#include <iostream>
19
20#include "AST/Expr.hpp"
21#include "AST/Pass.hpp"
22#include "AST/Print.hpp"
23#include "AST/Stmt.hpp"
24#include "AST/TranslationUnit.hpp"
25#include "ResolvExpr/CandidateFinder.hpp"
26#include "ResolvExpr/Resolver.hpp"
27
28namespace ResolvExpr {
29
30namespace {
31
32class CandidatePrintCore : public ast::WithSymbolTable,
33                public ast::WithConstTranslationUnit {
34        std::ostream & os;
35public:
36        CandidatePrintCore( std::ostream & os ) : os( os ) {}
37
38        void postvisit( const ast::ExprStmt * stmt ) {
39                ast::TypeEnvironment env;
40                CandidateFinder finder( { symtab, transUnit().global }, env );
41                finder.find( stmt->expr, ResolveMode::withAdjustment() );
42                int count = 1;
43                os << "There are " << finder.candidates.size() << " candidates\n";
44                for ( const std::shared_ptr<Candidate> & cand : finder ) {
45                        os << "Candidate " << count++ << " ==============\n";
46                        ast::print( os, cand->expr->result.get() );
47                        os << std::endl;
48                }
49        }
50};
51
52} // namespace
53
54void printCandidates( ast::TranslationUnit & transUnit ) {
55        ast::Pass<CandidatePrintCore>::run( transUnit, std::cout );
56}
57
58} // namespace ResolvExpr
59
60// Local Variables: //
61// tab-width: 4 //
62// mode: c++ //
63// compile-command: "make install" //
64// End: //
Note: See TracBrowser for help on using the repository browser.