Changeset 937e51d for src/CodeGen


Ignore:
Timestamp:
Jun 26, 2015, 4:00:26 PM (11 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, stuck-waitfor-destruct, with_gc
Children:
0df292b, e0ff3e6
Parents:
eb50842 (diff), 1869adf (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.
Message:

Merge pointer to pointer to qualified fix into master

Location:
src/CodeGen
Files:
5 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    reb50842 r937e51d  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CodeGenerator2.cc --
     7// CodeGenerator.cc --
    88//
    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 May 21 17:13:35 2015
    13 // Update Count     : 7
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Jun 24 16:11:41 2015
     13// Update Count     : 143
    1414//
    1515
     
    1919#include <list>
    2020
     21#include "Parser/ParseNode.h"
     22
    2123#include "SynTree/Type.h"
    22 #include "SynTree/Declaration.h"
    23 #include "SynTree/Statement.h"
    2424#include "SynTree/Expression.h"
    2525#include "SynTree/Initializer.h"
     26#include "SynTree/Statement.h"
    2627
    2728#include "utility.h"
    2829#include "UnimplementedError.h"
    2930
    30 #include "CodeGenerator2.h"
     31#include "CodeGenerator.h"
    3132#include "OperatorTable.h"
    3233#include "GenType.h"
     
    3536
    3637namespace CodeGen {
    37         int CodeGenerator2::tabsize = 4;
    38 
    39         CodeGenerator2::CodeGenerator2( std::ostream &os ) : cur_indent( 0 ), insideFunction( false ), before( os ), after() { }
    40 
    41         CodeGenerator2::CodeGenerator2( std::ostream &os, std::string init, int indent, bool infunp )
    42                 : cur_indent( indent ), insideFunction( infunp ), before( os ) {
    43                 //before << std::string( init );
    44         }
    45 
    46         CodeGenerator2::CodeGenerator2( std::ostream &os, char *init, int indent, bool infunp )
    47                 : cur_indent( indent ), insideFunction( infunp ), before( os ) {
    48                 //before << std::string( init );
     38        int CodeGenerator::tabsize = 4;
     39
     40        // the kinds of statements that would ideally be separated by more whitespace
     41        bool wantSpacing( Statement * stmt) {
     42                return dynamic_cast< IfStmt * >( stmt ) || dynamic_cast< CompoundStmt * >( stmt ) ||
     43                        dynamic_cast< WhileStmt * >( stmt ) || dynamic_cast< ForStmt * > ( stmt ) || dynamic_cast< SwitchStmt *>( stmt );
     44        }
     45
     46        ostream & CodeGenerator::Indenter::operator()( ostream & output ) {
     47          return output << string( cg.cur_indent, ' ' );
     48        }
     49
     50        ostream & operator<<( ostream & output, CodeGenerator::Indenter &indent ) {
     51                return indent( output );
     52        }
     53
     54        CodeGenerator::CodeGenerator( std::ostream &os ) : indent(*this), cur_indent( 0 ), insideFunction( false ), output( os ) { }
     55
     56        CodeGenerator::CodeGenerator( std::ostream &os, std::string init, int indentation, bool infunp )
     57                        : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) {
     58                //output << std::string( init );
     59        }
     60
     61        CodeGenerator::CodeGenerator( std::ostream &os, char *init, int indentation, bool infunp )
     62                        : indent(*this), cur_indent( indentation ), insideFunction( infunp ), output( os ) {
     63                //output << std::string( init );
    4964        }
    5065
     
    5671                } // if
    5772        }
    58  
     73
    5974        //*** Declarations
    60         void CodeGenerator2::visit( FunctionDecl *functionDecl ) {
     75        void CodeGenerator::visit( FunctionDecl *functionDecl ) {
    6176                handleStorageClass( functionDecl );
    62                 before << genType( functionDecl->get_functionType(), mangleName( functionDecl ) );
     77                if ( functionDecl->get_isInline() ) {
     78                        output << "inline ";
     79                } // if
     80                if ( functionDecl->get_isNoreturn() ) {
     81                        output << "_Noreturn ";
     82                } // if
     83                output << genType( functionDecl->get_functionType(), mangleName( functionDecl ) );
    6384
    6485                // how to get this to the Functype?
    6586                std::list< Declaration * > olds = functionDecl->get_oldDecls();
    6687                if ( ! olds.empty() ) {
    67                         before << " /* function has old declaration */";
     88                        output << " /* function has old declaration */";
    6889                } // if
    6990
     
    7495        }
    7596
    76         void CodeGenerator2::visit( ObjectDecl *objectDecl ) {
     97        void CodeGenerator::visit( ObjectDecl *objectDecl ) {
    7798                handleStorageClass( objectDecl );
    78                 before << genType( objectDecl->get_type(), mangleName( objectDecl ) );
     99                output << genType( objectDecl->get_type(), mangleName( objectDecl ) );
    79100       
    80101                if ( objectDecl->get_init() ) {
    81                         before << " = ";
     102                        output << " = ";
    82103                        objectDecl->get_init()->accept( *this );
    83104                } // if
    84105                if ( objectDecl->get_bitfieldWidth() ) {
    85                         before << ":";
     106                        output << ":";
    86107                        objectDecl->get_bitfieldWidth()->accept( *this );
    87108                } // if
    88109        }
    89110
    90         void CodeGenerator2::handleAggregate( AggregateDecl *aggDecl ) {
     111        void CodeGenerator::handleAggregate( AggregateDecl *aggDecl ) {
    91112                if ( aggDecl->get_name() != "" )
    92                         before << aggDecl->get_name();
     113                        output << aggDecl->get_name();
    93114       
    94115                std::list< Declaration * > &memb = aggDecl->get_members();
    95116
    96117                if ( ! memb.empty() ) {
    97                         before << endl << string( cur_indent, ' ' ) << "{" << endl;
    98 
    99                         cur_indent += CodeGenerator2::tabsize;
     118                        output << " {" << endl;
     119
     120                        cur_indent += CodeGenerator::tabsize;
    100121                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    101                                 before << string( cur_indent, ' ' );
     122                                output << indent;
    102123                                (*i)->accept(*this );
    103                                 before << ";" << endl;
     124                                output << ";" << endl;
    104125                        }
    105126
    106                         cur_indent -= CodeGenerator2::tabsize;
    107 
    108                         before << string( cur_indent, ' ' ) << "}";
    109                 } // if
    110         }
    111 
    112         void CodeGenerator2::visit( StructDecl *structDecl ) {
    113                 before << "struct ";
     127                        cur_indent -= CodeGenerator::tabsize;
     128
     129                        output << indent << "}";
     130                } // if
     131        }
     132
     133        void CodeGenerator::visit( StructDecl *structDecl ) {
     134                output << "struct ";
    114135                handleAggregate( structDecl );
    115136        }
    116137
    117         void CodeGenerator2::visit( UnionDecl *aggregateDecl ) {
    118                 before << "union ";
     138        void CodeGenerator::visit( UnionDecl *aggregateDecl ) {
     139                output << "union ";
    119140                handleAggregate( aggregateDecl );
    120141        }
    121142 
    122         void CodeGenerator2::visit( EnumDecl *aggDecl ) {
    123                 before << "enum ";
     143        void CodeGenerator::visit( EnumDecl *aggDecl ) {
     144                output << "enum ";
    124145
    125146                if ( aggDecl->get_name() != "" )
    126                         before << aggDecl->get_name();
     147                        output << aggDecl->get_name();
    127148       
    128149                std::list< Declaration* > &memb = aggDecl->get_members();
    129150
    130151                if ( ! memb.empty() ) {
    131                         before << endl << "{" << endl;
    132 
    133                         cur_indent += CodeGenerator2::tabsize;
     152                        output << " {" << endl;
     153
     154                        cur_indent += CodeGenerator::tabsize;
    134155                        for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
    135156                                ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i );
    136157                                assert( obj );
    137                                 before << string( cur_indent, ' ' ) << mangleName( obj );
     158                                output << indent << mangleName( obj );
    138159                                if ( obj->get_init() ) {
    139                                         before << " = ";
     160                                        output << " = ";
    140161                                        obj->get_init()->accept(*this );
    141162                                } // if
    142                                 before << "," << endl;
     163                                output << "," << endl;
    143164                        } // for
    144165
    145                         cur_indent -= CodeGenerator2::tabsize;
    146 
    147                         before << "}" << endl;
    148                 } // if
    149         }
    150  
    151         void CodeGenerator2::visit( ContextDecl *aggregateDecl ) {}
    152  
    153         void CodeGenerator2::visit( TypedefDecl *typeDecl ) {
    154                 before << "typedef ";
    155                 before << genType( typeDecl->get_base(), typeDecl->get_name() );
    156         }
    157  
    158         void CodeGenerator2::visit( TypeDecl *typeDecl ) {
     166                        cur_indent -= CodeGenerator::tabsize;
     167
     168                        output << indent << "}";
     169                } // if
     170        }
     171 
     172        void CodeGenerator::visit( ContextDecl *aggregateDecl ) {}
     173 
     174        void CodeGenerator::visit( TypedefDecl *typeDecl ) {
     175                output << "typedef ";
     176                output << genType( typeDecl->get_base(), typeDecl->get_name() );
     177        }
     178 
     179        void CodeGenerator::visit( TypeDecl *typeDecl ) {
    159180                // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes,
    160181                // still to be done
    161                 before << "extern unsigned long " << typeDecl->get_name();
     182                output << "extern unsigned long " << typeDecl->get_name();
    162183                if ( typeDecl->get_base() ) {
    163                         before << " = sizeof( " << genType( typeDecl->get_base(), "" ) << " )";
    164                 } // if
    165         }
    166 
    167         void CodeGenerator2::visit( SingleInit *init ) {
     184                        output << " = sizeof( " << genType( typeDecl->get_base(), "" ) << " )";
     185                } // if
     186        }
     187
     188        void CodeGenerator::visit( SingleInit *init ) {
    168189                init->get_value()->accept( *this );
    169190        }
    170191
    171         void CodeGenerator2::visit( ListInit *init ) {
    172                 before << "{ ";
     192        void CodeGenerator::visit( ListInit *init ) {
     193                output << "{ ";
    173194                genCommaList( init->begin_initializers(), init->end_initializers() );
    174                 before << " }";
    175         }
    176 
    177         void CodeGenerator2::visit( Constant *constant ) {
    178                 before << constant->get_value() ;
     195                output << " }";
     196        }
     197
     198        void CodeGenerator::visit( Constant *constant ) {
     199                output << constant->get_value() ;
    179200        }
    180201
    181202        //*** Expressions
    182         void CodeGenerator2::visit( ApplicationExpr *applicationExpr ) {
     203        void CodeGenerator::visit( ApplicationExpr *applicationExpr ) {
    183204                if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
    184205                        OperatorInfo opInfo;
     
    211232                                        assert( applicationExpr->get_args().size() == 2 );
    212233                                        (*arg++)->accept( *this );
    213                                         before << "[";
    214                                         (*arg)->accept( *this );
    215                                         before << "]";
     234                                        output << "[";
     235                                        (*arg)->accept( *this );
     236                                        output << "]";
    216237                                        break;
    217238             
     
    224245                                  case OT_PREFIXASSIGN:
    225246                                        assert( applicationExpr->get_args().size() == 1 );
    226                                         before << "(";
    227                                         before << opInfo.symbol;
    228                                         (*arg)->accept( *this );
    229                                         before << ")";
     247                                        output << "(";
     248                                        output << opInfo.symbol;
     249                                        (*arg)->accept( *this );
     250                                        output << ")";
    230251                                        break;
    231252             
     
    234255                                        assert( applicationExpr->get_args().size() == 1 );
    235256                                        (*arg)->accept( *this );
    236                                         before << opInfo.symbol;
     257                                        output << opInfo.symbol;
    237258                                        break;
    238259
     
    240261                                  case OT_INFIXASSIGN:
    241262                                        assert( applicationExpr->get_args().size() == 2 );
    242                                         before << "(";
     263                                        output << "(";
    243264                                        (*arg++)->accept( *this );
    244                                         before << opInfo.symbol;
    245                                         (*arg)->accept( *this );
    246                                         before << ")";
     265                                        output << opInfo.symbol;
     266                                        (*arg)->accept( *this );
     267                                        output << ")";
    247268                                        break;
    248269             
     
    253274                        } else {
    254275                                varExpr->accept( *this );
    255                                 before << "(";
     276                                output << "(";
    256277                                genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() );
    257                                 before << ")";
     278                                output << ")";
    258279                        } // if
    259280                } else {
    260281                        applicationExpr->get_function()->accept( *this );
    261                         before << "(";
     282                        output << "(";
    262283                        genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() );
    263                         before << ")";
    264                 } // if
    265         }
    266  
    267         void CodeGenerator2::visit( UntypedExpr *untypedExpr ) {
     284                        output << ")";
     285                } // if
     286        }
     287 
     288        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
    268289                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
    269290                        OperatorInfo opInfo;
     
    274295                                        assert( untypedExpr->get_args().size() == 2 );
    275296                                        (*arg++)->accept( *this );
    276                                         before << "[";
    277                                         (*arg)->accept( *this );
    278                                         before << "]";
     297                                        output << "[";
     298                                        (*arg)->accept( *this );
     299                                        output << "]";
    279300                                        break;
    280301             
     
    285306                                  case OT_PREFIX:
    286307                                  case OT_PREFIXASSIGN:
     308                                  case OT_LABELADDRESS:
    287309                                        assert( untypedExpr->get_args().size() == 1 );
    288                                         before << "(";
    289                                         before << opInfo.symbol;
    290                                         (*arg)->accept( *this );
    291                                         before << ")";
     310                                        output << "(";
     311                                        output << opInfo.symbol;
     312                                        (*arg)->accept( *this );
     313                                        output << ")";
    292314                                        break;
    293315             
     
    296318                                        assert( untypedExpr->get_args().size() == 1 );
    297319                                        (*arg)->accept( *this );
    298                                         before << opInfo.symbol;
     320                                        output << opInfo.symbol;
    299321                                        break;
    300322 
     
    302324                                  case OT_INFIXASSIGN:
    303325                                        assert( untypedExpr->get_args().size() == 2 );
    304                                         before << "(";
     326                                        output << "(";
    305327                                        (*arg++)->accept( *this );
    306                                         before << opInfo.symbol;
    307                                         (*arg)->accept( *this );
    308                                         before << ")";
    309                                         break;
    310              
     328                                        output << opInfo.symbol;
     329                                        (*arg)->accept( *this );
     330                                        output << ")";
     331                                        break;
     332                                       
    311333                                  case OT_CONSTANT:
    312334                                        // there are no intrinsic definitions of 0 or 1 as functions
     
    315337                        } else {
    316338                                nameExpr->accept( *this );
    317                                 before << "(";
     339                                output << "(";
    318340                                genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() );
    319                                 before << ")";
     341                                output << ")";
    320342                        } // if
    321343                } else {
    322344                        untypedExpr->get_function()->accept( *this );
    323                         before << "(";
     345                        output << "(";
    324346                        genCommaList( untypedExpr->get_args().begin(), untypedExpr->get_args().end() );
    325                         before << ")";
    326                 } // if
    327         }
    328  
    329         void CodeGenerator2::visit( NameExpr *nameExpr ) {
     347                        output << ")";
     348                } // if
     349        }
     350 
     351        void CodeGenerator::visit( NameExpr *nameExpr ) {
    330352                OperatorInfo opInfo;
    331353                if ( operatorLookup( nameExpr->get_name(), opInfo ) ) {
    332354                        assert( opInfo.type == OT_CONSTANT );
    333                         before << opInfo.symbol;
    334                 } else {
    335                         before << nameExpr->get_name();
    336                 } // if
    337         }
    338  
    339         void CodeGenerator2::visit( AddressExpr *addressExpr ) {
    340                 before << "(&";
     355                        output << opInfo.symbol;
     356                } else {
     357                        output << nameExpr->get_name();
     358                } // if
     359        }
     360 
     361        void CodeGenerator::visit( AddressExpr *addressExpr ) {
     362                output << "(&";
    341363                // this hack makes sure that we don't convert "constant_zero" to "0" if we're taking its address
    342364                if ( VariableExpr *variableExpr = dynamic_cast< VariableExpr* >( addressExpr->get_arg() ) ) {
    343                         before << mangleName( variableExpr->get_var() );
     365                        output << mangleName( variableExpr->get_var() );
    344366                } else {
    345367                        addressExpr->get_arg()->accept( *this );
    346368                } // if
    347                 before << ")";
    348         }
    349 
    350         void CodeGenerator2::visit( CastExpr *castExpr ) {
    351                 before << "((";
     369                output << ")";
     370        }
     371
     372        void CodeGenerator::visit( CastExpr *castExpr ) {
     373                output << "((";
    352374                if ( castExpr->get_results().empty() ) {
    353                         before << "void" ;
    354                 } else {
    355                         before << genType( castExpr->get_results().front(), "" );
    356                 } // if
    357                 before << ")";
     375                        output << "void" ;
     376                } else {
     377                        output << genType( castExpr->get_results().front(), "" );
     378                } // if
     379                output << ")";
    358380                castExpr->get_arg()->accept( *this );
    359                 before << ")";
    360         }
    361  
    362         void CodeGenerator2::visit( UntypedMemberExpr *memberExpr ) {
     381                output << ")";
     382        }
     383 
     384        void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) {
    363385                assert( false );
    364386        }
    365387 
    366         void CodeGenerator2::visit( MemberExpr *memberExpr ) {
     388        void CodeGenerator::visit( MemberExpr *memberExpr ) {
    367389                memberExpr->get_aggregate()->accept( *this );
    368                 before << "." << mangleName( memberExpr->get_member() );
    369         }
    370  
    371         void CodeGenerator2::visit( VariableExpr *variableExpr ) {
     390                output << "." << mangleName( memberExpr->get_member() );
     391        }
     392 
     393        void CodeGenerator::visit( VariableExpr *variableExpr ) {
    372394                OperatorInfo opInfo;
    373395                if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( variableExpr->get_var()->get_name(), opInfo ) && opInfo.type == OT_CONSTANT ) {
    374                         before << opInfo.symbol;
    375                 } else {
    376                         before << mangleName( variableExpr->get_var() );
    377                 } // if
    378         }
    379  
    380         void CodeGenerator2::visit( ConstantExpr *constantExpr ) {
     396                        output << opInfo.symbol;
     397                } else {
     398                        output << mangleName( variableExpr->get_var() );
     399                } // if
     400        }
     401 
     402        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    381403                assert( constantExpr->get_constant() );
    382404                constantExpr->get_constant()->accept( *this );
    383405        }
    384406 
    385         void CodeGenerator2::visit( SizeofExpr *sizeofExpr ) {
    386                 before << "sizeof(";
     407        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
     408                output << "sizeof(";
    387409                if ( sizeofExpr->get_isType() ) {
    388                         before << genType( sizeofExpr->get_type(), "" );
     410                        output << genType( sizeofExpr->get_type(), "" );
    389411                } else {
    390412                        sizeofExpr->get_expr()->accept( *this );
    391413                } // if
    392                 before << ")";
    393         }
    394  
    395         void CodeGenerator2::visit( LogicalExpr *logicalExpr ) {
    396                 before << "(";
     414                output << ")";
     415        }
     416 
     417        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
     418                output << "(";
    397419                logicalExpr->get_arg1()->accept( *this );
    398420                if ( logicalExpr->get_isAnd() ) {
    399                         before << " && ";
    400                 } else {
    401                         before << " || ";
     421                        output << " && ";
     422                } else {
     423                        output << " || ";
    402424                } // if
    403425                logicalExpr->get_arg2()->accept( *this );
    404                 before << ")";
    405         }
    406  
    407         void CodeGenerator2::visit( ConditionalExpr *conditionalExpr ) {
    408                 before << "(";
     426                output << ")";
     427        }
     428 
     429        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
     430                output << "(";
    409431                conditionalExpr->get_arg1()->accept( *this );
    410                 before << " ? ";
     432                output << " ? ";
    411433                conditionalExpr->get_arg2()->accept( *this );
    412                 before << " : ";
     434                output << " : ";
    413435                conditionalExpr->get_arg3()->accept( *this );
    414                 before << ")";
    415         }
    416  
    417         void CodeGenerator2::visit( CommaExpr *commaExpr ) {
    418                 before << "(";
     436                output << ")";
     437        }
     438 
     439        void CodeGenerator::visit( CommaExpr *commaExpr ) {
     440                output << "(";
    419441                commaExpr->get_arg1()->accept( *this );
    420                 before << " , ";
     442                output << " , ";
    421443                commaExpr->get_arg2()->accept( *this );
    422                 before << ")";
    423         }
    424  
    425         void CodeGenerator2::visit( TupleExpr *tupleExpr ) {}
    426  
    427         void CodeGenerator2::visit( TypeExpr *typeExpr ) {}
    428  
    429  
     444                output << ")";
     445        }
     446 
     447        void CodeGenerator::visit( TupleExpr *tupleExpr ) {}
     448 
     449        void CodeGenerator::visit( TypeExpr *typeExpr ) {}
     450
    430451        //*** Statements
    431         void CodeGenerator2::visit( CompoundStmt *compoundStmt ) {
     452        void CodeGenerator::visit( CompoundStmt *compoundStmt ) {
    432453                std::list<Statement*> ks = compoundStmt->get_kids();
    433 
    434                 before << endl << string( cur_indent, ' ' ) << "{" << endl;
    435 
    436                 cur_indent += CodeGenerator2::tabsize;
     454                output << "{" << endl;
     455
     456                cur_indent += CodeGenerator::tabsize;
    437457
    438458                for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end();  i++) {
    439                         before << string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() )  ;
     459                        output << indent << printLabels( (*i)->get_labels() );
    440460                        (*i)->accept(*this );
    441                         shift_left();
    442                         before << endl;
     461
     462                        output << endl;
     463                        if ( wantSpacing( *i ) ) {
     464                                output << endl;
     465                        }
    443466                }
    444                 cur_indent -= CodeGenerator2::tabsize;
    445 
    446                 before << string( cur_indent, ' ' ) << "}" << endl;
    447         }
    448 
    449         void CodeGenerator2::visit( ExprStmt *exprStmt ) {
    450                 if ( exprStmt != 0 ) {
    451                         exprStmt->get_expr()->accept( *this );
    452                         shift_left();
    453                         before << ";" ;
    454                 } // if
    455         }
    456 
    457         void CodeGenerator2::visit( IfStmt *ifStmt ) {
    458                 before << "if (";
     467                cur_indent -= CodeGenerator::tabsize;
     468
     469                output << indent << "}";
     470        }
     471
     472        void CodeGenerator::visit( ExprStmt *exprStmt ) {
     473                // I don't see why this check is necessary.
     474                // If this starts to cause problems then put it back in,
     475                // with an explanation
     476                assert( exprStmt );
     477
     478                // if ( exprStmt != 0 ) {
     479                exprStmt->get_expr()->accept( *this );
     480                output << ";" ;
     481                // } // if
     482        }
     483
     484        void CodeGenerator::visit( IfStmt *ifStmt ) {
     485                output << "if (";
    459486                ifStmt->get_condition()->accept(*this );
    460                 after += ")\n";
    461                 shift_left();
    462 
    463                 cur_indent += CodeGenerator2::tabsize;
    464                 before << string( cur_indent, ' ' );
     487                output << ") ";
     488
    465489                ifStmt->get_thenPart()->accept(*this );
    466                 cur_indent -= CodeGenerator2::tabsize;
    467                 shift_left(); before << endl;
    468490
    469491                if ( ifStmt->get_elsePart() != 0) {
    470                         before << string( cur_indent, ' ' ) << " else " << endl ;
    471 
    472                         cur_indent += CodeGenerator2::tabsize;
     492                        output << " else ";
    473493                        ifStmt->get_elsePart()->accept(*this );
    474                         cur_indent -= CodeGenerator2::tabsize;
    475                 } // if
    476         }
    477 
    478         void CodeGenerator2::visit( SwitchStmt *switchStmt ) {
    479                 //before << /* "\r" << */ string( cur_indent, ' ' ) << CodeGenerator2::printLabels( switchStmt->get_labels() )
    480                 before << "switch (" ;
     494                } // if
     495        }
     496
     497        void CodeGenerator::visit( SwitchStmt *switchStmt ) {
     498                output << "switch (" ;
    481499                switchStmt->get_condition()->accept(*this );
    482                 after += ")\n";
    483                 shift_left();
    484 
    485                 before << string( cur_indent, ' ' ) << "{" << std::endl;
    486                 cur_indent += CodeGenerator2::tabsize;
    487 
    488                 std::list< Statement * > stmts = switchStmt->get_branches();
    489                 bool lastBreak = false;
    490 
    491                 // horrible, horrible hack
    492                 if ( dynamic_cast<BranchStmt *>( stmts.back() ) != 0 ) {
    493                         lastBreak = true;
    494                         stmts.pop_back();
    495                 } // if
    496                 acceptAll( stmts, *this );
    497                 if ( lastBreak ) {
    498                         Statement *st = switchStmt->get_branches().back();
    499                         before << CodeGenerator2::printLabels( st->get_labels());
    500                         st->accept( *this );
    501                 } // if
    502          
    503                 cur_indent -= CodeGenerator2::tabsize;
    504 
    505                 before << /* "\r" << */ string( cur_indent, ' ' ) << "}" << endl ;
    506         }
    507 
    508         void CodeGenerator2::visit( CaseStmt *caseStmt ) {
    509                 before << string( cur_indent, ' ' );
    510                 if ( caseStmt->isDefault())
    511                         before << "default "  ;
    512                 else {
    513                         before << "case "  ;
     500                output << ") ";
     501               
     502                output << "{" << std::endl;
     503                cur_indent += CodeGenerator::tabsize;
     504
     505                acceptAll( switchStmt->get_branches(), *this );
     506
     507                cur_indent -= CodeGenerator::tabsize;
     508
     509                output << indent << "}";
     510        }
     511
     512        void CodeGenerator::visit( CaseStmt *caseStmt ) {
     513                output << indent;
     514                if ( caseStmt->isDefault()) {
     515                        output << "default";
     516                } else {
     517                        output << "case ";
    514518                        caseStmt->get_condition()->accept(*this );
    515519                } // if
    516                 after += ":\n";
    517                 shift_left();
    518 
     520                output << ":\n";
     521               
    519522                std::list<Statement *> sts = caseStmt->get_statements();
    520523
    521                 cur_indent += CodeGenerator2::tabsize;
     524                cur_indent += CodeGenerator::tabsize;
    522525                for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end();  i++) {
    523                         before << /* "\r" << */ string( cur_indent, ' ' ) << printLabels( (*i)->get_labels() )  ;
     526                        output << indent << printLabels( (*i)->get_labels() )  ;
    524527                        (*i)->accept(*this );
    525                         shift_left();
    526                         before << ";" << endl;
     528                        output << endl;
    527529                }
    528                 cur_indent -= CodeGenerator2::tabsize;
    529         }
    530 
    531         void CodeGenerator2::visit( BranchStmt *branchStmt ) {
     530                cur_indent -= CodeGenerator::tabsize;
     531        }
     532
     533        void CodeGenerator::visit( BranchStmt *branchStmt ) {
    532534                switch ( branchStmt->get_type()) {
    533535                  case BranchStmt::Goto:
    534536                        if ( ! branchStmt->get_target().empty() )
    535                                 before << "goto " << branchStmt->get_target();
     537                                output << "goto " << branchStmt->get_target();
    536538                        else {
    537539                                if ( branchStmt->get_computedTarget() != 0 ) {
    538                                         before << "goto *";
     540                                        output << "goto *";
    539541                                        branchStmt->get_computedTarget()->accept( *this );
    540542                                } // if
     
    542544                        break;
    543545                  case BranchStmt::Break:
    544                         before << "break";
     546                        output << "break";
    545547                        break;
    546548                  case BranchStmt::Continue:
    547                         before << "continue";
     549                        output << "continue";
    548550                        break;
    549551                }
    550                 before << ";";
    551         }
    552 
    553 
    554         void CodeGenerator2::visit( ReturnStmt *returnStmt ) {
    555                 before << "return ";
     552                output << ";";
     553        }
     554
     555
     556        void CodeGenerator::visit( ReturnStmt *returnStmt ) {
     557                output << "return ";
    556558
    557559                // xxx -- check for null expression;
     
    559561                        returnStmt->get_expr()->accept( *this );
    560562                } // if
    561                 after += ";";
    562         }
    563 
    564         void CodeGenerator2::visit( WhileStmt *whileStmt ) {
     563                output << ";";
     564        }
     565
     566        void CodeGenerator::visit( WhileStmt *whileStmt ) {
    565567                if ( whileStmt->get_isDoWhile() )
    566                         before << "do" ;
     568                        output << "do" ;
    567569                else {
    568                         before << "while (" ;
     570                        output << "while (" ;
    569571                        whileStmt->get_condition()->accept(*this );
    570                         after += ")";
    571                 } // if
    572                 after += "{\n";
    573                 shift_left();
    574 
     572                        output << ")";
     573                } // if
     574                output << " ";
     575
     576                output << CodeGenerator::printLabels( whileStmt->get_body()->get_labels() );
    575577                whileStmt->get_body()->accept( *this );
    576578
    577                 before << /* "\r" << */ string( cur_indent, ' ' ) << "}" ;
     579                output << indent;
    578580
    579581                if ( whileStmt->get_isDoWhile() ) {
    580                         before << " while (" ;
     582                        output << " while (" ;
    581583                        whileStmt->get_condition()->accept(*this );
    582                         after += ");";
    583                 } // if
    584 
    585                 after += "\n";
    586         }
    587 
    588         void CodeGenerator2::visit( ForStmt *forStmt ) {
    589                 before << "for (";
     584                        output << ");";
     585                } // if
     586        }
     587
     588        void CodeGenerator::visit( ForStmt *forStmt ) {
     589                output << "for (";
    590590
    591591                if ( forStmt->get_initialization() != 0 )
    592592                        forStmt->get_initialization()->accept( *this );
    593593                else
    594                         before << ";";
    595                 shift_left();
    596 
     594                        output << ";";
     595               
    597596                if ( forStmt->get_condition() != 0 )
    598597                        forStmt->get_condition()->accept( *this );
    599                 shift_left(); before << ";";
     598                output << ";";
    600599
    601600                if ( forStmt->get_increment() != 0 )
    602601                        forStmt->get_increment()->accept( *this );
    603                 shift_left(); before << ")" << endl;
     602                output << ") ";
    604603
    605604                if ( forStmt->get_body() != 0 ) {
    606                         cur_indent += CodeGenerator2::tabsize;
    607                         before << string( cur_indent, ' ' ) << CodeGenerator2::printLabels( forStmt->get_body()->get_labels() );
     605                        output << CodeGenerator::printLabels( forStmt->get_body()->get_labels() );
    608606                        forStmt->get_body()->accept( *this );
    609                         cur_indent -= CodeGenerator2::tabsize;
    610                 } // if
    611         }
    612 
    613         void CodeGenerator2::visit( NullStmt *nullStmt ) {
    614                 //before << /* "\r" << */ string( cur_indent, ' ' ) << CodeGenerator2::printLabels( nullStmt->get_labels() );
    615                 before << "/* null statement */ ;";
    616         }
    617 
    618         void CodeGenerator2::visit( DeclStmt *declStmt ) {
     607                } // if
     608        }
     609
     610        void CodeGenerator::visit( NullStmt *nullStmt ) {
     611                //output << indent << CodeGenerator::printLabels( nullStmt->get_labels() );
     612                output << "/* null statement */ ;";
     613        }
     614
     615        void CodeGenerator::visit( DeclStmt *declStmt ) {
    619616                declStmt->get_decl()->accept( *this );
    620617       
    621618                if ( doSemicolon( declStmt->get_decl() ) ) {
    622                         after += ";";
    623                 } // if
    624                 shift_left();
    625         }
    626 
    627         std::string CodeGenerator2::printLabels( std::list< Label > &l ) {
     619                        output << ";";
     620                } // if
     621        }
     622
     623        std::string CodeGenerator::printLabels( std::list< Label > &l ) {
    628624                std::string str( "" );
    629                 l.unique();
     625                l.unique(); // assumes a sorted list. Why not use set?
    630626
    631627                for ( std::list< Label >::iterator i = l.begin(); i != l.end(); i++ )
     
    635631        }
    636632
    637         void CodeGenerator2::shift_left() {
    638                 before << after;
    639                 after = "";
    640         }
    641 
    642         void CodeGenerator2::handleStorageClass( Declaration *decl ) {
     633        void CodeGenerator::handleStorageClass( Declaration *decl ) {
    643634                switch ( decl->get_storageClass() ) {
    644                   case Declaration::NoStorageClass:
    645                         break;
    646                   case Declaration::Extern:
    647                         before << "extern ";
    648                         break;
    649                   case Declaration::Static:
    650                         before << "static ";
    651                         break;
    652                   case Declaration::Auto:
     635                  case DeclarationNode::Extern:
     636                        output << "extern ";
     637                        break;
     638                  case DeclarationNode::Static:
     639                        output << "static ";
     640                        break;
     641                  case DeclarationNode::Auto:
    653642                        // silently drop storage class
    654643                        break;
    655                   case Declaration::Register:
    656                         before << "register ";
     644                  case DeclarationNode::Register:
     645                        output << "register ";
     646                        break;
     647                  case DeclarationNode::Inline:
     648                        output << "inline ";
     649                        break;
     650                  case DeclarationNode::Fortran:
     651                        output << "fortran ";
     652                        break;
     653                  case DeclarationNode::Noreturn:
     654                        output << "_Noreturn ";
     655                        break;
     656                  case DeclarationNode::Threadlocal:
     657                        output << "_Thread_local ";
     658                        break;
     659                  case DeclarationNode::NoStorageClass:
    657660                        break;
    658661                } // switch
  • src/CodeGen/CodeGenerator.h

    reb50842 r937e51d  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // CodeGenerator2.h --
     7// CodeGenerator.h --
    88//
    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 : Mon May 18 23:35:37 2015
    13 // Update Count     : 2
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Jun 11 13:24:23 2015
     13// Update Count     : 23
    1414//
    1515
     
    1717#define CODEGENV_H
    1818
    19 #include <strstream>
    2019#include <list>
    2120
     
    2524
    2625namespace CodeGen {
    27         class CodeGenerator2 : public Visitor {
     26        class CodeGenerator : public Visitor {
    2827          public:
    2928                static int tabsize;
    3029
    31                 CodeGenerator2( std::ostream &os );
    32                 CodeGenerator2( std::ostream &os, std::string, int indent = 0, bool infun = false );
    33                 CodeGenerator2( std::ostream &os, char *, int indent = 0, bool infun = false );
    34 
    35                 CodeGenerator2( CodeGenerator2 & );
     30                CodeGenerator( std::ostream &os );
     31                CodeGenerator( std::ostream &os, std::string, int indent = 0, bool infun = false );
     32                CodeGenerator( std::ostream &os, char *, int indent = 0, bool infun = false );
    3633
    3734                //*** Declaration
     
    8279                virtual void visit( DeclStmt * );
    8380
    84                 std::string get_string( void );
    85                 void add_string_left( std::string s ) { before << s; }
    86                 void shift_left();
    8781                template< class Iterator > void genCommaList( Iterator begin, Iterator end );
     82
     83                struct Indenter {
     84                        Indenter(CodeGenerator &cg) : cg(cg) {}
     85                        CodeGenerator & cg;
     86                        std::ostream& operator()(std::ostream & os);
     87                };
    8888          private:
     89
     90                Indenter indent;
    8991                int cur_indent;
    9092                bool insideFunction;
    91                 std::ostream &before;
    92                 std::string after;
     93                std::ostream &output;
    9394
    9495                static std::string printLabels ( std::list < Label > & );
     
    100101       
    101102        template< class Iterator >
    102         void CodeGenerator2::genCommaList( Iterator begin, Iterator end ) {
     103        void CodeGenerator::genCommaList( Iterator begin, Iterator end ) {
    103104                if ( begin == end ) return;
    104105
     
    106107                        (*begin++)->accept( *this );
    107108                        if ( begin == end ) return;
    108                         before << ", ";
     109                        output << ", ";
    109110                } // for
    110111        }
  • src/CodeGen/GenType.cc

    reb50842 r937e51d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 23:38:22 2015
    13 // Update Count     : 2
    14 //
    15 
    16 #include <strstream>
     12// Last Modified On : Mon Jun  8 14:36:02 2015
     13// Update Count     : 9
     14//
     15
     16#include <sstream>
    1717#include <cassert>
    1818
    1919#include "GenType.h"
    20 #include "CodeGenerator2.h"
     20#include "CodeGenerator.h"
    2121#include "SynTree/Visitor.h"
    2222#include "SynTree/Type.h"
     
    6868
    6969        void GenType::genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic ) {
    70                 std::ostrstream os;
     70                std::ostringstream os;
    7171                if ( typeString != "" ) {
    7272                        if ( typeString[ 0 ] == '*' ) {
     
    9797                } // if
    9898                if ( dimension != 0 ) {
    99                         CodeGenerator2 cg( os );
     99                        CodeGenerator cg( os );
    100100                        dimension->accept( cg );
    101101                } // if
    102102                os << "]";
    103103
    104                 typeString = std::string( os.str(), os.pcount() );
     104                typeString = os.str();
    105105 
    106106                base->accept( *this );
     
    127127
    128128        void GenType::visit( FunctionType *funcType ) {
    129                 std::ostrstream os;
     129                std::ostringstream os;
    130130
    131131                if ( typeString != "" ) {
     
    148148                        } // if
    149149                } else {
    150                         CodeGenerator2 cg( os );
     150                        CodeGenerator cg( os );
    151151                        os << "(" ;
    152152
     
    159159                } // if
    160160 
    161                 typeString = std::string( os.str(), os.pcount() );
     161                typeString = os.str();
    162162
    163163                if ( funcType->get_returnVals().size() == 0 ) {
  • src/CodeGen/Generate.cc

    reb50842 r937e51d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 23:39:24 2015
    13 // Update Count     : 1
     12// Last Modified On : Thu Jun  4 14:04:25 2015
     13// Update Count     : 5
    1414//
    1515
     
    2121#include "Generate.h"
    2222#include "SynTree/Declaration.h"
    23 
    24 #include "CodeGenerator2.h"
     23#include "CodeGenerator.h"
    2524
    2625using namespace std;
     
    2827namespace CodeGen {
    2928        void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics ) {
    30                 CodeGen::CodeGenerator2 cgv( os );
     29                CodeGen::CodeGenerator cgv( os );
    3130
    3231                for ( std::list<Declaration *>::iterator i = translationUnit.begin(); i != translationUnit.end();  i++ ) {
    3332                        if ( LinkageSpec::isGeneratable( (*i)->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( (*i)->get_linkage() ) ) ) {
    3433                                (*i)->accept(cgv);
    35                                 cgv.shift_left();
    3634                                if ( doSemicolon( *i ) ) {
    3735                                        os << ";";
  • src/CodeGen/OperatorTable.cc

    reb50842 r937e51d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 23:42:07 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Jun 23 17:41:14 2015
     13// Update Count     : 5
    1414//
    1515
     
    2020        namespace {
    2121                const OperatorInfo tableValues[] = {
    22                         {       "?[?]",         "",             "_operator_index",                      OT_INDEX                },
    23                         {       "?()",          "",             "_operator_call",                       OT_CALL                 },
    24                         {       "?++",          "++",   "_operator_postincr",           OT_POSTFIXASSIGN        },
    25                         {       "?--",          "--",   "_operator_postdecr",           OT_POSTFIXASSIGN        },
    26                         {       "*?",           "*",    "_operator_deref",                      OT_PREFIX               },
    27                         {       "+?",           "+",    "_operator_unaryplus",          OT_PREFIX               },
    28                         {       "-?",           "-",    "_operator_unaryminus",         OT_PREFIX               },
    29                         {       "~?",           "~",    "_operator_bitnot",                     OT_PREFIX               },
    30                         {       "!?",           "!",    "_operator_lognot",                     OT_PREFIX               },
    31                         {       "++?",          "++",   "_operator_preincr",            OT_PREFIXASSIGN         },
    32                         {       "--?",          "--",   "_operator_predecr",            OT_PREFIXASSIGN         },
    33                         {       "?*?",          "*",    "_operator_multiply",           OT_INFIX                },
    34                         {       "?/?",          "/",    "_operator_divide",                     OT_INFIX                },
    35                         {       "?%?",          "%",    "_operator_modulus",            OT_INFIX                },
    36                         {       "?+?",          "+",    "_operator_add",                        OT_INFIX                },
    37                         {       "?-?",          "-",    "_operator_subtract",           OT_INFIX                },
    38                         {       "?<<?",         "<<",   "_operator_shiftleft",          OT_INFIX                },
    39                         {       "?>>?",         ">>",   "_operator_shiftright",         OT_INFIX                },
    40                         {       "?<?",          "<",    "_operator_less",                       OT_INFIX                },
    41                         {       "?>?",          ">",    "_operator_greater",            OT_INFIX                },
    42                         {       "?<=?",         "<=",   "_operator_lessequal",          OT_INFIX                },
    43                         {       "?>=?",         ">=",   "_operator_greaterequal",       OT_INFIX                },
    44                         {       "?==?",         "==",   "_operator_equal",                      OT_INFIX                },
    45                         {       "?!=?",         "!=",   "_operator_notequal",           OT_INFIX                },
    46                         {       "?&?",          "&",    "_operator_bitand",                     OT_INFIX                },
    47                         {       "?^?",          "^",    "_operator_bitxor",                     OT_INFIX                },
    48                         {       "?|?",          "|",    "_operator_bitor",                      OT_INFIX                },
    49                         {       "?=?",          "=",    "_operator_assign",                     OT_INFIXASSIGN          },
    50                         {       "?*=?",         "*=",   "_operator_multassign",         OT_INFIXASSIGN          },
    51                         {       "?/=?",         "/=",   "_operator_divassign",          OT_INFIXASSIGN          },
    52                         {       "?%=?",         "%=",   "_operator_modassign",          OT_INFIXASSIGN          },
    53                         {       "?+=?",         "+=",   "_operator_addassign",          OT_INFIXASSIGN          },
    54                         {       "?-=?",         "-=",   "_operator_subassign",          OT_INFIXASSIGN          },
     22                        {       "?[?]",         "",             "_operator_index",                              OT_INDEX                        },
     23                        {       "?()",          "",             "_operator_call",                               OT_CALL                         },
     24                        {       "?++",          "++",   "_operator_postincr",                   OT_POSTFIXASSIGN        },
     25                        {       "?--",          "--",   "_operator_postdecr",                   OT_POSTFIXASSIGN        },
     26                        {       "*?",           "*",    "_operator_deref",                              OT_PREFIX                       },
     27                        {       "+?",           "+",    "_operator_unaryplus",                  OT_PREFIX                       },
     28                        {       "-?",           "-",    "_operator_unaryminus",                 OT_PREFIX                       },
     29                        {       "~?",           "~",    "_operator_bitnot",                             OT_PREFIX                       },
     30                        {       "!?",           "!",    "_operator_lognot",                             OT_PREFIX                       },
     31                        {       "++?",          "++",   "_operator_preincr",                    OT_PREFIXASSIGN         },
     32                        {       "--?",          "--",   "_operator_predecr",                    OT_PREFIXASSIGN         },
     33                        {       "?*?",          "*",    "_operator_multiply",                   OT_INFIX                        },
     34                        {       "?/?",          "/",    "_operator_divide",                             OT_INFIX                        },
     35                        {       "?%?",          "%",    "_operator_modulus",                    OT_INFIX                        },
     36                        {       "?+?",          "+",    "_operator_add",                                OT_INFIX                        },
     37                        {       "?-?",          "-",    "_operator_subtract",                   OT_INFIX                        },
     38                        {       "?<<?",         "<<",   "_operator_shiftleft",                  OT_INFIX                        },
     39                        {       "?>>?",         ">>",   "_operator_shiftright",                 OT_INFIX                        },
     40                        {       "?<?",          "<",    "_operator_less",                               OT_INFIX                        },
     41                        {       "?>?",          ">",    "_operator_greater",                    OT_INFIX                        },
     42                        {       "?<=?",         "<=",   "_operator_lessequal",                  OT_INFIX                        },
     43                        {       "?>=?",         ">=",   "_operator_greaterequal",               OT_INFIX                        },
     44                        {       "?==?",         "==",   "_operator_equal",                              OT_INFIX                        },
     45                        {       "?!=?",         "!=",   "_operator_notequal",                   OT_INFIX                        },
     46                        {       "?&?",          "&",    "_operator_bitand",                             OT_INFIX                        },
     47                        {       "?^?",          "^",    "_operator_bitxor",                             OT_INFIX                        },
     48                        {       "?|?",          "|",    "_operator_bitor",                              OT_INFIX                        },
     49                        {       "?=?",          "=",    "_operator_assign",                             OT_INFIXASSIGN          },
     50                        {       "?*=?",         "*=",   "_operator_multassign",                 OT_INFIXASSIGN          },
     51                        {       "?/=?",         "/=",   "_operator_divassign",                  OT_INFIXASSIGN          },
     52                        {       "?%=?",         "%=",   "_operator_modassign",                  OT_INFIXASSIGN          },
     53                        {       "?+=?",         "+=",   "_operator_addassign",                  OT_INFIXASSIGN          },
     54                        {       "?-=?",         "-=",   "_operator_subassign",                  OT_INFIXASSIGN          },
    5555                        {       "?<<=?",        "<<=",  "_operator_shiftleftassign",    OT_INFIXASSIGN          },
    5656                        {       "?>>=?",        ">>=",  "_operator_shiftrightassign",   OT_INFIXASSIGN          },
    57                         {       "?&=?",         "&=",   "_operator_bitandassign",       OT_INFIXASSIGN          },
    58                         {       "?^=?",         "^=",   "_operator_bitxorassign",       OT_INFIXASSIGN          },
    59                         {       "?|=?",         "|=",   "_operator_bitorassign",        OT_INFIXASSIGN          },
    60                         {       "0",            "0",    "_constant_zero",                       OT_CONSTANT             },
    61                         {       "1",            "1",    "_constant_one",                        OT_CONSTANT             }
     57                        {       "?&=?",         "&=",   "_operator_bitandassign",               OT_INFIXASSIGN          },
     58                        {       "?^=?",         "^=",   "_operator_bitxorassign",               OT_INFIXASSIGN          },
     59                        {       "?|=?",         "|=",   "_operator_bitorassign",                OT_INFIXASSIGN          },
     60                        {       "&&",           "&&",   "&&",                                                   OT_LABELADDRESS         },
     61                        {       "0",            "0",    "_constant_zero",                               OT_CONSTANT                     },
     62                        {       "1",            "1",    "_constant_one",                                OT_CONSTANT                     }
    6263                };
    6364
  • src/CodeGen/OperatorTable.h

    reb50842 r937e51d  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 18 23:43:07 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Jun 23 16:09:27 2015
     13// Update Count     : 3
    1414//
    1515
     
    2929                OT_POSTFIXASSIGN,
    3030                OT_INFIXASSIGN,
     31                OT_LABELADDRESS,
    3132                OT_CONSTANT
    3233        };
  • src/CodeGen/module.mk

    reb50842 r937e51d  
     1######################### -*- Mode: Makefile-Gmake -*- ########################
     2##
     3## Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     4##
     5## The contents of this file are covered under the licence agreement in the
     6## file "LICENCE" distributed with Cforall.
     7##
     8## module.mk --
     9##
     10## Author           : Richard C. Bilson
     11## Created On       : Mon Jun  1 17:49:17 2015
     12## Last Modified By : Peter A. Buhr
     13## Last Modified On : Tue Jun  2 11:17:02 2015
     14## Update Count     : 3
     15###############################################################################
     16
     17#SRC +=  ArgTweak/Rewriter.cc \
     18#       ArgTweak/Mutate.cc
     19
    120SRC +=  CodeGen/Generate.cc \
    2         CodeGen/CodeGenerator2.cc \
     21        CodeGen/CodeGenerator.cc \
    322        CodeGen/GenType.cc \
    423        CodeGen/FixNames.cc \
    5         CodeGen/OperatorTable.cc \
    6         $(NULL)
     24        CodeGen/OperatorTable.cc
Note: See TracChangeset for help on using the changeset viewer.