source: src/SynTree/FunctionType.cc@ 23063ea

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox 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 23063ea was c0aa336, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

third attempt at gcc attributes

  • 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// FunctionType.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 : Wed Feb 1 17:21:00 2017
13// Update Count : 2
14//
15
16#include <algorithm>
17
18#include "Type.h"
19#include "Declaration.h"
20#include "Common/utility.h"
21#include "Tuples/Tuples.h"
22
23FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), isVarArgs( isVarArgs ) {
24}
25
26FunctionType::FunctionType( const FunctionType &other ) : Type( other ), isVarArgs( other.isVarArgs ) {
27 cloneAll( other.returnVals, returnVals );
28 cloneAll( other.parameters, parameters );
29}
30
31FunctionType::~FunctionType() {
32 deleteAll( returnVals );
33 deleteAll( parameters );
34}
35
36namespace {
37 bool containsTtype( const std::list<DeclarationWithType * > & l ) {
38 if ( ! l.empty() ) {
39 return Tuples::isTtype( l.back()->get_type() );
40 }
41 return false;
42 }
43}
44
45bool FunctionType::isTtype() const {
46 return containsTtype( returnVals ) || containsTtype( parameters );
47}
48
49void FunctionType::print( std::ostream &os, int indent ) const {
50 using std::string;
51 using std::endl;
52
53 Type::print( os, indent );
54 os << "function" << endl;
55 if ( ! parameters.empty() ) {
56 os << string( indent + 2, ' ' ) << "with parameters" << endl;
57 printAll( parameters, os, indent + 4 );
58 if ( isVarArgs ) {
59 os << string( indent + 4, ' ' ) << "and a variable number of other arguments" << endl;
60 } // if
61 } else if ( isVarArgs ) {
62 os << string( indent + 4, ' ' ) << "accepting unspecified arguments" << endl;
63 } // if
64 os << string( indent + 2, ' ' ) << "returning ";
65 if ( returnVals.empty() ) {
66 os << endl << string( indent + 4, ' ' ) << "nothing " << endl;
67 } else {
68 os << endl;
69 printAll( returnVals, os, indent + 4 );
70 } // if
71}
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.