Browse Source

Fixed crash when decompiling System.Net.ShellExpression.

pull/100/head
Daniel Grunwald 15 years ago
parent
commit
404b27c860
  1. 2
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 9
      ICSharpCode.Decompiler/ILAst/ILAstTypes.cs
  3. 5
      ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

2
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -1125,7 +1125,7 @@ namespace ICSharpCode.Decompiler.Ast
} }
} }
TypeCode code = TypeAnalysis.GetTypeCode(type); TypeCode code = TypeAnalysis.GetTypeCode(type);
if (code == TypeCode.Object) if (code == TypeCode.Object || code == TypeCode.Empty)
return new Ast.PrimitiveExpression((int)val); return new Ast.PrimitiveExpression((int)val);
else else
return new Ast.PrimitiveExpression(CSharpPrimitiveCast.Cast(code, val, false)); return new Ast.PrimitiveExpression(CSharpPrimitiveCast.Cast(code, val, false));

9
ICSharpCode.Decompiler/ILAst/ILAstTypes.cs

@ -465,9 +465,12 @@ namespace ICSharpCode.Decompiler.ILAst
public override void WriteTo(ITextOutput output) public override void WriteTo(ITextOutput output)
{ {
Debug.Assert(Values.Count > 0); if (this.Values != null) {
foreach (int i in this.Values) { foreach (int i in this.Values) {
output.WriteLine("case {0}:", i); output.WriteLine("case {0}:", i);
}
} else {
output.WriteLine("default:");
} }
output.Indent(); output.Indent();
base.WriteTo(output); base.WriteTo(output);

5
ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

@ -28,6 +28,10 @@ namespace ICSharpCode.Decompiler.ILAst
ta.method = method; ta.method = method;
ta.InferTypes(method); ta.InferTypes(method);
ta.InferRemainingStores(); ta.InferRemainingStores();
// Now that stores were inferred, we can infer the remaining instructions that depended on those stored
// (but which didn't provide an expected type for the store)
// For example, this is necessary to make a switch() over a generated variable work correctly.
ta.InferTypes(method);
} }
DecompilerContext context; DecompilerContext context;
@ -356,7 +360,6 @@ namespace ICSharpCode.Decompiler.ILAst
{ {
ArrayType arrayType = InferTypeForExpression(expr.Arguments[0], null) as ArrayType; ArrayType arrayType = InferTypeForExpression(expr.Arguments[0], null) as ArrayType;
if (forceInferChildren) { if (forceInferChildren) {
InferTypeForExpression(expr.Arguments[0], new ArrayType(typeSystem.Byte));
InferTypeForExpression(expr.Arguments[1], typeSystem.Int32); InferTypeForExpression(expr.Arguments[1], typeSystem.Int32);
} }
return arrayType != null ? arrayType.ElementType : null; return arrayType != null ? arrayType.ElementType : null;

Loading…
Cancel
Save