source: src/SynTree/AggregateDecl.cc @ dae881f

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since dae881f was 5d125e4, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

start code allowing structures to no fields

  • Property mode set to 100644
File size: 2.1 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// AggregateDecl.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Sun May 17 23:56:39 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Jul 13 18:03:30 2016
13// Update Count     : 10
14//
15
16#include "Declaration.h"
17#include "Type.h"
18#include "Common/utility.h"
19
20
21AggregateDecl::AggregateDecl( const std::string &name ) : Parent( name, DeclarationNode::NoStorageClass, LinkageSpec::Cforall ), body( false ) {
22}
23
24AggregateDecl::AggregateDecl( const AggregateDecl &other ) : Parent( other ) {
25        cloneAll( other.members, members );
26        cloneAll( other.parameters, parameters );
27        body = other.body;
28}
29
30AggregateDecl::~AggregateDecl() {
31        deleteAll( members );
32        deleteAll( parameters );
33}
34
35void AggregateDecl::print( std::ostream &os, int indent ) const {
36        using std::string;
37        using std::endl;
38
39        os << typeString() << " " << get_name();
40        os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
41
42        if ( ! parameters.empty() ) {
43                os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
44                printAll( parameters, os, indent+4 );
45        } // if
46        if ( ! members.empty() ) {
47                os << endl << string( indent+2, ' ' ) << "with members" << endl;
48                printAll( members, os, indent+4 );
49        } // if
50}
51
52void AggregateDecl::printShort( std::ostream &os, int indent ) const {
53        using std::string;
54        using std::endl;
55
56        os << typeString() << " " << get_name();
57        os << string( indent+2, ' ' ) << "with body " << has_body() << endl;
58
59        if ( ! parameters.empty() ) {
60                os << endl << string( indent+2, ' ' ) << "with parameters" << endl;
61                printAll( parameters, os, indent+4 );
62        } // if
63}
64
65std::string StructDecl::typeString() const { return "struct"; }
66
67std::string UnionDecl::typeString() const { return "union"; }
68
69std::string EnumDecl::typeString() const { return "enum"; }
70
71std::string TraitDecl::typeString() const { return "context"; }
72
73// Local Variables: //
74// tab-width: 4 //
75// mode: c++ //
76// compile-command: "make install" //
77// End: //
Note: See TracBrowser for help on using the repository browser.