source: src/SynTree/TupleType.cc @ 6242335

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

Big push on designations and initialization: works with generic types, tuples, arrays, tests pass.
Refactor guard_value_impl.
Add list of declarations to TupleType?.

  • Property mode set to 100644
File size: 2.3 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// TupleType.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 : Wed Feb  1 17:10:58 2017
13// Update Count     : 3
14//
15
16#include "Declaration.h"
17#include "Initializer.h"
18#include "Type.h"
19#include "Common/utility.h"
20#include "Parser/LinkageSpec.h"
21
22TupleType::TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), types( types ) {
23        for ( Type * t : *this ) {
24                // 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
25                // they end up getting constructors, which end up being inserted causing problems. This happens because the object decls have to be visited so that
26                // 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
27                // 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
28                // object is visited, it is never constructed. Ultimately, a better solution might be either:
29                // a) to separate TupleType from its declarations, into TupleDecl and Tuple{Inst?}Type, ala StructDecl and StructInstType
30                // b) separate initializer nodes better, e.g. add a MaybeConstructed node that is replaced by genInit, rather than what currently exists in a bool
31                members.push_back( new ObjectDecl( "" , Type::StorageClasses(), LinkageSpec::Cforall, nullptr, t->clone(), new ListInit( {}, {}, false ) ) );
32        }
33}
34
35TupleType::TupleType( const TupleType& other ) : Type( other ) {
36        cloneAll( other.types, types );
37        cloneAll( other.members, members );
38}
39
40TupleType::~TupleType() {
41        deleteAll( types );
42        deleteAll( members );
43}
44
45void TupleType::print( std::ostream &os, int indent ) const {
46        Type::print( os, indent );
47        os << "tuple of types" << std::endl;
48        printAll( types, os, indent+2 );
49}
50
51// Local Variables: //
52// tab-width: 4 //
53// mode: c++ //
54// compile-command: "make install" //
55// End: //
Note: See TracBrowser for help on using the repository browser.