private Expression FixCaseLiteralValue(LiteralExpression literalCondition) { V_0 = this.theSwitch.get_Condition().get_ExpressionType(); V_1 = Convert.ToInt32(literalCondition.get_Value()) + this.conditionOffset; literalCondition.set_Value(V_1); V_2 = this.context.get_MethodContext().get_Method().get_Module().get_TypeSystem(); if (String.op_Equality(V_0.get_Name(), "System.Nullable`1") && V_0.get_HasGenericParameters()) { V_0 = V_0.get_GenericParameters().get_Item(0); } if (String.op_Equality(V_0.get_FullName(), V_2.get_Char().get_FullName())) { return(new LiteralExpression((object)Convert.ToChar(V_1), V_2, null)); } if (String.op_Equality(V_0.get_FullName(), V_2.get_Boolean().get_FullName())) { return(new LiteralExpression((object)Convert.ToBoolean(V_1), V_2, null)); } V_3 = V_0.Resolve(); if (V_3 == null || !V_3.get_IsEnum()) { return(literalCondition); } V_4 = EnumHelper.GetEnumExpression(V_3, literalCondition, V_2); if (V_4 as LiteralExpression != null) { V_4 = new ExplicitCastExpression(V_4, V_3, null); } return(V_4); }
private uint GetIndexFromLiteralExpression(LiteralExpression dimention) { V_0 = dimention.get_Value(); if (String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.Int32")) { stackVariable80 = (Int32)V_0; if (stackVariable80 < 0) { throw new IndexOutOfRangeException(); } return(stackVariable80); } if (String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.UInt32")) { return((UInt32)V_0); } if (String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.Int16")) { stackVariable74 = (Int16)V_0; if (stackVariable74 < 0) { throw new IndexOutOfRangeException(); } return(stackVariable74); } if (String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.UInt16")) { return((UInt16)V_0); } if (String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.Int8")) { stackVariable68 = (SByte)V_0; if (stackVariable68 < 0) { throw new IndexOutOfRangeException(); } return(stackVariable68); } if (String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.UInt8")) { return((Byte)V_0); } if (String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.Int64")) { V_1 = (Int64)V_0; if (V_1 < (long)0 || V_1 > (ulong)-1) { throw new IndexOutOfRangeException(); } return((uint)V_1); } if (!String.op_Equality(dimention.get_ExpressionType().get_FullName(), "System.UInt64")) { throw new IndexOutOfRangeException(); } V_2 = (UInt64)V_0; if (V_2 < (long)0 || V_2 > (ulong)-1) { throw new IndexOutOfRangeException(); } return((uint)V_2); }
public static Expression GetEnumExpression(TypeDefinition enumDefinition, LiteralExpression targetedValue, TypeSystem typeSystem) { V_0 = EnumHelper.GetEnumBitSize(enumDefinition); V_1 = (long)0; V_4 = targetedValue.get_Value().GetType().get_FullName(); if (V_4 != null) { if (String.op_Equality(V_4, "System.Int32")) { if (V_0 != 32) { V_1 = (long)((Int32)targetedValue.get_Value()); } else { V_1 = (ulong)((Int32)targetedValue.get_Value()); } } else { if (String.op_Equality(V_4, "System.Int64")) { V_1 = (Int64)targetedValue.get_Value(); } else { if (String.op_Equality(V_4, "System.UInt32")) { V_1 = (ulong)((UInt32)targetedValue.get_Value()); } else { if (String.op_Equality(V_4, "System.UInt64")) { V_1 = (UInt64)targetedValue.get_Value(); } else { if (String.op_Equality(V_4, "System.Byte")) { V_1 = (ulong)((Byte)targetedValue.get_Value()); } else { if (String.op_Equality(V_4, "System.SByte")) { V_1 = (long)((SByte)targetedValue.get_Value()); } else { if (String.op_Equality(V_4, "System.Int16")) { V_1 = (long)((Int16)targetedValue.get_Value()); } else { if (String.op_Equality(V_4, "System.UInt16")) { V_1 = (ulong)((UInt16)targetedValue.get_Value()); } } } } } } } } } stackVariable10 = enumDefinition.get_Fields(); V_2 = new List <FieldDefinition>(); V_6 = stackVariable10.GetEnumerator(); try { while (V_6.MoveNext()) { V_7 = V_6.get_Current(); if (V_7.get_Constant() == null || V_7.get_Constant().get_Value() == null) { continue; } V_8 = (long)0; V_4 = V_7.get_Constant().get_Value().GetType().get_FullName(); if (V_4 != null) { if (String.op_Equality(V_4, "System.Int32")) { V_8 = (ulong)((Int32)V_7.get_Constant().get_Value()); } else { if (String.op_Equality(V_4, "System.UInt32")) { V_8 = (ulong)((UInt32)V_7.get_Constant().get_Value()); } else { if (String.op_Equality(V_4, "System.Byte")) { V_8 = (ulong)((Byte)V_7.get_Constant().get_Value()); } else { if (String.op_Equality(V_4, "System.SByte")) { V_8 = (ulong)((byte)((SByte)V_7.get_Constant().get_Value())); } else { if (String.op_Equality(V_4, "System.Int16")) { V_8 = (ulong)((ushort)((Int16)V_7.get_Constant().get_Value())); } else { if (String.op_Equality(V_4, "System.UInt16")) { V_8 = (ulong)((UInt16)V_7.get_Constant().get_Value()); } else { if (String.op_Equality(V_4, "System.Int64")) { V_8 = (Int64)V_7.get_Constant().get_Value(); } else { if (String.op_Equality(V_4, "System.UInt64")) { V_8 = (UInt64)V_7.get_Constant().get_Value(); } } } } } } } } } if (V_8 != V_1) { if (V_8 == 0 || V_8 | V_1 != V_1) { continue; } V_2.Add(V_7); } else { V_9 = new EnumExpression(V_7, targetedValue.get_UnderlyingSameMethodInstructions()); goto Label1; } } goto Label0; } finally { V_6.Dispose(); } Label1: return(V_9); Label0: if (V_2.get_Count() < 2) { return(targetedValue); } V_3 = new BinaryExpression(21, new EnumExpression(V_2.get_Item(0), null), new EnumExpression(V_2.get_Item(1), null), typeSystem, null, false); V_3.set_ExpressionType(enumDefinition); V_10 = 2; while (V_10 < V_2.get_Count()) { V_3 = new BinaryExpression(21, V_3, new EnumExpression(V_2.get_Item(V_10), null), typeSystem, null, false); V_3.set_ExpressionType(enumDefinition); V_10 = V_10 + 1; } return(V_3.CloneAndAttachInstructions(targetedValue.get_UnderlyingSameMethodInstructions())); }
private void FixCharLiteral(LiteralExpression literal) { literal.set_Value(Convert.ToChar(literal.get_Value())); return; }
private void FixBooleanLiteral(LiteralExpression literal) { literal.set_Value(Convert.ToBoolean(literal.get_Value())); return; }