Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2009-08-06 18:51:39 +0400
committerMarek Safar <marek.safar@gmail.com>2009-08-06 18:51:39 +0400
commit3de7d1eb70167bb3bc2d2ed08ca8c2eadca230c4 (patch)
tree5db83b2d6a69ecf80ef68f806967e62dafded503 /mcs/class/dlr
parent57e4b484caea9e26fe63b684f3ad8bc1c1bc9b07 (diff)
2009-08-04 Marek Safar <marek.safar@gmail.com>
* Updated to r26623. svn path=/trunk/mcs/; revision=139498
Diffstat (limited to 'mcs/class/dlr')
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/BoundDispEvent.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/ComBinder.cs27
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSink.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinkProxy.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinksContainer.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/ComObject.cs2
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/ComRuntimeHelpers.cs40
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/DispCallableMetaObject.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Errors.cs2
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/IDispatchComObject.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.Build.csproj152
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj11
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs6
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Variant.cs66
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallInfo.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSite.cs21
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteBinder.cs7
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObject.cs5
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObjectBinder.cs20
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoObject.cs53
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BinaryExpression.cs41
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BlockExpression.cs25
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/CatchBlock.cs20
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConditionalExpression.cs25
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs9
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugInfoExpression.cs11
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DefaultExpression.cs5
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DynamicExpression.cs24
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ElementInit.cs18
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs32
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionVisitor.cs236
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/GotoExpression.cs24
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/IndexExpression.cs24
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/InvocationExpression.cs25
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelExpression.cs20
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs58
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ListInitExpression.cs24
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LoopExpression.cs25
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberAssignment.cs18
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberExpression.cs23
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberInitExpression.cs20
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberListBinding.cs18
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberMemberBinding.cs18
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MethodCallExpression.cs24
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewArrayExpression.cs26
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewExpression.cs26
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ParameterExpression.cs9
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/RuntimeVariablesExpression.cs19
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchCase.cs15
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchExpression.cs25
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TryExpression.cs26
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeBinaryExpression.cs26
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeUtils.cs44
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs23
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/BoundConstants.cs6
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/CompilerScope.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DebugInfoGenerator.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.Generated.cs5
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/ILGen.cs6
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/KeyedQueue.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LabelInfo.cs6
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Binary.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Expressions.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Logical.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Statements.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Unary.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.cs12
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/OffsetTrackingILGenerator.cs12
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Bindings.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolDocumentGenerator.cs17
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/VariableBinder.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.Core.csproj17
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.ExtensionAttribute.csproj10
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Properties/AssemblyInfo.cs2
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Stubs.cs7
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Action.cs6
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/CollectionExtensions.cs9
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ContractUtils.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ExceptionFactory.Generated.cs16
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Function.cs6
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyCollectionBuilder.cs11
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyDictionary.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/TypeExtensions.cs7
84 files changed, 1275 insertions, 378 deletions
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/BoundDispEvent.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/BoundDispEvent.cs
index 7569a74d1d6..ca907a66dfa 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/BoundDispEvent.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/BoundDispEvent.cs
@@ -85,7 +85,7 @@ namespace Microsoft.Scripting {
/// </summary>
/// <param name="handler">The handler to be added.</param>
/// <returns>The original event with handler added.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -110,7 +110,7 @@ namespace Microsoft.Scripting {
/// </summary>
/// <param name="handler">The handler to be removed.</param>
/// <returns>The original event with handler removed.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComBinder.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComBinder.cs
index 3a7d606d2b8..b923b531604 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComBinder.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComBinder.cs
@@ -42,7 +42,12 @@ namespace Microsoft.Scripting {
/// <summary>
/// Provides helper methods to bind COM objects dynamically.
/// </summary>
- public static class ComBinder {
+#if MICROSOFT_DYNAMIC
+ public
+#else
+ internal
+#endif
+ static class ComBinder {
/// <summary>
/// Determines if an object is a COM object.
@@ -61,7 +66,7 @@ namespace Microsoft.Scripting {
/// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
/// <param name="delayInvocation">true if member evaluation may be delayed.</param>
/// <returns>true if operation was bound successfully; otherwise, false.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -111,7 +116,7 @@ namespace Microsoft.Scripting {
/// <param name="value">The <see cref="DynamicMetaObject"/> representing the value for the set member operation.</param>
/// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
/// <returns>true if operation was bound successfully; otherwise, false.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -144,7 +149,7 @@ namespace Microsoft.Scripting {
/// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke member operation.</param>
/// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
/// <returns>true if operation was bound successfully; otherwise, false.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -177,7 +182,7 @@ namespace Microsoft.Scripting {
/// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke member operation.</param>
/// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
/// <returns>true if operation was bound successfully; otherwise, false.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -210,7 +215,7 @@ namespace Microsoft.Scripting {
/// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke member operation.</param>
/// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
/// <returns>true if operation was bound successfully; otherwise, false.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -244,7 +249,7 @@ namespace Microsoft.Scripting {
/// <param name="value">The <see cref="DynamicMetaObject"/> representing the value for the set index operation.</param>
/// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
/// <returns>true if operation was bound successfully; otherwise, false.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -277,7 +282,7 @@ namespace Microsoft.Scripting {
/// <param name="instance">The target of the dynamic operation.</param>
/// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
/// <returns>true if operation was bound successfully; otherwise, false.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -322,7 +327,7 @@ namespace Microsoft.Scripting {
/// </summary>
/// <param name="value">The object for which member names are requested.</param>
/// <returns>The collection of member names.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -346,7 +351,7 @@ namespace Microsoft.Scripting {
/// </summary>
/// <param name="value">The object for which member names are requested.</param>
/// <returns>The collection of member names.</returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -374,7 +379,7 @@ namespace Microsoft.Scripting {
/// <returns>The collection of pairs that represent data member's names and their data.</returns>
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSink.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSink.cs
index 8acec9bec9e..db80b91ef92 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSink.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSink.cs
@@ -278,7 +278,7 @@ namespace Microsoft.Scripting {
#region IDisposable
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -290,7 +290,7 @@ namespace Microsoft.Scripting {
#endregion
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinkProxy.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinkProxy.cs
index 032bc1efa39..f56f0ecfc4c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinkProxy.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinkProxy.cs
@@ -75,7 +75,7 @@ namespace Microsoft.Scripting {
#region Base Class Overrides
-#if MICROSOFT_DYNAMIC
+#if CLR2
// to match the base method
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
#else
@@ -93,7 +93,7 @@ namespace Microsoft.Scripting {
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
-#if MICROSOFT_DYNAMIC
+#if CLR2
// to match the base method
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinksContainer.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinksContainer.cs
index 1f3fbe54378..85611833aef 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinksContainer.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComEventSinksContainer.cs
@@ -65,7 +65,7 @@ namespace Microsoft.Scripting {
#region IDisposable Members
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -84,7 +84,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComObject.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComObject.cs
index 0860ae04bb5..c562fda78f4 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComObject.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComObject.cs
@@ -61,7 +61,7 @@ namespace Microsoft.Scripting {
/// This is the factory method to get the ComObject corresponding to an RCW
/// </summary>
/// <returns></returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComRuntimeHelpers.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComRuntimeHelpers.cs
index be0f036363b..9cf6b700e70 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComRuntimeHelpers.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/ComRuntimeHelpers.cs
@@ -34,7 +34,7 @@ namespace Microsoft.Scripting {
internal static class ComRuntimeHelpers {
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -263,7 +263,7 @@ namespace Microsoft.Scripting {
// *** BEGIN GENERATED CODE ***
// generated by function: gen_ConvertByrefToPtr from: generate_comdispatch.py
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -275,7 +275,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -287,7 +287,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -299,7 +299,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -311,7 +311,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -323,7 +323,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -335,7 +335,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -347,7 +347,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -359,7 +359,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -371,7 +371,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -383,7 +383,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -395,7 +395,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -407,7 +407,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -424,7 +424,7 @@ namespace Microsoft.Scripting {
#endregion
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -436,7 +436,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -449,7 +449,7 @@ namespace Microsoft.Scripting {
return variant;
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -468,7 +468,7 @@ namespace Microsoft.Scripting {
System.Runtime.InteropServices.Marshal.GetNativeVariantForObject(obj, UnsafeMethods.ConvertVariantByrefToPtr(ref variant));
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -490,7 +490,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -534,7 +534,7 @@ namespace Microsoft.Scripting {
}
[Obsolete("do not use this method", true)]
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/DispCallableMetaObject.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/DispCallableMetaObject.cs
index 89ce41b3461..7a43abffb87 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/DispCallableMetaObject.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/DispCallableMetaObject.cs
@@ -48,7 +48,7 @@ namespace Microsoft.Scripting {
base.BindInvoke(binder, args);
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -73,7 +73,7 @@ namespace Microsoft.Scripting {
return null;
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Errors.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Errors.cs
index 29029fda99c..6850a675704 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Errors.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Errors.cs
@@ -22,7 +22,7 @@ namespace System.Dynamic {
namespace Microsoft.Scripting {
#endif
-#if MICROSOFT_DYNAMIC
+#if true
internal static partial class Strings {
private static string FormatString(string format, params object[] args) {
return string.Format(System.Globalization.CultureInfo.CurrentCulture, format, args);
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/IDispatchComObject.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/IDispatchComObject.cs
index 0b18e39c2b5..bd5f4b2fdb5 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/IDispatchComObject.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/IDispatchComObject.cs
@@ -352,7 +352,7 @@ namespace Microsoft.Scripting {
funcDescHandle = pFuncDesc;
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
@@ -515,7 +515,7 @@ namespace Microsoft.Scripting {
return typeInfoCoClass;
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[SecurityCritical, SecurityTreatAsSafe]
#else
[SecuritySafeCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.Build.csproj b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.Build.csproj
new file mode 100644
index 00000000000..776fa696bd8
--- /dev/null
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.Build.csproj
@@ -0,0 +1,152 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+
+
+
+ <PropertyGroup>
+ <OutputType>Library</OutputType>
+ <RootNamespace>Microsoft.Dynamic</RootNamespace>
+ <AssemblyName>Microsoft.Dynamic</AssemblyName>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>pdbonly</DebugType>
+ <BinPlaceSymbols>false</BinPlaceSymbols>
+ <RunCodeAnalysis>false</RunCodeAnalysis>
+ <GenerateAssemblyAttribute>false</GenerateAssemblyAttribute>
+<OutputPath>$(SolutionDir)\..\Bin\40\</OutputPath>
+<AssemblyOriginatorKeyFile>$(SolutionDir)\Runtime\MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
+ <SignAssembly Condition="'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')">true</SignAssembly>
+ <SignedSym Condition="'$(SignAssembly)' == 'true'">SIGNED</SignedSym>
+ <DelaySign>true</DelaySign>
+ <DefineConstants>MICROSOFT_DYNAMIC;$(SignedSym)</DefineConstants>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}</ProjectGuid>
+
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>$(SolutionDir)\..\Bin\40\</OutputPath>
+ <DefineConstants>DEBUG;TRACE;CODEPLEX_40;SYSTEM_CORE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>$(SolutionDir)\..\Bin\40\</OutputPath>
+ <DefineConstants>TRACE;CODEPLEX_40;SYSTEM_CORE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="mscorlib" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <TextStringResource Include="System.Dynamic.txt">
+ <ResFile>System.Dynamic</ResFile>
+ <Sealed>true</Sealed>
+ <Visibility>internal</Visibility>
+ <GenerateResource>true</GenerateResource>
+ <FullClassName>System.Dynamic.SR</FullClassName>
+ <Parameterize>true</Parameterize>
+ </TextStringResource>
+ </ItemGroup>
+ <!-- Begin Generated Project Items By GenerateSystemCoreCsproj.py -->
+ <ItemGroup>
+ <!-- -->
+ <!-- -->
+ <!-- -->
+ <Compile Include="ArgBuilder.cs" />
+ <Compile Include="Assert.cs" />
+ <Compile Include="BoolArgBuilder.cs" />
+ <Compile Include="BoundDispEvent.cs" />
+ <Compile Include="CollectionExtensions.cs" />
+ <Compile Include="ComBinder.cs" />
+ <Compile Include="ComBinderHelpers.cs" />
+ <Compile Include="ComDispIds.cs" />
+ <Compile Include="ComEventDesc.cs" />
+ <Compile Include="ComEventSink.cs" />
+ <Compile Include="ComEventSinkProxy.cs" />
+ <Compile Include="ComEventSinksContainer.cs" />
+ <Compile Include="ComFallbackMetaObject.cs" />
+ <Compile Include="ComHresults.cs" />
+ <Compile Include="ComInterop.cs" />
+ <Compile Include="ComInvokeAction.cs" />
+ <Compile Include="ComInvokeBinder.cs" />
+ <Compile Include="ComMetaObject.cs" />
+ <Compile Include="ComMethodDesc.cs" />
+ <Compile Include="ComObject.cs" />
+ <Compile Include="ComRuntimeHelpers.cs" />
+ <Compile Include="ComTypeClassDesc.cs" />
+ <Compile Include="ComTypeDesc.cs" />
+ <Compile Include="ComTypeEnumDesc.cs" />
+ <Compile Include="ComTypeLibDesc.cs" />
+ <Compile Include="ContractUtils.cs" />
+ <Compile Include="ConversionArgBuilder.cs" />
+ <Compile Include="ConvertArgBuilder.cs" />
+ <Compile Include="ConvertibleArgBuilder.cs" />
+ <Compile Include="CurrencyArgBuilder.cs" />
+ <Compile Include="DateTimeArgBuilder.cs" />
+ <Compile Include="DispatchArgBuilder.cs" />
+ <Compile Include="DispCallable.cs" />
+ <Compile Include="DispCallableMetaObject.cs" />
+ <Compile Include="ErrorArgBuilder.cs" />
+ <Compile Include="ExcepInfo.cs" />
+ <Compile Include="Helpers.cs" />
+ <Compile Include="IDispatchComObject.cs" />
+ <Compile Include="IDispatchMetaObject.cs" />
+ <Compile Include="NullArgBuilder.cs" />
+ <Compile Include="SimpleArgBuilder.cs" />
+ <Compile Include="SplatCallSite.cs" />
+ <Compile Include="StringArgBuilder.cs" />
+ <Compile Include="TypeUtils.cs" />
+ <Compile Include="UnknownArgBuilder.cs" />
+ <Compile Include="VarEnumSelector.cs" />
+ <Compile Include="Variant.cs" />
+ <Compile Include="VariantArgBuilder.cs" />
+ <Compile Include="VariantArray.cs" />
+ <Compile Include="VariantBuilder.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <!-- -->
+ <!-- Properties -->
+ <!-- -->
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Properties\GlobalSuppressions.cs" />
+ </ItemGroup>
+ <!-- End Generated Project Items By GenerateSystemCoreCsproj.py -->
+ <ItemGroup>
+ <Compile Include="Parameterized.System.Dynamic.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <DefineConstants>$(DefineConstants);PRODUCTION_BUILD</DefineConstants>
+ <PublishMetaAssemblyPath>$(InternalPath)\sdk\ref\WinFX\$(WINFX_REFS_VERSION)</PublishMetaAssemblyPath>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}</ProjectGuid>
+
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>$(SolutionDir)\..\Bin\40\</OutputPath>
+ <DefineConstants>DEBUG;TRACE;CODEPLEX_40;SYSTEM_CORE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>$(SolutionDir)\..\Bin\40\</OutputPath>
+ <DefineConstants>TRACE;CODEPLEX_40;SYSTEM_CORE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+</Project>
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj
index f799b702cdb..9d724e56ef2 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj
@@ -1,10 +1,10 @@
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>10.0.20624</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D4AE44AD-07B9-41DC-BB3B-1FDCDE3C987D}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -18,12 +18,13 @@
<SignAssembly Condition="'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')">true</SignAssembly>
<SignedSym Condition="'$(SignAssembly)' == 'true'">SIGNED</SignedSym>
<DelaySign>true</DelaySign>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FxCop|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>$(SolutionDir)\..\Bin\fxcop\</OutputPath>
- <DefineConstants>DEBUG;TRACE;$(SignedSym);MICROSOFT_DYNAMIC</DefineConstants>
+ <DefineConstants>DEBUG;TRACE;$(SignedSym);MICROSOFT_DYNAMIC;CLR2</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -38,7 +39,7 @@
<Optimize>false</Optimize>
<OutputPath>$(SolutionDir)\..\Bin\Debug\</OutputPath>
<DocumentationFile>$(OutputPath)\Microsoft.Dynamic.xml</DocumentationFile>
- <DefineConstants>DEBUG;TRACE;$(SignedSym);MICROSOFT_DYNAMIC</DefineConstants>
+ <DefineConstants>DEBUG;TRACE;$(SignedSym);MICROSOFT_DYNAMIC;CLR2</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -51,7 +52,7 @@
<Optimize>true</Optimize>
<OutputPath>$(SolutionDir)\..\Bin\Release\</OutputPath>
<DocumentationFile>$(OutputPath)\Microsoft.Dynamic.XML</DocumentationFile>
- <DefineConstants>TRACE;$(SignedSym);MICROSOFT_DYNAMIC</DefineConstants>
+ <DefineConstants>TRACE;$(SignedSym);MICROSOFT_DYNAMIC;CLR2</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs
index f7c7effa408..3e4cd76c101 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs
@@ -32,11 +32,11 @@ using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("Microsoft.Dynamic.ComInterop")]
+[assembly: AssemblyTitle("Microsoft.Dynamic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("Microsoft.Dynamic.ComInterop")]
+[assembly: AssemblyProduct("Microsoft.Dynamic")]
[assembly: AssemblyCopyright("� Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -59,7 +59,7 @@ using System.Security;
// by using the '*' as shown below:
[assembly: System.Resources.NeutralResourcesLanguage("en-US")]
-[assembly: AssemblyVersion("0.9.6.10")]
+[assembly: AssemblyVersion("0.9.6.20")]
[assembly: AssemblyFileVersion("1.0.0.00")]
[assembly: AssemblyInformationalVersion("1.0")]
[assembly: AllowPartiallyTrustedCallers]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Variant.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Variant.cs
index 1dfa33627ef..fbbccf001de 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Variant.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Variant.cs
@@ -173,7 +173,7 @@ namespace Microsoft.Scripting {
/// </summary>
/// <returns></returns>
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -226,7 +226,7 @@ namespace Microsoft.Scripting {
/// Release any unmanaged memory associated with the Variant
/// </summary>
/// <returns></returns>
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -275,7 +275,7 @@ namespace Microsoft.Scripting {
VariantType = VarEnum.VT_NULL;
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -328,7 +328,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -351,7 +351,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -374,7 +374,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -397,7 +397,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -420,7 +420,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -443,7 +443,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -466,7 +466,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -489,7 +489,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -512,7 +512,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -535,7 +535,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -558,7 +558,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -581,7 +581,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -604,7 +604,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -627,7 +627,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -655,7 +655,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -678,7 +678,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -701,7 +701,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -713,7 +713,7 @@ namespace Microsoft.Scripting {
// VT_BSTR
public String AsBstr {
- #if MICROSOFT_DYNAMIC
+ #if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -725,7 +725,7 @@ namespace Microsoft.Scripting {
return null;
}
}
- #if MICROSOFT_DYNAMIC
+ #if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -738,7 +738,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -750,7 +750,7 @@ namespace Microsoft.Scripting {
// VT_UNKNOWN
public Object AsUnknown {
- #if MICROSOFT_DYNAMIC
+ #if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -762,7 +762,7 @@ namespace Microsoft.Scripting {
return null;
}
}
- #if MICROSOFT_DYNAMIC
+ #if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -775,7 +775,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -787,7 +787,7 @@ namespace Microsoft.Scripting {
// VT_DISPATCH
public Object AsDispatch {
- #if MICROSOFT_DYNAMIC
+ #if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -799,7 +799,7 @@ namespace Microsoft.Scripting {
return null;
}
}
- #if MICROSOFT_DYNAMIC
+ #if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -812,7 +812,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -831,7 +831,7 @@ namespace Microsoft.Scripting {
// VT_VARIANT
public Object AsVariant {
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -839,7 +839,7 @@ namespace Microsoft.Scripting {
return Marshal.GetObjectForNativeVariant(UnsafeMethods.ConvertVariantByrefToPtr(ref this));
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -851,7 +851,7 @@ namespace Microsoft.Scripting {
}
}
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
@@ -862,7 +862,7 @@ namespace Microsoft.Scripting {
}
// constructs a ByRef variant to pass contents of another variant ByRef.
-#if MICROSOFT_DYNAMIC
+#if CLR2
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
#endif
[SecurityCritical]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallInfo.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallInfo.cs
index cf77f1ee12b..790d70520c7 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallInfo.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallInfo.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
using Microsoft.Linq.Expressions;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif //SILVERLIGHT
+
#if CODEPLEX_40
namespace System.Dynamic {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSite.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSite.cs
index 3158164274a..eb218e88089 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSite.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSite.cs
@@ -31,6 +31,10 @@ using Microsoft.Linq.Expressions.Compiler;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif //SILVERLIGHT
+
#if CODEPLEX_40
namespace System.Runtime.CompilerServices {
#else
@@ -109,15 +113,24 @@ namespace Microsoft.Runtime.CompilerServices {
}
Func<CallSiteBinder, CallSite> ctor;
+ MethodInfo method = null;
var ctors = _SiteCtors;
lock (ctors) {
if (!ctors.TryGetValue(delegateType, out ctor)) {
- MethodInfo method = typeof(CallSite<>).MakeGenericType(delegateType).GetMethod("Create");
- ctor = (Func<CallSiteBinder, CallSite>)Delegate.CreateDelegate(typeof(Func<CallSiteBinder, CallSite>), method);
- ctors.Add(delegateType, ctor);
+ method = typeof(CallSite<>).MakeGenericType(delegateType).GetMethod("Create");
+
+ if (TypeUtils.CanCache(delegateType)) {
+ ctor = (Func<CallSiteBinder, CallSite>)Delegate.CreateDelegate(typeof(Func<CallSiteBinder, CallSite>), method);
+ ctors.Add(delegateType, ctor);
+ }
}
}
- return ctor(binder);
+ if (ctor != null) {
+ return ctor(binder);
+ }
+
+ // slow path
+ return (CallSite)method.Invoke(null, new object[] { binder });
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteBinder.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteBinder.cs
index bfd76825ced..1e02b8e3ef3 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteBinder.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteBinder.cs
@@ -30,6 +30,10 @@ using Microsoft.Linq.Expressions;
using System.Threading;
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif //SILVERLIGHT
+
#if CODEPLEX_40
namespace System.Runtime.CompilerServices {
#else
@@ -143,9 +147,10 @@ namespace Microsoft.Runtime.CompilerServices {
//
// finally produce the new rule if we need to
//
-#if !MICROSOFT_SCRIPTING_CORE
+#if !MICROSOFT_SCRIPTING_CORE && !SILVERLIGHT
// We cannot compile rules in the heterogeneous app domains since they
// may come from less trusted sources
+ // Silverlight always uses a homogenous appdomain, so we don’t need this check
if (!AppDomain.CurrentDomain.IsHomogenous) {
throw Error.HomogenousAppDomainRequired();
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObject.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObject.cs
index 9c5fc873d2e..55bcc8f32ee 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObject.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObject.cs
@@ -24,7 +24,12 @@ using Microsoft.Scripting.Utils;
using Microsoft.Linq.Expressions;
#endif
using System.Reflection;
+
+#if SILVERLIGHT
+using System.Core;
+#else
using System.Runtime.Remoting;
+#endif
#if CODEPLEX_40
namespace System.Dynamic {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObjectBinder.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObjectBinder.cs
index ae59b973ac1..013ef1c7097 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObjectBinder.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObjectBinder.cs
@@ -31,7 +31,12 @@ using System.Runtime.CompilerServices;
using Microsoft.Runtime.CompilerServices;
#endif
+
+#if SILVERLIGHT
+using System.Core;
+#else
using System.Runtime.Remoting;
+#endif
#if CODEPLEX_40
namespace System.Dynamic {
@@ -64,13 +69,6 @@ namespace Microsoft.Scripting {
}
/// <summary>
- /// Gets the value indicating if we should validate the result of the binding.
- /// </summary>
- protected virtual bool ValidateBindingResult {
- get { return true; }
- }
-
- /// <summary>
/// Performs the runtime binding of the dynamic operation on a set of arguments.
/// </summary>
/// <param name="args">An array of arguments to the dynamic operation.</param>
@@ -99,10 +97,8 @@ namespace Microsoft.Scripting {
// Ensure that the binder's ReturnType matches CallSite's return
// type. We do this so meta objects and language binders can
// compose trees together without needing to insert converts.
- //
- // For now, we need to allow binders to opt out of this check.
Type expectedResult;
- if (ValidateBindingResult) {
+ if (IsStandardBinder) {
expectedResult = ReturnType;
if (returnLabel.Type != typeof(void) &&
@@ -110,8 +106,8 @@ namespace Microsoft.Scripting {
throw Error.BinderNotCompatibleWithCallSite(expectedResult, this, returnLabel.Type);
}
} else {
- // We have to at least make sure it works with the CallSite's
- // type to build the return.
+ // Even for non-standard binders, we have to at least make sure
+ // it works with the CallSite's type to build the return.
expectedResult = returnLabel.Type;
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoObject.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoObject.cs
index 8222ed322d1..58258970f9f 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoObject.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoObject.cs
@@ -33,6 +33,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Dynamic {
#else
@@ -695,7 +699,7 @@ namespace Microsoft.Scripting {
: base(expression, BindingRestrictions.Empty, value) {
}
- private DynamicMetaObject GetDynamicMetaObjectForMember(string name, bool ignoreCase, DynamicMetaObject fallback) {
+ private DynamicMetaObject BindGetOrInvokeMember(DynamicMetaObjectBinder binder, string name, bool ignoreCase, DynamicMetaObject fallback, Func<DynamicMetaObject, DynamicMetaObject> fallbackInvoke) {
ExpandoClass klass = Value.Class;
//try to find the member, including the deleted members
@@ -713,43 +717,46 @@ namespace Microsoft.Scripting {
value
);
- Expression memberValue = Expression.Block(
- new[] { value },
- Expression.Condition(
- tryGetValue,
- value,
- fallback.Expression,
- typeof(object)
- )
+ var result = new DynamicMetaObject(value, BindingRestrictions.Empty);
+ if (fallbackInvoke != null) {
+ result = fallbackInvoke(result);
+ }
+
+ result = new DynamicMetaObject(
+ Expression.Block(
+ new[] { value },
+ Expression.Condition(
+ tryGetValue,
+ result.Expression,
+ fallback.Expression,
+ typeof(object)
+ )
+ ),
+ result.Restrictions.Merge(fallback.Restrictions)
);
- return new DynamicMetaObject(memberValue, fallback.Restrictions);
+ return AddDynamicTestAndDefer(binder, Value.Class, null, result);
}
public override DynamicMetaObject BindGetMember(GetMemberBinder binder) {
ContractUtils.RequiresNotNull(binder, "binder");
- DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
+ return BindGetOrInvokeMember(
+ binder,
binder.Name,
binder.IgnoreCase,
- binder.FallbackGetMember(this)
+ binder.FallbackGetMember(this),
+ null
);
-
- return AddDynamicTestAndDefer(binder, Value.Class, null, memberValue);
}
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) {
ContractUtils.RequiresNotNull(binder, "binder");
- DynamicMetaObject memberValue = GetDynamicMetaObjectForMember(
+ return BindGetOrInvokeMember(
+ binder,
binder.Name,
binder.IgnoreCase,
- binder.FallbackInvokeMember(this, args)
- );
- //invoke the member value using the language's binder
- return AddDynamicTestAndDefer(
- binder,
- Value.Class,
- null,
- binder.FallbackInvoke(memberValue, args, null)
+ binder.FallbackInvokeMember(this, args),
+ value => binder.FallbackInvoke(value, args, null)
);
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BinaryExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BinaryExpression.cs
index df231bf8a44..299e2766cd0 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BinaryExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BinaryExpression.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -76,18 +80,21 @@ namespace Microsoft.Linq.Expressions {
}
return false;
}
+
/// <summary>
/// Gets the right operand of the binary operation.
/// </summary>
public Expression Right {
get { return _right; }
}
+
/// <summary>
/// Gets the left operand of the binary operation.
/// </summary>
public Expression Left {
get { return _left; }
}
+
/// <summary>
/// Gets the implementing method for the binary operation.
/// </summary>
@@ -99,6 +106,34 @@ namespace Microsoft.Linq.Expressions {
return null;
}
+ // Note: takes children in evaluation order, which is also the order
+ // that ExpressionVisitor visits them. Having them this way reduces the
+ // chances people will make a mistake and use an inconsistent order in
+ // derived visitors.
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="left">The <see cref="Left" /> property of the result.</param>
+ /// <param name="conversion">The <see cref="Conversion" /> property of the result.</param>
+ /// <param name="right">The <see cref="Right" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public BinaryExpression Update(Expression left, LambdaExpression conversion, Expression right) {
+ if (left == Left && right == Right && conversion == Conversion) {
+ return this;
+ }
+ if (IsReferenceComparison) {
+ if (NodeType == ExpressionType.Equal) {
+ return Expression.ReferenceEqual(left, right);
+ } else {
+ return Expression.ReferenceNotEqual(left, right);
+ }
+ }
+ return Expression.MakeBinary(NodeType, left, right, IsLiftedToNull, Method, conversion);
+ }
+
/// <summary>
/// Reduces the binary expression node to a simpler expression.
/// If CanReduce returns true, this should return a valid expression.
@@ -274,6 +309,7 @@ namespace Microsoft.Linq.Expressions {
internal virtual LambdaExpression GetConversion() {
return null;
}
+
/// <summary>
/// Gets a value that indicates whether the expression tree node represents a lifted call to an operator.
/// </summary>
@@ -299,7 +335,10 @@ namespace Microsoft.Linq.Expressions {
}
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitBinary(this);
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BlockExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BlockExpression.cs
index 430eda70891..8dab6ca8b70 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BlockExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/BlockExpression.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Threading;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -66,7 +70,10 @@ namespace Microsoft.Linq.Expressions {
internal BlockExpression() {
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitBlock(this);
}
@@ -87,6 +94,22 @@ namespace Microsoft.Linq.Expressions {
get { return GetExpression(ExpressionCount - 1).Type; }
}
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="variables">The <see cref="Variables" /> property of the result.</param>
+ /// <param name="expressions">The <see cref="Expressions" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public BlockExpression Update(IEnumerable<ParameterExpression> variables, IEnumerable<Expression> expressions) {
+ if (variables == Variables && expressions == Expressions) {
+ return this;
+ }
+
+ return Expression.Block(Type, variables, expressions);
+ }
+
internal virtual Expression GetExpression(int index) {
throw ContractUtils.Unreachable;
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/CatchBlock.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/CatchBlock.cs
index f2698e54764..c5c470844b9 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/CatchBlock.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/CatchBlock.cs
@@ -22,6 +22,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -85,6 +89,22 @@ namespace Microsoft.Linq.Expressions {
public override string ToString() {
return ExpressionStringBuilder.CatchBlockToString(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="variable">The <see cref="Variable" /> property of the result.</param>
+ /// <param name="filter">The <see cref="Filter" /> property of the result.</param>
+ /// <param name="body">The <see cref="Body" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public CatchBlock Update(ParameterExpression variable, Expression filter, Expression body) {
+ if (variable == Variable && filter == Filter && body == Body) {
+ return this;
+ }
+ return Expression.MakeCatchBlock(Test, variable, body, filter);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConditionalExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConditionalExpression.cs
index d7d0cf0a33f..bb34d14fe7a 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConditionalExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConditionalExpression.cs
@@ -22,6 +22,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Diagnostics;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -93,9 +97,28 @@ namespace Microsoft.Linq.Expressions {
return Expression.Empty();
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitConditional(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="test">The <see cref="Test" /> property of the result.</param>
+ /// <param name="ifTrue">The <see cref="IfTrue" /> property of the result.</param>
+ /// <param name="ifFalse">The <see cref="IfFalse" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public ConditionalExpression Update(Expression test, Expression ifTrue, Expression ifFalse) {
+ if (test == Test && ifTrue == IfTrue && ifFalse == IfFalse) {
+ return this;
+ }
+ return Expression.Condition(test, ifTrue, ifFalse, Type);
+ }
}
internal class FullConditionalExpression : ConditionalExpression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs
index 65c89b8b4a0..8ccc0828a25 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs
@@ -22,6 +22,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -79,7 +83,10 @@ namespace Microsoft.Linq.Expressions {
get { return _value; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitConstant(this);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugInfoExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugInfoExpression.cs
index b0fc4c0c266..a9922c02805 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugInfoExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugInfoExpression.cs
@@ -22,6 +22,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -102,7 +106,10 @@ namespace Microsoft.Linq.Expressions {
get { throw ContractUtils.Unreachable; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitDebugInfo(this);
}
}
@@ -150,7 +157,7 @@ namespace Microsoft.Linq.Expressions {
}
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitDebugInfo(this);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DefaultExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DefaultExpression.cs
index 3c3c31fa192..66a4f7d741c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DefaultExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DefaultExpression.cs
@@ -52,7 +52,10 @@ namespace Microsoft.Linq.Expressions {
get { return ExpressionType.Default; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitDefault(this);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DynamicExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DynamicExpression.cs
index 1b7127284bf..3b86acc3b34 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DynamicExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/DynamicExpression.cs
@@ -32,6 +32,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -136,7 +140,10 @@ namespace Microsoft.Linq.Expressions {
throw ContractUtils.Unreachable;
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitDynamic(this);
}
@@ -151,6 +158,21 @@ namespace Microsoft.Linq.Expressions {
throw ContractUtils.Unreachable;
}
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public DynamicExpression Update(IEnumerable<Expression> arguments) {
+ if (arguments == Arguments) {
+ return this;
+ }
+
+ return Expression.MakeDynamic(DelegateType, Binder, arguments);
+ }
+
#region IArgumentProvider Members
Expression IArgumentProvider.GetArgument(int index) {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ElementInit.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ElementInit.cs
index b4795931fef..de1bdacb3df 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ElementInit.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ElementInit.cs
@@ -28,6 +28,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -75,6 +79,20 @@ namespace Microsoft.Linq.Expressions {
public override string ToString() {
return ExpressionStringBuilder.ElementInitBindingToString(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public ElementInit Update(IEnumerable<Expression> arguments) {
+ if (arguments == Arguments) {
+ return this;
+ }
+ return Expression.ElementInit(AddMethod, arguments);
+ }
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs
index 9a79ee68251..979a8765849 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs
@@ -32,6 +32,10 @@ using Microsoft.Runtime.CompilerServices;
using System.Threading;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -103,7 +107,7 @@ namespace Microsoft.Linq.Expressions {
get {
#if !MICROSOFT_SCRIPTING_CORE
ExtensionInfo extInfo;
- if (_legacyCtorSupportTable.TryGetValue(this, out extInfo)) {
+ if (_legacyCtorSupportTable != null && _legacyCtorSupportTable.TryGetValue(this, out extInfo)) {
return extInfo.NodeType;
}
#endif
@@ -121,7 +125,7 @@ namespace Microsoft.Linq.Expressions {
get {
#if !MICROSOFT_SCRIPTING_CORE
ExtensionInfo extInfo;
- if (_legacyCtorSupportTable.TryGetValue(this, out extInfo)) {
+ if (_legacyCtorSupportTable != null && _legacyCtorSupportTable.TryGetValue(this, out extInfo)) {
return extInfo.Type;
}
#endif
@@ -161,16 +165,26 @@ namespace Microsoft.Linq.Expressions {
/// children, and if any of them change, should return a new copy of
/// itself with the modified children.
/// </remarks>
- protected internal virtual Expression VisitChildren(Func<Expression, Expression> visitor) {
+ protected internal virtual Expression VisitChildren(ExpressionVisitor visitor) {
ContractUtils.Requires(CanReduce, "this", Strings.MustBeReducible);
- return visitor(ReduceExtensions());
+ return visitor.Visit(ReduceExtensions());
}
- // Visitor pattern: this is the method that dispatches back to the visitor
- // NOTE: this is unlike the Visit method, which provides a hook for
- // derived classes to extend the visitor framework to be able to walk
- // themselves
- internal virtual Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type. For
+ /// example, <see cref="MethodCallExpression" /> will call into
+ /// <see cref="ExpressionVisitor.VisitMethodCall" />.
+ /// </summary>
+ /// <param name="visitor">The visitor to visit this node with.</param>
+ /// <returns>The result of visiting this node.</returns>
+ /// <remarks>
+ /// This default implementation for <see cref="ExpressionType.Extension" />
+ /// nodes will call <see cref="ExpressionVisitor.VisitExtension" />.
+ /// Override this method to call into a more specific method on a derived
+ /// visitor class of ExprressionVisitor. However, it should still
+ /// support unknown visitors by calling VisitExtension.
+ /// </remarks>
+ protected internal virtual Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitExtension(this);
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionVisitor.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionVisitor.cs
index bc86995dfa6..2334ac20adb 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionVisitor.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionVisitor.cs
@@ -28,6 +28,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -69,7 +73,7 @@ namespace Microsoft.Linq.Expressions {
/// <param name="nodes">The expressions to visit.</param>
/// <returns>The modified expression list, if any of the elements were modified;
/// otherwise, returns the original expression list.</returns>
- protected ReadOnlyCollection<Expression> Visit(ReadOnlyCollection<Expression> nodes) {
+ public ReadOnlyCollection<Expression> Visit(ReadOnlyCollection<Expression> nodes) {
Expression[] newNodes = null;
for (int i = 0, n = nodes.Count; i < n; i++) {
Expression node = Visit(nodes[i]);
@@ -118,7 +122,7 @@ namespace Microsoft.Linq.Expressions {
/// optionally replacing it with a new element.</param>
/// <returns>The modified node list, if any of the elements were modified;
/// otherwise, returns the original node list.</returns>
- protected static ReadOnlyCollection<T> Visit<T>(ReadOnlyCollection<T> nodes, Func<T, T> elementVisitor) {
+ public static ReadOnlyCollection<T> Visit<T>(ReadOnlyCollection<T> nodes, Func<T, T> elementVisitor) {
T[] newNodes = null;
for (int i = 0, n = nodes.Count; i < n; i++) {
T node = elementVisitor(nodes[i]);
@@ -147,7 +151,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
/// <exception cref="InvalidOperationException">The visit method for this node returned a different type.</exception>
- protected T VisitAndConvert<T>(T node, string callerName) where T : Expression {
+ public T VisitAndConvert<T>(T node, string callerName) where T : Expression {
if (node == null) {
return null;
}
@@ -167,7 +171,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
/// <exception cref="InvalidOperationException">The visit method for this node returned a different type.</exception>
- protected ReadOnlyCollection<T> VisitAndConvert<T>(ReadOnlyCollection<T> nodes, string callerName) where T : Expression {
+ public ReadOnlyCollection<T> VisitAndConvert<T>(ReadOnlyCollection<T> nodes, string callerName) where T : Expression {
T[] newNodes = null;
for (int i = 0, n = nodes.Count; i < n; i++) {
T node = Visit(nodes[i]) as T;
@@ -199,22 +203,14 @@ namespace Microsoft.Linq.Expressions {
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitBinary(BinaryExpression node) {
// Walk children in evaluation order: left, conversion, right
- Expression l = Visit(node.Left);
- LambdaExpression c = VisitAndConvert(node.Conversion, "VisitBinary");
- Expression r = Visit(node.Right);
- if (l == node.Left && r == node.Right && c == node.Conversion) {
- return node;
- }
- if (node.IsReferenceComparison) {
- if (node.NodeType == ExpressionType.Equal) {
- return Expression.ReferenceEqual(l, r);
- } else {
- return Expression.ReferenceNotEqual(l, r);
- }
- }
- var result = Expression.MakeBinary(node.NodeType, l, r, node.IsLiftedToNull, node.Method, c);
- ValidateBinary(node, result);
- return result;
+ return ValidateBinary(
+ node,
+ node.Update(
+ Visit(node.Left),
+ VisitAndConvert(node.Conversion, "VisitBinary"),
+ Visit(node.Right)
+ )
+ );
}
/// <summary>
@@ -259,13 +255,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitConditional(ConditionalExpression node) {
- Expression t = Visit(node.Test);
- Expression l = Visit(node.IfTrue);
- Expression r = Visit(node.IfFalse);
- if (t == node.Test && l == node.IfTrue && r == node.IfFalse) {
- return node;
- }
- return Expression.Condition(t, l, r, node.Type);
+ return node.Update(Visit(node.Test), Visit(node.IfTrue), Visit(node.IfFalse));
}
/// <summary>
@@ -326,7 +316,7 @@ namespace Microsoft.Linq.Expressions {
/// <see cref="Expression.VisitChildren" /> will try to reduce the node.
/// </remarks>
protected internal virtual Expression VisitExtension(Expression node) {
- return node.VisitChildren(this.Visit);
+ return node.VisitChildren(this);
}
/// <summary>
@@ -336,12 +326,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitGoto(GotoExpression node) {
- LabelTarget t = VisitLabelTarget(node.Target);
- Expression v = Visit(node.Value);
- if (t == node.Target && v == node.Value) {
- return node;
- }
- return Expression.MakeGoto(node.Kind, t, v, node.Type);
+ return node.Update(VisitLabelTarget(node.Target), Visit(node.Value));
}
/// <summary>
@@ -377,12 +362,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitLabel(LabelExpression node) {
- LabelTarget l = VisitLabelTarget(node.Target);
- Expression d = Visit(node.DefaultValue);
- if (l == node.Target && d == node.DefaultValue) {
- return node;
- }
- return Expression.Label(l, d);
+ return node.Update(VisitLabelTarget(node.Target), Visit(node.DefaultValue));
}
/// <summary>
@@ -393,12 +373,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitLambda<T>(Expression<T> node) {
- Expression b = Visit(node.Body);
- var p = VisitAndConvert(node.Parameters, "VisitLambda");
- if (b == node.Body && p == node.Parameters) {
- return node;
- }
- return Expression.Lambda<T>(b, node.Name, node.TailCall, p);
+ return node.Update(Visit(node.Body), VisitAndConvert(node.Parameters, "VisitLambda"));
}
/// <summary>
@@ -408,15 +383,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitLoop(LoopExpression node) {
- LabelTarget @break = VisitLabelTarget(node.BreakLabel);
- LabelTarget @continue = VisitLabelTarget(node.ContinueLabel);
- Expression b = Visit(node.Body);
- if (@break == node.BreakLabel &&
- @continue == node.ContinueLabel &&
- b == node.Body) {
- return node;
- }
- return Expression.Loop(b, @break, @continue);
+ return node.Update(VisitLabelTarget(node.BreakLabel), VisitLabelTarget(node.ContinueLabel), Visit(node.Body));
}
/// <summary>
@@ -426,11 +393,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitMember(MemberExpression node) {
- Expression e = Visit(node.Expression);
- if (e == node.Expression) {
- return node;
- }
- return Expression.MakeMemberAccess(e, node.Member);
+ return node.Update(Visit(node.Expression));
}
/// <summary>
@@ -472,14 +435,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitNewArray(NewArrayExpression node) {
- ReadOnlyCollection<Expression> e = Visit(node.Expressions);
- if (e == node.Expressions) {
- return node;
- }
- if (node.NodeType == ExpressionType.NewArrayInit) {
- return Expression.NewArrayInit(node.Type.GetElementType(), e);
- }
- return Expression.NewArrayBounds(node.Type.GetElementType(), e);
+ return node.Update(Visit(node.Expressions));
}
/// <summary>
@@ -490,14 +446,7 @@ namespace Microsoft.Linq.Expressions {
/// otherwise, returns the original expression.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
protected internal virtual Expression VisitNew(NewExpression node) {
- ReadOnlyCollection<Expression> a = Visit(node.Arguments);
- if (a == node.Arguments) {
- return node;
- }
- if (node.Members != null) {
- return Expression.New(node.Constructor, a, node.Members);
- }
- return Expression.New(node.Constructor, a);
+ return node.Update(Visit(node.Arguments));
}
/// <summary>
@@ -517,11 +466,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitRuntimeVariables(RuntimeVariablesExpression node) {
- var v = VisitAndConvert(node.Variables, "VisitRuntimeVariables");
- if (v == node.Variables) {
- return node;
- }
- return Expression.RuntimeVariables(v);
+ return node.Update(VisitAndConvert(node.Variables, "VisitRuntimeVariables"));
}
/// <summary>
@@ -531,12 +476,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected virtual SwitchCase VisitSwitchCase(SwitchCase node) {
- ReadOnlyCollection<Expression> t = Visit(node.TestValues);
- Expression b = Visit(node.Body);
- if (t == node.TestValues && b == node.Body) {
- return node;
- }
- return Expression.SwitchCase(b, t);
+ return node.Update(Visit(node.TestValues), Visit(node.Body));
}
/// <summary>
@@ -546,15 +486,14 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitSwitch(SwitchExpression node) {
- Expression s = Visit(node.SwitchValue);
- ReadOnlyCollection<SwitchCase> c = Visit(node.Cases, VisitSwitchCase);
- Expression d = Visit(node.DefaultBody);
- if (s == node.SwitchValue && c == node.Cases && d == node.DefaultBody) {
- return node;
- }
- var result = Expression.Switch(node.Type, s, d, node.Comparison, c);
- ValidateSwitch(node, result);
- return result;
+ return ValidateSwitch(
+ node,
+ node.Update(
+ Visit(node.SwitchValue),
+ Visit(node.Cases, VisitSwitchCase),
+ Visit(node.DefaultBody)
+ )
+ );
}
/// <summary>
@@ -564,13 +503,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected virtual CatchBlock VisitCatchBlock(CatchBlock node) {
- ParameterExpression v = VisitAndConvert(node.Variable, "VisitCatchBlock");
- Expression f = Visit(node.Filter);
- Expression b = Visit(node.Body);
- if (v == node.Variable && b == node.Body && f == node.Filter) {
- return node;
- }
- return Expression.MakeCatchBlock(node.Test, v, b, f);
+ return node.Update(VisitAndConvert(node.Variable, "VisitCatchBlock"), Visit(node.Filter), Visit(node.Body));
}
/// <summary>
@@ -580,18 +513,12 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitTry(TryExpression node) {
- Expression b = Visit(node.Body);
- ReadOnlyCollection<CatchBlock> h = Visit(node.Handlers, VisitCatchBlock);
- Expression y = Visit(node.Finally);
- Expression f = Visit(node.Fault);
-
- if (b == node.Body &&
- h == node.Handlers &&
- y == node.Finally &&
- f == node.Fault) {
- return node;
- }
- return Expression.MakeTry(node.Type, b, y, f, h);
+ return node.Update(
+ Visit(node.Body),
+ Visit(node.Handlers, VisitCatchBlock),
+ Visit(node.Finally),
+ Visit(node.Fault)
+ );
}
/// <summary>
@@ -601,14 +528,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitTypeBinary(TypeBinaryExpression node) {
- Expression e = Visit(node.Expression);
- if (e == node.Expression) {
- return node;
- }
- if (node.NodeType == ExpressionType.TypeIs) {
- return Expression.TypeIs(e, node.TypeOperand);
- }
- return Expression.TypeEqual(e, node.TypeOperand);
+ return node.Update(Visit(node.Expression));
}
/// <summary>
@@ -618,13 +538,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitUnary(UnaryExpression node) {
- Expression o = Visit(node.Operand);
- if (o == node.Operand) {
- return node;
- }
- var result = Expression.MakeUnary(node.NodeType, o, node.Type, node.Method);
- ValidateUnary(node, result);
- return result;
+ return ValidateUnary(node, node.Update(Visit(node.Operand)));
}
/// <summary>
@@ -634,12 +548,10 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitMemberInit(MemberInitExpression node) {
- NewExpression n = VisitAndConvert(node.NewExpression, "VisitMemberInit");
- ReadOnlyCollection<MemberBinding> bindings = Visit(node.Bindings, VisitMemberBinding);
- if (n == node.NewExpression && bindings == node.Bindings) {
- return node;
- }
- return Expression.MemberInit(n, bindings);
+ return node.Update(
+ VisitAndConvert(node.NewExpression, "VisitMemberInit"),
+ Visit(node.Bindings, VisitMemberBinding)
+ );
}
/// <summary>
@@ -649,12 +561,10 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected internal virtual Expression VisitListInit(ListInitExpression node) {
- NewExpression n = VisitAndConvert(node.NewExpression, "VisitListInit");
- ReadOnlyCollection<ElementInit> initializers = Visit(node.Initializers, VisitElementInit);
- if (n == node.NewExpression && initializers == node.Initializers) {
- return node;
- }
- return Expression.ListInit(n, initializers);
+ return node.Update(
+ VisitAndConvert(node.NewExpression, "VisitListInit"),
+ Visit(node.Initializers, VisitElementInit)
+ );
}
/// <summary>
@@ -664,11 +574,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected virtual ElementInit VisitElementInit(ElementInit node) {
- ReadOnlyCollection<Expression> arguments = Visit(node.Arguments);
- if (arguments == node.Arguments) {
- return node;
- }
- return Expression.ElementInit(node.AddMethod, arguments);
+ return node.Update(Visit(node.Arguments));
}
/// <summary>
@@ -697,11 +603,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected virtual MemberAssignment VisitMemberAssignment(MemberAssignment node) {
- Expression e = Visit(node.Expression);
- if (e == node.Expression) {
- return node;
- }
- return Expression.Bind(node.Member, e);
+ return node.Update(Visit(node.Expression));
}
/// <summary>
@@ -711,11 +613,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected virtual MemberMemberBinding VisitMemberMemberBinding(MemberMemberBinding node) {
- ReadOnlyCollection<MemberBinding> bindings = Visit(node.Bindings, VisitMemberBinding);
- if (bindings == node.Bindings) {
- return node;
- }
- return Expression.MemberBind(node.Member, bindings);
+ return node.Update(Visit(node.Bindings, VisitMemberBinding));
}
/// <summary>
@@ -725,11 +623,7 @@ namespace Microsoft.Linq.Expressions {
/// <returns>The modified expression, if it or any subexpression was modified;
/// otherwise, returns the original expression.</returns>
protected virtual MemberListBinding VisitMemberListBinding(MemberListBinding node) {
- ReadOnlyCollection<ElementInit> initializers = Visit(node.Initializers, VisitElementInit);
- if (initializers == node.Initializers) {
- return node;
- }
- return Expression.ListBind(node.Member, initializers);
+ return node.Update(Visit(node.Initializers, VisitElementInit));
}
@@ -741,18 +635,22 @@ namespace Microsoft.Linq.Expressions {
// require derived classes to be explicit about what they want to do if
// types change.
//
- private static void ValidateUnary(UnaryExpression before, UnaryExpression after) {
- if (before.Method == null) {
+ private static UnaryExpression ValidateUnary(UnaryExpression before, UnaryExpression after) {
+ if (before != after && before.Method == null) {
if (after.Method != null) {
throw Error.MustRewriteWithoutMethod(after.Method, "VisitUnary");
}
- ValidateChildType(before.Operand.Type, after.Operand.Type, "VisitUnary");
+ // rethrow has null operand
+ if (before.Operand != null && after.Operand != null) {
+ ValidateChildType(before.Operand.Type, after.Operand.Type, "VisitUnary");
+ }
}
+ return after;
}
- private static void ValidateBinary(BinaryExpression before, BinaryExpression after) {
- if (before.Method == null) {
+ private static BinaryExpression ValidateBinary(BinaryExpression before, BinaryExpression after) {
+ if (before != after && before.Method == null) {
if (after.Method != null) {
throw Error.MustRewriteWithoutMethod(after.Method, "VisitBinary");
}
@@ -760,15 +658,17 @@ namespace Microsoft.Linq.Expressions {
ValidateChildType(before.Left.Type, after.Left.Type, "VisitBinary");
ValidateChildType(before.Right.Type, after.Right.Type, "VisitBinary");
}
+ return after;
}
// We wouldn't need this if switch didn't infer the method.
- private static void ValidateSwitch(SwitchExpression before, SwitchExpression after) {
+ private static SwitchExpression ValidateSwitch(SwitchExpression before, SwitchExpression after) {
// If we did not have a method, we don't want to bind to one,
// it might not be the right thing.
if (before.Comparison == null && after.Comparison != null) {
throw Error.MustRewriteWithoutMethod(after.Comparison, "VisitSwitch");
}
+ return after;
}
// Value types must stay as the same type, otherwise it's now a
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/GotoExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/GotoExpression.cs
index 9b71b08e79e..8113a33d942 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/GotoExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/GotoExpression.cs
@@ -22,6 +22,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -106,9 +110,27 @@ namespace Microsoft.Linq.Expressions {
get { return _kind; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitGoto(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="target">The <see cref="Target" /> property of the result.</param>
+ /// <param name="value">The <see cref="Value" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public GotoExpression Update(LabelTarget target, Expression value) {
+ if (target == Target && value == Value) {
+ return this;
+ }
+ return Expression.MakeGoto(Kind, target, value, Type);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/IndexExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/IndexExpression.cs
index f067615eef2..4e39a2a1c3d 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/IndexExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/IndexExpression.cs
@@ -31,6 +31,10 @@ using Microsoft.Runtime.CompilerServices;
using System.Text;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -104,6 +108,21 @@ namespace Microsoft.Linq.Expressions {
get { return ReturnReadOnly(ref _arguments); }
}
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="object">The <see cref="Object" /> property of the result.</param>
+ /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public IndexExpression Update(Expression @object, IEnumerable<Expression> arguments) {
+ if (@object == Object && arguments == Arguments) {
+ return this;
+ }
+ return Expression.MakeIndex(@object, Indexer, arguments);
+ }
+
Expression IArgumentProvider.GetArgument(int index) {
return _arguments[index];
}
@@ -114,7 +133,10 @@ namespace Microsoft.Linq.Expressions {
}
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitIndex(this);
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/InvocationExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/InvocationExpression.cs
index c4d8b4aa0b8..d1c3640772f 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/InvocationExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/InvocationExpression.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -78,6 +82,22 @@ namespace Microsoft.Linq.Expressions {
get { return ReturnReadOnly(ref _arguments); }
}
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
+ /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public InvocationExpression Update(Expression expression, IEnumerable<Expression> arguments) {
+ if (expression == Expression && arguments == Arguments) {
+ return this;
+ }
+
+ return Expression.Invoke(expression, arguments);
+ }
+
Expression IArgumentProvider.GetArgument(int index) {
return _arguments[index];
}
@@ -88,7 +108,10 @@ namespace Microsoft.Linq.Expressions {
}
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitInvocation(this);
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelExpression.cs
index 6963b7e7c20..ed90933399a 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelExpression.cs
@@ -71,9 +71,27 @@ namespace Microsoft.Linq.Expressions {
get { return _defaultValue; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitLabel(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="target">The <see cref="Target" /> property of the result.</param>
+ /// <param name="defaultValue">The <see cref="DefaultValue" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public LabelExpression Update(LabelTarget target, Expression defaultValue) {
+ if (target == Target && defaultValue == DefaultValue) {
+ return this;
+ }
+ return Expression.Label(target, defaultValue);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs
index 5e33e6c1601..74a0675a43c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs
@@ -34,6 +34,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -205,7 +209,25 @@ namespace Microsoft.Linq.Expressions {
return (TDelegate)(object)LambdaCompiler.Compile(this, debugInfoGenerator);
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="body">The <see cref="LambdaExpression.Body">Body</see> property of the result.</param>
+ /// <param name="parameters">The <see cref="LambdaExpression.Parameters">Parameters</see> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public Expression<TDelegate> Update(Expression body, IEnumerable<ParameterExpression> parameters) {
+ if (body == Body && parameters == Parameters) {
+ return this;
+ }
+ return Expression.Lambda<TDelegate>(body, Name, TailCall, parameters);
+ }
+
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitLambda(this);
}
@@ -225,27 +247,32 @@ namespace Microsoft.Linq.Expressions {
/// Creates an Expression{T} given the delegate type. Caches the
/// factory method to speed up repeated creations for the same T.
/// </summary>
- internal static LambdaExpression CreateLambda(Type delegateType, string name, Expression body, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters) {
+ internal static LambdaExpression CreateLambda(Type delegateType, Expression body, string name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters) {
// Get or create a delegate to the public Expression.Lambda<T>
// method and call that will be used for creating instances of this
// delegate type
- LambdaFactory factory;
-
+ LambdaFactory fastPath;
if (_LambdaFactories == null) {
// NOTE: this must be Interlocked assigment since we use _LambdaFactories for locking.
Interlocked.CompareExchange(ref _LambdaFactories, new CacheDict<Type, LambdaFactory>(50), null);
}
+ MethodInfo create = null;
lock (_LambdaFactories) {
- if (!_LambdaFactories.TryGetValue(delegateType, out factory)) {
- _LambdaFactories[delegateType] = factory = (LambdaFactory)Delegate.CreateDelegate(
- typeof(LambdaFactory),
- typeof(Expression<>).MakeGenericType(delegateType).GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic)
- );
+ if (!_LambdaFactories.TryGetValue(delegateType, out fastPath)) {
+ create = typeof(Expression<>).MakeGenericType(delegateType).GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic);
+ if (TypeUtils.CanCache(delegateType)) {
+ _LambdaFactories[delegateType] = fastPath = (LambdaFactory)Delegate.CreateDelegate(typeof(LambdaFactory), create);
+ }
}
}
- return factory(body, name, tailCall, parameters);
+ if (fastPath != null) {
+ return fastPath(body, name, tailCall, parameters);
+ }
+
+ Debug.Assert(create != null);
+ return (LambdaExpression)create.Invoke(null, new object[] { body, name, tailCall, parameters });
}
/// <summary>
@@ -452,7 +479,7 @@ namespace Microsoft.Linq.Expressions {
Type delegateType = DelegateHelpers.MakeDelegateType(typeArgs);
- return CreateLambda(delegateType, name, body, tailCall, parameterList);
+ return CreateLambda(delegateType, body, name, tailCall, parameterList);
}
/// <summary>
@@ -467,7 +494,7 @@ namespace Microsoft.Linq.Expressions {
var paramList = parameters.ToReadOnly();
ValidateLambdaArgs(delegateType, ref body, paramList);
- return CreateLambda(delegateType, name, body, false, paramList);
+ return CreateLambda(delegateType, body, name, false, paramList);
}
/// <summary>
@@ -483,7 +510,7 @@ namespace Microsoft.Linq.Expressions {
var paramList = parameters.ToReadOnly();
ValidateLambdaArgs(delegateType, ref body, paramList);
- return CreateLambda(delegateType, name, body, tailCall, paramList);
+ return CreateLambda(delegateType, body, name, tailCall, paramList);
}
private static void ValidateLambdaArgs(Type delegateType, ref Expression body, ReadOnlyCollection<ParameterExpression> parameters) {
@@ -497,7 +524,10 @@ namespace Microsoft.Linq.Expressions {
MethodInfo mi;
lock (_LambdaDelegateCache) {
if (!_LambdaDelegateCache.TryGetValue(delegateType, out mi)) {
- _LambdaDelegateCache[delegateType] = mi = delegateType.GetMethod("Invoke");
+ mi = delegateType.GetMethod("Invoke");
+ if (TypeUtils.CanCache(delegateType)) {
+ _LambdaDelegateCache[delegateType] = mi;
+ }
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ListInitExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ListInitExpression.cs
index 5d9f18750a3..01b206af60b 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ListInitExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ListInitExpression.cs
@@ -30,6 +30,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -93,7 +97,10 @@ namespace Microsoft.Linq.Expressions {
get { return _initializers; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitListInit(this);
}
@@ -107,6 +114,21 @@ namespace Microsoft.Linq.Expressions {
public override Expression Reduce() {
return MemberInitExpression.ReduceListInit(_newExpression, _initializers, true);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="newExpression">The <see cref="NewExpression" /> property of the result.</param>
+ /// <param name="initializers">The <see cref="Initializers" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public ListInitExpression Update(NewExpression newExpression, IEnumerable<ElementInit> initializers) {
+ if (newExpression == NewExpression && initializers == Initializers) {
+ return this;
+ }
+ return Expression.ListInit(newExpression, initializers);
+ }
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LoopExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LoopExpression.cs
index 13c9b43f480..f96c2c62492 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LoopExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/LoopExpression.cs
@@ -22,6 +22,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -82,9 +86,28 @@ namespace Microsoft.Linq.Expressions {
get { return _continue; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitLoop(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="breakLabel">The <see cref="BreakLabel" /> property of the result.</param>
+ /// <param name="continueLabel">The <see cref="ContinueLabel" /> property of the result.</param>
+ /// <param name="body">The <see cref="Body" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public LoopExpression Update(LabelTarget breakLabel, LabelTarget continueLabel, Expression body) {
+ if (breakLabel == BreakLabel && continueLabel == ContinueLabel && body == Body) {
+ return this;
+ }
+ return Expression.Loop(body, breakLabel, continueLabel);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberAssignment.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberAssignment.cs
index c700b6e0524..13d5d24351a 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberAssignment.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberAssignment.cs
@@ -22,6 +22,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -44,6 +48,20 @@ namespace Microsoft.Linq.Expressions {
public Expression Expression {
get { return _expression; }
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public MemberAssignment Update(Expression expression) {
+ if (expression == Expression) {
+ return this;
+ }
+ return Expression.Bind(Member, expression);
+ }
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberExpression.cs
index 7f4ac52f81e..c2abcca93af 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberExpression.cs
@@ -23,6 +23,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -80,9 +84,26 @@ namespace Microsoft.Linq.Expressions {
throw ContractUtils.Unreachable;
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitMember(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public MemberExpression Update(Expression expression) {
+ if (expression == Expression) {
+ return this;
+ }
+ return Expression.MakeMemberAccess(expression, Member);
+ }
}
internal class FieldExpression : MemberExpression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberInitExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberInitExpression.cs
index 3481b59d2db..6e5b27c1a4f 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberInitExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberInitExpression.cs
@@ -87,7 +87,10 @@ namespace Microsoft.Linq.Expressions {
get { return _bindings; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitMemberInit(this);
}
@@ -139,6 +142,21 @@ namespace Microsoft.Linq.Expressions {
default: throw ContractUtils.Unreachable;
}
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="newExpression">The <see cref="NewExpression" /> property of the result.</param>
+ /// <param name="bindings">The <see cref="Bindings" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public MemberInitExpression Update(NewExpression newExpression, IEnumerable<MemberBinding> bindings) {
+ if (newExpression == NewExpression && bindings == Bindings) {
+ return this;
+ }
+ return Expression.MemberInit(newExpression, bindings);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberListBinding.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberListBinding.cs
index e46e58ac9b2..be6c60f7833 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberListBinding.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberListBinding.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -49,6 +53,20 @@ namespace Microsoft.Linq.Expressions {
public ReadOnlyCollection<ElementInit> Initializers {
get { return _initializers; }
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="initializers">The <see cref="Initializers" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public MemberListBinding Update(IEnumerable<ElementInit> initializers) {
+ if (initializers == Initializers) {
+ return this;
+ }
+ return Expression.ListBind(Member, initializers);
+ }
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberMemberBinding.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberMemberBinding.cs
index 58308c31da7..d3e1d726e75 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberMemberBinding.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberMemberBinding.cs
@@ -24,6 +24,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -51,6 +55,20 @@ namespace Microsoft.Linq.Expressions {
public ReadOnlyCollection<MemberBinding> Bindings {
get { return _bindings; }
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="bindings">The <see cref="Bindings" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public MemberMemberBinding Update(IEnumerable<MemberBinding> bindings) {
+ if (bindings == Bindings) {
+ return this;
+ }
+ return Expression.MemberBind(Member, bindings);
+ }
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MethodCallExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MethodCallExpression.cs
index 1fc2f424b1c..65444fd5936 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MethodCallExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/MethodCallExpression.cs
@@ -30,6 +30,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -91,11 +95,29 @@ namespace Microsoft.Linq.Expressions {
get { return GetOrMakeArguments(); }
}
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="object">The <see cref="Object" /> property of the result.</param>
+ /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public MethodCallExpression Update(Expression @object, IEnumerable<Expression> arguments) {
+ if (@object == Object && arguments == Arguments) {
+ return this;
+ }
+ return Expression.Call(@object, Method, arguments);
+ }
+
internal virtual ReadOnlyCollection<Expression> GetOrMakeArguments() {
throw ContractUtils.Unreachable;
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitMethodCall(this);
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewArrayExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewArrayExpression.cs
index abf7394cca3..b58d450edd4 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewArrayExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewArrayExpression.cs
@@ -29,6 +29,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -73,9 +77,29 @@ namespace Microsoft.Linq.Expressions {
get { return _expressions; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitNewArray(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="expressions">The <see cref="Expressions" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public NewArrayExpression Update(IEnumerable<Expression> expressions) {
+ if (expressions == Expressions) {
+ return this;
+ }
+ if (NodeType == ExpressionType.NewArrayInit) {
+ return Expression.NewArrayInit(Type.GetElementType(), expressions);
+ }
+ return Expression.NewArrayBounds(Type.GetElementType(), expressions);
+ }
}
internal sealed class NewArrayInitExpression : NewArrayExpression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewExpression.cs
index a9e607ce966..7185da31659 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/NewExpression.cs
@@ -30,6 +30,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -100,9 +104,29 @@ namespace Microsoft.Linq.Expressions {
get { return _members; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitNew(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public NewExpression Update(IEnumerable<Expression> arguments) {
+ if (arguments == Arguments) {
+ return this;
+ }
+ if (Members != null) {
+ return Expression.New(Constructor, arguments, Members);
+ }
+ return Expression.New(Constructor, arguments);
+ }
}
internal class NewValueTypeExpression : NewExpression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ParameterExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ParameterExpression.cs
index 7ab0ce553d3..b6caef52f1f 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ParameterExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/ParameterExpression.cs
@@ -22,6 +22,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -118,7 +122,10 @@ namespace Microsoft.Linq.Expressions {
return false;
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitParameter(this);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/RuntimeVariablesExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/RuntimeVariablesExpression.cs
index 9a2af5f8765..1d16968c8e2 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/RuntimeVariablesExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/RuntimeVariablesExpression.cs
@@ -73,9 +73,26 @@ namespace Microsoft.Linq.Expressions {
get { return _variables; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitRuntimeVariables(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="variables">The <see cref="Variables" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public RuntimeVariablesExpression Update(IEnumerable<ParameterExpression> variables) {
+ if (variables == Variables) {
+ return this;
+ }
+ return Expression.RuntimeVariables(variables);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchCase.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchCase.cs
index e40bc23895f..bf860465951 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchCase.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchCase.cs
@@ -65,6 +65,21 @@ namespace Microsoft.Linq.Expressions {
public override string ToString() {
return ExpressionStringBuilder.SwitchCaseToString(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="testValues">The <see cref="TestValues" /> property of the result.</param>
+ /// <param name="body">The <see cref="Body" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public SwitchCase Update(IEnumerable<Expression> testValues, Expression body) {
+ if (testValues == TestValues && body == Body) {
+ return this;
+ }
+ return Expression.SwitchCase(body, testValues);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchExpression.cs
index bbf4c68265c..0358ef49989 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchExpression.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -96,7 +100,10 @@ namespace Microsoft.Linq.Expressions {
get { return _comparison; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitSwitch(this);
}
@@ -109,6 +116,22 @@ namespace Microsoft.Linq.Expressions {
return false;
}
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="switchValue">The <see cref="SwitchValue" /> property of the result.</param>
+ /// <param name="cases">The <see cref="Cases" /> property of the result.</param>
+ /// <param name="defaultBody">The <see cref="DefaultBody" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public SwitchExpression Update(Expression switchValue, IEnumerable<SwitchCase> cases, Expression defaultBody) {
+ if (switchValue == SwitchValue && cases == Cases && defaultBody == DefaultBody) {
+ return this;
+ }
+ return Expression.Switch(Type, switchValue, defaultBody, Comparison, cases);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TryExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TryExpression.cs
index e38aa9e601e..9a455fe2218 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TryExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TryExpression.cs
@@ -24,6 +24,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -101,9 +105,29 @@ namespace Microsoft.Linq.Expressions {
get { return _fault; }
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitTry(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="body">The <see cref="Body" /> property of the result.</param>
+ /// <param name="handlers">The <see cref="Handlers" /> property of the result.</param>
+ /// <param name="finally">The <see cref="Finally" /> property of the result.</param>
+ /// <param name="fault">The <see cref="Fault" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public TryExpression Update(Expression body, IEnumerable<CatchBlock> handlers, Expression @finally, Expression fault) {
+ if (body == Body && handlers == Handlers && @finally == Finally && fault == Fault) {
+ return this;
+ }
+ return Expression.MakeTry(Type, body, @finally, fault, handlers);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeBinaryExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeBinaryExpression.cs
index 101591c9c0c..306bc150c5e 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeBinaryExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeBinaryExpression.cs
@@ -22,6 +22,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -161,9 +165,29 @@ namespace Microsoft.Linq.Expressions {
#endregion
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitTypeBinary(this);
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public TypeBinaryExpression Update(Expression expression) {
+ if (expression == Expression) {
+ return this;
+ }
+ if (NodeType == ExpressionType.TypeIs) {
+ return Expression.TypeIs(expression, TypeOperand);
+ }
+ return Expression.TypeEqual(expression, TypeOperand);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeUtils.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeUtils.cs
index d154ecdb386..dec832167b6 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeUtils.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeUtils.cs
@@ -24,6 +24,10 @@ using Microsoft.Linq.Expressions;
#endif
using System.Reflection;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Dynamic.Utils {
#else
@@ -149,8 +153,9 @@ namespace Microsoft.Scripting.Utils {
return false;
}
- internal static bool AreEquivalent(Type t1, Type t2) {
-#if MICROSOFT_SCRIPTING_CORE
+ internal static bool AreEquivalent(Type t1, Type t2)
+ {
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
return t1 == t2;
#else
return t1 == t2 || t1.IsEquivalentTo(t2);
@@ -581,5 +586,40 @@ namespace Microsoft.Scripting.Utils {
internal static Type GetNonRefType(this Type type) {
return type.IsByRef ? type.GetElementType() : type;
}
+
+ private static readonly Assembly _mscorlib = typeof(object).Assembly;
+ private static readonly Assembly _systemCore = typeof(Expression).Assembly;
+
+ /// <summary>
+ /// We can cache references to types, as long as they aren't in
+ /// collectable assemblies. Unfortunately, we can't really distinguish
+ /// between different flavors of assemblies. But, we can at least
+ /// create a whitelist for types in mscorlib (so we get the primitives)
+ /// and System.Core (so we find Func/Action overloads, etc).
+ /// </summary>
+ internal static bool CanCache(this Type t) {
+ // Note: we don't have to scan base or declaring types here.
+ // There's no way for a type in mscorlib to derive from or be
+ // contained in a type from another assembly. The only thing we
+ // need to look at is the generic arguments, which are the thing
+ // that allows mscorlib types to be specialized by types in other
+ // assemblies.
+
+ var asm = t.Assembly;
+ if (asm != _mscorlib && asm != _systemCore) {
+ // Not in mscorlib or our assembly
+ return false;
+ }
+
+ if (t.IsGenericType) {
+ foreach (Type g in t.GetGenericArguments()) {
+ if (!CanCache(g)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs
index dbdc26c57ea..15a90e10b87 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs
@@ -28,6 +28,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions {
#else
@@ -114,7 +118,10 @@ namespace Microsoft.Linq.Expressions {
}
}
- internal override Expression Accept(ExpressionVisitor visitor) {
+ /// <summary>
+ /// Dispatches to the specific visit method for this node type.
+ /// </summary>
+ protected internal override Expression Accept(ExpressionVisitor visitor) {
return visitor.VisitUnary(this);
}
@@ -274,6 +281,20 @@ namespace Microsoft.Linq.Expressions {
Debug.Assert(i == block.Length);
return Block(new TrueReadOnlyCollection<ParameterExpression>(temps), new TrueReadOnlyCollection<Expression>(block));
}
+
+ /// <summary>
+ /// Creates a new expression that is like this one, but using the
+ /// supplied children. If all of the children are the same, it will
+ /// return this expression.
+ /// </summary>
+ /// <param name="operand">The <see cref="Operand" /> property of the result.</param>
+ /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
+ public UnaryExpression Update(Expression operand) {
+ if (operand == Operand) {
+ return this;
+ }
+ return Expression.MakeUnary(NodeType, operand, Type, Method);
+ }
}
public partial class Expression {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/BoundConstants.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/BoundConstants.cs
index 9893c6ff726..0c0c701b920 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/BoundConstants.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/BoundConstants.cs
@@ -29,6 +29,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
@@ -135,7 +139,7 @@ namespace Microsoft.Linq.Expressions.Compiler {
int count = 0;
foreach (var reference in _references) {
if (!lc.CanEmitBoundConstants) {
- throw Error.CannotCompileConstant(reference.Value);
+ throw Error.CannotCompileConstant(reference.Key.Value);
}
if (ShouldCache(reference.Value)) {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/CompilerScope.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/CompilerScope.cs
index c0faaa933b7..7230dcef21c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/CompilerScope.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/CompilerScope.cs
@@ -32,6 +32,10 @@ using Microsoft.Scripting;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DebugInfoGenerator.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DebugInfoGenerator.cs
index 843b30bd1fe..4d2f39e7e0d 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DebugInfoGenerator.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DebugInfoGenerator.cs
@@ -13,11 +13,13 @@
*
* ***************************************************************************/
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
#if CODEPLEX_40
using ILGenerator = System.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#else
using ILGenerator = Microsoft.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#endif
+#endif
#if CODEPLEX_40
using System;
@@ -62,7 +64,7 @@ namespace Microsoft.Runtime.CompilerServices {
public abstract void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint);
internal virtual void MarkSequencePoint(LambdaExpression method, MethodBase methodBase, ILGenerator ilg, DebugInfoExpression sequencePoint) {
- MarkSequencePoint(method, ilg.CurrentOffset, sequencePoint);
+ MarkSequencePoint(method, ilg.ILOffset, sequencePoint);
}
internal virtual void SetLocalName(LocalBuilder localBuilder, string name) {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.Generated.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.Generated.cs
index 7d5528fa924..58c3ea74d0e 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.Generated.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.Generated.cs
@@ -201,7 +201,10 @@ namespace Microsoft.Linq.Expressions.Compiler {
}
if (!curTypeInfo.TypeChain.TryGetValue(lookingUp, out nextTypeInfo)) {
- curTypeInfo.TypeChain[lookingUp] = nextTypeInfo = new TypeInfo();
+ nextTypeInfo = new TypeInfo();
+ if (TypeUtils.CanCache(lookingUp)) {
+ curTypeInfo.TypeChain[lookingUp] = nextTypeInfo;
+ }
}
return nextTypeInfo;
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/ILGen.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/ILGen.cs
index f4521c2f0dd..4a2737c6d69 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/ILGen.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/ILGen.cs
@@ -15,11 +15,13 @@
using System; using Microsoft;
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
#if CODEPLEX_40
using ILGenerator = System.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#else
using ILGenerator = Microsoft.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#endif
+#endif
using System.Collections.Generic;
using System.Diagnostics;
@@ -36,6 +38,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/KeyedQueue.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/KeyedQueue.cs
index 464293c9c63..54c6e2649b7 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/KeyedQueue.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/KeyedQueue.cs
@@ -22,6 +22,10 @@ using System.Linq.Expressions;
using Microsoft.Linq.Expressions;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LabelInfo.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LabelInfo.cs
index ad35a95e270..f2edf80d425 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LabelInfo.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LabelInfo.cs
@@ -15,11 +15,13 @@
using System; using Microsoft;
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
#if CODEPLEX_40
using ILGenerator = System.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#else
using ILGenerator = Microsoft.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#endif
+#endif
using System.Collections.Generic;
using System.Diagnostics;
@@ -30,6 +32,10 @@ using Microsoft.Scripting.Utils;
#endif
using System.Reflection.Emit;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Binary.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Binary.cs
index 03a18d04f6a..d74806a16a2 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Binary.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Binary.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
using System.Reflection;
using System.Reflection.Emit;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Expressions.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Expressions.cs
index 35224319a84..01a34ebdd59 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Expressions.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Expressions.cs
@@ -31,6 +31,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Logical.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Logical.cs
index 2dd68e61706..26a5fb6cc7c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Logical.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Logical.cs
@@ -24,6 +24,10 @@ using Microsoft.Scripting.Utils;
using System.Reflection;
using System.Reflection.Emit;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Statements.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Statements.cs
index 530bda3a03d..a5ffac1c147 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Statements.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Statements.cs
@@ -26,6 +26,10 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Unary.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Unary.cs
index d63a1f14561..7a542085402 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Unary.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Unary.cs
@@ -29,6 +29,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.cs
index 4139dec8beb..d91af000a4d 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.cs
@@ -15,11 +15,13 @@
using System; using Microsoft;
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
#if CODEPLEX_40
using ILGenerator = System.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#else
using ILGenerator = Microsoft.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
#endif
+#endif
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -99,7 +101,7 @@ namespace Microsoft.Linq.Expressions.Compiler {
private LambdaCompiler(AnalyzedTree tree, LambdaExpression lambda) {
Type[] parameterTypes = GetParameterTypes(lambda).AddFirst(typeof(Closure));
-#if SILVERLIGHT
+#if SILVERLIGHT && MICROSOFT_SCRIPTING_CORE
var method = new DynamicMethod(lambda.Name ?? "lambda_method", lambda.ReturnType, parameterTypes);
#else
var method = new DynamicMethod(lambda.Name ?? "lambda_method", lambda.ReturnType, parameterTypes, true);
@@ -109,7 +111,11 @@ namespace Microsoft.Linq.Expressions.Compiler {
_lambda = lambda;
_method = method;
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
_ilg = new OffsetTrackingILGenerator(method.GetILGenerator());
+#else
+ _ilg = method.GetILGenerator();
+#endif
_hasClosureArgument = true;
@@ -144,7 +150,11 @@ namespace Microsoft.Linq.Expressions.Compiler {
_typeBuilder = (TypeBuilder)method.DeclaringType;
_method = method;
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
_ilg = new OffsetTrackingILGenerator(method.GetILGenerator());
+#else
+ _ilg = method.GetILGenerator();
+#endif
// These are populated by AnalyzeTree/VariableBinder
_scope = tree.Scopes[lambda];
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/OffsetTrackingILGenerator.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/OffsetTrackingILGenerator.cs
index f3f251977a9..e3755fe4fe8 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/OffsetTrackingILGenerator.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/OffsetTrackingILGenerator.cs
@@ -21,6 +21,11 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics.SymbolStore;
+// Not needed in CLR 4 builds because we have the
+// ILGenerator.ILOffset property.
+
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
@@ -28,14 +33,12 @@ namespace Microsoft.Linq.Expressions.Compiler {
#endif
/// <summary>
/// Wraps ILGenerator with code that tracks the current IL offset as instructions are emitted into the IL stream.
- /// We can conditionally compile this for non-Dev10 release only (using #ifdef MICROSOFT_SCRIPTING)
- /// as soon as Dev10 feature request (http://vstfdevdiv:8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=599427) gets implemented.
/// </summary>
internal sealed class OffsetTrackingILGenerator {
private readonly ILGenerator _ilg;
internal int _offset;
- internal int CurrentOffset { get { return _offset; } }
+ internal int ILOffset { get { return _offset; } }
internal OffsetTrackingILGenerator(ILGenerator ilg) {
Debug.Assert(ilg != null);
@@ -359,5 +362,6 @@ namespace Microsoft.Linq.Expressions.Compiler {
#endregion
}
-
}
+
+#endif
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Bindings.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Bindings.cs
index e102b5a03ad..fdd8ef6d19c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Bindings.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Bindings.cs
@@ -27,6 +27,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.cs
index 12298c86dd6..8d1cc5abf73 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.cs
@@ -30,6 +30,10 @@ using Microsoft.Runtime.CompilerServices;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolDocumentGenerator.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolDocumentGenerator.cs
index cb0775cd49c..818f7fba0b1 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolDocumentGenerator.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolDocumentGenerator.cs
@@ -15,6 +15,14 @@
using System; using Microsoft;
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
+#if CODEPLEX_40
+using ILGenerator = System.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
+#else
+using ILGenerator = Microsoft.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
+#endif
+#endif
+
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
@@ -27,10 +35,9 @@ using Microsoft.Linq.Expressions.Compiler;
#endif
using System.Reflection;
using System.Reflection.Emit;
-#if CODEPLEX_40
-using ILGenerator = System.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
-#else
-using ILGenerator = Microsoft.Linq.Expressions.Compiler.OffsetTrackingILGenerator;
+
+#if SILVERLIGHT
+using System.Core;
#endif
#if CODEPLEX_40
@@ -66,7 +73,7 @@ namespace Microsoft.Runtime.CompilerServices {
}
public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint) {
- Debug.Assert(false);
+ throw Error.PdbGeneratorNeedsExpressionCompiler();
}
internal override void SetLocalName(LocalBuilder localBuilder, string name) {
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/VariableBinder.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/VariableBinder.cs
index fb01051b8e3..6883c0ab3c1 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/VariableBinder.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Compiler/VariableBinder.cs
@@ -24,6 +24,10 @@ using System.Dynamic.Utils;
using Microsoft.Scripting.Utils;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Linq.Expressions.Compiler {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.Core.csproj b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.Core.csproj
index 766f3130950..ffd6c58aa1b 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.Core.csproj
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.Core.csproj
@@ -1,10 +1,11 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>10.0.20624</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2AE75F5A-CD1F-4925-9647-AF4D1C282FB4}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -14,13 +15,13 @@
<AssemblyName>Microsoft.Scripting.Core</AssemblyName>
<DocumentationFile>$(OutputPath)\Microsoft.Scripting.Core.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
- <OldToolsVersion>2.0</OldToolsVersion>
<AssemblyOriginatorKeyFile>$(SolutionDir)\Runtime\MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
<SignAssembly Condition="'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')">true</SignAssembly>
<SignedSym Condition="'$(SignAssembly)' == 'true'">SIGNED</SignedSym>
<DelaySign>true</DelaySign>
- <SilverlightPath Condition="$(SilverlightPath) == ''">$(ProgramFiles)\Microsoft Silverlight\2.0.40115.0</SilverlightPath>
+ <SilverlightPath Condition="'$(SilverlightPath)' == ''">$(ProgramFiles)\Microsoft Silverlight\3.0.40624.0</SilverlightPath>
<BaseAddress>855638016</BaseAddress>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FxCop|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -89,8 +90,8 @@
<SilverlightBuild>true</SilverlightBuild>
</PropertyGroup>
<ItemGroup>
- <Reference Include="System" Condition=" $(SilverlightBuild) != 'true' " />
- <Reference Include="System.Configuration" Condition=" $(SilverlightBuild) != 'true' " />
+ <Reference Include="System" Condition=" '$(SilverlightBuild)' != 'true' " />
+ <Reference Include="System.Configuration" Condition=" '$(SilverlightBuild)' != 'true' " />
<Reference Include="mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" Condition=" '$(SilverlightBuild)' == 'true' ">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SilverlightPath)\mscorlib.dll</HintPath>
@@ -99,8 +100,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SilverlightPath)\System.dll</HintPath>
</Reference>
- <Reference Include="System.Data" Condition=" $(SilverlightBuild) != 'true' " />
- <Reference Include="System.Xml" Condition=" $(SilverlightBuild) != 'true' " />
+ <Reference Include="System.Data" Condition=" '$(SilverlightBuild)' != 'true' " />
+ <Reference Include="System.Xml" Condition=" '$(SilverlightBuild)' != 'true' " />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Hosts\Silverlight\SilverlightVersion.cs" Condition=" '$(SilverlightBuild)' == 'true' ">
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.ExtensionAttribute.csproj b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.ExtensionAttribute.csproj
index 863a5d01eeb..7ff289cce50 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.ExtensionAttribute.csproj
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.ExtensionAttribute.csproj
@@ -1,23 +1,23 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>10.0.20624</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8B0F1074-750E-4D64-BF23-A1E0F54261E5}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Scripting.ExtensionAttribute</RootNamespace>
<AssemblyName>Microsoft.Scripting.ExtensionAttribute</AssemblyName>
- <OldToolsVersion>2.0</OldToolsVersion>
<AssemblyOriginatorKeyFile>$(SolutionDir)\Runtime\MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
<SignAssembly Condition="'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')">true</SignAssembly>
<SignedSym Condition="'$(SignAssembly)' == 'true'">SIGNED</SignedSym>
<DelaySign>true</DelaySign>
<BaseAddress>866123776</BaseAddress>
- <SilverlightPath Condition="$(SilverlightPath) == ''">$(ProgramFiles)\Microsoft Silverlight\2.0.40115.0</SilverlightPath>
+ <SilverlightPath Condition="'$(SilverlightPath)' == ''">$(ProgramFiles)\Microsoft Silverlight\3.0.40624.0</SilverlightPath>
+ <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'FxCop|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -77,7 +77,7 @@
<SilverlightBuild>true</SilverlightBuild>
</PropertyGroup>
<ItemGroup>
- <Reference Include="System" Condition=" $(SilverlightBuild) != 'true' " />
+ <Reference Include="System" Condition=" '$(SilverlightBuild)' != 'true' " />
<Reference Include="mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" Condition=" '$(SilverlightBuild)' == 'true' ">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SilverlightPath)\mscorlib.dll</HintPath>
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Properties/AssemblyInfo.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Properties/AssemblyInfo.cs
index 8760043dbb1..ca62dd972ae 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Properties/AssemblyInfo.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Properties/AssemblyInfo.cs
@@ -63,7 +63,7 @@ using System.Security;
[assembly: System.Resources.NeutralResourcesLanguage("en-US")]
#if !SILVERLIGHT
-[assembly: AssemblyVersion("0.9.6.10")]
+[assembly: AssemblyVersion("0.9.6.20")]
[assembly: AssemblyFileVersion("1.0.0.00")]
[assembly: AssemblyInformationalVersion("1.0")]
[assembly: AllowPartiallyTrustedCallers]
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Stubs.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Stubs.cs
index 25ef27c9f77..c86ce620bfe 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Stubs.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Stubs.cs
@@ -27,6 +27,13 @@ using Microsoft.Scripting.Utils;
#if SILVERLIGHT // Stubs
+// This is needed so we can build Silverlight version on Codeplex
+// where System.Core namespace is not defined.
+namespace System.Core
+{
+ class Dummy { }
+}
+
namespace System {
/// <summary>
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Action.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Action.cs
index 3d6eee3ae10..c445a3250db 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Action.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Action.cs
@@ -20,14 +20,14 @@ namespace System {
#else
namespace Microsoft {
#endif
- #if MICROSOFT_SCRIPTING_CORE
+ #if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
/// <summary>
/// Encapsulates a method that takes no parameters and does not return a value.
/// </summary>
public delegate void Action();
- #endif
+#endif
// public delegate void Action<T>(T obj); -- Already defined in mscorlib
@@ -36,7 +36,7 @@ namespace Microsoft {
// *** BEGIN GENERATED CODE ***
// generated by function: gen_action_types from: generate_dynsites.py
-#if MICROSOFT_SCRIPTING_CORE
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
/// <summary>
/// Encapsulates a method that takes two parameters and does not return a value.
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/CollectionExtensions.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/CollectionExtensions.cs
index 48ac6c1e17d..7b285b86d7c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/CollectionExtensions.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/CollectionExtensions.cs
@@ -18,6 +18,9 @@ using System; using Microsoft;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
+#if !MICROSOFT_SCRIPTING_CORE
+using System.Diagnostics.Contracts;
+#endif
using System.Runtime.CompilerServices;
#if !CODEPLEX_40
using Microsoft.Runtime.CompilerServices;
@@ -37,6 +40,9 @@ namespace Microsoft.Scripting.Utils {
/// changed after creation. The exception is if the enumerable is
/// already a ReadOnlyCollection{T}, in which case we just return it.
/// </summary>
+#if !MICROSOFT_SCRIPTING_CORE
+ [Pure]
+#endif
internal static ReadOnlyCollection<T> ToReadOnly<T>(this IEnumerable<T> enumerable) {
if (enumerable == null) {
return EmptyReadOnlyCollection<T>.Instance;
@@ -78,6 +84,9 @@ namespace Microsoft.Scripting.Utils {
return h;
}
+#if !MICROSOFT_SCRIPTING_CORE
+ [Pure]
+#endif
internal static bool ListEquals<T>(this ICollection<T> first, ICollection<T> second) {
if (first.Count != second.Count) {
return false;
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ContractUtils.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ContractUtils.cs
index 2e09e18c7f2..a83426ac172 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ContractUtils.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ContractUtils.cs
@@ -23,6 +23,10 @@ using System.Linq.Expressions;
using Microsoft.Linq.Expressions;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Dynamic.Utils {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ExceptionFactory.Generated.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ExceptionFactory.Generated.cs
index b08b49e68cc..c58f0e1fa87 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ExceptionFactory.Generated.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ExceptionFactory.Generated.cs
@@ -1494,6 +1494,15 @@ namespace Microsoft.Linq.Expressions {
return FormatString("An IDynamicMetaObjectProvider {0} created an invalid DynamicMetaObject instance.", p0);
}
+ /// <summary>
+ /// A string like "DebugInfoGenerator created by CreatePdbGenerator can only be used with LambdaExpression.CompileToMethod."
+ /// </summary>
+ internal static string PdbGeneratorNeedsExpressionCompiler {
+ get {
+ return "DebugInfoGenerator created by CreatePdbGenerator can only be used with LambdaExpression.CompileToMethod.";
+ }
+ }
+
}
/// <summary>
/// Strongly-typed and parameterized exception factory.
@@ -2515,6 +2524,13 @@ namespace Microsoft.Linq.Expressions {
return new InvalidOperationException(Strings.InvalidMetaObjectCreated(p0));
}
+ /// <summary>
+ /// NotSupportedException with message like "DebugInfoGenerator created by CreatePdbGenerator can only be used with LambdaExpression.CompileToMethod."
+ /// </summary>
+ internal static Exception PdbGeneratorNeedsExpressionCompiler() {
+ return new NotSupportedException(Strings.PdbGeneratorNeedsExpressionCompiler);
+ }
+
}
// *** END GENERATED CODE ***
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Function.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Function.cs
index be68a4f7145..331afc8df45 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Function.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/Function.cs
@@ -21,7 +21,7 @@ namespace System {
namespace Microsoft {
#endif
- #if MICROSOFT_SCRIPTING_CORE
+ #if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
/// <summary>
/// Encapsulates a method that has no parameters and returns a value of the type specified by the TResult parameter.
@@ -39,14 +39,14 @@ namespace Microsoft {
/// <returns>The return value of the method that this delegate encapsulates.</returns>
public delegate TResult Func<T, TResult>(T arg);
- #endif
+#endif
#region Generated Func Types
// *** BEGIN GENERATED CODE ***
// generated by function: gen_func_types from: generate_dynsites.py
-#if MICROSOFT_SCRIPTING_CORE
+#if MICROSOFT_SCRIPTING_CORE || SILVERLIGHT
/// <summary>
/// Encapsulates a method that has two parameters and returns a value of the type specified by the TResult parameter.
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyCollectionBuilder.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyCollectionBuilder.cs
index e9c24a93bf9..501f4df304f 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyCollectionBuilder.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyCollectionBuilder.cs
@@ -25,6 +25,10 @@ using Microsoft.Scripting.Utils;
using Microsoft.Linq.Expressions;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Runtime.CompilerServices {
#else
@@ -34,7 +38,9 @@ namespace Microsoft.Runtime.CompilerServices {
/// The builder for read only collection.
/// </summary>
/// <typeparam name="T">The type of the collection element.</typeparam>
+#if !SILVERLIGHT
[Serializable]
+#endif
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public sealed class ReadOnlyCollectionBuilder<T> : IList<T>, System.Collections.IList {
private const int DefaultCapacity = 4;
@@ -42,7 +48,10 @@ namespace Microsoft.Runtime.CompilerServices {
private T[] _items;
private int _size;
private int _version;
+
+#if !SILVERLIGHT
[NonSerialized]
+#endif
private Object _syncRoot;
static readonly T[] _emptyArray = new T[0];
@@ -450,7 +459,9 @@ namespace Microsoft.Runtime.CompilerServices {
throw new ArgumentException(Strings.InvalidObjectType(value != null ? value.GetType() : (object)"null", typeof(T)), argument);
}
+#if !SILVERLIGHT
[Serializable]
+#endif
private class Enumerator : IEnumerator<T>, System.Collections.IEnumerator {
private readonly ReadOnlyCollectionBuilder<T> _builder;
private readonly int _version;
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyDictionary.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyDictionary.cs
index 3d444f371b9..94fb35a7076 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyDictionary.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyDictionary.cs
@@ -22,6 +22,10 @@ using System.Linq.Expressions;
using Microsoft.Linq.Expressions;
#endif
+#if SILVERLIGHT
+using System.Core;
+#endif
+
#if CODEPLEX_40
namespace System.Dynamic.Utils {
#else
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/TypeExtensions.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/TypeExtensions.cs
index 10e2c553cdc..8654baff36e 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/TypeExtensions.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Utils/TypeExtensions.cs
@@ -67,7 +67,12 @@ namespace Microsoft.Scripting.Utils {
ParameterInfo[] pis;
lock (_ParamInfoCache) {
if (!_ParamInfoCache.TryGetValue(method, out pis)) {
- _ParamInfoCache[method] = pis = method.GetParameters();
+ pis = method.GetParameters();
+
+ Type t = method.DeclaringType;
+ if (t != null && TypeUtils.CanCache(t)) {
+ _ParamInfoCache[method] = pis;
+ }
}
}
return pis;