source: src/SynTree/FunctionType.cc @ 68f9c43

new-envwith_gc
Last change on this file since 68f9c43 was 68f9c43, checked in by Aaron Moss <a3moss@…>, 6 years ago

First pass at delete removal

  • Property mode set to 100644
File size: 2.2 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 <list>              // for list
17#include <ostream>           // for operator<<, basic_ostream, ostream, endl
18#include <string>            // for operator<<, char_traits, string
19
20#include "Common/utility.h"  // for cloneAll, deleteAll, printAll
21#include "Declaration.h"     // for DeclarationWithType
22#include "Tuples/Tuples.h"   // for isTtype
23#include "Type.h"            // for FunctionType, Type, Type::Qualifiers
24
25class Attribute;
26
27FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), isVarArgs( isVarArgs ) {
28}
29
30FunctionType::FunctionType( const FunctionType &other ) : Type( other ), isVarArgs( other.isVarArgs ) {
31        cloneAll( other.returnVals, returnVals );
32        cloneAll( other.parameters, parameters );
33}
34
35namespace {
36        bool containsTtype( const std::list<DeclarationWithType * > & l ) {
37                if ( ! l.empty() ) {
38                        return Tuples::isTtype( l.back()->get_type() );
39                }
40                return false;
41        }
42}
43
44bool FunctionType::isTtype() const {
45        return containsTtype( returnVals ) || containsTtype( parameters );
46}
47
48void FunctionType::print( std::ostream &os, Indenter indent ) const {
49        using std::string;
50        using std::endl;
51
52        Type::print( os, indent );
53        os << "function" << endl;
54        if ( ! parameters.empty() ) {
55                os << indent << "... with parameters" << endl;
56                printAll( parameters, os, indent+1 );
57                if ( isVarArgs ) {
58                        os << indent+1 << "and a variable number of other arguments" << endl;
59                } // if
60        } else if ( isVarArgs ) {
61                os << indent+1 << "accepting unspecified arguments" << endl;
62        } // if
63        os << indent << "... returning ";
64        if ( returnVals.empty() ) {
65                os << "nothing " << endl;
66        } else {
67                os << endl;
68                printAll( returnVals, os, indent+1 );
69        } // if
70}
71
72// Local Variables: //
73// tab-width: 4 //
74// mode: c++ //
75// compile-command: "make install" //
76// End: //
Note: See TracBrowser for help on using the repository browser.