Changeset 44adf1b


Ignore:
Timestamp:
Mar 5, 2024, 9:55:04 AM (7 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
af60383
Parents:
9262fe9
Message:

Removed casts around get_next (also replaced with direct field access) that are no longer needed.

Location:
src/Parser
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r9262fe9 r44adf1b  
    101101DeclarationNode * DeclarationNode::clone() const {
    102102        DeclarationNode * newnode = new DeclarationNode;
    103         newnode->set_next( maybeCopy( get_next() ) );
     103        newnode->next = maybeCopy( next );
    104104        newnode->name = name ? new string( *name ) : nullptr;
    105105
     
    717717
    718718                // there may be typedefs chained onto the type
    719                 if ( o->get_next() ) {
    720                         set_last( o->get_next()->clone() );
     719                if ( o->next ) {
     720                        set_last( o->next->clone() );
    721721                } // if
    722722        } // if
  • src/Parser/ExpressionNode.h

    r9262fe9 r44adf1b  
    2626                if ( nullptr == expr ) return nullptr;
    2727                ExpressionNode * node = new ExpressionNode( ast::shallowCopy( expr.get() ) );
    28                 node->set_next( maybeCopy( get_next() ) );
     28                node->next = maybeCopy( next );
    2929                return node;
    3030        }
  • src/Parser/InitializerNode.cc

    r9262fe9 r44adf1b  
    3636                : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ), isDelete( false ) {
    3737        if ( aggrp )
    38                 kids = dynamic_cast< InitializerNode * >( get_next() );
     38                kids = next;
    3939
    4040        if ( kids )
     
    4848
    4949        if ( aggrp )
    50                 kids = dynamic_cast< InitializerNode * >( get_next() );
     50                kids = next;
    5151
    5252        if ( kids )
    53                 set_next( nullptr );
     53                next = nullptr;
    5454} // InitializerNode::InitializerNode
    5555
     
    7373                        while ( curdes != nullptr) {
    7474                                curdes->printOneLine(os);
    75                                 curdes = (ExpressionNode *)(curdes->get_next());
     75                                curdes = curdes->next;
    7676                                if ( curdes ) os << ", ";
    7777                        } // while
     
    8787
    8888        InitializerNode *moreInit;
    89         if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) {
     89        if ( ( moreInit = next ) ) {
    9090                moreInit->printOneLine( os );
    9191        } // if
     
    9898                std::vector<ast::ptr<ast::Designation>> designlist;
    9999                InitializerNode * child = next_init();
    100                 for ( ; child != nullptr ; child = dynamic_cast< InitializerNode * >( child->get_next() ) ) {
     100                for ( ; child != nullptr ; child = child->next ) {
    101101                        std::deque<ast::ptr<ast::Expr>> desList;
    102102                        buildList( child->designator, desList );
  • src/Parser/ParseNode.h

    r9262fe9 r44adf1b  
    6464        virtual ParseList<Next> * clone() const = 0;
    6565
    66         Next * get_next() const { return next; }
    67         void set_next( Next * newlink ) { next = newlink; }
    68 
    6966        Next * get_last() {
    7067                Next * current = static_cast<Next *>( this );
  • src/Parser/StatementNode.cc

    r9262fe9 r44adf1b  
    5454                StatementNode * nextStmt = new StatementNode(
    5555                        new ast::DeclStmt( decl->location, maybeBuild( decl ) ) );
    56                 set_next( nextStmt );
    57                 if ( decl->get_next() ) {
    58                         get_next()->set_next( new StatementNode( dynamic_cast< DeclarationNode * >(decl->get_next()) ) );
    59                         decl->set_next( 0 );
     56                next = nextStmt;
     57                if ( decl->next ) {
     58                        next->next = new StatementNode( decl->next );
     59                        decl->next = nullptr;
    6060                } // if
    6161        } else {
    62                 if ( decl->get_next() ) {
    63                         set_next( new StatementNode( dynamic_cast< DeclarationNode * >( decl->get_next() ) ) );
    64                         decl->set_next( 0 );
     62                if ( decl->next ) {
     63                        next = new StatementNode( decl->next );
     64                        decl->next = nullptr;
    6565                } // if
    6666                agg = decl;
     
    8787        ClauseNode * prev = this;
    8888        // find end of list and maintain previous pointer
    89         for ( ClauseNode * curr = prev; curr != nullptr; curr = (ClauseNode *)curr->get_next() ) {
    90                 ClauseNode * node = strict_dynamic_cast< ClauseNode * >(curr);
     89        for ( ClauseNode * curr = prev; curr != nullptr; curr = curr->next ) {
     90                ClauseNode * node = curr;
    9191                assert( dynamic_cast<ast::CaseClause *>( node->clause.get() ) );
    9292                prev = curr;
    9393        } // for
    94         ClauseNode * node = dynamic_cast< ClauseNode * >(prev);
     94        ClauseNode * node = prev;
    9595        // convert from StatementNode list to Statement list
    9696        std::vector<ast::ptr<ast::Stmt>> stmts;
     
    332332        clause->when_cond = notZeroExpr( maybeMoveBuild( when ) );
    333333
    334         ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() );
    335         targetExpr->set_next( nullptr );
     334        ExpressionNode * next = targetExpr->next;
     335        targetExpr->next = nullptr;
    336336        buildMoveList( next, clause->target_args );
    337337
  • src/Parser/TypeData.cc

    r9262fe9 r44adf1b  
    494494        for ( auto i = outputList.begin() ;
    495495                        i != outputList.end() ;
    496                         ++i, n = (DeclarationNode*)n->get_next() ) {
     496                        ++i, n = n->next ) {
    497497                // Only the object type class adds additional assertions.
    498498                if ( n->variable.tyClass != ast::TypeDecl::Otype ) {
     
    639639        for ( auto i = outputForall.begin() ;
    640640                        i != outputForall.end() ;
    641                         ++i, n = (DeclarationNode*)n->get_next() ) {
     641                        ++i, n = n->next ) {
    642642                // Only the object type class adds additional assertions.
    643643                if ( n->variable.tyClass != ast::TypeDecl::Otype ) {
     
    12721272        auto members = ret->members.begin();
    12731273        ret->hide = td->enumeration.hiding == EnumHiding::Hide ? ast::EnumDecl::EnumHiding::Hide : ast::EnumDecl::EnumHiding::Visible;
    1274         for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
     1274        for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = cur->next, ++members ) {
    12751275                if ( cur->enumInLine ) {
    12761276                        // Do Nothing
     
    15001500        assert( ! function.params );
    15011501        // loop over declaration first as it is easier to spot errors
    1502         for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = dynamic_cast< DeclarationNode * >( decl->get_next() ) ) {
     1502        for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = decl->next ) {
    15031503                // scan ALL parameter names for each declaration name to check for duplicates
    1504                 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode * >( param->get_next() ) ) {
     1504                for ( DeclarationNode * param = function.idList; param != nullptr; param = param->next ) {
    15051505                        if ( *decl->name == *param->name ) {
    15061506                                // type set => parameter name already transformed by a declaration names so there is a duplicate
     
    15241524        //    rtb( a, b, c ) const char * b; {} => int rtn( int a, const char * b, int c ) {}
    15251525
    1526         for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode * >( param->get_next() ) ) {
     1526        for ( DeclarationNode * param = function.idList; param != nullptr; param = param->next ) {
    15271527                if ( ! param->type ) {                                                  // generate type int for empty parameter type
    15281528                        param->type = new TypeData( TypeData::Basic );
  • src/Parser/parser.yy

    r9262fe9 r44adf1b  
    127127
    128128        // Start at second variable in declaration list and clone the type specifiers for each variable.
    129         for ( DeclarationNode * cur = dynamic_cast<DeclarationNode *>( declList->get_next() ); cur != nullptr; cur = dynamic_cast<DeclarationNode *>( cur->get_next() ) ) {
     129        for ( DeclarationNode * cur = declList->next ; cur != nullptr; cur = cur->next ) {
    130130                cl->cloneBaseType( cur, copyattr );                             // cur is modified
    131131        } // for
     
    139139void distExt( DeclarationNode * declaration ) {
    140140        // distribute EXTENSION across all declarations
    141         for ( DeclarationNode *iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     141        for ( DeclarationNode *iter = declaration ; iter != nullptr ; iter = iter->next ) {
    142142                iter->set_extension( true );
    143143        } // for
     
    146146void distInl( DeclarationNode * declaration ) {
    147147        // distribute INLINE across all declarations
    148         for ( DeclarationNode *iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     148        for ( DeclarationNode *iter = declaration ; iter != nullptr ; iter = iter->next ) {
    149149                iter->set_inLine( true );
    150150        } // for
     
    153153void distQual( DeclarationNode * declaration, DeclarationNode * qualifiers ) {
    154154        // distribute qualifiers across all non-variable declarations in a distribution statemement
    155         for ( DeclarationNode * iter = declaration; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) {
     155        for ( DeclarationNode * iter = declaration ; iter != nullptr ; iter = iter->next ) {
    156156                // SKULLDUGGERY: Distributions are parsed inside out, so qualifiers are added to declarations inside out. Since
    157157                // addQualifiers appends to the back of the list, the forall clauses are in the wrong order (right to left). To
Note: See TracChangeset for help on using the changeset viewer.