source: src/SynTree/TupleExpr.cc @ 3b58d91

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 3b58d91 was 3b58d91, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

add AST nodes TupleIndexExpr?, MemberTupleExpr?, MassAssignExpr?, and MultipleAssignExpr?, modify parser to produce nodes for field tuples, modify UntypedMemberExpr? to contain a list of members

  • Property mode set to 100644
File size: 3.0 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
20TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
21}
22
23TupleExpr::TupleExpr( const TupleExpr &other ) : Expression( other ) {
24        cloneAll( other.exprs, exprs );
25}
26
27TupleExpr::~TupleExpr() {
28        deleteAll( exprs );
29}
30
31void 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
37SolvedTupleExpr::SolvedTupleExpr( std::list<Expression *> &_exprs, Expression *_aname ) : Expression( _aname ) {
38        std::copy(_exprs.begin(), _exprs.end(), back_inserter(exprs));
39}
40
41SolvedTupleExpr::SolvedTupleExpr( const SolvedTupleExpr &other ) : Expression( other ) {
42        cloneAll( other.exprs, exprs );
43}
44
45void 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
51TupleIndexExpr::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
57TupleIndexExpr::TupleIndexExpr( const TupleIndexExpr &other ) : Expression( other ), tuple( other.tuple->clone() ), index( other.index ) {
58}
59
60TupleIndexExpr::~TupleIndexExpr() {
61        delete tuple;
62}
63
64void 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
71MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) {
72        cloneAll( member->get_results(), get_results() ); // xxx - ???
73}
74
75MemberTupleExpr::MemberTupleExpr( const MemberTupleExpr &other ) : Expression( other ), member( other.member->clone() ), aggregate( other.aggregate->clone() ) {
76}
77
78MemberTupleExpr::~MemberTupleExpr() {
79        delete member;
80        delete aggregate;
81}
82
83void 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: //
Note: See TracBrowser for help on using the repository browser.