source: src/SynTree/FunctionType.cc @ 70a1c3ae

no_list
Last change on this file since 70a1c3ae was 70a1c3ae, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Starting to remove std::list to see if it affects performance, started with List of attributes

  • Property mode set to 100644
File size: 2.3 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::vector< 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
35FunctionType::~FunctionType() {
36        deleteAll( returnVals );
37        deleteAll( parameters );
38}
39
40namespace {
41        bool containsTtype( const std::list<DeclarationWithType * > & l ) {
42                if ( ! l.empty() ) {
43                        return Tuples::isTtype( l.back()->get_type() );
44                }
45                return false;
46        }
47}
48
49bool FunctionType::isTtype() const {
50        return containsTtype( returnVals ) || containsTtype( parameters );
51}
52
53void FunctionType::print( std::ostream &os, Indenter indent ) const {
54        using std::string;
55        using std::endl;
56
57        Type::print( os, indent );
58        os << "function" << endl;
59        if ( ! parameters.empty() ) {
60                os << indent << "... with parameters" << endl;
61                printAll( parameters, os, indent+1 );
62                if ( isVarArgs ) {
63                        os << indent+1 << "and a variable number of other arguments" << endl;
64                } // if
65        } else if ( isVarArgs ) {
66                os << indent+1 << "accepting unspecified arguments" << endl;
67        } // if
68        os << indent << "... returning";
69        if ( returnVals.empty() ) {
70                os << " nothing" << endl;
71        } else {
72                os << endl;
73                printAll( returnVals, os, indent+1 );
74        } // if
75}
76
77// Local Variables: //
78// tab-width: 4 //
79// mode: c++ //
80// compile-command: "make install" //
81// End: //
Note: See TracBrowser for help on using the repository browser.