Ignore:
Timestamp:
Sep 20, 2017, 11:47:26 AM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
47b5b63
Parents:
a9a4771
git-author:
Rob Schluntz <rschlunt@…> (09/20/17 11:46:26)
git-committer:
Rob Schluntz <rschlunt@…> (09/20/17 11:47:26)
Message:

Cleanup CodeGen? and make linemarkers a bit more accurate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.h

    ra9a4771 rd22e90f  
    3131
    3232                CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false );
    33                 CodeGenerator( std::ostream &os, std::string, int indent = 0, bool infun = false );
    34                 CodeGenerator( std::ostream &os, char *, int indent = 0, bool infun = false );
    3533
    3634                //*** Turn off visit_children for all nodes
     
    125123
    126124                void updateLocation( BaseSyntaxNode const * to );
     125                struct LineEnder {
     126                        CodeGenerator & cg;
     127                        LineEnder( CodeGenerator & cg ) : cg( cg ) {}
     128                        std::ostream & operator()(std::ostream &) const;
     129                };
    127130          private:
    128131                Indenter indent;
    129                 bool insideFunction;
    130                 std::ostream &output;
     132                std::ostream & output;
    131133                LabelPrinter printLabels;
    132134                bool pretty = false;  // pretty print
    133135                bool genC = false;    // true if output has to be C code
    134136                bool lineMarks = false;
     137        public:
     138                LineEnder endl;
     139        private:
    135140
    136141                CodeLocation currentLocation;
    137142                void updateLocation( CodeLocation const & to );
    138                 void nextLine();
    139143
    140144                void handleStorageClass( DeclarationWithType *decl );
     
    163167        /// returns C-compatible name of declaration
    164168        std::string genName( DeclarationWithType * decl );
     169
     170        inline std::ostream & operator<<( std::ostream & os, const CodeGenerator::LineEnder & endl ) {
     171                return endl( os );
     172        }
    165173} // namespace CodeGen
    166174
Note: See TracChangeset for help on using the changeset viewer.