1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
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:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
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.
20
using ICSharpCode.NRefactory.TypeSystem;
22
namespace ICSharpCode.NRefactory.Semantics
25
/// Resolve result representing a 'foreach' loop.
27
public class ForEachResolveResult : ResolveResult
30
/// Gets the semantic tree for the call to GetEnumerator.
32
public readonly ResolveResult GetEnumeratorCall;
35
/// Gets the collection type.
37
public readonly IType CollectionType;
40
/// Gets the enumerator type.
42
public readonly IType EnumeratorType;
45
/// Gets the element type.
46
/// This is the type that would be inferred for an implicitly-typed element variable.
47
/// For explicitly-typed element variables, this type may differ from <c>ElementVariable.Type</c>.
49
public readonly IType ElementType;
52
/// Gets the element variable.
54
public readonly IVariable ElementVariable;
57
/// Gets the Current property on the IEnumerator.
58
/// Returns null if the property is not found.
60
public readonly IProperty CurrentProperty;
63
/// Gets the MoveNext() method on the IEnumerator.
64
/// Returns null if the method is not found.
66
public readonly IMethod MoveNextMethod;
68
public ForEachResolveResult(ResolveResult getEnumeratorCall, IType collectionType, IType enumeratorType, IType elementType, IVariable elementVariable, IProperty currentProperty, IMethod moveNextMethod, IType voidType)
71
if (getEnumeratorCall == null)
72
throw new ArgumentNullException("getEnumeratorCall");
73
if (collectionType == null)
74
throw new ArgumentNullException("collectionType");
75
if (enumeratorType == null)
76
throw new ArgumentNullException("enumeratorType");
77
if (elementType == null)
78
throw new ArgumentNullException("elementType");
79
if (elementVariable == null)
80
throw new ArgumentNullException("elementVariable");
81
this.GetEnumeratorCall = getEnumeratorCall;
82
this.CollectionType = collectionType;
83
this.EnumeratorType = enumeratorType;
84
this.ElementType = elementType;
85
this.ElementVariable = elementVariable;
86
this.CurrentProperty = currentProperty;
87
this.MoveNextMethod = moveNextMethod;