From 89c7a8a5b42013e1c9325b64aa73c9c54c90df72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Wed, 23 Feb 2011 00:03:24 +0000 Subject: [PATCH] Keep track of the original variable for ILVariable --- ICSharpCode.Decompiler/ILAst/ILAstBuilder.cs | 8 +++++--- ICSharpCode.Decompiler/ILAst/ILAstTypes.cs | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/ILAst/ILAstBuilder.cs b/ICSharpCode.Decompiler/ILAst/ILAstBuilder.cs index 63bdd0ae2..ea228e014 100644 --- a/ICSharpCode.Decompiler/ILAst/ILAstBuilder.cs +++ b/ICSharpCode.Decompiler/ILAst/ILAstBuilder.cs @@ -462,7 +462,8 @@ namespace Decompiler newVars = new List(1) { new VariableInfo() { Variable = new ILVariable() { Name = "var_" + variableIndex, - Type = varType + Type = varType, + OriginalVariable = methodDef.Body.Variables[variableIndex] }, Stores = stores, Loads = loads @@ -472,7 +473,8 @@ namespace Decompiler newVars = stores.Select(st => new VariableInfo() { Variable = new ILVariable() { Name = "var_" + variableIndex + "_" + st.Offset.ToString("X2"), - Type = varType + Type = varType, + OriginalVariable = methodDef.Body.Variables[variableIndex] }, Stores = new List() {st}, Loads = new List() @@ -521,7 +523,7 @@ namespace Decompiler this.Variables.AddRange(newVars.Select(v => v.Variable)); } } else { - this.Variables = methodDef.Body.Variables.Select(v => new ILVariable() { Name = string.IsNullOrEmpty(v.Name) ? "var_" + v.Index : v.Name, Type = v.VariableType }).ToList(); + this.Variables = methodDef.Body.Variables.Select(v => new ILVariable() { Name = string.IsNullOrEmpty(v.Name) ? "var_" + v.Index : v.Name, Type = v.VariableType, OriginalVariable = v }).ToList(); foreach(ByteCode byteCode in body) { if (byteCode.Code == ILCode.Ldloc || byteCode.Code == ILCode.Stloc || byteCode.Code == ILCode.Ldloca) { int index = ((VariableDefinition)byteCode.Operand).Index; diff --git a/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs b/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs index 8280ccf76..92ea2f680 100644 --- a/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs +++ b/ICSharpCode.Decompiler/ILAst/ILAstTypes.cs @@ -176,6 +176,7 @@ namespace Decompiler public string Name; public bool IsGenerated; public TypeReference Type; + public VariableDefinition OriginalVariable; public override string ToString() {