PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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