| 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 : Mon May 18 09:01:28 2015
|
|---|
| 13 | // Update Count : 1
|
|---|
| 14 | //
|
|---|
| 15 |
|
|---|
| 16 | #include <algorithm>
|
|---|
| 17 |
|
|---|
| 18 | #include "Type.h"
|
|---|
| 19 | #include "Declaration.h"
|
|---|
| 20 | #include "Common/utility.h"
|
|---|
| 21 |
|
|---|
| 22 | FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs ) : Type( tq ), isVarArgs( isVarArgs ) {
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | FunctionType::FunctionType( const FunctionType &other ) : Type( other ), isVarArgs( other.isVarArgs ) {
|
|---|
| 26 | cloneAll( other.returnVals, returnVals );
|
|---|
| 27 | cloneAll( other.parameters, parameters );
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | FunctionType::~FunctionType() {
|
|---|
| 31 | deleteAll( returnVals );
|
|---|
| 32 | deleteAll( parameters );
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | void FunctionType::print( std::ostream &os, int indent ) const {
|
|---|
| 36 | using std::string;
|
|---|
| 37 | using std::endl;
|
|---|
| 38 |
|
|---|
| 39 | Type::print( os, indent );
|
|---|
| 40 | os << "function" << endl;
|
|---|
| 41 | if ( ! parameters.empty() ) {
|
|---|
| 42 | os << string( indent + 2, ' ' ) << "with parameters" << endl;
|
|---|
| 43 | printAll( parameters, os, indent + 4 );
|
|---|
| 44 | if ( isVarArgs ) {
|
|---|
| 45 | os << string( indent + 4, ' ' ) << "and a variable number of other arguments" << endl;
|
|---|
| 46 | } // if
|
|---|
| 47 | } else if ( isVarArgs ) {
|
|---|
| 48 | os << string( indent + 4, ' ' ) << "accepting unspecified arguments" << endl;
|
|---|
| 49 | } // if
|
|---|
| 50 | os << string( indent + 2, ' ' ) << "returning ";
|
|---|
| 51 | if ( returnVals.empty() ) {
|
|---|
| 52 | os << endl << string( indent + 4, ' ' ) << "nothing " << endl;
|
|---|
| 53 | } else {
|
|---|
| 54 | os << endl;
|
|---|
| 55 | printAll( returnVals, os, indent + 4 );
|
|---|
| 56 | } // if
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | // Local Variables: //
|
|---|
| 60 | // tab-width: 4 //
|
|---|
| 61 | // mode: c++ //
|
|---|
| 62 | // compile-command: "make install" //
|
|---|
| 63 | // End: //
|
|---|