source: src/SynTree/Type.cc @ bf4ac09

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 bf4ac09 was bf4ac09, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

change type of Qualifiers to bit fields

  • Property mode set to 100644
File size: 2.0 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 : Wed Mar 15 21:22:16 2017
13// Update Count     : 15
14//
15
16#include "SynTree.h"
17#include "Visitor.h"
18#include "Type.h"
19#include "Declaration.h"
20#include "Attribute.h"
21#include "Common/utility.h"
22
23using namespace std;
24
25const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
26        "_Bool",
27        "char",
28        "char",
29        "unsigned char",
30        "short",
31        "short unsigned",
32        "int",
33        "unsigned int",
34        "long int",
35        "long unsigned int",
36        "long long int",
37        "long long unsigned 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};
48
49Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
50
51Type::Type( const Type &other ) : tq( other.tq ) {
52        cloneAll( other.forall, forall );
53        cloneAll( other.attributes, attributes );
54}
55
56Type::~Type() {
57        deleteAll( forall );
58        deleteAll( attributes );
59}
60
61const char * Type::QualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" };
62
63void Type::print( std::ostream &os, int indent ) const {
64        if ( ! forall.empty() ) {
65                os << "forall" << std::endl;
66                printAll( forall, os, indent + 4 );
67                os << std::string( indent+2, ' ' );
68        } // if
69
70        if ( ! attributes.empty() ) {
71                os << endl << string( indent+2, ' ' ) << "with attributes" << endl;
72                printAll( attributes, os, indent+4 );
73        } // if
74       
75        tq.print( os, indent );
76}
77
78std::ostream & operator<<( std::ostream & out, const Type * type ) {
79        if ( type ) {
80                type->print( out );
81        } else {
82                out << "nullptr";
83        } // if
84        return out;
85}
86
87// Local Variables: //
88// tab-width: 4 //
89// mode: c++ //
90// compile-command: "make install" //
91// End: //
Note: See TracBrowser for help on using the repository browser.