source: src/ResolvExpr/Candidate.cpp @ e37db112

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since e37db112 was 2595df1, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Now using string print to sort alternatives

  • Property mode set to 100644
File size: 1.5 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// 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>
19
20#include "AST/Print.hpp"
21
22namespace ResolvExpr {
23
24void print( std::ostream & os, const Candidate & cand, Indenter indent ) {
25        os << "Cost " << cand.cost << ": ";
26        if ( cand.expr ) {
27                ++indent;
28                ast::print( os, cand.expr, indent );
29                os << std::endl << indent-1 << "(types:" << std::endl;
30                os << indent;
31                ast::print( os, cand.expr->result, indent );
32                --indent;
33                os << std::endl << indent << ")" << std::endl;
34        } else {
35                os << "Null expression!" << std::endl;
36        } // if
37        os << indent << "Environment:";
38        ast::print( os, cand.env, indent+1 );
39        os << std::endl;
40}
41
42void print( std::ostream & os, const CandidateList & cands, Indenter indent ) {
43        std::vector<std::string> sorted;
44        sorted.reserve(cands.size());
45        for(const auto & c : cands) {
46                std::stringstream ss;
47                print( ss, *c, indent );
48                sorted.push_back(ss.str());
49        }
50
51        std::sort(sorted.begin(), sorted.end());
52
53        for ( const auto & s : sorted ) {
54                os << s << std::endl;
55        }
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.