From d8fc41e7a9ae4929951e23a29ec8c0bb247b3475 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 19 Apr 2011 22:49:10 +0200 Subject: [PATCH] Add refanytype and refanyval to type analysis. --- .../Ast/Transforms/PatternStatementTransform.cs | 2 +- ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs b/ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs index d3bf2f7c1..7d9a6c599 100644 --- a/ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs +++ b/ICSharpCode.Decompiler/Ast/Transforms/PatternStatementTransform.cs @@ -416,7 +416,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms if (declarationPoint != foreachStatement) { // oops, the enumerator variable can't be moved into the foreach loop // Undo our AST changes: - ((BlockStatement)foreachStatement.Parent).Statements.InsertBefore(foreachStatement, node); + ((BlockStatement)foreachStatement.Parent).Statements.InsertBefore(foreachStatement, node.Detach()); foreachStatement.ReplaceWith(tryCatch); return null; } diff --git a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs index be93bdcca..bf9109a52 100644 --- a/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs +++ b/ICSharpCode.Decompiler/ILAst/TypeAnalysis.cs @@ -458,6 +458,16 @@ namespace ICSharpCode.Decompiler.ILAst InferTypeForExpression(expr.Arguments[0], (TypeReference)expr.Operand); } return typeSystem.TypedReference; + case ILCode.Refanytype: + if (forceInferChildren) { + InferTypeForExpression(expr.Arguments[0], typeSystem.TypedReference); + } + return new TypeReference("System", "RuntimeTypeHandle", module, module, true); + case ILCode.Refanyval: + if (forceInferChildren) { + InferTypeForExpression(expr.Arguments[0], typeSystem.TypedReference); + } + return new ByReferenceType((TypeReference)expr.Operand); #endregion #region Arithmetic instructions case ILCode.Not: // bitwise complement