edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1594104 File: RubyTests.cs =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C1594104 (server) 2/16/2010 3:19 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;InteropFix @@ -747,6 +747,7 @@ Dlr_Methods, Dlr_Visibility, Dlr_Languages, + Dlr_DynamicObject1, Serialization1, }; =================================================================== edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/DlrInteropTests.cs;C1240182 File: DlrInteropTests.cs =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/DlrInteropTests.cs;C1240182 (server) 2/16/2010 3:18 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/DlrInteropTests.cs;InteropFix @@ -847,6 +847,39 @@ //# Pass in ref/out params //# Named arguments } + + public class DynamicObject1 : DynamicObject { + public string Test() { + return "Hello, Test"; + } + + public override IEnumerable GetDynamicMemberNames() { + return new string[] { "Test2", "Test3" }; + } + + public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { + result = "Invoke Member " + binder.Name; + return true; + } + + public override bool TryInvoke(InvokeBinder binder, object[] args, out object result) { + result = "Invoke"; + return true; + } + } + + public void Dlr_DynamicObject1() { + Context.ObjectClass.SetConstant("C", new DynamicObject1()); + TestOutput(@" +p C.Test2 +p C.call +p C.methods(false) +", @" +'Invoke Member Test2' +'Invoke' +['test2', 'test3'] +"); + } } } =================================================================== edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Win32API/Win32API.cs;C1438355 File: Win32API.cs =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Win32API/Win32API.cs;C1438355 (server) 2/16/2010 5:08 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Win32API/Win32API.cs;InteropFix @@ -309,7 +309,7 @@ } return Methods.GetMutableStringBytes.OpCall( - Ast.Dynamic(ConvertToStrAction.Make(_context), typeof(MutableString), arg.Expression) + AstUtils.LightDynamic(ConvertToStrAction.Make(_context), typeof(MutableString), arg.Expression) ); case ArgType.Int32: @@ -319,7 +319,7 @@ return Ast.Convert( Ast.Call( - Ast.Dynamic(ConvertToIntAction.Make(_context), typeof(IntegerValue), arg.Expression), + AstUtils.LightDynamic(ConvertToIntAction.Make(_context), typeof(IntegerValue), arg.Expression), Methods.IntegerValue_ToUInt32Unchecked ), typeof(int) =================================================================== edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;C1586787 File: Utils.cs =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;C1586787 (server) 2/16/2010 5:00 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;InteropFix @@ -13,6 +13,12 @@ * * ***************************************************************************/ +#if !CLR2 +using System.Linq.Expressions; +#else +using Microsoft.Scripting.Ast; +#endif + using System; using Microsoft.Scripting.Utils; using System.Diagnostics; @@ -22,6 +28,7 @@ using System.Collections.Generic; using IronRuby.Builtins; using System.Globalization; +using System.Dynamic; namespace IronRuby.Runtime { public static class Utils { @@ -482,6 +489,11 @@ return str.ToLower(CultureInfo.InvariantCulture); } #endif + internal static IEnumerable/*!*/ ToExpressions(this IEnumerable/*!*/ metaObjects) { + foreach (var metaObject in metaObjects) { + yield return metaObject != null ? metaObject.Expression : null; + } + } } } =================================================================== edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/InteropBinder.cs;C1594104 File: InteropBinder.cs =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/InteropBinder.cs;C1594104 (server) 2/16/2010 3:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/InteropBinder.cs;InteropFix @@ -218,14 +218,13 @@ public override DynamicMetaObject/*!*/ FallbackInvoke(DynamicMetaObject/*!*/ target, DynamicMetaObject/*!*/[]/*!*/ args, DynamicMetaObject errorSuggestion) { - var exprs = RubyBinder.ToExpressions(args, -1); - exprs[0] = target.Expression; + AstExpressions exprs = new AstExpressions(); + exprs.Add(target.Expression); + exprs.Add(args.ToExpressions()); return new DynamicMetaObject( - Expression.Dynamic(_context.MetaBinderFactory.InteropReturn(CallInfo), typeof(object), exprs), - target.Restrictions.Merge(BindingRestrictions.Combine(args)). - // TODO: ??? - Merge(BindingRestrictions.GetTypeRestriction(target.Expression, target.GetLimitType())) + AstUtils.LightDynamic(_context.MetaBinderFactory.InteropReturn(CallInfo), typeof(object), exprs), + target.Restrictions.Merge(BindingRestrictions.Combine(args)) ); } @@ -439,16 +438,16 @@ Expression.Condition( Expression.AndAlso( Expression.Equal( - Expression.Dynamic(_tryGetMember, typeof(object), target.Expression), + AstUtils.LightDynamic(_tryGetMember, typeof(object), target.Expression), Expression.Constant(OperationFailed.Value) ), Expression.NotEqual( - Expression.Dynamic(_tryGetMemberUnmangled, typeof(object), target.Expression), + AstUtils.LightDynamic(_tryGetMemberUnmangled, typeof(object), target.Expression), Expression.Constant(OperationFailed.Value) ) ), - Expression.Dynamic(_setMemberUnmangled, typeof(object), target.Expression, args[0].Expression), - Expression.Dynamic(_setMember, typeof(object), target.Expression, args[0].Expression) + AstUtils.LightDynamic(_setMemberUnmangled, typeof(object), target.Expression, args[0].Expression), + AstUtils.LightDynamic(_setMember, typeof(object), target.Expression, args[0].Expression) ), target.Restrict(CompilerHelpers.GetType(target.Value)).Restrictions ); @@ -646,12 +645,10 @@ Debug.Assert(args.Length > 1); var exprs = new AstExpressions(); - exprs.Add(Expression.Dynamic(_getMember, typeof(object), target.Expression)); - for (int i = 0; i < args.Length; i++) { - exprs.Add(args[i].Expression); - } + exprs.Add(AstUtils.LightDynamic(_getMember, typeof(object), target.Expression)); + exprs.Add(args.ToExpressions()); - return new DynamicMetaObject(Expression.Dynamic(_setIndex, typeof(object), exprs), BindingRestrictions.Empty); + return new DynamicMetaObject(AstUtils.LightDynamic(_setIndex, typeof(object), exprs), BindingRestrictions.Empty); } #endregion @@ -791,16 +788,7 @@ return "Interop.Splat" + (_context != null ? " @" + Context.RuntimeId.ToString() : null); } } - - // TODO: remove - internal static DynamicMetaObject/*!*/ CreateErrorMetaObject(this DynamicMetaObjectBinder binder, DynamicMetaObject/*!*/ target, DynamicMetaObject/*!*/[]/*!*/ args, - DynamicMetaObject errorSuggestion) { - return errorSuggestion ?? new DynamicMetaObject( - Expression.Throw(Expression.New(typeof(NotImplementedException)), binder.ReturnType), - target.Restrictions.Merge(BindingRestrictions.Combine(args)) - ); - } - + // TODO: convert binder internal static DynamicMetaObject TryBindCovertToDelegate(RubyMetaObject/*!*/ target, ConvertBinder/*!*/ binder, MethodInfo/*!*/ delegateFactory) { var metaBuilder = new MetaObjectBuilder(target); =================================================================== edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyBinder.cs;C1475764 File: RubyBinder.cs =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyBinder.cs;C1475764 (server) 2/16/2010 4:47 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyBinder.cs;InteropFix @@ -29,6 +29,7 @@ using IronRuby.Runtime.Conversions; using System.Reflection; using System.Runtime.CompilerServices; +using System.Collections.Generic; namespace IronRuby.Runtime.Calls { public sealed class RubyBinder : DefaultBinder { @@ -71,15 +72,6 @@ #region MetaObjects // negative start reserves as many slots at the beginning of the new array: - internal static Expression/*!*/[]/*!*/ ToExpressions(DynamicMetaObject/*!*/[]/*!*/ args, int start) { - var result = new Expression[args.Length - start]; - for (int i = Math.Max(0, -start); i < result.Length; i++) { - result[i] = args[start + i].Expression; - } - return result; - } - - // negative start reserves as many slots at the beginning of the new array: internal static object/*!*/[]/*!*/ ToValues(DynamicMetaObject/*!*/[]/*!*/ args, int start) { var result = new object[args.Length - start]; for (int i = Math.Max(0, -start); i < result.Length; i++) { =================================================================== edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyScopeMethodMissingInfo.cs;C1594104 File: RubyScopeMethodMissingInfo.cs =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyScopeMethodMissingInfo.cs;C1594104 (server) 2/16/2010 5:07 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyScopeMethodMissingInfo.cs;InteropFix @@ -65,7 +65,7 @@ var globalScope = args.TargetClass.GlobalScope; // TODO: this just calls super for now, so it doesn't look up the scope: - metaBuilder.Result = Ast.Dynamic( + metaBuilder.Result = AstUtils.LightDynamic( new RubyCallAction(globalScope.Context, Symbols.MethodMissing, new RubyCallSignature( args.Signature.ArgumentCount, =================================================================== edit: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Scripts/ircoverage.bat;C1586787 File: ircoverage.bat =================================================================== --- $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Scripts/ircoverage.bat;C1586787 (server) 2/16/2010 3:27 PM +++ Shelved Change: $/Dev10/feature/vs_langs01_s/Merlin/Main/Languages/Ruby/Scripts/ircoverage.bat;InteropFix @@ -9,7 +9,8 @@ xcopy /s /y "%SRC%\IronPython*" "%DST%" xcopy /s /y "%SRC%\Microsoft.*.dll" "%DST%" -%VSINSTR% "%SRC%\IronRuby.dll" +rem Instrumenting DetectFileAccessPermissions fails. See TFS bug #380474. +%VSINSTR% "%SRC%\IronRuby.dll" /EXCLUDE:IronRuby.Runtime.RubyExceptionData::DetectFileAccessPermissions %VSINSTR% "%SRC%\IronRuby.Libraries.dll" %VSINSTR% "%SRC%\IronRuby.Libraries.Yaml.dll" ===================================================================