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 | // TupleExpr.cc --
|
---|
8 | //
|
---|
9 | // Author : Richard C. Bilson
|
---|
10 | // Created On : Mon May 18 07:44:20 2015
|
---|
11 | // Last Modified By : Peter A. Buhr
|
---|
12 | // Last Modified On : Mon May 18 10:59:19 2015
|
---|
13 | // Update Count : 1
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include "Expression.h"
|
---|
17 | #include "Common/utility.h"
|
---|
18 | #include "Type.h"
|
---|
19 |
|
---|
20 | TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
|
---|
21 | }
|
---|
22 |
|
---|
23 | TupleExpr::TupleExpr( const TupleExpr &other ) : Expression( other ) {
|
---|
24 | cloneAll( other.exprs, exprs );
|
---|
25 | }
|
---|
26 |
|
---|
27 | TupleExpr::~TupleExpr() {
|
---|
28 | deleteAll( exprs );
|
---|
29 | }
|
---|
30 |
|
---|
31 | void TupleExpr::print( std::ostream &os, int indent ) const {
|
---|
32 | os << std::string( indent, ' ' ) << "Tuple:" << std::endl;
|
---|
33 | printAll( exprs, os, indent+2 );
|
---|
34 | Expression::print( os, indent );
|
---|
35 | }
|
---|
36 |
|
---|
37 | SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) {
|
---|
38 | std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs));
|
---|
39 | }
|
---|
40 |
|
---|
41 | SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) {
|
---|
42 | cloneAll( other.exprs, exprs );
|
---|
43 | }
|
---|
44 |
|
---|
45 | void SolvedTupleExpr::print( std::ostream &os, int indent ) const {
|
---|
46 | os << std::string( indent, ' ' ) << "Solved Tuple:" << std::endl;
|
---|
47 | printAll( exprs, os, indent+2 );
|
---|
48 | Expression::print( os, indent );
|
---|
49 | }
|
---|
50 |
|
---|
51 | TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) {
|
---|
52 | // TupleType * type = safe_dynamic_cast< TypeType * >( tuple->get_ )
|
---|
53 | assert( tuple->get_results().size() >= index );
|
---|
54 | add_result( *std::next( tuple->get_results().begin(), index ) );
|
---|
55 | }
|
---|
56 |
|
---|
57 | TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) {
|
---|
58 | }
|
---|
59 |
|
---|
60 | TupleIndexExpr::~TupleIndexExpr() {
|
---|
61 | delete tuple;
|
---|
62 | }
|
---|
63 |
|
---|
64 | void TupleIndexExpr::print( std::ostream &os, int indent ) const {
|
---|
65 | os << std::string( indent, ' ' ) << "Tuple Index Expression, with tuple:" << std::endl;
|
---|
66 | tuple->print( os, indent+2 );
|
---|
67 | os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl;
|
---|
68 | Expression::print( os, indent );
|
---|
69 | }
|
---|
70 |
|
---|
71 | MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
|
---|
72 | cloneAll( member->get_results(), get_results() ); // xxx - ???
|
---|
73 | }
|
---|
74 |
|
---|
75 | MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
|
---|
76 | }
|
---|
77 |
|
---|
78 | MemberTupleExpr::~MemberTupleExpr() {
|
---|
79 | delete member;
|
---|
80 | delete aggregate;
|
---|
81 | }
|
---|
82 |
|
---|
83 | void MemberTupleExpr::print( std::ostream &os, int indent ) const {
|
---|
84 | os << std::string( indent, ' ' ) << "Member Tuple Expression, with aggregate:" << std::endl;
|
---|
85 | aggregate->print( os, indent+2 );
|
---|
86 | os << std::string( indent+2, ' ' ) << "with member: " << std::endl;
|
---|
87 | member->print( os, indent+2 );
|
---|
88 | Expression::print( os, indent );
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | // Local Variables: //
|
---|
93 | // tab-width: 4 //
|
---|
94 | // mode: c++ //
|
---|
95 | // compile-command: "make install" //
|
---|
96 | // End: //
|
---|