source: translator/ResolvExpr/Alternative.cc@ 643a2e1

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 643a2e1 was d9a0e76, checked in by Peter A. Buhr <pabuhr@…>, 11 years ago

remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#include "Alternative.h"
2#include "SynTree/Type.h"
3#include "SynTree/Expression.h"
4#include "utility.h"
5
6namespace ResolvExpr {
7 Alternative::Alternative() : expr( 0 ) {}
8
9 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost )
10 : cost( cost ), cvtCost( Cost::zero ), expr( expr ), env( env ) {}
11
12 Alternative::Alternative( Expression *expr, const TypeEnvironment &env, const Cost& cost, const Cost &cvtCost )
13 : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ) {}
14
15 Alternative::Alternative( const Alternative &other ) {
16 initialize( other, *this );
17 }
18
19 Alternative &Alternative::operator=( const Alternative &other ) {
20 if ( &other == this ) return *this;
21 initialize( other, *this );
22 return *this;
23 }
24
25 void Alternative::initialize( const Alternative &src, Alternative &dest ) {
26 dest.cost = src.cost;
27 dest.cvtCost = src.cvtCost;
28 dest.expr = maybeClone( src.expr );
29 dest.env = src.env;
30 }
31
32 Alternative::~Alternative() {
33 delete expr;
34 }
35
36 void Alternative::print( std::ostream &os, int indent ) const {
37 os << std::string( indent, ' ' ) << "Cost " << cost << ": ";
38 if ( expr ) {
39 expr->print( os, indent );
40 os << "(types:" << std::endl;
41 printAll( expr->get_results(), os, indent + 4 );
42 os << ")" << std::endl;
43 } else {
44 os << "Null expression!" << std::endl;
45 }
46 os << std::string( indent, ' ' ) << "Environment: ";
47 env.print( os, indent+2 );
48 os << std::endl;
49 }
50} // namespace ResolvExpr
Note: See TracBrowser for help on using the repository browser.