// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // FunctionType.cc -- // // Author : Richard C. Bilson // Created On : Mon May 18 07:44:20 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Wed Feb 1 17:21:00 2017 // Update Count : 2 // #include #include "Type.h" #include "Declaration.h" #include "Common/utility.h" #include "Tuples/Tuples.h" FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), isVarArgs( isVarArgs ) { } FunctionType::FunctionType( const FunctionType &other ) : Type( other ), isVarArgs( other.isVarArgs ) { cloneAll( other.returnVals, returnVals ); cloneAll( other.parameters, parameters ); } FunctionType::~FunctionType() { deleteAll( returnVals ); deleteAll( parameters ); } namespace { bool containsTtype( const std::list & l ) { if ( ! l.empty() ) { return Tuples::isTtype( l.back()->get_type() ); } return false; } } bool FunctionType::isTtype() const { return containsTtype( returnVals ) || containsTtype( parameters ); } void FunctionType::print( std::ostream &os, int indent ) const { using std::string; using std::endl; Type::print( os, indent ); os << "function" << endl; if ( ! parameters.empty() ) { os << string( indent + 2, ' ' ) << "with parameters" << endl; printAll( parameters, os, indent + 4 ); if ( isVarArgs ) { os << string( indent + 4, ' ' ) << "and a variable number of other arguments" << endl; } // if } else if ( isVarArgs ) { os << string( indent + 4, ' ' ) << "accepting unspecified arguments" << endl; } // if os << string( indent + 2, ' ' ) << "returning "; if ( returnVals.empty() ) { os << endl << string( indent + 4, ' ' ) << "nothing " << endl; } else { os << endl; printAll( returnVals, os, indent + 4 ); } // if } // Local Variables: // // tab-width: 4 // // mode: c++ // // compile-command: "make install" // // End: //