From e92a799182095092d27b485271c809efecd7cdd1 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 10 Aug 2009 13:12:58 +0000 Subject: [PATCH] 2009-08-10 Marek Safar * CSharpInvokeBinder.cs, CSharpGetMemberBinder.cs, CSharpInvokeMemberBinder.cs: Defer fallback for now. svn path=/trunk/mcs/; revision=139638 --- .../CSharpBinder.cs | 52 +++++++++++++++++++ .../CSharpGetMemberBinder.cs | 3 +- .../CSharpInvokeBinder.cs | 3 +- .../CSharpInvokeMemberBinder.cs | 9 ++-- .../Microsoft.CSharp.RuntimeBinder/ChangeLog | 5 ++ .../Microsoft.CSharp.dll.sources | 1 + 6 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs 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 0000000000000..f9bcfa710a81f --- /dev/null +++ b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs @@ -0,0 +1,52 @@ +// +// CSharpBinder.cs +// +// Authors: +// Marek Safar +// +// 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 152b3cfd7c83d..d66ad0ed042ca 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 @@ public override int GetHashCode () 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 2f81f144bfa81..a4e46f055873d 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 @@ public override int GetHashCode () 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 15e57c5c2bb62..0c8b9c503e7f1 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 @@ public override int GetHashCode () 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 TypeArguments { diff --git a/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/ChangeLog b/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/ChangeLog index 79a2633dac744..bd64be890e0b2 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 + + * CSharpInvokeBinder.cs, CSharpGetMemberBinder.cs, + CSharpInvokeMemberBinder.cs: Defer fallback for now. + 2009-08-07 Marek Safar * 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 2d6ec6e30698b..7c4756a703a17 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