Пример #1
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     if (stmt.Loop == _loop)
     {
         Result = true;
     }
 }
Пример #2
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     if (stmt.Loop == _offScopeLoop)
     {
         if (_loopStack.Any())
         {
             stmt.Loop = _loopStack.Last();
         }
         else
         {
             stmt.EliminationPredicate = () => true;
         }
     }
 }
Пример #3
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     _execLeaf = stmt;
 }
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     IsEmpty = false;
 }
Пример #5
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Break(_loopMap[stmt.Loop]);
     LabelLastStmt(stmt);
 }
Пример #6
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Result = stmt;
 }
Пример #7
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     SingleResult(stmt.Successor);
 }
Пример #8
0
 /// <summary>
 /// Transforms a loop break statement. The default implementation places a new break loop
 /// statement inside the current loop.
 /// </summary>
 /// <param name="stmt">loop break statement</param>
 public virtual void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Break(_loopMap[stmt.Loop]);
     CopyAttributesToLastStatement(stmt);
     LabelLastStmt(stmt);
 }
Пример #9
0
        public void AcceptLoopBlock(LoopBlock stmt)
        {
            IfStatement cond = stmt.Body.AsSingleStatement() as IfStatement;

            if (cond == null)
            {
                return;
            }

            if (cond.Conditions.Count != 1 ||
                cond.Branches.Count != 2)
            {
                return;
            }

            IList <Statement> trueBranch = cond.Branches[0].AsStatementList();

            if (trueBranch.Count == 0 ||
                !trueBranch.Last().Equals(new ContinueLoopStatement()
            {
                Loop = stmt
            }))
            {
                return;
            }

            IList <Statement> falseBranch = cond.Branches[1].AsStatementList();

            if (falseBranch.Count == 0)
            {
                return;
            }

#if false
            BreakLoopStatement breaker = new BreakLoopStatement()
            {
                Loop = stmt
            };
            Statement trailer = cond.Branches[1].Clone;
            trailer.RemoveAll(breaker);
#endif

            Statement         trailer = cond.Branches[1].Clone;
            BreakLoopReplacer blr     = new BreakLoopReplacer(stmt);
            trailer.Accept(blr);

            if (trailer.NeedsLoopScope(stmt))
            {
                return;
            }
#if false
            CompoundStatement trailer = new CompoundStatement();
            trailer.Statements.AddRange(falseBranch.Take(falseBranch.Count - 1));
            if (trailer.NeedsLoopScope(stmt))
            {
                return;
            }

            BreakLoopStatement breaker = falseBranch.Last() as BreakLoopStatement;
            if (breaker == null)
            {
                return;
            }

            if (breaker.Loop.IsAncestor(stmt))
            {
                /* Consider the following situation:
                 *
                 * L1: loop
                 *   some outer loop work
                 *   L2: loop
                 *     if someCondition then
                 *       do something
                 *       continue L2
                 *     else
                 *       do something different
                 *       break L1
                 *     end if
                 *   end loop L2
                 * end loop L1
                 *
                 * As the inner break statement breaks the outer loop, this loop
                 * must be transformed into the following code:
                 *
                 * L1: loop
                 *   some outer loop work
                 *   while someCondition loop
                 *     do something
                 *   end while
                 *   do something different
                 *   break L1
                 * end loop
                 * */

                if (breaker.Loop != stmt)
                {
                    trailer.Statements.Add(breaker);
                }
            }
            else
            {
                return;
            }
#endif

            CompoundStatement newBody = new CompoundStatement();
            newBody.Statements.AddRange(trueBranch.Take(trueBranch.Count - 1));

            LoopBlock whileBlock = (LoopBlock)stmt.Clone;
            whileBlock.HeadCondition = cond.Conditions[0];
            whileBlock.Body          = newBody;
            whileBlock.Trailer       = trailer;

            Result = whileBlock;
        }
Пример #10
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     IsEmpty = false;
 }
Пример #11
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Break(_loopMap[stmt.Loop]);
     LabelLastStmt(stmt);
 }
