Browse Source

Improve TransformArrayInitializers

pull/734/head
Siegfried Pammer 9 years ago
parent
commit
cd8c4e03a2
  1. 17
      ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs

17
ICSharpCode.Decompiler/IL/Transforms/TransformArrayInitializers.cs

@ -186,7 +186,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -186,7 +186,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
IType type;
if (index >= length)
break;
if (!block.Instructions[i].MatchStObj(out target, out value, out type) || !IsPrimitiveValue(value))
if (!block.Instructions[i].MatchStObj(out target, out value, out type) || value.Descendants.OfType<IInstructionWithVariableOperand>().Any(inst => inst.Variable == store))
return false;
var ldelem = target as LdElema;
if (ldelem == null || !ldelem.Array.MatchLdLoc(store) || ldelem.Indices.Count != 1 || !ldelem.Indices[0].MatchLdcI4(out index))
@ -206,21 +206,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -206,21 +206,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return true;
}
bool IsPrimitiveValue(ILInstruction value)
{
switch (value.OpCode) {
case OpCode.LdLoc:
case OpCode.LdNull:
case OpCode.LdcI4:
case OpCode.LdcI8:
case OpCode.LdcF:
case OpCode.LdcDecimal:
return true;
default:
return false;
}
}
bool HandleJaggedArrayInitializer(Block block, int pos, ILVariable store, int length, out ILVariable finalStore, out ILInstruction[] values, out int instructionsToRemove)
{
instructionsToRemove = 0;

Loading…
Cancel
Save