PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/ICSharpCode.Decompiler/Ast/Annotations.cs

http://github.com/icsharpcode/ILSpy
C# | 52 lines | 38 code | 6 blank | 8 comment | 2 complexity | d0d6f7cc8116f78d473b062c84e8e5ed MD5 | raw file
 1using System;
 2using System.Collections.Generic;
 3using System.Diagnostics;
 4using ICSharpCode.Decompiler.ILAst;
 5using ICSharpCode.NRefactory.CSharp;
 6using Mono.Cecil;
 7
 8namespace ICSharpCode.Decompiler.Ast
 9{
10	public class TypeInformation
11	{
12		public readonly TypeReference InferredType;
13		public readonly TypeReference ExpectedType;
14		
15		public TypeInformation(TypeReference inferredType, TypeReference expectedType)
16		{
17			this.InferredType = inferredType;
18			this.ExpectedType = expectedType;
19		}
20	}
21	
22	public class LdTokenAnnotation {}
23	
24	/// <summary>
25	/// Annotation that is applied to the body expression of an Expression.Lambda() call.
26	/// </summary>
27	public class ParameterDeclarationAnnotation
28	{
29		public readonly List<ParameterDeclaration> Parameters = new List<ParameterDeclaration>();
30		
31		public ParameterDeclarationAnnotation(ILExpression expr)
32		{
33			Debug.Assert(expr.Code == ILCode.ExpressionTreeParameterDeclarations);
34			for (int i = 0; i < expr.Arguments.Count - 1; i++) {
35				ILExpression p = expr.Arguments[i];
36				// p looks like this:
37				//   stloc(v, call(Expression::Parameter, call(Type::GetTypeFromHandle, ldtoken(...)), ldstr(...)))
38				ILVariable v = (ILVariable)p.Operand;
39				TypeReference typeRef = (TypeReference)p.Arguments[0].Arguments[0].Arguments[0].Operand;
40				string name = (string)p.Arguments[0].Arguments[1].Operand;
41				Parameters.Add(new ParameterDeclaration(AstBuilder.ConvertType(typeRef), name).WithAnnotation(v));
42			}
43		}
44	}
45	
46	/// <summary>
47	/// Annotation that is applied to a LambdaExpression that was produced by an expression tree.
48	/// </summary>
49	public class ExpressionTreeLambdaAnnotation
50	{
51	}
52}