source: src/SynTree/Type.cc @ 027c496

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 027c496 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
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// Type.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 : Mon Sep 25 15:16:32 2017
13// Update Count     : 38
14//
15#include "Type.h"
16
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
21#include "SynTree/Declaration.h"     // for TypeDecl
22
23using namespace std;
24
25const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
26        "_Bool",
27        "char",
28        "signed char",
29        "unsigned char",
30        "signed short int",
31        "unsigned short int",
32        "signed int",
33        "unsigned int",
34        "signed long int",
35        "unsigned long int",
36        "signed long long int",
37        "unsigned long long int",
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",
47        "__int128",
48        "unsigned __int128",
49};
50
51Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
52
53Type::Type( const Type &other ) : BaseSyntaxNode( other ), tq( other.tq ) {
54        cloneAll( other.forall, forall );
55        cloneAll( other.attributes, attributes );
56}
57
58Type::~Type() {
59        deleteAll( forall );
60        deleteAll( attributes );
61}
62
63// These must remain in the same order as the corresponding bit fields.
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" };
67
68Type * Type::stripDeclarator() {
69        Type * type, * at;
70        for ( type = this; (at = InitTweak::getPointerBase( type )); type = at );
71        return type;
72}
73
74Type * Type::stripReferences() {
75        Type * type;
76        ReferenceType * ref;
77        for ( type = this; (ref = dynamic_cast<ReferenceType *>( type )); type = ref->base );
78        return type;
79}
80
81int Type::referenceDepth() const { return 0; }
82
83void Type::print( std::ostream &os, Indenter indent ) const {
84        if ( ! forall.empty() ) {
85                os << "forall" << std::endl;
86                printAll( forall, os, indent+1 );
87                os << ++indent;
88        } // if
89
90        if ( ! attributes.empty() ) {
91                os << "with attributes" << endl;
92                printAll( attributes, os, indent+1 );
93        } // if
94
95        tq.print( os );
96}
97
98// Empty Variable declarations:
99const Type::FuncSpecifiers noFuncSpecifiers;
100const Type::StorageClasses noStorageClasses;
101const Type::Qualifiers noQualifiers;
102
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.