source: src/SynTree/Type.cc @ 68195a6

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 68195a6 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: 2.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//
[f1b1e4c]7// Type.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
[de9285f]11// Last Modified By : Peter A. Buhr
[201aeb9]12// Last Modified On : Mon Sep 25 15:16:32 2017
13// Update Count     : 38
[0dd3a2f]14//
[51b7345]15#include "Type.h"
[0dd3a2f]16
[ea6332d]17#include "Attribute.h"               // for Attribute
18#include "Common/utility.h"          // for cloneAll, deleteAll, printAll
19#include "InitTweak/InitTweak.h"     // for getPointerBase
20#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
[be9288a]21#include "SynTree/Declaration.h"     // for TypeDecl
[51b7345]22
[c0aa336]23using namespace std;
24
[17cd4eb]25const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
[a08ba92]26        "_Bool",
27        "char",
[de9285f]28        "signed char",
[a08ba92]29        "unsigned char",
[de9285f]30        "signed short int",
31        "unsigned short int",
32        "signed int",
[a08ba92]33        "unsigned int",
[de9285f]34        "signed long int",
35        "unsigned long int",
36        "signed long long int",
37        "unsigned long long int",
[a08ba92]38        "float",
39        "double",
40        "long double",
41        "float _Complex",
42        "double _Complex",
43        "long double _Complex",
44        "float _Imaginary",
45        "double _Imaginary",
46        "long double _Imaginary",
[201aeb9]47        "__int128",
48        "unsigned __int128",
[17cd4eb]49};
[51b7345]50
[c0aa336]51Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
[51b7345]52
[64ac636]53Type::Type( const Type &other ) : BaseSyntaxNode( other ), tq( other.tq ) {
[a08ba92]54        cloneAll( other.forall, forall );
[c0aa336]55        cloneAll( other.attributes, attributes );
[51b7345]56}
57
[17cd4eb]58Type::~Type() {
[a08ba92]59        deleteAll( forall );
[c0aa336]60        deleteAll( attributes );
[51b7345]61}
62
[68fe077a]63// These must remain in the same order as the corresponding bit fields.
[615a096]64const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" };
65const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
66const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
[0dd3a2f]67
[0698aa1]68Type * Type::stripDeclarator() {
[de9285f]69        Type * type, * at;
70        for ( type = this; (at = InitTweak::getPointerBase( type )); type = at );
[6f95000]71        return type;
72}
[0dd3a2f]73
[0698aa1]74Type * Type::stripReferences() {
[de9285f]75        Type * type;
76        ReferenceType * ref;
[50377a4]77        for ( type = this; (ref = dynamic_cast<ReferenceType *>( type )); type = ref->base );
[0698aa1]78        return type;
79}
80
[e6cee92]81int Type::referenceDepth() const { return 0; }
82
[50377a4]83void Type::print( std::ostream &os, Indenter indent ) const {
[f1b1e4c]84        if ( ! forall.empty() ) {
85                os << "forall" << std::endl;
[50377a4]86                printAll( forall, os, indent+1 );
87                os << ++indent;
[f1b1e4c]88        } // if
[c0aa336]89
90        if ( ! attributes.empty() ) {
[50377a4]91                os << "with attributes" << endl;
92                printAll( attributes, os, indent+1 );
[c0aa336]93        } // if
[64ac636]94
[d6d747d]95        tq.print( os );
[f1b1e4c]96}
97
[65cdc1e]98// Empty Variable declarations:
99const Type::FuncSpecifiers noFuncSpecifiers;
100const Type::StorageClasses noStorageClasses;
101const Type::Qualifiers noQualifiers;
102
[0dd3a2f]103// Local Variables: //
104// tab-width: 4 //
105// mode: c++ //
106// compile-command: "make install" //
107// End: //
Note: See TracBrowser for help on using the repository browser.