source: src/SynTree/FunctionType.cc @ c0aa336

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since c0aa336 was c0aa336, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

third attempt at gcc attributes

  • Property mode set to 100644
File size: 2.1 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//
[8bf784a]7// FunctionType.cc --
[0dd3a2f]8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
[c0aa336]12// Last Modified On : Wed Feb  1 17:21:00 2017
13// Update Count     : 2
[0dd3a2f]14//
15
[51b7345]16#include <algorithm>
17
18#include "Type.h"
19#include "Declaration.h"
[d3b7937]20#include "Common/utility.h"
[8bf784a]21#include "Tuples/Tuples.h"
[51b7345]22
[c0aa336]23FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), isVarArgs( isVarArgs ) {
[51b7345]24}
25
[c8ffe20b]26FunctionType::FunctionType( const FunctionType &other ) : Type( other ), isVarArgs( other.isVarArgs ) {
[0dd3a2f]27        cloneAll( other.returnVals, returnVals );
28        cloneAll( other.parameters, parameters );
[51b7345]29}
30
[c8ffe20b]31FunctionType::~FunctionType() {
[0dd3a2f]32        deleteAll( returnVals );
33        deleteAll( parameters );
[51b7345]34}
35
[8bf784a]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
[c8ffe20b]49void FunctionType::print( std::ostream &os, int indent ) const {
[0dd3a2f]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
[51b7345]71}
72
[0dd3a2f]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.