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 | |
---|
19 | using System; |
---|
20 | using ICSharpCode.NRefactory.TypeSystem; |
---|
21 | |
---|
22 | namespace ICSharpCode.NRefactory.Semantics |
---|
23 | { |
---|
24 | /// <summary> |
---|
25 | /// Resolve result representing a 'foreach' loop. |
---|
26 | /// </summary> |
---|
27 | public class ForEachResolveResult : ResolveResult |
---|
28 | { |
---|
29 | /// <summary> |
---|
30 | /// Gets the semantic tree for the call to GetEnumerator. |
---|
31 | /// </summary> |
---|
32 | public readonly ResolveResult GetEnumeratorCall; |
---|
33 | |
---|
34 | /// <summary> |
---|
35 | /// Gets the collection type. |
---|
36 | /// </summary> |
---|
37 | public readonly IType CollectionType; |
---|
38 | |
---|
39 | /// <summary> |
---|
40 | /// Gets the enumerator type. |
---|
41 | /// </summary> |
---|
42 | public readonly IType EnumeratorType; |
---|
43 | |
---|
44 | /// <summary> |
---|
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>. |
---|
48 | /// </summary> |
---|
49 | public readonly IType ElementType; |
---|
50 | |
---|
51 | /// <summary> |
---|
52 | /// Gets the element variable. |
---|
53 | /// </summary> |
---|
54 | public readonly IVariable ElementVariable; |
---|
55 | |
---|
56 | /// <summary> |
---|
57 | /// Gets the Current property on the IEnumerator. |
---|
58 | /// Returns null if the property is not found. |
---|
59 | /// </summary> |
---|
60 | public readonly IProperty CurrentProperty; |
---|
61 | |
---|
62 | /// <summary> |
---|
63 | /// Gets the MoveNext() method on the IEnumerator. |
---|
64 | /// Returns null if the method is not found. |
---|
65 | /// </summary> |
---|
66 | public readonly IMethod MoveNextMethod; |
---|
67 | |
---|
68 | public ForEachResolveResult(ResolveResult getEnumeratorCall, IType collectionType, IType enumeratorType, IType elementType, IVariable elementVariable, IProperty currentProperty, IMethod moveNextMethod, IType voidType) |
---|
69 | : base(voidType) |
---|
70 | { |
---|
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; |
---|
88 | } |
---|
89 | } |
---|
90 | } |
---|