source: src/SynTree/FunctionType.cc @ 8bf784a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 8bf784a was 8bf784a, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

name mangling for ttype, fix SynTree? operator<< to work with nullptr, add isTtype check, ttype variables are automatically "sized"

  • Property mode set to 100644
File size: 2.0 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
12// Last Modified On : Mon May 18 09:01:28 2015
13// Update Count     : 1
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
[c8ffe20b]23FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs ) : Type( tq ), 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.