source: src/SynTree/Type.cc @ ea6332d

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

Big header cleaning pass - commit 3

  • Property mode set to 100644
File size: 2.7 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 : Andrew Beach
12// Last Modified On : Wed Aug  2 11:11:00 2017
13// Update Count     : 29
14//
15
16#include "Attribute.h"               // for Attribute
17#include "Common/utility.h"          // for cloneAll, deleteAll, printAll
18#include "InitTweak/InitTweak.h"     // for getPointerBase
19#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
20#include "Type.h"
21
22using namespace std;
23
24const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
25        "_Bool",
26        "char",
27        "char",
28        "unsigned char",
29        "short",
30        "short unsigned",
31        "int",
32        "unsigned int",
33        "long int",
34        "long unsigned int",
35        "long long int",
36        "long long unsigned int",
37        "float",
38        "double",
39        "long double",
40        "float _Complex",
41        "double _Complex",
42        "long double _Complex",
43        "float _Imaginary",
44        "double _Imaginary",
45        "long double _Imaginary",
46};
47
48Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
49
50Type::Type( const Type &other ) : BaseSyntaxNode( other ), tq( other.tq ) {
51        cloneAll( other.forall, forall );
52        cloneAll( other.attributes, attributes );
53}
54
55Type::~Type() {
56        deleteAll( forall );
57        deleteAll( attributes );
58}
59
60// These must remain in the same order as the corresponding bit fields.
61const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" };
62const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
63const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
64
65Type *Type::stripDeclarator() {
66        Type * type = this;
67        while ( Type * at = InitTweak::getPointerBase( type ) ) {
68                type = at;
69        }
70        return type;
71}
72
73void Type::print( std::ostream &os, int indent ) const {
74        if ( ! forall.empty() ) {
75                os << "forall" << std::endl;
76                printAll( forall, os, indent + 4 );
77                os << std::string( indent+2, ' ' );
78        } // if
79
80        if ( ! attributes.empty() ) {
81                os << endl << string( indent+2, ' ' ) << "with attributes" << endl;
82                printAll( attributes, os, indent+4 );
83        } // if
84
85        tq.print( os );
86}
87
88// Empty Variable declarations:
89const Type::FuncSpecifiers noFuncSpecifiers;
90const Type::StorageClasses noStorageClasses;
91const Type::Qualifiers noQualifiers;
92
93std::ostream & operator<<( std::ostream & out, const Type * type ) {
94        if ( type ) {
95                type->print( out );
96        } else {
97                out << "nullptr";
98        } // if
99        return out;
100}
101
102// Local Variables: //
103// tab-width: 4 //
104// mode: c++ //
105// compile-command: "make install" //
106// End: //
Note: See TracBrowser for help on using the repository browser.