Fix XMM scanning on Mac x86.
[mono.git] / mcs / class / dlr / Runtime / Microsoft.Scripting.Core / Actions / InvokeMemberBinder.cs
1 /* ****************************************************************************
2  *
3  * Copyright (c) Microsoft Corporation. 
4  *
5  * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
6  * copy of the license can be found in the License.html file at the root of this distribution. If 
7  * you cannot locate the  Apache License, Version 2.0, please send an email to 
8  * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
9  * by the terms of the Apache License, Version 2.0.
10  *
11  * You must not remove this notice, or any other, from this software.
12  *
13  *
14  * ***************************************************************************/
15
16 using System.Dynamic.Utils;
17
18 namespace System.Dynamic {
19
20     /// <summary>
21     /// Represents the invoke member dynamic operation at the call site,
22     /// providing the binding semantic and the details about the operation.
23     /// </summary>
24     public abstract class InvokeMemberBinder : DynamicMetaObjectBinder {
25         private readonly string _name;
26         private readonly bool _ignoreCase;
27         private readonly CallInfo _callInfo;
28
29         /// <summary>
30         /// Initializes a new instance of the <see cref="InvokeMemberBinder" />.
31         /// </summary>
32         /// <param name="name">The name of the member to invoke.</param>
33         /// <param name="ignoreCase">true if the name should be matched ignoring case; false otherwise.</param>
34         /// <param name="callInfo">The signature of the arguments at the call site.</param>
35         protected InvokeMemberBinder(string name, bool ignoreCase, CallInfo callInfo) {
36             ContractUtils.RequiresNotNull(name, "name");
37             ContractUtils.RequiresNotNull(callInfo, "callInfo");
38
39             _name = name;
40             _ignoreCase = ignoreCase;
41             _callInfo = callInfo;
42         }
43
44         /// <summary>
45         /// The result type of the operation.
46         /// </summary>
47         public override sealed Type ReturnType {
48             get { return typeof(object); }
49         }
50
51         /// <summary>
52         /// Gets the name of the member to invoke.
53         /// </summary>
54         public string Name {
55             get {
56                 return _name;
57             }
58         }
59
60         /// <summary>
61         /// Gets the value indicating if the string comparison should ignore the case of the member name.
62         /// </summary>
63         public bool IgnoreCase {
64             get {
65                 return _ignoreCase;
66             }
67         }
68
69         /// <summary>
70         /// Gets the signature of the arguments at the call site.
71         /// </summary>
72         public CallInfo CallInfo {
73             get { return _callInfo; }
74         }
75
76         /// <summary>
77         /// Performs the binding of the dynamic invoke member operation.
78         /// </summary>
79         /// <param name="target">The target of the dynamic invoke member operation.</param>
80         /// <param name="args">An array of arguments of the dynamic invoke member operation.</param>
81         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
82         public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) {
83             ContractUtils.RequiresNotNull(target, "target");
84             ContractUtils.RequiresNotNullItems(args, "args");
85
86             return target.BindInvokeMember(this, args);
87         }
88
89         // this is a standard DynamicMetaObjectBinder
90         internal override sealed bool IsStandardBinder {
91             get {
92                 return true;
93             }
94         }
95
96         /// <summary>
97         /// Performs the binding of the dynamic invoke member operation if the target dynamic object cannot bind.
98         /// </summary>
99         /// <param name="target">The target of the dynamic invoke member operation.</param>
100         /// <param name="args">The arguments of the dynamic invoke member operation.</param>
101         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
102         public DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args) {
103             return FallbackInvokeMember(target, args, null);
104         }
105
106         /// <summary>
107         /// When overridden in the derived class, performs the binding of the dynamic invoke member operation if the target dynamic object cannot bind.
108         /// </summary>
109         /// <param name="target">The target of the dynamic invoke member operation.</param>
110         /// <param name="args">The arguments of the dynamic invoke member operation.</param>
111         /// <param name="errorSuggestion">The binding result to use if binding fails, or null.</param>
112         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
113         public abstract DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion);
114
115         /// <summary>
116         /// When overridden in the derived class, performs the binding of the dynamic invoke operation if the target dynamic object cannot bind.
117         /// </summary>
118         /// <param name="target">The target of the dynamic invoke operation.</param>
119         /// <param name="args">The arguments of the dynamic invoke operation.</param>
120         /// <param name="errorSuggestion">The binding result to use if binding fails, or null.</param>
121         /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
122         /// <remarks>
123         /// This method is called by the target when the target implements the invoke member operation
124         /// as a sequence of get member, and invoke, to let the <see cref="DynamicMetaObject"/>
125         /// request the binding of the invoke operation only.
126         /// </remarks>
127         public abstract DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion);
128     }
129 }