You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
3.1 KiB

  1. // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a copy of this
  4. // software and associated documentation files (the "Software"), to deal in the Software
  5. // without restriction, including without limitation the rights to use, copy, modify, merge,
  6. // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
  7. // to whom the Software is furnished to do so, subject to the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be included in all copies or
  10. // substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  13. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  14. // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  15. // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17. // DEALINGS IN THE SOFTWARE.
  18. using System;
  19. using ICSharpCode.Decompiler.TypeSystem;
  20. namespace ICSharpCode.Decompiler.Semantics
  21. {
  22. /// <summary>
  23. /// Resolve result representing a 'foreach' loop.
  24. /// </summary>
  25. public class ForEachResolveResult : ResolveResult
  26. {
  27. /// <summary>
  28. /// Gets the semantic tree for the call to GetEnumerator.
  29. /// </summary>
  30. public readonly ResolveResult GetEnumeratorCall;
  31. /// <summary>
  32. /// Gets the collection type.
  33. /// </summary>
  34. public readonly IType CollectionType;
  35. /// <summary>
  36. /// Gets the enumerator type.
  37. /// </summary>
  38. public readonly IType EnumeratorType;
  39. /// <summary>
  40. /// Gets the element type.
  41. /// This is the type that would be inferred for an implicitly-typed element variable.
  42. /// For explicitly-typed element variables, this type may differ from <c>ElementVariable.Type</c>.
  43. /// </summary>
  44. public readonly IType ElementType;
  45. /// <summary>
  46. /// Gets the Current property on the IEnumerator.
  47. /// Returns null if the property is not found.
  48. /// </summary>
  49. public readonly IProperty CurrentProperty;
  50. /// <summary>
  51. /// Gets the MoveNext() method on the IEnumerator.
  52. /// Returns null if the method is not found.
  53. /// </summary>
  54. public readonly IMethod MoveNextMethod;
  55. public ForEachResolveResult(ResolveResult getEnumeratorCall, IType collectionType, IType enumeratorType, IType elementType, IProperty currentProperty, IMethod moveNextMethod, IType voidType)
  56. : base(voidType)
  57. {
  58. if (getEnumeratorCall == null)
  59. throw new ArgumentNullException("getEnumeratorCall");
  60. if (collectionType == null)
  61. throw new ArgumentNullException("collectionType");
  62. if (enumeratorType == null)
  63. throw new ArgumentNullException("enumeratorType");
  64. if (elementType == null)
  65. throw new ArgumentNullException("elementType");
  66. this.GetEnumeratorCall = getEnumeratorCall;
  67. this.CollectionType = collectionType;
  68. this.EnumeratorType = enumeratorType;
  69. this.ElementType = elementType;
  70. this.CurrentProperty = currentProperty;
  71. this.MoveNextMethod = moveNextMethod;
  72. }
  73. }
  74. }