[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 |
---|
[c0aa336] | 11 | // Last Modified By : Peter A. Buhr |
---|
[ddfd945] | 12 | // Last Modified On : Thu Mar 16 08:32:44 2017 |
---|
| 13 | // Update Count : 22 |
---|
[0dd3a2f] | 14 | // |
---|
| 15 | |
---|
[51b7345] | 16 | #include "SynTree.h" |
---|
| 17 | #include "Visitor.h" |
---|
| 18 | #include "Type.h" |
---|
| 19 | #include "Declaration.h" |
---|
[c0aa336] | 20 | #include "Attribute.h" |
---|
[d3b7937] | 21 | #include "Common/utility.h" |
---|
[51b7345] | 22 | |
---|
[c0aa336] | 23 | using namespace std; |
---|
| 24 | |
---|
[17cd4eb] | 25 | const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = { |
---|
[a08ba92] | 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", |
---|
[17cd4eb] | 47 | }; |
---|
[51b7345] | 48 | |
---|
[c0aa336] | 49 | Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {} |
---|
[51b7345] | 50 | |
---|
[17cd4eb] | 51 | Type::Type( const Type &other ) : tq( other.tq ) { |
---|
[a08ba92] | 52 | cloneAll( other.forall, forall ); |
---|
[c0aa336] | 53 | cloneAll( other.attributes, attributes ); |
---|
[51b7345] | 54 | } |
---|
| 55 | |
---|
[17cd4eb] | 56 | Type::~Type() { |
---|
[a08ba92] | 57 | deleteAll( forall ); |
---|
[c0aa336] | 58 | deleteAll( attributes ); |
---|
[51b7345] | 59 | } |
---|
| 60 | |
---|
[68fe077a] | 61 | // These must remain in the same order as the corresponding bit fields. |
---|
[ddfd945] | 62 | const char * Type::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn" }; |
---|
[68fe077a] | 63 | const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" }; |
---|
[6e8bd43] | 64 | const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; |
---|
[0dd3a2f] | 65 | |
---|
[f1b1e4c] | 66 | void Type::print( std::ostream &os, int indent ) const { |
---|
| 67 | if ( ! forall.empty() ) { |
---|
| 68 | os << "forall" << std::endl; |
---|
| 69 | printAll( forall, os, indent + 4 ); |
---|
| 70 | os << std::string( indent+2, ' ' ); |
---|
| 71 | } // if |
---|
[c0aa336] | 72 | |
---|
| 73 | if ( ! attributes.empty() ) { |
---|
| 74 | os << endl << string( indent+2, ' ' ) << "with attributes" << endl; |
---|
| 75 | printAll( attributes, os, indent+4 ); |
---|
| 76 | } // if |
---|
| 77 | |
---|
[f1b1e4c] | 78 | tq.print( os, indent ); |
---|
| 79 | } |
---|
| 80 | |
---|
[3906301] | 81 | std::ostream & operator<<( std::ostream & out, const Type * type ) { |
---|
[8bf784a] | 82 | if ( type ) { |
---|
| 83 | type->print( out ); |
---|
| 84 | } else { |
---|
| 85 | out << "nullptr"; |
---|
[c0aa336] | 86 | } // if |
---|
[baf7fee] | 87 | return out; |
---|
| 88 | } |
---|
| 89 | |
---|
[0dd3a2f] | 90 | // Local Variables: // |
---|
| 91 | // tab-width: 4 // |
---|
| 92 | // mode: c++ // |
---|
| 93 | // compile-command: "make install" // |
---|
| 94 | // End: // |
---|