source: src/SynTree/Type.cc @ f980549

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 f980549 was e149f77, checked in by Thierry Delisle <tdelisle@…>, 7 years ago
  • moved print routine to base syntax node and implementated in code gen.
  • added virtual and override where needed in the syntree.
  • Property mode set to 100644
File size: 2.9 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 : Mon Sep 11 13:21:25 2017
13// Update Count     : 37
14//
15#include "Type.h"
16
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
23using namespace std;
24
25const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
26        "_Bool",
27        "char",
28        "signed char",
29        "unsigned char",
30        "signed short int",
31        "unsigned short int",
32        "signed int",
33        "unsigned int",
34        "signed long int",
35        "unsigned long int",
36        "signed long long int",
37        "unsigned long long 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 ) : BaseSyntaxNode( 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
61// These must remain in the same order as the corresponding bit fields.
62const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" };
63const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
64const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
65
66Type * Type::stripDeclarator() {
67        Type * type, * at;
68        for ( type = this; (at = InitTweak::getPointerBase( type )); type = at );
69        return type;
70}
71
72Type * Type::stripReferences() {
73        Type * type;
74        ReferenceType * ref;
75        for ( type = this; (ref = dynamic_cast<ReferenceType *>( type )); type = ref->get_base() );
76        return type;
77}
78
79int Type::referenceDepth() const { return 0; }
80
81void Type::print( std::ostream &os, int indent ) const {
82        if ( ! forall.empty() ) {
83                os << "forall" << std::endl;
84                printAll( forall, os, indent + 4 );
85                os << std::string( indent+2, ' ' );
86        } // if
87
88        if ( ! attributes.empty() ) {
89                os << endl << string( indent+2, ' ' ) << "with attributes" << endl;
90                printAll( attributes, os, indent+4 );
91        } // if
92
93        tq.print( os );
94}
95
96// Empty Variable declarations:
97const Type::FuncSpecifiers noFuncSpecifiers;
98const Type::StorageClasses noStorageClasses;
99const Type::Qualifiers noQualifiers;
100
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.