Browse Source

Keep track of the original variable for ILVariable

pull/37/head
David Srbecký 15 years ago
parent
commit
89c7a8a5b4
  1. 8
      ICSharpCode.Decompiler/ILAst/ILAstBuilder.cs
  2. 1
      ICSharpCode.Decompiler/ILAst/ILAstTypes.cs

8
ICSharpCode.Decompiler/ILAst/ILAstBuilder.cs

@ -462,7 +462,8 @@ namespace Decompiler @@ -462,7 +462,8 @@ namespace Decompiler
newVars = new List<VariableInfo>(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 @@ -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<ByteCode>() {st},
Loads = new List<ByteCode>()
@ -521,7 +523,7 @@ namespace Decompiler @@ -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;

1
ICSharpCode.Decompiler/ILAst/ILAstTypes.cs

@ -176,6 +176,7 @@ namespace Decompiler @@ -176,6 +176,7 @@ namespace Decompiler
public string Name;
public bool IsGenerated;
public TypeReference Type;
public VariableDefinition OriginalVariable;
public override string ToString()
{

Loading…
Cancel
Save