source: src/SynTree/TupleExpr.cc @ 6eb8948

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 6eb8948 was 6eb8948, checked in by Rob Schluntz <rschlunt@…>, 6 years ago

make TupleAssignment? generate temporaries, add StmtExpr? for GCC statement expressions, expand tuple assignment expressions, collapse SolvedTupleExpr?, MassAssignExpr?, and MultipleAssignExpr? into TupleAssignExpr?

  • Property mode set to 100644
File size: 3.5 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// 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#include "Declaration.h"
20
21TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
22}
23
24TupleExpr::TupleExpr( const TupleExpr &other ) : Expression( other ) {
25        cloneAll( other.exprs, exprs );
26}
27
28TupleExpr::~TupleExpr() {
29        deleteAll( exprs );
30}
31
32void TupleExpr::print( std::ostream &os, int indent ) const {
33        os << std::string( indent, ' ' ) << "Tuple:" << std::endl;
34        printAll( exprs, os, indent+2 );
35        Expression::print( os, indent );
36}
37
38TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) {
39        // TupleType * type = safe_dynamic_cast< TypeType * >( tuple->get_ )
40        assert( tuple->get_results().size() >= index );
41        add_result( *std::next( tuple->get_results().begin(), index ) );
42}
43
44TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) {
45}
46
47TupleIndexExpr::~TupleIndexExpr() {
48        delete tuple;
49}
50
51void TupleIndexExpr::print( std::ostream &os, int indent ) const {
52        os << std::string( indent, ' ' ) << "Tuple Index Expression, with tuple:" << std::endl;
53        tuple->print( os, indent+2 );
54        os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl;
55        Expression::print( os, indent );
56}
57
58MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
59        cloneAll( member->get_results(), get_results() ); // xxx - ???
60}
61
62MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
63}
64
65MemberTupleExpr::~MemberTupleExpr() {
66        delete member;
67        delete aggregate;
68}
69
70void MemberTupleExpr::print( std::ostream &os, int indent ) const {
71        os << std::string( indent, ' ' ) << "Member Tuple Expression, with aggregate:" << std::endl;
72        aggregate->print( os, indent+2 );
73        os << std::string( indent+2, ' ' ) << "with member: " << std::endl;
74        member->print( os, indent+2 );
75        Expression::print( os, indent );
76}
77
78
79TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) {
80        for ( Expression * expr : assigns ) {
81                cloneAll( expr->get_results(), get_results() );
82        }
83}
84
85TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ), tempDecls( other.tempDecls ) /* temporary */ {
86        cloneAll( other.assigns, assigns );
87        // xxx - clone needs to go into assigns and replace tempDecls
88}
89
90TupleAssignExpr::~TupleAssignExpr() {
91        deleteAll( assigns );
92        // deleteAll( tempDecls );
93}
94
95void TupleAssignExpr::print( std::ostream &os, int indent ) const {
96        os << std::string( indent, ' ' ) << "Tuple Assignment Expression, with temporaries:" << std::endl;
97        printAll( tempDecls, os, indent+4 );
98        os << std::string( indent+2, ' ' ) << "with assignments: " << std::endl;
99        printAll( assigns, os, indent+4 );
100        Expression::print( os, indent );
101}
102
103
104
105// Local Variables: //
106// tab-width: 4 //
107// mode: c++ //
108// compile-command: "make install" //
109// End: //
Note: See TracBrowser for help on using the repository browser.