示例#1
0
 private CompilerOptimizedSwitchByStringStatement ComposeSwitch(CreateCompilerOptimizedSwitchByStringStatementsStep.SwitchData data)
 {
     V_0 = new CompilerOptimizedSwitchByStringStatement(data.get_SwitchExpression(), data.get_SwitchExpressionLoadInstructions());
     V_1 = data.get_CaseConditionToBlockMap().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_2 = V_1.get_Current();
             if (V_2.get_Value() != null && SwitchHelpers.BlockHasFallThroughSemantics(V_2.get_Value()))
             {
                 V_2.get_Value().AddStatement(new BreakSwitchCaseStatement());
             }
             V_0.AddCase(new ConditionCase(V_2.get_Key(), V_2.get_Value()));
         }
     }
     finally
     {
         ((IDisposable)V_1).Dispose();
     }
     if (data.get_HaveDefaultCase())
     {
         if (SwitchHelpers.BlockHasFallThroughSemantics(data.get_DefaultCase()))
         {
             data.get_DefaultCase().AddStatement(new BreakSwitchCaseStatement());
         }
         V_0.AddCase(new DefaultCase(data.get_DefaultCase()));
     }
     return(V_0);
 }
示例#2
0
 private bool TryMatchCondition(Expression condition, BlockStatement block, CreateCompilerOptimizedSwitchByStringStatementsStep.SwitchData data)
 {
     if (condition.get_CodeNodeType() != 23 && condition.get_CodeNodeType() != 24)
     {
         return(false);
     }
     if (condition.get_CodeNodeType() != 24)
     {
         V_5 = condition as UnaryExpression;
         if (V_5.get_Operator() != 11 || V_5.get_Operand().get_CodeNodeType() != 24)
         {
             return(false);
         }
         V_0 = V_5.get_Operand() as BinaryExpression;
     }
     else
     {
         V_0 = condition as BinaryExpression;
         if (V_0.get_Operator() == 11)
         {
             if (!this.TryMatchCondition(V_0.get_Left(), null, data) || !this.TryMatchCondition(V_0.get_Right(), null, data))
             {
                 return(false);
             }
             if (block != null)
             {
                 V_2 = data.get_CaseConditionToBlockMap().get_Count() - 1;
                 V_4 = data.get_CaseConditionToBlockMap().get_Item(V_2);
                 V_3 = V_4.get_Key();
                 data.get_CaseConditionToBlockMap().set_Item(V_2, new KeyValuePair <Expression, BlockStatement>(V_3, block));
             }
             return(true);
         }
     }
     if (V_0.get_Right().get_CodeNodeType() != 22 || V_0.get_Operator() != 9)
     {
         return(false);
     }
     V_1 = V_0.get_Right() as LiteralExpression;
     if (condition.get_CodeNodeType() == 23 && String.op_Inequality(V_1.get_ExpressionType().get_FullName(), "System.String"))
     {
         return(false);
     }
     if (condition.get_CodeNodeType() == 24 && String.op_Inequality(V_1.get_ExpressionType().get_FullName(), "System.Object") || V_1.get_Value() != null)
     {
         return(false);
     }
     if (data.get_SwitchExpression() != null)
     {
         if (!data.get_SwitchExpression().Equals(V_0.get_Left()))
         {
             return(false);
         }
         data.get_SwitchExpressionLoadInstructions().Add(V_0.get_Left().get_UnderlyingSameMethodInstructions().First <Instruction>().get_Offset());
     }
     else
     {
         data.set_SwitchExpression(V_0.get_Left());
     }
     data.get_CaseConditionToBlockMap().Add(new KeyValuePair <Expression, BlockStatement>(V_1, block));
     return(true);
 }