source: translator/ResolvExpr/Alternative.cc@ c8ffe20b

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since c8ffe20b was 51b73452, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: Alternative.cc,v 1.6 2005/08/29 20:14:15 rcbilson Exp $
5 *
6 */
7
8#include "Alternative.h"
9#include "SynTree/Type.h"
10#include "SynTree/Expression.h"
11#include "utility.h"
12
13namespace ResolvExpr {
14
15Alternative::Alternative()
16 : expr( 0 )
17{
18}
19
20Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost )
21 : cost( cost ), cvtCost( Cost::zero ), expr( expr ), env( env )
22{
23}
24
25Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost, const Cost &cvtCost )
26 : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env )
27{
28}
29
30Alternative::Alternative( const Alternative &other )
31{
32 initialize( other, *this );
33}
34
35Alternative &
36Alternative::operator=( const Alternative &other )
37{
38 if( &other == this ) return *this;
39 initialize( other, *this );
40 return *this;
41}
42
43void
44Alternative::initialize( const Alternative &src, Alternative &dest )
45{
46 dest.cost = src.cost;
47 dest.cvtCost = src.cvtCost;
48 dest.expr = maybeClone( src.expr );
49 dest.env = src.env;
50}
51
52Alternative::~Alternative()
53{
54 delete expr;
55}
56
57void
58Alternative::print( std::ostream &os, int indent ) const
59{
60 os << std::string( indent, ' ' ) << "Cost " << cost << ": ";
61 if( expr ) {
62 expr->print( os, indent );
63 os << "(types:" << std::endl;
64 printAll( expr->get_results(), os, indent + 4 );
65 os << ")" << std::endl;
66 } else {
67 os << "Null expression!" << std::endl;
68 }
69 os << std::string( indent, ' ' ) << "Environment: ";
70 env.print( os, indent+2 );
71 os << std::endl;
72}
73
74
75} // namespace ResolvExpr
Note: See TracBrowser for help on using the repository browser.