Changeset 67a67af for src/CodeGen
- Timestamp:
- Aug 11, 2017, 10:55:14 AM (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:
- 03321e4, f196351
- Parents:
- 3b4571b (diff), 54cd58b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/CodeGen
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r3b4571b r67a67af 64 64 } // extension 65 65 66 ostream & CodeGenerator::Indenter::operator()( ostream & output ) const {67 return output << string( cg.cur_indent, ' ' );68 }69 70 ostream & operator<<( ostream & output, const CodeGenerator::Indenter &indent ) {71 return indent( output );72 }73 74 66 CodeGenerator::LabelPrinter & CodeGenerator::LabelPrinter::operator()( std::list< Label > & l ) { 75 67 labels = &l; … … 109 101 } 110 102 111 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( *this), cur_indent( 0), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {}103 CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks ) : indent( CodeGenerator::tabsize ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {} 112 104 113 105 string CodeGenerator::mangleName( DeclarationWithType * decl ) { … … 200 192 output << " {" << endl; 201 193 202 cur_indent += CodeGenerator::tabsize;194 ++indent; 203 195 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) { 204 196 output << lineDirective( *i ) << indent; … … 207 199 } // for 208 200 209 cur_indent -= CodeGenerator::tabsize;201 --indent; 210 202 211 203 output << indent << "}"; … … 237 229 output << " {" << endl; 238 230 239 cur_indent += CodeGenerator::tabsize;231 ++indent; 240 232 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 241 233 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i ); … … 249 241 } // for 250 242 251 cur_indent -= CodeGenerator::tabsize;243 --indent; 252 244 253 245 output << indent << "}"; … … 761 753 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids(); 762 754 output << lineDirective( stmtExpr) << "({" << std::endl; 763 cur_indent += CodeGenerator::tabsize;755 ++indent; 764 756 unsigned int numStmts = stmts.size(); 765 757 unsigned int i = 0; … … 784 776 ++i; 785 777 } 786 cur_indent -= CodeGenerator::tabsize;778 --indent; 787 779 output << indent << "})"; 788 780 } … … 793 785 output << "{" << endl; 794 786 795 cur_indent += CodeGenerator::tabsize;787 ++indent; 796 788 797 789 for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end(); i++ ) { … … 804 796 } // if 805 797 } // for 806 cur_indent -= CodeGenerator::tabsize;798 --indent; 807 799 808 800 output << indent << "}"; … … 872 864 873 865 output << "{" << std::endl; 874 cur_indent += CodeGenerator::tabsize;866 ++indent; 875 867 acceptAll( switchStmt->get_statements(), *this ); 876 cur_indent -= CodeGenerator::tabsize;868 --indent; 877 869 output << indent << "}"; 878 870 } … … 891 883 std::list<Statement *> sts = caseStmt->get_statements(); 892 884 893 cur_indent += CodeGenerator::tabsize;885 ++indent; 894 886 for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end(); i++) { 895 887 output << indent << printLabels( (*i)->get_labels() ) ; … … 897 889 output << endl; 898 890 } // for 899 cur_indent -= CodeGenerator::tabsize;891 --indent; 900 892 } 901 893 -
src/CodeGen/CodeGenerator.h
r3b4571b r67a67af 23 23 #include "SynTree/Visitor.h" // for Visitor 24 24 #include "SynTree/SynTree.h" // for Visitor Nodes 25 26 #include "Common/Indenter.h" // for Indenter 25 27 26 28 namespace CodeGen { … … 100 102 template< class Iterator > void genCommaList( Iterator begin, Iterator end ); 101 103 102 struct Indenter {103 Indenter(CodeGenerator &cg) : cg(cg) {}104 CodeGenerator & cg;105 std::ostream& operator()(std::ostream & os) const;106 };107 108 104 struct LabelPrinter { 109 105 LabelPrinter(CodeGenerator &cg) : cg(cg), labels( 0 ) {} … … 128 124 private: 129 125 Indenter indent; 130 int cur_indent;131 126 bool insideFunction; 132 127 std::ostream &output;
Note: See TracChangeset
for help on using the changeset viewer.