Ignore:
Timestamp:
May 18, 2015, 11:20:23 AM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
51587aa
Parents:
a32b204
Message:

licencing: third groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/SynTree/FunctionDecl.cc

    ra32b204 r0dd3a2f  
     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// FunctionDecl.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 08:48:46 2015
     13// Update Count     : 1
     14//
     15
    116#include <cassert>
    217
     
    621#include "utility.h"
    722
    8 
    923FunctionDecl::FunctionDecl( const std::string &name, StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline )
    1024        : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ) {
    11     // this is a brazen hack to force the function "main" to have C linkage
    12     if ( name == "main" ) {
    13         set_linkage( LinkageSpec::C );
    14     }
     25        // this is a brazen hack to force the function "main" to have C linkage
     26        if ( name == "main" ) {
     27                set_linkage( LinkageSpec::C );
     28        } // if
    1529}
    1630
    1731FunctionDecl::FunctionDecl( const FunctionDecl &other )
    18     : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ) {
     32        : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), isInline( other.isInline ) {
    1933}
    2034
    2135FunctionDecl::~FunctionDecl() {
    22     delete type;
    23     delete statements;
     36        delete type;
     37        delete statements;
    2438}
    2539
    2640Type * FunctionDecl::get_type() const {
    27     return type;
     41        return type;
    2842}
    2943
    3044void FunctionDecl::set_type( Type *t ) {
    31     type = dynamic_cast< FunctionType* >( t );
    32     assert( type );
     45        type = dynamic_cast< FunctionType* >( t );
     46        assert( type );
    3347}
    3448
    3549void FunctionDecl::print( std::ostream &os, int indent ) const {
    36     using std::endl;
    37     using std::string;
    38    
    39     if ( get_name() != "" ) {
    40         os << get_name() << ": a ";
    41     }
    42     if ( get_linkage() != LinkageSpec::Cforall ) {
    43         os << LinkageSpec::toString( get_linkage() ) << " ";
    44     }
    45     if ( isInline ) {
    46         os << "inline ";
    47     }
    48     if ( get_storageClass() != NoStorageClass ) {
    49         os << storageClassName[ get_storageClass() ] << ' ';
    50     }
    51     if ( get_type() ) {
    52         get_type()->print( os, indent );
    53     } else {
    54         os << "untyped entity ";
    55     }
    56     if ( ! oldIdents.empty() ) {
    57         os << string( indent+2, ' ' ) << "with parameter names" << endl;
    58         for ( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) {
    59             os << string( indent+4, ' ' ) << *i << endl;
    60         }
    61     }
    62     if ( ! oldDecls.empty() ) {
    63         os << string( indent+2, ' ' ) << "with parameter declarations" << endl;
    64         printAll( oldDecls, os, indent+4 );
    65     }
    66     if ( statements ) {
    67         os << string( indent+2, ' ' ) << "with body " << endl;
    68         statements->print( os, indent+4 );
    69     }
     50        using std::endl;
     51        using std::string;
     52       
     53        if ( get_name() != "" ) {
     54                os << get_name() << ": a ";
     55        } // if
     56        if ( get_linkage() != LinkageSpec::Cforall ) {
     57                os << LinkageSpec::toString( get_linkage() ) << " ";
     58        } // if
     59        if ( isInline ) {
     60                os << "inline ";
     61        } // if
     62        if ( get_storageClass() != NoStorageClass ) {
     63                os << storageClassName[ get_storageClass() ] << ' ';
     64        } // if
     65        if ( get_type() ) {
     66                get_type()->print( os, indent );
     67        } else {
     68                os << "untyped entity ";
     69        } // if
     70        if ( ! oldIdents.empty() ) {
     71                os << string( indent+2, ' ' ) << "with parameter names" << endl;
     72                for ( std::list< std::string >::const_iterator i = oldIdents.begin(); i != oldIdents.end(); ++i ) {
     73                        os << string( indent+4, ' ' ) << *i << endl;
     74                } // for
     75        } // if
     76        if ( ! oldDecls.empty() ) {
     77                os << string( indent+2, ' ' ) << "with parameter declarations" << endl;
     78                printAll( oldDecls, os, indent+4 );
     79        } // if
     80        if ( statements ) {
     81                os << string( indent+2, ' ' ) << "with body " << endl;
     82                statements->print( os, indent+4 );
     83        } // if
    7084}
    7185
    7286void FunctionDecl::printShort( std::ostream &os, int indent ) const {
    73     using std::endl;
    74     using std::string;
    75    
    76     if ( get_name() != "" ) {
    77         os << get_name() << ": a ";
    78     }
    79     if ( isInline ) {
    80         os << "inline ";
    81     }
    82     if ( get_storageClass() != NoStorageClass ) {
    83         os << storageClassName[ get_storageClass() ] << ' ';
    84     }
    85     if ( get_type() ) {
    86         get_type()->print( os, indent );
    87     } else {
    88         os << "untyped entity ";
    89     }
     87        using std::endl;
     88        using std::string;
     89       
     90        if ( get_name() != "" ) {
     91                os << get_name() << ": a ";
     92        } // if
     93        if ( isInline ) {
     94                os << "inline ";
     95        } // if
     96        if ( get_storageClass() != NoStorageClass ) {
     97                os << storageClassName[ get_storageClass() ] << ' ';
     98        } // if
     99        if ( get_type() ) {
     100                get_type()->print( os, indent );
     101        } else {
     102                os << "untyped entity ";
     103        } // if
    90104}
     105
     106// Local Variables: //
     107// tab-width: 4 //
     108// mode: c++ //
     109// compile-command: "make install" //
     110// End: //
Note: See TracChangeset for help on using the changeset viewer.