Пример #1
0
 private void EmbedIntoDefaultIf(GotoStatement jump)
 {
     V_0 = jump.get_Parent() as BlockStatement;
     V_1 = new BlockStatement();
     V_1.AddStatement(jump);
     V_2 = new IfStatement(this.GetLiteralExpression(true), V_1, null);
     V_1.set_Parent(V_2);
     V_3 = V_0.get_Statements().IndexOf(jump);
     V_0.get_Statements().RemoveAt(V_3);
     V_0.AddStatementAt(V_3, V_2);
     if (V_0.get_Parent() as ConditionCase != null && V_0.get_Statements().IndexOf(V_2) == V_0.get_Statements().get_Count())
     {
         V_0.AddStatement(new BreakStatement(null));
     }
     return;
 }
Пример #2
0
 private void MoveOut(IfStatement gotoStatement, string label)
 {
     V_0 = gotoStatement.get_Parent() as BlockStatement;
     V_1 = this.GetOuterBlock(V_0);
     V_2 = new VariableReferenceExpression(this.GetLabelVariable(label), null);
     this.ExtractConditionIntoVariable(V_2.CloneExpressionOnly() as VariableReferenceExpression, gotoStatement, V_0);
     V_3 = V_0.get_Parent();
     if (V_3 as SwitchCase != null)
     {
         V_3 = V_3.get_Parent();
     }
     if (V_0.get_Parent() as SwitchCase != null || V_0.get_Parent() as WhileStatement != null || V_0.get_Parent() as DoWhileStatement != null || V_0.get_Parent() as ForStatement != null || V_0.get_Parent() as ForEachStatement != null)
     {
         V_4 = new BlockStatement();
         V_4.AddStatement(new BreakStatement(null));
         V_5       = new IfStatement(V_2.CloneExpressionOnly(), V_4, null);
         V_6       = V_0.get_Statements().IndexOf(gotoStatement);
         dummyVar0 = V_0.get_Statements().Remove(gotoStatement);
         V_0.AddStatementAt(V_6, V_5);
     }
     else
     {
         if (V_0.get_Parent() as IfStatement == null && V_0.get_Parent() as TryStatement == null && V_0.get_Parent() as IfElseIfStatement == null)
         {
             throw new ArgumentOutOfRangeException("Goto statement can not leave this parent construct.");
         }
         V_7 = V_0.get_Statements().IndexOf(gotoStatement) + 1;
         V_8 = new BlockStatement();
         while (V_7 < V_0.get_Statements().get_Count())
         {
             V_8.AddStatement(V_0.get_Statements().get_Item(V_7));
             V_0.get_Statements().RemoveAt(V_7);
         }
         V_9       = new IfStatement(new UnaryExpression(1, V_2.CloneExpressionOnly(), null), V_8, null);
         dummyVar1 = V_0.get_Statements().Remove(gotoStatement);
         if (V_9.get_Then().get_Statements().get_Count() != 0)
         {
             V_0.AddStatement(V_9);
         }
     }
     V_1.AddStatementAt(V_1.get_Statements().IndexOf(V_3) + 1, gotoStatement);
     return;
 }