Changeset bdfc032 for src


Ignore:
Timestamp:
Feb 4, 2020, 11:35:26 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
eef8dfb
Parents:
aefb247 (diff), 4f7b418 (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 branch 'master' into dkobets-vector

Location:
src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • src/Common/Stats/Time.h

    raefb247 rbdfc032  
    99// Author           : Thierry Delisle
    1010// Created On       : Fri Mar 01 15:14:11 2019
    11 // Last Modified By :
     11// Last Modified By : Andrew Beach
    1212// Last Modified On :
    1313// Update Count     :
     
    4141                                f();
    4242                        }
     43
     44                        template<typename ret_t = void, typename func_t, typename... arg_t>
     45                        inline ret_t TimeCall(
     46                                        const char *, func_t func, arg_t&&... arg) {
     47                                return func(std::forward<arg_t>(arg)...);
     48                        }
    4349#               else
    4450                        void StartGlobal();
     
    5965                                func();
    6066                        }
     67
     68                        template<typename ret_t = void, typename func_t, typename... arg_t>
     69                        inline ret_t TimeCall(
     70                                        const char * name, func_t func, arg_t&&... arg) {
     71                                BlockGuard guard(name);
     72                                return func(std::forward<arg_t>(arg)...);
     73                        }
    6174#               endif
    6275        }
  • src/Concurrency/Keywords.cc

    raefb247 rbdfc032  
    716716                                new UntypedExpr(
    717717                                        new NameExpr( "__thrd_start" ),
    718                                         { new VariableExpr( param ) }
     718                                        { new VariableExpr( param ), new NameExpr("main") }
    719719                                )
    720720                        )
  • src/Concurrency/Waitfor.cc

    raefb247 rbdfc032  
    1111// Last Modified By :
    1212// Last Modified On :
    13 // Update Count     : 11
     13// Update Count     : 12
    1414//
    1515
     
    4242void foo() {
    4343        while( true ) {
    44                 when( a < 1 ) waitfor( f, a ) { bar(); }
     44                when( a < 1 ) waitfor( f : a ) { bar(); }
    4545                or timeout( swagl() );
    46                 or waitfor( g, a ) { baz(); }
    47                 or waitfor( ^?{}, a ) { break; }
     46                or waitfor( g : a ) { baz(); }
     47                or waitfor( ^?{} : a ) { break; }
    4848                or waitfor( ^?{} ) { break; }
    4949        }
  • src/ControlStruct/LabelFixer.cc

    raefb247 rbdfc032  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 11 22:26:02 2019
    13 // Update Count     : 159
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Jan 21 10:32:00 2020
     13// Update Count     : 160
    1414//
    1515
     
    2121#include "ControlStruct/LabelGenerator.h"  // for LabelGenerator
    2222#include "LabelFixer.h"
    23 #include "MLEMutator.h"                    // for MLEMutator
     23#include "MLEMutator.h"                    // for MultiLevelExitMutator
    2424#include "SynTree/Declaration.h"           // for FunctionDecl
    2525#include "SynTree/Expression.h"            // for NameExpr, Expression, Unty...
     
    4444
    4545        void LabelFixer::postvisit( FunctionDecl * functionDecl ) {
    46                 PassVisitor<MLEMutator> mlemut( resolveJumps(), generator );
    47                 functionDecl->acceptMutator( mlemut );
     46                PassVisitor<MultiLevelExitMutator> mlem( resolveJumps(), generator );
     47                // We start in the body so we can stop when we hit another FunctionDecl.
     48                maybeMutate( functionDecl->statements, mlem );
    4849        }
    4950
     
    7576
    7677
    77         // sets the definition of the labelTable entry to be the provided statement for every label in the list
    78         // parameter. Happens for every kind of statement
     78        // Sets the definition of the labelTable entry to be the provided statement for every label in
     79        // the list parameter. Happens for every kind of statement.
    7980        Label LabelFixer::setLabelsDef( std::list< Label > & llabel, Statement * definition ) {
    8081                assert( definition != 0 );
    8182                assert( llabel.size() > 0 );
    82 
    83                 Entry * e = new Entry( definition );
    8483
    8584                for ( std::list< Label >::iterator i = llabel.begin(); i != llabel.end(); i++ ) {
     
    8786                        l.set_statement( definition ); // attach statement to the label to be used later
    8887                        if ( labelTable.find( l ) == labelTable.end() ) {
    89                                 // all labels on this statement need to use the same entry, so this should only be created once
     88                                // All labels on this statement need to use the same entry,
     89                                // so this should only be created once.
    9090                                // undefined and unused until now, add an entry
    91                                 labelTable[ l ] =  e;
     91                                labelTable[ l ] = new Entry( definition );
    9292                        } else if ( labelTable[ l ]->defined() ) {
    9393                                // defined twice, error
    94                                 SemanticError( l.get_statement()->location, "Duplicate definition of label: " + l.get_name() );
    95                         }       else {
     94                                SemanticError( l.get_statement()->location,
     95                                        "Duplicate definition of label: " + l.get_name() );
     96                        } else {
    9697                                // used previously, but undefined until now -> link with this entry
     98                                // Question: Is changing objects important?
    9799                                delete labelTable[ l ];
    98                                 labelTable[ l ] = e;
     100                                labelTable[ l ] = new Entry( definition );
    99101                        } // if
    100102                } // for
    101103
    102                 // produce one of the labels attached to this statement to be temporarily used as the canonical label
     104                // Produce one of the labels attached to this statement to be temporarily used as the
     105                // canonical label.
    103106                return labelTable[ llabel.front() ]->get_label();
    104107        }
  • src/ControlStruct/MLEMutator.cc

    raefb247 rbdfc032  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 22 17:22:44 2019
    13 // Update Count     : 220
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jan 22 11:50:00 2020
     13// Update Count     : 223
    1414//
    1515
     
    3333
    3434namespace ControlStruct {
    35         MLEMutator::~MLEMutator() {
     35        MultiLevelExitMutator::~MultiLevelExitMutator() {
    3636                delete targetTable;
    3737                targetTable = 0;
    3838        }
    3939        namespace {
    40                 bool isLoop( const MLEMutator::Entry & e ) { return dynamic_cast< WhileStmt * >( e.get_controlStructure() ) || dynamic_cast< ForStmt * >( e.get_controlStructure() ); }
    41                 bool isSwitch( const MLEMutator::Entry & e ) { return dynamic_cast< SwitchStmt *>( e.get_controlStructure() ); }
    42 
    43                 bool isBreakTarget( const MLEMutator::Entry & e ) { return isLoop( e ) || isSwitch( e ) || dynamic_cast< CompoundStmt *>( e.get_controlStructure() ); }
    44                 bool isContinueTarget( const MLEMutator::Entry & e ) { return isLoop( e ); }
    45                 bool isFallthroughTarget( const MLEMutator::Entry & e ) { return dynamic_cast< CaseStmt *>( e.get_controlStructure() );; }
    46                 bool isFallthroughDefaultTarget( const MLEMutator::Entry & e ) { return isSwitch( e ); }
     40                bool isLoop( const MultiLevelExitMutator::Entry & e ) {
     41                        return dynamic_cast< WhileStmt * >( e.get_controlStructure() )
     42                                || dynamic_cast< ForStmt * >( e.get_controlStructure() );
     43                }
     44                bool isSwitch( const MultiLevelExitMutator::Entry & e ) {
     45                        return dynamic_cast< SwitchStmt *>( e.get_controlStructure() );
     46                }
     47
     48                bool isBreakTarget( const MultiLevelExitMutator::Entry & e ) {
     49                        return isLoop( e ) || isSwitch( e )
     50                                || dynamic_cast< CompoundStmt *>( e.get_controlStructure() );
     51                }
     52                bool isContinueTarget( const MultiLevelExitMutator::Entry & e ) {
     53                        return isLoop( e );
     54                }
     55                bool isFallthroughTarget( const MultiLevelExitMutator::Entry & e ) {
     56                        return dynamic_cast< CaseStmt *>( e.get_controlStructure() );
     57                }
     58                bool isFallthroughDefaultTarget( const MultiLevelExitMutator::Entry & e ) {
     59                        return isSwitch( e );
     60                }
    4761        } // namespace
     62
     63        void MultiLevelExitMutator::premutate( FunctionDecl * ) {
     64                visit_children = false;
     65        }
    4866
    4967        // break labels have to come after the statement they break out of, so mutate a statement, then if they inform us
    5068        // through the breakLabel field tha they need a place to jump to on a break statement, add the break label to the
    5169        // body of statements
    52         void MLEMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
     70        void MultiLevelExitMutator::fixBlock( std::list< Statement * > &kids, bool caseClause ) {
    5371                SemanticErrorException errors;
    5472
     
    8199        }
    82100
    83         void MLEMutator::premutate( CompoundStmt *cmpndStmt ) {
     101        void MultiLevelExitMutator::premutate( CompoundStmt *cmpndStmt ) {
    84102                visit_children = false;
    85103                bool labeledBlock = !(cmpndStmt->labels.empty());
     
    118136                        }
    119137                }
    120                 assertf( false, "Could not find label '%s' on statement %s", originalTarget.get_name().c_str(), toString( stmt ).c_str() );
    121         }
    122 
    123 
    124         Statement *MLEMutator::postmutate( BranchStmt *branchStmt ) throw ( SemanticErrorException ) {
     138                assertf( false, "Could not find label '%s' on statement %s",
     139                        originalTarget.get_name().c_str(), toString( stmt ).c_str() );
     140        }
     141
     142
     143        Statement *MultiLevelExitMutator::postmutate( BranchStmt *branchStmt )
     144                        throw ( SemanticErrorException ) {
    125145                std::string originalTarget = branchStmt->originalTarget;
    126146
     
    230250        }
    231251
    232         Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
     252        Statement *MultiLevelExitMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
    233253                // only generate these when needed
    234254                if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop;
     
    253273
    254274        template< typename LoopClass >
    255         void MLEMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
     275        void MultiLevelExitMutator::prehandleLoopStmt( LoopClass * loopStmt ) {
    256276                // remember this as the most recent enclosing loop, then mutate the body of the loop -- this will determine
    257277                // whether brkLabel and contLabel are used with branch statements and will recursively do the same to nested
     
    264284
    265285        template< typename LoopClass >
    266         Statement * MLEMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
     286        Statement * MultiLevelExitMutator::posthandleLoopStmt( LoopClass * loopStmt ) {
    267287                assert( ! enclosingControlStructures.empty() );
    268288                Entry &e = enclosingControlStructures.back();
     
    275295        }
    276296
    277         void MLEMutator::premutate( WhileStmt * whileStmt ) {
     297        void MultiLevelExitMutator::premutate( WhileStmt * whileStmt ) {
    278298                return prehandleLoopStmt( whileStmt );
    279299        }
    280300
    281         void MLEMutator::premutate( ForStmt * forStmt ) {
     301        void MultiLevelExitMutator::premutate( ForStmt * forStmt ) {
    282302                return prehandleLoopStmt( forStmt );
    283303        }
    284304
    285         Statement * MLEMutator::postmutate( WhileStmt * whileStmt ) {
     305        Statement * MultiLevelExitMutator::postmutate( WhileStmt * whileStmt ) {
    286306                return posthandleLoopStmt( whileStmt );
    287307        }
    288308
    289         Statement * MLEMutator::postmutate( ForStmt * forStmt ) {
     309        Statement * MultiLevelExitMutator::postmutate( ForStmt * forStmt ) {
    290310                return posthandleLoopStmt( forStmt );
    291311        }
    292312
    293         void MLEMutator::premutate( IfStmt * ifStmt ) {
     313        void MultiLevelExitMutator::premutate( IfStmt * ifStmt ) {
    294314                // generate a label for breaking out of a labeled if
    295315                bool labeledBlock = !(ifStmt->get_labels().empty());
     
    301321        }
    302322
    303         Statement * MLEMutator::postmutate( IfStmt * ifStmt ) {
     323        Statement * MultiLevelExitMutator::postmutate( IfStmt * ifStmt ) {
    304324                bool labeledBlock = !(ifStmt->get_labels().empty());
    305325                if ( labeledBlock ) {
     
    311331        }
    312332
    313         void MLEMutator::premutate( TryStmt * tryStmt ) {
     333        void MultiLevelExitMutator::premutate( TryStmt * tryStmt ) {
    314334                // generate a label for breaking out of a labeled if
    315335                bool labeledBlock = !(tryStmt->get_labels().empty());
     
    321341        }
    322342
    323         Statement * MLEMutator::postmutate( TryStmt * tryStmt ) {
     343        Statement * MultiLevelExitMutator::postmutate( TryStmt * tryStmt ) {
    324344                bool labeledBlock = !(tryStmt->get_labels().empty());
    325345                if ( labeledBlock ) {
     
    331351        }
    332352
    333         void MLEMutator::premutate( CaseStmt *caseStmt ) {
     353        void MultiLevelExitMutator::premutate( FinallyStmt * ) {
     354                GuardAction([this, old = std::move(enclosingControlStructures)]() {
     355                        enclosingControlStructures = std::move(old);
     356                });
     357                enclosingControlStructures = std::list<Entry>();
     358                GuardValue( inFinally );
     359                inFinally = true;
     360        }
     361
     362        void MultiLevelExitMutator::premutate( ReturnStmt *returnStmt ) {
     363                if ( inFinally ) {
     364                        SemanticError( returnStmt->location, "'return' may not appear in a finally clause" );
     365                }
     366        }
     367
     368        void MultiLevelExitMutator::premutate( CaseStmt *caseStmt ) {
    334369                visit_children = false;
    335370
     
    370405        }
    371406
    372         void MLEMutator::premutate( SwitchStmt *switchStmt ) {
     407        void MultiLevelExitMutator::premutate( SwitchStmt *switchStmt ) {
    373408                // generate a label for breaking out of a labeled switch
    374409                Label brkLabel = generator->newLabel("switchBreak", switchStmt);
     
    396431        }
    397432
    398         Statement * MLEMutator::postmutate( SwitchStmt * switchStmt ) {
     433        Statement * MultiLevelExitMutator::postmutate( SwitchStmt * switchStmt ) {
    399434                Entry &e = enclosingControlStructures.back();
    400435                assert ( e == switchStmt );
  • src/ControlStruct/MLEMutator.h

    raefb247 rbdfc032  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Oct 22 17:22:47 2019
    13 // Update Count     : 45
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jan 22 11:50:00 2020
     13// Update Count     : 48
    1414//
    1515
     
    3030        class LabelGenerator;
    3131
    32         class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards {
     32        class MultiLevelExitMutator : public WithVisitorRef<MultiLevelExitMutator>,
     33                        public WithShortCircuiting, public WithGuards {
    3334          public:
    3435                class Entry;
    35                 MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
    36                 ~MLEMutator();
     36                MultiLevelExitMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) :
     37                        targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
     38                ~MultiLevelExitMutator();
     39
     40                void premutate( FunctionDecl * );
    3741
    3842                void premutate( CompoundStmt *cmpndStmt );
     
    4751                void premutate( SwitchStmt *switchStmt );
    4852                Statement * postmutate( SwitchStmt *switchStmt );
     53                void premutate( ReturnStmt *returnStmt );
    4954                void premutate( TryStmt *tryStmt );
    5055                Statement * postmutate( TryStmt *tryStmt );
     56                void premutate( FinallyStmt *finallyStmt );
    5157
    5258                Statement *mutateLoop( Statement *bodyLoop, Entry &e );
     
    110116                Label breakLabel;
    111117                LabelGenerator *generator;
     118                bool inFinally = false;
    112119
    113120                template< typename LoopClass >
  • src/Parser/lex.ll

    raefb247 rbdfc032  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sun Aug  4 20:53:47 2019
    13  * Update Count     : 719
     12 * Last Modified On : Sat Feb  1 07:16:44 2020
     13 * Update Count     : 724
    1414 */
    1515
     
    330330                                /* identifier */
    331331{identifier}    { IDENTIFIER_RETURN(); }
    332 "`"{identifier}"`" {                                                                    // CFA
    333         yytext[yyleng - 1] = '\0'; yytext += 1;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
     332"``"{identifier}"``" {                                                                  // CFA
     333        yytext[yyleng - 2] = '\0'; yytext += 2;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
    334334        IDENTIFIER_RETURN();
    335335}
  • src/Parser/parser.yy

    raefb247 rbdfc032  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 15:32:58 2019
    13 // Update Count     : 4409
     12// Last Modified On : Sat Feb  1 10:04:40 2020
     13// Update Count     : 4440
    1414//
    1515
     
    323323%type<op> ptrref_operator                               unary_operator                          assignment_operator
    324324%type<en> primary_expression                    postfix_expression                      unary_expression
    325 %type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
     325%type<en> cast_expression_list                  cast_expression                         exponential_expression          multiplicative_expression       additive_expression
    326326%type<en> shift_expression                              relational_expression           equality_expression
    327327%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     
    579579        | '(' compound_statement ')'                                            // GCC, lambda expression
    580580                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
    581         | constant '`' IDENTIFIER                                                       // CFA, postfix call
    582                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
    583         | string_literal '`' IDENTIFIER                                         // CFA, postfix call
    584                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
    585         | IDENTIFIER '`' IDENTIFIER                                                     // CFA, postfix call
    586                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }
    587         | tuple '`' IDENTIFIER                                                          // CFA, postfix call
    588                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
    589         | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
    590                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    591581        | type_name '.' identifier                                                      // CFA, nested type
    592582                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    642632        | postfix_expression '(' argument_expression_list ')'
    643633                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     634        | postfix_expression '`' identifier                                     // CFA, postfix call
     635                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     636        | constant '`' identifier                                                       // CFA, postfix call
     637                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     638        | string_literal '`' identifier                                         // CFA, postfix call
     639                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
    644640        | postfix_expression '.' identifier
    645641                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     
    666662        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    667663                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    668         | '^' primary_expression '{' argument_expression_list '}' // CFA
     664        | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call
    669665                {
    670666                        Token fn;
     
    679675        | argument_expression
    680676        | argument_expression_list ',' argument_expression
    681                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     677                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    682678        ;
    683679
     
    691687field_name_list:                                                                                // CFA, tuple field selector
    692688        field
    693         | field_name_list ',' field                                     { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     689        | field_name_list ',' field                                     { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    694690        ;
    695691
     
    960956                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    961957        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    962                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
     958                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
    963959        ;
    964960
     
    966962        assignment_expression_opt
    967963        | tuple_expression_list ',' assignment_expression_opt
    968                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     964                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    969965        ;
    970966
     
    13071303        WAITFOR '(' cast_expression ')'
    13081304                { $$ = $3; }
    1309         | WAITFOR '(' cast_expression ',' argument_expression_list ')'
    1310                 { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1305//      | WAITFOR '(' cast_expression ',' argument_expression_list ')'
     1306//              { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1307        | WAITFOR '(' cast_expression_list ':' argument_expression_list ')'
     1308                { $$ = (ExpressionNode *)($3->set_last( $5 )); }
     1309        ;
     1310
     1311cast_expression_list:
     1312        cast_expression
     1313        | cast_expression_list ',' cast_expression
     1314                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    13111315        ;
    13121316
     
    14191423        asm_operand
    14201424        | asm_operands_list ',' asm_operand
    1421                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     1425                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    14221426        ;
    14231427
     
    14351439                { $$ = new ExpressionNode( $1 ); }
    14361440        | asm_clobbers_list_opt ',' string_literal
    1437                 // set_last returns ParseNode *
    1438                 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
     1441                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); }
    14391442        ;
    14401443
     
    23592362        | initializer_list_opt ',' initializer          { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    23602363        | initializer_list_opt ',' designation initializer
    2361                 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
     2364                { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }
    23622365        ;
    23632366
     
    23812384        designator
    23822385        | designator_list designator
    2383                 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
     2386                { $$ = (ExpressionNode *)($1->set_last( $2 )); }
    23842387        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    23852388        ;
     
    24782481                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; }
    24792482        | type_list ',' type
    2480                 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); }
     2483                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
    24812484        | type_list ',' assignment_expression
    24822485                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; }
  • src/SymTab/Validate.cc

    raefb247 rbdfc032  
    375375                        Stats::Heap::newPass("validate-F");
    376376                        Stats::Time::BlockGuard guard("validate-F");
    377                         Stats::Time::TimeBlock("Fix Object Type", [&]() {
    378                                 FixObjectType::fix( translationUnit );
    379                         });
    380                         Stats::Time::TimeBlock("Array Length", [&]() {
    381                                 ArrayLength::computeLength( translationUnit );
    382                         });
    383                         Stats::Time::TimeBlock("Find Special Declarations", [&]() {
    384                                 Validate::findSpecialDecls( translationUnit );
    385                         });
    386                         Stats::Time::TimeBlock("Fix Label Address", [&]() {
    387                                 mutateAll( translationUnit, labelAddrFixer );
    388                         });
    389                         Stats::Time::TimeBlock("Handle Attributes", [&]() {
    390                                 Validate::handleAttributes( translationUnit );
    391                         });
     377                        Stats::Time::TimeCall("Fix Object Type",
     378                                FixObjectType::fix, translationUnit);
     379                        Stats::Time::TimeCall("Array Length",
     380                                ArrayLength::computeLength, translationUnit);
     381                        Stats::Time::TimeCall("Find Special Declarations",
     382                                Validate::findSpecialDecls, translationUnit);
     383                        Stats::Time::TimeCall("Fix Label Address",
     384                                mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer);
     385                        Stats::Time::TimeCall("Handle Attributes",
     386                                Validate::handleAttributes, translationUnit);
    392387                }
    393388        }
  • src/SynTree/Statement.cc

    raefb247 rbdfc032  
    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 : Sun Sep  3 20:46:44 2017
    13 // Update Count     : 68
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jan 20 16:03:00 2020
     13// Update Count     : 71
    1414//
    1515
     
    4646Statement::~Statement() {}
    4747
    48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {}
    49 
    50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     48ExprStmt::ExprStmt( Expression * expr ) : Statement(), expr( expr ) {}
     49
     50ExprStmt::ExprStmt( const ExprStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
    5151
    5252ExprStmt::~ExprStmt() {
     
    5454}
    5555
    56 void ExprStmt::print( std::ostream &os, Indenter indent ) const {
     56void ExprStmt::print( std::ostream & os, Indenter indent ) const {
    5757        os << "Expression Statement:" << endl << indent+1;
    5858        expr->print( os, indent+1 );
     
    6060
    6161
    62 AsmStmt::AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
     62AsmStmt::AsmStmt( bool voltile, Expression * instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
    6363
    6464AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) {
     
    7575}
    7676
    77 void AsmStmt::print( std::ostream &os, Indenter indent ) const {
     77void AsmStmt::print( std::ostream & os, Indenter indent ) const {
    7878        os << "Assembler Statement:" << endl;
    7979        os << indent+1 << "instruction: " << endl << indent;
     
    9696DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {}
    9797
    98 void DirectiveStmt::print( std::ostream &os, Indenter ) const {
     98void DirectiveStmt::print( std::ostream & os, Indenter ) const {
    9999        os << "GCC Directive:" << directive << endl;
    100100}
    101101
    102102
    103 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" };
     103const char * BranchStmt::brType[] = {
     104        "Goto", "Break", "Continue", "Fall Through", "Fall Through Default",
     105};
    104106
    105107BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) :
     
    111113}
    112114
    113 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) :
     115BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ) :
    114116        Statement(), computedTarget( computedTarget ), type( type ) {
    115117        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
     
    118120}
    119121
    120 void BranchStmt::print( std::ostream &os, Indenter indent ) const {
     122void BranchStmt::print( std::ostream & os, Indenter indent ) const {
     123        assert(type < 5);
    121124        os << "Branch (" << brType[type] << ")" << endl ;
    122125        if ( target != "" ) os << indent+1 << "with target: " << target << endl;
     
    125128}
    126129
    127 ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {}
     130ReturnStmt::ReturnStmt( Expression * expr ) : Statement(), expr( expr ) {}
    128131
    129132ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}
     
    133136}
    134137
    135 void ReturnStmt::print( std::ostream &os, Indenter indent ) const {
     138void ReturnStmt::print( std::ostream & os, Indenter indent ) const {
    136139        os << "Return Statement, returning: ";
    137140        if ( expr != nullptr ) {
     
    142145}
    143146
    144 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):
     147IfStmt::IfStmt( Expression * condition, Statement * thenPart, Statement * elsePart, std::list<Statement *> initialization ):
    145148        Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}
    146149
     
    157160}
    158161
    159 void IfStmt::print( std::ostream &os, Indenter indent ) const {
     162void IfStmt::print( std::ostream & os, Indenter indent ) const {
    160163        os << "If on condition: " << endl;
    161164        os << indent+1;
     
    176179        thenPart->print( os, indent+1 );
    177180
    178         if ( elsePart != 0 ) {
     181        if ( elsePart != nullptr ) {
    179182                os << indent << "... else: " << endl;
    180183                os << indent+1;
     
    183186}
    184187
    185 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ):
     188SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ):
    186189        Statement(), condition( condition ), statements( statements ) {
    187190}
     
    198201}
    199202
    200 void SwitchStmt::print( std::ostream &os, Indenter indent ) const {
     203void SwitchStmt::print( std::ostream & os, Indenter indent ) const {
    201204        os << "Switch on condition: ";
    202205        condition->print( os );
     
    208211}
    209212
    210 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :
     213CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) :
    211214        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    212         if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " );
     215        if ( isDefault() && condition != nullptr ) SemanticError( condition, "default case with condition: " );
    213216}
    214217
     
    229232}
    230233
    231 void CaseStmt::print( std::ostream &os, Indenter indent ) const {
     234void CaseStmt::print( std::ostream & os, Indenter indent ) const {
    232235        if ( isDefault() ) os << indent << "Default ";
    233236        else {
     
    243246}
    244247
    245 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):
     248WhileStmt::WhileStmt( Expression * condition, Statement * body, std::list< Statement * > & initialization, bool isDoWhile ):
    246249        Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) {
    247250}
     
    256259}
    257260
    258 void WhileStmt::print( std::ostream &os, Indenter indent ) const {
     261void WhileStmt::print( std::ostream & os, Indenter indent ) const {
    259262        os << "While on condition: " << endl ;
    260263        condition->print( os, indent+1 );
     
    262265        os << indent << "... with body: " << endl;
    263266
    264         if ( body != 0 ) body->print( os, indent+1 );
    265 }
    266 
    267 ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):
     267        if ( body != nullptr ) body->print( os, indent+1 );
     268}
     269
     270ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body ):
    268271        Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {
    269272}
     
    282285}
    283286
    284 void ForStmt::print( std::ostream &os, Indenter indent ) const {
     287void ForStmt::print( std::ostream & os, Indenter indent ) const {
    285288        Statement::print( os, indent ); // print labels
    286289
     
    305308        }
    306309
    307         if ( body != 0 ) {
     310        if ( body != nullptr ) {
    308311                os << "\n" << indent << "... with body: \n" << indent+1;
    309312                body->print( os, indent+1 );
     
    317320}
    318321
    319 ThrowStmt::ThrowStmt( const ThrowStmt &other ) :
     322ThrowStmt::ThrowStmt( const ThrowStmt & other ) :
    320323        Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) {
    321324}
     
    326329}
    327330
    328 void ThrowStmt::print( std::ostream &os, Indenter indent) const {
     331void ThrowStmt::print( std::ostream & os, Indenter indent) const {
    329332        if ( target ) os << "Non-Local ";
    330333        os << "Throw Statement, raising: ";
     
    336339}
    337340
    338 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :
     341TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) :
    339342        Statement(), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
    340343}
    341344
    342 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
     345TryStmt::TryStmt( const TryStmt & other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {
    343346        cloneAll( other.handlers, handlers );
    344347}
     
    350353}
    351354
    352 void TryStmt::print( std::ostream &os, Indenter indent ) const {
     355void TryStmt::print( std::ostream & os, Indenter indent ) const {
    353356        os << "Try Statement" << endl;
    354357        os << indent << "... with block:" << endl << indent+1;
     
    363366
    364367        // finally block
    365         if ( finallyBlock != 0 ) {
     368        if ( finallyBlock != nullptr ) {
    366369                os << indent << "... and finally:" << endl << indent+1;
    367370                finallyBlock->print( os, indent+1 );
     
    369372}
    370373
    371 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) :
     374CatchStmt::CatchStmt( Kind kind, Declaration * decl, Expression * cond, Statement * body ) :
    372375        Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {
    373376                assertf( decl, "Catch clause must have a declaration." );
     
    383386}
    384387
    385 void CatchStmt::print( std::ostream &os, Indenter indent ) const {
     388void CatchStmt::print( std::ostream & os, Indenter indent ) const {
    386389        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    387390
     
    401404
    402405
    403 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) {
     406FinallyStmt::FinallyStmt( CompoundStmt * block ) : Statement(), block( block ) {
    404407}
    405408
     
    411414}
    412415
    413 void FinallyStmt::print( std::ostream &os, Indenter indent ) const {
     416void FinallyStmt::print( std::ostream & os, Indenter indent ) const {
    414417        os << "Finally Statement" << endl;
    415418        os << indent << "... with block:" << endl << indent+1;
     
    458461}
    459462
    460 void WaitForStmt::print( std::ostream &os, Indenter indent ) const {
     463void WaitForStmt::print( std::ostream & os, Indenter indent ) const {
    461464        os << "Waitfor Statement" << endl;
    462465        indent += 1;
     
    514517}
    515518
    516 void NullStmt::print( std::ostream &os, Indenter indent ) const {
     519void NullStmt::print( std::ostream & os, Indenter indent ) const {
    517520        os << "Null Statement" << endl;
    518521        Statement::print( os, indent );
     
    530533}
    531534
    532 void ImplicitCtorDtorStmt::print( std::ostream &os, Indenter indent ) const {
     535void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const {
    533536        os << "Implicit Ctor Dtor Statement" << endl;
    534537        os << indent << "... with Ctor/Dtor: ";
  • src/SynTree/Statement.h

    raefb247 rbdfc032  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 12 09:01:53 2019
    13 // Update Count     : 83
     12// Last Modified On : Fri Jan 10 14:13:24 2020
     13// Update Count     : 85
    1414//
    1515
     
    257257        Statement * body;
    258258
    259         ForStmt( std::list<Statement *> initialization, Expression * condition = 0, Expression * increment = 0, Statement * body = 0 );
     259        ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr );
    260260        ForStmt( const ForStmt & other );
    261261        virtual ~ForStmt();
     
    357357        FinallyStmt * finallyBlock;
    358358
    359         TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = 0 );
     359        TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr );
    360360        TryStmt( const TryStmt & other );
    361361        virtual ~TryStmt();
  • src/cfa.make

    raefb247 rbdfc032  
    1 
    2 
    31CFACOMPILE = $(CFACC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) $(AM_CFLAGS) $(CFLAGS)
    42LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
     
    2119        $(am__mv) $$depbase.Tpo $$depbase.Plo
    2220
    23 AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
    24 am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
    25 am__v_JAVAC_0 = @echo "  JAVAC   " $@;
    26 am__v_JAVAC_1 =
    27 
    28 AM_V_GOC = $(am__v_GOC_@AM_V@)
    29 am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
    30 am__v_GOC_0 = @echo "  GOC     " $@;
    31 am__v_GOC_1 =
    32 
    3321UPPCC = u++
    3422UPPCOMPILE = $(UPPCC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_UPPFLAGS) $(UPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CFLAGS) $(CFLAGS)
     
    3826am__v_UPP_0 = @echo "  UPP     " $@;
    3927am__v_UPP_1 =
     28
     29AM_V_GOC = $(am__v_GOC_@AM_V@)
     30am__v_GOC_ = $(am__v_GOC_@AM_DEFAULT_V@)
     31am__v_GOC_0 = @echo "  GOC     " $@;
     32am__v_GOC_1 =
     33
     34AM_V_RUST = $(am__v_RUST_@AM_V@)
     35am__v_RUST_ = $(am__v_RUST_@AM_DEFAULT_V@)
     36am__v_RUST_0 = @echo "  RUST     " $@;
     37am__v_RUST_1 =
     38
     39AM_V_NODEJS = $(am__v_NODEJS_@AM_V@)
     40am__v_NODEJS_ = $(am__v_NODEJS_@AM_DEFAULT_V@)
     41am__v_NODEJS_0 = @echo "  NODEJS     " $@;
     42am__v_NODEJS_1 =
     43
     44AM_V_JAVAC = $(am__v_JAVAC_@AM_V@)
     45am__v_JAVAC_ = $(am__v_JAVAC_@AM_DEFAULT_V@)
     46am__v_JAVAC_0 = @echo "  JAVAC   " $@;
     47am__v_JAVAC_1 =
Note: See TracChangeset for help on using the changeset viewer.