Browse Source

Negation of operators on nullable values is not allowed for correct decompilation

pull/205/head
Pent Ploompuu 15 years ago
parent
commit
cb174caab3
  1. 2
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  2. 5
      ICSharpCode.Decompiler/ILAst/ILCodes.cs
  3. 9
      ICSharpCode.Decompiler/ILAst/NullableOperators.cs
  4. 1
      ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

2
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -747,6 +747,8 @@ namespace ICSharpCode.Decompiler.Ast @@ -747,6 +747,8 @@ namespace ICSharpCode.Decompiler.Ast
}
case ILCode.InitializedObject:
return new InitializedObjectExpression();
case ILCode.Wrap:
return new ParenthesizedExpression(arg1);
case ILCode.AddressOf:
return MakeRef(arg1);
default:

5
ICSharpCode.Decompiler/ILAst/ILCodes.cs

@ -259,6 +259,11 @@ namespace ICSharpCode.Decompiler.ILAst @@ -259,6 +259,11 @@ namespace ICSharpCode.Decompiler.ILAst
NullCoalescing,
InitArray, // Array Initializer
/// <summary>
/// Defines a barrier between the parent opcode and argument opcode that prevents combining them
/// </summary>
Wrap,
// new Class { Prop = 1, Collection = { { 2, 3 }, {4, 5} }}
// is represented as:
// InitObject(newobj Class,

9
ICSharpCode.Decompiler/ILAst/NullableOperators.cs

@ -325,10 +325,11 @@ namespace ICSharpCode.Decompiler.ILAst @@ -325,10 +325,11 @@ namespace ICSharpCode.Decompiler.ILAst
var pm = new PatternMatcher();
if (!pm.Match(ps[i], expr)) continue;
var n = pm.BuildNew(OperatorVariableAB, expr);
expr.Code = n.Code;
expr.Operand = n.Operand;
expr.Arguments = n.Arguments;
expr.ILRanges = n.ILRanges;
expr.Code = ILCode.Wrap;
expr.Operand = null;
expr.Arguments.Clear();
expr.Arguments.Add(n);
expr.ILRanges.Clear();
expr.InferredType = n.InferredType;
return true;
}

1
ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

@ -749,6 +749,7 @@ namespace ICSharpCode.Decompiler.ILAst @@ -749,6 +749,7 @@ namespace ICSharpCode.Decompiler.ILAst
#endregion
case ILCode.Pop:
return null;
case ILCode.Wrap:
case ILCode.Dup:
return InferTypeForExpression(expr.Arguments.Single(), expectedType);
default:

Loading…
Cancel
Save