source: src/SynTree/NamedTypeDecl.cc@ 837a17c

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 837a17c was d3b7937, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

building runtime library (first attempt)

  • Property mode set to 100644
File size: 2.3 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// NamedTypeDecl.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 : Sat Jun 13 08:13:55 2015
13// Update Count : 3
14//
15
16#include "Declaration.h"
17#include "Type.h"
18#include "Common/utility.h"
19
20NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *base )
21 : Parent( name, sc, LinkageSpec::Cforall ), base( base ) {}
22
23NamedTypeDecl::NamedTypeDecl( const TypeDecl &other )
24 : Parent( other ), base( maybeClone( other.base ) ) {
25 cloneAll( other.parameters, parameters );
26 cloneAll( other.assertions, assertions );
27}
28
29NamedTypeDecl::~NamedTypeDecl() {
30 delete base;
31 deleteAll( parameters );
32 deleteAll( assertions );
33}
34
35void NamedTypeDecl::print( std::ostream &os, int indent ) const {
36 using namespace std;
37
38 if ( get_name() != "" ) {
39 os << get_name() << ": ";
40 } // if
41 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
42 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
43 } // if
44 os << typeString();
45 if ( base ) {
46 os << " for ";
47 base->print( os, indent );
48 } // if
49 if ( ! parameters.empty() ) {
50 os << endl << string( indent, ' ' ) << "with parameters" << endl;
51 printAll( parameters, os, indent+2 );
52 } // if
53 if ( ! assertions.empty() ) {
54 os << endl << string( indent, ' ' ) << "with assertions" << endl;
55 printAll( assertions, os, indent+2 );
56 } // if
57}
58
59void NamedTypeDecl::printShort( std::ostream &os, int indent ) const {
60 using namespace std;
61
62 if ( get_name() != "" ) {
63 os << get_name() << ": ";
64 } // if
65 if ( get_storageClass() != DeclarationNode::NoStorageClass ) {
66 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
67 } // if
68 os << typeString();
69 if ( base ) {
70 os << " for ";
71 base->print( os, indent );
72 } // if
73 if ( ! parameters.empty() ) {
74 os << endl << string( indent, ' ' ) << "with parameters" << endl;
75 printAll( parameters, os, indent+2 );
76 } // if
77}
78
79std::string TypedefDecl::typeString() const { return "typedef"; }
80
81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.