Changeset c850687


Ignore:
Timestamp:
May 11, 2017, 11:07:58 AM (7 years ago)
Author:
Andrew Beach <ajbeach@…>
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:
8514fe19
Parents:
29cf9c8
Message:

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

Files:
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    r29cf9c8 rc850687  
    251251\lstdefinelanguage{CFA}[ANSI]{C}{
    252252        morekeywords={_Alignas,_Alignof,__alignof,__alignof__,asm,__asm,__asm__,_At,_Atomic,__attribute,__attribute__,auto,
    253                 _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,disable,dtype,enable,__extension__,
    254                 fallthrough,fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,_Noreturn,one_t,otype,restrict,_Static_assert,
    255                 _Thread_local,throw,throwResume,trait,try,ttype,typeof,__typeof,__typeof__,zero_t},
     253                _Bool,catch,catchResume,choose,_Complex,__complex,__complex__,__const,__const__,coroutine,disable,dtype,enable,__extension__,
     254                fallthrough,fallthru,finally,forall,ftype,_Generic,_Imaginary,inline,__label__,lvalue,monitor,mutex,_Noreturn,one_t,otype,restrict,_Static_assert,
     255                thread,_Thread_local,throw,throwResume,trait,try,ttype,typeof,__typeof,__typeof__,zero_t},
    256256}%
    257257
  • 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 " );
  • src/CodeGen/CodeGenerator.h

    r29cf9c8 rc850687  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  1 16:20:04 2017
    13 // Update Count     : 50
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed May 10 10:57:00 2017
     13// Update Count     : 51
    1414//
    1515
     
    2525#include "SymTab/Indexer.h"
    2626
     27#include "Common/utility.h"
     28
    2729namespace CodeGen {
    2830        class CodeGenerator : public Visitor {
     
    3032                static int tabsize;
    3133
    32                 CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false );
     34                CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false );
    3335                CodeGenerator( std::ostream &os, std::string, int indent = 0, bool infun = false );
    3436                CodeGenerator( std::ostream &os, char *, int indent = 0, bool infun = false );
     
    110112                };
    111113
     114                struct LineMarker {
     115                        CodeLocation const & loc;
     116                        bool toPrint;
     117
     118                        LineMarker(CodeLocation const & loc, bool toPrint);
     119                };
     120
     121                LineMarker lineDirective(BaseSyntaxNode const * node);
     122
    112123                void asmName( DeclarationWithType *decl );
    113124
     
    122133                bool pretty = false;  // pretty print
    123134                bool genC = false;    // true if output has to be C code
     135                bool lineMarks = false;
    124136
    125137                void printDesignators( std::list< Expression * > & );
     
    149161        /// returns C-compatible name of declaration
    150162        std::string genName( DeclarationWithType * decl );
     163
     164        std::ostream & operator<<(std::ostream &,
     165                CodeGenerator::LineMarker const &);
    151166} // namespace CodeGen
    152167
  • src/CodeGen/GenType.cc

    r29cf9c8 rc850687  
    2828        class GenType : public Visitor {
    2929          public:
    30                 GenType( const std::string &typeString, bool pretty = false, bool genC = false );
     30                GenType( const std::string &typeString, bool pretty = false, bool genC = false, bool lineMarks = false );
    3131                std::string get_typeString() const { return typeString; }
    3232                void set_typeString( const std::string &newValue ) { typeString = newValue; }
     
    5454                bool pretty = false; // pretty print
    5555                bool genC = false;   // generating C code?
     56                bool lineMarks = false;
    5657        };
    5758
    58         std::string genType( Type *type, const std::string &baseString, bool pretty, bool genC ) {
    59                 GenType gt( baseString, pretty, genC );
     59        std::string genType( Type *type, const std::string &baseString, bool pretty, bool genC , bool lineMarks ) {
     60                GenType gt( baseString, pretty, genC, lineMarks );
    6061                std::ostringstream os;
    6162
    6263                if ( ! type->get_attributes().empty() ) {
    63                         CodeGenerator cg( os, pretty, genC );
     64                        CodeGenerator cg( os, pretty, genC, lineMarks );
    6465                        cg.genAttributes( type->get_attributes() );
    6566                } // if
     
    7374  }
    7475
    75         GenType::GenType( const std::string &typeString, bool pretty, bool genC ) : typeString( typeString ), pretty( pretty ), genC( genC ) {}
     76        GenType::GenType( const std::string &typeString, bool pretty, bool genC, bool lineMarks ) : typeString( typeString ), pretty( pretty ), genC( genC ), lineMarks( lineMarks ) {}
    7677
    7778        void GenType::visit( VoidType *voidType ) {
     
    114115                } // if
    115116                if ( dimension != 0 ) {
    116                         CodeGenerator cg( os, pretty, genC );
     117                        CodeGenerator cg( os, pretty, genC, lineMarks );
    117118                        dimension->accept( cg );
    118119                } else if ( isVarLen ) {
     
    168169                        } // if
    169170                } else {
    170                         CodeGenerator cg( os, pretty, genC );
     171                        CodeGenerator cg( os, pretty, genC, lineMarks );
    171172                        os << "(" ;
    172173
     
    191192                        // assertf( ! genC, "Aggregate type parameters should not reach code generation." );
    192193                        std::ostringstream os;
    193                         CodeGenerator cg( os, pretty, genC );
     194                        CodeGenerator cg( os, pretty, genC, lineMarks );
    194195                        os << "forall(";
    195196                        cg.genCommaList( funcType->get_forall().begin(), funcType->get_forall().end() );
     
    202203                if ( ! refType->get_parameters().empty() ) {
    203204                        std::ostringstream os;
    204                         CodeGenerator cg( os, pretty, genC );
     205                        CodeGenerator cg( os, pretty, genC, lineMarks );
    205206                        os << "(";
    206207                        cg.genCommaList( refType->get_parameters().begin(), refType->get_parameters().end() );
     
    242243                for ( Type * t : *tupleType ) {
    243244                        i++;
    244                         os << genType( t, "", pretty, genC ) << (i == tupleType->size() ? "" : ", ");
     245                        os << genType( t, "", pretty, genC, lineMarks ) << (i == tupleType->size() ? "" : ", ");
    245246                }
    246247                os << "]";
  • src/CodeGen/GenType.h

    r29cf9c8 rc850687  
    2121
    2222namespace CodeGen {
    23         std::string genType( Type *type, const std::string &baseString, bool pretty = false, bool genC = false );
     23        std::string genType( Type *type, const std::string &baseString, bool pretty = false, bool genC = false, bool lineMarks = false );
    2424  std::string genPrettyType( Type * type, const std::string & baseString );
    2525} // namespace CodeGen
  • src/CodeGen/Generate.cc

    r29cf9c8 rc850687  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  4 14:04:25 2015
    13 // Update Count     : 5
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed May 19 13:05:00 2017
     13// Update Count     : 6
    1414//
    1515
     
    3131
    3232namespace CodeGen {
    33         void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC ) {
    34                 CodeGen::CodeGenerator cgv( os, pretty, generateC );
     33        void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks ) {
     34                CodeGen::CodeGenerator cgv( os, pretty, generateC, lineMarks );
    3535                for ( auto & dcl : translationUnit ) {
    3636                        if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) {
     37                                os << cgv.lineDirective(dcl);
    3738                                dcl->accept(cgv);
    3839                                if ( doSemicolon( dcl ) ) {
     
    4849                        os << CodeGen::genPrettyType( type, "" );
    4950                } else {
    50                         CodeGen::CodeGenerator cgv( os, true, false );
     51                        CodeGen::CodeGenerator cgv( os, true, false, false );
    5152                        node->accept( cgv );
    5253                }
  • src/CodeGen/Generate.h

    r29cf9c8 rc850687  
    2424namespace CodeGen {
    2525        /// Generates code. doIntrinsics determines if intrinsic functions are printed, pretty formats output nicely (e.g., uses unmangled names, etc.), generateC is true when the output must consist only of C code (allows some assertions, etc.)
    26         void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false );
     26        void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false , bool lineMarks = false );
    2727
    2828        /// Generate code for a single node -- helpful for debugging in gdb
  • src/main.cc

    r29cf9c8 rc850687  
     1
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     
    910// Author           : Richard C. Bilson
    1011// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 14 14:35:54 2016
    13 // Update Count     : 436
     12// Last Modified By : Andrew Beach
     13// Last Modified On : Wed May 10 14:45:00 2017
     14// Update Count     : 437
    1415//
    1516
     
    7980        errorp = false,
    8081        codegenp = false,
    81         prettycodegenp = false;
     82        prettycodegenp = false,
     83        nolinemarks = false;
    8284
    8385static void parse_cmdline( int argc, char *argv[], const char *& filename );
     
    310312
    311313                CodeTools::fillLocations( translationUnit );
    312                 CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true );
     314                CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, ! nolinemarks );
    313315
    314316                CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
     
    336338        } catch ( CompilerError &e ) {
    337339                cerr << "Compiler Error: " << e.get_what() << endl;
    338                 cerr << "(please report bugs to " << endl;
     340                cerr << "(please report bugs to [REDACTED])" << endl;
    339341                if ( output != &cout ) {
    340342                        delete output;
     
    375377
    376378        int c;
    377         while ( (c = getopt_long( argc, argv, "abBcdefglmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
     379        while ( (c = getopt_long( argc, argv, "abBcdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
    378380                switch ( c ) {
    379381                  case Ast:
     
    411413                  case 'l':                                                                             // generate libcfa.c
    412414                        libcfap = true;
     415                        break;
     416                  case 'L':                                                                             // surpress lines marks
     417                        nolinemarks = true;
    413418                        break;
    414419                  case Nopreamble:
Note: See TracChangeset for help on using the changeset viewer.