source: src/SynTree/Type.cc @ cdc4d43

new-envwith_gc
Last change on this file since cdc4d43 was 68f9c43, checked in by Aaron Moss <a3moss@…>, 6 years ago

First pass at delete removal

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[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
[de9285f]11// Last Modified By : Peter A. Buhr
[201aeb9]12// Last Modified On : Mon Sep 25 15:16:32 2017
13// Update Count     : 38
[0dd3a2f]14//
[51b7345]15#include "Type.h"
[0dd3a2f]16
[9bfc9da]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#include "SynTree/TypeSubstitution.h" // for TypeSubstitution
[51b7345]23
[c0aa336]24using namespace std;
25
[17cd4eb]26const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
[a08ba92]27        "_Bool",
28        "char",
[de9285f]29        "signed char",
[a08ba92]30        "unsigned char",
[de9285f]31        "signed short int",
32        "unsigned short int",
33        "signed int",
[a08ba92]34        "unsigned int",
[de9285f]35        "signed long int",
36        "unsigned long int",
37        "signed long long int",
38        "unsigned long long int",
[a08ba92]39        "float",
40        "double",
41        "long double",
42        "float _Complex",
43        "double _Complex",
44        "long double _Complex",
45        "float _Imaginary",
46        "double _Imaginary",
47        "long double _Imaginary",
[201aeb9]48        "__int128",
49        "unsigned __int128",
[17cd4eb]50};
[51b7345]51
[c0aa336]52Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
[51b7345]53
[64ac636]54Type::Type( const Type &other ) : BaseSyntaxNode( other ), tq( other.tq ) {
[a08ba92]55        cloneAll( other.forall, forall );
[c0aa336]56        cloneAll( other.attributes, attributes );
[51b7345]57}
58
[68fe077a]59// These must remain in the same order as the corresponding bit fields.
[615a096]60const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" };
61const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
62const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
[0dd3a2f]63
[0698aa1]64Type * Type::stripDeclarator() {
[de9285f]65        Type * type, * at;
66        for ( type = this; (at = InitTweak::getPointerBase( type )); type = at );
[6f95000]67        return type;
68}
[0dd3a2f]69
[0698aa1]70Type * Type::stripReferences() {
[de9285f]71        Type * type;
72        ReferenceType * ref;
[50377a4]73        for ( type = this; (ref = dynamic_cast<ReferenceType *>( type )); type = ref->base );
[0698aa1]74        return type;
75}
76
[e6cee92]77int Type::referenceDepth() const { return 0; }
78
[9bfc9da]79TypeSubstitution Type::genericSubstitution() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }
80
[50377a4]81void Type::print( std::ostream &os, Indenter indent ) const {
[f1b1e4c]82        if ( ! forall.empty() ) {
83                os << "forall" << std::endl;
[50377a4]84                printAll( forall, os, indent+1 );
85                os << ++indent;
[f1b1e4c]86        } // if
[c0aa336]87
88        if ( ! attributes.empty() ) {
[50377a4]89                os << "with attributes" << endl;
90                printAll( attributes, os, indent+1 );
[c0aa336]91        } // if
[64ac636]92
[d6d747d]93        tq.print( os );
[f1b1e4c]94}
95
[65cdc1e]96// Empty Variable declarations:
97const Type::FuncSpecifiers noFuncSpecifiers;
98const Type::StorageClasses noStorageClasses;
99const Type::Qualifiers noQualifiers;
100
[0dd3a2f]101// Local Variables: //
102// tab-width: 4 //
103// mode: c++ //
104// compile-command: "make install" //
105// End: //
Note: See TracBrowser for help on using the repository browser.