Changeset 44adf1b
- Timestamp:
- Mar 5, 2024, 9:55:04 AM (11 months ago)
- Branches:
- master
- Children:
- af60383
- Parents:
- 9262fe9
- Location:
- src/Parser
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r9262fe9 r44adf1b 101 101 DeclarationNode * DeclarationNode::clone() const { 102 102 DeclarationNode * newnode = new DeclarationNode; 103 newnode-> set_next( maybeCopy( get_next() ));103 newnode->next = maybeCopy( next ); 104 104 newnode->name = name ? new string( *name ) : nullptr; 105 105 … … 717 717 718 718 // 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() ); 721 721 } // if 722 722 } // if -
src/Parser/ExpressionNode.h
r9262fe9 r44adf1b 26 26 if ( nullptr == expr ) return nullptr; 27 27 ExpressionNode * node = new ExpressionNode( ast::shallowCopy( expr.get() ) ); 28 node-> set_next( maybeCopy( get_next() ));28 node->next = maybeCopy( next ); 29 29 return node; 30 30 } -
src/Parser/InitializerNode.cc
r9262fe9 r44adf1b 36 36 : expr( _expr ), aggregate( aggrp ), designator( des ), kids( nullptr ), maybeConstructed( true ), isDelete( false ) { 37 37 if ( aggrp ) 38 kids = dynamic_cast< InitializerNode * >( get_next() );38 kids = next; 39 39 40 40 if ( kids ) … … 48 48 49 49 if ( aggrp ) 50 kids = dynamic_cast< InitializerNode * >( get_next() );50 kids = next; 51 51 52 52 if ( kids ) 53 set_next( nullptr );53 next = nullptr; 54 54 } // InitializerNode::InitializerNode 55 55 … … 73 73 while ( curdes != nullptr) { 74 74 curdes->printOneLine(os); 75 curdes = (ExpressionNode *)(curdes->get_next());75 curdes = curdes->next; 76 76 if ( curdes ) os << ", "; 77 77 } // while … … 87 87 88 88 InitializerNode *moreInit; 89 if ( ( moreInit = dynamic_cast< InitializerNode * >( get_next() )) ) {89 if ( ( moreInit = next ) ) { 90 90 moreInit->printOneLine( os ); 91 91 } // if … … 98 98 std::vector<ast::ptr<ast::Designation>> designlist; 99 99 InitializerNode * child = next_init(); 100 for ( ; child != nullptr ; child = dynamic_cast< InitializerNode * >( child->get_next() )) {100 for ( ; child != nullptr ; child = child->next ) { 101 101 std::deque<ast::ptr<ast::Expr>> desList; 102 102 buildList( child->designator, desList ); -
src/Parser/ParseNode.h
r9262fe9 r44adf1b 64 64 virtual ParseList<Next> * clone() const = 0; 65 65 66 Next * get_next() const { return next; }67 void set_next( Next * newlink ) { next = newlink; }68 69 66 Next * get_last() { 70 67 Next * current = static_cast<Next *>( this ); -
src/Parser/StatementNode.cc
r9262fe9 r44adf1b 54 54 StatementNode * nextStmt = new StatementNode( 55 55 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; 60 60 } // if 61 61 } 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; 65 65 } // if 66 66 agg = decl; … … 87 87 ClauseNode * prev = this; 88 88 // 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; 91 91 assert( dynamic_cast<ast::CaseClause *>( node->clause.get() ) ); 92 92 prev = curr; 93 93 } // for 94 ClauseNode * node = dynamic_cast< ClauseNode * >(prev);94 ClauseNode * node = prev; 95 95 // convert from StatementNode list to Statement list 96 96 std::vector<ast::ptr<ast::Stmt>> stmts; … … 332 332 clause->when_cond = notZeroExpr( maybeMoveBuild( when ) ); 333 333 334 ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() );335 targetExpr-> set_next( nullptr );334 ExpressionNode * next = targetExpr->next; 335 targetExpr->next = nullptr; 336 336 buildMoveList( next, clause->target_args ); 337 337 -
src/Parser/TypeData.cc
r9262fe9 r44adf1b 494 494 for ( auto i = outputList.begin() ; 495 495 i != outputList.end() ; 496 ++i, n = (DeclarationNode*)n->get_next()) {496 ++i, n = n->next ) { 497 497 // Only the object type class adds additional assertions. 498 498 if ( n->variable.tyClass != ast::TypeDecl::Otype ) { … … 639 639 for ( auto i = outputForall.begin() ; 640 640 i != outputForall.end() ; 641 ++i, n = (DeclarationNode*)n->get_next()) {641 ++i, n = n->next ) { 642 642 // Only the object type class adds additional assertions. 643 643 if ( n->variable.tyClass != ast::TypeDecl::Otype ) { … … 1272 1272 auto members = ret->members.begin(); 1273 1273 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 ) { 1275 1275 if ( cur->enumInLine ) { 1276 1276 // Do Nothing … … 1500 1500 assert( ! function.params ); 1501 1501 // loop over declaration first as it is easier to spot errors 1502 for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = d ynamic_cast< DeclarationNode * >( decl->get_next() )) {1502 for ( DeclarationNode * decl = function.oldDeclList; decl != nullptr; decl = decl->next ) { 1503 1503 // 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 ) { 1505 1505 if ( *decl->name == *param->name ) { 1506 1506 // type set => parameter name already transformed by a declaration names so there is a duplicate … … 1524 1524 // rtb( a, b, c ) const char * b; {} => int rtn( int a, const char * b, int c ) {} 1525 1525 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 ) { 1527 1527 if ( ! param->type ) { // generate type int for empty parameter type 1528 1528 param->type = new TypeData( TypeData::Basic ); -
src/Parser/parser.yy
r9262fe9 r44adf1b 127 127 128 128 // Start at second variable in declaration list and clone the type specifiers for each variable. 129 for ( DeclarationNode * cur = d ynamic_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 ) { 130 130 cl->cloneBaseType( cur, copyattr ); // cur is modified 131 131 } // for … … 139 139 void distExt( DeclarationNode * declaration ) { 140 140 // 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 ) { 142 142 iter->set_extension( true ); 143 143 } // for … … 146 146 void distInl( DeclarationNode * declaration ) { 147 147 // 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 ) { 149 149 iter->set_inLine( true ); 150 150 } // for … … 153 153 void distQual( DeclarationNode * declaration, DeclarationNode * qualifiers ) { 154 154 // 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 ) { 156 156 // SKULLDUGGERY: Distributions are parsed inside out, so qualifiers are added to declarations inside out. Since 157 157 // 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.