Changeset 3f7e12cb for src/SynTree/FunctionDecl.cc
- Timestamp:
- Nov 8, 2017, 5:43:33 PM (8 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/FunctionDecl.cc
r78315272 r3f7e12cb 26 26 #include "Statement.h" // for CompoundStmt 27 27 #include "Type.h" // for Type, FunctionType, Type::FuncSpecif... 28 #include "VarExprReplacer.h" 28 29 29 30 extern bool translation_unit_nomain; … … 39 40 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 40 41 : 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 } 41 54 } 42 55 … … 46 59 } 47 60 48 void FunctionDecl::print( std::ostream &os, int indent ) const { 61 FunctionDecl * FunctionDecl::newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements ) { 62 return new FunctionDecl( name, Type::StorageClasses(), LinkageSpec::C, type, statements ); 63 } 64 65 void FunctionDecl::print( std::ostream &os, Indenter indent ) const { 49 66 using std::endl; 50 67 using std::string; 51 68 52 if ( get_name()!= "" ) {53 os << get_name()<< ": ";69 if ( name != "" ) { 70 os << name << ": "; 54 71 } // if 55 if ( get_linkage()!= LinkageSpec::Cforall ) {56 os << LinkageSpec::linkageName( get_linkage()) << " ";72 if ( linkage != LinkageSpec::Cforall ) { 73 os << LinkageSpec::linkageName( linkage ) << " "; 57 74 } // if 58 75 59 printAll( get_attributes(), os, indent );76 printAll( attributes, os, indent ); 60 77 61 78 get_storageClasses().print( os ); 62 79 get_funcSpec().print( os ); 63 80 64 if ( get_type()) {65 get_type()->print( os, indent );81 if ( type ) { 82 type->print( os, indent ); 66 83 } else { 67 84 os << "untyped entity "; … … 69 86 70 87 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 ); 74 90 } // if 75 91 } 76 92 77 void FunctionDecl::printShort( std::ostream &os, intindent ) const {93 void FunctionDecl::printShort( std::ostream &os, Indenter indent ) const { 78 94 using std::endl; 79 95 using std::string; 80 96 81 if ( get_name()!= "" ) {82 os << get_name()<< ": ";97 if ( name != "" ) { 98 os << name << ": "; 83 99 } // if 84 85 // xxx - should printShort print attributes?86 100 87 101 get_storageClasses().print( os ); 88 102 get_funcSpec().print( os ); 89 103 90 if ( get_type()) {91 get_type()->print( os, indent );104 if ( type ) { 105 type->print( os, indent ); 92 106 } else { 93 107 os << "untyped entity ";
Note:
See TracChangeset
for help on using the changeset viewer.