diff options
author | Marek Safar <marek.safar@gmail.com> | 2009-08-10 17:12:58 +0400 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2009-08-10 17:12:58 +0400 |
commit | e92a799182095092d27b485271c809efecd7cdd1 (patch) | |
tree | c916c1606528b2e1f857c1f8415b5179901a7030 /mcs | |
parent | aae196a7f4337cde9fe556ccd7015934e6cad5cb (diff) |
2009-08-10 Marek Safar <marek.safar@gmail.com>
* CSharpInvokeBinder.cs, CSharpGetMemberBinder.cs,
CSharpInvokeMemberBinder.cs: Defer fallback for now.
svn path=/trunk/mcs/; revision=139638
Diffstat (limited to 'mcs')
6 files changed, 65 insertions, 8 deletions
diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs new file mode 100644 index 00000000000..f9bcfa710a8 --- /dev/null +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs @@ -0,0 +1,52 @@ +// +// CSharpBinder.cs +// +// Authors: +// Marek Safar <marek.safar@gmail.com> +// +// Copyright (C) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Dynamic; +using System.Linq.Expressions; + +namespace Microsoft.CSharp.RuntimeBinder +{ + class CSharpBinder + { + public static DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject errorSuggestion, DynamicMetaObject[] args) + { + return Bind (target, errorSuggestion); + } + + public static DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject errorSuggestion) + { + return errorSuggestion ?? + new DynamicMetaObject( + Expression.Constant(new object ()), + target.Restrictions.Merge( + BindingRestrictions.GetTypeRestriction( + target.Expression, target.LimitType))); + } + } +} diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpGetMemberBinder.cs b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpGetMemberBinder.cs index 152b3cfd7c8..d66ad0ed042 100644 --- a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpGetMemberBinder.cs +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpGetMemberBinder.cs @@ -69,10 +69,9 @@ namespace Microsoft.CSharp.RuntimeBinder return base.GetHashCode (); } - [MonoTODO] public override DynamicMetaObject FallbackGetMember (DynamicMetaObject target, DynamicMetaObject errorSuggestion) { - throw new NotImplementedException (); + return CSharpBinder.Bind (target, errorSuggestion); } } } diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeBinder.cs b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeBinder.cs index 2f81f144bfa..a4e46f05587 100644 --- a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeBinder.cs +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeBinder.cs @@ -77,10 +77,9 @@ namespace Microsoft.CSharp.RuntimeBinder return base.GetHashCode (); } - [MonoTODO] public override DynamicMetaObject FallbackInvoke (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) { - throw new NotImplementedException (); + return CSharpBinder.Bind (target, errorSuggestion, args); } } } diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeMemberBinder.cs b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeMemberBinder.cs index 15e57c5c2bb..0c8b9c503e7 100644 --- a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeMemberBinder.cs +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeMemberBinder.cs @@ -79,16 +79,17 @@ namespace Microsoft.CSharp.RuntimeBinder return base.GetHashCode (); } - [MonoTODO] public override DynamicMetaObject FallbackInvoke (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) { - throw new NotImplementedException (); + var b = new CSharpInvokeBinder (flags, callingContext, argumentInfo); + + // TODO: Is errorSuggestion ever used? + return b.Defer (target, args); } - [MonoTODO] public override DynamicMetaObject FallbackInvokeMember (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion) { - throw new NotImplementedException (); + return CSharpBinder.Bind (target, errorSuggestion, args); } public IList<Type> TypeArguments { diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/ChangeLog b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/ChangeLog index 79a2633dac7..bd64be890e0 100644 --- a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/ChangeLog +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/ChangeLog @@ -1,3 +1,8 @@ +2009-08-10 Marek Safar <marek.safar@gmail.com> + + * CSharpInvokeBinder.cs, CSharpGetMemberBinder.cs, + CSharpInvokeMemberBinder.cs: Defer fallback for now. + 2009-08-07 Marek Safar <marek.safar@gmail.com> * CSharpInvokeBinder.cs, CSharpGetIndexBinder.cs, Extensions.cs, diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.dll.sources b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.dll.sources index 2d6ec6e3069..7c4756a703a 100644 --- a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.dll.sources +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.dll.sources @@ -19,3 +19,4 @@ Microsoft.CSharp.RuntimeBinder/CSharpUnaryOperationBinder.cs Microsoft.CSharp.RuntimeBinder/Extensions.cs Microsoft.CSharp.RuntimeBinder/RuntimeBinderException.cs Microsoft.CSharp.RuntimeBinder/RuntimeBinderInternalCompilerException.cs +Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs |