Ignore:
Timestamp:
Nov 8, 2017, 5:43:33 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
954908d
Parents:
78315272 (diff), e35f30a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/FunctionDecl.cc

    r78315272 r3f7e12cb  
    2626#include "Statement.h"           // for CompoundStmt
    2727#include "Type.h"                // for Type, FunctionType, Type::FuncSpecif...
     28#include "VarExprReplacer.h"
    2829
    2930extern bool translation_unit_nomain;
     
    3940FunctionDecl::FunctionDecl( const FunctionDecl &other )
    4041                : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     42
     43        VarExprReplacer::DeclMap declMap;
     44        for ( auto p : group_iterate( other.type->parameters, type->parameters ) ) {
     45                declMap[ std::get<0>(p) ] = std::get<1>(p);
     46        }
     47        for ( auto p : group_iterate( other.type->returnVals, type->returnVals ) ) {
     48                declMap[ std::get<0>(p) ] = std::get<1>(p);
     49        }
     50        if ( ! declMap.empty() ) {
     51                VarExprReplacer replacer( declMap );
     52                accept( replacer );
     53        }
    4154}
    4255
     
    4659}
    4760
    48 void FunctionDecl::print( std::ostream &os, int indent ) const {
     61FunctionDecl * FunctionDecl::newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements ) {
     62        return new FunctionDecl( name, Type::StorageClasses(), LinkageSpec::C, type, statements );
     63}
     64
     65void FunctionDecl::print( std::ostream &os, Indenter indent ) const {
    4966        using std::endl;
    5067        using std::string;
    5168
    52         if ( get_name() != "" ) {
    53                 os << get_name() << ": ";
     69        if ( name != "" ) {
     70                os << name << ": ";
    5471        } // if
    55         if ( get_linkage() != LinkageSpec::Cforall ) {
    56                 os << LinkageSpec::linkageName( get_linkage() ) << " ";
     72        if ( linkage != LinkageSpec::Cforall ) {
     73                os << LinkageSpec::linkageName( linkage ) << " ";
    5774        } // if
    5875
    59         printAll( get_attributes(), os, indent );
     76        printAll( attributes, os, indent );
    6077
    6178        get_storageClasses().print( os );
    6279        get_funcSpec().print( os );
    6380
    64         if ( get_type() ) {
    65                 get_type()->print( os, indent );
     81        if ( type ) {
     82                type->print( os, indent );
    6683        } else {
    6784                os << "untyped entity ";
     
    6986
    7087        if ( statements ) {
    71                 os << string( indent + 2, ' ' ) << "with body " << endl;
    72                 os << string( indent + 4, ' ' );
    73                 statements->print( os, indent + 4 );
     88                os << indent << "... with body " << endl << indent+1;
     89                statements->print( os, indent+1 );
    7490        } // if
    7591}
    7692
    77 void FunctionDecl::printShort( std::ostream &os, int indent ) const {
     93void FunctionDecl::printShort( std::ostream &os, Indenter indent ) const {
    7894        using std::endl;
    7995        using std::string;
    8096
    81         if ( get_name() != "" ) {
    82                 os << get_name() << ": ";
     97        if ( name != "" ) {
     98                os << name << ": ";
    8399        } // if
    84 
    85         // xxx - should printShort print attributes?
    86100
    87101        get_storageClasses().print( os );
    88102        get_funcSpec().print( os );
    89103
    90         if ( get_type() ) {
    91                 get_type()->print( os, indent );
     104        if ( type ) {
     105                type->print( os, indent );
    92106        } else {
    93107                os << "untyped entity ";
Note: See TracChangeset for help on using the changeset viewer.