Changes in / [9dc08363:941e14a]


Ignore:
Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Stmt.cpp

    r9dc08363 r941e14a  
    99// Author           : Aaron B. Moss
    1010// Created On       : Wed May  8 13:00:00 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 19:01:20 2022
    13 // Update Count     : 3
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed May 15 15:53:00 2019
     13// Update Count     : 2
    1414//
    1515
     
    5656
    5757// --- BranchStmt
    58 BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, const std::vector<Label>&& labels )
    59                 : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) {
     58BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, std::vector<Label>&& labels )
     59: Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) {
    6060        // Make sure a syntax error hasn't slipped through.
    6161        assert( Goto != kind || !target.empty() );
  • src/AST/Stmt.hpp

    r9dc08363 r941e14a  
    1010// Created On       : Wed May  8 13:00:00 2019
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 20:06:41 2022
    13 // Update Count     : 34
     12// Last Modified On : Tue Feb  1 17:44:46 2022
     13// Update Count     : 24
    1414//
    1515
     
    3939        std::vector<Label> labels;
    4040
    41         Stmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
     41        Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
    4242                : ParseNode(loc), labels(std::move(labels)) {}
    4343
     
    5555        std::list<ptr<Stmt>> kids;
    5656
    57         CompoundStmt(const CodeLocation & loc, const std::list<ptr<Stmt>> && ks = {}, const std::vector<Label> && labels = {} )
     57        CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {},
     58                                 std::vector<Label> && labels = {} )
    5859                : Stmt(loc, std::move(labels)), kids(std::move(ks)) {}
    5960
     
    7374class NullStmt final : public Stmt {
    7475  public:
    75         NullStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
     76        NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
    7677                : Stmt(loc, std::move(labels)) {}
    7778
     
    8788        ptr<Expr> expr;
    8889
    89         ExprStmt( const CodeLocation & loc, const Expr* e, const std::vector<Label> && labels = {} )
     90        ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label> && labels = {} )
    9091                : Stmt(loc, std::move(labels)), expr(e) {}
    9192
     
    106107
    107108        AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction,
    108                          const std::vector<ptr<Expr>> && output, const std::vector<ptr<Expr>> && input,
    109                          const std::vector<ptr<ConstantExpr>> && clobber, const std::vector<Label> && gotoLabels,
    110                          const std::vector<Label> && labels = {})
     109                         std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>> && input,
     110                         std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label> && gotoLabels,
     111                         std::vector<Label> && labels = {})
    111112                : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction),
    112113                  output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)),
     
    143144
    144145        IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then,
    145                         const Stmt * else_ = nullptr, const std::vector<ptr<Stmt>> && inits = {},
    146                         const std::vector<Label> && labels = {} )
     146                        const Stmt * else_ = nullptr, std::vector<ptr<Stmt>> && inits = {},
     147                        std::vector<Label> && labels = {} )
    147148                : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_),
    148149                  inits(std::move(inits)) {}
     
    160161        std::vector<ptr<Stmt>> stmts;
    161162
    162         SwitchStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts,
    163                                 const std::vector<Label> && labels = {} )
     163        SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
     164                                std::vector<Label> && labels = {} )
    164165                : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    165166
     
    177178        std::vector<ptr<Stmt>> stmts;
    178179
    179         CaseStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts,
    180                           const std::vector<Label> && labels = {} )
     180        CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
     181                          std::vector<Label> && labels = {} )
    181182                : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    182183
     
    199200
    200201        WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,
    201                                  const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} )
     202                           std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
    202203                : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {}
    203204
    204205        WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_,
    205                                  const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} )
     206                           std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
    206207                : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {}
    207208
     
    221222        ptr<Stmt> else_;
    222223
    223         ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond,
    224                          const Expr * inc, const Stmt * body, const std::vector<Label> && label = {} )
     224        ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
     225                         const Expr * inc, const Stmt * body, std::vector<Label> && label = {} )
    225226                : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {}
    226227
    227         ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond,
    228                          const Expr * inc, const Stmt * body, const Stmt * else_, const std::vector<Label> && labels = {} )
     228        ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
     229                         const Expr * inc, const Stmt * body, const Stmt * else_, std::vector<Label> && labels = {} )
    229230                : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {}
    230231
     
    246247        Kind kind;
    247248
    248         BranchStmt( const CodeLocation & loc, Kind kind, Label target, const std::vector<Label> && labels = {} );
    249         BranchStmt( const CodeLocation & loc, const Expr * computedTarget, const std::vector<Label> && labels = {} )
    250                 : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), computedTarget(computedTarget), kind(Goto) {}
     249        BranchStmt( const CodeLocation & loc, Kind kind, Label target,
     250                                std::vector<Label> && labels = {} );
     251        BranchStmt( const CodeLocation & loc, const Expr * computedTarget,
     252                                std::vector<Label> && labels = {} )
     253                : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc),
     254                  computedTarget(computedTarget), kind(Goto) {}
    251255
    252256        const char * kindName() const { return kindNames[kind]; }
     
    265269        ptr<Expr> expr;
    266270
    267         ReturnStmt( const CodeLocation & loc, const Expr * expr, const std::vector<Label> && labels = {} )
     271        ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} )
    268272                : Stmt(loc, std::move(labels)), expr(expr) {}
    269273
     
    284288        ExceptionKind kind;
    285289
    286         ThrowStmt( const CodeLocation & loc, ExceptionKind kind, const Expr * expr,
    287                            const Expr * target, const std::vector<Label> && labels = {} )
     290        ThrowStmt(
     291                const CodeLocation & loc, ExceptionKind kind, const Expr * expr, const Expr * target,
     292                std::vector<Label> && labels = {} )
    288293                : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {}
    289294
     
    301306        ptr<FinallyStmt> finally;
    302307
    303         TryStmt( const CodeLocation & loc, const CompoundStmt * body,
    304                          const std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally,
    305                          const std::vector<Label> && labels = {} )
     308        TryStmt(
     309                const CodeLocation & loc, const CompoundStmt * body,
     310                std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally,
     311                std::vector<Label> && labels = {} )
    306312                : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {}
    307313
     
    320326        ExceptionKind kind;
    321327
    322         CatchStmt( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,
    323                            const Stmt * body, const std::vector<Label> && labels = {} )
     328        CatchStmt(
     329                const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond,
     330                const Stmt * body, std::vector<Label> && labels = {} )
    324331                : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {}
    325332
     
    351358        enum Type { None, Coroutine, Generator } type = None;
    352359
    353         SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, const std::vector<Label> && labels = {} )
     360        SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} )
    354361                : Stmt(loc, std::move(labels)), then(then), type(type) {}
    355362
     
    389396        OrElse orElse;
    390397
    391         WaitForStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )
     398        WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
    392399                : Stmt(loc, std::move(labels)) {}
    393400
     
    403410        ptr<Decl> decl;
    404411
    405         DeclStmt( const CodeLocation & loc, const Decl * decl, const std::vector<Label> && labels = {} )
     412        DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} )
    406413                : Stmt(loc, std::move(labels)), decl(decl) {}
    407414
     
    434441
    435442        MutexStmt( const CodeLocation & loc, const Stmt * stmt,
    436                            const std::vector<ptr<Expr>> && mutexes, const std::vector<Label> && labels = {} )
     443                           std::vector<ptr<Expr>> && mutexes, std::vector<Label> && labels = {} )
    437444                : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {}
    438445
  • src/CodeGen/CodeGenerator.cc

    r9dc08363 r941e14a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 20:30:30 2022
    13 // Update Count     : 541
     12// Last Modified On : Tue Feb  1 16:29:25 2022
     13// Update Count     : 540
    1414//
    1515#include "CodeGenerator.h"
     
    10201020                        output << "fallthru";
    10211021                        break;
    1022                   default: ;                                                                    // prevent warning
    10231022                } // switch
    10241023                // print branch target for labelled break/continue/fallthru in debug mode
  • src/ControlStruct/MLEMutator.cc

    r9dc08363 r941e14a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 20:18:57 2022
    13 // Update Count     : 227
     12// Last Modified On : Tue Feb  1 09:26:28 2022
     13// Update Count     : 225
    1414//
    1515
     
    136136                        }
    137137                }
    138                 assertf( false, "CFA internal error: could not find label '%s' on statement %s",
     138                assertf( false, "Could not find label '%s' on statement %s",
    139139                        originalTarget.get_name().c_str(), toString( stmt ).c_str() );
    140140        }
     
    395395                }
    396396                assert( ! enclosingControlStructures.empty() );
    397                 assertf( dynamic_cast<SwitchStmt *>( enclosingControlStructures.back().get_controlStructure() ),
    398                                  "CFA internal error: control structure enclosing a case clause must be a switch, but is: %s",
    399                                  toCString( enclosingControlStructures.back().get_controlStructure() ) );
     397                assertf( dynamic_cast<SwitchStmt *>( enclosingControlStructures.back().get_controlStructure() ), "Control structure enclosing a case clause must be a switch, but is: %s", toCString( enclosingControlStructures.back().get_controlStructure() ) );
    400398                if ( caseStmt->isDefault() ) {
    401399                        if ( enclosingControlStructures.back().isFallDefaultUsed() ) {
  • src/ControlStruct/MultiLevelExit.cpp

    r9dc08363 r941e14a  
    1010// Created On       : Mon Nov  1 13:48:00 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 20:19:24 2022
    13 // Update Count     : 30
     12// Last Modified On : Tue Feb  1 18:48:47 2022
     13// Update Count     : 29
    1414//
    1515
     
    206206                }
    207207        }
    208         assertf( false, "CFA internal error: could not find label '%s' on statement %s",
     208        assertf( false, "Could not find label '%s' on statement %s",
    209209                         originalTarget.name.c_str(), toString( stmt ).c_str() );
    210210}
     
    406406        Entry & entry = enclosing_control_structures.back();
    407407        assertf( dynamic_cast< const SwitchStmt * >( entry.stmt ),
    408                          "CFA internal error: control structure enclosing a case clause must be a switch, but is: %s",
     408                         "Control structure enclosing a case clause must be a switch, but is: %s",
    409409                         toString( entry.stmt ).c_str() );
    410410        if ( mutStmt->isDefault() ) {
  • src/Parser/StatementNode.cc

    r9dc08363 r941e14a  
    1111// Created On       : Sat May 16 14:59:41 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Wed Feb  2 20:29:30 2022
    14 // Update Count     : 425
     13// Last Modified On : Wed Feb  2 12:27:58 2022
     14// Update Count     : 424
    1515//
    1616
     
    138138
    139139Statement * build_case( ExpressionNode * ctl ) {
    140         return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // stmt starts empty and then added to
     140        return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // no init
    141141} // build_case
    142142
    143143Statement * build_default() {
    144         return new CaseStmt( nullptr, {}, true );                       // stmt starts empty and then added to
     144        return new CaseStmt( nullptr, {}, true );                       // no init
    145145} // build_default
    146146
  • src/SynTree/Statement.cc

    r9dc08363 r941e14a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 20:19:33 2022
    13 // Update Count     : 90
     12// Last Modified On : Wed Feb  2 11:55:19 2022
     13// Update Count     : 80
    1414//
    1515
     
    2929#include "SynTree/Label.h"         // for Label, operator<<
    3030
    31 using namespace std;
    32 
    33 
    34 Statement::Statement( const list<Label> & labels ) : labels( labels ) {}
    35 
    36 void Statement::print( ostream & os, Indenter indent ) const {
     31using std::string;
     32using std::endl;
     33
     34Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {}
     35
     36void Statement::print( std::ostream & os, Indenter indent ) const {
    3737        if ( ! labels.empty() ) {
    3838                os << indent << "... Labels: {";
     
    5454}
    5555
    56 void ExprStmt::print( ostream & os, Indenter indent ) const {
    57         os << "Expression Statement:" << endl << indent + 1;
    58         expr->print( os, indent + 1 );
    59 }
    60 
    61 
    62 AsmStmt::AsmStmt( bool voltile, Expression * instruction, const list<Expression *> output, const list<Expression *> input, const list<ConstantExpr *> clobber, const list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}
     56void ExprStmt::print( std::ostream & os, Indenter indent ) const {
     57        os << "Expression Statement:" << endl << indent+1;
     58        expr->print( os, indent+1 );
     59}
     60
     61
     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( ostream & os, Indenter indent ) const {
     77void AsmStmt::print( std::ostream & os, Indenter indent ) const {
    7878        os << "Assembler Statement:" << endl;
    79         os << indent + 1 << "instruction: " << endl << indent;
    80         instruction->print( os, indent + 1 );
     79        os << indent+1 << "instruction: " << endl << indent;
     80        instruction->print( os, indent+1 );
    8181        if ( ! output.empty() ) {
    82                 os << endl << indent + 1 << "output: " << endl;
    83                 printAll( output, os, indent + 1 );
     82                os << endl << indent+1 << "output: " << endl;
     83                printAll( output, os, indent+1 );
    8484        } // if
    8585        if ( ! input.empty() ) {
    86                 os << indent + 1 << "input: " << endl;
    87                 printAll( input, os, indent + 1 );
     86                os << indent+1 << "input: " << endl;
     87                printAll( input, os, indent+1 );
    8888        } // if
    8989        if ( ! clobber.empty() ) {
    90                 os << indent + 1 << "clobber: " << endl;
    91                 printAll( clobber, os, indent + 1 );
     90                os << indent+1 << "clobber: " << endl;
     91                printAll( clobber, os, indent+1 );
    9292        } // if
    9393}
    9494
    9595
    96 DirectiveStmt::DirectiveStmt( const string & directive ) : Statement(), directive( directive ) {}
    97 
    98 void DirectiveStmt::print( ostream & os, Indenter ) const {
     96DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {}
     97
     98void DirectiveStmt::print( std::ostream & os, Indenter ) const {
    9999        os << "GCC Directive:" << directive << endl;
    100100}
     
    120120}
    121121
    122 void BranchStmt::print( ostream & os, Indenter indent ) const {
    123         assertf(type < BranchStmts, "CFA internal error: invalid branch statement" );
     122void BranchStmt::print( std::ostream & os, Indenter indent ) const {
     123        assert(type < 5);
    124124        os << "Branch (" << brType[type] << ")" << endl ;
    125         if ( target != "" ) os << indent + 1 << "with target: " << target << endl;
    126         if ( originalTarget != "" ) os << indent + 1 << "with original target: " << originalTarget << endl;
    127         if ( computedTarget != nullptr ) os << indent + 1 << "with computed target: " << computedTarget << endl;
     125        if ( target != "" ) os << indent+1 << "with target: " << target << endl;
     126        if ( originalTarget != "" ) os << indent+1 << "with original target: " << originalTarget << endl;
     127        if ( computedTarget != nullptr ) os << indent+1 << "with computed target: " << computedTarget << endl;
    128128}
    129129
     
    136136}
    137137
    138 void ReturnStmt::print( ostream & os, Indenter indent ) const {
     138void ReturnStmt::print( std::ostream & os, Indenter indent ) const {
    139139        os << "Return Statement, returning: ";
    140140        if ( expr != nullptr ) {
    141                 os << endl << indent + 1;
    142                 expr->print( os, indent + 1 );
     141                os << endl << indent+1;
     142                expr->print( os, indent+1 );
    143143        }
    144144        os << endl;
    145145}
    146146
    147 IfStmt::IfStmt( Expression * condition, Statement * then, Statement * else_, const list<Statement *> initialization ):
     147IfStmt::IfStmt( Expression * condition, Statement * then, Statement * else_, std::list<Statement *> initialization ):
    148148        Statement(), condition( condition ), then( then ), else_( else_ ), initialization( initialization ) {}
    149149
     
    160160}
    161161
    162 void IfStmt::print( ostream & os, Indenter indent ) const {
     162void IfStmt::print( std::ostream & os, Indenter indent ) const {
    163163        os << "If on condition: " << endl;
    164         os << indent + 1;
    165         condition->print( os, indent + 1 );
     164        os << indent+1;
     165        condition->print( os, indent+1 );
    166166
    167167        if ( !initialization.empty() ) {
    168168                os << indent << "... with initialization: \n";
    169169                for ( const Statement * stmt : initialization ) {
    170                         os << indent + 1;
    171                         stmt->print( os, indent + 1 );
     170                        os << indent+1;
     171                        stmt->print( os, indent+1 );
    172172                }
    173173                os << endl;
     
    176176        os << indent << "... then: " << endl;
    177177
    178         os << indent + 1;
    179         then->print( os, indent + 1 );
     178        os << indent+1;
     179        then->print( os, indent+1 );
    180180
    181181        if ( else_ != nullptr ) {
    182182                os << indent << "... else: " << endl;
    183                 os << indent + 1;
    184                 else_->print( os, indent + 1 );
     183                os << indent+1;
     184                else_->print( os, indent+1 );
    185185        } // if
    186186}
    187187
    188 SwitchStmt::SwitchStmt( Expression * condition, const list<Statement *> & statements ):
     188SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ):
    189189        Statement(), condition( condition ), statements( statements ) {
    190190}
     
    201201}
    202202
    203 void SwitchStmt::print( ostream & os, Indenter indent ) const {
     203void SwitchStmt::print( std::ostream & os, Indenter indent ) const {
    204204        os << "Switch on condition: ";
    205205        condition->print( os );
     
    207207
    208208        for ( const Statement * stmt : statements ) {
    209                 stmt->print( os, indent + 1 );
    210         }
    211 }
    212 
    213 CaseStmt::CaseStmt( Expression * condition, const list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) :
    214                 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
     209                stmt->print( os, indent+1 );
     210        }
     211}
     212
     213CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) :
     214        Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {
    215215        if ( isDefault() && condition != nullptr ) SemanticError( condition, "default case with condition: " );
    216216}
    217217
    218218CaseStmt::CaseStmt( const CaseStmt & other ) :
    219                 Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
     219        Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {
    220220        cloneAll( other.stmts, stmts );
    221221}
     
    226226}
    227227
    228 CaseStmt * CaseStmt::makeDefault( const list<Label> & labels, list<Statement *> stmts ) {
     228CaseStmt * CaseStmt::makeDefault( const std::list<Label> & labels, std::list<Statement *> stmts ) {
    229229        CaseStmt * stmt = new CaseStmt( nullptr, stmts, true );
    230230        stmt->labels = labels;
     
    232232}
    233233
    234 void CaseStmt::print( ostream & os, Indenter indent ) const {
     234void CaseStmt::print( std::ostream & os, Indenter indent ) const {
    235235        if ( isDefault() ) os << indent << "Default ";
    236236        else {
     
    241241
    242242        for ( Statement * stmt : stmts ) {
    243                 os << indent + 1;
    244                 stmt->print( os, indent + 1 );
    245         }
    246 }
    247 
    248 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, const list< Statement * > & initialization, bool isDoWhile ):
     243                os << indent+1;
     244                stmt->print( os, indent+1 );
     245        }
     246}
     247
     248WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, const std::list< Statement * > & initialization, bool isDoWhile ):
    249249        Statement(), condition( condition ), body( body ), else_( nullptr ), initialization( initialization ), isDoWhile( isDoWhile) {
    250250}
    251251
    252 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const list< Statement * > & initialization, bool isDoWhile ):
     252WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list< Statement * > & initialization, bool isDoWhile ):
    253253        Statement(), condition( condition), body( body ), else_( else_ ), initialization( initialization ), isDoWhile( isDoWhile) {
    254254}
     
    263263}
    264264
    265 void WhileDoStmt::print( ostream & os, Indenter indent ) const {
     265void WhileDoStmt::print( std::ostream & os, Indenter indent ) const {
    266266        os << "While on condition: " << endl ;
    267         condition->print( os, indent + 1 );
     267        condition->print( os, indent+1 );
    268268
    269269        os << indent << "... with body: " << endl;
    270270
    271         if ( body != nullptr ) body->print( os, indent + 1 );
    272 }
    273 
    274 ForStmt::ForStmt( const list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body, Statement * else_ ):
     271        if ( body != nullptr ) body->print( os, indent+1 );
     272}
     273
     274ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body, Statement * else_ ):
    275275        Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ), else_( else_ ) {
    276276}
     
    290290}
    291291
    292 void ForStmt::print( ostream & os, Indenter indent ) const {
     292void ForStmt::print( std::ostream & os, Indenter indent ) const {
    293293        Statement::print( os, indent ); // print labels
    294294
     
    298298                os << indent << "... initialization: \n";
    299299                for ( Statement * stmt : initialization ) {
    300                         os << indent + 1;
    301                         stmt->print( os, indent + 1 );
     300                        os << indent+1;
     301                        stmt->print( os, indent+1 );
    302302                }
    303303        }
    304304
    305305        if ( condition != nullptr ) {
    306                 os << indent << "... condition: \n" << indent + 1;
    307                 condition->print( os, indent + 1 );
     306                os << indent << "... condition: \n" << indent+1;
     307                condition->print( os, indent+1 );
    308308        }
    309309
    310310        if ( increment != nullptr ) {
    311                 os << "\n" << indent << "... increment: \n" << indent + 1;
    312                 increment->print( os, indent + 1 );
     311                os << "\n" << indent << "... increment: \n" << indent+1;
     312                increment->print( os, indent+1 );
    313313        }
    314314
    315315        if ( body != nullptr ) {
    316                 os << "\n" << indent << "... with body: \n" << indent + 1;
    317                 body->print( os, indent + 1 );
     316                os << "\n" << indent << "... with body: \n" << indent+1;
     317                body->print( os, indent+1 );
    318318        }
    319319
    320320        if ( else_ != nullptr ) {
    321                 os << "\n" << indent << "... with body: \n" << indent + 1;
    322                 else_->print( os, indent + 1 );
     321                os << "\n" << indent << "... with body: \n" << indent+1;
     322                else_->print( os, indent+1 );
    323323        }
    324324        os << endl;
     
    339339}
    340340
    341 void ThrowStmt::print( ostream & os, Indenter indent) const {
     341void ThrowStmt::print( std::ostream & os, Indenter indent) const {
    342342        if ( target ) os << "Non-Local ";
    343343        os << "Throw Statement, raising: ";
    344         expr->print(os, indent + 1);
     344        expr->print(os, indent+1);
    345345        if ( target ) {
    346346                os << "... at: ";
    347                 target->print(os, indent + 1);
    348         }
    349 }
    350 
    351 TryStmt::TryStmt( CompoundStmt * tryBlock, const list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) :
     347                target->print(os, indent+1);
     348        }
     349}
     350
     351TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) :
    352352        Statement(), block( tryBlock ),  handlers( handlers ), finallyBlock( finallyBlock ) {
    353353}
     
    363363}
    364364
    365 void TryStmt::print( ostream & os, Indenter indent ) const {
     365void TryStmt::print( std::ostream & os, Indenter indent ) const {
    366366        os << "Try Statement" << endl;
    367         os << indent << "... with block:" << endl << indent + 1;
    368         block->print( os, indent + 1 );
     367        os << indent << "... with block:" << endl << indent+1;
     368        block->print( os, indent+1 );
    369369
    370370        // handlers
    371371        os << indent << "... and handlers:" << endl;
    372372        for ( const CatchStmt * stmt : handlers ) {
    373                 os << indent + 1;
    374                 stmt->print( os, indent + 1 );
     373                os << indent+1;
     374                stmt->print( os, indent+1 );
    375375        }
    376376
    377377        // finally block
    378378        if ( finallyBlock != nullptr ) {
    379                 os << indent << "... and finally:" << endl << indent + 1;
    380                 finallyBlock->print( os, indent + 1 );
     379                os << indent << "... and finally:" << endl << indent+1;
     380                finallyBlock->print( os, indent+1 );
    381381        } // if
    382382}
     
    396396}
    397397
    398 void CatchStmt::print( ostream & os, Indenter indent ) const {
     398void CatchStmt::print( std::ostream & os, Indenter indent ) const {
    399399        os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl;
    400400
    401401        os << indent << "... catching: ";
    402         decl->printShort( os, indent + 1 );
     402        decl->printShort( os, indent+1 );
    403403        os << endl;
    404404
    405405        if ( cond ) {
    406                 os << indent << "... with conditional:" << endl << indent + 1;
    407                 cond->print( os, indent + 1 );
     406                os << indent << "... with conditional:" << endl << indent+1;
     407                cond->print( os, indent+1 );
    408408        }
    409409
    410410        os << indent << "... with block:" << endl;
    411         os << indent + 1;
    412         body->print( os, indent + 1 );
     411        os << indent+1;
     412        body->print( os, indent+1 );
    413413}
    414414
     
    424424}
    425425
    426 void FinallyStmt::print( ostream & os, Indenter indent ) const {
     426void FinallyStmt::print( std::ostream & os, Indenter indent ) const {
    427427        os << "Finally Statement" << endl;
    428         os << indent << "... with block:" << endl << indent + 1;
    429         block->print( os, indent + 1 );
     428        os << indent << "... with block:" << endl << indent+1;
     429        block->print( os, indent+1 );
    430430}
    431431
     
    439439}
    440440
    441 void SuspendStmt::print( ostream & os, Indenter indent ) const {
     441void SuspendStmt::print( std::ostream & os, Indenter indent ) const {
    442442        os << "Suspend Statement";
    443443        switch (type) {
     
    496496}
    497497
    498 void WaitForStmt::print( ostream & os, Indenter indent ) const {
     498void WaitForStmt::print( std::ostream & os, Indenter indent ) const {
    499499        os << "Waitfor Statement" << endl;
    500500        indent += 1;
     
    531531
    532532
    533 WithStmt::WithStmt( const list< Expression * > & exprs, Statement * stmt ) : Declaration("", noStorageClasses, LinkageSpec::Cforall), exprs( exprs ), stmt( stmt ) {}
     533WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Declaration("", noStorageClasses, LinkageSpec::Cforall), exprs( exprs ), stmt( stmt ) {}
    534534WithStmt::WithStmt( const WithStmt & other ) : Declaration( other ), stmt( maybeClone( other.stmt ) ) {
    535535        cloneAll( other.exprs, exprs );
     
    540540}
    541541
    542 void WithStmt::print( ostream & os, Indenter indent ) const {
     542void WithStmt::print( std::ostream & os, Indenter indent ) const {
    543543        os << "With statement" << endl;
    544544        os << indent << "... with expressions: " << endl;
    545         printAll( exprs, os, indent + 1 );
    546         os << indent << "... with statement:" << endl << indent + 1;
    547         stmt->print( os, indent + 1 );
    548 }
    549 
    550 
    551 NullStmt::NullStmt( const list<Label> & labels ) : Statement( labels ) {
    552 }
    553 
    554 void NullStmt::print( ostream & os, Indenter indent ) const {
     545        printAll( exprs, os, indent+1 );
     546        os << indent << "... with statement:" << endl << indent+1;
     547        stmt->print( os, indent+1 );
     548}
     549
     550
     551NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) {
     552}
     553
     554void NullStmt::print( std::ostream & os, Indenter indent ) const {
    555555        os << "Null Statement" << endl;
    556556        Statement::print( os, indent );
     
    568568}
    569569
    570 void ImplicitCtorDtorStmt::print( ostream & os, Indenter indent ) const {
     570void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const {
    571571        os << "Implicit Ctor Dtor Statement" << endl;
    572572        os << indent << "... with Ctor/Dtor: ";
    573         callStmt->print( os, indent + 1);
     573        callStmt->print( os, indent+1);
    574574        os << endl;
    575575}
    576576
    577 MutexStmt::MutexStmt( Statement * stmt, const list<Expression *> mutexObjs )
     577MutexStmt::MutexStmt( Statement * stmt, std::list<Expression *> mutexObjs )
    578578        : Statement(), stmt( stmt ), mutexObjs( mutexObjs ) { }
    579579
     
    587587}
    588588
    589 void MutexStmt::print( ostream & os, Indenter indent ) const {
     589void MutexStmt::print( std::ostream & os, Indenter indent ) const {
    590590        os << "Mutex Statement" << endl;
    591591        os << indent << "... with Expressions: " << endl;
    592592        for (auto * obj : mutexObjs) {
    593                 os << indent + 1;
    594                 obj->print( os, indent + 1);
     593                os << indent+1;
     594                obj->print( os, indent+1);
    595595                os << endl;
    596596        }
    597         os << indent << "... with Statement: " << endl << indent + 1;
    598         stmt->print( os, indent + 1 );
     597        os << indent << "... with Statement: " << endl << indent+1;
     598        stmt->print( os, indent+1 );
    599599}
    600600
  • src/SynTree/Statement.h

    r9dc08363 r941e14a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  2 20:15:30 2022
    13 // Update Count     : 98
     12// Last Modified On : Wed Feb  2 11:49:17 2022
     13// Update Count     : 94
    1414//
    1515
     
    107107        std::list<Label> gotolabels;
    108108
    109         AsmStmt( bool voltile, Expression * instruction, const std::list<Expression *> output, const std::list<Expression *> input, const std::list<ConstantExpr *> clobber, const std::list<Label> gotolabels );
     109        AsmStmt( bool voltile, Expression * instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels );
    110110        AsmStmt( const AsmStmt & other );
    111111        virtual ~AsmStmt();
     
    153153
    154154        IfStmt( Expression * condition, Statement * then, Statement * else_,
    155                         const std::list<Statement *> initialization = std::list<Statement *>() );
     155                        std::list<Statement *> initialization = std::list<Statement *>() );
    156156        IfStmt( const IfStmt & other );
    157157        virtual ~IfStmt();
     
    260260        Statement * else_;
    261261
    262         ForStmt( const std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr );
     262        ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr );
    263263        ForStmt( const ForStmt & other );
    264264        virtual ~ForStmt();
     
    281281class BranchStmt : public Statement {
    282282  public:
    283         enum Type { Goto, Break, Continue, FallThrough, FallThroughDefault, BranchStmts };
     283        enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault };
    284284
    285285        // originalTarget kept for error messages.
     
    360360        FinallyStmt * finallyBlock;
    361361
    362         TryStmt( CompoundStmt * tryBlock, const std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr );
     362        TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr );
    363363        TryStmt( const TryStmt & other );
    364364        virtual ~TryStmt();
     
    543543        std::list<Expression *> mutexObjs; // list of mutex objects to acquire
    544544
    545         MutexStmt( Statement * stmt, const std::list<Expression *> mutexObjs );
     545        MutexStmt( Statement * stmt, std::list<Expression *> mutexObjs );
    546546        MutexStmt( const MutexStmt & other );
    547547        virtual ~MutexStmt();
Note: See TracChangeset for help on using the changeset viewer.