[0dd3a2f] | 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 | //
|
---|
[3b58d91] | 7 | // TupleExpr.cc --
|
---|
[0dd3a2f] | 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 | //
|
---|
[51b73452] | 15 |
|
---|
| 16 | #include "Expression.h"
|
---|
[d3b7937] | 17 | #include "Common/utility.h"
|
---|
[3b58d91] | 18 | #include "Type.h"
|
---|
[51b73452] | 19 |
|
---|
[0dd3a2f] | 20 | TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
|
---|
[51b73452] | 21 | }
|
---|
| 22 |
|
---|
[0dd3a2f] | 23 | TupleExpr::TupleExpr( const TupleExpr &other ) : Expression( other ) {
|
---|
| 24 | cloneAll( other.exprs, exprs );
|
---|
[51b73452] | 25 | }
|
---|
| 26 |
|
---|
[0dd3a2f] | 27 | TupleExpr::~TupleExpr() {
|
---|
| 28 | deleteAll( exprs );
|
---|
[51b73452] | 29 | }
|
---|
| 30 |
|
---|
[0dd3a2f] | 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 );
|
---|
[51b73452] | 35 | }
|
---|
| 36 |
|
---|
[0dd3a2f] | 37 | SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) {
|
---|
| 38 | std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs));
|
---|
[51b73452] | 39 | }
|
---|
| 40 |
|
---|
[0dd3a2f] | 41 | SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) {
|
---|
| 42 | cloneAll( other.exprs, exprs );
|
---|
[51b73452] | 43 | }
|
---|
| 44 |
|
---|
[0dd3a2f] | 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 );
|
---|
[51b73452] | 49 | }
|
---|
| 50 |
|
---|
[3b58d91] | 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 |
|
---|
[0dd3a2f] | 92 | // Local Variables: //
|
---|
| 93 | // tab-width: 4 //
|
---|
| 94 | // mode: c++ //
|
---|
| 95 | // compile-command: "make install" //
|
---|
| 96 | // End: //
|
---|