Пример #12
0
        public void AcceptLoopBlock(LoopBlock stmt)
        {
            IfStatement cond = stmt.Body.AsSingleStatement() as IfStatement;
            if (cond == null)
                return;

            if (cond.Conditions.Count != 1 ||
                cond.Branches.Count != 2)
                return;

            IList<Statement> trueBranch = cond.Branches[0].AsStatementList();
            if (trueBranch.Count == 0 ||
                !trueBranch.Last().Equals(new ContinueLoopStatement() { Loop = stmt }))
                return;

            IList<Statement> falseBranch = cond.Branches[1].AsStatementList();
            if (falseBranch.Count == 0)
                return;

#if false
            BreakLoopStatement breaker = new BreakLoopStatement() { Loop = stmt };
            Statement trailer = cond.Branches[1].Clone;
            trailer.RemoveAll(breaker);
#endif

            Statement trailer = cond.Branches[1].Clone;
            BreakLoopReplacer blr = new BreakLoopReplacer(stmt);
            trailer.Accept(blr);

            if (trailer.NeedsLoopScope(stmt))
                return;
#if false
            CompoundStatement trailer = new CompoundStatement();
            trailer.Statements.AddRange(falseBranch.Take(falseBranch.Count - 1));
            if (trailer.NeedsLoopScope(stmt))
                return;

            BreakLoopStatement breaker = falseBranch.Last() as BreakLoopStatement;
            if (breaker == null)
                return;

            if (breaker.Loop.IsAncestor(stmt))
            {
                /* Consider the following situation:
                 * 
                 * L1: loop
                 *   some outer loop work
                 *   L2: loop
                 *     if someCondition then
                 *       do something
                 *       continue L2
                 *     else
                 *       do something different
                 *       break L1
                 *     end if
                 *   end loop L2
                 * end loop L1
                 * 
                 * As the inner break statement breaks the outer loop, this loop
                 * must be transformed into the following code:
                 * 
                 * L1: loop
                 *   some outer loop work
                 *   while someCondition loop
                 *     do something
                 *   end while
                 *   do something different
                 *   break L1
                 * end loop
                 * */

                if (breaker.Loop != stmt)
                {
                    trailer.Statements.Add(breaker);
                }
            }
            else
                return;
#endif

            CompoundStatement newBody = new CompoundStatement();
            newBody.Statements.AddRange(trueBranch.Take(trueBranch.Count - 1));

            LoopBlock whileBlock = (LoopBlock)stmt.Clone;
            whileBlock.HeadCondition = cond.Conditions[0];
            whileBlock.Body = newBody;
            whileBlock.Trailer = trailer;

            Result = whileBlock;
        }
Пример #13
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     if (stmt.Loop == _offScopeLoop)
     {
         if (_loopStack.Any())
         {
             stmt.Loop = _loopStack.Last();
         }
         else
         {
             stmt.EliminationPredicate = () => true;
         }
     }
 }
Пример #14
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     if (stmt.Loop == _loop)
         Result = true;
 }
Пример #15
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     CreateLabelForNextInstruction(stmt);
     Emit(ISet.Goto(CreateLabel(stmt.Loop.Successor)), stmt, CloseBB(), 0);
 }
Пример #16
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     SimpleResult(stmt);
 }
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     SingleResult(stmt.Successor);
 }
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     _result.Add(stmt);
 }
Пример #19
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
 }
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Result = stmt;
 }
Пример #21
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
 }
Пример #22
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     SimpleResult(stmt);
 }
Пример #23
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     _result.Add(stmt);
 }
Пример #24
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Check(stmt);
 }
Пример #25
0
 public void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Check(stmt);
 }
Пример #26
0
 /// <summary>
 /// Transforms a loop break statement. The default implementation places a new break loop
 /// statement inside the current loop.
 /// </summary>
 /// <param name="stmt">loop break statement</param>
 public virtual void AcceptBreakLoop(BreakLoopStatement stmt)
 {
     Break(_loopMap[stmt.Loop]);
     CopyAttributesToLastStatement(stmt);
     LabelLastStmt(stmt);
 }