source: src/SynTree/Type.cc @ e6cfa8ff

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since e6cfa8ff was cfaa2873, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

generate BasicType::typeNames from BasicTypes?-gen

  • Property mode set to 100644
File size: 4.3 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
[357390f]11// Last Modified By : Peter A. Buhr
[cfaa2873]12// Last Modified On : Sun Dec 15 16:52:37 2019
13// Update Count     : 49
[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
[cfaa2873]26// GENERATED START, DO NOT EDIT
27// GENERATED BY BasicTypes-gen.cc
[357390f]28const char * BasicType::typeNames[] = {
[cdcddfe1]29        "_Bool",
30        "char",
31        "signed char",
32        "unsigned char",
33        "signed short int",
34        "unsigned short int",
35        "signed int",
36        "unsigned int",
37        "signed long int",
38        "unsigned long int",
39        "signed long long int",
40        "unsigned long long int",
41        "__int128",
42        "unsigned __int128",
43        "_Float16",
44        "_Float16 _Complex",
45        "_Float32",
46        "_Float32 _Complex",
47        "float",
48        "float _Complex",
49        "_Float32x",
50        "_Float32x _Complex",
51        "_Float64",
52        "_Float64 _Complex",
53        "double",
54        "double _Complex",
55        "_Float64x",
56        "_Float64x _Complex",
57        "__float80",
58        "_Float128",
59        "_Float128 _Complex",
60        "__float128",
61        "long double",
62        "long double _Complex",
63        "_Float128x",
64        "_Float128x _Complex",
[17cd4eb]65};
[cfaa2873]66// GENERATED END
[51b7345]67
[c0aa336]68Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
[51b7345]69
[64ac636]70Type::Type( const Type &other ) : BaseSyntaxNode( other ), tq( other.tq ) {
[a08ba92]71        cloneAll( other.forall, forall );
[c0aa336]72        cloneAll( other.attributes, attributes );
[51b7345]73}
74
[17cd4eb]75Type::~Type() {
[a08ba92]76        deleteAll( forall );
[c0aa336]77        deleteAll( attributes );
[51b7345]78}
79
[68fe077a]80// These must remain in the same order as the corresponding bit fields.
[999c700]81const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" };
[615a096]82const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
[b4f8808]83const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "mutex", "_Atomic" };
[0dd3a2f]84
[0698aa1]85Type * Type::stripDeclarator() {
[de9285f]86        Type * type, * at;
87        for ( type = this; (at = InitTweak::getPointerBase( type )); type = at );
[6f95000]88        return type;
89}
[0dd3a2f]90
[0698aa1]91Type * Type::stripReferences() {
[de9285f]92        Type * type;
93        ReferenceType * ref;
[50377a4]94        for ( type = this; (ref = dynamic_cast<ReferenceType *>( type )); type = ref->base );
[0698aa1]95        return type;
96}
97
[85dac33]98const Type * Type::stripReferences() const {
99        const Type * type;
100        const ReferenceType * ref;
101        for ( type = this; (ref = dynamic_cast<const ReferenceType *>( type )); type = ref->base );
102        return type;
103}
104
[e6cee92]105int Type::referenceDepth() const { return 0; }
106
[9bfc9da]107TypeSubstitution Type::genericSubstitution() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }
108
[357390f]109void Type::print( std::ostream & os, Indenter indent ) const {
[f1b1e4c]110        if ( ! forall.empty() ) {
111                os << "forall" << std::endl;
[50377a4]112                printAll( forall, os, indent+1 );
113                os << ++indent;
[f1b1e4c]114        } // if
[c0aa336]115
116        if ( ! attributes.empty() ) {
[50377a4]117                os << "with attributes" << endl;
118                printAll( attributes, os, indent+1 );
[c0aa336]119        } // if
[64ac636]120
[d6d747d]121        tq.print( os );
[f1b1e4c]122}
123
[c5d7701]124
[c194661]125QualifiedType::QualifiedType( const Type::Qualifiers & tq, Type * parent, Type * child ) : Type( tq, {} ), parent( parent ), child( child ) {
[c5d7701]126}
127
[c194661]128QualifiedType::QualifiedType( const QualifiedType & other ) : Type( other ), parent( maybeClone( other.parent ) ), child( maybeClone( other.child ) ) {
[c5d7701]129}
130
131QualifiedType::~QualifiedType() {
[c194661]132        delete parent;
133        delete child;
[c5d7701]134}
135
136void QualifiedType::print( std::ostream & os, Indenter indent ) const {
[07ec1a2]137        os << "Qualified Type:" << endl;
[c194661]138        os << indent+1;
139        parent->print( os, indent+1 );
140        os << endl << indent+1;
141        child->print( os, indent+1 );
142        os << endl;
[c5d7701]143        Type::print( os, indent+1 );
144}
145
[47498bd]146GlobalScopeType::GlobalScopeType() : Type( Type::Qualifiers(), {} ) {}
147
[0b3b2ae]148void GlobalScopeType::print( std::ostream & os, Indenter ) const {
[47498bd]149        os << "Global Scope Type" << endl;
150}
151
[c5d7701]152
[65cdc1e]153// Empty Variable declarations:
154const Type::FuncSpecifiers noFuncSpecifiers;
155const Type::StorageClasses noStorageClasses;
156const Type::Qualifiers noQualifiers;
157
[0dd3a2f]158// Local Variables: //
159// tab-width: 4 //
160// mode: c++ //
161// compile-command: "make install" //
162// End: //
Note: See TracBrowser for help on using the repository browser.