Ignore:
Timestamp:
Sep 23, 2024, 11:14:56 AM (6 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
738a9b4
Parents:
b723b63
Message:

Added ForeachStmt? (felt better than ForEachStmt?). This new node is a bit optimistic in that currently it is covering a very narrow case, but with improvements to it and RangeExpr?, it could handle many more kind of loops.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cpp

    rb723b63 rfca78f1  
    213213        if ( forctl->range_over ) {
    214214                ast::Expr * range_over = maybeMoveBuild( forctl->range_over );
    215                 auto kind = forctl->kind;                                               // save before delete, used in return
     215                bool isIncreasing = forctl->kind == OperKinds::LEThan;
     216                // Copy all the data needed before the delete.
    216217                delete forctl;
    217                 return new ast::ForStmt( location,
     218                return new ast::ForeachStmt( location,
    218219                        std::move( astinit ),
    219                         range_over, kind == OperKinds::LEThan,
     220                        range_over,
     221                        isIncreasing ? ast::IncreasingRange : ast::DecreasingRange,
    220222                        buildMoveSingle( stmt ),
    221223                        buildMoveOptional( else_ )
Note: See TracChangeset for help on using the changeset viewer.