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

5
ICSharpCode.Decompiler/ILAst/ILAstTypes.cs

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

5
ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs

@ -28,6 +28,10 @@ namespace ICSharpCode.Decompiler.ILAst @@ -28,6 +28,10 @@ namespace ICSharpCode.Decompiler.ILAst
ta.method = method;
ta.InferTypes(method);
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;
@ -356,7 +360,6 @@ namespace ICSharpCode.Decompiler.ILAst @@ -356,7 +360,6 @@ namespace ICSharpCode.Decompiler.ILAst
{
ArrayType arrayType = InferTypeForExpression(expr.Arguments[0], null) as ArrayType;
if (forceInferChildren) {
InferTypeForExpression(expr.Arguments[0], new ArrayType(typeSystem.Byte));
InferTypeForExpression(expr.Arguments[1], typeSystem.Int32);
}
return arrayType != null ? arrayType.ElementType : null;

Loading…
Cancel
Save