private void CreateMethod(CatchClause catchClause, VariableDeclarationExpression variable, out Expression methodInvocationExpression)
 {
     methodInvocationExpression = null;
     stackVariable4             = catchClause.get_Filter() as BlockStatement;
     V_0 = (((stackVariable4.get_Statements().First <Statement>() as ExpressionStatement).get_Expression() as BinaryExpression).get_Right() as SafeCastExpression).get_Expression() as VariableReferenceExpression;
     V_0.set_Variable(variable.get_Variable());
     V_1 = stackVariable4.get_Statements().Last <Statement>() as ExpressionStatement;
     V_1.set_Expression(new ReturnExpression(V_1.get_Expression(), V_1.get_Expression().get_MappedInstructions()));
     V_2 = this.context.get_TypeContext().get_GeneratedFilterMethods().get_Count() + this.methodsToBeDecompiled.get_Count();
     V_3 = new MethodDefinition(String.Format("JustDecompileGenerated_Filter_{0}", V_2), 1, this.context.get_MethodContext().get_Method().get_Module().get_TypeSystem().get_Boolean());
     V_3.set_Body(new MethodBody(V_3));
     V_3.set_MetadataToken(new MetadataToken(0x6000000, 0xffffff - V_2));
     V_3.set_IsStatic(this.context.get_MethodContext().get_Method().get_IsStatic());
     V_3.set_HasThis(!V_3.get_IsStatic());
     V_3.set_DeclaringType(this.context.get_MethodContext().get_Method().get_DeclaringType());
     V_3.set_SemanticsAttributes(0);
     V_3.set_IsJustDecompileGenerated(true);
     V_4 = new DecompilationContext(this.CloneAndReplaceMethodBody(this.context.get_MethodContext(), V_3.get_Body()), this.context.get_TypeContext(), this.context.get_Language());
     V_5 = V_0.get_Variable().Resolve();
     if (V_4.get_MethodContext().get_VariableDefinitionToNameMap().ContainsKey(V_5))
     {
         V_4.get_MethodContext().get_VariableDefinitionToNameMap().Add(V_5, "JustDecompileGenerated_Exception");
     }
     else
     {
         V_4.get_MethodContext().get_VariableDefinitionToNameMap().set_Item(V_5, "JustDecompileGenerated_Exception");
     }
     dummyVar0 = V_4.get_MethodContext().get_VariablesToNotDeclare().Add(variable.get_Variable());
     this.methodsToBeDecompiled.Add(new FilterMethodToBeDecompiled(V_3, catchClause, V_4, catchClause.get_Filter() as BlockStatement));
     V_6 = this.AddAllParameters(catchClause, V_3, variable);
     methodInvocationExpression = this.CreateMethodInvocation(V_3, V_6);
     return;
 }
 private void ProcessVariableDeclaration(VariableDeclarationExpression node)
 {
     if (!this.methodContext.get_VariableDefinitionToNameMap().ContainsKey(node.get_Variable()))
     {
         this.methodContext.get_VariableDefinitionToNameMap().Add(node.get_Variable(), node.get_Variable().get_Name());
     }
     if (this.state == RenameVariables.State.SearchForPossibleNames)
     {
         this.SuggestNameForVariable(node.get_Variable());
         return;
     }
     if (this.state == 1)
     {
         this.TryRenameVariable(node.get_Variable());
     }
     return;
 }
Exemple #3
0
 public override void VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     if ((object)node.get_Variable() == (object)this.oldVariable)
     {
         node.set_Variable(this.newVariable);
     }
     return;
 }
Exemple #4
0
 public override void VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     if (node.get_Variable() == this.variable)
     {
         this.found = true;
         return;
     }
     this.VisitVariableDeclarationExpression(node);
     return;
 }
Exemple #5
0
 public override void VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     this.RemoveVariable(node.get_Variable().Resolve());
     return;
 }
 public override ICodeNode VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     dummyVar0 = this.TryDiscardVariable(node.get_Variable());
     return(node);
 }
 private List <Expression> AddAllParameters(CatchClause catchClause, MethodDefinition method, VariableDeclarationExpression variable)
 {
     V_0 = new List <Expression>();
     method.get_Parameters().Add(this.CreateParameter("JustDecompileGenerated_Exception", variable.get_Variable().get_VariableType()));
     V_0.Add(new UnaryExpression(7, new VariableReferenceExpression(variable.get_Variable(), null), null));
     if (this.catchClausesUsedVariablesMap.ContainsKey(catchClause))
     {
         V_1 = this.catchClausesUsedVariablesMap.get_Item(catchClause).GetEnumerator();
         try
         {
             while (V_1.MoveNext())
             {
                 V_2 = V_1.get_Current();
                 if (!this.variablesUsedOutsideFilters.Contains(V_2) || (object)V_2 == (object)variable.get_Variable())
                 {
                     continue;
                 }
                 if (this.context.get_MethodContext().get_VariablesToRename().Contains(V_2))
                 {
                     stackVariable72 = null;
                 }
                 else
                 {
                     stackVariable72 = V_2.get_Name();
                 }
                 V_3 = stackVariable72;
                 V_4 = this.CreateParameter(V_3, V_2.get_VariableType());
                 if (V_3 == null)
                 {
                     if (!this.catchClausesVariablesToParametersMap.ContainsKey(catchClause))
                     {
                         this.catchClausesVariablesToParametersMap.Add(catchClause, new Dictionary <VariableDefinition, ParameterDefinition>());
                     }
                     this.catchClausesVariablesToParametersMap.get_Item(catchClause).Add(V_2, V_4);
                 }
                 method.get_Parameters().Add(V_4);
                 V_0.Add(new UnaryExpression(7, new VariableReferenceExpression(V_2, null), null));
             }
         }
         finally
         {
             ((IDisposable)V_1).Dispose();
         }
     }
     if (this.catchClausesUsedParametersMap.ContainsKey(catchClause))
     {
         V_5 = this.catchClausesUsedParametersMap.get_Item(catchClause).GetEnumerator();
         try
         {
             while (V_5.MoveNext())
             {
                 V_6 = V_5.get_Current();
                 method.get_Parameters().Add(this.CreateParameter(V_6.get_Name(), V_6.get_ParameterType()));
                 V_0.Add(new UnaryExpression(7, new ArgumentReferenceExpression(V_6, null), null));
             }
         }
         finally
         {
             ((IDisposable)V_5).Dispose();
         }
     }
     return(V_0);
 }
 public override ICodeNode VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     this.AddReferencedVariable(node.get_Variable().Resolve());
     return(node);
 }
