source: src/SynTree/ArrayType.cc @ 5510027

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumwith_gc
Last change on this file since 5510027 was 50377a4, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Refactor tree print code to use Indenter

  • Property mode set to 100644
File size: 1.8 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// ArrayType.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 : Fri Mar 17 09:40:30 2017
13// Update Count     : 13
14//
15
16#include <list>              // for list
17#include <ostream>           // for operator<<, ostream
18
19#include "Common/utility.h"  // for maybeClone
20#include "Expression.h"      // for Expression
21#include "Type.h"            // for ArrayType, Type, Type::Qualifiers
22
23class Attribute;
24
25
26ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes )
27        : Type( tq, attributes ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic ) {
28        base->set_lvalue( false );
29}
30
31ArrayType::ArrayType( const ArrayType &other )
32                : Type( other ), base( maybeClone( other.base ) ), dimension( maybeClone( other.dimension ) ),
33                  isVarLen( other.isVarLen ), isStatic( other.isStatic ) {
34}
35
36ArrayType::~ArrayType() {
37        delete base;
38        delete dimension;
39}
40
41void ArrayType::print( std::ostream &os, Indenter indent ) const {
42        Type::print( os, indent );
43        if ( isStatic ) {
44                os << "static ";
45        } // if
46        if ( isVarLen ) {
47                os << "variable length array of ";
48        } else if ( dimension ) {
49                os << "array of ";
50        } else {
51                os << "open array of ";
52        } // if
53        if ( base ) {
54                base->print( os, indent );
55        } // if
56        if ( dimension ) {
57                os << " with dimension of ";
58                dimension->print( os, indent );
59        } // if
60}
61
62// Local Variables: //
63// tab-width: 4 //
64// mode: c++ //
65// compile-command: "make install" //
66// End: //
Note: See TracBrowser for help on using the repository browser.