Ignore:
Timestamp:
Jul 8, 2015, 12:43:04 PM (4 years ago)
Author:
cameron
Message:

Bug fix for while loops

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4647 r4649  
    509509        PabloAST * m2 = pb.createOr(base, starAccum);
    510510        PabloAST * loopComputation = markerVar(AdvanceMarker(process(repeated, makeMarker(InitialPostPositionByte, m1), pb), InitialPostPositionByte, pb));
    511         Next * nextPending = pb.createNext(starPending, pb.createAnd(loopComputation, pb.createNot(m2)));
    512         Next * nextStarAccum = pb.createNext(starAccum, pb.createOr(loopComputation, m2));
     511        PabloAST * starPending_ = pb.createAnd(loopComputation, pb.createNot(m2));
     512        PabloAST * starAccum_ = pb.createOr(loopComputation, m2);
     513        mWhileTest = pb.createOr(mWhileTest, starPending_);
     514       
     515        Next * nextPending = pb.createNext(starPending, starPending_);
     516        Next * nextStarAccum = pb.createNext(starAccum, starAccum_);
    513517        mLoopVariants.push_back(nextPending);
    514518        mLoopVariants.push_back(nextStarAccum);
    515         mWhileTest = pb.createOr(mWhileTest, nextPending);
    516519        mStarDepth--;
    517520       
    518         return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", pb.createOr(base, nextStarAccum)));
     521        return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", pb.createOr(base, starAccum_)));
    519522    }   
    520523    else {
     
    528531
    529532        PabloAST * loopComputation = markerVar(AdvanceMarker(process(repeated, makeMarker(InitialPostPositionByte, whilePending), wb), InitialPostPositionByte, wb));
    530         Next * nextWhilePending = wb.createNext(whilePending, wb.createAnd(loopComputation, wb.createNot(whileAccum)));
    531         Next * nextWhileAccum = wb.createNext(whileAccum, wb.createOr(loopComputation, whileAccum));
    532         Next * nextWhileTest = wb.createNext(whileTest, wb.createOr(mWhileTest, nextWhilePending));
     533        PabloAST * whilePending_ = wb.createAnd(loopComputation, wb.createNot(whileAccum));
     534        PabloAST * whileAccum_ = wb.createOr(loopComputation, whileAccum);
     535        PabloAST * whileTest_ = wb.createOr(mWhileTest, whilePending_);
     536        Next * nextWhilePending = wb.createNext(whilePending, whilePending_);
     537        Next * nextWhileAccum = wb.createNext(whileAccum, whileAccum_);
     538        Next * nextWhileTest = wb.createNext(whileTest, whileTest_);
    533539        mLoopVariants.push_back(nextWhilePending);
    534540        mLoopVariants.push_back(nextWhileAccum);
    535541        mLoopVariants.push_back(nextWhileTest);
    536         pb.createWhile(whileTest, mLoopVariants, wb);
     542        pb.createWhile(whileTest_, mLoopVariants, wb);
    537543        mStarDepth--;
    538544        mLoopVariants.clear();
    539         return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", nextWhileAccum));
     545        return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", whileAccum_));
    540546    }   
    541547} // end of namespace re
Note: See TracChangeset for help on using the changeset viewer.