/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

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