source: src/SynTree/ArrayType.cc @ 0ce063b

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 0ce063b 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
RevLine 
[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//
[bb8ea30]7// ArrayType.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[c0aa336]11// Last Modified By : Peter A. Buhr
[615a096]12// Last Modified On : Fri Mar 17 09:40:30 2017
13// Update Count     : 13
[0dd3a2f]14//
[51b7345]15
[ea6332d]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;
[51b7345]24
25
[c0aa336]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 ) {
[615a096]28        base->set_lvalue( false );
[51b7345]29}
30
31ArrayType::ArrayType( const ArrayType &other )
[cf0941d]32                : Type( other ), base( maybeClone( other.base ) ), dimension( maybeClone( other.dimension ) ),
33                  isVarLen( other.isVarLen ), isStatic( other.isStatic ) {
[51b7345]34}
35
[0dd3a2f]36ArrayType::~ArrayType() {
37        delete base;
38        delete dimension;
[51b7345]39}
40
[50377a4]41void ArrayType::print( std::ostream &os, Indenter indent ) const {
[0dd3a2f]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
[cf0941d]56        if ( dimension ) {
[d58ebf3]57                os << " with dimension of ";
[bb8ea30]58                dimension->print( os, indent );
[cf0941d]59        } // if
[51b7345]60}
61
[0dd3a2f]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.