/NRefactory/ICSharpCode.NRefactory.CSharp/Resolver/OperatorResolveResult.cs

http://github.com/icsharpcode/ILSpy · C# · 109 lines · 70 code · 11 blank · 28 comment · 12 complexity · d2546f5769b4940ceb85fe8a3dd08598 MD5 · raw file

  1. // Copyright (c) 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 System.Collections.Generic;
  20. using System.Linq;
  21. using ICSharpCode.NRefactory.Semantics;
  22. using ICSharpCode.NRefactory.TypeSystem;
  23. using ICSharpCode.NRefactory.Utils;
  24. namespace ICSharpCode.NRefactory.CSharp.Resolver
  25. {
  26. /// <summary>
  27. /// Resolve result representing a built-in unary operator.
  28. /// (user-defined operators use InvocationResolveResult)
  29. /// </summary>
  30. public class UnaryOperatorResolveResult : ResolveResult
  31. {
  32. public readonly UnaryOperatorType Operator;
  33. public readonly ResolveResult Input;
  34. public UnaryOperatorResolveResult(IType resultType, UnaryOperatorType op, ResolveResult input)
  35. : base(resultType)
  36. {
  37. if (input == null)
  38. throw new ArgumentNullException("input");
  39. this.Operator = op;
  40. this.Input = input;
  41. }
  42. public override IEnumerable<ResolveResult> GetChildResults()
  43. {
  44. return new [] { Input };
  45. }
  46. }
  47. /// <summary>
  48. /// Resolve result representing a built-in binary operator.
  49. /// (user-defined operators use InvocationResolveResult)
  50. /// </summary>
  51. public class BinaryOperatorResolveResult : ResolveResult
  52. {
  53. public readonly BinaryOperatorType Operator;
  54. public readonly ResolveResult Left;
  55. public readonly ResolveResult Right;
  56. public BinaryOperatorResolveResult(IType resultType, ResolveResult lhs, BinaryOperatorType op, ResolveResult rhs)
  57. : base(resultType)
  58. {
  59. if (lhs == null)
  60. throw new ArgumentNullException("lhs");
  61. if (rhs == null)
  62. throw new ArgumentNullException("rhs");
  63. this.Left = lhs;
  64. this.Operator = op;
  65. this.Right = rhs;
  66. }
  67. public override IEnumerable<ResolveResult> GetChildResults()
  68. {
  69. return new [] { Left, Right };
  70. }
  71. }
  72. /// <summary>
  73. /// Resolve result representing the conditional operator.
  74. /// </summary>
  75. public class ConditionalOperatorResolveResult : ResolveResult
  76. {
  77. public readonly ResolveResult Condition;
  78. public readonly ResolveResult True;
  79. public readonly ResolveResult False;
  80. public ConditionalOperatorResolveResult(IType targetType, ResolveResult condition, ResolveResult @true, ResolveResult @false)
  81. : base(targetType)
  82. {
  83. if (condition == null)
  84. throw new ArgumentNullException("condition");
  85. if (@true == null)
  86. throw new ArgumentNullException("true");
  87. if (@false == null)
  88. throw new ArgumentNullException("false");
  89. this.Condition = condition;
  90. this.True = @true;
  91. this.False = @false;
  92. }
  93. public override IEnumerable<ResolveResult> GetChildResults()
  94. {
  95. return new [] { Condition, True, False };
  96. }
  97. }
  98. }