Browse Source

Set DelayExceptions = true in ILReader for get/set operations on multi-dim arrays.

pull/1405/head
Siegfried Pammer 7 years ago
parent
commit
3f4ffd64f8
  1. 2
      ICSharpCode.Decompiler/DecompilerSettings.cs
  2. 8
      ICSharpCode.Decompiler/IL/Instructions.cs
  3. 3
      ICSharpCode.Decompiler/IL/Instructions.tt

2
ICSharpCode.Decompiler/DecompilerSettings.cs

@ -795,7 +795,7 @@ namespace ICSharpCode.Decompiler @@ -795,7 +795,7 @@ namespace ICSharpCode.Decompiler
/// <summary>
/// Gets/Sets whether C# 7.0 local functions should be used.
/// Note: this language feature is currenly not implemented and this setting is always false.
/// Note: this language feature is currently not implemented and this setting is always false.
/// </summary>
public bool LocalFunctions {
get { return localFunctions; }

8
ICSharpCode.Decompiler/IL/Instructions.cs

@ -3617,6 +3617,8 @@ namespace ICSharpCode.Decompiler.IL @@ -3617,6 +3617,8 @@ namespace ICSharpCode.Decompiler.IL
public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
{
ILRange.WriteTo(output, options);
if (DelayExceptions)
output.Write("delayex.");
output.Write(OpCode);
output.Write(' ');
field.WriteTo(output);
@ -3639,7 +3641,7 @@ namespace ICSharpCode.Decompiler.IL @@ -3639,7 +3641,7 @@ namespace ICSharpCode.Decompiler.IL
protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match)
{
var o = other as LdFlda;
return o != null && this.target.PerformMatch(o.target, ref match) && field.Equals(o.field);
return o != null && this.target.PerformMatch(o.target, ref match) && DelayExceptions == o.DelayExceptions && field.Equals(o.field);
}
}
}
@ -4642,6 +4644,8 @@ namespace ICSharpCode.Decompiler.IL @@ -4642,6 +4644,8 @@ namespace ICSharpCode.Decompiler.IL
public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
{
ILRange.WriteTo(output, options);
if (DelayExceptions)
output.Write("delayex.");
if (IsReadOnly)
output.Write("readonly.");
output.Write(OpCode);
@ -4670,7 +4674,7 @@ namespace ICSharpCode.Decompiler.IL @@ -4670,7 +4674,7 @@ namespace ICSharpCode.Decompiler.IL
protected internal override bool PerformMatch(ILInstruction other, ref Patterns.Match match)
{
var o = other as LdElema;
return o != null && type.Equals(o.type) && this.array.PerformMatch(o.array, ref match) && Patterns.ListMatch.DoMatch(this.Indices, o.Indices, ref match) && IsReadOnly == o.IsReadOnly;
return o != null && type.Equals(o.type) && this.array.PerformMatch(o.array, ref match) && Patterns.ListMatch.DoMatch(this.Indices, o.Indices, ref match) && DelayExceptions == o.DelayExceptions && IsReadOnly == o.IsReadOnly;
}
}
}

3
ICSharpCode.Decompiler/IL/Instructions.tt

@ -708,6 +708,9 @@ namespace ICSharpCode.Decompiler.IL @@ -708,6 +708,9 @@ namespace ICSharpCode.Decompiler.IL
static Action<OpCode> MayThrowIfNotDelayed = HasFlag("(DelayExceptions ? InstructionFlags.None : InstructionFlags.MayThrow)") + (opCode => {
opCode.Members.Add("public bool DelayExceptions; // NullReferenceException/IndexOutOfBoundsException only occurs when the reference is dereferenced");
opCode.GenerateWriteTo = true;
opCode.WriteOpCodePrefix.Add("if (DelayExceptions)" + Environment.NewLine + "\toutput.Write(\"delayex.\");");
opCode.PerformMatchConditions.Add("DelayExceptions == o.DelayExceptions");
});
static Action<OpCode> BaseClass(string name)

Loading…
Cancel
Save