private void AddCastIfNeeded(Expression useExpression, VariableReference variable) { V_0 = new TypeInferer.u003cu003ec__DisplayClass8_0(); V_0.variable = variable; V_4 = useExpression.get_CodeNodeType(); if (V_4 == 19) { V_1 = useExpression as MethodInvocationExpression; V_2 = V_1.get_Arguments().FirstOrDefault <Expression>(new Func <Expression, bool>(V_0.u003cAddCastIfNeededu003eb__0)); if (V_2 == null) { V_7 = V_1.get_MethodExpression().get_Target(); if (V_7.get_CodeNodeType() != 26 || (object)(V_7 as VariableReferenceExpression).get_Variable() != (object)V_0.variable) { this.AddCastIfNeeded(V_7, V_0.variable); return; } V_8 = V_1.get_MethodExpression().get_Method().get_DeclaringType(); if (!this.IsSubtype(V_8, V_0.variable.get_VariableType())) { V_1.get_MethodExpression().set_Target(new ExplicitCastExpression(V_7, V_8, null)); return; } } else { V_5 = V_1.get_Arguments().IndexOf(V_2); V_6 = V_1.get_MethodExpression().get_Method().get_Parameters().get_Item(V_5).ResolveParameterType(V_1.get_MethodExpression().get_Method()); if (!this.IsSubtype(V_6, V_0.variable.get_VariableType())) { if (V_6.get_IsPrimitive() && V_0.variable.get_VariableType().get_IsPrimitive() && String.op_Equality(ExpressionTypeInferer.GetContainingType(V_6.Resolve(), V_0.variable.get_VariableType().Resolve()).get_FullName(), V_6.get_FullName())) { return; } V_1.get_Arguments().set_Item(V_5, new ExplicitCastExpression(V_2, V_6, null)); return; } } } else { if (V_4 != 24) { return; } V_3 = useExpression as BinaryExpression; if (V_3.get_Operator() == 26 && V_3.get_Right().get_CodeNodeType() == 26 && (object)(V_3.get_Right() as VariableReferenceExpression).get_Variable() == (object)V_0.variable) { V_9 = V_3.get_Left().get_ExpressionType(); if (!this.IsSubtype(V_9, V_0.variable.get_VariableType())) { V_3.set_Right(new ExplicitCastExpression(V_3.get_Right(), V_9, null)); } } } return; }
public override void VisitBinaryExpression(BinaryExpression node) { V_0 = this.GetExpressionTypeName(node.get_Left()); V_1 = this.GetExpressionTypeName(node.get_Right()); this.VisitBinaryExpression(node); if (String.op_Inequality(this.GetExpressionTypeName(node.get_Left()), V_0)) { stackVariable16 = true; } else { stackVariable16 = String.op_Inequality(this.GetExpressionTypeName(node.get_Right()), V_1); } V_2 = stackVariable16; if (node.get_IsAssignmentExpression() || node.get_IsSelfAssign() && !node.get_IsEventHandlerAddOrRemove()) { V_3 = node.get_Left(); V_4 = node.get_Right(); if (V_4.get_HasType() && V_3.get_HasType()) { V_5 = V_3.get_ExpressionType(); V_6 = V_4.get_ExpressionType().Resolve(); if (this.ShouldAddCast(V_6, V_5)) { node.set_Right(new ExplicitCastExpression(V_4, V_5, null)); V_2 = true; } V_7 = V_5.Resolve(); if (V_7 != null && V_6 != null && V_7.get_IsEnum() && V_6.get_IsValueType() && String.op_Inequality(V_7.get_FullName(), V_6.get_FullName())) { node.set_Right(new ExplicitCastExpression(V_4, V_5, null)); V_2 = true; } } } else { if (!this.IsArithmeticOperator(node.get_Operator())) { if (this.IsBitwiseOperator(node.get_Operator()) || node.get_IsComparisonExpression()) { V_10 = node.get_Left(); V_11 = node.get_Right(); if (V_11.get_HasType() && V_10.get_HasType()) { V_12 = V_10.get_ExpressionType(); V_13 = V_11.get_ExpressionType().Resolve(); if (this.ShouldAddCast(V_13, V_12)) { node.set_Right(new ExplicitCastExpression(V_11, V_12, null)); V_2 = true; } V_14 = V_11.get_ExpressionType(); V_15 = V_10.get_ExpressionType().Resolve(); if (this.ShouldAddCast(V_15, V_14)) { node.set_Left(new ExplicitCastExpression(V_10, V_14, null)); V_2 = true; } if (V_15 != null && V_15.get_IsEnum() && V_13 != null && V_13.get_IsEnum() && String.op_Inequality(V_15.get_FullName(), V_13.get_FullName())) { node.set_Left(new ExplicitCastExpression(V_10, this.GetEnumUnderlyingType(V_15), null)); node.set_Right(new ExplicitCastExpression(V_11, this.GetEnumUnderlyingType(V_15), null)); V_2 = true; } } } else { if (this.IsShiftOperator(node.get_Operator())) { if (node.get_Left().get_HasType()) { V_16 = node.get_Left().get_ExpressionType().Resolve(); if (V_16 != null && V_16.get_IsEnum()) { node.set_Left(new ExplicitCastExpression(node.get_Left(), this.GetEnumUnderlyingType(V_16), null)); V_2 = true; } } if (node.get_Right().get_HasType()) { V_17 = node.get_Right().get_ExpressionType().Resolve(); if (V_17 != null && V_17.get_IsEnum()) { node.set_Right(new ExplicitCastExpression(node.get_Right(), this.GetEnumUnderlyingType(V_17), null)); V_2 = true; } } } } } else { if (node.get_Left().get_HasType()) { V_8 = node.get_Left().get_ExpressionType().Resolve(); if (V_8 != null && V_8.get_IsEnum()) { node.set_Left(new ExplicitCastExpression(node.get_Left(), this.GetEnumUnderlyingType(V_8), null)); V_2 = true; } } if (node.get_Right().get_HasType()) { V_9 = node.get_Right().get_ExpressionType().Resolve(); if (V_9 != null && V_9.get_IsEnum()) { node.set_Right(new ExplicitCastExpression(node.get_Right(), this.GetEnumUnderlyingType(V_9), null)); V_2 = true; } } } } if (V_2) { node.UpdateType(); } return; }
protected void DecompileConstructorChain(MethodDefinition method, ILanguage language, DecompiledType decompiledType) { if (this.cacheService.IsDecompiledMemberInCache(method, language, this.renameInvalidMembers)) { V_3 = this.cacheService.GetDecompiledMemberFromCache(method, language, this.renameInvalidMembers); this.AddDecompiledMemberToDecompiledType(V_3, decompiledType); BaseWriterContextService.AddAssignmentDataToDecompiledType(V_3, decompiledType); return; } if (method.get_Body() == null) { V_4 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null)); this.cacheService.AddDecompiledMemberToCache(method, language, this.renameInvalidMembers, V_4); return; } V_0 = this.DecompileMethod(language, method, decompiledType.get_TypeContext().ShallowPartialClone()); V_1 = new List <CachedDecompiledMember>(); V_2 = method.get_DeclaringType(); if (!method.get_IsStatic()) { V_5 = V_2.get_Methods().GetEnumerator(); try { while (V_5.MoveNext()) { V_6 = V_5.get_Current(); if (!V_6.get_IsConstructor() || String.op_Equality(V_6.get_FullName(), V_0.get_Member().get_MemberFullName()) || V_6.get_IsStatic()) { continue; } if (V_6.get_Body() != null) { V_1.Add(this.DecompileMethod(language, V_6, decompiledType.get_TypeContext().ShallowPartialClone())); } else { V_7 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(V_6), null, null)); V_1.Add(V_7); } } } finally { V_5.Dispose(); } V_1.Add(V_0); this.MergeConstructorsTypeContexts(V_1, decompiledType); V_8 = V_1.GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = new BaseWriterContextService.u003cu003ec__DisplayClass15_0(); V_9.constructor = V_8.get_Current(); if (language as IntermediateLanguage == null) { this.RemoveBaseCtorInvocationStatements(V_9.constructor, decompiledType); } if (V_9.constructor.get_Member().get_Context() != null) { if (!this.cacheService.IsDecompiledMemberInCache(V_9.constructor.get_Member().get_Context().get_Method(), language, this.renameInvalidMembers)) { this.cacheService.AddDecompiledMemberToCache(V_9.constructor.get_Member().get_Context().get_Method(), language, this.renameInvalidMembers, V_9.constructor); } } else { V_10 = decompiledType.get_Type().get_Methods().First <MethodDefinition>(new Func <MethodDefinition, bool>(V_9.u003cDecompileConstructorChainu003eb__0)); if (!this.cacheService.IsDecompiledMemberInCache(V_10, language, this.renameInvalidMembers)) { this.cacheService.AddDecompiledMemberToCache(V_10, language, this.renameInvalidMembers, V_9.constructor); } } this.AddDecompiledMemberToDecompiledType(V_9.constructor, decompiledType); } } finally { ((IDisposable)V_8).Dispose(); } } return; }