Ignore:
Timestamp:
May 11, 2017, 11:07:58 AM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
8514fe19
Parents:
29cf9c8
Message:

Add -L flag to turn of line marks. Updated the keyword list.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r29cf9c8 rc850687  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus May  9 16:50:00 2017
     12// Last Modified On : Wed May 10 14:45:00 2017
    1313// Update Count     : 484
    1414//
     
    4141namespace CodeGen {
    4242        int CodeGenerator::tabsize = 4;
    43 
    44         // Pseudo Function: output << lineDirective(currentNode);
    45     struct lineDirective {
    46         CodeLocation const & loc;
    47                 lineDirective(CodeLocation const & location) : loc(location) {}
    48                 lineDirective(BaseSyntaxNode const * node) : loc(node->location) {}
    49         };
    50         std::ostream & operator<<(std::ostream & out, lineDirective const & ld) {
    51                 if (ld.loc.isSet())
    52                         return out << "\n# " << ld.loc.linenumber << " \""
    53                                 << ld.loc.filename << "\"\n";
    54                 return out << "\n// Unset Location\n";
    55         }
    5643
    5744        // the kinds of statements that would ideally be followed by whitespace
     
    10289        }
    10390
    104         CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), pretty( pretty ), genC( genC ) {}
     91        CodeGenerator::LineMarker::LineMarker(
     92                        CodeLocation const & loc, bool toPrint) :
     93                loc(loc), toPrint(toPrint)
     94        {}
     95
     96        CodeGenerator::LineMarker CodeGenerator::lineDirective(
     97                        BaseSyntaxNode const * node) {
     98                return LineMarker(node->location, lineMarks);
     99        }
     100
     101        std::ostream & operator<<(std::ostream & out,
     102                        CodeGenerator::LineMarker const & marker) {
     103                if (marker.toPrint && marker.loc.isSet()) {
     104                        return out << "\n# " << marker.loc.linenumber << " \""
     105                                << marker.loc.filename << "\"\n";
     106                } else if (marker.toPrint) {
     107                        return out << "\n/* Missing CodeLocation */\n";
     108                } else {
     109                return out;
     110                }
     111        }
     112
     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 ) {}
    105114
    106115        CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )
     
    143152        // *** Declarations
    144153        void CodeGenerator::visit( FunctionDecl * functionDecl ) {
    145                 output << lineDirective( functionDecl );
    146 
    147154                extension( functionDecl );
    148155                genAttributes( functionDecl->get_attributes() );
     
    168175                }
    169176
    170                 output << lineDirective( objectDecl );
    171 
    172177                extension( objectDecl );
    173178                genAttributes( objectDecl->get_attributes() );
     
    221226
    222227        void CodeGenerator::visit( StructDecl * structDecl ) {
    223                 output << lineDirective( structDecl );
    224 
    225228                extension( structDecl );
    226229                handleAggregate( structDecl, "struct " );
     
    228231
    229232        void CodeGenerator::visit( UnionDecl * unionDecl ) {
    230                 output << lineDirective( unionDecl );
    231 
    232233                extension( unionDecl );
    233234                handleAggregate( unionDecl, "union " );
Note: See TracChangeset for help on using the changeset viewer.