Exemple #9
0
 public override void VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     this.WriteTypeAndName(node.get_Variable().get_VariableType(), node.get_Variable().get_Name());
     return;
 }
Exemple #10
0
 public override void VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     this.get_TypesDependingOn().UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.get_Variable().get_VariableType()));
     this.VisitVariableDeclarationExpression(node);
     return;
 }
Exemple #11
0
 public override ICodeNode VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     dummyVar0 = this.decompilationContext.get_MethodContext().get_VariablesToRename().Add(node.get_Variable());
     return(this.VisitVariableDeclarationExpression(node));
 }
 public static bool TryMatch(BlockStatement filter, out VariableDeclarationExpression variableDeclaration, out Expression filterExpression)
 {
     variableDeclaration = null;
     filterExpression    = null;
     if (!CatchClausesFilterPattern.TryMatchVariableDeclaration(filter, out variableDeclaration))
     {
         return(false);
     }
     if (filter.get_Statements().get_Count() != 3)
     {
         return(false);
     }
     V_0 = filter.get_Statements().get_Item(1) as IfStatement;
     if (V_0 == null)
     {
         return(false);
     }
     V_1 = null;
     V_2 = null;
     if ((V_0.get_Condition() as BinaryExpression).get_Operator() != 10)
     {
         V_1 = V_0.get_Else();
         V_2 = V_0.get_Then();
     }
     else
     {
         V_1 = V_0.get_Then();
         V_2 = V_0.get_Else();
     }
     V_3 = null;
     V_4 = null;
     if (V_1.get_Statements().get_Count() != 1 && V_1.get_Statements().get_Count() != 2 && V_1.get_Statements().get_Count() != 3 || V_2.get_Statements().get_Count() != 1)
     {
         return(false);
     }
     if (V_1.get_Statements().get_Count() != 2)
     {
         if (V_1.get_Statements().get_Count() == 3)
         {
             V_8 = V_1.get_Statements().get_Item(0) as ExpressionStatement;
             V_9 = V_1.get_Statements().get_Item(1) as ExpressionStatement;
             if (V_8 == null || V_9 == null)
             {
                 return(false);
             }
             if (V_8.get_Expression().get_CodeNodeType() != 24 || V_9.get_Expression().get_CodeNodeType() != 19)
             {
                 if (V_8.get_Expression().get_CodeNodeType() != 19 || V_9.get_Expression().get_CodeNodeType() != 24)
                 {
                     return(false);
                 }
                 V_4 = V_8;
                 V_3 = V_9;
             }
             else
             {
                 V_3 = V_8;
                 V_4 = V_9;
             }
         }
     }
     else
     {
         V_7 = V_1.get_Statements().get_Item(0) as ExpressionStatement;
         if (V_7 == null)
         {
             return(false);
         }
         if (V_7.get_Expression().get_CodeNodeType() != 24)
         {
             if (V_7.get_Expression().get_CodeNodeType() != 19)
             {
                 return(false);
             }
             V_4 = V_7;
         }
         else
         {
             V_3 = V_7;
         }
     }
     if (V_3 != null)
     {
         V_10 = V_3.get_Expression() as BinaryExpression;
         if (V_10 == null || !V_10.get_IsAssignmentExpression() || String.op_Inequality(V_10.get_ExpressionType().get_FullName(), variableDeclaration.get_ExpressionType().get_FullName()))
         {
             return(false);
         }
         stackVariable98 = V_10.get_Left() as VariableReferenceExpression;
         V_11            = V_10.get_Right() as VariableReferenceExpression;
         if (stackVariable98 == null || V_11 == null)
         {
             return(false);
         }
     }
     if (V_4 != null)
     {
         V_12 = V_4.get_Expression() as MethodInvocationExpression;
         if (V_12 == null || String.op_Inequality(V_12.get_MethodExpression().get_Method().get_FullName(), "System.Void Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(System.Exception)"))
         {
             return(false);
         }
     }
     V_5 = filter.get_Statements().get_Item(2) as ExpressionStatement;
     if (V_5 == null)
     {
         return(false);
     }
     V_6 = V_5.get_Expression() as VariableReferenceExpression;
     if (V_6 == null)
     {
         return(false);
     }
     if (!CatchClausesFilterPattern.TryMatchFilterExpression(V_0, variableDeclaration.get_Variable().get_VariableType(), V_6, out filterExpression))
     {
         return(false);
     }
     return(true);
 }