Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2893_BNLR/HeuristicLab.ExtLibs/HeuristicLab.NRefactory/5.5.0/NRefactory.CSharp-5.5.0/Resolver/DynamicInvocationResolveResult.cs

Last change on this file was 11700, checked in by jkarder, 10 years ago

#2077: created branch and added first version

File size: 3.6 KB
Line 
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
19using System;
20using System.Collections.Generic;
21using System.Globalization;
22using System.Linq;
23using ICSharpCode.NRefactory.Semantics;
24using ICSharpCode.NRefactory.TypeSystem;
25
26namespace ICSharpCode.NRefactory.CSharp.Resolver
27{
28  public enum DynamicInvocationType {
29    /// <summary>
30    /// The invocation is a normal invocation ( 'a(b)' ).
31    /// </summary>
32    Invocation,
33
34    /// <summary>
35    /// The invocation is an indexing ( 'a[b]' ).
36    /// </summary>
37    Indexing,
38
39    /// <summary>
40    /// The invocation is an object creation ( 'new a(b)' ). Also used when invoking a base constructor ( ' : base(a) ' ) and chaining constructors ( ' : this(a) ').
41    /// </summary>
42    ObjectCreation,
43  }
44
45  /// <summary>
46  /// Represents the result of an invocation of a member of a dynamic object.
47  /// </summary>
48  public class DynamicInvocationResolveResult : ResolveResult
49  {
50    /// <summary>
51    /// Target of the invocation. Can be a dynamic expression or a <see cref="MethodGroupResolveResult"/>.
52    /// </summary>
53    public readonly ResolveResult Target;
54
55    /// <summary>
56    /// Type of the invocation.
57    /// </summary>
58    public readonly DynamicInvocationType InvocationType;
59
60    /// <summary>
61    /// Arguments for the call. Named arguments will be instances of <see cref="NamedArgumentResolveResult"/>.
62    /// </summary>
63    public readonly IList<ResolveResult> Arguments;
64
65    /// <summary>
66    /// Gets the list of initializer statements that are appplied to the result of this invocation.
67    /// This is used to represent object and collection initializers.
68    /// With the initializer statements, the <see cref="InitializedObjectResolveResult"/> is used
69    /// to refer to the result of this invocation.
70    /// Initializer statements can only exist if the <see cref="InvocationType"/> is <see cref="DynamicInvocationType.ObjectCreation"/>.
71    /// </summary>
72    public readonly IList<ResolveResult> InitializerStatements;
73
74    public DynamicInvocationResolveResult(ResolveResult target, DynamicInvocationType invocationType, IList<ResolveResult> arguments, IList<ResolveResult> initializerStatements = null) : base(SpecialType.Dynamic) {
75      this.Target                = target;
76      this.InvocationType        = invocationType;
77      this.Arguments             = arguments ?? EmptyList<ResolveResult>.Instance;
78      this.InitializerStatements = initializerStatements ?? EmptyList<ResolveResult>.Instance;
79    }
80
81    public override string ToString()
82    {
83      return string.Format(CultureInfo.InvariantCulture, "[Dynamic invocation ]");
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.