source: src/ResolvExpr/Alternative.cc@ 7e4b44db

new-env with_gc
Last change on this file since 7e4b44db was 68f9c43, checked in by Aaron Moss <a3moss@…>, 8 years ago

First pass at delete removal

  • Property mode set to 100644
File size: 2.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// Alternative.cc --
8//
9// Author : Richard C. Bilson
10// Created On : Sat May 16 23:44:23 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Sat May 16 23:54:23 2015
13// Update Count : 2
14//
15
16#include "Alternative.h"
17
18#include <ostream> // for operator<<, ostream, basic_o...
19#include <string> // for operator<<, char_traits, string
20#include <utility> // for move
21
22#include "Common/utility.h" // for maybeClone
23#include "ResolvExpr/Cost.h" // for Cost, Cost::zero, operator<<
24#include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment
25#include "SynTree/Expression.h" // for Expression
26#include "SynTree/Type.h" // for Type
27
28namespace ResolvExpr {
29 Alternative::Alternative() : cost( Cost::zero ), cvtCost( Cost::zero ), expr( 0 ) {}
30
31 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost )
32 : cost( cost ), cvtCost( Cost::zero ), expr( expr ), env( env ) {}
33
34 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost, const Cost &cvtCost )
35 : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ) {}
36
37 void Alternative::print( std::ostream &os, Indenter indent ) const {
38 os << "Cost " << cost << ": ";
39 if ( expr ) {
40 expr->print( os, indent+1 );
41 os << std::endl << indent << "(types:" << std::endl;
42 os << indent+1;
43 expr->result->print( os, indent+1 );
44 os << std::endl << indent << ")" << std::endl;
45 } else {
46 os << "Null expression!" << std::endl;
47 } // if
48 os << indent << "Environment: ";
49 env.print( os, indent+1 );
50 os << std::endl;
51 }
52
53 void splice( AltList& dst, AltList& src ) {
54 dst.reserve( dst.size() + src.size() );
55 for ( Alternative& alt : src ) {
56 dst.push_back( std::move(alt) );
57 }
58 src.clear();
59 }
60
61 void spliceBegin( AltList& dst, AltList& src ) {
62 splice( src, dst );
63 dst.swap( src );
64 }
65
66} // namespace ResolvExpr
67
68// Local Variables: //
69// tab-width: 4 //
70// mode: c++ //
71// compile-command: "make install" //
72// End: //
Note: See TracBrowser for help on using the repository browser.