Changes in / [1ce2189:a5de33e]
- Location:
- src
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r1ce2189 ra5de33e 66 66 } // extension 67 67 68 ostream & CodeGenerator::Indenter::operator()( ostream & output ) const {69 return output << string( cg.cur_indent, ' ' );70 }71 72 ostream & operator<<( ostream & output, const CodeGenerator::Indenter &indent ) {73 return indent( output );74 }75 76 68 CodeGenerator::LabelPrinter & CodeGenerator::LabelPrinter::operator()( std::list< Label > & l ) { 77 69 labels = &l; … … 111 103 } 112 104 113 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 ) {}105 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 ) {} 114 106 115 107 string CodeGenerator::mangleName( DeclarationWithType * decl ) { … … 202 194 output << " {" << endl; 203 195 204 cur_indent += CodeGenerator::tabsize;196 ++indent; 205 197 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) { 206 198 output << lineDirective( *i ) << indent; … … 209 201 } // for 210 202 211 cur_indent -= CodeGenerator::tabsize;203 --indent; 212 204 213 205 output << indent << "}"; … … 239 231 output << " {" << endl; 240 232 241 cur_indent += CodeGenerator::tabsize;233 ++indent; 242 234 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 243 235 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i ); … … 251 243 } // for 252 244 253 cur_indent -= CodeGenerator::tabsize;245 --indent; 254 246 255 247 output << indent << "}"; … … 755 747 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids(); 756 748 output << lineDirective( stmtExpr) << "({" << std::endl; 757 cur_indent += CodeGenerator::tabsize;749 ++indent; 758 750 unsigned int numStmts = stmts.size(); 759 751 unsigned int i = 0; … … 778 770 ++i; 779 771 } 780 cur_indent -= CodeGenerator::tabsize;772 --indent; 781 773 output << indent << "})"; 782 774 } … … 787 779 output << "{" << endl; 788 780 789 cur_indent += CodeGenerator::tabsize;781 ++indent; 790 782 791 783 for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end(); i++ ) { … … 798 790 } // if 799 791 } // for 800 cur_indent -= CodeGenerator::tabsize;792 --indent; 801 793 802 794 output << indent << "}"; … … 866 858 867 859 output << "{" << std::endl; 868 cur_indent += CodeGenerator::tabsize;860 ++indent; 869 861 acceptAll( switchStmt->get_statements(), *this ); 870 cur_indent -= CodeGenerator::tabsize;862 --indent; 871 863 output << indent << "}"; 872 864 } … … 885 877 std::list<Statement *> sts = caseStmt->get_statements(); 886 878 887 cur_indent += CodeGenerator::tabsize;879 ++indent; 888 880 for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end(); i++) { 889 881 output << indent << printLabels( (*i)->get_labels() ) ; … … 891 883 output << endl; 892 884 } // for 893 cur_indent -= CodeGenerator::tabsize;885 --indent; 894 886 } 895 887 -
src/CodeGen/CodeGenerator.h
r1ce2189 ra5de33e 25 25 #include "SymTab/Indexer.h" 26 26 27 #include "Common/Indenter.h" 27 28 #include "Common/utility.h" 28 29 … … 102 103 template< class Iterator > void genCommaList( Iterator begin, Iterator end ); 103 104 104 struct Indenter {105 Indenter(CodeGenerator &cg) : cg(cg) {}106 CodeGenerator & cg;107 std::ostream& operator()(std::ostream & os) const;108 };109 110 105 struct LabelPrinter { 111 106 LabelPrinter(CodeGenerator &cg) : cg(cg), labels( 0 ) {} … … 130 125 private: 131 126 Indenter indent; 132 int cur_indent;133 127 bool insideFunction; 134 128 std::ostream &output; -
src/ResolvExpr/CurrentObject.cc
r1ce2189 ra5de33e 19 19 #include "CurrentObject.h" 20 20 21 #include "Common/Indenter.h" 22 21 23 #include "SynTree/Declaration.h" 22 24 #include "SynTree/Initializer.h" … … 45 47 assertf( false, "unhandled type on getConstValue %s", toString( constExpr->get_result() ).c_str() ); // xxx - might be semantic error 46 48 } 47 }48 49 struct Indenter {50 static const int amt = 2;51 unsigned int indent = 0;52 53 Indenter & operator+=(int nlevels) { indent += amt*nlevels; return *this; }54 Indenter & operator-=(int nlevels) { indent -= amt*nlevels; return *this; }55 Indenter operator+(int nlevels) { Indenter indenter = *this; return indenter += nlevels; }56 Indenter operator-(int nlevels) { Indenter indenter = *this; return indenter -= nlevels; }57 Indenter & operator++() { return *this += 1; }58 Indenter & operator--() { return *this -= 1; }59 };60 std::ostream & operator<<( std::ostream & out, Indenter & indent ) {61 return out << std::string(indent.indent, ' ');62 49 } 63 50 -
src/ResolvExpr/CurrentObject.h
r1ce2189 ra5de33e 25 25 class MemberIterator; 26 26 27 // TODO: memory management of MemberIterators 27 28 class CurrentObject { 28 29 public:
Note: See TracChangeset
for help on using the changeset viewer.