public override ICodeNode VisitReturnExpression(ReturnExpression node) { node = (ReturnExpression)this.VisitReturnExpression(node); V_0 = this.context.get_MethodContext().get_Method().get_ReturnType().Resolve(); if (V_0 == null) { return(node); } if (node.get_Value() == null) { return(node); } if (V_0.get_IsEnum() && !this.context.get_MethodContext().get_Method().get_ReturnType().get_IsArray() && node.get_Value().get_ExpressionType() == null || String.op_Inequality(node.get_Value().get_ExpressionType().get_FullName(), V_0.get_FullName())) { if (node.get_Value() as LiteralExpression == null) { if (node.get_Value() as ExplicitCastExpression == null || (node.get_Value() as ExplicitCastExpression).get_Expression() as LiteralExpression == null) { if (node.get_Value().get_HasType() && this.NeedsCast(node.get_Value().get_ExpressionType(), V_0)) { node.set_Value(new ExplicitCastExpression(node.get_Value(), V_0, null)); } } else { node.set_Value(EnumHelper.GetEnumExpression(V_0, (node.get_Value() as ExplicitCastExpression).get_Expression() as LiteralExpression, this.typeSystem)); } } else { node.set_Value(EnumHelper.GetEnumExpression(V_0, node.get_Value() as LiteralExpression, this.typeSystem)); } } return(node); }
internal void RemoveBlockAt(int index) { V_0 = this.get_Blocks()[index]; V_1 = V_0.get_Last().get_Next(); if (V_0.get_Predecessors().get_Count() > 0) { throw new Exception("The block to be removed cannot have predecessors"); } V_2 = this.get_Blocks(); this.set_Blocks(new InstructionBlock[(int)this.get_Blocks().Length - 1]); V_3 = 0; while (V_3 < (int)this.get_Blocks().Length) { if (V_3 >= index) { stackVariable29 = 1; } else { stackVariable29 = 0; } V_4 = stackVariable29; this.get_Blocks()[V_3] = V_2[V_3 + V_4]; this.get_Blocks()[V_3].set_Index(V_3); dummyVar0 = this.get_Blocks()[V_3].get_Predecessors().Remove(V_0); if ((object)this.get_Blocks()[V_3].get_First().get_Previous() == (object)V_0.get_Last()) { this.get_Blocks()[V_3].get_First().set_Previous(V_0.get_First().get_Previous()); } if ((object)this.get_Blocks()[V_3].get_Last().get_Next() == (object)V_0.get_First()) { this.get_Blocks()[V_3].get_Last().set_Next(V_0.get_Last().get_Next()); } V_3 = V_3 + 1; } dummyVar1 = this.get_InstructionToBlockMapping().Remove(V_0.get_First().get_Offset()); dummyVar2 = this.get_SwitchBlocksInformation().Remove(V_0); V_0.set_Successors(new InstructionBlock[0]); V_5 = V_0.GetEnumerator(); try { while (V_5.MoveNext()) { V_6 = V_5.get_Current(); dummyVar3 = this.get_OffsetToInstruction().Remove(V_6.get_Offset()); } } finally { if (V_5 != null) { V_5.Dispose(); } } V_7 = this.get_MethodBody().get_ExceptionHandlers().GetEnumerator(); try { while (V_7.MoveNext()) { V_8 = V_7.get_Current(); if ((object)V_8.get_TryStart() == (object)V_0.get_First()) { V_8.set_TryStart(V_1); } if ((object)V_8.get_TryEnd() == (object)V_0.get_First()) { V_8.set_TryEnd(V_1); } if ((object)V_8.get_HandlerStart() == (object)V_0.get_First()) { V_8.set_HandlerStart(V_1); } if ((object)V_8.get_HandlerEnd() == (object)V_0.get_First()) { V_8.set_HandlerEnd(V_1); } if ((object)V_8.get_FilterStart() == (object)V_0.get_First()) { V_8.set_FilterStart(V_1); } if ((object)V_8.get_FilterEnd() != (object)V_0.get_First()) { continue; } V_8.set_FilterEnd(V_1); } } finally { V_7.Dispose(); } V_0.set_Index(-1); return; }
public static bool AreEqual(TypeReference firstType, TypeReference secondType) { if (String.op_Equality(firstType.GetFriendlyFullName(null), secondType.GetFriendlyFullName(null))) { return(true); } V_0 = firstType.GetElementType(); V_1 = secondType.GetElementType(); if (V_0.get_HasGenericParameters() && V_1.get_HasGenericParameters() && String.op_Equality(V_0.get_FullName(), V_1.get_FullName()) && V_0.get_GenericParameters().get_Count() == V_1.get_GenericParameters().get_Count()) { return(true); } return(false); }
public override void VisitBinaryExpression(BinaryExpression node) { this.VisitBinaryExpression(node); if (node.get_Operator() == 26 && node.get_Right().get_CodeNodeType() == 38) { V_0 = node.get_Right() as ArrayCreationExpression; V_1 = Utilities.IsInitializerPresent(V_0.get_Initializer()); if (node.get_Left().get_CodeNodeType() == 27) { V_2 = node.get_Left() as VariableDeclarationExpression; node.set_Left(new ArrayVariableDeclarationExpression(V_2, V_0.get_ElementType(), V_0.get_Dimensions().CloneExpressionsOnly(), V_1, null)); } if (node.get_Left().get_CodeNodeType() == 26) { V_3 = node.get_Left() as VariableReferenceExpression; node.set_Left(new ArrayVariableReferenceExpression(V_3, V_0.get_ElementType(), V_0.get_Dimensions().CloneExpressionsOnly(), V_1, null)); } if (node.get_Left().get_CodeNodeType() == 30) { V_4 = node.get_Left() as FieldReferenceExpression; node.set_Left(new ArrayAssignmentFieldReferenceExpression(V_4, V_0.get_ElementType(), V_0.get_Dimensions().CloneExpressionsOnly(), V_1, null)); } } return; }
public static KeyValuePair <CFGBlockLogicalConstruct, CFGBlockLogicalConstruct> SplitCFGBlockAt(LogicalFlowBuilderContext logicalContext, CFGBlockLogicalConstruct cfgBlock, int expressionIndex) { V_0 = cfgBlock.get_LogicalConstructExpressions(); if (V_0 == null) { throw new ArgumentNullException("blockExpressions"); } if (expressionIndex <= 0 || expressionIndex >= V_0.get_Count()) { throw new ArgumentOutOfRangeException("expressionIndex"); } V_1 = logicalContext.get_CFGBlockToLogicalConstructMap().get_Item(cfgBlock.get_TheBlock()); V_2 = (int)V_1.Length; V_3 = 0; while (V_3 < V_2 && cfgBlock != V_1[V_3]) { V_3 = V_3 + 1; } if (V_3 == V_2) { throw new ArgumentException("cfgBlock"); } V_4 = cfgBlock.get_LogicalConstructExpressions().GetRange(0, expressionIndex); V_5 = new PartialCFGBlockLogicalConstruct(cfgBlock, V_4); V_5.RedirectPredecessors(); V_6 = cfgBlock.get_LogicalConstructExpressions().GetRange(expressionIndex, V_0.get_Count() - expressionIndex); V_7 = new PartialCFGBlockLogicalConstruct(cfgBlock, V_6); V_7.RedirectSuccessors(); V_5.AddToSuccessors(V_7); V_7.AddToPredecessors(V_5); V_8 = new CFGBlockLogicalConstruct[V_2 + 1]; V_9 = 0; V_10 = 0; while (V_9 < V_2) { if (V_9 == V_3) { V_8[V_10] = V_5; stackVariable68 = V_10 + 1; V_10 = stackVariable68; V_8[stackVariable68] = V_7; } else { V_8[V_10] = V_1[V_9]; } V_9 = V_9 + 1; V_10 = V_10 + 1; } logicalContext.get_CFGBlockToLogicalConstructMap().set_Item(cfgBlock.get_TheBlock(), V_8); return(new KeyValuePair <CFGBlockLogicalConstruct, CFGBlockLogicalConstruct>(V_5, V_7)); }
private LinqQueryExpression ProcessExtensionMethodChain(IEnumerable <MethodInvocationExpression> methodInvocations, MethodInvocationExpression topInvoke, bool queryable) { this.currentIdentifier = null; this.clauses.Clear(); V_0 = methodInvocations.GetEnumerator(); try { while (true) { if (V_0.MoveNext()) { V_1 = V_0.get_Current(); V_2 = true; V_3 = V_1.get_MethodExpression().get_MethodDefinition().get_Name(); if (V_3 == null) { break; } if (String.op_Equality(V_3, "Select")) { V_2 = this.TryProcessSelectMethod(V_1, queryable); } else { if (String.op_Equality(V_3, "SelectMany")) { V_2 = this.TryProcessSelectManyMethod(V_1, queryable); } else { if (String.op_Equality(V_3, "Where")) { V_2 = this.TryProcessWhereMethod(V_1, queryable); } else { if (String.op_Equality(V_3, "OrderBy")) { V_2 = this.TryProcessOrderByMethod(V_1, true, queryable); } else { if (String.op_Equality(V_3, "OrderByDescending")) { V_2 = this.TryProcessOrderByMethod(V_1, false, queryable); } else { if (String.op_Equality(V_3, "ThenBy")) { V_2 = this.TryProcessThenByMethod(V_1, true, queryable); } else { if (String.op_Equality(V_3, "ThenByDescending")) { V_2 = this.TryProcessThenByMethod(V_1, false, queryable); } else { if (String.op_Equality(V_3, "Join")) { V_2 = this.TryProcessJoinMethod(V_1, false, queryable); } else { if (String.op_Equality(V_3, "GroupJoin")) { V_2 = this.TryProcessJoinMethod(V_1, true, queryable); } else { if (!String.op_Equality(V_3, "GroupBy")) { break; } V_2 = this.TryProcessGroupByMethod(V_1, queryable); } } } } } } } } } if (!V_2) { V_5 = null; goto Label1; } } else { goto Label0; } } V_5 = null; } finally { if (V_0 != null) { V_0.Dispose(); } } Label1: return(V_5); Label0: if (this.clauses.get_Count() == 0) { return(null); } if (this.currentIdentifier != null) { this.clauses.Add(new SelectClause(new VariableReferenceExpression(this.currentIdentifier, null), null)); } return(new LinqQueryExpression(new List <QueryClause>(this.clauses), topInvoke.get_ExpressionType(), null)); }
private bool TryProcessGroupByMethod(MethodInvocationExpression methodInvoke, bool queryable) { V_0 = methodInvoke.get_MethodExpression().get_MethodDefinition(); if (V_0.get_Parameters().get_Count() > 3 || V_0.get_Parameters().get_Count() != V_0.get_GenericParameters().get_Count() || V_0.get_GenericParameters().get_Count() == 3 && String.op_Inequality(V_0.get_GenericParameters().get_Item(2).get_Name(), "TElement")) { return(false); } V_1 = this.GetLambdaExpression(methodInvoke.get_Arguments().get_Item(1), queryable); if (V_1 == null || V_1.get_Arguments().get_Count() != 1) { return(false); } this.ProcessCurrentIdentifier(methodInvoke.get_Arguments().get_Item(0), V_1.get_Parameters()[0].Resolve()); stackVariable44 = new VariableReference[1]; stackVariable44[0] = this.currentIdentifier; V_2 = this.ProcessReturnExpression(V_1, stackVariable44); if (V_2 == null) { return(false); } if (methodInvoke.get_Arguments().get_Count() != 3) { V_3 = new VariableReferenceExpression(this.currentIdentifier, null); } else { V_4 = this.GetLambdaExpression(methodInvoke.get_Arguments().get_Item(2), queryable); if (V_4 == null || V_4.get_Arguments().get_Count() != 1) { return(false); } stackVariable84 = new VariableReference[1]; stackVariable84[0] = this.currentIdentifier; V_3 = this.ProcessReturnExpression(V_4, stackVariable84); if (V_3 == null) { return(false); } } this.clauses.Add(new GroupClause(V_3, V_2, methodInvoke.get_InvocationInstructions())); this.currentIdentifier = null; return(true); }
public override ICodeNode VisitPropertyReferenceExpression(PropertyReferenceExpression node) { V_0 = node.get_MethodExpression(); if (V_0.get_Target() == null || V_0.get_Target().get_CodeNodeType() != 26 || !this.asyncData.get_AwaiterVariables().Contains((V_0.get_Target() as VariableReferenceExpression).get_Variable())) { return(this.VisitPropertyReferenceExpression(node)); } V_1 = (V_0.get_Target() as VariableReferenceExpression).get_Variable(); if ((object)this.currentAwaiterVariable == (object)V_1 && String.op_Equality(V_0.get_Method().get_Name(), "get_IsCompleted") && this.matcherState == 1) { this.matcherState = 6; return(null); } this.matcherState = 8; return(node); }
private bool IsGetCurrent(Expression expression) { V_0 = expression as MethodInvocationExpression; if (V_0 == null) { V_1 = expression as PropertyReferenceExpression; if (V_1 == null) { return(false); } return(String.op_Equality(V_1.get_Property().get_Name(), "Current")); } if (V_0.get_MethodExpression().get_Target() as VariableReferenceExpression == null || String.op_Inequality(V_0.get_MethodExpression().get_Method().get_Name(), "get_Current")) { return(false); } if ((object)(V_0.get_MethodExpression().get_Target() as VariableReferenceExpression).get_Variable() != (object)this.theEnumerator) { return(false); } return(true); }
private bool GetBuilderField() { stackVariable2 = this.GetStateMachineMethod("SetStateMachine"); if (stackVariable2 == null) { dummyVar0 = stackVariable2; stackVariable2 = this.GetStateMachineMethod("System.Runtime.CompilerServices.IAsyncStateMachine.SetStateMachine"); } V_0 = stackVariable2; if (V_0 == null || V_0.get_Body() == null) { return(false); } if (V_0.get_Body().get_Instructions().get_Count() <= 1) { V_5 = this.stateMachineTypeDef.get_Fields().GetEnumerator(); try { while (V_5.MoveNext()) { V_6 = V_5.get_Current(); if (!String.op_Equality(V_6.get_FieldType().get_Name(), "AsyncVoidMethodBuilder") && !String.op_Equality(V_6.get_FieldType().get_Name(), "AsyncTaskMethodBuilder") && !String.op_Equality(V_6.get_FieldType().get_Name(), "AsyncTaskMethodBuilder`1")) { continue; } this.builderField = V_6; V_4 = true; goto Label1; } goto Label0; } finally { V_5.Dispose(); } } else { V_1 = V_0.get_Body().get_Instructions().GetEnumerator(); try { while (V_1.MoveNext()) { V_2 = V_1.get_Current(); if (V_2.get_OpCode().get_Code() != 121) { continue; } this.builderField = ((FieldReference)V_2.get_Operand()).Resolve(); V_4 = true; goto Label1; } goto Label0; } finally { V_1.Dispose(); } } Label1: return(V_4); Label0: return(false); }
public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node) { V_0 = node.get_MethodExpression(); if (V_0.get_Target() != null) { if (V_0.get_Target().get_CodeNodeType() == 26 && this.asyncData.get_AwaiterVariables().Contains((V_0.get_Target() as VariableReferenceExpression).get_Variable())) { V_1 = (V_0.get_Target() as VariableReferenceExpression).get_Variable(); if ((object)this.currentAwaiterVariable == (object)V_1) { if (!String.op_Equality(V_0.get_Method().get_Name(), "get_IsCompleted")) { if (String.op_Equality(V_0.get_Method().get_Name(), "GetResult") && this.matcherState & 2 == 2) { this.matcherState = this.matcherState ^ 2; return(new AwaitExpression((Expression)this.Visit(this.awaitedExpression), V_0.get_Method().get_ReturnType(), node.get_UnderlyingSameMethodInstructions())); } } else { if (this.matcherState == 1) { this.matcherState = 6; return(null); } } } this.matcherState = 8; return(node); } if (V_0.get_Target().get_CodeNodeType() == 30 && (object)(V_0.get_Target() as FieldReferenceExpression).get_Field().Resolve() == (object)this.builderField && String.op_Equality(V_0.get_Method().get_Name(), "SetResult")) { if (node.get_Arguments().get_Count() > 0) { stackVariable34 = node.get_Arguments().get_Item(0); } else { stackVariable34 = null; } return(new ReturnExpression(stackVariable34, V_0.get_UnderlyingSameMethodInstructions())); } } return(this.VisitMethodInvocationExpression(node)); }
private YieldStateMachineControlFlowRebuilder.NextStateNumberSearchResult TryGetNextStateNumber(InstructionBlock theBlock, out int newStateNumber) { V_0 = theBlock.get_Last(); while ((object)V_0 != (object)theBlock.get_First()) { if (V_0.get_OpCode().get_Code() == 122 && (object)this.stateField == (object)((FieldReference)V_0.get_Operand()).Resolve()) { V_0 = V_0.get_Previous(); if (!StateMachineUtilities.TryGetOperandOfLdc(V_0, out newStateNumber)) { return(0); } V_0 = V_0.get_Previous().get_Previous(); if (V_0.get_OpCode().get_Code() == 122 && this.CheckAndSaveCurrentItemField((FieldReference)V_0.get_Operand())) { return(1); } return(0); } V_0 = V_0.get_Previous(); } newStateNumber = 0; return(2); }
private bool MarkTrueReturningPredecessorsAsYieldReturn(InstructionBlock theBlock) { V_0 = (new HashSet <InstructionBlock>(theBlock.get_Predecessors())).GetEnumerator(); try { while (V_0.MoveNext()) { V_1 = V_0.get_Current(); if ((object)V_1.get_Last() != (object)V_1.get_First()) { V_2 = null; V_3 = V_1.get_Last(); if (StateMachineUtilities.IsUnconditionalBranch(V_3)) { V_3 = V_3.get_Previous(); } if (!this.IsFinallyMethodInvocationBlock(V_1)) { if (!this.TryGetVariableFromInstruction(V_3, out V_2) || !this.CheckAndSaveReturnFlagVariable(V_2) || !StateMachineUtilities.TryGetOperandOfLdc(V_3.get_Previous(), out V_4)) { V_5 = false; goto Label1; } else { if (V_4 != 1) { if (V_4 == 0) { continue; } V_5 = false; goto Label1; } else { if (this.TryAddToYieldReturningBlocks(V_1)) { continue; } V_5 = false; goto Label1; } } } else { if (this.MarkTrueReturningPredecessorsAsYieldReturn(V_1)) { continue; } V_5 = false; goto Label1; } } else { if (!StateMachineUtilities.IsUnconditionalBranch(V_1.get_Last())) { V_5 = false; goto Label1; } else { dummyVar0 = this.toBeRemoved.Add(V_1); if (this.MarkTrueReturningPredecessorsAsYieldReturn(V_1)) { continue; } V_5 = false; goto Label1; } } } goto Label0; } finally { ((IDisposable)V_0).Dispose(); } Label1: return(V_5); Label0: return(true); }
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; }
protected override TypeSpecificContext GetTypeContext(TypeDefinition type, ILanguage language, Dictionary <string, DecompiledType> decompiledTypes) { V_0 = this.GetTypeContext(type, language, decompiledTypes); if (!V_0.get_IsWinRTImplementation() && V_0.get_CurrentType().get_IsNotPublic() && V_0.get_CurrentType().get_IsSealed() && V_0.get_CurrentType().get_Name().StartsWith("<CLR>")) { V_0.set_IsWinRTImplementation(true); } return(V_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); }
private Expression GetIdentifierReference(VariableReference identifierReference, ref Expression target) { V_0 = target as MethodInvocationExpression; if (V_0 == null || V_0.get_MethodExpression().get_MethodDefinition() == null || !V_0.get_MethodExpression().get_MethodDefinition().get_IsStatic() || !String.op_Equality(V_0.get_MethodExpression().get_MethodDefinition().get_DeclaringType().get_FullName(), "System.Linq.Enumerable") && !String.op_Equality(V_0.get_MethodExpression().get_MethodDefinition().get_DeclaringType().get_FullName(), "System.Linq.Queryable") || !String.op_Equality(V_0.get_MethodExpression().get_Method().get_Name(), "Cast")) { return(new VariableReferenceExpression(identifierReference, null)); } target = V_0.get_Arguments().get_Item(0); dummyVar0 = this.methodContext.get_UndeclaredLinqVariables().Remove(identifierReference.Resolve()); return(new VariableDeclarationExpression(identifierReference.Resolve(), null)); }
private Expression AddAssignmentCastIfNeeded(Expression expr) { V_0 = this.context.get_MethodContext().get_Method().get_Module().get_TypeSystem(); if (expr as BinaryExpression != null && (expr as BinaryExpression).get_IsAssignmentExpression()) { V_1 = expr as BinaryExpression; if ((object)V_1.get_Left().get_ExpressionType() != (object)V_1.get_Right().get_ExpressionType() && V_1.get_Left().get_ExpressionType().get_IsPrimitive() && V_1.get_Right().get_ExpressionType().get_IsPrimitive() && !this.IsSubtype(V_1.get_Right().get_ExpressionType(), V_1.get_Left().get_ExpressionType()) && V_1.get_Right().get_CodeNodeType() != 22) { if (V_1.get_Right().get_CodeNodeType() == 31 && String.op_Equality(V_1.get_Right().get_ExpressionType().get_FullName(), V_0.get_UInt16().get_FullName()) && String.op_Equality(V_1.get_Left().get_ExpressionType().get_FullName(), V_0.get_Char().get_FullName())) { ((ExplicitCastExpression)V_1.get_Right()).set_TargetType(V_0.get_Char()); return(expr); } V_1.set_Right(new ExplicitCastExpression(V_1.get_Right(), V_1.get_Left().get_ExpressionType(), null)); } } return(expr); }
private LinqQueryExpression RemoveTransparentIdentifiers(LinqQueryExpression originalQuery) { V_0 = (LinqQueryExpression)originalQuery.Clone(); V_1 = new List <VariableReference>(); V_2 = new RebuildLinqQueriesStep.LinqQueriesRebuilder.TransparentIdentifierCleaner(); V_3 = new HashSet <VariableReference>(); V_4 = 0; while (V_4 < V_0.get_Clauses().get_Count()) { V_0.get_Clauses().set_Item(V_4, (QueryClause)V_2.Visit(V_0.get_Clauses().get_Item(V_4))); V_5 = V_0.get_Clauses().get_Item(V_4); if (V_5.get_CodeNodeType() != 73) { if (V_5.get_CodeNodeType() != 78) { if (V_5.get_CodeNodeType() != 74 || V_4 == V_0.get_Clauses().get_Count() - 1) { if (V_5.get_CodeNodeType() == 80) { V_1.Clear(); V_1.Add(((IntoClause)V_5).get_Identifier().get_Variable()); } } else { V_6 = ((IntoClause)V_0.get_Clauses().get_Item(V_4 + 1)).get_Identifier().get_Variable(); if (this.IsTransparentIdentifier(V_6)) { V_7 = this.GetPropertyToValueMap((V_5 as SelectClause).get_Expression()); if (V_7 == null) { return(originalQuery); } if (V_1.get_Count() != 2) { if (V_1.get_Count() != 1) { return(originalQuery); } V_8 = this.GenerateLetClause(V_7, V_1.get_Item(0)); if (V_8 == null) { return(originalQuery); } V_0.get_Clauses().set_Item(V_4, V_8); V_0.get_Clauses().RemoveAt(V_4 + 1); } else { if (!this.RemoveIdentifier(V_7, V_1)) { return(originalQuery); } V_0.get_Clauses().RemoveAt(V_4); V_0.get_Clauses().RemoveAt(V_4); V_4 = V_4 - 1; } dummyVar0 = this.methodContext.get_VariablesToRename().Add(V_6.Resolve()); dummyVar1 = V_3.Add(V_6); V_1.Clear(); V_1.Add(V_6); this.UpdateCleaner(V_2, V_6, V_7); } } } else { if (V_0.get_Clauses().get_Item(V_4 + 1).get_CodeNodeType() == 80) { V_1.Add(((IntoClause)V_0.get_Clauses().get_Item(V_4 + 1)).get_Identifier().get_Variable()); V_4 = V_4 + 1; } else { V_1.Add(this.GetVariableReference((V_5 as JoinClause).get_InnerIdentifier())); } } } else { V_1.Add(this.GetVariableReference((V_5 as FromClause).get_Identifier())); } V_4 = V_4 + 1; } if ((new RebuildLinqQueriesStep.LinqQueriesRebuilder.TransparentIdentifierFinder(V_3)).ContainsTransparentIdentifiers(V_0)) { return(originalQuery); } return(V_0); }
private InstructionBlock GetInstructionBlock(int instructionOffset) { V_0 = this.context.get_MethodContext().get_ControlFlowGraph().get_OffsetToInstruction().get_Item(instructionOffset); while (!this.context.get_MethodContext().get_ControlFlowGraph().get_InstructionToBlockMapping().TryGetValue(V_0.get_Offset(), out V_1)) { V_0 = V_0.get_Previous(); } return(V_1); }
private CanCastExpression CreateCanCastExpression(MatchContext matchContext, BinaryExpression node) { V_0 = (SafeCastExpression)matchContext.get_Item("SafeCast"); V_1 = new List <Instruction>(); V_1.AddRange(V_0.get_MappedInstructions()); V_1.AddRange(node.get_MappedInstructions()); V_1.AddRange(node.get_Right().get_UnderlyingSameMethodInstructions()); return(new CanCastExpression((Expression)this.codeTransformer.Visit(V_0.get_Expression()), V_0.get_TargetType(), V_1)); }
private bool ChangesAssignedExpression(Expression currentExpression, Expression assignedValue, Expression assignmentRecipient) { if (currentExpression as MethodInvocationExpression != null) { V_1 = currentExpression as MethodInvocationExpression; if (assignedValue.get_ExpressionType().get_IsByReference() && V_1.get_MethodExpression().get_Target() != null) { V_2 = V_1.get_MethodExpression().get_Target(); if (V_2.Equals(assignmentRecipient)) { return(false); } if (V_2 as UnaryExpression != null && (V_2 as UnaryExpression).get_Operator() == 8 && (V_2 as UnaryExpression).get_Operand().Equals(assignmentRecipient)) { return(false); } } return(true); } if (currentExpression as BinaryExpression == null) { return(false); } V_0 = currentExpression as BinaryExpression; if (V_0.get_Left().Equals(assignedValue)) { return(true); } if (assignedValue as ArrayIndexerExpression != null) { V_3 = assignedValue as ArrayIndexerExpression; if (V_0.get_Left().Equals(V_3.get_Target())) { return(true); } V_4 = V_3.get_Indices().GetEnumerator(); try { while (V_4.MoveNext()) { V_5 = V_4.get_Current(); if (!V_0.get_Left().Equals(V_5)) { continue; } V_6 = true; goto Label1; } goto Label0; } finally { if (V_4 != null) { V_4.Dispose(); } } Label1: return(V_6); } Label0: if (assignedValue as UnaryExpression != null) { return(this.ChangesAssignedExpression(currentExpression, (assignedValue as UnaryExpression).get_Operand(), assignmentRecipient)); } if (assignedValue as ExplicitCastExpression != null) { return(this.ChangesAssignedExpression(currentExpression, (assignedValue as ExplicitCastExpression).get_Expression(), assignmentRecipient)); } if (assignedValue as CanCastExpression == null) { return(false); } return(this.ChangesAssignedExpression(currentExpression, (assignedValue as CanCastExpression).get_Expression(), assignmentRecipient)); }
protected override void InlineInBlocks() { V_0 = this.methodContext.get_Expressions().get_BlockExpressions().GetEnumerator(); try { while (V_0.MoveNext()) { V_1 = V_0.get_Current(); V_2 = V_1.get_Value(); V_3 = new Boolean[V_2.get_Count()]; V_4 = (int)this.methodContext.get_ControlFlowGraph().get_InstructionToBlockMapping().get_Item(V_1.get_Key()).get_Successors().Length > 1; V_5 = V_2.get_Count() - 2; V_6 = V_5 + 1; while (V_5 >= 0) { V_7 = V_2.get_Item(V_5) as BinaryExpression; if (V_7 == null || !V_7.get_IsAssignmentExpression() || V_7.get_Left().get_CodeNodeType() != 26) { V_6 = V_5; } else { V_8 = (V_7.get_Left() as VariableReferenceExpression).get_Variable().Resolve(); if (this.variablesToInline.Contains(V_8)) { V_9 = V_7.get_Right(); if (this.IsEnumeratorGetCurrent(V_9) || this.IsQueryInvocation(V_9) || V_8.get_VariableType() != null && V_8.get_VariableType().get_IsPinned()) { V_6 = V_5; } else { V_10 = new List <Instruction>(V_7.get_MappedInstructions()); V_10.AddRange(V_7.get_Left().get_UnderlyingSameMethodInstructions()); stackVariable78 = this.inliner; stackVariable79 = V_8; stackVariable82 = V_9.CloneAndAttachInstructions(V_10); stackVariable85 = V_2.get_Item(V_6); if (!V_4) { stackVariable87 = false; } else { stackVariable87 = V_6 + 1 == V_2.get_Count(); } if (!stackVariable78.TryInlineVariable(stackVariable79, stackVariable82, stackVariable85, stackVariable87, out V_11)) { V_6 = V_5; } else { V_2.set_Item(V_6, (Expression)V_11); V_3[V_5] = true; } } } else { V_6 = V_5; } } V_5 = V_5 - 1; } this.FastRemoveExpressions(V_2, V_3); } } finally { ((IDisposable)V_0).Dispose(); } return; }
private static string FormatLabel(int offset) { V_0 = String.Concat("000", offset.ToString("x")); return(String.Concat("IL_", V_0.Substring(V_0.get_Length() - 4))); }
public override ICodeNode VisitBoxExpression(BoxExpression node) { dummyVar0 = this.VisitBoxExpression(node); if (node.get_BoxedExpression().get_CodeNodeType() == 22 && String.op_Equality(node.get_BoxedAs().get_FullName(), this.currentTypeSystem.get_Boolean().get_FullName())) { this.FixBooleanLiteral(node.get_BoxedExpression() as LiteralExpression); return(node.get_BoxedExpression().CloneAndAttachInstructions(node.get_MappedInstructions())); } if (node.get_BoxedExpression().get_CodeNodeType() == 31 && ((ExplicitCastExpression)node.get_BoxedExpression()).get_Expression().get_CodeNodeType() == 31) { stackVariable20 = node.get_BoxedExpression() as ExplicitCastExpression; V_0 = stackVariable20.get_Expression() as ExplicitCastExpression; if (String.op_Equality(stackVariable20.get_TargetType().get_FullName(), this.currentTypeSystem.get_Char().get_FullName()) && String.op_Equality(V_0.get_TargetType().get_FullName(), this.currentTypeSystem.get_UInt16().get_FullName())) { V_0.set_TargetType(this.currentTypeSystem.get_Char()); node.set_BoxedExpression(V_0); } } return(node); }
private bool IsNullCheck(Expression condition) { if (condition as BinaryExpression == null) { return(false); } V_0 = condition as BinaryExpression; if (V_0.get_Operator() == 10 && V_0.get_Right() as LiteralExpression != null && (V_0.get_Right() as LiteralExpression).get_Value() == null) { return(true); } return(false); }
private bool IsTempVariable(VariableReference variable) { V_0 = this.methodContext.get_VariableDefinitionToNameMap().get_Item(variable.Resolve()); if (!V_0.StartsWith("CS$") && !V_0.StartsWith("VB$") && V_0.IndexOf("__init") <= 0 && !V_0.StartsWith("stackVariable") && !V_0.StartsWith("exception_")) { return(false); } return(true); }
private void ProcessTypeMembers(TypeDefinition type, MemberRenamingData memberRenamingData) { if (type.get_HasMethods()) { V_0 = type.get_Methods().GetEnumerator(); try { while (V_0.MoveNext()) { V_1 = V_0.get_Current(); this.RenameMember(V_1, memberRenamingData); } } finally { V_0.Dispose(); } } if (type.get_HasProperties()) { V_2 = type.get_Properties().GetEnumerator(); try { while (V_2.MoveNext()) { V_3 = V_2.get_Current(); this.RenameMember(V_3, memberRenamingData); } } finally { V_2.Dispose(); } } if (type.get_HasFields()) { V_4 = type.get_Fields().GetEnumerator(); try { while (V_4.MoveNext()) { V_5 = V_4.get_Current(); this.RenameMember(V_5, memberRenamingData); } } finally { V_4.Dispose(); } } if (type.get_HasEvents()) { V_6 = type.get_Events().GetEnumerator(); try { while (V_6.MoveNext()) { V_7 = V_6.get_Current(); this.RenameMember(V_7, memberRenamingData); } } finally { V_6.Dispose(); } } return; }
public override void VisitExpressionStatement(ExpressionStatement node) { if (node.get_Expression() as BinaryExpression != null) { V_0 = node.get_Expression() as BinaryExpression; if (V_0.get_Operator() == 26 && V_0.get_Left() as VariableReferenceExpression != null && V_0.get_Right() as VariableReferenceExpression != null) { stackVariable18 = (V_0.get_Left() as VariableReferenceExpression).get_Variable(); V_1 = (V_0.get_Right() as VariableReferenceExpression).get_Variable(); if ((object)stackVariable18 == (object)V_1) { this.statementsToRemove.Add(node); } } } return; }
private string GetMethodName(MethodDefinition method) { V_0 = method.GetFriendlyMemberName(null); if (V_0.Contains("<")) { V_0 = V_0.Substring(0, V_0.IndexOf("<")); } if (method.get_IsGetter() && V_0.IndexOf("get_") == 0 || method.get_IsSetter() && V_0.IndexOf("set_") == 0) { return(V_0.Substring(4)); } if (!method.get_IsConstructor()) { return(V_0); } return(method.get_DeclaringType().GetFriendlyTypeName(this.context.get_Language(), "<", ">")); }