[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 | // |
---|
| 7 | // BasicType.cc -- |
---|
| 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[c0aa336] | 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Wed Feb 1 17:12:15 2017 |
---|
| 13 | // Update Count : 8 |
---|
[0dd3a2f] | 14 | // |
---|
[51b7345] | 15 | |
---|
[0dd3a2f] | 16 | #include <cassert> |
---|
[51b7345] | 17 | #include "Type.h" |
---|
| 18 | |
---|
[c0aa336] | 19 | BasicType::BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), kind( bt ) {} |
---|
[51b7345] | 20 | |
---|
[17cd4eb] | 21 | void BasicType::print( std::ostream &os, int indent ) const { |
---|
[0dd3a2f] | 22 | static const char *kindNames[] = { |
---|
| 23 | "_Bool", "char", "signed char", "unsigned char", "short signed int", "short unsigned int", |
---|
| 24 | "signed int", "unsigned int", "long signed int", "long unsigned int", "long long signed int", |
---|
| 25 | "long long unsigned int", "float", "double", "long double", "float _Complex", "double _Complex", |
---|
| 26 | "long double _Complex", "float _Imaginary", "double _Imaginary", "long double _Imaginary" |
---|
| 27 | }; |
---|
[51b7345] | 28 | |
---|
[0dd3a2f] | 29 | Type::print( os, indent ); |
---|
[d58ebf3] | 30 | os << kindNames[ kind ]; |
---|
[51b7345] | 31 | } |
---|
| 32 | |
---|
[17cd4eb] | 33 | bool BasicType::isInteger() const { |
---|
[0dd3a2f] | 34 | switch ( kind ) { |
---|
| 35 | case Bool: |
---|
| 36 | case Char: |
---|
| 37 | case SignedChar: |
---|
| 38 | case UnsignedChar: |
---|
| 39 | case ShortSignedInt: |
---|
| 40 | case ShortUnsignedInt: |
---|
| 41 | case SignedInt: |
---|
| 42 | case UnsignedInt: |
---|
| 43 | case LongSignedInt: |
---|
| 44 | case LongUnsignedInt: |
---|
| 45 | case LongLongSignedInt: |
---|
| 46 | case LongLongUnsignedInt: |
---|
| 47 | return true; |
---|
| 48 | case Float: |
---|
| 49 | case Double: |
---|
| 50 | case LongDouble: |
---|
| 51 | case FloatComplex: |
---|
| 52 | case DoubleComplex: |
---|
| 53 | case LongDoubleComplex: |
---|
| 54 | case FloatImaginary: |
---|
| 55 | case DoubleImaginary: |
---|
| 56 | case LongDoubleImaginary: |
---|
| 57 | return false; |
---|
| 58 | case NUMBER_OF_BASIC_TYPES: |
---|
| 59 | assert( false ); |
---|
| 60 | } // switch |
---|
[51b7345] | 61 | assert( false ); |
---|
[0dd3a2f] | 62 | return false; |
---|
[51b7345] | 63 | } |
---|
| 64 | |
---|
| 65 | |
---|
[0dd3a2f] | 66 | // Local Variables: // |
---|
| 67 | // tab-width: 4 // |
---|
| 68 | // mode: c++ // |
---|
| 69 | // compile-command: "make install" // |
---|
| 70 | // End: // |
---|