source: src/ResolvExpr/Candidate.cpp @ 0b6089f

Last change on this file since 0b6089f was 9feb34b, checked in by Andrew Beach <ajbeach@…>, 20 months ago

Moved toString and toCString to a new header. Updated includes. cassert was somehow getting instances of toString before but that stopped working so I embedded the new smaller include.

  • Property mode set to 100644
File size: 1.5 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// Candidate.cpp --
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#include "Candidate.hpp"
17
18#include <iostream>
[9feb34b]19#include <sstream>
[99d4584]20
21#include "AST/Print.hpp"
22
23namespace ResolvExpr {
24
25void print( std::ostream & os, const Candidate & cand, Indenter indent ) {
26        os << "Cost " << cand.cost << ": ";
27        if ( cand.expr ) {
28                ++indent;
29                ast::print( os, cand.expr, indent );
30                os << std::endl << indent-1 << "(types:" << std::endl;
31                os << indent;
32                ast::print( os, cand.expr->result, indent );
33                --indent;
34                os << std::endl << indent << ")" << std::endl;
35        } else {
36                os << "Null expression!" << std::endl;
37        } // if
38        os << indent << "Environment:";
39        ast::print( os, cand.env, indent+1 );
40        os << std::endl;
41}
42
43void print( std::ostream & os, const CandidateList & cands, Indenter indent ) {
[2595df1]44        std::vector<std::string> sorted;
45        sorted.reserve(cands.size());
46        for(const auto & c : cands) {
[9feb34b]47                std::ostringstream ss;
[2595df1]48                print( ss, *c, indent );
49                sorted.push_back(ss.str());
50        }
51
52        std::sort(sorted.begin(), sorted.end());
53
54        for ( const auto & s : sorted ) {
55                os << s << std::endl;
[99d4584]56        }
57}
58
59} // namespace ResolvExpr
60
61// Local Variables: //
62// tab-width: 4 //
63// mode: c++ //
64// compile-command: "make install" //
[9feb34b]65// End: //
Note: See TracBrowser for help on using the repository browser.