[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 | // |
---|
[6eb8948] | 7 | // TupleType.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 |
---|
[07de76b] | 12 | // Last Modified On : Fri Dec 13 23:44:38 2019 |
---|
| 13 | // Update Count : 4 |
---|
[0dd3a2f] | 14 | // |
---|
[51b7345] | 15 | |
---|
[ea6332d] | 16 | #include <list> // for list |
---|
| 17 | #include <ostream> // for operator<<, ostream, basic_ostream |
---|
| 18 | |
---|
| 19 | #include "Common/utility.h" // for cloneAll, deleteAll, printAll |
---|
| 20 | #include "Declaration.h" // for Declaration, ObjectDecl |
---|
| 21 | #include "Initializer.h" // for ListInit |
---|
[07de76b] | 22 | #include "LinkageSpec.h" // for Cforall |
---|
[ea6332d] | 23 | #include "Type.h" // for TupleType, Type, Type::Qualifiers |
---|
| 24 | |
---|
| 25 | class Attribute; |
---|
[51b7345] | 26 | |
---|
[c0aa336] | 27 | TupleType::TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), types( types ) { |
---|
[62423350] | 28 | for ( Type * t : *this ) { |
---|
| 29 | // xxx - this is very awkward. TupleTypes should contain objects so that members can be named, but if they don't have an initializer node then |
---|
| 30 | // they end up getting constructors, which end up being inserted causing problems. This happens because the object decls have to be visited so that |
---|
| 31 | // their types are kept in sync with the types list here. Ultimately, the types list here should be eliminated and perhaps replaced with a list-view |
---|
| 32 | // of the object types list, but I digress. The temporary solution here is to make a ListInit with maybeConstructed = false, that way even when the |
---|
| 33 | // object is visited, it is never constructed. Ultimately, a better solution might be either: |
---|
| 34 | // a) to separate TupleType from its declarations, into TupleDecl and Tuple{Inst?}Type, ala StructDecl and StructInstType |
---|
| 35 | // b) separate initializer nodes better, e.g. add a MaybeConstructed node that is replaced by genInit, rather than what currently exists in a bool |
---|
| 36 | members.push_back( new ObjectDecl( "" , Type::StorageClasses(), LinkageSpec::Cforall, nullptr, t->clone(), new ListInit( {}, {}, false ) ) ); |
---|
| 37 | } |
---|
[51b7345] | 38 | } |
---|
| 39 | |
---|
[0dd3a2f] | 40 | TupleType::TupleType( const TupleType& other ) : Type( other ) { |
---|
| 41 | cloneAll( other.types, types ); |
---|
[62423350] | 42 | cloneAll( other.members, members ); |
---|
[51b7345] | 43 | } |
---|
| 44 | |
---|
[0dd3a2f] | 45 | TupleType::~TupleType() { |
---|
| 46 | deleteAll( types ); |
---|
[62423350] | 47 | deleteAll( members ); |
---|
[51b7345] | 48 | } |
---|
| 49 | |
---|
[50377a4] | 50 | void TupleType::print( std::ostream &os, Indenter indent ) const { |
---|
[0dd3a2f] | 51 | Type::print( os, indent ); |
---|
| 52 | os << "tuple of types" << std::endl; |
---|
[50377a4] | 53 | printAll( types, os, indent+1 ); |
---|
[51b7345] | 54 | } |
---|
| 55 | |
---|
[0dd3a2f] | 56 | // Local Variables: // |
---|
| 57 | // tab-width: 4 // |
---|
| 58 | // mode: c++ // |
---|
| 59 | // compile-command: "make install" // |
---|
| 60 | // End: // |
---|