Changeset 50377a4
- Timestamp:
- Oct 2, 2017, 4:39:42 PM (7 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:
- bf4b4cf
- Parents:
- a8555c5
- Location:
- src
- Files:
-
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
ra8555c5 r50377a4 1088 1088 } // namespace CodeGen 1089 1089 1090 1091 unsigned Indenter::tabsize = 2; 1092 1090 1093 std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) { 1091 1094 if ( node ) { -
src/Common/Indenter.h
ra8555c5 r50377a4 18 18 19 19 struct Indenter { 20 Indenter( unsigned int amt = 2 ) : amt( amt ) {} 21 unsigned int amt = 2; // amount 1 level increases indent by (i.e. how much to increase by in operator++) 22 unsigned int indent = 0; 20 static unsigned tabsize; 21 22 Indenter( unsigned int amt = tabsize, unsigned int indent = 0 ) : amt( amt ), indent( indent ) {} 23 unsigned int amt; // amount 1 level increases indent by (i.e. how much to increase by in operator++) 24 unsigned int indent; 23 25 24 26 Indenter & operator+=(int nlevels) { indent += amt*nlevels; return *this; } … … 30 32 }; 31 33 32 inline std::ostream & operator<<( std::ostream & out, Indenter & indent ) {34 inline std::ostream & operator<<( std::ostream & out, const Indenter & indent ) { 33 35 return out << std::string(indent.indent, ' '); 34 36 } -
src/Common/utility.h
ra8555c5 r50377a4 28 28 #include <cassert> 29 29 30 #include "Common/Indenter.h" 31 30 32 template< typename T > 31 33 static inline T * maybeClone( const T *orig ) { … … 75 77 76 78 template< typename Container > 77 void printAll( const Container &container, std::ostream &os, int indent = 0) {79 void printAll( const Container &container, std::ostream &os, Indenter indent = {} ) { 78 80 for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) { 79 81 if ( *i ) { 80 os << std::string( indent, ' ' );81 (*i)->print( os, indent + 2);82 os << indent; 83 (*i)->print( os, indent ); 82 84 // need an endl after each element because it's not easy to know when each individual item should end 83 85 os << std::endl; … … 351 353 template< typename T1, typename T2 > 352 354 struct group_iterate_t { 355 private: 356 std::tuple<T1, T2> args; 357 public: 353 358 group_iterate_t( bool skipBoundsCheck, const T1 & v1, const T2 & v2 ) : args(v1, v2) { 354 359 assertf(skipBoundsCheck || v1.size() == v2.size(), "group iteration requires containers of the same size: <%zd, %zd>.", v1.size(), v2.size()); 355 360 }; 356 361 362 typedef std::tuple<decltype(*std::get<0>(args).begin()), decltype(*std::get<1>(args).begin())> value_type; 363 typedef decltype(std::get<0>(args).begin()) T1Iter; 364 typedef decltype(std::get<1>(args).begin()) T2Iter; 365 357 366 struct iterator { 358 typedef typename std::remove_reference<T1>::type T1val;359 typedef typename std::remove_reference<T2>::type T2val;360 typedef std::tuple<typename T1val::value_type &, typename T2val::value_type &> value_type;361 typedef typename T1val::iterator T1Iter;362 typedef typename T2val::iterator T2Iter;363 367 typedef std::tuple<T1Iter, T2Iter> IterTuple; 364 368 IterTuple it; … … 370 374 value_type operator*() const { return std::tie( *std::get<0>(it), *std::get<1>(it) ); } 371 375 }; 376 372 377 iterator begin() { return iterator( std::get<0>(args).begin(), std::get<1>(args).begin() ); } 373 378 iterator end() { return iterator( std::get<0>(args).end(), std::get<1>(args).end() ); } 374 375 private:376 std::tuple<T1, T2> args;377 379 }; 378 380 -
src/InitTweak/FixInit.cc
ra8555c5 r50377a4 552 552 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 553 553 // move env from callExpr to retExpr 554 retExpr->set_env( callExpr->get_env() ); 555 callExpr->set_env( nullptr ); 554 std::swap( retExpr->env, callExpr->env ); 556 555 return retExpr; 557 556 } else { -
src/ResolvExpr/Alternative.cc
ra8555c5 r50377a4 66 66 } 67 67 68 void Alternative::print( std::ostream &os, intindent ) const {69 os << std::string( indent, ' ' ) <<"Cost " << cost << ": ";68 void Alternative::print( std::ostream &os, Indenter indent ) const { 69 os << "Cost " << cost << ": "; 70 70 if ( expr ) { 71 expr->print( os, indent );72 os << "(types:" << std::endl;73 os << std::string( indent+4, ' ' );74 expr-> get_result()->print( os, indent + 4);75 os << std::endl << ")" << std::endl;71 expr->print( os, indent+1 ); 72 os << std::endl << indent << "(types:" << std::endl; 73 os << indent+1; 74 expr->result->print( os, indent+1 ); 75 os << std::endl << indent << ")" << std::endl; 76 76 } else { 77 77 os << "Null expression!" << std::endl; 78 78 } // if 79 os << std::string( indent, ' ' )<< "Environment: ";80 env.print( os, indent+ 2);79 os << indent << "Environment: "; 80 env.print( os, indent+1 ); 81 81 os << std::endl; 82 82 } -
src/ResolvExpr/Alternative.h
ra8555c5 r50377a4 39 39 ~Alternative(); 40 40 41 void print( std::ostream &os, int indent = 0) const;41 void print( std::ostream &os, Indenter indent = {} ) const; 42 42 43 43 Cost cost; -
src/ResolvExpr/AlternativeFinder.cc
ra8555c5 r50377a4 75 75 76 76 namespace { 77 void printAlts( const AltList &list, std::ostream &os, int indent = 0 ) { 77 void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt = 0 ) { 78 Indenter indent = { Indenter::tabsize, indentAmt }; 78 79 for ( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) { 79 80 i->print( os, indent ); … … 195 196 AltList winners; 196 197 findMinCost( alternatives.begin(), alternatives.end(), back_inserter( winners ) ); 197 stream << "Cannot choose between " << winners.size() << " alternatives for expression 198 stream << "Cannot choose between " << winners.size() << " alternatives for expression\n"; 198 199 expr->print( stream ); 199 stream << "Alternatives are: ";200 printAlts( winners, stream, 8);200 stream << "Alternatives are:\n"; 201 printAlts( winners, stream, 1 ); 201 202 throw SemanticError( stream.str() ); 202 203 } … … 728 729 PRINT( 729 730 std::cerr << "known function ops:" << std::endl; 730 printAlts( funcOpFinder.alternatives, std::cerr, 8);731 printAlts( funcOpFinder.alternatives, std::cerr, 1 ); 731 732 ) 732 733 -
src/ResolvExpr/TypeEnvironment.cc
ra8555c5 r50377a4 68 68 } 69 69 70 void EqvClass::print( std::ostream &os, intindent ) const {71 os << std::string( indent, ' ' ) <<"( ";70 void EqvClass::print( std::ostream &os, Indenter indent ) const { 71 os << "( "; 72 72 std::copy( vars.begin(), vars.end(), std::ostream_iterator< std::string >( os, " " ) ); 73 73 os << ")"; 74 74 if ( type ) { 75 75 os << " -> "; 76 type->print( os, indent );76 type->print( os, indent+1 ); 77 77 } // if 78 78 if ( ! allowWidening ) { … … 144 144 } 145 145 146 void TypeEnvironment::print( std::ostream &os, intindent ) const {146 void TypeEnvironment::print( std::ostream &os, Indenter indent ) const { 147 147 for ( std::list< EqvClass >::const_iterator i = env.begin(); i != env.end(); ++i ) { 148 148 i->print( os, indent ); -
src/ResolvExpr/TypeEnvironment.h
ra8555c5 r50377a4 68 68 EqvClass &operator=( const EqvClass &other ); 69 69 ~EqvClass(); 70 void print( std::ostream &os, int indent = 0) const;70 void print( std::ostream &os, Indenter indent = {} ) const; 71 71 }; 72 72 … … 80 80 void makeSubstitution( TypeSubstitution &result ) const; 81 81 bool isEmpty() const { return env.empty(); } 82 void print( std::ostream &os, int indent = 0) const;82 void print( std::ostream &os, Indenter indent = {} ) const; 83 83 void combine( const TypeEnvironment &second, Type *(*combineFunc)( Type*, Type* ) ); 84 84 void simpleCombine( const TypeEnvironment &second ); -
src/SynTree/AddressExpr.cc
ra8555c5 r50377a4 62 62 } 63 63 64 void AddressExpr::print( std::ostream &os, intindent ) const {64 void AddressExpr::print( std::ostream &os, Indenter indent ) const { 65 65 os << "Address of:" << std::endl; 66 66 if ( arg ) { 67 os << std::string( indent+2, ' ' );68 arg->print( os, indent+ 2);67 os << indent+1; 68 arg->print( os, indent+1 ); 69 69 } // if 70 70 } … … 77 77 LabelAddressExpr::~LabelAddressExpr() {} 78 78 79 void LabelAddressExpr::print( std::ostream & os, int indent) const {80 os << "Address of label:" << std::endl << std::string( indent+2, ' ' ) <<arg;79 void LabelAddressExpr::print( std::ostream & os, Indenter ) const { 80 os << "Address of label:" << arg; 81 81 } 82 82 -
src/SynTree/AggregateDecl.cc
ra8555c5 r50377a4 41 41 } 42 42 43 void AggregateDecl::print( std::ostream &os, intindent ) const {43 void AggregateDecl::print( std::ostream &os, Indenter indent ) const { 44 44 using std::string; 45 45 using std::endl; 46 46 47 os << typeString() << " " << get_name()<< ":";47 os << typeString() << " " << name << ":"; 48 48 if ( get_linkage() != LinkageSpec::Cforall ) { 49 os << " " << LinkageSpec::linkageName( get_linkage());49 os << " " << LinkageSpec::linkageName( linkage ); 50 50 } // if 51 os << " with body " << has_body() << endl;51 os << " with body " << has_body(); 52 52 53 53 if ( ! parameters.empty() ) { 54 os << endl << string( indent+2, ' ' ) << "with parameters" << endl;55 printAll( parameters, os, indent+ 4);54 os << endl << indent << "... with parameters" << endl; 55 printAll( parameters, os, indent+1 ); 56 56 } // if 57 57 if ( ! members.empty() ) { 58 os << endl << string( indent+2, ' ' ) << "with members" << endl;59 printAll( members, os, indent+ 4);58 os << endl << indent << "... with members" << endl; 59 printAll( members, os, indent+1 ); 60 60 } // if 61 61 if ( ! attributes.empty() ) { 62 os << endl << string( indent+2, ' ' ) << "with attributes" << endl;63 printAll( attributes, os, indent+ 4);62 os << endl << indent << "... with attributes" << endl; 63 printAll( attributes, os, indent+1 ); 64 64 } // if 65 os << endl; 65 66 } 66 67 67 void AggregateDecl::printShort( std::ostream &os, intindent ) const {68 void AggregateDecl::printShort( std::ostream &os, Indenter indent ) const { 68 69 using std::string; 69 70 using std::endl; 70 71 71 os << typeString() << " " << get_name(); 72 os << string( indent+2, ' ' ) << "with body " << has_body() << endl; 72 os << typeString() << " " << name << " with body " << has_body() << endl; 73 73 74 74 if ( ! parameters.empty() ) { 75 os << endl << string( indent+2, ' ' ) << "with parameters" << endl;76 printAll( parameters, os, indent+ 4);75 os << indent << "... with parameters" << endl; 76 printAll( parameters, os, indent+1 ); 77 77 } // if 78 78 } -
src/SynTree/ApplicationExpr.cc
ra8555c5 r50377a4 68 68 } 69 69 70 void printInferParams( const InferredParams & inferParams, std::ostream &os, intindent, int level ) {70 void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) { 71 71 if ( ! inferParams.empty() ) { 72 os << std::string(indent, ' ')<< "with inferred parameters " << level << ":" << std::endl;72 os << indent << "with inferred parameters " << level << ":" << std::endl; 73 73 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) { 74 os << std::string(indent+2, ' ');75 Declaration::declFromId( i->second.decl )->printShort( os, indent+ 2);74 os << indent+1; 75 Declaration::declFromId( i->second.decl )->printShort( os, indent+1 ); 76 76 os << std::endl; 77 printInferParams( *i->second.inferParams, os, indent+ 2, level+1 );77 printInferParams( *i->second.inferParams, os, indent+1, level+1 ); 78 78 } // for 79 79 } // if 80 80 } 81 81 82 void ApplicationExpr::print( std::ostream &os, int indent ) const { 83 os << "Application of" << std::endl << std::string(indent+2, ' '); 84 function->print( os, indent+2 ); 82 void ApplicationExpr::print( std::ostream &os, Indenter indent ) const { 83 os << "Application of" << std::endl << indent+1; 84 function->print( os, indent+1 ); 85 os << std::endl; 85 86 if ( ! args.empty() ) { 86 os << std::string( indent, ' ' ) << "to arguments" << std::endl;87 printAll( args, os, indent+ 2);87 os << indent << "... to arguments" << std::endl; 88 printAll( args, os, indent+1 ); 88 89 } // if 89 printInferParams( inferParams, os, indent+ 2, 0 );90 printInferParams( inferParams, os, indent+1, 0 ); 90 91 Expression::print( os, indent ); 91 92 } -
src/SynTree/ArrayType.cc
ra8555c5 r50377a4 39 39 } 40 40 41 void ArrayType::print( std::ostream &os, intindent ) const {41 void ArrayType::print( std::ostream &os, Indenter indent ) const { 42 42 Type::print( os, indent ); 43 43 if ( isStatic ) { -
src/SynTree/AttrType.cc
ra8555c5 r50377a4 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AttrType.cc.cc -- 7 // AttrType.cc.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 42 42 } 43 43 44 void AttrType::print( std::ostream &os, intindent ) const {44 void AttrType::print( std::ostream &os, Indenter indent ) const { 45 45 Type::print( os, indent ); 46 46 os << "attribute " << name << " applied to "; -
src/SynTree/Attribute.cc
ra8555c5 r50377a4 28 28 } 29 29 30 void Attribute::print( std::ostream &os, intindent ) const {30 void Attribute::print( std::ostream &os, Indenter indent ) const { 31 31 using std::endl; 32 32 using std::string; … … 36 36 if ( ! parameters.empty() ) { 37 37 os << " with parameters: " << endl; 38 printAll( parameters, os, indent );38 printAll( parameters, os, indent+1 ); 39 39 } 40 40 } -
src/SynTree/Attribute.h
ra8555c5 r50377a4 46 46 virtual void accept( Visitor & v ) override { v.visit( this ); } 47 47 virtual Attribute * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 48 virtual void print( std::ostream & os, int indent = 0) const override;48 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 49 49 }; 50 50 -
src/SynTree/BaseSyntaxNode.h
ra8555c5 r50377a4 17 17 18 18 #include "Common/CodeLocation.h" 19 #include "Common/Indenter.h" 19 20 class Visitor; 20 21 class Mutator; … … 29 30 virtual void accept( Visitor & v ) = 0; 30 31 virtual BaseSyntaxNode * acceptMutator( Mutator & m ) = 0; 31 virtual void print( std::ostream & os, int indent = 0 ) const = 0; 32 /// Notes: 33 /// * each node is responsible for indenting its children. 34 /// * Expressions should not finish with a newline, since the expression's parent has better information. 35 virtual void print( std::ostream & os, Indenter indent = {} ) const = 0; 36 void print( std::ostream & os, unsigned int indent ) { 37 print( os, Indenter{ Indenter::tabsize, indent }); 38 } 32 39 }; 33 40 -
src/SynTree/BasicType.cc
ra8555c5 r50377a4 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // BasicType.cc -- 7 // BasicType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 24 24 BasicType::BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), kind( bt ) {} 25 25 26 void BasicType::print( std::ostream &os, intindent ) const {26 void BasicType::print( std::ostream &os, Indenter indent ) const { 27 27 Type::print( os, indent ); 28 28 os << BasicType::typeNames[ kind ]; -
src/SynTree/CommaExpr.cc
ra8555c5 r50377a4 39 39 } 40 40 41 void CommaExpr::print( std::ostream &os, intindent ) const {41 void CommaExpr::print( std::ostream &os, Indenter indent ) const { 42 42 os << "Comma Expression:" << std::endl; 43 os << std::string( indent+2, ' ');44 arg1->print( os, indent+ 2);43 os << (indent+1); 44 arg1->print( os, indent+1 ); 45 45 os << std::endl; 46 os << std::string( indent+2, ' ');47 arg2->print( os, indent+ 2);46 os << (indent+1); 47 arg2->print( os, indent+1 ); 48 48 Expression::print( os, indent ); 49 49 } -
src/SynTree/CompoundStmt.cc
ra8555c5 r50377a4 73 73 } 74 74 75 void CompoundStmt::print( std::ostream &os, intindent ) const {76 os << "CompoundStmt" << endl 77 printAll( kids, os, indent + 2);75 void CompoundStmt::print( std::ostream &os, Indenter indent ) const { 76 os << "CompoundStmt" << endl; 77 printAll( kids, os, indent+1 ); 78 78 } 79 79 -
src/SynTree/DeclStmt.cc
ra8555c5 r50377a4 33 33 } 34 34 35 void DeclStmt::print( std::ostream &os, intindent ) const {35 void DeclStmt::print( std::ostream &os, Indenter indent ) const { 36 36 assert( decl != 0 ); 37 37 os << "Declaration of "; -
src/SynTree/Declaration.cc
ra8555c5 r50377a4 70 70 } 71 71 72 void AsmDecl::print( std::ostream &os, intindent ) const {72 void AsmDecl::print( std::ostream &os, Indenter indent ) const { 73 73 stmt->print( os, indent ); 74 74 } 75 75 76 void AsmDecl::printShort( std::ostream &os, intindent ) const {76 void AsmDecl::printShort( std::ostream &os, Indenter indent ) const { 77 77 stmt->print( os, indent ); 78 78 } -
src/SynTree/Declaration.h
ra8555c5 r50377a4 64 64 virtual void accept( Visitor &v ) override = 0; 65 65 virtual Declaration *acceptMutator( Mutator &m ) override = 0; 66 virtual void print( std::ostream &os, int indent = 0) const override = 0;67 virtual void printShort( std::ostream &os, int indent = 0) const = 0;66 virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0; 67 virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0; 68 68 69 69 static void dumpIds( std::ostream &os ); … … 142 142 virtual void accept( Visitor &v ) override { v.visit( this ); } 143 143 virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 144 virtual void print( std::ostream &os, int indent = 0) const override;145 virtual void printShort( std::ostream &os, int indent = 0) const override;144 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 145 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 146 146 }; 147 147 … … 170 170 virtual void accept( Visitor &v ) override { v.visit( this ); } 171 171 virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 172 virtual void print( std::ostream &os, int indent = 0) const override;173 virtual void printShort( std::ostream &os, int indent = 0) const override;172 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 173 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 174 174 }; 175 175 … … 193 193 194 194 virtual NamedTypeDecl *clone() const override = 0; 195 virtual void print( std::ostream &os, int indent = 0) const override;196 virtual void printShort( std::ostream &os, int indent = 0) const override;195 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 196 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 197 197 }; 198 198 … … 235 235 virtual void accept( Visitor &v ) override { v.visit( this ); } 236 236 virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 237 virtual void print( std::ostream &os, int indent = 0) const override;237 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 238 238 239 239 private: … … 276 276 AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; } 277 277 278 virtual void print( std::ostream &os, int indent = 0) const override;279 virtual void printShort( std::ostream &os, int indent = 0) const override;278 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 279 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 280 280 protected: 281 281 virtual std::string typeString() const = 0; … … 355 355 virtual void accept( Visitor &v ) override { v.visit( this ); } 356 356 virtual AsmDecl *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 357 virtual void print( std::ostream &os, int indent = 0) const override;358 virtual void printShort( std::ostream &os, int indent = 0) const override;357 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 358 virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; 359 359 }; 360 360 -
src/SynTree/Expression.cc
ra8555c5 r50377a4 44 44 } 45 45 46 void Expression::print( std::ostream &os, intindent ) const {46 void Expression::print( std::ostream &os, Indenter indent ) const { 47 47 if ( env ) { 48 os << std:: string( indent, ' ' ) << "with environment:" << std::endl;49 env->print( os, indent+ 2);48 os << std::endl << indent << "... with environment:" << std::endl; 49 env->print( os, indent+1 ); 50 50 } // if 51 51 52 if ( argName ) {53 os << std::string( indent, ' ' ) << "with designator:";54 argName->print( os, indent+2 );55 } // if56 57 52 if ( extension ) { 58 os << std:: string( indent, ' ' ) << "with extension:";53 os << std::endl << indent << "... with extension:"; 59 54 } // if 60 55 } … … 69 64 ConstantExpr::~ConstantExpr() {} 70 65 71 void ConstantExpr::print( std::ostream &os, intindent ) const {66 void ConstantExpr::print( std::ostream &os, Indenter indent ) const { 72 67 os << "constant expression " ; 73 68 constant.print( os ); … … 96 91 } 97 92 98 void VariableExpr::print( std::ostream &os, intindent ) const {93 void VariableExpr::print( std::ostream &os, Indenter indent ) const { 99 94 os << "Variable Expression: "; 100 101 Declaration *decl = get_var(); 102 if ( decl != 0) decl->printShort(os, indent + 2); 103 os << std::endl; 95 var->printShort(os, indent); 104 96 Expression::print( os, indent ); 105 97 } … … 124 116 } 125 117 126 void SizeofExpr::print( std::ostream &os, intindent) const {118 void SizeofExpr::print( std::ostream &os, Indenter indent) const { 127 119 os << "Sizeof Expression on: "; 128 129 if (isType) 130 type->print(os, indent + 2); 131 else 132 expr->print(os, indent + 2); 133 134 os << std::endl; 120 if (isType) type->print(os, indent+1); 121 else expr->print(os, indent+1); 135 122 Expression::print( os, indent ); 136 123 } … … 155 142 } 156 143 157 void AlignofExpr::print( std::ostream &os, intindent) const {144 void AlignofExpr::print( std::ostream &os, Indenter indent) const { 158 145 os << "Alignof Expression on: "; 159 160 if (isType) 161 type->print(os, indent + 2); 162 else 163 expr->print(os, indent + 2); 164 165 os << std::endl; 166 Expression::print( os, indent ); 167 } 168 169 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) : 170 Expression( _aname ), type(type_), member(member_) { 146 if (isType) type->print(os, indent+1); 147 else expr->print(os, indent+1); 148 Expression::print( os, indent ); 149 } 150 151 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member, Expression *_aname ) : 152 Expression( _aname ), type(type), member(member) { 153 assert( type ); 171 154 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 172 155 } … … 179 162 } 180 163 181 void UntypedOffsetofExpr::print( std::ostream &os, int indent) const { 182 os << std::string( indent, ' ' ) << "Untyped Offsetof Expression on member " << member << " of "; 183 184 if ( type ) { 185 type->print(os, indent + 2); 186 } else { 187 os << "<NULL>"; 188 } 189 190 os << std::endl; 191 Expression::print( os, indent ); 192 } 193 194 OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) : 195 Expression( _aname ), type(type_), member(member_) { 164 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const { 165 os << "Untyped Offsetof Expression on member " << member << " of "; 166 type->print(os, indent+1); 167 Expression::print( os, indent ); 168 } 169 170 OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname ) : 171 Expression( _aname ), type(type), member(member) { 172 assert( member ); 173 assert( type ); 196 174 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 197 175 } … … 204 182 } 205 183 206 void OffsetofExpr::print( std::ostream &os, int indent) const { 207 os << std::string( indent, ' ' ) << "Offsetof Expression on member "; 208 209 if ( member ) { 210 os << member->get_name(); 211 } else { 212 os << "<NULL>"; 213 } 214 215 os << " of "; 216 217 if ( type ) { 218 type->print(os, indent + 2); 219 } else { 220 os << "<NULL>"; 221 } 222 223 os << std::endl; 224 Expression::print( os, indent ); 225 } 226 227 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 184 void OffsetofExpr::print( std::ostream &os, Indenter indent) const { 185 os << "Offsetof Expression on member " << member->name << " of "; 186 type->print(os, indent+1); 187 Expression::print( os, indent ); 188 } 189 190 OffsetPackExpr::OffsetPackExpr( StructInstType *type, Expression *aname_ ) : Expression( aname_ ), type( type ) { 191 assert( type ); 228 192 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 229 193 } … … 233 197 OffsetPackExpr::~OffsetPackExpr() { delete type; } 234 198 235 void OffsetPackExpr::print( std::ostream &os, int indent ) const { 236 os << std::string( indent, ' ' ) << "Offset pack expression on "; 237 238 if ( type ) { 239 type->print(os, indent + 2); 240 } else { 241 os << "<NULL>"; 242 } 243 244 os << std::endl; 199 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const { 200 os << "Offset pack expression on "; 201 type->print(os, indent+1); 245 202 Expression::print( os, indent ); 246 203 } … … 264 221 } 265 222 266 void AttrExpr::print( std::ostream &os, intindent) const {223 void AttrExpr::print( std::ostream &os, Indenter indent) const { 267 224 os << "Attr "; 268 attr->print( os, indent + 2);225 attr->print( os, indent+1); 269 226 if ( isType || expr ) { 270 227 os << "applied to: "; 271 272 if (isType) 273 type->print(os, indent + 2); 274 else 275 expr->print(os, indent + 2); 228 if (isType) type->print(os, indent+1); 229 else expr->print(os, indent+1); 276 230 } // if 277 278 os << std::endl;279 231 Expression::print( os, indent ); 280 232 } … … 295 247 } 296 248 297 void CastExpr::print( std::ostream &os, int indent ) const { 298 os << "Cast of:" << std::endl << std::string( indent+2, ' ' ); 299 arg->print(os, indent+2); 300 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 301 os << std::string( indent+2, ' ' ); 249 void CastExpr::print( std::ostream &os, Indenter indent ) const { 250 os << "Cast of:" << std::endl << indent+1; 251 arg->print(os, indent+1); 252 os << std::endl << indent << "... to:"; 302 253 if ( result->isVoid() ) { 303 os << " nothing";254 os << " nothing"; 304 255 } else { 305 result->print( os, indent+2 ); 256 os << std::endl << indent+1; 257 result->print( os, indent+1 ); 306 258 } // if 307 os << std::endl;308 259 Expression::print( os, indent ); 309 260 } … … 320 271 } 321 272 322 void VirtualCastExpr::print( std::ostream &os, int indent ) const { 323 os << "Virtual Cast of:" << std::endl << std::string( indent+2, ' ' ); 324 arg->print(os, indent+2); 325 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 326 os << std::string( indent+2, ' ' ); 273 void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const { 274 os << "Virtual Cast of:" << std::endl << indent+1; 275 arg->print(os, indent+1); 276 os << std::endl << indent << "... to:"; 327 277 if ( ! result ) { 328 os << " unknown";278 os << " unknown"; 329 279 } else { 330 result->print( os, indent+2 ); 280 os << std::endl << indent+1; 281 result->print( os, indent+1 ); 331 282 } // if 332 os << std::endl; 333 Expression::print( os, indent ); 334 } 335 336 UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) : 337 Expression( _aname ), member(_member), aggregate(_aggregate) {} 283 Expression::print( os, indent ); 284 } 285 286 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate, Expression *_aname ) : 287 Expression( _aname ), member(member), aggregate(aggregate) { 288 assert( aggregate ); 289 } 338 290 339 291 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) : … … 346 298 } 347 299 348 void UntypedMemberExpr::print( std::ostream &os, int indent ) const { 349 os << "Untyped Member Expression, with field: " << std::endl; 350 os << std::string( indent+2, ' ' ); 351 get_member()->print(os, indent+4); 352 os << std::string( indent+2, ' ' ); 353 354 Expression *agg = get_aggregate(); 355 os << "from aggregate: " << std::endl; 356 if (agg != 0) { 357 os << std::string( indent + 4, ' ' ); 358 agg->print(os, indent + 4); 359 } 360 os << std::string( indent+2, ' ' ); 300 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 301 os << "Untyped Member Expression, with field: " << std::endl << indent+1; 302 member->print(os, indent+1 ); 303 os << indent << "... from aggregate: " << std::endl << indent+1; 304 aggregate->print(os, indent+1); 361 305 Expression::print( os, indent ); 362 306 } … … 377 321 378 322 379 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 380 Expression( _aname ), member(_member), aggregate(_aggregate) { 323 MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname ) : 324 Expression( _aname ), member(member), aggregate(aggregate) { 325 assert( member ); 326 assert( aggregate ); 381 327 382 328 TypeSubstitution sub( makeSub( aggregate->get_result() ) ); … … 396 342 } 397 343 398 void MemberExpr::print( std::ostream &os, intindent ) const {344 void MemberExpr::print( std::ostream &os, Indenter indent ) const { 399 345 os << "Member Expression, with field: " << std::endl; 400 401 assert( member ); 402 os << std::string( indent + 2, ' ' ); 403 member->print( os, indent + 2 ); 404 os << std::endl; 405 406 Expression *agg = get_aggregate(); 407 os << std::string( indent, ' ' ) << "from aggregate: " << std::endl; 408 if (agg != 0) { 409 os << std::string( indent + 2, ' ' ); 410 agg->print(os, indent + 2); 411 } 412 os << std::string( indent+2, ' ' ); 346 os << indent+1; 347 member->print( os, indent+1 ); 348 os << std::endl << indent << "... from aggregate: " << std::endl << indent+1; 349 aggregate->print(os, indent + 1); 413 350 Expression::print( os, indent ); 414 351 } … … 456 393 457 394 458 void UntypedExpr::print( std::ostream &os, intindent ) const {395 void UntypedExpr::print( std::ostream &os, Indenter indent ) const { 459 396 os << "Applying untyped: " << std::endl; 460 os << std::string( indent+2, ' ' ); 461 function->print(os, indent + 2); 462 os << std::string( indent, ' ' ) << "...to: " << std::endl; 463 printAll(args, os, indent + 2); 464 Expression::print( os, indent ); 465 } 466 467 void UntypedExpr::printArgs( std::ostream &os, int indent ) const { 468 std::list<Expression *>::const_iterator i; 469 for (i = args.begin(); i != args.end(); i++) { 470 os << std::string(indent, ' ' ); 471 (*i)->print(os, indent); 472 } 473 } 474 475 NameExpr::NameExpr( std::string _name, Expression *_aname ) : Expression( _aname ), name(_name) { 476 assertf(_name != "0", "Zero is not a valid name\n"); 477 assertf(_name != "1", "One is not a valid name\n"); 397 os << indent+1; 398 function->print(os, indent+1); 399 os << std::endl << indent << "...to: " << std::endl; 400 printAll(args, os, indent+1); 401 Expression::print( os, indent ); 402 } 403 404 NameExpr::NameExpr( std::string name, Expression *_aname ) : Expression( _aname ), name(name) { 405 assertf(name != "0", "Zero is not a valid name"); 406 assertf(name != "1", "One is not a valid name"); 478 407 } 479 408 … … 483 412 NameExpr::~NameExpr() {} 484 413 485 void NameExpr::print( std::ostream &os, intindent ) const {486 os << "Name: " << get_name() << std::endl;414 void NameExpr::print( std::ostream &os, Indenter indent ) const { 415 os << "Name: " << get_name(); 487 416 Expression::print( os, indent ); 488 417 } … … 502 431 } 503 432 504 void LogicalExpr::print( std::ostream &os, intindent )const {505 os << "Short-circuited operation (" << (isAnd ?"and":"or") << ") on: ";433 void LogicalExpr::print( std::ostream &os, Indenter indent )const { 434 os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: "; 506 435 arg1->print(os); 507 436 os << " and "; 508 437 arg2->print(os); 509 os << std::endl; 510 Expression::print( os, indent ); 511 } 512 513 ConditionalExpr::ConditionalExpr( Expression *arg1_, Expression *arg2_, Expression *arg3_, Expression *_aname ) : 514 Expression( _aname ), arg1(arg1_), arg2(arg2_), arg3(arg3_) {} 438 Expression::print( os, indent ); 439 } 440 441 ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname ) : 442 Expression( _aname ), arg1(arg1), arg2(arg2), arg3(arg3) {} 515 443 516 444 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : … … 524 452 } 525 453 526 void ConditionalExpr::print( std::ostream &os, int indent ) const { 527 os << "Conditional expression on: " << std::endl; 528 os << std::string( indent+2, ' ' ); 529 arg1->print( os, indent+2 ); 530 os << std::string( indent, ' ' ) << "First alternative:" << std::endl; 531 os << std::string( indent+2, ' ' ); 532 arg2->print( os, indent+2 ); 533 os << std::string( indent, ' ' ) << "Second alternative:" << std::endl; 534 os << std::string( indent+2, ' ' ); 535 arg3->print( os, indent+2 ); 536 os << std::endl; 454 void ConditionalExpr::print( std::ostream &os, Indenter indent ) const { 455 os << "Conditional expression on: " << std::endl << indent+1; 456 arg1->print( os, indent+1 ); 457 os << indent << "First alternative:" << std::endl << indent+1; 458 arg2->print( os, indent+1 ); 459 os << indent << "Second alternative:" << std::endl << indent+1; 460 arg3->print( os, indent+1 ); 537 461 Expression::print( os, indent ); 538 462 } … … 541 465 542 466 543 void AsmExpr::print( std::ostream &os, intindent ) const {467 void AsmExpr::print( std::ostream &os, Indenter indent ) const { 544 468 os << "Asm Expression: " << std::endl; 545 if ( inout ) inout->print( os, indent + 2);546 if ( constraint ) constraint->print( os, indent + 2);547 if ( operand ) operand->print( os, indent + 2);469 if ( inout ) inout->print( os, indent+1 ); 470 if ( constraint ) constraint->print( os, indent+1 ); 471 if ( operand ) operand->print( os, indent+1 ); 548 472 } 549 473 … … 551 475 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) { 552 476 assert( callExpr ); 553 assert( callExpr-> has_result());477 assert( callExpr->result ); 554 478 set_result( callExpr->get_result()->clone() ); 555 479 } … … 569 493 } 570 494 571 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const { 572 os << "Implicit Copy Constructor Expression: " << std::endl; 573 assert( callExpr ); 574 os << std::string( indent+2, ' ' ); 575 callExpr->print( os, indent + 2 ); 576 os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl; 577 printAll(tempDecls, os, indent+2); 578 os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl; 579 printAll(returnDecls, os, indent+2); 495 void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const { 496 os << "Implicit Copy Constructor Expression: " << std::endl << indent+1; 497 callExpr->print( os, indent+1 ); 498 os << std::endl << indent << "... with temporaries:" << std::endl; 499 printAll( tempDecls, os, indent+1 ); 500 os << std::endl << indent << "... with return temporaries:" << std::endl; 501 printAll( returnDecls, os, indent+1 ); 580 502 Expression::print( os, indent ); 581 503 } … … 587 509 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 588 510 assert( arg ); 589 set_result( maybeClone( arg-> get_result()) );511 set_result( maybeClone( arg->result ) ); 590 512 } 591 513 … … 597 519 } 598 520 599 void ConstructorExpr::print( std::ostream &os, int indent ) const { 600 os << "Constructor Expression: " << std::endl; 601 assert( callExpr ); 602 os << std::string( indent+2, ' ' ); 521 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 522 os << "Constructor Expression: " << std::endl << indent+1; 603 523 callExpr->print( os, indent + 2 ); 604 524 Expression::print( os, indent ); … … 618 538 } 619 539 620 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 621 os << "Compound Literal Expression: " << std::endl; 622 os << std::string( indent+2, ' ' ); 623 get_result()->print( os, indent + 2 ); 624 os << std::string( indent+2, ' ' ); 625 initializer->print( os, indent + 2 ); 540 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { 541 os << "Compound Literal Expression: " << std::endl << indent+1; 542 result->print( os, indent+1 ); 543 os << indent+1; 544 initializer->print( os, indent+1 ); 626 545 Expression::print( os, indent ); 627 546 } … … 629 548 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 630 549 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} 631 void RangeExpr::print( std::ostream &os, intindent ) const {550 void RangeExpr::print( std::ostream &os, Indenter indent ) const { 632 551 os << "Range Expression: "; 633 552 low->print( os, indent ); … … 659 578 deleteAll( returnDecls ); 660 579 } 661 void StmtExpr::print( std::ostream &os, intindent ) const {662 os << "Statement Expression: " << std::endl << std::string( indent, ' ' );663 statements->print( os, indent+ 2);580 void StmtExpr::print( std::ostream &os, Indenter indent ) const { 581 os << "Statement Expression: " << std::endl << indent+1; 582 statements->print( os, indent+1 ); 664 583 if ( ! returnDecls.empty() ) { 665 os << std::string( indent+2, ' ' ) << "with returnDecls: ";666 printAll( returnDecls, os, indent+ 2);584 os << indent+1 << "... with returnDecls: "; 585 printAll( returnDecls, os, indent+1 ); 667 586 } 668 587 if ( ! dtors.empty() ) { 669 os << std::string( indent+2, ' ' ) << "with dtors: ";670 printAll( dtors, os, indent+ 2);588 os << indent+1 << "... with dtors: "; 589 printAll( dtors, os, indent+1 ); 671 590 } 672 591 Expression::print( os, indent ); … … 690 609 delete var; 691 610 } 692 void UniqueExpr::print( std::ostream &os, intindent ) const {693 os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' );694 get_expr()->print( os, indent+2);695 if ( get_object()) {696 os << std::string( indent+2, ' ' ) << "with decl: ";697 get_object()->printShort( os, indent+ 2);611 void UniqueExpr::print( std::ostream &os, Indenter indent ) const { 612 os << "Unique Expression with id:" << id << std::endl << indent+1; 613 expr->print( os, indent+1 ); 614 if ( object ) { 615 os << indent << "... with decl: "; 616 get_object()->printShort( os, indent+1 ); 698 617 } 699 618 Expression::print( os, indent ); … … 713 632 } 714 633 715 void UntypedInitExpr::print( std::ostream & os, intindent ) const {716 os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );717 expr->print( os, indent+ 2);634 void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const { 635 os << "Untyped Init Expression" << std::endl << indent+1; 636 expr->print( os, indent+1 ); 718 637 if ( ! initAlts.empty() ) { 719 638 for ( const InitAlternative & alt : initAlts ) { 720 os << std::string( indent+2, ' ' )<< "InitAlternative: ";721 alt.type->print( os, indent+ 2);722 alt.designation->print( os, indent+ 2);639 os << indent+1 << "InitAlternative: "; 640 alt.type->print( os, indent+1 ); 641 alt.designation->print( os, indent+1 ); 723 642 } 724 643 } … … 734 653 } 735 654 736 void InitExpr::print( std::ostream & os, intindent ) const {737 os << "Init Expression" << std::endl << std::string( indent+2, ' ' );738 expr->print( os, indent+ 2);739 os << std::string( indent+2, ' ' ) << "with designation: ";740 designation->print( os, indent+ 2);655 void InitExpr::print( std::ostream & os, Indenter indent ) const { 656 os << "Init Expression" << std::endl << indent+1; 657 expr->print( os, indent+1 ); 658 os << indent+1 << "... with designation: "; 659 designation->print( os, indent+1 ); 741 660 } 742 661 -
src/SynTree/Expression.h
ra8555c5 r50377a4 58 58 virtual void accept( Visitor & v ) override = 0; 59 59 virtual Expression * acceptMutator( Mutator & m ) override = 0; 60 virtual void print( std::ostream & os, int indent = 0) const override;60 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 61 61 }; 62 62 … … 101 101 virtual void accept( Visitor & v ) { v.visit( this ); } 102 102 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 103 virtual void print( std::ostream & os, int indent = 0) const;103 virtual void print( std::ostream & os, Indenter indent = {} ) const; 104 104 }; 105 105 … … 119 119 void set_function( Expression * newValue ) { function = newValue; } 120 120 121 void set_args( std::list<Expression *> & listArgs ) { args = listArgs; }122 121 std::list<Expression*>::iterator begin_args() { return args.begin(); } 123 122 std::list<Expression*>::iterator end_args() { return args.end(); } … … 130 129 virtual void accept( Visitor & v ) { v.visit( this ); } 131 130 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 132 virtual void print( std::ostream & os, int indent = 0 ) const; 133 virtual void printArgs(std::ostream & os, int indent = 0) const; 131 virtual void print( std::ostream & os, Indenter indent = {} ) const; 134 132 }; 135 133 … … 149 147 virtual void accept( Visitor & v ) { v.visit( this ); } 150 148 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 151 virtual void print( std::ostream & os, int indent = 0) const;149 virtual void print( std::ostream & os, Indenter indent = {} ) const; 152 150 }; 153 151 … … 170 168 virtual void accept( Visitor & v ) { v.visit( this ); } 171 169 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 172 virtual void print( std::ostream & os, int indent = 0) const;170 virtual void print( std::ostream & os, Indenter indent = {} ) const; 173 171 }; 174 172 … … 186 184 virtual void accept( Visitor & v ) { v.visit( this ); } 187 185 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 188 virtual void print( std::ostream & os, int indent = 0) const;186 virtual void print( std::ostream & os, Indenter indent = {} ) const; 189 187 }; 190 188 … … 205 203 virtual void accept( Visitor & v ) { v.visit( this ); } 206 204 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 207 virtual void print( std::ostream & os, int indent = 0) const;205 virtual void print( std::ostream & os, Indenter indent = {} ) const; 208 206 }; 209 207 … … 223 221 virtual void accept( Visitor & v ) { v.visit( this ); } 224 222 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 225 virtual void print( std::ostream & os, int indent = 0) const;223 virtual void print( std::ostream & os, Indenter indent = {} ) const; 226 224 }; 227 225 … … 244 242 virtual void accept( Visitor & v ) { v.visit( this ); } 245 243 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 246 virtual void print( std::ostream & os, int indent = 0) const;244 virtual void print( std::ostream & os, Indenter indent = {} ) const; 247 245 }; 248 246 … … 266 264 virtual void accept( Visitor & v ) { v.visit( this ); } 267 265 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 268 virtual void print( std::ostream & os, int indent = 0) const;266 virtual void print( std::ostream & os, Indenter indent = {} ) const; 269 267 }; 270 268 … … 287 285 virtual void accept( Visitor & v ) { v.visit( this ); } 288 286 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 289 virtual void print( std::ostream & os, int indent = 0) const;287 virtual void print( std::ostream & os, Indenter indent = {} ) const; 290 288 }; 291 289 … … 305 303 virtual void accept( Visitor & v ) { v.visit( this ); } 306 304 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 307 virtual void print( std::ostream & os, int indent = 0) const;305 virtual void print( std::ostream & os, Indenter indent = {} ) const; 308 306 }; 309 307 … … 330 328 virtual void accept( Visitor & v ) { v.visit( this ); } 331 329 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 332 virtual void print( std::ostream & os, int indent = 0) const;330 virtual void print( std::ostream & os, Indenter indent = {} ) const; 333 331 }; 334 332 … … 355 353 virtual void accept( Visitor & v ) { v.visit( this ); } 356 354 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 357 virtual void print( std::ostream & os, int indent = 0) const;355 virtual void print( std::ostream & os, Indenter indent = {} ) const; 358 356 }; 359 357 … … 376 374 virtual void accept( Visitor & v ) { v.visit( this ); } 377 375 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 378 virtual void print( std::ostream & os, int indent = 0) const;376 virtual void print( std::ostream & os, Indenter indent = {} ) const; 379 377 }; 380 378 … … 397 395 virtual void accept( Visitor & v ) { v.visit( this ); } 398 396 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 399 virtual void print( std::ostream & os, int indent = 0) const;397 virtual void print( std::ostream & os, Indenter indent = {} ) const; 400 398 }; 401 399 … … 415 413 virtual void accept( Visitor & v ) { v.visit( this ); } 416 414 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 417 virtual void print( std::ostream & os, int indent = 0) const;415 virtual void print( std::ostream & os, Indenter indent = {} ) const; 418 416 }; 419 417 … … 443 441 virtual void accept( Visitor & v ) { v.visit( this ); } 444 442 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 445 virtual void print( std::ostream & os, int indent = 0) const;443 virtual void print( std::ostream & os, Indenter indent = {} ) const; 446 444 }; 447 445 … … 465 463 virtual void accept( Visitor & v ) { v.visit( this ); } 466 464 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 467 virtual void print( std::ostream & os, int indent = 0) const;465 virtual void print( std::ostream & os, Indenter indent = {} ) const; 468 466 469 467 private: … … 492 490 virtual void accept( Visitor & v ) { v.visit( this ); } 493 491 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 494 virtual void print( std::ostream & os, int indent = 0) const;492 virtual void print( std::ostream & os, Indenter indent = {} ) const; 495 493 }; 496 494 … … 513 511 virtual void accept( Visitor & v ) { v.visit( this ); } 514 512 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 515 virtual void print( std::ostream & os, int indent = 0) const;513 virtual void print( std::ostream & os, Indenter indent = {} ) const; 516 514 }; 517 515 … … 531 529 virtual void accept( Visitor & v ) { v.visit( this ); } 532 530 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 533 virtual void print( std::ostream & os, int indent = 0) const;531 virtual void print( std::ostream & os, Indenter indent = {} ) const; 534 532 }; 535 533 … … 557 555 virtual void accept( Visitor & v ) { v.visit( this ); } 558 556 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 559 virtual void print( std::ostream & os, int indent = 0) const;557 virtual void print( std::ostream & os, Indenter indent = {} ) const; 560 558 561 559 // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints … … 585 583 virtual void accept( Visitor & v ) { v.visit( this ); } 586 584 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 587 virtual void print( std::ostream & os, int indent = 0) const;585 virtual void print( std::ostream & os, Indenter indent = {} ) const; 588 586 }; 589 587 … … 603 601 virtual void accept( Visitor & v ) { v.visit( this ); } 604 602 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 605 virtual void print( std::ostream & os, int indent = 0) const;603 virtual void print( std::ostream & os, Indenter indent = {} ) const; 606 604 }; 607 605 … … 621 619 virtual void accept( Visitor & v ) { v.visit( this ); } 622 620 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 623 virtual void print( std::ostream & os, int indent = 0) const;621 virtual void print( std::ostream & os, Indenter indent = {} ) const; 624 622 }; 625 623 … … 640 638 virtual void accept( Visitor & v ) { v.visit( this ); } 641 639 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 642 virtual void print( std::ostream & os, int indent = 0) const;640 virtual void print( std::ostream & os, Indenter indent = {} ) const; 643 641 }; 644 642 … … 657 655 virtual void accept( Visitor & v ) { v.visit( this ); } 658 656 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 659 virtual void print( std::ostream & os, int indent = 0) const;657 virtual void print( std::ostream & os, Indenter indent = {} ) const; 660 658 }; 661 659 … … 674 672 virtual void accept( Visitor & v ) { v.visit( this ); } 675 673 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 676 virtual void print( std::ostream & os, int indent = 0) const;674 virtual void print( std::ostream & os, Indenter indent = {} ) const; 677 675 }; 678 676 … … 695 693 virtual void accept( Visitor & v ) { v.visit( this ); } 696 694 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 697 virtual void print( std::ostream & os, int indent = 0) const;695 virtual void print( std::ostream & os, Indenter indent = {} ) const; 698 696 }; 699 697 … … 713 711 virtual void accept( Visitor & v ) { v.visit( this ); } 714 712 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 715 virtual void print( std::ostream & os, int indent = 0) const;713 virtual void print( std::ostream & os, Indenter indent = {} ) const; 716 714 }; 717 715 … … 736 734 virtual void accept( Visitor & v ) { v.visit( this ); } 737 735 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 738 virtual void print( std::ostream & os, int indent = 0) const;736 virtual void print( std::ostream & os, Indenter indent = {} ) const; 739 737 }; 740 738 … … 763 761 virtual void accept( Visitor & v ) { v.visit( this ); } 764 762 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 765 virtual void print( std::ostream & os, int indent = 0) const;763 virtual void print( std::ostream & os, Indenter indent = {} ) const; 766 764 767 765 private: … … 797 795 virtual void accept( Visitor & v ) { v.visit( this ); } 798 796 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 799 virtual void print( std::ostream & os, int indent = 0) const;797 virtual void print( std::ostream & os, Indenter indent = {} ) const; 800 798 }; 801 799 … … 818 816 virtual void accept( Visitor & v ) { v.visit( this ); } 819 817 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 820 virtual void print( std::ostream & os, int indent = 0) const;818 virtual void print( std::ostream & os, Indenter indent = {} ) const; 821 819 }; 822 820 -
src/SynTree/FunctionDecl.cc
ra8555c5 r50377a4 63 63 } 64 64 65 void FunctionDecl::print( std::ostream &os, intindent ) const {65 void FunctionDecl::print( std::ostream &os, Indenter indent ) const { 66 66 using std::endl; 67 67 using std::string; 68 68 69 if ( get_name()!= "" ) {70 os << get_name()<< ": ";69 if ( name != "" ) { 70 os << name << ": "; 71 71 } // if 72 if ( get_linkage()!= LinkageSpec::Cforall ) {73 os << LinkageSpec::linkageName( get_linkage()) << " ";72 if ( linkage != LinkageSpec::Cforall ) { 73 os << LinkageSpec::linkageName( linkage ) << " "; 74 74 } // if 75 75 76 printAll( get_attributes(), os, indent );76 printAll( attributes, os, indent ); 77 77 78 78 get_storageClasses().print( os ); 79 79 get_funcSpec().print( os ); 80 80 81 if ( get_type()) {82 get_type()->print( os, indent );81 if ( type ) { 82 type->print( os, indent ); 83 83 } else { 84 84 os << "untyped entity "; … … 86 86 87 87 if ( statements ) { 88 os << string( indent + 2, ' ' ) << "with body " << endl; 89 os << string( indent + 4, ' ' ); 90 statements->print( os, indent + 4 ); 88 os << indent << "... with body " << endl << indent+1; 89 statements->print( os, indent+1 ); 91 90 } // if 92 91 } 93 92 94 void FunctionDecl::printShort( std::ostream &os, intindent ) const {93 void FunctionDecl::printShort( std::ostream &os, Indenter indent ) const { 95 94 using std::endl; 96 95 using std::string; 97 96 98 if ( get_name()!= "" ) {99 os << get_name()<< ": ";97 if ( name != "" ) { 98 os << name << ": "; 100 99 } // if 101 102 // xxx - should printShort print attributes?103 100 104 101 get_storageClasses().print( os ); 105 102 get_funcSpec().print( os ); 106 103 107 if ( get_type()) {108 get_type()->print( os, indent );104 if ( type ) { 105 type->print( os, indent ); 109 106 } else { 110 107 os << "untyped entity "; -
src/SynTree/FunctionType.cc
ra8555c5 r50377a4 51 51 } 52 52 53 void FunctionType::print( std::ostream &os, intindent ) const {53 void FunctionType::print( std::ostream &os, Indenter indent ) const { 54 54 using std::string; 55 55 using std::endl; … … 58 58 os << "function" << endl; 59 59 if ( ! parameters.empty() ) { 60 os << string( indent + 2, ' ' ) << "with parameters" << endl;61 printAll( parameters, os, indent + 4);60 os << indent << "... with parameters" << endl; 61 printAll( parameters, os, indent+1 ); 62 62 if ( isVarArgs ) { 63 os << string( indent + 4, ' ' )<< "and a variable number of other arguments" << endl;63 os << indent+1 << "and a variable number of other arguments" << endl; 64 64 } // if 65 65 } else if ( isVarArgs ) { 66 os << string( indent + 4, ' ' )<< "accepting unspecified arguments" << endl;66 os << indent+1 << "accepting unspecified arguments" << endl; 67 67 } // if 68 os << string( indent + 2, ' ' ) << "returning ";68 os << indent << "... returning "; 69 69 if ( returnVals.empty() ) { 70 os << endl << string( indent + 4, ' ' ) <<"nothing " << endl;70 os << "nothing " << endl; 71 71 } else { 72 72 os << endl; 73 printAll( returnVals, os, indent + 4);73 printAll( returnVals, os, indent+1 ); 74 74 } // if 75 75 } -
src/SynTree/Initializer.cc
ra8555c5 r50377a4 38 38 } 39 39 40 void Designation::print( std::ostream &os, intindent ) const {40 void Designation::print( std::ostream &os, Indenter indent ) const { 41 41 if ( ! designators.empty() ) { 42 os << std::string(indent + 2, ' ' ) << "designated by: " << std::endl; 43 for ( std::list < Expression * >::const_iterator i = designators.begin(); i != designators.end(); i++ ) { 44 os << std::string(indent + 4, ' ' ); 45 ( *i )->print(os, indent + 4 ); 42 os << "... designated by: " << std::endl; 43 for ( const Expression * d : designators ) { 44 os << indent+1; 45 d->print(os, indent+1 ); 46 os << std::endl; 46 47 } 47 os << std::endl;48 48 } // if 49 49 } … … 64 64 } 65 65 66 void SingleInit::print( std::ostream &os, int indent ) const { 67 os << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl; 68 os << std::string(indent+4, ' ' ); 69 value->print( os, indent+4 ); 66 void SingleInit::print( std::ostream &os, Indenter indent ) const { 67 os << "Simple Initializer: "; 68 value->print( os, indent ); 70 69 } 71 70 … … 93 92 } 94 93 95 void ListInit::print( std::ostream &os, int indent ) const { 96 os << std::string(indent, ' ') << "Compound initializer: " << std::endl; 97 for ( Designation * d : designations ) { 98 d->print( os, indent + 2 ); 99 } 100 101 for ( const Initializer * init : initializers ) { 102 init->print( os, indent + 2 ); 94 void ListInit::print( std::ostream &os, Indenter indent ) const { 95 os << "Compound initializer: " << std::endl; 96 for ( auto p : group_iterate( designations, initializers ) ) { 97 const Designation * d = std::get<0>(p); 98 const Initializer * init = std::get<1>(p); 99 os << indent+1; 100 init->print( os, indent+1 ); 103 101 os << std::endl; 102 if ( ! d->designators.empty() ) { 103 os << indent+1; 104 d->print( os, indent+1 ); 105 } 104 106 } 105 107 } … … 116 118 } 117 119 118 void ConstructorInit::print( std::ostream &os, intindent ) const {119 os << std::endl << std::string(indent, ' ') <<"Constructor initializer: " << std::endl;120 void ConstructorInit::print( std::ostream &os, Indenter indent ) const { 121 os << "Constructor initializer: " << std::endl; 120 122 if ( ctor ) { 121 os << std::string(indent+2, ' '); 122 os << "initially constructed with "; 123 ctor->print( os, indent+4 ); 123 os << indent << "... initially constructed with "; 124 ctor->print( os, indent+1 ); 124 125 } // if 125 126 126 127 if ( dtor ) { 127 os << std::string(indent+2, ' '); 128 os << "destructed with "; 129 dtor->print( os, indent+4 ); 128 os << indent << "... destructed with "; 129 dtor->print( os, indent+1 ); 130 130 } 131 131 132 132 if ( init ) { 133 os << std::string(indent+2, ' '); 134 os << "with fallback C-style initializer: "; 135 init->print( os, indent+4 ); 133 os << indent << "... with fallback C-style initializer: "; 134 init->print( os, indent+1 ); 136 135 } 137 136 } -
src/SynTree/Initializer.h
ra8555c5 r50377a4 40 40 virtual void accept( Visitor &v ) override { v.visit( this ); } 41 41 virtual Designation * acceptMutator( Mutator &m ) override { return m.mutate( this ); } 42 virtual void print( std::ostream &os, int indent = 0) const override;42 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 43 43 }; 44 44 … … 57 57 virtual void accept( Visitor &v ) override = 0; 58 58 virtual Initializer *acceptMutator( Mutator &m ) override = 0; 59 virtual void print( std::ostream &os, int indent = 0) const override = 0;59 virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0; 60 60 private: 61 61 bool maybeConstructed; … … 78 78 virtual void accept( Visitor &v ) override { v.visit( this ); } 79 79 virtual Initializer *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 80 virtual void print( std::ostream &os, int indent = 0) const override;80 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 81 81 }; 82 82 … … 106 106 virtual void accept( Visitor &v ) override { v.visit( this ); } 107 107 virtual Initializer *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 108 virtual void print( std::ostream &os, int indent = 0) const override;108 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 109 109 }; 110 110 … … 135 135 virtual void accept( Visitor &v ) override { v.visit( this ); } 136 136 virtual Initializer *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 137 virtual void print( std::ostream &os, int indent = 0) const override;137 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 138 138 139 139 private: -
src/SynTree/NamedTypeDecl.cc
ra8555c5 r50377a4 38 38 } 39 39 40 void NamedTypeDecl::print( std::ostream &os, intindent ) const {40 void NamedTypeDecl::print( std::ostream &os, Indenter indent ) const { 41 41 using namespace std; 42 42 43 if ( get_name() != "" ) { 44 os << get_name() << ": "; 45 } // if 46 if ( get_linkage() != LinkageSpec::Cforall ) { 47 os << LinkageSpec::linkageName( get_linkage() ) << " "; 43 if ( name != "" ) os << name << ": "; 44 45 if ( linkage != LinkageSpec::Cforall ) { 46 os << LinkageSpec::linkageName( linkage ) << " "; 48 47 } // if 49 48 get_storageClasses().print( os ); … … 51 50 if ( base ) { 52 51 os << " for "; 53 base->print( os, indent );52 base->print( os, indent+1 ); 54 53 } // if 55 54 if ( ! parameters.empty() ) { 56 os << endl << string( indent, ' ' ) << "with parameters" << endl;57 printAll( parameters, os, indent+ 2);55 os << endl << indent << "... with parameters" << endl; 56 printAll( parameters, os, indent+1 ); 58 57 } // if 59 58 if ( ! assertions.empty() ) { 60 os << endl << string( indent, ' ' ) << "with assertions" << endl;61 printAll( assertions, os, indent+ 2);59 os << endl << indent << "... with assertions" << endl; 60 printAll( assertions, os, indent+1 ); 62 61 } // if 63 62 } 64 63 65 void NamedTypeDecl::printShort( std::ostream &os, intindent ) const {64 void NamedTypeDecl::printShort( std::ostream &os, Indenter indent ) const { 66 65 using namespace std; 67 66 68 if ( get_name() != "" ) { 69 os << get_name() << ": "; 70 } // if 67 if ( name != "" ) os << name << ": "; 71 68 get_storageClasses().print( os ); 72 69 os << typeString(); 73 70 if ( base ) { 74 71 os << " for "; 75 base->print( os, indent );72 base->print( os, indent+1 ); 76 73 } // if 77 74 if ( ! parameters.empty() ) { 78 os << endl << string( indent, ' ' ) << "with parameters" << endl;79 printAll( parameters, os, indent+ 2);75 os << endl << indent << "... with parameters" << endl; 76 printAll( parameters, os, indent+1 ); 80 77 } // if 81 78 } -
src/SynTree/ObjectDecl.cc
ra8555c5 r50377a4 44 44 } 45 45 46 void ObjectDecl::print( std::ostream &os, int indent ) const { 47 if ( get_name() != "" ) { 48 os << get_name() << ": "; 46 void ObjectDecl::print( std::ostream &os, Indenter indent ) const { 47 if ( name != "" ) os << name << ": "; 48 49 if ( linkage != LinkageSpec::Cforall ) { 50 os << LinkageSpec::linkageName( linkage ) << " "; 49 51 } // if 50 51 if ( get_linkage() != LinkageSpec::Cforall ) {52 os << LinkageSpec::linkageName( get_linkage() ) << " ";53 } // if54 55 printAll( get_attributes(), os, indent );56 52 57 53 get_storageClasses().print( os ); 58 54 59 if ( get_type()) {60 get_type()->print( os, indent );55 if ( type ) { 56 type->print( os, indent ); 61 57 } else { 62 58 os << " untyped entity "; … … 64 60 65 61 if ( init ) { 66 os << " with initializer " << std::endl; 67 init->print( os, indent+2 ); 68 os << std::endl << std::string(indent+2, ' '); 69 os << "maybeConstructed? " << init->get_maybeConstructed(); 62 os << " with initializer (" << (init->get_maybeConstructed() ? "maybe constructed" : "not constructed") << ")" << std::endl << indent+1; 63 init->print( os, indent+1 ); 64 os << std::endl; 70 65 } // if 71 66 67 if ( ! attributes.empty() ) { 68 os << std::endl << indent << "... with attributes: " << std::endl; 69 printAll( attributes, os, indent+1 ); 70 } 71 72 72 if ( bitfieldWidth ) { 73 os << std::string(indent, ' '); 74 os << " with bitfield width "; 73 os << indent << " with bitfield width "; 75 74 bitfieldWidth->print( os ); 76 75 } // if 77 76 } 78 77 79 void ObjectDecl::printShort( std::ostream &os, intindent ) const {78 void ObjectDecl::printShort( std::ostream &os, Indenter indent ) const { 80 79 #if 0 81 80 if ( get_mangleName() != "") { … … 83 82 } else 84 83 #endif 85 if ( get_name() != "" ) { 86 os << get_name() << ": "; 87 } // if 88 89 // xxx - should printShort print attributes? 84 if ( name != "" ) os << name << ": "; 90 85 91 86 get_storageClasses().print( os ); 92 87 93 if ( get_type()) {94 get_type()->print( os, indent );88 if ( type ) { 89 type->print( os, indent ); 95 90 } else { 96 91 os << "untyped entity "; -
src/SynTree/PointerType.cc
ra8555c5 r50377a4 41 41 } 42 42 43 void PointerType::print( std::ostream &os, intindent ) const {43 void PointerType::print( std::ostream &os, Indenter indent ) const { 44 44 Type::print( os, indent ); 45 45 if ( ! is_array() ) { -
src/SynTree/ReferenceToType.cc
ra8555c5 r50377a4 14 14 // 15 15 16 #include <stddef.h> // for NULL17 16 #include <cassert> // for assert 18 17 #include <list> // for list, _List_const_iterator, list<>::cons... … … 38 37 } 39 38 40 void ReferenceToType::print( std::ostream &os, intindent ) const {39 void ReferenceToType::print( std::ostream &os, Indenter indent ) const { 41 40 using std::endl; 42 41 … … 44 43 os << "instance of " << typeString() << " " << name << " "; 45 44 if ( ! parameters.empty() ) { 46 os << endl << std::string( indent, ' ' ) << "with parameters" << endl;47 printAll( parameters, os, indent+ 2);45 os << endl << indent << "... with parameters" << endl; 46 printAll( parameters, os, indent+1 ); 48 47 } // if 49 48 } … … 65 64 66 65 std::list<TypeDecl*>* StructInstType::get_baseParameters() { 67 if ( ! baseStruct ) return NULL;66 if ( ! baseStruct ) return nullptr; 68 67 return &baseStruct->get_parameters(); 69 68 } … … 76 75 } 77 76 78 void StructInstType::print( std::ostream &os, intindent ) const {77 void StructInstType::print( std::ostream &os, Indenter indent ) const { 79 78 using std::endl; 80 79 81 if ( baseStruct == NULL) ReferenceToType::print( os, indent );80 if ( baseStruct == nullptr ) ReferenceToType::print( os, indent ); 82 81 else { 83 82 Type::print( os, indent ); 84 83 os << "instance of " << typeString() << " " << name << " with body " << baseStruct->has_body() << " "; 85 84 if ( ! parameters.empty() ) { 86 os << endl << std::string( indent, ' ' ) << "with parameters" << endl;87 printAll( parameters, os, indent+ 2);85 os << endl << indent << "... with parameters" << endl; 86 printAll( parameters, os, indent+1 ); 88 87 } // if 89 88 } // if … … 97 96 98 97 std::list< TypeDecl * > * UnionInstType::get_baseParameters() { 99 if ( ! baseUnion ) return NULL;98 if ( ! baseUnion ) return nullptr; 100 99 return &baseUnion->get_parameters(); 101 100 } … … 108 107 } 109 108 110 void UnionInstType::print( std::ostream &os, intindent ) const {109 void UnionInstType::print( std::ostream &os, Indenter indent ) const { 111 110 using std::endl; 112 111 113 if ( baseUnion == NULL) ReferenceToType::print( os, indent );112 if ( baseUnion == nullptr ) ReferenceToType::print( os, indent ); 114 113 else { 115 114 Type::print( os, indent ); 116 115 os << "instance of " << typeString() << " " << name << " with body " << baseUnion->has_body() << " "; 117 116 if ( ! parameters.empty() ) { 118 os << endl << std::string( indent, ' ' ) << "with parameters" << endl;119 printAll( parameters, os, indent+ 2);117 os << endl << indent << "... with parameters" << endl; 118 printAll( parameters, os, indent+1 ); 120 119 } // if 121 120 } // if … … 166 165 bool TypeInstType::isComplete() const { return baseType->isComplete(); } 167 166 168 void TypeInstType::print( std::ostream &os, intindent ) const {167 void TypeInstType::print( std::ostream &os, Indenter indent ) const { 169 168 using std::endl; 170 169 … … 172 171 os << "instance of " << typeString() << " " << get_name() << " (" << ( isFtype ? "" : "not" ) << " function type) "; 173 172 if ( ! parameters.empty() ) { 174 os << endl << std::string( indent, ' ' ) << "with parameters" << endl;175 printAll( parameters, os, indent+ 2);173 os << endl << indent << "... with parameters" << endl; 174 printAll( parameters, os, indent+1 ); 176 175 } // if 177 176 } -
src/SynTree/ReferenceType.cc
ra8555c5 r50377a4 35 35 } 36 36 37 void ReferenceType::print( std::ostream &os, intindent ) const {37 void ReferenceType::print( std::ostream &os, Indenter indent ) const { 38 38 Type::print( os, indent ); 39 39 os << "reference to "; -
src/SynTree/Statement.cc
ra8555c5 r50377a4 34 34 Statement::Statement( std::list<Label> labels ) : labels( labels ) {} 35 35 36 void Statement::print( __attribute__((unused)) std::ostream &, __attribute__((unused)) int indent ) const {} 36 void Statement::print( std::ostream & os, Indenter ) const { 37 if ( ! labels.empty() ) { 38 os << "Labels: {"; 39 for ( const Label & l : labels ) { 40 os << l << ","; 41 } 42 os << "}" << endl; 43 } 44 } 37 45 38 46 Statement::~Statement() {} … … 46 54 } 47 55 48 void ExprStmt::print( std::ostream &os, intindent ) const {49 os << "Expression Statement:" << endl << std::string( indent + 2, ' ' );50 expr->print( os, indent + 2);56 void ExprStmt::print( std::ostream &os, Indenter indent ) const { 57 os << "Expression Statement:" << endl << indent+1; 58 expr->print( os, indent+1 ); 51 59 } 52 60 … … 67 75 } 68 76 69 void AsmStmt::print( std::ostream &os, intindent ) const {77 void AsmStmt::print( std::ostream &os, Indenter indent ) const { 70 78 os << "Assembler Statement:" << endl; 71 os << std::string( indent, ' ' ) << "instruction: " << endl << std::string( indent, ' ' );72 instruction->print( os, indent + 2);79 os << indent+1 << "instruction: " << endl << indent; 80 instruction->print( os, indent+1 ); 73 81 if ( ! output.empty() ) { 74 os << endl << std::string( indent, ' ' )<< "output: " << endl;75 printAll( output, os, indent + 2);82 os << endl << indent+1 << "output: " << endl; 83 printAll( output, os, indent+1 ); 76 84 } // if 77 85 if ( ! input.empty() ) { 78 os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' );79 printAll( input, os, indent + 2);86 os << indent+1 << "input: " << endl; 87 printAll( input, os, indent+1 ); 80 88 } // if 81 89 if ( ! clobber.empty() ) { 82 os << std::string( indent, ' ' )<< "clobber: " << endl;83 printAll( clobber, os, indent + 2);90 os << indent+1 << "clobber: " << endl; 91 printAll( clobber, os, indent+1 ); 84 92 } // if 85 93 } … … 103 111 } 104 112 105 void BranchStmt::print( std::ostream &os, intindent ) const {106 os << string( indent, ' ' ) <<"Branch (" << brType[type] << ")" << endl ;107 if ( target != "" ) os << string( indent+2, ' ' )<< "with target: " << target << endl;108 if ( originalTarget != "" ) os << string( indent+2, ' ' )<< "with original target: " << originalTarget << endl;109 if ( computedTarget != nullptr ) os << string( indent+2, ' ' )<< "with computed target: " << computedTarget << endl;113 void BranchStmt::print( std::ostream &os, Indenter indent ) const { 114 os << "Branch (" << brType[type] << ")" << endl ; 115 if ( target != "" ) os << indent+1 << "with target: " << target << endl; 116 if ( originalTarget != "" ) os << indent+1 << "with original target: " << originalTarget << endl; 117 if ( computedTarget != nullptr ) os << indent+1 << "with computed target: " << computedTarget << endl; 110 118 } 111 119 … … 118 126 } 119 127 120 void ReturnStmt::print( std::ostream &os, intindent ) const {121 os << 122 if ( expr != 0) {123 os << endl << string( indent+2, ' ' );124 expr->print( os, indent + 2);128 void ReturnStmt::print( std::ostream &os, Indenter indent ) const { 129 os << "Return Statement, returning: "; 130 if ( expr != nullptr ) { 131 os << endl << indent+1; 132 expr->print( os, indent+1 ); 125 133 } 126 134 os << endl; … … 142 150 } 143 151 144 void IfStmt::print( std::ostream &os, intindent ) const {145 os << "If on condition: " << endl 146 os << string( indent+4, ' ' );147 condition->print( os, indent + 4);152 void IfStmt::print( std::ostream &os, Indenter indent ) const { 153 os << "If on condition: " << endl; 154 os << indent+1; 155 condition->print( os, indent+1 ); 148 156 149 157 if ( !initialization.empty() ) { 150 os << string( indent + 2, ' ' ) << "initialization: \n";151 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it) {152 os << string( indent + 4, ' ' );153 (*it)->print( os, indent + 4);158 os << indent << "... with initialization: \n"; 159 for ( const Statement * stmt : initialization ) { 160 os << indent+1; 161 stmt->print( os, indent+1 ); 154 162 } 155 163 os << endl; 156 164 } 157 165 158 os << string( indent+2, ' ' )<< "... then: " << endl;159 160 os << string( indent+4, ' ' );161 thenPart->print( os, indent + 4);166 os << indent << "... then: " << endl; 167 168 os << indent+1; 169 thenPart->print( os, indent+1 ); 162 170 163 171 if ( elsePart != 0 ) { 164 os << string( indent+2, ' ' )<< "... else: " << endl;165 os << string( indent+4, ' ' );166 elsePart->print( os, indent + 4);172 os << indent << "... else: " << endl; 173 os << indent+1; 174 elsePart->print( os, indent+1 ); 167 175 } // if 168 176 } … … 183 191 } 184 192 185 void SwitchStmt::print( std::ostream &os, intindent ) const {193 void SwitchStmt::print( std::ostream &os, Indenter indent ) const { 186 194 os << "Switch on condition: "; 187 195 condition->print( os ); 188 196 os << endl; 189 197 190 // statements 191 std::list<Statement *>::const_iterator i; 192 for ( i = statements.begin(); i != statements.end(); i++) 193 (*i)->print( os, indent + 4 ); 194 195 //for_each( statements.begin(), statements.end(), mem_fun( bind1st(&Statement::print ), os )); 198 for ( const Statement * stmt : statements ) { 199 stmt->print( os, indent+1 ); 200 } 196 201 } 197 202 198 203 CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) : 199 204 Statement( labels ), condition( condition ), stmts( statements ), _isDefault( deflt ) { 200 if ( isDefault() && condition != 0 ) 201 throw SemanticError("default with conditions"); 205 if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition); 202 206 } 203 207 … … 216 220 } 217 221 218 void CaseStmt::print( std::ostream &os, int indent ) const { 219 os << string( indent, ' ' ); 220 221 if ( isDefault() ) 222 os << "Default "; 222 void CaseStmt::print( std::ostream &os, Indenter indent ) const { 223 if ( isDefault() ) os << "Default "; 223 224 else { 224 225 os << "Case "; 225 condition->print( os ); 226 } // if 227 228 os << endl; 229 230 std::list<Statement *>::const_iterator i; 231 for ( i = stmts.begin(); i != stmts.end(); i++) 232 (*i )->print( os, indent + 4 ); 226 condition->print( os, indent ); 227 } // if 228 os << endl; 229 230 for ( Statement * stmt : stmts ) { 231 stmt->print( os, indent+1 ); 232 } 233 233 } 234 234 … … 246 246 } 247 247 248 void WhileStmt::print( std::ostream &os, intindent ) const {248 void WhileStmt::print( std::ostream &os, Indenter indent ) const { 249 249 os << "While on condition: " << endl ; 250 condition->print( os, indent + 4);251 252 os << string( indent, ' ' ) << ".... with body: " << endl;253 254 if ( body != 0 ) body->print( os, indent + 4);250 condition->print( os, indent+1 ); 251 252 os << indent << "... with body: " << endl; 253 254 if ( body != 0 ) body->print( os, indent+1 ); 255 255 } 256 256 … … 272 272 } 273 273 274 void ForStmt::print( std::ostream &os, int indent ) const { 275 os << "Labels: {"; 276 for ( std::list<Label>::const_iterator it = get_labels().begin(); it != get_labels().end(); ++it) { 277 os << *it << ","; 278 } 279 os << "}" << endl; 280 281 os << string( indent, ' ' ) << "For Statement" << endl ; 282 283 os << string( indent + 2, ' ' ) << "initialization: \n"; 284 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) { 285 os << string( indent + 4, ' ' ); 286 (*it)->print( os, indent + 4 ); 287 } 288 289 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 290 if ( condition != 0 ) { 291 os << string( indent + 4, ' ' ); 292 condition->print( os, indent + 4 ); 293 } 294 295 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 296 if ( increment != 0 ) { 297 os << string( indent + 4, ' ' ); 298 increment->print( os, indent + 4 ); 299 } 300 301 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 274 void ForStmt::print( std::ostream &os, Indenter indent ) const { 275 Statement::print( os, indent ); // print labels 276 277 os << "For Statement" << endl; 278 279 if ( ! initialization.empty() ) { 280 os << indent << "... initialization: \n"; 281 for ( Statement * stmt : initialization ) { 282 os << indent+1; 283 stmt->print( os, indent+1 ); 284 } 285 } 286 287 if ( condition != nullptr ) { 288 os << indent << "... condition: \n" << indent+1; 289 condition->print( os, indent+1 ); 290 } 291 292 if ( increment != nullptr ) { 293 os << "\n" << indent << "... increment: \n" << indent+1; 294 increment->print( os, indent+1 ); 295 } 296 302 297 if ( body != 0 ) { 303 os << string( indent + 4, ' ' ); 304 body->print( os, indent + 4 ); 305 } 306 298 os << "\n" << indent << "... with body: \n" << indent+1; 299 body->print( os, indent+1 ); 300 } 307 301 os << endl; 308 302 } … … 322 316 } 323 317 324 void ThrowStmt::print( std::ostream &os, int indent) const { 318 void ThrowStmt::print( std::ostream &os, Indenter indent) const { 319 if ( target ) os << "Non-Local "; 320 os << "Throw Statement, raising: "; 321 expr->print(os, indent+1); 325 322 if ( target ) { 326 os << "Non-Local "; 327 } 328 os << "Throw Statement, raising: "; 329 expr->print(os, indent + 4); 330 if ( target ) { 331 os << "At: "; 332 target->print(os, indent + 4); 323 os << "... at: "; 324 target->print(os, indent+1); 333 325 } 334 326 } … … 348 340 } 349 341 350 void TryStmt::print( std::ostream &os, intindent ) const {342 void TryStmt::print( std::ostream &os, Indenter indent ) const { 351 343 os << "Try Statement" << endl; 352 os << string( indent + 2, ' ' ) << "with block:" << endl; 353 os << string( indent + 4, ' ' ); 354 block->print( os, indent + 4 ); 344 os << indent << "... with block:" << endl << indent+1; 345 block->print( os, indent+1 ); 355 346 356 347 // handlers 357 os << string( indent + 2, ' ' ) << "and handlers:" << endl;358 for ( std::list<CatchStmt *>::const_iterator i = handlers.begin(); i != handlers.end(); i++) {359 os << string( indent + 4, ' ' );360 (*i )->print( os, indent + 4);348 os << indent << "... and handlers:" << endl; 349 for ( const CatchStmt * stmt : handlers ) { 350 os << indent+1; 351 stmt->print( os, indent+1 ); 361 352 } 362 353 363 354 // finally block 364 355 if ( finallyBlock != 0 ) { 365 os << string( indent + 2, ' ' ) << "and finally:" << endl;366 finallyBlock->print( os, indent + 4);356 os << indent << "... and finally:" << endl << indent+1; 357 finallyBlock->print( os, indent+1 ); 367 358 } // if 368 359 } … … 370 361 CatchStmt::CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, Expression *cond, Statement *body ) : 371 362 Statement( labels ), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { 363 assertf( decl, "Catch clause must have a declaration." ); 372 364 } 373 365 … … 381 373 } 382 374 383 void CatchStmt::print( std::ostream &os, intindent ) const {375 void CatchStmt::print( std::ostream &os, Indenter indent ) const { 384 376 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; 385 377 386 os << string( indent + 2, ' ' ) << "... catching: "; 387 if ( decl ) { 388 decl->printShort( os, indent + 4 ); 389 os << endl; 390 } 391 else 392 os << string( indent + 4 , ' ' ) << ">>> Error: this catch clause must have a declaration <<<" << endl; 378 os << indent << "... catching: "; 379 decl->printShort( os, indent+1 ); 380 os << endl; 393 381 394 382 if ( cond ) { 395 os << string( indent + 2, ' ' ) << "with conditional:" << endl; 396 os << string( indent + 4, ' ' ); 397 cond->print( os, indent + 4 ); 398 } 399 else 400 os << string( indent + 2, ' ' ) << "with no conditional" << endl; 401 402 os << string( indent + 2, ' ' ) << "with block:" << endl; 403 os << string( indent + 4, ' ' ); 404 body->print( os, indent + 4 ); 383 os << indent << "... with conditional:" << endl << indent+1; 384 cond->print( os, indent+1 ); 385 } 386 387 os << indent << "... with block:" << endl; 388 os << indent+1; 389 body->print( os, indent+1 ); 405 390 } 406 391 … … 417 402 } 418 403 419 void FinallyStmt::print( std::ostream &os, intindent ) const {404 void FinallyStmt::print( std::ostream &os, Indenter indent ) const { 420 405 os << "Finally Statement" << endl; 421 os << string( indent + 2, ' ' ) << "with block:" << endl; 422 os << string( indent + 4, ' ' ); 423 block->print( os, indent + 4 ); 406 os << indent << "... with block:" << endl << indent+1; 407 block->print( os, indent+1 ); 424 408 } 425 409 … … 465 449 } 466 450 467 void WaitForStmt::print( std::ostream &os, intindent ) const {451 void WaitForStmt::print( std::ostream &os, Indenter indent ) const { 468 452 os << "Waitfor Statement" << endl; 469 os << string( indent + 2, ' ' ) << "with block:" << endl; 470 os << string( indent + 4, ' ' ); 453 os << indent << "... with block:" << endl << indent+1; 471 454 // block->print( os, indent + 4 ); 472 455 } … … 475 458 NullStmt::NullStmt() : Statement( std::list<Label>() ) {} 476 459 477 void NullStmt::print( std::ostream &os, __attribute__((unused)) int indent) const {478 os << "Null Statement" << endl 460 void NullStmt::print( std::ostream &os, Indenter ) const { 461 os << "Null Statement" << endl; 479 462 } 480 463 … … 490 473 } 491 474 492 void ImplicitCtorDtorStmt::print( std::ostream &os, intindent ) const {475 void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const { 493 476 os << "Implicit Ctor Dtor Statement" << endl; 494 os << string( indent + 2, ' ' ) << "with Ctor/Dtor: ";495 callStmt->print( os, indent + 2);477 os << indent << "... with Ctor/Dtor: "; 478 callStmt->print( os, indent+1); 496 479 os << endl; 497 480 } -
src/SynTree/Statement.h
ra8555c5 r50377a4 46 46 virtual void accept( Visitor &v ) override = 0; 47 47 virtual Statement *acceptMutator( Mutator &m ) override = 0; 48 virtual void print( std::ostream &os, int indent = 0) const override;48 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 49 49 }; 50 50 … … 65 65 virtual void accept( Visitor &v ) override { v.visit( this ); } 66 66 virtual CompoundStmt *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 67 virtual void print( std::ostream &os, int indent = 0) const override;67 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 68 68 }; 69 69 … … 76 76 virtual void accept( Visitor &v ) override { v.visit( this ); } 77 77 virtual NullStmt *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 78 virtual void print( std::ostream &os, int indent = 0) const override;78 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 79 79 }; 80 80 … … 93 93 virtual void accept( Visitor &v ) override { v.visit( this ); } 94 94 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 95 virtual void print( std::ostream &os, int indent = 0) const override;95 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 96 96 }; 97 97 … … 124 124 virtual void accept( Visitor & v ) { v.visit( this ); } 125 125 virtual Statement * acceptMutator( Mutator & m ) { return m.mutate( this ); } 126 virtual void print( std::ostream & os, int indent = 0) const;126 virtual void print( std::ostream & os, Indenter indent = {} ) const; 127 127 }; 128 128 … … 150 150 virtual void accept( Visitor &v ) override { v.visit( this ); } 151 151 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 152 virtual void print( std::ostream &os, int indent = 0) const override;152 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 153 153 }; 154 154 … … 171 171 172 172 virtual SwitchStmt *clone() const override { return new SwitchStmt( *this ); } 173 virtual void print( std::ostream &os, int indent = 0) const override;173 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 174 174 175 175 }; … … 199 199 200 200 virtual CaseStmt *clone() const override { return new CaseStmt( *this ); } 201 virtual void print( std::ostream &os, int indent = 0) const override;201 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 202 202 private: 203 203 bool _isDefault; … … 225 225 virtual void accept( Visitor &v ) override { v.visit( this ); } 226 226 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 227 virtual void print( std::ostream &os, int indent = 0) const override;227 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 228 228 }; 229 229 … … 251 251 virtual void accept( Visitor &v ) override { v.visit( this ); } 252 252 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 253 virtual void print( std::ostream &os, int indent = 0) const override;253 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 254 254 }; 255 255 … … 280 280 virtual void accept( Visitor &v ) override { v.visit( this ); } 281 281 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 282 virtual void print( std::ostream &os, int indent = 0) const override;282 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 283 283 private: 284 284 static const char *brType[]; … … 299 299 virtual void accept( Visitor &v ) override { v.visit( this ); } 300 300 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 301 virtual void print( std::ostream &os, int indent = 0) const override;301 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 302 302 }; 303 303 … … 323 323 virtual void accept( Visitor &v ) override { v.visit( this ); } 324 324 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 325 virtual void print( std::ostream &os, int indent = 0) const override;325 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 326 326 }; 327 327 … … 346 346 virtual void accept( Visitor &v ) override { v.visit( this ); } 347 347 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 348 virtual void print( std::ostream &os, int indent = 0) const override;348 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 349 349 }; 350 350 … … 374 374 virtual void accept( Visitor &v ) override { v.visit( this ); } 375 375 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 376 virtual void print( std::ostream &os, int indent = 0) const override;376 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 377 377 }; 378 378 … … 391 391 virtual void accept( Visitor &v ) override { v.visit( this ); } 392 392 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 393 virtual void print( std::ostream &os, int indent = 0) const override;393 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 394 394 }; 395 395 … … 428 428 virtual void accept( Visitor &v ) override { v.visit( this ); } 429 429 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 430 virtual void print( std::ostream &os, int indent = 0) const override;430 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 431 431 432 432 }; … … 448 448 virtual void accept( Visitor &v ) override { v.visit( this ); } 449 449 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 450 virtual void print( std::ostream &os, int indent = 0) const override;450 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 451 451 }; 452 452 … … 470 470 virtual void accept( Visitor &v ) override { v.visit( this ); } 471 471 virtual Statement *acceptMutator( Mutator &m ) override { return m.mutate( this ); } 472 virtual void print( std::ostream &os, int indent = 0) const override;472 virtual void print( std::ostream &os, Indenter indent = {} ) const override; 473 473 }; 474 474 -
src/SynTree/TupleExpr.cc
ra8555c5 r50377a4 39 39 } 40 40 41 void UntypedTupleExpr::print( std::ostream &os, intindent ) const {41 void UntypedTupleExpr::print( std::ostream &os, Indenter indent ) const { 42 42 os << "Untyped Tuple:" << std::endl; 43 printAll( exprs, os, indent+ 2);43 printAll( exprs, os, indent+1 ); 44 44 Expression::print( os, indent ); 45 45 } … … 57 57 } 58 58 59 void TupleExpr::print( std::ostream &os, intindent ) const {59 void TupleExpr::print( std::ostream &os, Indenter indent ) const { 60 60 os << "Tuple:" << std::endl; 61 printAll( exprs, os, indent+ 2);61 printAll( exprs, os, indent+1 ); 62 62 Expression::print( os, indent ); 63 63 } … … 78 78 } 79 79 80 void TupleIndexExpr::print( std::ostream &os, intindent ) const {80 void TupleIndexExpr::print( std::ostream &os, Indenter indent ) const { 81 81 os << "Tuple Index Expression, with tuple:" << std::endl; 82 os << std::string( indent+2, ' ' );83 tuple->print( os, indent+ 2);84 os << std::string( indent+2, ' ' )<< "with index: " << index << std::endl;82 os << indent+1; 83 tuple->print( os, indent+1 ); 84 os << indent+1 << "with index: " << index << std::endl; 85 85 Expression::print( os, indent ); 86 86 } … … 109 109 } 110 110 111 void TupleAssignExpr::print( std::ostream &os, intindent ) const {111 void TupleAssignExpr::print( std::ostream &os, Indenter indent ) const { 112 112 os << "Tuple Assignment Expression, with stmt expr:" << std::endl; 113 os << std::string( indent+2, ' ' );114 stmtExpr->print( os, indent+ 4);113 os << indent+1; 114 stmtExpr->print( os, indent+1 ); 115 115 Expression::print( os, indent ); 116 116 } -
src/SynTree/TupleType.cc
ra8555c5 r50377a4 48 48 } 49 49 50 void TupleType::print( std::ostream &os, intindent ) const {50 void TupleType::print( std::ostream &os, Indenter indent ) const { 51 51 Type::print( os, indent ); 52 52 os << "tuple of types" << std::endl; 53 printAll( types, os, indent+ 2);53 printAll( types, os, indent+1 ); 54 54 } 55 55 -
src/SynTree/Type.cc
ra8555c5 r50377a4 75 75 Type * type; 76 76 ReferenceType * ref; 77 for ( type = this; (ref = dynamic_cast<ReferenceType *>( type )); type = ref-> get_base());77 for ( type = this; (ref = dynamic_cast<ReferenceType *>( type )); type = ref->base ); 78 78 return type; 79 79 } … … 81 81 int Type::referenceDepth() const { return 0; } 82 82 83 void Type::print( std::ostream &os, intindent ) const {83 void Type::print( std::ostream &os, Indenter indent ) const { 84 84 if ( ! forall.empty() ) { 85 85 os << "forall" << std::endl; 86 printAll( forall, os, indent + 4);87 os << std::string( indent+2, ' ' );86 printAll( forall, os, indent+1 ); 87 os << ++indent; 88 88 } // if 89 89 90 90 if ( ! attributes.empty() ) { 91 os << endl << string( indent+2, ' ' ) <<"with attributes" << endl;92 printAll( attributes, os, indent+ 4);91 os << "with attributes" << endl; 92 printAll( attributes, os, indent+1 ); 93 93 } // if 94 94 -
src/SynTree/Type.h
ra8555c5 r50377a4 181 181 virtual void accept( Visitor & v ) = 0; 182 182 virtual Type *acceptMutator( Mutator & m ) = 0; 183 virtual void print( std::ostream & os, int indent = 0) const;183 virtual void print( std::ostream & os, Indenter indent = {} ) const; 184 184 }; 185 185 … … 198 198 virtual void accept( Visitor & v ) override { v.visit( this ); } 199 199 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 200 virtual void print( std::ostream & os, int indent = 0) const override;200 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 201 201 }; 202 202 … … 240 240 virtual void accept( Visitor & v ) override { v.visit( this ); } 241 241 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 242 virtual void print( std::ostream & os, int indent = 0) const override;242 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 243 243 244 244 bool isInteger() const; … … 275 275 virtual void accept( Visitor & v ) override { v.visit( this ); } 276 276 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 277 virtual void print( std::ostream & os, int indent = 0) const override;277 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 278 278 }; 279 279 … … 303 303 virtual void accept( Visitor & v ) override { v.visit( this ); } 304 304 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 305 virtual void print( std::ostream & os, int indent = 0) const override;305 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 306 306 }; 307 307 … … 327 327 virtual void accept( Visitor & v ) override { v.visit( this ); } 328 328 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 329 virtual void print( std::ostream & os, int indent = 0) const override;329 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 330 330 }; 331 331 … … 354 354 virtual void accept( Visitor & v ) override { v.visit( this ); } 355 355 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 356 virtual void print( std::ostream & os, int indent = 0) const override;356 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 357 357 }; 358 358 … … 376 376 virtual void accept( Visitor & v ) override = 0; 377 377 virtual Type *acceptMutator( Mutator & m ) override = 0; 378 virtual void print( std::ostream & os, int indent = 0) const override;378 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 379 379 380 380 virtual void lookup( __attribute__((unused)) const std::string & name, __attribute__((unused)) std::list< Declaration* > & foundDecls ) const {} … … 410 410 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 411 411 412 virtual void print( std::ostream & os, int indent = 0) const override;412 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 413 413 private: 414 414 virtual std::string typeString() const override; … … 442 442 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 443 443 444 virtual void print( std::ostream & os, int indent = 0) const override;444 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 445 445 private: 446 446 virtual std::string typeString() const override; … … 514 514 virtual void accept( Visitor & v ) override { v.visit( this ); } 515 515 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 516 virtual void print( std::ostream & os, int indent = 0) const override;516 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 517 517 private: 518 518 virtual std::string typeString() const override; … … 551 551 virtual void accept( Visitor & v ) override { v.visit( this ); } 552 552 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 553 virtual void print( std::ostream & os, int indent = 0) const override;553 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 554 554 }; 555 555 … … 570 570 virtual void accept( Visitor & v ) override { v.visit( this ); } 571 571 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 572 virtual void print( std::ostream & os, int indent = 0) const override;572 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 573 573 }; 574 574 … … 599 599 virtual void accept( Visitor & v ) override { v.visit( this ); } 600 600 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 601 virtual void print( std::ostream & os, int indent = 0) const override;601 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 602 602 }; 603 603 … … 613 613 virtual void accept( Visitor & v ) override { v.visit( this ); } 614 614 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 615 virtual void print( std::ostream & os, int indent = 0) const override;615 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 616 616 }; 617 617 … … 625 625 virtual void accept( Visitor & v ) override { v.visit( this ); } 626 626 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 627 virtual void print( std::ostream & os, int indent = 0) const override;627 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 628 628 }; 629 629 … … 637 637 virtual void accept( Visitor & v ) override { v.visit( this ); } 638 638 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 639 virtual void print( std::ostream & os, int indent = 0) const override;639 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 640 640 }; 641 641 -
src/SynTree/TypeDecl.cc
ra8555c5 r50377a4 41 41 } 42 42 43 void TypeDecl::print( std::ostream &os, intindent ) const {43 void TypeDecl::print( std::ostream &os, Indenter indent ) const { 44 44 NamedTypeDecl::print( os, indent ); 45 45 if ( init ) { 46 os << std::endl << std::string( indent, ' ' )<< "with type initializer: ";47 init->print( os, indent + 2);46 os << std::endl << indent << "with type initializer: "; 47 init->print( os, indent + 1 ); 48 48 } 49 49 } -
src/SynTree/TypeExpr.cc
ra8555c5 r50377a4 30 30 } 31 31 32 void TypeExpr::print( std::ostream &os, intindent ) const {32 void TypeExpr::print( std::ostream &os, Indenter indent ) const { 33 33 if ( type ) type->print( os, indent ); 34 34 Expression::print( os, indent ); -
src/SynTree/TypeSubstitution.cc
ra8555c5 r50377a4 243 243 } 244 244 245 void TypeSubstitution::print( std::ostream &os, intindent ) const {246 os << std::string( indent, ' ' )<< "Types:" << std::endl;245 void TypeSubstitution::print( std::ostream &os, Indenter indent ) const { 246 os << indent << "Types:" << std::endl; 247 247 for ( TypeEnvType::const_iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) { 248 os << std::string( indent+2, ' ' )<< i->first << " -> ";249 i->second->print( os, indent+ 4);248 os << indent+1 << i->first << " -> "; 249 i->second->print( os, indent+2 ); 250 250 os << std::endl; 251 251 } // for 252 os << std::string( indent, ' ' )<< "Non-types:" << std::endl;252 os << indent << "Non-types:" << std::endl; 253 253 for ( VarEnvType::const_iterator i = varEnv.begin(); i != varEnv.end(); ++i ) { 254 os << std::string( indent+2, ' ' )<< i->first << " -> ";255 i->second->print( os, indent+ 4);254 os << indent+1 << i->first << " -> "; 255 i->second->print( os, indent+2 ); 256 256 os << std::endl; 257 257 } // for -
src/SynTree/TypeSubstitution.h
ra8555c5 r50377a4 61 61 TypeSubstitution * acceptMutator( Mutator & mutator ); 62 62 63 void print( std::ostream &os, int indent = 0) const;63 void print( std::ostream &os, Indenter indent = {} ) const; 64 64 TypeSubstitution *clone() const { return new TypeSubstitution( *this ); } 65 65 private: -
src/SynTree/TypeofType.cc
ra8555c5 r50377a4 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypeofType.cc -- 7 // TypeofType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 33 33 } 34 34 35 void TypeofType::print( std::ostream &os, intindent ) const {35 void TypeofType::print( std::ostream &os, Indenter indent ) const { 36 36 Type::print( os, indent ); 37 37 os << "type-of expression "; -
src/SynTree/VarArgsType.cc
ra8555c5 r50377a4 25 25 VarArgsType::VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {} 26 26 27 void VarArgsType::print( std::ostream &os, intindent ) const {27 void VarArgsType::print( std::ostream &os, Indenter indent ) const { 28 28 Type::print( os, indent ); 29 29 os << "builtin var args pack"; -
src/SynTree/VoidType.cc
ra8555c5 r50377a4 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // VoidType.cc -- 7 // VoidType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 24 24 } 25 25 26 void VoidType::print( std::ostream &os, intindent ) const {26 void VoidType::print( std::ostream &os, Indenter indent ) const { 27 27 Type::print( os, indent ); 28 28 os << "void "; -
src/SynTree/ZeroOneType.cc
ra8555c5 r50377a4 25 25 ZeroType::ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {} 26 26 27 void ZeroType::print( std::ostream &os, __attribute__((unused)) int indent) const {27 void ZeroType::print( std::ostream &os, Indenter ) const { 28 28 os << "zero_t"; 29 29 } … … 33 33 OneType::OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes ) : Type( tq, attributes ) {} 34 34 35 void OneType::print( std::ostream &os, __attribute__((unused)) int indent) const {35 void OneType::print( std::ostream &os, Indenter ) const { 36 36 os << "one_t"; 37 37 } -
src/tests/.expect/castError.txt
ra8555c5 r50377a4 1 castError.c:7:1 error: Cannot choose between 3 alternatives for expression Cast of: 1 castError.c:7:1 error: Cannot choose between 3 alternatives for expression 2 Cast of: 2 3 Name: f 4 ... to: 5 charAlternatives are: 6 Cost ( 1, 0, 0, 0 ): Cast of: 7 Variable Expression: f: function 8 accepting unspecified arguments 9 ... returning nothing 3 10 4 to: 5 char 6 Alternatives are: Cost ( 1, 0, 0, 0 ): Cast of: 7 Variable Expression: f: function 8 accepting unspecified arguments 9 returning 10 nothing 11 ... to: 12 char 13 (types: 14 char 15 ) 16 Environment: 17 18 Cost ( 1, 0, 0, 0 ): Cast of: 19 Variable Expression: f: signed int 20 ... to: 21 char 22 (types: 23 char 24 ) 25 Environment: 26 27 Cost ( 1, 0, 0, 0 ): Cast of: 28 Variable Expression: f: double 29 ... to: 30 char 31 (types: 32 char 33 ) 34 Environment: 11 35 12 36 13 to:14 char15 (types:16 char17 )18 Environment:19 20 Cost ( 1, 0, 0, 0 ): Cast of:21 Variable Expression: f: signed int22 23 to:24 char25 (types:26 char27 )28 Environment:29 30 Cost ( 1, 0, 0, 0 ): Cast of:31 Variable Expression: f: double32 33 to:34 char35 (types:36 char37 )38 Environment:39 40 -
src/tests/.expect/scopeErrors.txt
ra8555c5 r50377a4 1 1 scopeErrors.c:2:1 error: duplicate object definition for thisIsAnError: signed int 2 2 scopeErrors.c:20:1 error: duplicate function definition for butThisIsAnError: function 3 with parameters 4 double 5 returning 6 _retval_butThisIsAnError: Attribute with name: unused 7 double 8 with body 9 CompoundStmt 3 ... with parameters 4 double 5 ... returning 6 _retval_butThisIsAnError: double 7 ... with attributes: 8 Attribute with name: unused 10 9 10 ... with body 11 CompoundStmt 12
Note: See TracChangeset
for help on using the changeset viewer.