瀏覽代碼

[System.Core] SLE from CoreFX including interpreter

Marek Safar 9 年之前
父節點
當前提交
9d5de96b0f
共有 100 個文件被更改,包括 419 次插入15452 次删除
  1. 1 1
      external/corefx
  2. 24 0
      mcs/build/common/SR.cs
  3. 0 1
      mcs/class/Makefile
  4. 0 53
      mcs/class/Mono.Dynamic.Interpreter/Assembly/AssemblyInfo.cs
  5. 0 27
      mcs/class/Mono.Dynamic.Interpreter/Makefile
  6. 0 103
      mcs/class/Mono.Dynamic.Interpreter/Mono.Dynamic.Interpreter.dll.sources
  7. 6 36
      mcs/class/System.Core/Makefile
  8. 1 0
      mcs/class/System.Core/System.Core_test.dll.sources
  9. 0 47
      mcs/class/System.Core/System.Linq.Expressions.Interpret/LambdaCompiler.cs
  10. 0 3
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Add.cs
  11. 0 7
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_AndAlso.cs
  12. 0 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Bind.cs
  13. 1 8
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Call.cs
  14. 0 6
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Coalesce.cs
  15. 2 8
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Convert.cs
  16. 0 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Equal.cs
  17. 0 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_GreaterThan.cs
  18. 0 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_GreaterThanOrEqual.cs
  19. 0 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Invoke.cs
  20. 1 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Lambda.cs
  21. 0 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_LessThan.cs
  22. 0 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_LessThanOrEqual.cs
  23. 0 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_ListBind.cs
  24. 0 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_ListInit.cs
  25. 81 0
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Loop.cs
  26. 0 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_MemberBind.cs
  27. 0 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_MemberInit.cs
  28. 0 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Negate.cs
  29. 0 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Not.cs
  30. 1 5
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_OrElse.cs
  31. 1 2
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Power.cs
  32. 0 1
      mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Quote.cs
  33. 56 4
      mcs/class/System.Core/common_System.Core.dll.sources
  34. 17 0
      mcs/class/System.Core/corefx/LambdaExpression.cs
  35. 183 0
      mcs/class/System.Core/corefx/SR.cs
  36. 4 0
      mcs/class/System.Core/corefx/SR.missing.cs
  37. 31 114
      mcs/class/System.Core/dynamic_System.Core.dll.sources
  38. 2 87
      mcs/class/System.Core/interpreter_System.Core.dll.sources
  39. 0 8
      mcs/class/System.Numerics.Vectors/SR.cs
  40. 6 1
      mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
  41. 1 5
      mcs/class/dlr/Makefile
  42. 0 8
      mcs/class/dlr/README
  43. 0 5
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Actions/Dummy.cs
  44. 0 133
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/BinaryExpression.cs
  45. 0 235
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs
  46. 0 45
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/EmptyStatements.cs
  47. 0 149
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/LightLambdaExpression.cs
  48. 0 82
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/UnaryExpression.cs
  49. 0 111
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/Utils.cs
  50. 0 911
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs
  51. 0 128
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/ConstantCheck.cs
  52. 0 110
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/DelegateHelpers.Generated.cs
  53. 0 87
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/DelegateHelpers.cs
  54. 0 108
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/BranchLabel.cs
  55. 0 34
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/ILightCallSiteBinder.cs
  56. 0 191
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs
  57. 0 176
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs
  58. 0 50
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ArithmeticInstruction.cs
  59. 0 134
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ArrayOperations.cs
  60. 0 905
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.Generated.cs
  61. 0 300
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.cs
  62. 0 50
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ComparisonInstruction.cs
  63. 0 58
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ConstantInstruction.cs
  64. 0 623
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ControlFlowInstructions.cs
  65. 0 132
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DivInstruction.cs
  66. 0 76
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructionN.cs
  67. 0 509
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructions.Generated.cs
  68. 0 55
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicSplatInstruction.cs
  69. 0 201
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
  70. 0 94
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/FieldOperations.cs
  71. 0 171
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs
  72. 0 171
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs
  73. 0 61
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/Instruction.cs
  74. 0 123
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs
  75. 0 1074
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs
  76. 0 309
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LabelInfo.cs
  77. 0 171
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs
  78. 0 171
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs
  79. 0 374
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LocalAccess.cs
  80. 0 118
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs
  81. 0 204
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs
  82. 0 368
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NegateInstruction.cs
  83. 0 202
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
  84. 0 191
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotInstruction.cs
  85. 0 254
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NumericConvertInstruction.cs
  86. 0 176
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs
  87. 0 160
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs
  88. 0 160
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs
  89. 0 118
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/StackOperations.cs
  90. 0 204
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs
  91. 0 193
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/TypeOperations.cs
  92. 0 176
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs
  93. 0 297
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/InterpretedFrame.cs
  94. 0 262
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs
  95. 0 1736
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs
  96. 0 198
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs
  97. 0 756
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.Generated.cs
  98. 0 280
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs
  99. 0 260
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambdaClosureVisitor.cs
  100. 0 266
      mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LocalVariables.cs

+ 1 - 1
external/corefx

@@ -1 +1 @@
-Subproject commit aea0864c79826fa9e6b65689c16f2d2c911c7c1f
+Subproject commit 4323a3d33746eee175b7f705e61ef24848c17de6

+ 24 - 0
mcs/build/common/SR.cs

@@ -21,6 +21,30 @@ static partial class SR
 	{
 		return name;
 	}
+
+	internal static string Format(string resourceFormat, params object[] args)
+	{
+		if (args != null) {
+			return string.Format (CultureInfo.InvariantCulture, resourceFormat, args);
+		}
+
+		return resourceFormat;
+	}
+
+	internal static string Format(string resourceFormat, object p1)
+	{
+		return string.Format (CultureInfo.InvariantCulture, resourceFormat, p1);
+	}
+
+	internal static string Format(string resourceFormat, object p1, object p2)
+	{
+		return string.Format (CultureInfo.InvariantCulture, resourceFormat, p1, p2);
+	}
+
+	internal static string Format(string resourceFormat, object p1, object p2, object p3)
+	{
+		return string.Format (CultureInfo.InvariantCulture, resourceFormat, p1, p2, p3);
+	}
 }
 
 namespace System.Runtime.CompilerServices

+ 0 - 1
mcs/class/Makefile

@@ -85,7 +85,6 @@ mobile_common_dirs := \
 
 aot_only_dirs := \
 	$(mobile_common_dirs)	\
-	Mono.Dynamic.Interpreter	\
 	Mono.CompilerServices.SymbolWriter	\
 	Mono.Simd			\
 	$(pcl_facade_dirs)

+ 0 - 53
mcs/class/Mono.Dynamic.Interpreter/Assembly/AssemblyInfo.cs

@@ -1,53 +0,0 @@
-//
-// AssemblyInfo.cs
-//
-// Authors:
-//	Marek Safar ([email protected])
-//
-// Copyright (c) 2014 Xamarin Inc. (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Reflection;
-using System.Resources;
-using System.Security;
-using System.Security.Permissions;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about the assembly
-
-[assembly: AssemblyTitle ("Mono.Dynamic.Interpreter.dll")]
-[assembly: AssemblyDescription ("Mono.Dynamic.Interpreter.dll")]
-[assembly: AssemblyDefaultAlias ("Mono.Dynamic.Interpreter.dll")]
-
-[assembly: AssemblyCompany (Consts.MonoCompany)]
-[assembly: AssemblyProduct (Consts.MonoProduct)]
-[assembly: AssemblyCopyright (Consts.MonoCopyright)]
-[assembly: AssemblyVersion (Consts.FxVersion)]
-[assembly: SatelliteContractVersion (Consts.FxVersion)]
-[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)]
-[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
-
-[assembly: CLSCompliant (true)]
-

+ 0 - 27
mcs/class/Mono.Dynamic.Interpreter/Makefile

@@ -1,27 +0,0 @@
-thisdir = class/Mono.Dynamic.Interpreter
-SUBDIRS = 
-include ../../build/rules.make
-
-LIBRARY = Mono.Dynamic.Interpreter.dll
-
-LIB_REFS = System
-LIB_MCS_FLAGS = \
-	-d:FEATURE_CORE_DLR,FEATURE_DBNULL,FEATURE_DEFAULT_PARAMETER_VALUE,FEATURE_GET_TYPE_INFO,FEATURE_VARIANCE,FEATURE_SERIALIZATION,CLR45 \
-	-d:MONO_INTERPRETER \
-	-delaysign -keyfile:../mono.pub
-
-ifdef AOT_FRIENDLY_PROFILE
-mono_dynamic_interpreter_deps = $(the_libdir_base)plaincore/System.Core.dll
-LIB_REFS += plaincore/System.Core
-else
-LIB_REFS += System.Core
-endif
-
-include ../../build/library.make
-
-$(the_libdir_base)Mono.Dynamic.Interpreter.dll: $(mono_dynamic_interpreter_deps)
-
-$(the_libdir_base)plaincore/System.Core.dll:
-	(cd ../System.Core; $(MAKE) $@)
-
-.NOTPARALLEL: $(the_libdir_base)plaincore/System.Core.dll

+ 0 - 103
mcs/class/Mono.Dynamic.Interpreter/Mono.Dynamic.Interpreter.dll.sources

@@ -1,103 +0,0 @@
-../../build/common/Consts.cs
-Assembly/AssemblyInfo.cs
-
-../dlr/Runtime/Microsoft.Scripting/ArgumentTypeException.cs
-../dlr/Runtime/Microsoft.Scripting/InvalidImplementationException.cs
-../dlr/Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs
-../dlr/Runtime/Microsoft.Scripting/Stubs.cs
-
-../dlr/Runtime/Microsoft.Scripting/Runtime/NotNullAttribute.cs
-../dlr/Runtime/Microsoft.Scripting/Runtime/ParamDictionaryAttribute.cs
-
-../dlr/Runtime/Microsoft.Dynamic/DebugOptions.cs
-../dlr/Runtime/Microsoft.Dynamic/MultiRuntimeAwareAttribute.cs
-../dlr/Runtime/Microsoft.Dynamic/PerfTrack.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Actions/Dummy.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Ast/BinaryExpression.cs
-../dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs
-../dlr/Runtime/Microsoft.Dynamic/Ast/EmptyStatements.cs
-../dlr/Runtime/Microsoft.Dynamic/Ast/LightLambdaExpression.cs
-../dlr/Runtime/Microsoft.Dynamic/Ast/UnaryExpression.cs
-../dlr/Runtime/Microsoft.Dynamic/Ast/Utils.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs
-../dlr/Runtime/Microsoft.Dynamic/Generation/ConstantCheck.cs
-../dlr/Runtime/Microsoft.Dynamic/Generation/DelegateHelpers.cs
-../dlr/Runtime/Microsoft.Dynamic/Generation/DelegateHelpers.Generated.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/BranchLabel.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/ILightCallSiteBinder.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/InterpretedFrame.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.Generated.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambdaClosureVisitor.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/LocalVariables.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/LoopCompiler.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/RuntimeVariables.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ArithmeticInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ArrayOperations.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ComparisonInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ConstantInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.Generated.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ControlFlowInstructions.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DivInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructionN.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructions.Generated.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicSplatInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/FieldOperations.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/Instruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LabelInfo.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LocalAccess.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NegateInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NumericConvertInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/StackOperations.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/TypeOperations.cs
-../dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Math/Complex64.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Runtime/ArgumentArray.cs
-../dlr/Runtime/Microsoft.Dynamic/Runtime/DynamicNull.cs
-../dlr/Runtime/Microsoft.Dynamic/Runtime/ExceptionHelpers.cs
-../dlr/Runtime/Microsoft.Dynamic/Runtime/ScriptingRuntimeHelpers.cs
-
-../dlr/Runtime/Microsoft.Dynamic/Utils/ArrayUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/Assert.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/CacheDict.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/ContractUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/CollectionExtensions.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/CollectionUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/DynamicUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/ExceptionUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/ExceptionFactory.Generated.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/HybridReferenceDictionary.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/ListEqualityComparer.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/MathUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/ReferenceEqualityComparer.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/ReflectionUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/StringUtils.cs
-../dlr/Runtime/Microsoft.Dynamic/Utils/TypeUtils.cs

+ 6 - 36
mcs/class/System.Core/Makefile

@@ -8,37 +8,23 @@ REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,PFX_LEGACY_3_5,FEATURE_NETCORE
 LIB_REFS = System
 LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) -d:INSIDE_SYSCORE -d:LIBC -unsafe -nowarn:436
 TXT_RESOURCE_STRINGS = ../referencesource/System.Core/System.Core.txt
+RESX_RESOURCE_STRING = ../../../external/corefx/src/System.Linq.Expressions/src/Resources/Strings.resx
 
 ifneq (2.1, $(FRAMEWORK_VERSION))
-LIB_MCS_FLAGS += -d:NET_3_5 -nowarn:1720
+LIB_MCS_FLAGS += -d:NET_3_5
 endif
 
-ifdef MOBILE_DYNAMIC
-LIB_MCS_FLAGS += -d:FEATURE_CORE_DLR,FEATURE_REFEMIT
-endif
-
-system_core_plain_libdir = $(the_libdir_base)plaincore
-
 ifdef AOT_FRIENDLY_PROFILE
 extra_test_flags := -exclude:NotWorkingInterpreter
-system_core_library_deps = $(the_libdir_base)Mono.Dynamic.Interpreter.dll $(system_core_plain_libdir)/System.Core.dll
-LIB_MCS_FLAGS += -d:FEATURE_CORE_DLR
-
-ifneq (plaincore/,$(intermediate))
-LIB_REFS += Mono.Dynamic.Interpreter
-LIB_MCS_FLAGS += -d:MONO_INTERPRETER
-endif
-
+LIB_MCS_FLAGS += -d:NO_FEATURE_STATIC_DELEGATE,FEATURE_MAKE_RUN_METHODS
+else
+LIB_MCS_FLAGS += -d:FEATURE_COMPILE,FEATURE_COMPILE_TO_METHODBUILDER,FEATURE_PDB_GENERATOR
 endif
 
 ifeq (monotouch_runtime, $(PROFILE))
 LIB_MCS_FLAGS += -d:FULL_AOT_RUNTIME
 endif
 
-ifeq (4, $(FRAMEWORK_VERSION_MAJOR))
-LIB_MCS_FLAGS += -d:FEATURE_CORE_DLR,FEATURE_REFEMIT,FEATURE_PDBEMIT
-endif
-
 ifneq (basic, $(PROFILE))
 CLR_PROFILE := $(filter 2.0 4.0 4.5, $(FRAMEWORK_VERSION))
 endif
@@ -61,25 +47,9 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
 
 include ../../build/library.make
 
-$(the_libdir_base)System.Core.dll: $(system_core_library_deps)
-
-.NOTPARALLEL: $(system_core_plain_libdir)/System.Core.dll $(the_libdir_base)Mono.Dynamic.Interpreter.dll
-
-ifneq (plaincore/,$(intermediate))
-$(system_core_plain_libdir)/System.Core.dll:
-	$(MAKE) intermediate=plaincore/ $(system_core_plain_libdir)/System.Core.dll
-endif
-
-$(the_libdir_base)Mono.Dynamic.Interpreter.dll:
-	(cd ../Mono.Dynamic.Interpreter; $(MAKE))
-
 TEST_HARNESS_EXCLUDES += $(extra_test_flags)
 
-CLEAN_FILES = $(system_core_plain_libdir)/System.Core.dll
-
-ifndef intermediate
 ifneq ($(PROFILE),basic)
 csproj-local:
-	$(MAKE) csproj-local intermediate=plaincore/
-endif
+	$(MAKE) csproj-local
 endif

+ 1 - 0
mcs/class/System.Core/System.Core_test.dll.sources

@@ -34,6 +34,7 @@ System.Linq.Expressions/ExpressionTest_LeftShift.cs
 System.Linq.Expressions/ExpressionTest_Lift.cs
 System.Linq.Expressions/ExpressionTest_ListBind.cs
 System.Linq.Expressions/ExpressionTest_ListInit.cs
+System.Linq.Expressions/ExpressionTest_Loop.cs
 System.Linq.Expressions/ExpressionTest_MakeBinary.cs
 System.Linq.Expressions/ExpressionTest_MemberBind.cs
 System.Linq.Expressions/ExpressionTest_MemberInit.cs

+ 0 - 47
mcs/class/System.Core/System.Linq.Expressions.Interpret/LambdaCompiler.cs

@@ -1,47 +0,0 @@
-// 
-// LambdaCompiler.cs: System.Linq.Expression interpreter entry point
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System.Runtime.CompilerServices;
-#if MONO_INTERPRETER
-using Microsoft.Scripting.Generation;
-#endif
-
-namespace System.Linq.Expressions.Compiler
-{
-	static class LambdaCompiler
-	{
-		public static Delegate Compile (LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
-		{
-#if MONO_INTERPRETER
-			return lambda.LightCompile ();
-#else			
-			throw new NotSupportedException ("System.Linq.Expression interpreter is missing");
-#endif
-		}
-	}
-}

+ 0 - 3
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Add.cs

@@ -183,7 +183,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void AddTestNullable ()
 		{
 			var a = Expression.Parameter (typeof (int?), "a");
@@ -238,7 +237,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedAddLifted ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");
@@ -378,7 +376,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void AddLiftedDecimals ()
 		{
 			var l = Expression.Parameter (typeof (decimal?), "l");

+ 0 - 7
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_AndAlso.cs

@@ -143,7 +143,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void AndAlsoTestNullable ()
 		{
 			var a = Expression.Parameter (typeof (bool?), "a");
@@ -187,7 +186,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void AndAlsoNullableBoolItem ()
 		{
 			var i = Expression.Parameter (typeof (Item<bool?>), "i");
@@ -233,7 +231,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedAndAlso ()
 		{
 			var l = Expression.Parameter (typeof (Slot), "l");
@@ -254,7 +251,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedAndAlsoShortCircuit ()
 		{
 			var i = Expression.Parameter (typeof (Item<Slot>), "i");
@@ -270,7 +266,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		[Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=350228
 		public void UserDefinedLiftedAndAlsoShortCircuit ()
 		{
@@ -287,7 +282,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedAndAlsoLiftedToNull ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");
@@ -366,7 +360,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test] // from https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=350487
-		[Category ("NotWorkingInterpreter")]
 		public void Connect350487 ()
 		{
 			var p = Expression.Parameter (typeof (B), "b");

+ 0 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Bind.cs

@@ -145,7 +145,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void BindValueTypes ()
 		{
 			var i = Expression.Parameter (typeof (int), "i");

+ 1 - 8
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Call.cs

@@ -224,7 +224,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CallMethodOnStruct ()
 		{
 			var param = Expression.Parameter (typeof (EineStrukt), "s");
@@ -272,7 +271,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CallStaticMethodWithRefParameter ()
 		{
 			var p = Expression.Parameter (typeof (int), "i");
@@ -284,7 +282,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CallStaticMethodWithRefParameterAndOtherParameter ()
 		{
 			var i = Expression.Parameter (typeof (int), "i");
@@ -339,7 +336,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void Connect282729 ()
 		{
 			// test from https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282729
@@ -366,8 +362,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorking")]
-		[Category ("NotWorkingInterpreter")]
 		public void Connect290278 ()
 		{
 			// test from https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=290278
@@ -390,7 +384,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void Connect297597 ()
 		{
 			// test from https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=297597
@@ -408,6 +401,7 @@ namespace MonoTests.System.Linq.Expressions {
 
 		[Test]
 		[Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=319190
+		[Category ("NotWorkingInterpreter")]
 		public void Connect319190 ()
 		{
 			var lambda = Expression.Lambda<Func<bool>> (
@@ -513,7 +507,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CallNullableGetValueOrDefault () // #568989
 		{
 			var value = Expression.Parameter (typeof (int?), "value");

+ 0 - 6
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Coalesce.cs

@@ -87,7 +87,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CoalesceNullableInt ()
 		{
 			var a = Expression.Parameter (typeof (int?), "a");
@@ -116,7 +115,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CoalesceNullableToNonNullable ()
 		{
 			var a = Expression.Parameter (typeof (int?), "a");
@@ -134,7 +132,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		[Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=349822
 		public void CoalesceUserDefinedConversion ()
 		{
@@ -166,9 +163,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		// #12987
-		[Category ("MobileNotWorking")]
-		[Category ("NotWorkingInterpreter")]
 		public void CoalesceNullableSlotIntoInteger ()
 		{
 			var s = Expression.Parameter (typeof (Slot?), "s");

+ 2 - 8
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Convert.cs

@@ -71,7 +71,7 @@ namespace MonoTests.System.Linq.Expressions {
 			var c = Expression.Convert (
 				Expression.Constant (null, typeof (Bar)), typeof (Foo));
 
-			Assert.AreEqual ("Convert(null)", c.ToString ());
+			Assert.AreEqual ("Convert(null, Foo)", c.ToString ());
 		}
 
 		[Test]
@@ -94,7 +94,7 @@ namespace MonoTests.System.Linq.Expressions {
 				Expression.Constant (2, typeof (int)), typeof (long));
 
 			Assert.AreEqual (ExpressionType.ConvertChecked, c.NodeType);
-			Assert.AreEqual ("ConvertChecked(2)", c.ToString ());
+			Assert.AreEqual ("ConvertChecked(2, Int64)", c.ToString ());
 		}
 
 		[Test]
@@ -359,7 +359,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CompileNullableToNotNullable ()
 		{
 			var p = Expression.Parameter (typeof (int?), "i");
@@ -452,7 +451,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void ConvertImplicitToShortToNullableInt ()
 		{
 			var a = Expression.Parameter (typeof (ImplicitToShort?), "a");
@@ -478,7 +476,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void NullableImplicitToShort ()
 		{
 			var i = Expression.Parameter (typeof (ImplicitToShort?), "i");
@@ -514,7 +511,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void ConvertNullableULongToNullableDecimal ()
 		{
 			var p = Expression.Parameter (typeof (ulong?), "l");
@@ -559,7 +555,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void ConvertNullableImplictToIntToNullableLong ()
 		{
 			var i = Expression.Parameter (typeof (ImplicitToInt?), "i");
@@ -577,7 +572,6 @@ namespace MonoTests.System.Linq.Expressions {
 
 		[Test]
 		[ExpectedException (typeof (InvalidOperationException))]
-		[Category ("NotWorking")]
 		public void ConvertNullableIntToStringWithConvertMethod ()
 		{
 			Expression.Convert (

+ 0 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Equal.cs

@@ -248,7 +248,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedEqualLifted ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");
@@ -270,7 +269,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedEqualLiftedToNull ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");

+ 0 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_GreaterThan.cs

@@ -191,7 +191,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedGreaterThanLifted ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");
@@ -214,7 +213,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedGreaterThanLiftedToNull ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");

+ 0 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_GreaterThanOrEqual.cs

@@ -165,7 +165,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedGreaterThanOrEqualLifted ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");
@@ -188,7 +187,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedGreaterThanOrEqualLiftedToNull ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");

+ 0 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Invoke.cs

@@ -130,7 +130,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void InvokeWithExpressionLambdaAsArguments ()
 		{
 			var p = Expression.Parameter (typeof (string), "s");

+ 1 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Lambda.cs

@@ -194,7 +194,7 @@ namespace MonoTests.System.Linq.Expressions
 		{
 			var l = Expression.Lambda ("foo".ToConstant ());
 
-			Assert.AreEqual (typeof (Expression<Func<string>>), l.GetType ());
+			Assert.AreEqual (typeof (Func<string>), l.Type);
 		}
 
 		public static int CallDelegate (Func<int, int> e)

+ 0 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_LessThan.cs

@@ -165,7 +165,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedLessThanLifted ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");
@@ -188,7 +187,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedLessThanLiftedToNull ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");

+ 0 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_LessThanOrEqual.cs

@@ -165,7 +165,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedLessThanOrEqualLifted ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");
@@ -188,7 +187,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedLessThanOrEqualLiftedToNull ()
 		{
 			var l = Expression.Parameter (typeof (Slot?), "l");

+ 0 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_ListBind.cs

@@ -99,7 +99,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CompiledListBinding ()
 		{
 			var add = typeof (List<string>).GetMethod ("Add");

+ 0 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_ListInit.cs

@@ -126,7 +126,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CompileListOfStringsInit ()
 		{
 			var add = typeof (List<string>).GetMethod ("Add");
@@ -146,7 +145,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		[Category ("NotDotNet")]
 		public void CompileArrayListOfStringsInit ()
 		{

+ 81 - 0
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Loop.cs

@@ -0,0 +1,81 @@
+//
+// ExpressionTest_Loop.cs
+//
+// Author:
+//   Marek Safar ([email protected])
+//
+// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Reflection;
+using System.Linq;
+using System.Linq.Expressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Linq.Expressions {
+
+	[TestFixture]
+	public class ExpressionTest_Loop {
+
+		[Test]
+		public void ComplexTest ()
+		{
+            var breakLabel = Expression.Label ("LoopBreak");
+            var counter = Expression.Variable (typeof (int), "counter");
+
+            var l = Expression.Block (new[] { counter },
+                Expression.Assign (counter, Expression.Constant (-1)),
+                Expression.Loop (
+                Expression.Block (Expression.IfThenElse (
+                    Expression.Equal (Expression.Assign (counter, Expression.Add (counter, Expression.Constant (1))), Expression.Constant (1000)),
+                    Expression.Block (Expression.Break (breakLabel)),
+                    Expression.Call (null, typeof (Console).GetMethod ("WriteLine", new Type[] { typeof (int) }), counter)
+                )),
+                breakLabel)
+           );
+
+            var res = Expression.Lambda<Action> (l).Compile ();
+        }
+
+		[Test]
+		public void ComplexTest_2 ()
+		{
+            var breakLabel = Expression.Label ("LoopBreak");
+            var counter = Expression.Variable (typeof (int), "counter");
+
+            var l = Expression.Block (new[] { counter },
+                Expression.Assign (counter, Expression.Constant(-1)),
+                Expression.Loop (
+                Expression.IfThenElse (
+                    Expression.Equal (Expression.Assign (counter, Expression.Add (counter, Expression.Constant (1))), Expression.Constant (1000)),
+                    Expression.Break (breakLabel),
+                    Expression.Call (null, typeof (Console).GetMethod ("WriteLine", new Type[] { typeof (int) }), counter)
+                ),
+                breakLabel)
+           );
+
+            var res = Expression.Lambda<Action> (l).Compile ();
+		}
+	}
+}

+ 0 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_MemberBind.cs

@@ -139,7 +139,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CompiledMemberBinding ()
 		{
 			var getfoo = Expression.Lambda<Func<Foo>> (

+ 0 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_MemberInit.cs

@@ -93,7 +93,6 @@ namespace MonoTests.System.Linq.Expressions {
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void CompiledInit ()
 		{
 			var i = Expression.Lambda<Func<Thing>> (

+ 0 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Negate.cs

@@ -155,7 +155,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedNotNullableNegateNullable ()
 		{
 			var s = Expression.Parameter (typeof (Slot?), "s");
@@ -297,7 +296,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void NegateLiftedDecimal ()
 		{
 			var d = Expression.Parameter (typeof (decimal?), "l");

+ 0 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Not.cs

@@ -163,7 +163,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedNotNullable ()
 		{
 			var s = Expression.Parameter (typeof (Slot?), "s");

+ 1 - 5
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_OrElse.cs

@@ -173,7 +173,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void OrElseTestNullable ()
 		{
 			var a = Expression.Parameter (typeof (bool?), "a");
@@ -217,7 +216,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void OrElseNullableBoolItem ()
 		{
 			var i = Expression.Parameter (typeof (Item<bool?>), "i");
@@ -258,7 +256,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedOrElse ()
 		{
 			var l = Expression.Parameter (typeof (Slot), "l");
@@ -276,8 +273,8 @@ namespace MonoTests.System.Linq.Expressions
 			Assert.AreEqual (new Slot (64), orelse (new Slot (64), new Slot (64)));
 			Assert.AreEqual (new Slot (32), orelse (new Slot (32), new Slot (64)));
 		}
+
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedOrElseShortCircuit ()
 		{
 			var i = Expression.Parameter (typeof (Item<Slot>), "i");
@@ -294,7 +291,6 @@ namespace MonoTests.System.Linq.Expressions
 
 		[Test]
 		[Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=350228
-		[Category ("NotWorkingInterpreter")]
 		public void UserDefinedLiftedOrElseShortCircuit ()
 		{
 			var i = Expression.Parameter (typeof (Item<Slot?>), "i");

+ 1 - 2
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Power.cs

@@ -73,7 +73,7 @@ namespace MonoTests.System.Linq.Expressions
 
 			Assert.AreEqual (ExpressionType.Power, p.NodeType, "Power#01");
 			Assert.AreEqual (typeof (double), p.Type, "Add#02");
-			Assert.AreEqual ("(1 ^ 2)", p.ToString ());
+			Assert.AreEqual ("(1 ** 2)", p.ToString ());
 		}
 
 		[Test]
@@ -90,7 +90,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void NullablePower ()
 		{
 			var a = Expression.Parameter (typeof (double?), "a");

+ 0 - 1
mcs/class/System.Core/Test/System.Linq.Expressions/ExpressionTest_Quote.cs

@@ -58,7 +58,6 @@ namespace MonoTests.System.Linq.Expressions
 		}
 
 		[Test]
-		[Category ("NotWorkingInterpreter")]
 		public void ParameterInQuotedExpression () // #550722
 		{
 			// Expression<Func<string, Expression<Func<string>>>> e = (string s) => () => s;

+ 56 - 4
mcs/class/System.Core/common_System.Core.dll.sources

@@ -37,10 +37,9 @@ ReferenceSources/SR.missing.cs
 ReferenceSources/Error.cs
 ReferenceSources/Strings.cs
 
-../referencesource/System.Core/Microsoft/Scripting/Ast/DynamicExpression.cs
-../referencesource/System.Core/Microsoft/Scripting/Ast/ExpressionVisitor.cs
-../referencesource/System.Core/Microsoft/Scripting/Ast/IArgumentProvider.cs
-../referencesource/System.Core/Microsoft/Scripting/Ast/IDynamicExpression.cs
+corefx/LambdaExpression.cs
+corefx/SR.cs
+corefx/SR.missing.cs
 
 ../referencesource/System.Core/Microsoft/Scripting/Utils/Action.cs
 ../referencesource/System.Core/Microsoft/Scripting/Utils/Extension.cs
@@ -237,3 +236,56 @@ System.Security.Cryptography/ECParameters.cs
 System.Security.Cryptography/SHA256CryptoServiceProvider.cs
 System.Security.Cryptography/SHA384CryptoServiceProvider.cs
 System.Security.Cryptography/SHA512CryptoServiceProvider.cs
+
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/*.cs
+
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/CachedReflectionInfo.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/CollectionExtensions.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/EmptyReadOnlyCollection.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/ExpressionUtils.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/ExpressionVisitorUtils.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/ListArgumentProvider.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/ListParameterProvider.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/TypeExtensions.cs
+
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/*.cs
+
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Common/ArrayBuilderExtensions.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Common/ConstantCheck.cs
+
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.netstandard1.7.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/HoistedLocals.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/TypeInfoExtensions.cs
+
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSiteBinder.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSiteHelpers.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSiteOps.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/Closure.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/DebugInfoGenerator.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/IRuntimeVariables.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/ReadOnlyCollectionBuilder.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/RuleCache.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/RuntimeOps.ExpressionQuoter.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/RuntimeOps.RuntimeVariableList.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/RuntimeOps.MergedRuntimeVariables.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/RuntimeOps.RuntimeVariables.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/TrueReadOnlyCollection.cs
+
+../../../external/corefx/src/Common/src/System/Collections/Generic/ArrayBuilder.cs
+../../../external/corefx/src/Common/src/System/Collections/Generic/EnumerableHelpers.cs
+../../../external/corefx/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs
+
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/CacheDict.cs
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/ContractUtils.cs
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/ContractUtils.RequiresArrayRange.cs
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/Error.cs
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/ExpressionUtils.cs
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/Strings.cs
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/TypeExtensions.cs
+../../../external/corefx/src/Common/src/System/Dynamic/Utils/TypeUtils.cs
+
+../../../external/corefx/src/Common/src/System/Linq/Expressions/Compiler/DelegateHelpers.cs
+../../../external/corefx/src/Common/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs

+ 17 - 0
mcs/class/System.Core/corefx/LambdaExpression.cs

@@ -0,0 +1,17 @@
+#if FEATURE_COMPILE_TO_METHODBUILDER
+
+using System.Reflection.Emit;
+using System.Runtime.CompilerServices;
+
+namespace System.Linq.Expressions
+{
+	partial class LambdaExpression
+	{
+		public void CompileToMethod (MethodBuilder method, DebugInfoGenerator debugInfoGenerator)
+		{
+			CompileToMethod (method);
+		}
+	}
+}
+
+#endif

+ 183 - 0
mcs/class/System.Core/corefx/SR.cs

@@ -0,0 +1,183 @@
+//
+// This file was generated by resx2sr tool
+//
+
+partial class SR
+{
+	public const string ReducibleMustOverrideReduce = "reducible nodes must override Expression.Reduce()";
+	public const string MustReduceToDifferent = "node cannot reduce to itself or null";
+	public const string ReducedNotCompatible = "cannot assign from the reduced node type to the original node type";
+	public const string SetterHasNoParams = "Setter must have parameters.";
+	public const string PropertyCannotHaveRefType = "Property cannot have a managed pointer type.";
+	public const string IndexesOfSetGetMustMatch = "Indexing parameters of getter and setter must match.";
+	public const string AccessorsCannotHaveVarArgs = "Accessor method should not have VarArgs.";
+	public const string AccessorsCannotHaveByRefArgs = "Accessor indexes cannot be passed ByRef.";
+	public const string BoundsCannotBeLessThanOne = "Bounds count cannot be less than 1";
+	public const string TypeMustNotBeByRef = "Type must not be ByRef";
+	public const string TypeMustNotBePointer = "Type must not be a pointer type";
+	public const string TypeDoesNotHaveConstructorForTheSignature = "Type doesn't have constructor with a given signature";
+	public const string SetterMustBeVoid = "Setter should have void type.";
+	public const string PropertyTypeMustMatchGetter = "Property type must match the value type of getter";
+	public const string PropertyTypeMustMatchSetter = "Property type must match the value type of setter";
+	public const string BothAccessorsMustBeStatic = "Both accessors must be static.";
+	public const string OnlyStaticFieldsHaveNullInstance = "Static field requires null instance, non-static field requires non-null instance.";
+	public const string OnlyStaticPropertiesHaveNullInstance = "Static property requires null instance, non-static property requires non-null instance.";
+	public const string OnlyStaticMethodsHaveNullInstance = "Static method requires null instance, non-static method requires non-null instance.";
+	public const string PropertyTypeCannotBeVoid = "Property cannot have a void type.";
+	public const string InvalidUnboxType = "Can only unbox from an object or interface type to a value type.";
+	public const string ExpressionMustBeWriteable = "Expression must be writeable";
+	public const string ArgumentMustNotHaveValueType = "Argument must not have a value type.";
+	public const string MustBeReducible = "must be reducible node";
+	public const string AllTestValuesMustHaveSameType = "All test values must have the same type.";
+	public const string AllCaseBodiesMustHaveSameType = "All case bodies and the default body must have the same type.";
+	public const string DefaultBodyMustBeSupplied = "Default body must be supplied if case bodies are not System.Void.";
+	public const string LabelMustBeVoidOrHaveExpression = "Label type must be System.Void if an expression is not supplied";
+	public const string LabelTypeMustBeVoid = "Type must be System.Void for this label argument";
+	public const string QuotedExpressionMustBeLambda = "Quoted expression must be a lambda";
+	public const string VariableMustNotBeByRef = "Variable '{0}' uses unsupported type '{1}'. Reference types are not supported for variables.";
+	public const string DuplicateVariable = "Found duplicate parameter '{0}'. Each ParameterExpression in the list must be a unique object.";
+	public const string StartEndMustBeOrdered = "Start and End must be well ordered";
+	public const string FaultCannotHaveCatchOrFinally = "fault cannot be used with catch or finally clauses";
+	public const string TryMustHaveCatchFinallyOrFault = "try must have at least one catch, finally, or fault clause";
+	public const string BodyOfCatchMustHaveSameTypeAsBodyOfTry = "Body of catch must have the same type as body of try.";
+	public const string ExtensionNodeMustOverrideProperty = "Extension node must override the property {0}.";
+	public const string UserDefinedOperatorMustBeStatic = "User-defined operator method '{0}' must be static.";
+	public const string UserDefinedOperatorMustNotBeVoid = "User-defined operator method '{0}' must not be void.";
+	public const string CoercionOperatorNotDefined = "No coercion operator is defined between types '{0}' and '{1}'.";
+	public const string UnaryOperatorNotDefined = "The unary operator {0} is not defined for the type '{1}'.";
+	public const string BinaryOperatorNotDefined = "The binary operator {0} is not defined for the types '{1}' and '{2}'.";
+	public const string ReferenceEqualityNotDefined = "Reference equality is not defined for the types '{0}' and '{1}'.";
+	public const string OperandTypesDoNotMatchParameters = "The operands for operator '{0}' do not match the parameters of method '{1}'.";
+	public const string OverloadOperatorTypeDoesNotMatchConversionType = "The return type of overload method for operator '{0}' does not match the parameter type of conversion method '{1}'.";
+	public const string ConversionIsNotSupportedForArithmeticTypes = "Conversion is not supported for arithmetic types without operator overloading.";
+	public const string ArgumentMustBeArray = "Argument must be array";
+	public const string ArgumentMustBeBoolean = "Argument must be boolean";
+	public const string EqualityMustReturnBoolean = "The user-defined equality method '{0}' must return a boolean value.";
+	public const string ArgumentMustBeFieldInfoOrPropertyInfo = "Argument must be either a FieldInfo or PropertyInfo";
+	public const string ArgumentMustBeFieldInfoOrPropertyInfoOrMethod = "Argument must be either a FieldInfo, PropertyInfo or MethodInfo";
+	public const string ArgumentMustBeInstanceMember = "Argument must be an instance member";
+	public const string ArgumentMustBeInteger = "Argument must be of an integer type";
+	public const string ArgumentMustBeArrayIndexType = "Argument for array index must be of type Int32";
+	public const string ArgumentMustBeSingleDimensionalArrayType = "Argument must be single-dimensional, zero-based array type";
+	public const string ArgumentTypesMustMatch = "Argument types do not match";
+	public const string CannotAutoInitializeValueTypeElementThroughProperty = "Cannot auto initialize elements of value type through property '{0}', use assignment instead";
+	public const string CannotAutoInitializeValueTypeMemberThroughProperty = "Cannot auto initialize members of value type through property '{0}', use assignment instead";
+	public const string IncorrectTypeForTypeAs = "The type used in TypeAs Expression must be of reference or nullable type, {0} is neither";
+	public const string CoalesceUsedOnNonNullType = "Coalesce used with type that cannot be null";
+	public const string ExpressionTypeCannotInitializeArrayType = "An expression of type '{0}' cannot be used to initialize an array of type '{1}'";
+	public const string ArgumentTypeDoesNotMatchMember = " Argument type '{0}' does not match the corresponding member type '{1}'";
+	public const string ArgumentMemberNotDeclOnType = " The member '{0}' is not declared on type '{1}' being created";
+	public const string ExpressionTypeDoesNotMatchReturn = "Expression of type '{0}' cannot be used for return type '{1}'";
+	public const string ExpressionTypeDoesNotMatchAssignment = "Expression of type '{0}' cannot be used for assignment to type '{1}'";
+	public const string ExpressionTypeDoesNotMatchLabel = "Expression of type '{0}' cannot be used for label of type '{1}'";
+	public const string ExpressionTypeNotInvocable = "Expression of type '{0}' cannot be invoked";
+	public const string FieldNotDefinedForType = "Field '{0}' is not defined for type '{1}'";
+	public const string InstanceFieldNotDefinedForType = "Instance field '{0}' is not defined for type '{1}'";
+	public const string FieldInfoNotDefinedForType = "Field '{0}.{1}' is not defined for type '{2}'";
+	public const string IncorrectNumberOfIndexes = "Incorrect number of indexes";
+	public const string IncorrectNumberOfLambdaDeclarationParameters = "Incorrect number of parameters supplied for lambda declaration";
+	public const string IncorrectNumberOfMembersForGivenConstructor = " Incorrect number of members for constructor";
+	public const string IncorrectNumberOfArgumentsForMembers = "Incorrect number of arguments for the given members ";
+	public const string LambdaTypeMustBeDerivedFromSystemDelegate = "Lambda type parameter must be derived from System.MulticastDelegate";
+	public const string MemberNotFieldOrProperty = "Member '{0}' not field or property";
+	public const string MethodContainsGenericParameters = "Method {0} contains generic parameters";
+	public const string MethodIsGeneric = "Method {0} is a generic method definition";
+	public const string MethodNotPropertyAccessor = "The method '{0}.{1}' is not a property accessor";
+	public const string PropertyDoesNotHaveGetter = "The property '{0}' has no 'get' accessor";
+	public const string PropertyDoesNotHaveSetter = "The property '{0}' has no 'set' accessor";
+	public const string PropertyDoesNotHaveAccessor = "The property '{0}' has no 'get' or 'set' accessors";
+	public const string NotAMemberOfType = "'{0}' is not a member of type '{1}'";
+	public const string ExpressionNotSupportedForType = "The expression '{0}' is not supported for type '{1}'";
+	public const string UnsupportedExpressionType = "The expression type '{0}' is not supported";
+	public const string ParameterExpressionNotValidAsDelegate = "ParameterExpression of type '{0}' cannot be used for delegate parameter of type '{1}'";
+	public const string PropertyNotDefinedForType = "Property '{0}' is not defined for type '{1}'";
+	public const string InstancePropertyNotDefinedForType = "Instance property '{0}' is not defined for type '{1}'";
+	public const string InstancePropertyWithoutParameterNotDefinedForType = "Instance property '{0}' that takes no argument is not defined for type '{1}'";
+	public const string InstancePropertyWithSpecifiedParametersNotDefinedForType = "Instance property '{0}{1}' is not defined for type '{2}'";
+	public const string InstanceAndMethodTypeMismatch = "Method '{0}' declared on type '{1}' cannot be called with instance of type '{2}'";
+	public const string TypeContainsGenericParameters = "Type {0} contains generic parameters";
+	public const string TypeIsGeneric = "Type {0} is a generic type definition";
+	public const string TypeMissingDefaultConstructor = "Type '{0}' does not have a default constructor";
+	public const string ElementInitializerMethodNotAdd = "Element initializer method must be named 'Add'";
+	public const string ElementInitializerMethodNoRefOutParam = "Parameter '{0}' of element initializer method '{1}' must not be a pass by reference parameter";
+	public const string ElementInitializerMethodWithZeroArgs = "Element initializer method must have at least 1 parameter";
+	public const string ElementInitializerMethodStatic = "Element initializer method must be an instance method";
+	public const string TypeNotIEnumerable = "Type '{0}' is not IEnumerable";
+	public const string UnexpectedCoalesceOperator = "Unexpected coalesce operator.";
+	public const string InvalidCast = "Cannot cast from type '{0}' to type '{1}";
+	public const string UnhandledBinary = "Unhandled binary: {0}";
+	public const string UnhandledBinding = "Unhandled binding ";
+	public const string UnhandledBindingType = "Unhandled Binding Type: {0}";
+	public const string UnhandledConvert = "Unhandled convert: {0}";
+	public const string UnhandledUnary = "Unhandled unary: {0}";
+	public const string UnknownBindingType = "Unknown binding type";
+	public const string UserDefinedOpMustHaveConsistentTypes = "The user-defined operator method '{1}' for operator '{0}' must have identical parameter and return types.";
+	public const string UserDefinedOpMustHaveValidReturnType = "The user-defined operator method '{1}' for operator '{0}' must return the same type as its parameter or a derived type.";
+	public const string LogicalOperatorMustHaveBooleanOperators = "The user-defined operator method '{1}' for operator '{0}' must have associated boolean True and False operators.";
+	public const string MethodWithArgsDoesNotExistOnType = "No method '{0}' on type '{1}' is compatible with the supplied arguments.";
+	public const string GenericMethodWithArgsDoesNotExistOnType = "No generic method '{0}' on type '{1}' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. ";
+	public const string MethodWithMoreThanOneMatch = "More than one method '{0}' on type '{1}' is compatible with the supplied arguments.";
+	public const string PropertyWithMoreThanOneMatch = "More than one property '{0}' on type '{1}' is compatible with the supplied arguments.";
+	public const string IncorrectNumberOfTypeArgsForFunc = "An incorrect number of type arguments were specified for the declaration of a Func type.";
+	public const string IncorrectNumberOfTypeArgsForAction = "An incorrect number of type arguments were specified for the declaration of an Action type.";
+	public const string ArgumentCannotBeOfTypeVoid = "Argument type cannot be System.Void.";
+	public const string OutOfRange = "{0} must be greater than or equal to {1}";
+	public const string LabelTargetAlreadyDefined = "Cannot redefine label '{0}' in an inner block.";
+	public const string LabelTargetUndefined = "Cannot jump to undefined label '{0}'.";
+	public const string ControlCannotLeaveFinally = "Control cannot leave a finally block.";
+	public const string ControlCannotLeaveFilterTest = "Control cannot leave a filter test.";
+	public const string AmbiguousJump = "Cannot jump to ambiguous label '{0}'.";
+	public const string ControlCannotEnterTry = "Control cannot enter a try block.";
+	public const string ControlCannotEnterExpression = "Control cannot enter an expression--only statements can be jumped into.";
+	public const string NonLocalJumpWithValue = "Cannot jump to non-local label '{0}' with a value. Only jumps to labels defined in outer blocks can pass values.";
+	public const string ExtensionNotReduced = "Extension should have been reduced.";
+	public const string CannotCompileConstant = "CompileToMethod cannot compile constant '{0}' because it is a non-trivial value, such as a live object. Instead, create an expression tree that can construct this value.";
+	public const string CannotCompileDynamic = "Dynamic expressions are not supported by CompileToMethod. Instead, create an expression tree that uses System.Runtime.CompilerServices.CallSite.";
+	public const string InvalidLvalue = "Invalid lvalue for assignment: {0}.";
+	public const string UnknownLiftType = "unknown lift type: '{0}'.";
+	public const string UndefinedVariable = "variable '{0}' of type '{1}' referenced from scope '{2}', but it is not defined";
+	public const string CannotCloseOverByRef = "Cannot close over byref parameter '{0}' referenced in lambda '{1}'";
+	public const string UnexpectedVarArgsCall = "Unexpected VarArgs call to method '{0}'";
+	public const string RethrowRequiresCatch = "Rethrow statement is valid only inside a Catch block.";
+	public const string TryNotAllowedInFilter = "Try expression is not allowed inside a filter body.";
+	public const string MustRewriteToSameNode = "When called from '{0}', rewriting a node of type '{1}' must return a non-null value of the same type. Alternatively, override '{2}' and change it to not visit children of this type.";
+	public const string MustRewriteChildToSameType = "Rewriting child expression from type '{0}' to type '{1}' is not allowed, because it would change the meaning of the operation. If this is intentional, override '{2}' and change it to allow this rewrite.";
+	public const string MustRewriteWithoutMethod = "Rewritten expression calls operator method '{0}', but the original node had no operator method. If this is intentional, override '{1}' and change it to allow this rewrite.";
+	public const string InvalidNullValue = "The value null is not of type '{0}' and cannot be used in this collection.";
+	public const string InvalidObjectType = "The value '{0}' is not of type '{1}' and cannot be used in this collection.";
+	public const string TryNotSupportedForMethodsWithRefArgs = "TryExpression is not supported as an argument to method '{0}' because it has an argument with by-ref type. Construct the tree so the TryExpression is not nested inside of this expression.";
+	public const string TryNotSupportedForValueTypeInstances = "TryExpression is not supported as a child expression when accessing a member on type '{0}' because it is a value type. Construct the tree so the TryExpression is not nested inside of this expression.";
+	public const string EnumerationIsDone = "Enumeration has either not started or has already finished.";
+	public const string TestValueTypeDoesNotMatchComparisonMethodParameter = "Test value of type '{0}' cannot be used for the comparison method parameter of type '{1}'";
+	public const string SwitchValueTypeDoesNotMatchComparisonMethodParameter = "Switch value of type '{0}' cannot be used for the comparison method parameter of type '{1}'";
+	public const string PdbGeneratorNeedsExpressionCompiler = "DebugInfoGenerator created by CreatePdbGenerator can only be used with LambdaExpression.CompileToMethod.";
+	public const string InvalidArgumentValue = "Invalid argument value";
+	public const string NonEmptyCollectionRequired = "Non-empty collection required";
+	public const string CollectionModifiedWhileEnumerating = "Collection was modified; enumeration operation may not execute.";
+	public const string ExpressionMustBeReadable = "Expression must be readable";
+	public const string ExpressionTypeDoesNotMatchMethodParameter = "Expression of type '{0}' cannot be used for parameter of type '{1}' of method '{2}'";
+	public const string ExpressionTypeDoesNotMatchParameter = "Expression of type '{0}' cannot be used for parameter of type '{1}'";
+	public const string ExpressionTypeDoesNotMatchConstructorParameter = "Expression of type '{0}' cannot be used for constructor parameter of type '{1}'";
+	public const string IncorrectNumberOfMethodCallArguments = "Incorrect number of arguments supplied for call to method '{0}'";
+	public const string IncorrectNumberOfLambdaArguments = "Incorrect number of arguments supplied for lambda invocation";
+	public const string IncorrectNumberOfConstructorArguments = "Incorrect number of arguments for constructor";
+	public const string OperatorNotImplementedForType = "The operator '{0}' is not implemented for type '{1}'";
+	public const string NonStaticConstructorRequired = "The constructor should not be static";
+	public const string NonAbstractConstructorRequired = "Can't compile a NewExpression with a constructor declared on an abstract class";
+	public const string FirstArgumentMustBeCallSite = "First argument of delegate must be CallSite";
+	public const string NoOrInvalidRuleProduced = "No or Invalid rule produced";
+	public const string TypeMustBeDerivedFromSystemDelegate = "Type must be derived from System.Delegate";
+	public const string TypeParameterIsNotDelegate = "Type parameter is {0}. Expected a delegate.";
+	public const string ArgumentTypeCannotBeVoid = "Argument type cannot be void";
+	public const string ArgCntMustBeGreaterThanNameCnt = "Argument count must be greater than number of named arguments.";
+	public const string BinderNotCompatibleWithCallSite = "The result type '{0}' of the binder '{1}' is not compatible with the result type '{2}' expected by the call site.";
+	public const string BindingCannotBeNull = "Bind cannot return null.";
+	public const string DynamicBinderResultNotAssignable = "The result type '{0}' of the dynamic binding produced by binder '{1}' is not compatible with the result type '{2}' expected by the call site.";
+	public const string DynamicBindingNeedsRestrictions = "The result of the dynamic binding produced by the object with type '{0}' for the binder '{1}' needs at least one restriction.";
+	public const string DynamicObjectResultNotAssignable = "The result type '{0}' of the dynamic binding produced by the object with type '{1}' for the binder '{2}' is not compatible with the result type '{3}' expected by the call site.";
+	public const string InvalidMetaObjectCreated = "An IDynamicMetaObjectProvider {0} created an invalid DynamicMetaObject instance.";
+	public const string AmbiguousMatchInExpandoObject = "More than one key matching '{0}' was found in the ExpandoObject.";
+	public const string CollectionReadOnly = "Collection is read-only.";
+	public const string KeyDoesNotExistInExpando = "The specified key '{0}' does not exist in the ExpandoObject.";
+	public const string SameKeyExistsInExpando = "An element with the same key '{0}' already exists in the ExpandoObject.";
+}

+ 4 - 0
mcs/class/System.Core/corefx/SR.missing.cs

@@ -0,0 +1,4 @@
+partial class SR
+{ 
+	public const string MethodBuilderDoesNotHaveTypeBuilder = "MethodBuilder does not have a valid TypeBuilder";
+}

+ 31 - 114
mcs/class/System.Core/dynamic_System.Core.dll.sources

@@ -1,117 +1,34 @@
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/BinaryOperationBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/BindingRestrictions.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallInfo.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSite.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteHelpers.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteOps.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/ConvertBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CreateInstanceBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DeleteIndexBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DeleteMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObject.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObjectBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicObject.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoClass.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoObject.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/GetIndexBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/GetMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/IDynamicMetaObjectProvider.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/InvokeBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/InvokeMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/IInvokeOnGetBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/RuleCache.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/SetIndexBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/SetMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/UnaryOperationBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/UpdateDelegates.Generated.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Common/CachedReflectionInfo.cs
 
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/BinaryExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/BlockExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/CatchBlock.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ConditionalExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugInfoExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugViewWriter.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/DefaultExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ElementInit.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.DebuggerProxy.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionStringBuilder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionType.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/GotoExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/IndexExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/InvocationExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelTarget.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ListArgumentProvider.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ListInitExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LoopExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberAssignment.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberBinding.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberInitExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberListBinding.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberMemberBinding.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MethodCallExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/NewArrayExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/NewExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ParameterExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/RuntimeVariablesExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchCase.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/SymbolDocumentInfo.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/TryExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeBinaryExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeUtils.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/Helpers.cs
 
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/AnalyzedTree.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/AssemblyGen.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/BoundConstants.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/Closure.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/CompilerScope.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/CompilerScope.Storage.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/ConstantCheck.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/DebugInfoGenerator.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.Generated.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/ExpressionQuoter.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/HoistedLocals.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/ILGen.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/KeyedQueue.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LabelInfo.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Address.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Binary.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.ControlFlow.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Expressions.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Generated.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Lambda.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Logical.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Statements.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/LambdaCompiler.Unary.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/OffsetTrackingILGenerator.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/RuntimeVariableList.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/Set.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Bindings.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Generated.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/StackSpiller.Temps.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolDocumentGenerator.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolGuids.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/VariableBinder.cs
+../../../external/corefx/src/Common/src/System/NotImplemented.cs
 
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/CacheDict.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/CollectionExtensions.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ContractUtils.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ExceptionFactory.Generated.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/Helpers.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/IRuntimeVariables.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyCollectionBuilder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyDictionary.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReferenceEqualityComparer.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReflectionUtils.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/TrueReadOnlyCollection.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/TypeExtensions.cs
+../../../external/corefx/src/Common/src/System/Collections/Generic/ReferenceEqualityComparer.cs
+
+../../../external/corefx/src/Common/src/System/Linq/Expressions/Compiler/AssemblyGen.cs
+
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/AnalyzedTree.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/BoundConstants.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/CompilerScope.Storage.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/CompilerScope.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/ILGen.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/KeyedQueue.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LabelInfo.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Address.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Binary.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.ControlFlow.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Expressions.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Generated.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Lambda.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Logical.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Statements.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.Unary.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/LambdaCompiler.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/StackSpiller.Bindings.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/StackSpiller.ChildRewriter.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/StackSpiller.Generated.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/StackSpiller.SpilledExpressionBlock.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/StackSpiller.Temps.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/StackSpiller.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/VariableBinder.cs

+ 2 - 87
mcs/class/System.Core/interpreter_System.Core.dll.sources

@@ -1,89 +1,4 @@
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/BinaryOperationBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/BindingRestrictions.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallInfo.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSite.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteHelpers.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CallSiteOps.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/ConvertBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/CreateInstanceBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DeleteIndexBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DeleteMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObject.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicMetaObjectBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicObject.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoClass.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/ExpandoObject.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/GetIndexBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/GetMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/IDynamicMetaObjectProvider.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/InvokeBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/InvokeMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/IInvokeOnGetBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/RuleCache.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/SetIndexBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/SetMemberBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/UnaryOperationBinder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Actions/UpdateDelegates.Generated.cs
 
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/BinaryExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/BlockExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/CatchBlock.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ConditionalExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ConstantExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugInfoExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/DebugViewWriter.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/DefaultExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ElementInit.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/Expression.DebuggerProxy.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionStringBuilder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ExpressionType.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/GotoExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/IndexExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/InvocationExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LabelTarget.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LambdaExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ListArgumentProvider.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ListInitExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/LoopExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberAssignment.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberBinding.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberInitExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberListBinding.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MemberMemberBinding.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/MethodCallExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/NewArrayExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/NewExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/ParameterExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/RuntimeVariablesExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchCase.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/SwitchExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/SymbolDocumentInfo.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/TryExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeBinaryExpression.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/TypeUtils.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Ast/UnaryExpression.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/*.cs
 
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/DebugInfoGenerator.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/DelegateHelpers.Generated.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/Set.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Compiler/SymbolGuids.cs
-
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/CacheDict.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/CollectionExtensions.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ContractUtils.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ExceptionFactory.Generated.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/Helpers.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/IRuntimeVariables.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyCollectionBuilder.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReadOnlyDictionary.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReferenceEqualityComparer.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/ReflectionUtils.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/TrueReadOnlyCollection.cs
-../dlr/Runtime/Microsoft.Scripting.Core/Utils/TypeExtensions.cs
-
-System.Linq.Expressions.Interpret/LambdaCompiler.cs
+../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Common/CachedReflectionInfo.cs

+ 0 - 8
mcs/class/System.Numerics.Vectors/SR.cs

@@ -12,11 +12,3 @@ partial class SR
 	public const string Arg_TypeNotSupported = "Specified type is not supported";
 	public const string Reflection_MethodNotSupported = "Vector<T>.Count cannot be called via reflection when intrinsics are enabled.";
 }
-
-partial class SR
-{
-	public static string Format (string message, object data)
-	{
-		return string.Format (message, data);
-	}
-}

+ 6 - 1
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs

@@ -468,7 +468,12 @@ namespace System.Reflection.Emit
 
 		public static AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
 		{
-			throw new NotImplementedException ();
+			var ab = DefineDynamicAssembly (name, access);
+			foreach (var attr in  assemblyAttributes) {
+				ab.SetCustomAttribute (attr);
+			}
+
+			return ab;
 		}
 
 		public ModuleBuilder DefineDynamicModule (string name)

+ 1 - 5
mcs/class/dlr/Makefile

@@ -4,11 +4,7 @@ SUBDIRS =
 include ../../build/rules.make
 
 DISTFILES = \
-	Runtime/Microsoft.Dynamic/*.cs \
-	Runtime/Microsoft.Scripting.Core/Actions/*.cs \
-	Runtime/Microsoft.Scripting.Core/Ast/*.cs \
-	Runtime/Microsoft.Scripting.Core/Compiler/*.cs \
-	Runtime/Microsoft.Scripting.Core/Utils/*.cs
+	Runtime/Microsoft.Dynamic/*.cs
 
 all-local install-local clean-local test-local run-test-local run-test-ondotnet-local uninstall-local doc-update-local csproj-local:
 

+ 0 - 8
mcs/class/dlr/README

@@ -1,8 +0,0 @@
-This is fork of Microsoft DLR source code. The original code was published at
-http://dlr.codeplex.com/ which had the code used for .NET 4.0
-System.Linq.Expression public API. Since them the code was migrated to
-https://github.com/IronLanguages/main but it no longer has the goal to offer
-compatible System.Linq.Expression API and we cannot use some part of it.
-
-We want to have minimum local changes. Importatant changes need to be marked
-using easily recognizable marker (like MONO_INTERPRETER) for easier merging.

+ 0 - 5
mcs/class/dlr/Runtime/Microsoft.Dynamic/Actions/Dummy.cs

@@ -1,5 +0,0 @@
-namespace Microsoft.Scripting.Actions {
-	class Dummy
-	{
-	}
-}

+ 0 - 133
mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/BinaryExpression.cs

@@ -1,133 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Reflection;
-using System.Dynamic;
-using Microsoft.Scripting.Utils;
-using AstUtils = Microsoft.Scripting.Ast.Utils;
-
-namespace Microsoft.Scripting.Ast {
-    public static partial class Utils {
-#if !MONO_INTERPRETER
-        /// <summary>
-        /// Null coalescing expression
-        /// {result} ::= ((tmp = {_left}) == null) ? {right} : tmp
-        /// '??' operator in C#.
-        /// </summary>
-        public static Expression Coalesce(Expression left, Expression right, out ParameterExpression temp) {
-            return CoalesceInternal(left, right, null, false, out temp);
-        }
-
-        /// <summary>
-        /// True coalescing expression.
-        /// {result} ::= IsTrue(tmp = {left}) ? {right} : tmp
-        /// Generalized AND semantics.
-        /// </summary>
-        public static Expression CoalesceTrue(Expression left, Expression right, MethodInfo isTrue, out ParameterExpression temp) {
-            ContractUtils.RequiresNotNull(isTrue, "isTrue");
-            return CoalesceInternal(left, right, isTrue, false, out temp);
-        }
-
-        /// <summary>
-        /// False coalescing expression.
-        /// {result} ::= IsTrue(tmp = {left}) ? tmp : {right}
-        /// Generalized OR semantics.
-        /// </summary>
-        public static Expression CoalesceFalse(Expression left, Expression right, MethodInfo isTrue, out ParameterExpression temp) {
-            ContractUtils.RequiresNotNull(isTrue, "isTrue");
-            return CoalesceInternal(left, right, isTrue, true, out temp);
-        }
-
-        private static Expression CoalesceInternal(Expression left, Expression right, MethodInfo isTrue, bool isReverse, out ParameterExpression temp) {
-            ContractUtils.RequiresNotNull(left, "left");
-            ContractUtils.RequiresNotNull(right, "right");
-
-            // A bit too strict, but on a safe side.
-            ContractUtils.Requires(left.Type == right.Type, "Expression types must match");
-
-            temp = Expression.Variable(left.Type, "tmp_left");
-
-            Expression condition;
-            if (isTrue != null) {
-                ContractUtils.Requires(isTrue.ReturnType == typeof(bool), "isTrue", "Predicate must return bool.");
-                ParameterInfo[] parameters = isTrue.GetParameters();
-                ContractUtils.Requires(parameters.Length == 1, "isTrue", "Predicate must take one parameter.");
-                ContractUtils.Requires(isTrue.IsStatic && isTrue.IsPublic, "isTrue", "Predicate must be public and static.");
-
-                Type pt = parameters[0].ParameterType;
-                ContractUtils.Requires(TypeUtils.CanAssign(pt, left.Type), "left", "Incorrect left expression type");
-                condition = Expression.Call(isTrue, Expression.Assign(temp, left));
-            } else {
-                ContractUtils.Requires(TypeUtils.CanCompareToNull(left.Type), "left", "Incorrect left expression type");
-                condition = Expression.Equal(Expression.Assign(temp, left), AstUtils.Constant(null, left.Type));
-            }
-
-            Expression t, f;
-            if (isReverse) {
-                t = temp;
-                f = right;
-            } else {
-                t = right;
-                f = temp;
-            }
-
-            return Expression.Condition(condition, t, f);
-        }
-
-        public static Expression Coalesce(LambdaBuilder builder, Expression left, Expression right) {
-            ParameterExpression temp;
-            Expression result = Coalesce(left, right, out temp);
-            builder.AddHiddenVariable(temp);
-            return result;
-        }
-
-        /// <summary>
-        /// True coalescing expression.
-        /// {result} ::= IsTrue(tmp = {left}) ? {right} : tmp
-        /// Generalized AND semantics.
-        /// </summary>
-        public static Expression CoalesceTrue(LambdaBuilder builder, Expression left, Expression right, MethodInfo isTrue) {
-            ContractUtils.RequiresNotNull(isTrue, "isTrue");
-            ParameterExpression temp;
-            Expression result = CoalesceTrue(left, right, isTrue, out temp);
-            builder.AddHiddenVariable(temp);
-            return result;
-        }
-
-        /// <summary>
-        /// False coalescing expression.
-        /// {result} ::= IsTrue(tmp = {left}) ? tmp : {right}
-        /// Generalized OR semantics.
-        /// </summary>
-        public static Expression CoalesceFalse(LambdaBuilder builder, Expression left, Expression right, MethodInfo isTrue) {
-            ContractUtils.RequiresNotNull(isTrue, "isTrue");
-            ParameterExpression temp;
-            Expression result = CoalesceFalse(left, right, isTrue, out temp);
-            builder.AddHiddenVariable(temp);
-            return result;
-        }
-#endif
-        public static BinaryExpression Update(this BinaryExpression expression, Expression left, Expression right) {
-            return expression.Update(left, expression.Conversion, right);
-        }
-    }
-}

+ 0 - 235
mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs

@@ -1,235 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-#if FEATURE_NUMERICS
-using BigInt = System.Numerics.BigInteger;
-using Complex = System.Numerics.Complex;
-#endif
-
-using System;
-using System.Reflection;
-using Microsoft.Scripting.Generation;
-using Microsoft.Scripting.Math;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Ast {
-    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1724:TypeNamesShouldNotMatchNamespaces")]
-    public static partial class Utils {
-        private static readonly ConstantExpression TrueLiteral = Expression.Constant(true, typeof(bool));
-        private static readonly ConstantExpression FalseLiteral = Expression.Constant(false, typeof(bool));
-        private static readonly ConstantExpression NullLiteral = Expression.Constant(null, typeof(object));
-        private static readonly ConstantExpression EmptyStringLiteral = Expression.Constant(String.Empty, typeof(string));
-        private static readonly ConstantExpression[] IntCache = new ConstantExpression[100];
-
-        /// <summary>
-        /// Wraps the given value in a WeakReference and returns a tree that will retrieve
-        /// the value from the WeakReference.
-        /// </summary>
-        public static MemberExpression WeakConstant(object value) {
-            System.Diagnostics.Debug.Assert(!(value is Expression));
-            return Expression.Property(
-                Constant(new WeakReference(value)),
-                typeof(WeakReference).GetDeclaredProperty("Target")
-            );
-        }
-
-        public static ConstantExpression Constant(object value, Type type) {
-            return Expression.Constant(value, type);
-        }
-
-        // The helper API should return ConstantExpression after SymbolConstantExpression goes away
-        public static Expression Constant(object value) {
-            if (value == null) {
-                return NullLiteral;
-            }
-
-#if !MONO_INTERPRETER
-            BigInteger bi = value as BigInteger;
-            if ((object)bi != null) {
-                return BigIntegerConstant(bi);
-#endif
-
-#if FEATURE_NUMERICS
-            if (value is BigInt)
-                return BigIntConstant((BigInt)value);
-            if (value is Complex)
-                return ComplexConstant((Complex)value);
-#endif
-
-#if !MONO_INTERPRETER
-            if (value is Complex64)
-                return Complex64Constant((Complex64)value);
-#endif
-            if (value is Type) {
-                return Expression.Constant(value, typeof(Type));
-            } else if (value is ConstructorInfo) {
-                return Expression.Constant(value, typeof(ConstructorInfo));
-            } else if (value is EventInfo) {
-                return Expression.Constant(value, typeof(EventInfo));
-            } else if (value is FieldInfo) {
-                return Expression.Constant(value, typeof(FieldInfo));
-            } else if (value is MethodInfo) {
-                return Expression.Constant(value, typeof(MethodInfo));
-            } else if (value is PropertyInfo) {
-                return Expression.Constant(value, typeof(PropertyInfo));
-            } else {
-                Type t = value.GetType();
-                if (!t.GetTypeInfo().IsEnum) {
-                    switch (t.GetTypeCode()) {
-                        case TypeCode.Boolean:
-                            return (bool)value ? TrueLiteral : FalseLiteral;
-                        case TypeCode.Int32:
-                            int x = (int)value;
-                            int cacheIndex = x + 2;
-                            if (cacheIndex >= 0 && cacheIndex < IntCache.Length) {
-                                ConstantExpression res;
-                                if ((res = IntCache[cacheIndex]) == null) {
-                                    IntCache[cacheIndex] = res = Constant(x, typeof(int));
-                                }
-                                return res;
-                            }
-                            break;
-                        case TypeCode.String:
-                            if (String.IsNullOrEmpty((string)value)) {
-                                return EmptyStringLiteral;
-                            }
-                            break;
-                    }
-                }
-                return Expression.Constant(value);
-            }
-        }
-
-#if !MONO_INTERPRETER
-        private static Expression BigIntegerConstant(BigInteger value) {
-            int ival;
-            if (value.AsInt32(out ival)) {
-                return Expression.Call(
-                    new Func<int, BigInteger>(BigInteger.Create).GetMethodInfo(),
-                    Constant(ival)
-                );
-            }
-
-            long lval;
-            if (value.AsInt64(out lval)) {
-                return Expression.Call(
-                    new Func<long, BigInteger>(BigInteger.Create).GetMethodInfo(),
-                    Constant(lval)
-                );
-            }
-
-#if !FEATURE_NUMERICS
-            return Expression.Call(
-                new Func<int, uint[], BigInteger>(CompilerHelpers.CreateBigInteger).Method,
-                Constant((int)value.Sign),
-                CreateArray<uint>(value.GetWords())
-            );
-#else
-            return Expression.Call(
-                new Func<bool, byte[], BigInteger>(CompilerHelpers.CreateBigInteger).GetMethodInfo(),
-                Constant(value.Sign < 0),
-                CreateArray<byte>(value.Abs().ToByteArray())
-            );
-        }
-
-        private static Expression BigIntConstant(BigInt value) {
-            int ival;
-            if (value.AsInt32(out ival)) {
-                return Expression.Call(
-                    new Func<int, BigInt>(CompilerHelpers.CreateBigInt).GetMethodInfo(),
-                    Constant(ival)
-                );
-            }
-
-            long lval;
-            if (value.AsInt64(out lval)) {
-                return Expression.Call(
-                    new Func<long, BigInt>(CompilerHelpers.CreateBigInt).GetMethodInfo(),
-                    Constant(lval)
-                );
-            }
-
-            return Expression.Call(
-                new Func<bool, byte[], BigInt>(CompilerHelpers.CreateBigInt).GetMethodInfo(),
-                Constant(value.Sign < 0),
-                CreateArray<byte>(value.Abs().ToByteArray())
-            );
-#endif
-        }
-#endif
-        private static Expression CreateArray<T>(T[] array) {
-            // TODO: could we use blobs?
-            Expression[] init = new Expression[array.Length];
-            for (int i = 0; i < init.Length; i++) {
-                init[i] = Constant(array[i]);
-            }
-            return Expression.NewArrayInit(typeof(T), init);
-        }
-
-#if FEATURE_NUMERICS
-        private static Expression ComplexConstant(Complex value) {
-            if (value.Real != 0.0) {
-                if (value.Imaginary() != 0.0) {
-                    return Expression.Call(
-                        new Func<double, double, Complex>(MathUtils.MakeComplex).GetMethodInfo(),
-                        Constant(value.Real),
-                        Constant(value.Imaginary())
-                    );
-                } else {
-                    return Expression.Call(
-                        new Func<double, Complex>(MathUtils.MakeReal).GetMethodInfo(),
-                        Constant(value.Real)
-                    );
-                }
-            } else {
-                return Expression.Call(
-                    new Func<double, Complex>(MathUtils.MakeImaginary).GetMethodInfo(),
-                    Constant(value.Imaginary())
-                );
-            }
-        }
-#endif
-
-#if !MONO_INTERPRETER
-        private static Expression Complex64Constant(Complex64 value) {
-            if (value.Real != 0.0) {
-                if (value.Imag != 0.0) {
-                    return Expression.Call(
-                        new Func<double, double, Complex64>(Complex64.Make).GetMethodInfo(),
-                        Constant(value.Real),
-                        Constant(value.Imag)
-                    );
-                } else {
-                    return Expression.Call(
-                        new Func<double, Complex64>(Complex64.MakeReal).GetMethodInfo(),
-                        Constant(value.Real)
-                    );
-                }
-            } else {
-                return Expression.Call(
-                    new Func<double, Complex64>(Complex64.MakeImaginary).GetMethodInfo(),
-                    Constant(value.Imag)
-                );
-            }
-        }
-#endif
-    }
-}

+ 0 - 45
mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/EmptyStatements.cs

@@ -1,45 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Dynamic;
-
-namespace Microsoft.Scripting.Ast {
-    public static partial class Utils {
-        private static readonly DefaultExpression VoidInstance = Expression.Empty();
-
-        public static DefaultExpression Empty() {
-            return VoidInstance;
-        }
-
-        public static DefaultExpression Default(Type type) {
-            if (type == typeof(void)) {
-                return Empty();
-            }
-            return Expression.Default(type);
-        }
-    }
-}
-
-
-
-
-

+ 0 - 149
mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/LightLambdaExpression.cs

@@ -1,149 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Microsoft.Scripting.Interpreter;
-using Microsoft.Scripting.Generation;
-
-namespace Microsoft.Scripting.Ast {
-    public class LightLambdaExpression : Expression {
-        private readonly Expression _body;
-        private readonly Type _retType;
-        private readonly string _name;
-        private readonly IList<ParameterExpression> _args;
-
-        internal LightLambdaExpression(Type retType, Expression body, string name, IList<ParameterExpression> args) {
-            _body = body;
-            _name = name;
-            _args = args;
-            _retType = retType;
-        }
-
-        public Expression Body {
-            get {
-                return _body;
-            }
-        }
-
-        public string Name {
-            get {
-                return _name;
-            }
-        }
-
-        public IList<ParameterExpression> Parameters {
-            get {
-                return _args;
-            }
-        }
-
-        internal virtual LambdaExpression ReduceToLambdaWorker() {
-            throw new InvalidOperationException();
-        }
-
-        public Delegate Compile() {
-            return Compile(-1);
-        }
-
-        public Delegate Compile(int compilationThreshold) {
-            return new LightCompiler(compilationThreshold).CompileTop(this).CreateDelegate();
-        }
-
-        public override ExpressionType NodeType {
-            get { return ExpressionType.Extension; }
-        }
-
-        public override bool CanReduce {
-            get { return true; }
-        }
-
-        public override Expression Reduce() {
-            return ReduceToLambdaWorker();
-        }
-
-        public Type ReturnType {
-            get {
-                return _retType;
-            }
-        }
-    }
-
-    internal class TypedLightLambdaExpression : LightLambdaExpression {
-        private readonly Type _delegateType;
-
-        internal TypedLightLambdaExpression(Type retType, Type delegateType, Expression body, string name, IList<ParameterExpression> args)
-            : base(retType, body, name, args) {
-            _delegateType = delegateType;
-        }
-
-        internal override LambdaExpression ReduceToLambdaWorker() {
-            return Expression.Lambda(
-                _delegateType,
-                Body,
-                Name,
-                Parameters
-            );
-        }
-
-        public override Type Type {
-            get { return _delegateType; }
-        }
-    }
-
-    public class LightExpression<T> : LightLambdaExpression {
-        internal LightExpression(Type retType, Expression body, string name, IList<ParameterExpression> args)
-            : base(retType, body, name, args) {
-        }
-
-        public Expression<T> ReduceToLambda() {
-            return Expression.Lambda<T>(Body, Name, Parameters);
-        }
-
-        public override Type Type {
-            get { return typeof(T); }
-        }
-
-        public new T Compile() {
-            return Compile(-1);
-        }
-
-        public new T Compile(int compilationThreshold) {
-            return (T)(object)new LightCompiler(compilationThreshold).CompileTop(this).CreateDelegate();
-        }
-
-        internal override LambdaExpression ReduceToLambdaWorker() {
-            return ReduceToLambda();
-        }
-    }
-
-    public static partial class Utils {
-        public static LightExpression<T> LightLambda<T>(Type retType, Expression body, string name, IList<ParameterExpression> args) {
-            return new LightExpression<T>(retType, body, name, args);
-        }
-
-        public static LightLambdaExpression LightLambda(Type retType, Type delegateType, Expression body, string name, IList<ParameterExpression> args) {
-            return new TypedLightLambdaExpression(retType, delegateType, body, name, args);
-        }
-    }
-
-}

+ 0 - 82
mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/UnaryExpression.cs

@@ -1,82 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-using System.Reflection;
-
-namespace Microsoft.Scripting.Ast {
-    public static partial class Utils {
-        /// <summary>
-        /// Converts an expression to a void type.
-        /// </summary>
-        /// <param name="expression">An <see cref="Expression"/> to convert to void. </param>
-        /// <returns>An <see cref="Expression" /> that has the <see cref="P:System.Linq.Expressions.Expression.NodeType" /> property equal to <see cref="F:System.Linq.Expressions.ExpressionType.ConvertChecked" /> and the <see cref="P:System.Linq.Expressions.UnaryExpression.Operand" /> and <see cref="P:System.Linq.Expressions.Expression.Type" /> property set to void.</returns>
-        public static Expression Void(Expression expression) {
-            ContractUtils.RequiresNotNull(expression, "expression");
-            if (expression.Type == typeof(void)) {
-                return expression;
-            }
-            return Expression.Block(expression, Utils.Empty());
-        }
-
-        public static Expression Convert(Expression expression, Type type) {
-            ContractUtils.RequiresNotNull(expression, "expression");
-
-            if (expression.Type == type) {
-                return expression;
-            }
-
-            if (expression.Type == typeof(void)) {
-                return Expression.Block(expression, Utils.Default(type));
-            }
-
-            if (type == typeof(void)) {
-                return Void(expression);
-            }
-
-            // TODO: this is not the right level for this to be at. It should
-            // be pushed into languages if they really want this behavior.
-            if (type == typeof(object)) {
-                return Box(expression);
-            }
-
-            return Expression.Convert(expression, type);
-        }
-
-        /// <summary>
-        /// Returns an expression that boxes a given value. Uses boxed objects cache for Int32 and Boolean types.
-        /// </summary>
-        public static Expression Box(Expression expression) {
-            MethodInfo m;
-            if (expression.Type == typeof(int)) {
-                m = ScriptingRuntimeHelpers.Int32ToObjectMethod;
-            } else if (expression.Type == typeof(bool)) {
-                m = ScriptingRuntimeHelpers.BooleanToObjectMethod;
-            } else {
-                m = null;
-            }
-
-            return Expression.Convert(expression, typeof(object), m);
-        }
-    }
-}

+ 0 - 111
mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/Utils.cs

@@ -1,111 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Reflection;
-using System.Dynamic;
-using Microsoft.Scripting.Utils;
-using AstUtils = Microsoft.Scripting.Ast.Utils;
-
-namespace Microsoft.Scripting.Ast {
-    [Flags]
-    public enum ExpressionAccess {
-        None = 0,
-        Read = 1,
-        Write = 2,
-        ReadWrite = Read | Write,
-    }
-
-    public static partial class Utils {
-        /// <summary>
-        /// Determines whether specified expression type represents an assignment.
-        /// </summary>
-        /// <returns>
-        /// True if the expression type represents an assignment.
-        /// </returns>
-        /// <remarks>
-        /// Note that some other nodes can also assign to variables, members or array items:
-        /// MemberInit, NewArrayInit, Call with ref params, New with ref params, Dynamic with ref params.
-        /// </remarks>
-        public static bool IsAssignment(this ExpressionType type) {
-            return IsWriteOnlyAssignment(type) || IsReadWriteAssignment(type);
-        }
-
-        public static bool IsWriteOnlyAssignment(this ExpressionType type) {
-            return type == ExpressionType.Assign;
-        }
-
-        public static bool IsReadWriteAssignment(this ExpressionType type) {
-            switch (type) {
-                // unary:
-                case ExpressionType.PostDecrementAssign:
-                case ExpressionType.PostIncrementAssign:
-                case ExpressionType.PreDecrementAssign:
-                case ExpressionType.PreIncrementAssign:
-
-                // binary - compound:
-                case ExpressionType.AddAssign:
-                case ExpressionType.AddAssignChecked:
-                case ExpressionType.AndAssign:
-                case ExpressionType.DivideAssign:
-                case ExpressionType.ExclusiveOrAssign:
-                case ExpressionType.LeftShiftAssign:
-                case ExpressionType.ModuloAssign:
-                case ExpressionType.MultiplyAssign:
-                case ExpressionType.MultiplyAssignChecked:
-                case ExpressionType.OrAssign:
-                case ExpressionType.PowerAssign:
-                case ExpressionType.RightShiftAssign:
-                case ExpressionType.SubtractAssign:
-                case ExpressionType.SubtractAssignChecked:
-                    return true;
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// Determines if the left child of the given expression is read or written to or both.
-        /// </summary>
-        public static ExpressionAccess GetLValueAccess(this ExpressionType type) {
-            if (type.IsReadWriteAssignment()) {
-                return ExpressionAccess.ReadWrite;
-            }
-
-            if (type.IsWriteOnlyAssignment()) {
-                return ExpressionAccess.Write;
-            }
-
-            return ExpressionAccess.Read;
-        }
-
-        public static bool IsLValue(this ExpressionType type) {
-            // see Expression.RequiresCanWrite
-            switch (type) {
-                case ExpressionType.Index:
-                case ExpressionType.MemberAccess:
-                case ExpressionType.Parameter:
-                    return true;
-            }
-
-            return false;
-        }
-    }
-}

+ 0 - 911
mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs

@@ -1,911 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_NUMERICS
-using BigInt = System.Numerics.BigInteger;
-#endif
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#endif
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Dynamic;
-using System.Linq;
-using System.Reflection;
-using System.Threading;
-#if FEATURE_REFEMIT
-using System.Reflection.Emit;
-#endif
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Actions;
-using Microsoft.Scripting.Ast;
-using Microsoft.Scripting.Interpreter;
-using Microsoft.Scripting.Math;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-using AstUtils = Microsoft.Scripting.Ast.Utils;
-
-namespace Microsoft.Scripting.Generation {
-    // TODO: keep this?
-    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")]
-    public delegate void ActionRef<T0, T1>(ref T0 arg0, ref T1 arg1);
-
-    public static class CompilerHelpers {
-		public const MethodAttributes PublicStatic = MethodAttributes.Public | MethodAttributes.Static;
-		private static MethodInfo _CreateInstanceMethod;
-
-        private static int _Counter; // for generating unique names for lambda methods
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
-        public static object GetMissingValue(Type type) {
-            ContractUtils.RequiresNotNull(type, "type");
-
-            if (type.IsByRef) type = type.GetElementType();
-            if (type.IsEnum()) return Activator.CreateInstance(type);
-
-            switch (type.GetTypeCode()) {
-                default:
-                case TypeCode.Object:
-                    // struct
-                    if (type.IsSealed() && type.IsValueType()) {
-                        return Activator.CreateInstance(type);
-                    } else if (type == typeof(object)) {
-                        // parameter of type object receives the actual Missing value
-                        return Missing.Value;
-                    } else if (!type.IsValueType()) {
-                        return null;
-                    } else {
-                        throw Error.CantCreateDefaultTypeFor(type);
-                    }
-                case TypeCode.Empty:
-                case TypeCode.DBNull:
-                case TypeCode.String:
-                    return null;
-
-                case TypeCode.Boolean: return false;
-                case TypeCode.Char: return '\0';
-                case TypeCode.SByte: return (sbyte)0;
-                case TypeCode.Byte: return (byte)0;
-                case TypeCode.Int16: return (short)0;
-                case TypeCode.UInt16: return (ushort)0;
-                case TypeCode.Int32: return (int)0;
-                case TypeCode.UInt32: return (uint)0;
-                case TypeCode.Int64: return 0L;
-                case TypeCode.UInt64: return 0UL;
-                case TypeCode.Single: return 0.0f;
-                case TypeCode.Double: return 0.0D;
-                case TypeCode.Decimal: return (decimal)0;
-                case TypeCode.DateTime: return DateTime.MinValue;
-            }
-        }
-
-        public static bool IsStatic(MethodBase mi) {
-            return mi.IsConstructor || mi.IsStatic;
-        }
-
-        /// <summary>
-        /// True if the MethodBase is method which is going to construct an object
-        /// </summary>
-        public static bool IsConstructor(MethodBase mb) {
-            if (mb.IsConstructor) {
-                return true;
-            }
-
-            if (mb.IsGenericMethod) {
-                MethodInfo mi = mb as MethodInfo;
-
-				if (_CreateInstanceMethod == null)
-					Interlocked.CompareExchange (ref _CreateInstanceMethod, typeof(ScriptingRuntimeHelpers).GetMethod ("CreateInstance"), null);
-
-				if (mi.GetGenericMethodDefinition() == _CreateInstanceMethod) {
-                    return true;
-                }
-            }
-
-            return false;
-        }
-
-        public static T[] MakeRepeatedArray<T>(T item, int count) {
-            T[] ret = new T[count];
-            for (int i = 0; i < count; i++) ret[i] = item;
-            return ret;
-        }
-        
-        public static bool IsComparisonOperator(ExpressionType op) {
-            switch (op) {
-                case ExpressionType.LessThan: return true;
-                case ExpressionType.LessThanOrEqual: return true;
-                case ExpressionType.GreaterThan: return true;
-                case ExpressionType.GreaterThanOrEqual: return true;
-                case ExpressionType.Equal: return true;
-                case ExpressionType.NotEqual: return true;
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// Returns the System.Type for any object, including null.  The type of null
-        /// is represented by None.Type and all other objects just return the 
-        /// result of Object.GetType
-        /// </summary>
-        public static Type GetType(object obj) {
-            if (obj == null) {
-                return typeof(DynamicNull);
-            }
-
-            return obj.GetType();
-        }
-
-        /// <summary>
-        /// Simply returns a Type[] from calling GetType on each element of args.
-        /// </summary>
-        public static Type[] GetTypes(object[] args) {
-            Type[] types = new Type[args.Length];
-            for (int i = 0; i < args.Length; i++) {
-                types[i] = GetType(args[i]);
-            }
-            return types;
-        }
-
-        /// <summary>
-        /// EMITTED
-        /// Used by default method binder to check types of splatted arguments.
-        /// </summary>
-        public static bool TypesEqual(IList args, int start, Type[] types) {
-            for (int i = 0; i < types.Length; i++) {
-                object arg = args[start + i];
-                if (types[i] != (arg != null ? arg.GetType() : null)) {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        public static bool CanOptimizeMethod(MethodBase method) {
-            if (method.ContainsGenericParameters ||
-                method.IsProtected() ||
-                method.IsPrivate ||
-                !method.DeclaringType.IsVisible()) {
-                return false;
-            }
-            return true;
-        }
-
-        /// <summary>
-        /// Given a MethodInfo which may be declared on a non-public type this attempts to
-        /// return a MethodInfo which will dispatch to the original MethodInfo but is declared
-        /// on a public type.
-        /// 
-        /// Returns the original method if the method if a public version cannot be found.
-        /// </summary>
-        public static MethodInfo TryGetCallableMethod(Type targetType, MethodInfo method) {
-            if (method.DeclaringType == null || method.DeclaringType.IsVisible()) {
-                return method;
-            }
-
-            // first try and get it from the base type we're overriding...
-            MethodInfo baseMethod = method.GetRuntimeBaseDefinition();
-
-            if (baseMethod.DeclaringType.IsVisible() || baseMethod.DeclaringType.IsInterface()) {
-                // We need to instantiate the method as GetBaseDefinition might return a generic definition of the base method:
-                if (baseMethod.IsGenericMethodDefinition) {
-                    baseMethod = baseMethod.MakeGenericMethod(method.GetGenericArguments());
-                }
-                return baseMethod;
-            }
-
-#if WIN8 // TODO: interface map, method handle
-            foreach (Type iface in targetType.GetImplementedInterfaces()) {
-                dynamic mapping = ((dynamic)targetType).GetInterfaceMap(iface);
-                for (int i = 0; i < mapping.TargetMethods.Length; i++) {
-                    MethodInfo targetMethod = mapping.TargetMethods[i];
-                    if (targetMethod != null && ((dynamic)targetMethod).MethodHandle == ((dynamic)method).MethodHandle) {
-                        return mapping.InterfaceMethods[i];
-                    }
-                }
-            }
-#else
-            // maybe we can get it from an interface on the type this
-            // method came from...
-            foreach (Type iface in targetType.GetImplementedInterfaces()) {
-                if (iface.IsPublic()) {
-                    InterfaceMapping mapping = targetType.GetInterfaceMap(iface);
-                    for (int i = 0; i < mapping.TargetMethods.Length; i++) {
-                        MethodInfo targetMethod = mapping.TargetMethods[i];
-                        if (targetMethod != null && targetMethod.MethodHandle == method.MethodHandle) {
-                            return mapping.InterfaceMethods[i];
-                        }
-                    }
-                }
-            }
-#endif
-            return method;
-        }
-
-        /// <summary>
-        /// Non-public types can have public members that we find when calling type.GetMember(...).  This
-        /// filters out the non-visible members by attempting to resolve them to the correct visible type.
-        /// 
-        /// If no correct visible type can be found then the member is not visible and we won't call it.
-        /// </summary>
-        public static IEnumerable<MemberInfo> FilterNonVisibleMembers(Type targetType, IEnumerable<MemberInfo> members) {
-            if (targetType.IsVisible()) {
-                return members;
-            } else {
-                return FilterNonVisibleMembersIterator(targetType, members);
-            }
-        }
-
-        public static IEnumerable<MemberInfo> FilterNonVisibleMembersIterator(Type targetType, IEnumerable<MemberInfo> members) {
-            foreach (var member in members) {
-                MemberInfo visible = TryGetVisibleMember(targetType, member);
-                if (visible != null) {
-                    yield return visible;
-                }
-            }
-        }
-
-        public static MemberInfo TryGetVisibleMember(Type targetType, MemberInfo member) {
-            MethodInfo method;
-            PropertyInfo property;
-            EventInfo evnt;
-
-            MethodInfo mi;
-            MemberInfo visible = null;
-
-            if ((method = member as MethodInfo) != null) {
-                mi = TryGetCallableMethod(targetType, method);
-                if (CompilerHelpers.IsVisible(mi)) {
-                    visible = mi;
-                }
-            } else if ((property = member as PropertyInfo) != null) {
-                mi = TryGetCallableMethod(targetType, property.GetGetMethod() ?? property.GetSetMethod());
-                if (CompilerHelpers.IsVisible(mi)) {
-                    visible = mi.DeclaringType.GetDeclaredProperty(property.Name);
-                }
-            } else if ((evnt = member as EventInfo) != null) {
-                mi = TryGetCallableMethod(targetType, evnt.GetAddMethod() ?? evnt.GetRemoveMethod() ?? evnt.GetRaiseMethod());
-                if (CompilerHelpers.IsVisible(mi)) {
-                    visible = mi.DeclaringType.GetDeclaredEvent(evnt.Name);
-                }
-            }
-        
-            // all others can't be exposed out this way
-            return visible;
-        }
-
-#if !WIN8
-        /// <summary>
-        /// Sees if two MemberInfos point to the same underlying construct in IL.  This
-        /// ignores the ReflectedType property which exists on MemberInfos which
-        /// causes direct comparisons to be false even if they are the same member.
-        /// </summary>
-        public static bool MemberEquals(this MemberInfo self, MemberInfo other) {
-            if ((self == null) != (other == null)) {
-                // one null, the other isn't.
-                return false;
-            } else if (self == null) {
-                // both null
-                return true;
-            }
-
-            if (self.MemberType != other.MemberType) {
-                return false;
-            }
-
-            switch (self.MemberType) {
-                case MemberTypes.Field:
-                    return ((FieldInfo)self).FieldHandle.Equals(((FieldInfo)other).FieldHandle);
-                case MemberTypes.Method:
-                    return ((MethodInfo)self).MethodHandle.Equals(((MethodInfo)other).MethodHandle);
-                case MemberTypes.Constructor:
-                    return ((ConstructorInfo)self).MethodHandle.Equals(((ConstructorInfo)other).MethodHandle);
-                case MemberTypes.NestedType:
-                case MemberTypes.TypeInfo:
-                    return ((Type)self).TypeHandle.Equals(((Type)other).TypeHandle);
-                case MemberTypes.Event:
-                case MemberTypes.Property:
-                default:
-                    return
-                        ((MemberInfo)self).Module == ((MemberInfo)other).Module &&
-                        ((MemberInfo)self).MetadataToken == ((MemberInfo)other).MetadataToken;
-            }
-        }
-#endif
-
-        public static bool IsVisible(MethodBase info) {
-            return info.IsPublic && (info.DeclaringType == null || info.DeclaringType.IsVisible());
-        }
-
-        public static bool IsVisible(FieldInfo info) {
-            return info.IsPublic && (info.DeclaringType == null || info.DeclaringType.IsVisible());
-        }
-
-        public static bool IsProtected(this MethodBase info) {
-            return info.IsFamily || info.IsFamilyOrAssembly;
-        }
-
-        public static bool IsProtected(this FieldInfo info) {
-            return info.IsFamily || info.IsFamilyOrAssembly;
-        }
-
-        public static bool IsProtected(this Type type) {
-            return type.GetTypeInfo().IsNestedFamily || type.GetTypeInfo().IsNestedFamORAssem;
-        }
-
-        public static Type GetVisibleType(object value) {
-            return GetVisibleType(GetType(value));
-        }
-
-        public static Type GetVisibleType(Type t) {
-            while (!t.IsVisible()) {
-                t = t.GetBaseType();
-            }
-            return t;
-        }
-
-        public static MethodBase[] GetConstructors(Type t, bool privateBinding) {
-            return GetConstructors(t, privateBinding, false);
-        }
-
-        public static MethodBase[] GetConstructors(Type t, bool privateBinding, bool includeProtected) {
-            if (t.IsArray) {
-                // The JIT verifier doesn't like new int[](3) even though it appears as a ctor.
-                // We could do better and return newarr in the future.
-                return new MethodBase[] { GetArrayCtor(t) };
-            }
-
-            BindingFlags bf = BindingFlags.Instance | BindingFlags.Public;
-            if (privateBinding || includeProtected) {
-                bf |= BindingFlags.NonPublic;
-            }
-
-            IEnumerable<ConstructorInfo> ctors = t.GetDeclaredConstructors().WithBindingFlags(bf);
-
-            // leave in protected ctors, even if we're not in private binding mode.
-            if (!privateBinding && includeProtected) {
-                ctors = FilterConstructorsToPublicAndProtected(ctors);
-            }
-
-            if (t.IsValueType()
-#if !SILVERLIGHT && !WIN8 && !WP75
-                && t != typeof(ArgIterator)
-#endif
-) {
-                // structs don't define a parameterless ctor, add a generic method for that.
-                List<MethodBase> result = new List<MethodBase>();
-                result.Add(GetStructDefaultCtor(t));
-                result.AddRange(ctors.Cast<ConstructorInfo, MethodBase>());
-                return result.ToArray();
-            } else {
-                return ctors.ToArray();
-            }
-        }
-
-        public static IEnumerable<ConstructorInfo> FilterConstructorsToPublicAndProtected(IEnumerable<ConstructorInfo> ctors) {
-            foreach (var ctor in ctors) {
-                if (ctor.IsPublic || ctor.IsProtected()) {
-                    yield return ctor;
-                }
-            }
-        }
-
-        private static MethodBase GetStructDefaultCtor(Type t) {
-            return typeof(ScriptingRuntimeHelpers).GetDeclaredMethods("CreateInstance").Single().MakeGenericMethod(t);
-        }
-
-        private static MethodBase GetArrayCtor(Type t) {
-            return typeof(ScriptingRuntimeHelpers).GetDeclaredMethods("CreateArray").Single().MakeGenericMethod(t.GetElementType());
-        }
-
-        #region Type Conversions
-
-        public static MethodInfo GetImplicitConverter(Type fromType, Type toType) {
-            return GetConverter(fromType, fromType, toType, "op_Implicit") ?? GetConverter(toType, fromType, toType, "op_Implicit");
-        }
-
-        public static MethodInfo GetExplicitConverter(Type fromType, Type toType) {
-            return GetConverter(fromType, fromType, toType, "op_Explicit") ?? GetConverter(toType, fromType, toType, "op_Explicit");
-        }
-
-        private static MethodInfo GetConverter(Type type, Type fromType, Type toType, string opMethodName) {
-            foreach (MethodInfo mi in type.GetInheritedMembers(opMethodName).WithBindingFlags(BindingFlags.Public | BindingFlags.Static)) {
-                if ((mi.DeclaringType == null || mi.DeclaringType.IsVisible()) && mi.IsPublic &&
-                    mi.ReturnType == toType && mi.GetParameters()[0].ParameterType.IsAssignableFrom(fromType)) {
-                    return mi;
-                }
-            }
-            return null;
-        }
-
-        public static bool TryImplicitConversion(Object value, Type to, out object result) {
-            if (CompilerHelpers.TryImplicitConvert(value, to, to.GetInheritedMethods("op_Implicit").WithBindingFlags(BindingFlags.Public | BindingFlags.Static), out result)) {
-                return true;
-            }
-
-            Type curType = CompilerHelpers.GetType(value);
-            do {
-                if (CompilerHelpers.TryImplicitConvert(value, to, curType.GetInheritedMethods("op_Implicit").WithBindingFlags(BindingFlags.Public | BindingFlags.Static), out result)) {
-                    return true;
-                }
-                curType = curType.GetBaseType();
-            } while (curType != null);
-
-            return false;
-        }
-
-        private static bool TryImplicitConvert(Object value, Type to, IEnumerable<MethodInfo> implicitConv, out object result) {
-            foreach (MethodInfo mi in implicitConv) {
-                if (to.IsValueType() == mi.ReturnType.IsValueType() && to.IsAssignableFrom(mi.ReturnType)) {
-                    if (mi.IsStatic) {
-                        result = mi.Invoke(null, new object[] { value });
-                    } else {
-                        result = mi.Invoke(value, ArrayUtils.EmptyObjects);
-                    }
-                    return true;
-                }
-            }
-
-            result = null;
-            return false;
-        }
-
-        public static bool IsStrongBox(object target) {
-            Type t = CompilerHelpers.GetType(target);
-
-            return IsStrongBox(t);
-        }
-
-        public static bool IsStrongBox(Type t) {
-            return t.IsGenericType() && t.GetGenericTypeDefinition() == typeof(StrongBox<>);
-        }
-
-        /// <summary>
-        /// Returns a value which indicates failure when a OldConvertToAction of ImplicitTry or
-        /// ExplicitTry.
-        /// </summary>
-        public static Expression GetTryConvertReturnValue(Type type) {
-            Expression res;
-            var info = type.GetTypeInfo();
-            if (info.IsInterface || info.IsClass || (info.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))) {
-                res = AstUtils.Constant(null, type);
-            } else {
-                res = AstUtils.Constant(Activator.CreateInstance(type));
-            }
-
-            return res;
-        }
-
-        public static bool HasTypeConverter(Type fromType, Type toType) {
-#if FEATURE_TYPECONVERTER
-             TypeConverter _;
-            return TryGetTypeConverter(fromType, toType, out _);
-#else
-            return false;
-#endif
-        }
-
-        public static bool TryApplyTypeConverter(object value, Type toType, out object result) {
-#if FEATURE_TYPECONVERTER
-            TypeConverter converter;
-            if (value != null && CompilerHelpers.TryGetTypeConverter(value.GetType(), toType, out converter)) {
-                result = converter.ConvertFrom(value);
-                return true;
-            } else {
-                result = value;
-                return false;
-            }
-#else
-            result = value;
-            return false;
-#endif
-        }
-
-#if FEATURE_TYPECONVERTER
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
-        public static bool TryGetTypeConverter(Type fromType, Type toType, out TypeConverter converter) {
-            ContractUtils.RequiresNotNull(fromType, "fromType");
-            ContractUtils.RequiresNotNull(toType, "toType");
-
-            // try available type conversions...
-            foreach (TypeConverterAttribute tca in toType.GetCustomAttributes(typeof(TypeConverterAttribute), true)) {
-                try {
-                    converter = Activator.CreateInstance(Type.GetType(tca.ConverterTypeName)) as TypeConverter;
-                } catch (Exception) {
-                    converter = null;
-                }
-
-                if (converter != null && converter.CanConvertFrom(fromType)) {
-                    return true;
-                }
-            }
-
-            converter = null;
-            return false;
-        }
-#endif
-
-        #endregion
-
-#if !MONO_INTERPRETER
-        public static MethodBase[] GetMethodTargets(object obj) {
-            Type t = CompilerHelpers.GetType(obj);
-
-            if (typeof(Delegate).IsAssignableFrom(t)) {
-                MethodInfo mi = t.GetMethod("Invoke");
-                return new MethodBase[] { mi };
-            } else if (typeof(BoundMemberTracker).IsAssignableFrom(t)) {
-                BoundMemberTracker bmt = obj as BoundMemberTracker;
-                if (bmt.BoundTo.MemberType == TrackerTypes.Method) {
-                }
-            } else if (typeof(MethodGroup).IsAssignableFrom(t)) {
-            } else if (typeof(MemberGroup).IsAssignableFrom(t)) {
-            } else {
-                return MakeCallSignatureForCallableObject(t);
-            }
-
-            return null;
-        }
-#endif
-
-        private static MethodBase[] MakeCallSignatureForCallableObject(Type t) {
-            List<MethodBase> res = new List<MethodBase>();
-            foreach (MethodInfo method in t.GetInheritedMethods("Call")) {
-                if (method.IsSpecialName) {
-                    res.Add(method);
-                }
-            }
-            return res.ToArray();
-        }
-
-        public static Type[] GetSiteTypes(IList<Expression> arguments, Type returnType) {
-            int count = arguments.Count;
-
-            Type[] ret = new Type[count + 1];
-
-            for (int i = 0; i < count; i++) {
-                ret[i] = arguments[i].Type;
-            }
-
-            ret[count] = returnType;
-            return ret;
-        }
-
-        public static Type[] GetExpressionTypes(Expression[] expressions) {
-            ContractUtils.RequiresNotNull(expressions, "expressions");
-
-            Type[] res = new Type[expressions.Length];
-            for (int i = 0; i < res.Length; i++) {
-                ContractUtils.RequiresNotNull(expressions[i], "expressions[i]");
-
-                res[i] = expressions[i].Type;
-            }
-
-            return res;
-        }
-
-        public static Type MakeCallSiteType(params Type[] types) {
-            return typeof(CallSite<>).MakeGenericType(DelegateHelpers.MakeDelegate(types));
-        }
-
-        public static Type MakeCallSiteDelegateType(Type[] types) {
-            return DelegateHelpers.MakeDelegate(types);
-        }
-
-        /// <summary>
-        /// Creates an interpreted delegate for the lambda.
-        /// </summary>
-        /// <param name="lambda">The lambda to compile.</param>
-        /// <returns>A delegate which can interpret the lambda.</returns>
-        public static Delegate LightCompile(this LambdaExpression lambda) {
-            return new LightCompiler(-1).CompileTop(lambda).CreateDelegate();
-        }
-
-        /// <summary>
-        /// Creates an interpreted delegate for the lambda.
-        /// </summary>
-        /// <param name="lambda">The lambda to compile.</param>
-        /// <param name="compilationThreshold">The number of iterations before the interpreter starts compiling</param>
-        /// <returns>A delegate which can interpret the lambda.</returns>
-        public static Delegate LightCompile(this LambdaExpression lambda, int compilationThreshold) {
-            return new LightCompiler(compilationThreshold).CompileTop(lambda).CreateDelegate();
-        }
-
-        /// <summary>
-        /// Creates an interpreted delegate for the lambda.
-        /// </summary>
-        /// <typeparam name="T">The lambda's delegate type.</typeparam>
-        /// <param name="lambda">The lambda to compile.</param>
-        /// <returns>A delegate which can interpret the lambda.</returns>
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
-        public static T LightCompile<T>(this Expression<T> lambda) {
-            return (T)(object)LightCompile((LambdaExpression)lambda);
-        }
-
-        /// <summary>
-        /// Creates an interpreted delegate for the lambda.
-        /// </summary>
-        /// <param name="lambda">The lambda to compile.</param>
-        /// <param name="compilationThreshold">The number of iterations before the interpreter starts compiling</param>
-        /// <returns>A delegate which can interpret the lambda.</returns>
-        public static T LightCompile<T>(this Expression<T> lambda, int compilationThreshold) {
-            return (T)(object)LightCompile((LambdaExpression)lambda, compilationThreshold);
-        }
-
-#if FEATURE_REFEMIT
-        /// <summary>
-        /// Compiles the lambda into a method definition.
-        /// </summary>
-        /// <param name="lambda">the lambda to compile</param>
-        /// <param name="method">A <see cref="MethodBuilder"/> which will be used to hold the lambda's IL.</param>
-        /// <param name="emitDebugSymbols">A parameter that indicates if debugging information should be emitted to a PDB symbol store.</param>
-        public static void CompileToMethod(this LambdaExpression lambda, MethodBuilder method, bool emitDebugSymbols) {
-#if FEATURE_PDBEMIT
-            if (emitDebugSymbols) {
-                var module = method.Module as ModuleBuilder;
-                ContractUtils.Requires(module != null, "method", "MethodBuilder does not have a valid ModuleBuilder");
-                lambda.CompileToMethod(method, DebugInfoGenerator.CreatePdbGenerator());
-                return;
-            }
-#endif
-
-#if WIN8 // TODO
-            ((dynamic)lambda).CompileToMethod(method);
-#else
-            lambda.CompileToMethod(method);
-#endif
-        }
-#endif
-
-        /// <summary>
-        /// Compiles the LambdaExpression.
-        /// 
-        /// If the lambda is compiled with emitDebugSymbols, it will be
-        /// generated into a TypeBuilder. Otherwise, this method is the same as
-        /// calling LambdaExpression.Compile()
-        /// 
-        /// This is a workaround for a CLR limitiation: DynamicMethods cannot
-        /// have debugging information.
-        /// </summary>
-        /// <param name="lambda">the lambda to compile</param>
-        /// <param name="emitDebugSymbols">true to generate a debuggable method, false otherwise</param>
-        /// <returns>the compiled delegate</returns>
-        public static T Compile<T>(this Expression<T> lambda, bool emitDebugSymbols) {
-#if FEATURE_PDBEMIT && FEATURE_REFEMIT
-            if (emitDebugSymbols) {
-                return CompileToMethod(lambda, DebugInfoGenerator.CreatePdbGenerator(), true);
-            }
-#endif
-            return lambda.Compile();
-        }
-
-#if FEATURE_REFEMIT
-        /// <summary>
-        /// Compiles the LambdaExpression, emitting it into a new type, and
-        /// optionally making it debuggable.
-        /// 
-        /// This is a workaround for a CLR limitiation: DynamicMethods cannot
-        /// have debugging information.
-        /// </summary>
-        /// <param name="lambda">the lambda to compile</param>
-        /// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param>
-        /// <param name="emitDebugSymbols">True if debug symbols (PDBs) are emitted by the <paramref name="debugInfoGenerator"/>.</param>
-        /// <returns>the compiled delegate</returns>
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
-        public static T CompileToMethod<T>(Expression<T> lambda, DebugInfoGenerator debugInfoGenerator, bool emitDebugSymbols) {
-            return (T)(object)CompileToMethod((LambdaExpression)lambda, debugInfoGenerator, emitDebugSymbols);
-        }
-
-        public static Delegate CompileToMethod(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator, bool emitDebugSymbols) {
-            string methodName = String.IsNullOrEmpty(lambda.Name) ? GetUniqueMethodName() : lambda.Name;
-
-            var type = Snippets.Shared.DefineType(methodName, typeof(object), false, emitDebugSymbols).TypeBuilder;
-            var rewriter = new DebuggableCodeRewriter(type);
-            lambda = (LambdaExpression)rewriter.Visit(lambda);
-
-            //Create a unique method name when the lambda doesn't have a name or the name is empty.
-            var method = type.DefineMethod(methodName, CompilerHelpers.PublicStatic);
-
-            lambda.CompileToMethod(method, debugInfoGenerator);
-            var finished = type.CreateType();
-
-            rewriter.InitializeFields(finished);
-            
-            return finished.GetMethod(method.Name).CreateDelegate(lambda.Type);
-        }
-
-        /// <summary>
-        /// Removes all live objects and places them in static fields of a type.
-        /// </summary>
-        private sealed class DebuggableCodeRewriter : DynamicExpressionVisitor {
-            private readonly Dictionary<object, FieldBuilder> _fields = new Dictionary<object, FieldBuilder>(ReferenceEqualityComparer<object>.Instance);
-            private readonly TypeBuilder _type;
-            private readonly HashSet<string> _methodNames = new HashSet<string>();
-
-            internal DebuggableCodeRewriter(TypeBuilder type) {
-                _type = type;
-            }
-
-            internal void InitializeFields(Type type) {
-                foreach (var pair in _fields) {
-                    type.GetInheritedFields(pair.Value.Name).First().SetValue(null, pair.Key);
-                }
-            }
-
-            protected override Expression VisitLambda<T>(Expression<T> node) {
-                if (_methodNames.Contains(node.Name)) {
-                    int count = _methodNames.Count;
-
-                    string newName;
-                    do {
-                        newName = node.Name + "$" + count++;
-                    } while (_methodNames.Contains(newName));
-
-                    _methodNames.Add(newName);
-                    return Expression.Lambda<T>(
-                        base.Visit(node.Body),
-                        newName,
-                        node.TailCall,
-                        node.Parameters
-                    );
-                } else {
-                    _methodNames.Add(node.Name);
-                    return base.VisitLambda<T>(node);
-                }
-            }
-
-            protected override Expression VisitExtension(Expression node) {
-                // LightDynamicExpressions override Visit but we want to really reduce them
-                // because they reduce to DynamicExpressions.
-                LightDynamicExpression lightDyn = node as LightDynamicExpression;
-                if (lightDyn != null) {
-                    return Visit(lightDyn.Reduce());
-                }
-
-                return Visit(node.Reduce());
-            }
-
-            protected override Expression VisitConstant(ConstantExpression node) {
-                if (CanEmitConstant(node.Value, node.Type)) {
-                    return node;
-                }
-
-                FieldBuilder field;
-                if (!_fields.TryGetValue(node.Value, out field)) {
-                    field = _type.DefineField(
-                        "$constant" + _fields.Count,
-                        GetVisibleType(node.Value.GetType()),
-                        FieldAttributes.Public | FieldAttributes.Static
-                    );
-                    _fields.Add(node.Value, field);
-                }
-
-                Expression result = Expression.Field(null, field);
-                if (result.Type != node.Type) {
-                    result = Expression.Convert(result, node.Type);
-                }
-                return result;
-            }
-
-            protected override Expression VisitDynamic(DynamicExpression node) {
-                return Visit(Reduce(node));
-            }
-        }
-#endif
-
-        public static string GetUniqueMethodName() {
-            return "lambda_method" + "$" + System.Threading.Interlocked.Increment(ref _Counter);
-        }
-
-#if FEATURE_LCG
-        // Matches ILGen.TryEmitConstant
-        public static bool CanEmitConstant(object value, Type type) {
-            if (value == null || CanEmitILConstant(type)) {
-                return true;
-            }
-
-            Type t = value as Type;
-            if (t != null && ILGen.ShouldLdtoken(t)) {
-                return true;
-            }
-
-            MethodBase mb = value as MethodBase;
-            if (mb != null && ILGen.ShouldLdtoken(mb)) {
-                return true;
-            }
-
-            return false;
-        }
-
-        // Matches ILGen.TryEmitILConstant
-        internal static bool CanEmitILConstant(Type type) {
-            switch (type.GetTypeCode()) {
-                case TypeCode.Boolean:
-                case TypeCode.SByte:
-                case TypeCode.Int16:
-                case TypeCode.Int32:
-                case TypeCode.Int64:
-                case TypeCode.Single:
-                case TypeCode.Double:
-                case TypeCode.Char:
-                case TypeCode.Byte:
-                case TypeCode.UInt16:
-                case TypeCode.UInt32:
-                case TypeCode.UInt64:
-                case TypeCode.Decimal:
-                case TypeCode.String:
-                    return true;
-            }
-            return false;
-        }
-#endif
-
-        /// <summary>
-        /// Reduces the provided DynamicExpression into site.Target(site, *args).
-        /// </summary>
-        public static Expression Reduce(DynamicExpression node) {
-            // Store the callsite as a constant
-            var siteConstant = AstUtils.Constant(CallSite.Create(node.DelegateType, node.Binder));
-
-            // ($site = siteExpr).Target.Invoke($site, *args)
-            var site = Expression.Variable(siteConstant.Type, "$site");
-            return Expression.Block(
-                new[] { site },
-                Expression.Call(
-                    Expression.Field(
-                        Expression.Assign(site, siteConstant),
-                        siteConstant.Type.GetDeclaredField("Target")
-                    ),
-                    node.DelegateType.GetMethod("Invoke"),
-                    ArrayUtils.Insert(site, node.Arguments)
-                )
-            );
-        }
-#if !MONO_INTERPRETER
-        #region Factories
-#if !FEATURE_NUMERICS
-        [CLSCompliant(false)]
-        public static BigInteger CreateBigInteger(int sign, uint[] data) {
-            return new BigInteger(sign, data);
-        }
-#else
-        public static BigInteger CreateBigInteger(bool isNegative, byte[] data) {
-            return new BigInteger(CreateBigInt(isNegative, data));
-        }
-
-        public static BigInt CreateBigInt(int value) {
-            return (BigInt)value;
-        }
-
-        public static BigInt CreateBigInt(long value) {
-            return (BigInt)value;
-        }
-
-        public static BigInt CreateBigInt(bool isNegative, byte[] data) {
-            BigInt res = new BigInt(data);
-            return isNegative ? -res : res;
-        }
-
-#endif
-        #endregion
-#endif
-    }
-}

+ 0 - 128
mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/ConstantCheck.cs

@@ -1,128 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System.Diagnostics;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Generation {
-
-    public static class ConstantCheck {
-
-        /// <summary>
-        /// Tests to see if the expression is a constant with the given value.
-        /// </summary>
-        /// <param name="expression">The expression to examine</param>
-        /// <param name="value">The constant value to check for.</param>
-        /// <returns>true/false</returns>
-        public static bool Check(Expression expression, object value) {
-            ContractUtils.RequiresNotNull(expression, "expression");
-            return IsConstant(expression, value);
-        }
-
-
-        /// <summary>
-        /// Tests to see if the expression is a constant with the given value.
-        /// </summary>
-        /// <param name="e">The expression to examine</param>
-        /// <param name="value">The constant value to check for.</param>
-        /// <returns>true/false</returns>
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
-        internal static bool IsConstant(Expression e, object value) {
-            switch (e.NodeType) {
-                case ExpressionType.AndAlso:
-                    return CheckAndAlso((BinaryExpression)e, value);
-
-                case ExpressionType.OrElse:
-                    return CheckOrElse((BinaryExpression)e, value);
-
-                case ExpressionType.Constant:
-                    return CheckConstant((ConstantExpression)e, value);
-
-                case ExpressionType.TypeIs:
-                    return Check((TypeBinaryExpression)e, value);
-
-                default:
-                    return false;
-            }
-        }
-
-        //CONFORMING
-        internal static bool IsNull(Expression e) {
-            return IsConstant(e, null);
-        }
-
-
-        private static bool CheckAndAlso(BinaryExpression node, object value) {
-            Debug.Assert(node.NodeType == ExpressionType.AndAlso);
-
-            if (node.Method != null) {
-                return false;
-            }
-            //TODO: we can propagate through conversion, but it may not worth it.
-            if (node.Conversion != null) {
-                return false;
-            }
-    
-            if (value is bool) {
-                if ((bool)value) {
-                    return IsConstant(node.Left, true) && IsConstant(node.Right, true);
-                } else {
-                    // if left isn't a constant it has to be evaluated
-                    return IsConstant(node.Left, false);
-                }
-            }
-            return false;
-        }
-
-        private static bool CheckOrElse(BinaryExpression node, object value) {
-            Debug.Assert(node.NodeType == ExpressionType.OrElse);
-
-            if (node.Method != null) {
-                return false;
-            }
-
-            if (value is bool) {
-                if ((bool)value) {
-                    return IsConstant(node.Left, true);
-                } else {
-                    return IsConstant(node.Left, false) && IsConstant(node.Right, false);
-                }
-            }
-            return false;
-        }
-
-        private static bool CheckConstant(ConstantExpression node, object value) {
-            if (value == null) {
-                return node.Value == null;
-            } else {
-                return value.Equals(node.Value);
-            }
-        }
-
-        private static bool Check(TypeBinaryExpression node, object value) {
-            // allow constant TypeIs expressions to be optimized away
-            if (value is bool && ((bool)value) == true) {
-                return node.TypeOperand.IsAssignableFrom(node.Expression.Type);
-            }
-            return false;
-        }
-    }
-}

+ 0 - 110
mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/DelegateHelpers.Generated.cs

@@ -1,110 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Linq;
-using System.Diagnostics;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Generation {
-    internal static partial class DelegateHelpers {
-
-        #region Generated Maximum Delegate Arity
-
-        // *** BEGIN GENERATED CODE ***
-        // generated by function: gen_max_delegate_arity from: generate_dynsites.py
-
-        private const int MaximumArity = 17;
-
-        // *** END GENERATED CODE ***
-
-        #endregion
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
-        internal static Type MakeDelegate(Type[] types) {
-            Debug.Assert(types != null && types.Length > 0);
-
-            // Can only used predefined delegates if we have no byref types and
-            // the arity is small enough to fit in Func<...> or Action<...>
-            if (types.Length > MaximumArity || types.Any(t => t.IsByRef)) {
-                return MakeCustomDelegate(types);
-            }
-
-            Type returnType = types[types.Length - 1];
-            if (returnType == typeof(void)) {
-                types = types.RemoveLast();
-                switch (types.Length) {
-                    case 0: return typeof(Action);
-                    #region Generated Delegate Action Types
-
-                    // *** BEGIN GENERATED CODE ***
-                    // generated by function: gen_delegate_action from: generate_dynsites.py
-
-                    case 1: return typeof(Action<>).MakeGenericType(types);
-                    case 2: return typeof(Action<,>).MakeGenericType(types);
-                    case 3: return typeof(Action<,,>).MakeGenericType(types);
-                    case 4: return typeof(Action<,,,>).MakeGenericType(types);
-                    case 5: return typeof(Action<,,,,>).MakeGenericType(types);
-                    case 6: return typeof(Action<,,,,,>).MakeGenericType(types);
-                    case 7: return typeof(Action<,,,,,,>).MakeGenericType(types);
-                    case 8: return typeof(Action<,,,,,,,>).MakeGenericType(types);
-                    case 9: return typeof(Action<,,,,,,,,>).MakeGenericType(types);
-                    case 10: return typeof(Action<,,,,,,,,,>).MakeGenericType(types);
-                    case 11: return typeof(Action<,,,,,,,,,,>).MakeGenericType(types);
-                    case 12: return typeof(Action<,,,,,,,,,,,>).MakeGenericType(types);
-                    case 13: return typeof(Action<,,,,,,,,,,,,>).MakeGenericType(types);
-                    case 14: return typeof(Action<,,,,,,,,,,,,,>).MakeGenericType(types);
-                    case 15: return typeof(Action<,,,,,,,,,,,,,,>).MakeGenericType(types);
-                    case 16: return typeof(Action<,,,,,,,,,,,,,,,>).MakeGenericType(types);
-
-                    // *** END GENERATED CODE ***
-
-                    #endregion
-                }
-            } else {
-                switch (types.Length) {
-                    #region Generated Delegate Func Types
-
-                    // *** BEGIN GENERATED CODE ***
-                    // generated by function: gen_delegate_func from: generate_dynsites.py
-
-                    case 1: return typeof(Func<>).MakeGenericType(types);
-                    case 2: return typeof(Func<,>).MakeGenericType(types);
-                    case 3: return typeof(Func<,,>).MakeGenericType(types);
-                    case 4: return typeof(Func<,,,>).MakeGenericType(types);
-                    case 5: return typeof(Func<,,,,>).MakeGenericType(types);
-                    case 6: return typeof(Func<,,,,,>).MakeGenericType(types);
-                    case 7: return typeof(Func<,,,,,,>).MakeGenericType(types);
-                    case 8: return typeof(Func<,,,,,,,>).MakeGenericType(types);
-                    case 9: return typeof(Func<,,,,,,,,>).MakeGenericType(types);
-                    case 10: return typeof(Func<,,,,,,,,,>).MakeGenericType(types);
-                    case 11: return typeof(Func<,,,,,,,,,,>).MakeGenericType(types);
-                    case 12: return typeof(Func<,,,,,,,,,,,>).MakeGenericType(types);
-                    case 13: return typeof(Func<,,,,,,,,,,,,>).MakeGenericType(types);
-                    case 14: return typeof(Func<,,,,,,,,,,,,,>).MakeGenericType(types);
-                    case 15: return typeof(Func<,,,,,,,,,,,,,,>).MakeGenericType(types);
-                    case 16: return typeof(Func<,,,,,,,,,,,,,,,>).MakeGenericType(types);
-                    case 17: return typeof(Func<,,,,,,,,,,,,,,,,>).MakeGenericType(types);
-
-                    // *** END GENERATED CODE ***
-
-                    #endregion
-                }
-            }
-            throw Assert.Unreachable;
-        }
-    }
-}

+ 0 - 87
mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/DelegateHelpers.cs

@@ -1,87 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-#if FEATURE_REFEMIT
-using System.Reflection.Emit;
-#endif
-using System.Threading;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Generation {
-    internal static partial class DelegateHelpers {
-
-        private static Dictionary<ICollection<Type>, Type> _DelegateTypes;
-
-        private static Type MakeCustomDelegate(Type[] types) {
-            if (_DelegateTypes == null) {
-                Interlocked.CompareExchange(
-                    ref _DelegateTypes,
-                    new Dictionary<ICollection<Type>, Type>(ListEqualityComparer<Type>.Instance),
-                    null
-                );
-            }
-
-            bool found;
-            Type type;
-
-            //
-            // LOCK to retrieve the delegate type, if any
-            //
-
-            lock (_DelegateTypes) {
-                found = _DelegateTypes.TryGetValue(types, out type);
-            }
-
-            if (!found && type != null) {
-                return type;
-            }
-
-            //
-            // Create new delegate type
-            //
-
-            type = MakeNewCustomDelegate(types);
-
-            //
-            // LOCK to insert new delegate into the cache. If we already have one (racing threads), use the one from the cache
-            //
-
-            lock (_DelegateTypes) {
-                Type conflict;
-                if (_DelegateTypes.TryGetValue(types, out conflict) && conflict != null) {
-                    type = conflict;
-                } else {
-                    _DelegateTypes[types] = type;
-                }
-            }
-
-            return type;
-        }
-
-        private static Type MakeNewCustomDelegate(Type[] types) {
-#if FEATURE_REFEMIT
-            Type returnType = types[types.Length - 1];
-            Type[] parameters = types.RemoveLast();
-
-            return Snippets.Shared.DefineDelegate("Delegate" + types.Length, returnType, parameters);
-#else
-            throw new NotSupportedException("Signature not supported on this platform");
-#endif
-        }
-    }
-}

+ 0 - 108
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/BranchLabel.cs

@@ -1,108 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Diagnostics;
-using System.Collections.Generic;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal struct RuntimeLabel {
-        public readonly int Index;
-        public readonly int StackDepth;
-        public readonly int ContinuationStackDepth;
-
-        public RuntimeLabel(int index, int continuationStackDepth, int stackDepth) {
-            Index = index;
-            ContinuationStackDepth = continuationStackDepth;
-            StackDepth = stackDepth;
-        }
-
-        public override string ToString() {
-            return String.Format("->{0} C({1}) S({2})", Index, ContinuationStackDepth, StackDepth);
-        }
-    }
-
-    public sealed class BranchLabel {
-        internal const int UnknownIndex = Int32.MinValue;
-        internal const int UnknownDepth = Int32.MinValue;
-
-        internal int _labelIndex = UnknownIndex;
-        internal int _targetIndex = UnknownIndex;
-        internal int _stackDepth = UnknownDepth;
-        internal int _continuationStackDepth = UnknownDepth;
-
-        // Offsets of forward branching instructions targetting this label 
-        // that need to be updated after we emit the label.
-        private List<int> _forwardBranchFixups;
-
-        public BranchLabel() {
-        }
-
-        internal int LabelIndex {
-            get { return _labelIndex; }
-            set { _labelIndex = value; }
-        }
-
-        internal bool HasRuntimeLabel {
-            get { return _labelIndex != UnknownIndex; } 
-        }
-
-        internal int TargetIndex {
-            get { return _targetIndex; }
-        }
-
-        internal RuntimeLabel ToRuntimeLabel() {
-            Debug.Assert(_targetIndex != UnknownIndex && _stackDepth != UnknownDepth && _continuationStackDepth != UnknownDepth);
-            return new RuntimeLabel(_targetIndex, _continuationStackDepth, _stackDepth);
-        }
-
-        internal void Mark(InstructionList instructions) {
-            ContractUtils.Requires(_targetIndex == UnknownIndex && _stackDepth == UnknownDepth && _continuationStackDepth == UnknownDepth);
-
-            _stackDepth = instructions.CurrentStackDepth;
-            _continuationStackDepth = instructions.CurrentContinuationsDepth;
-            _targetIndex = instructions.Count;
-
-            if (_forwardBranchFixups != null) {
-                foreach (var branchIndex in _forwardBranchFixups) {
-                    FixupBranch(instructions, branchIndex);
-                }
-                _forwardBranchFixups = null;
-            }
-        }
-
-        internal void AddBranch(InstructionList instructions, int branchIndex) {
-            Debug.Assert(((_targetIndex == UnknownIndex) == (_stackDepth == UnknownDepth)));
-            Debug.Assert(((_targetIndex == UnknownIndex) == (_continuationStackDepth == UnknownDepth)));
-
-            if (_targetIndex == UnknownIndex) {
-                if (_forwardBranchFixups == null) {
-                    _forwardBranchFixups = new List<int>();
-                }
-                _forwardBranchFixups.Add(branchIndex);
-            } else {
-                FixupBranch(instructions, branchIndex);
-            }
-        }
-
-        internal void FixupBranch(InstructionList instructions, int branchIndex) {
-            Debug.Assert(_targetIndex != UnknownIndex);
-            instructions.FixupBranch(branchIndex, _targetIndex - branchIndex);
-        }
-    }
-
-
-}

+ 0 - 34
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/ILightCallSiteBinder.cs

@@ -1,34 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-using System.Reflection;
-using Microsoft.Scripting.Interpreter;
-using System.Runtime.CompilerServices;
-using System.Collections.Generic;
-
-namespace Microsoft.Scripting.Interpreter {
-    public interface ILightCallSiteBinder {
-        bool AcceptsArgumentArray { get; }
-    }
-}

+ 0 - 191
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs

@@ -1,191 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class AddInstruction : ArithmeticInstruction {
-
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        private AddInstruction() {
-        }
-
-        internal sealed class AddInt32 : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l + (Int32)r));
-            }
-        }
-
-        internal sealed class AddInt16 : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16)unchecked((Int16)l + (Int16)r);
-            }
-        }
-
-        internal sealed class AddInt64 : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)unchecked((Int64)l + (Int64)r);
-            }
-        }
-
-        internal sealed class AddUInt16 : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16)unchecked((UInt16)l + (UInt16)r);
-            }
-        }
-
-        internal sealed class AddUInt32 : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)unchecked((UInt32)l + (UInt32)r);
-            }
-        }
-
-        internal sealed class AddUInt64 : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)unchecked((UInt64)l + (UInt64)r);
-            }
-        }
-
-        internal sealed class AddSingle : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Single)((Single)l + (Single)r);
-            }
-        }
-
-        internal sealed class AddDouble : AddInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Double)l + (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new AddInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new AddInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new AddInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new AddUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new AddUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new AddUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new AddSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new AddDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Add()";
-        }
-    }
-
-    internal abstract class AddOvfInstruction : ArithmeticInstruction {
-
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        private AddOvfInstruction() {
-        }
-
-        internal sealed class AddOvfInt32 : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject(checked((Int32)l + (Int32)r));
-            }
-        }
-
-        internal sealed class AddOvfInt16 : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((Int16)((Int16)l + (Int16)r));
-            }
-        }
-
-        internal sealed class AddOvfInt64 : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((Int64)((Int64)l + (Int64)r));
-            }
-        }
-
-        internal sealed class AddOvfUInt16 : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt16)((UInt16)l + (UInt16)r));
-            }
-        }
-
-        internal sealed class AddOvfUInt32 : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt32)((UInt32)l + (UInt32)r));
-            }
-        }
-
-        internal sealed class AddOvfUInt64 : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt64)((UInt64)l + (UInt64)r));
-            }
-        }
-
-        internal sealed class AddOvfSingle : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Single)((Single)l + (Single)r);
-            }
-        }
-
-        internal sealed class AddOvfDouble : AddOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Double)l + (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new AddOvfInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new AddOvfInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new AddOvfInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new AddOvfUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new AddOvfUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new AddOvfUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new AddOvfSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new AddOvfDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "AddOvf()";
-        }
-    }
-}

+ 0 - 176
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs

@@ -1,176 +0,0 @@
-// 
-// AndInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class AndInstruction : ArithmeticInstruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Boolean;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _BooleanLifted;
-
-        private AndInstruction() {
-        }
-
-        internal sealed class AndInt32 : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject((Int32)l & (Int32)r);
-            }
-        }
-
-        internal sealed class AndInt16 : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16)((Int16)l & (Int16)r);
-            }
-        }
-
-        internal sealed class AndInt64 : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)((Int64)l & (Int64)r);
-            }
-        }
-
-        internal sealed class AndUInt16 : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16)((UInt16)l & (UInt16)r);
-            }
-        }
-
-        internal sealed class AndUInt32 : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)((UInt32)l & (UInt32)r);
-            }
-        }
-
-        internal sealed class AndUInt64 : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)((UInt64)l & (UInt64)r);
-            }
-        }
-
-        internal sealed class AndBoolean : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Boolean)((Boolean)l & (Boolean)r);
-            }
-        }
-
-        internal sealed class AndInt32Lifted : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32?)((Int32?)l & (Int32?)r);
-            }
-        }
-
-        internal sealed class AndInt16Lifted : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16?)((Int16?)l & (Int16?)r);
-            }
-        }
-
-        internal sealed class AndInt64Lifted : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64?)((Int64?)l & (Int64?)r);
-            }
-        }
-
-        internal sealed class AndUInt16Lifted : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16?)((UInt16?)l & (UInt16?)r);
-            }
-        }
-
-        internal sealed class AndUInt32Lifted : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32?)((UInt32?)l & (UInt32?)r);
-            }
-        }
-
-        internal sealed class AndUInt64Lifted : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64?)((UInt64?)l & (UInt64?)r);
-            }
-        }
-
-        internal sealed class AndBooleanLifted : AndInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ((Boolean?)l & (Boolean?)r);
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new AndInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new AndInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new AndInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new AndUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new AndUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new AndUInt64());
-                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new AndBoolean());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new AndInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new AndInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new AndInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new AndUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new AndUInt32Lifted());
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new AndUInt64Lifted());
-                case TypeCode.Boolean: return _BooleanLifted ?? (_BooleanLifted = new AndBooleanLifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "And()";
-        }
-    }
-}

+ 0 - 50
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ArithmeticInstruction.cs

@@ -1,50 +0,0 @@
-// 
-// ArithmeticInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class ArithmeticInstruction : Instruction {
-
-        public override int ConsumedStack { get { return 2; } }
-        public override int ProducedStack { get { return 1; } }
-
-        protected abstract object Calculate (object l, object r);
-
-        public override int Run(InterpretedFrame frame) {
-            object l = frame.Data[frame.StackIndex - 2];
-            object r = frame.Data[frame.StackIndex - 1];
-            frame.Data[frame.StackIndex - 2] = Calculate (l, r);
-            frame.StackIndex--;
-            return +1;
-        }
-    }
-}

+ 0 - 134
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ArrayOperations.cs

@@ -1,134 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-
-namespace Microsoft.Scripting.Interpreter {
-    public sealed class NewArrayInitInstruction<TElement> : Instruction {
-        private readonly int _elementCount;
-
-        internal NewArrayInitInstruction(int elementCount) {
-            _elementCount = elementCount;
-        }
-
-        public override int ConsumedStack { get { return _elementCount; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            TElement[] array = new TElement[_elementCount];
-            for (int i = _elementCount - 1; i >= 0; i--) {
-                array[i] = (TElement)frame.Pop();
-            }
-            frame.Push(array);
-            return +1;
-        }
-    }
-
-    public sealed class NewArrayInstruction<TElement> : Instruction {
-        internal NewArrayInstruction() { }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            int length = (int)frame.Pop();
-            frame.Push(new TElement[length]);
-            return +1;
-        }
-    }
-
-    public sealed class NewArrayBoundsInstruction : Instruction {
-        private readonly Type _elementType;
-        private readonly int _rank;
-
-        internal NewArrayBoundsInstruction(Type elementType, int rank) {
-            _elementType = elementType;
-            _rank = rank;
-        }
-
-        public override int ConsumedStack { get { return _rank; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var lengths = new int[_rank];
-            for (int i = _rank - 1; i >= 0; i--) {
-                lengths[i] = (int)frame.Pop();
-            }
-            var array = Array.CreateInstance(_elementType, lengths);
-            frame.Push(array);
-            return +1;
-        }
-    }
-
-    public sealed class GetArrayItemInstruction<TElement> : Instruction {
-        internal GetArrayItemInstruction() { }
-
-        public override int ConsumedStack { get { return 2; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            int index = (int)frame.Pop();
-            TElement[] array = (TElement[])frame.Pop();
-            frame.Push(array[index]);
-            return +1;
-        }
-
-        public override string InstructionName {
-            get { return "GetArrayItem"; }
-        }
-    }
-
-    public sealed class GetArrayLengthInstruction : Instruction {
-        private static Instruction instance;
-
-        private GetArrayLengthInstruction() { }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var array = (Array)frame.Pop();
-            frame.Push(array.Length);
-            return +1;
-        }
-
-        public static Instruction Create() {
-            return instance ?? (instance = new GetArrayLengthInstruction());
-        }
-
-        public override string InstructionName {
-            get { return "GetArrayLength"; }
-        }
-    }
-
-    public sealed class SetArrayItemInstruction<TElement> : Instruction {
-        internal SetArrayItemInstruction() { }
-
-        public override int ConsumedStack { get { return 3; } }
-        public override int ProducedStack { get { return 0; } }
-
-        public override int Run(InterpretedFrame frame) {
-            TElement value = (TElement)frame.Pop();
-            int index = (int)frame.Pop();
-            TElement[] array = (TElement[])frame.Pop();
-            array[index] = value;
-            return +1;
-        }
-
-        public override string InstructionName {
-            get { return "SetArrayItem"; }
-        }
-    }
-}

+ 0 - 905
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.Generated.cs

@@ -1,905 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Threading;
-using Microsoft.Scripting.Utils;
-using Microsoft.Scripting.Generation;
-using Microsoft.Scripting.Runtime;
-
-using System.Dynamic;
-
-namespace Microsoft.Scripting.Interpreter {
-    #region Generated Reflected Caller
-
-    // *** BEGIN GENERATED CODE ***
-    // generated by function: gen_all from: generate_reflected_calls.py
-
-    public partial class CallInstruction {
-        private const int MaxHelpers = 10;
-        private const int MaxArgs = 3;
-
-        public virtual object InvokeInstance(object instance, params object[] args) {
-            switch(args.Length) {
-                case 0: return Invoke(instance);
-                case 1: return Invoke(instance, args[0]);
-                case 2: return Invoke(instance, args[0], args[1]);
-                case 3: return Invoke(instance, args[0], args[1], args[2]);
-                case 4: return Invoke(instance, args[0], args[1], args[2], args[3]);
-                case 5: return Invoke(instance, args[0], args[1], args[2], args[3], args[4]);
-                case 6: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5]);
-                case 7: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
-                case 8: return Invoke(instance, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-                default: throw new InvalidOperationException();
-            }
-        }
-
-        public virtual object Invoke(params object[] args) {
-            switch(args.Length) {
-                case 0: return Invoke();
-                case 1: return Invoke(args[0]);
-                case 2: return Invoke(args[0], args[1]);
-                case 3: return Invoke(args[0], args[1], args[2]);
-                case 4: return Invoke(args[0], args[1], args[2], args[3]);
-                case 5: return Invoke(args[0], args[1], args[2], args[3], args[4]);
-                case 6: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5]);
-                case 7: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
-                case 8: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-                case 9: return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
-                default: throw new InvalidOperationException();
-            }
-        }
-
-        public virtual object Invoke() { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1, object arg2) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1, object arg2, object arg3) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) { throw new InvalidOperationException(); }
-        public virtual object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) { throw new InvalidOperationException(); }
-
-        /// <summary>
-        /// Fast creation works if we have a known primitive types for the entire
-        /// method siganture.  If we have any non-primitive types then FastCreate
-        /// falls back to SlowCreate which works for all types.
-        /// 
-        /// Fast creation is fast because it avoids using reflection (MakeGenericType
-        /// and Activator.CreateInstance) to create the types.  It does this through
-        /// calling a series of generic methods picking up each strong type of the
-        /// signature along the way.  When it runs out of types it news up the 
-        /// appropriate CallInstruction with the strong-types that have been built up.
-        /// 
-        /// One relaxation is that for return types which are non-primitive types
-        /// we can fallback to object due to relaxed delegates.
-        /// </summary>
-        private static CallInstruction FastCreate(MethodInfo target, ParameterInfo[] pi) {
-            Type t = TryGetParameterOrReturnType(target, pi, 0);
-            if (t == null) {
-                return new ActionCallInstruction(target);
-            }
-
-            if (t.IsEnum()) return SlowCreate(target, pi);
-            switch (t.GetTypeCode()) {
-                case TypeCode.Object: {
-                    if (t != typeof(object) && (IndexIsNotReturnType(0, target, pi) || t.IsValueType())) {
-                        // if we're on the return type relaxed delegates makes it ok to use object
-                        goto default;
-                    }
-                    return FastCreate<Object>(target, pi);
-                }
-                case TypeCode.Int16: return FastCreate<Int16>(target, pi);
-                case TypeCode.Int32: return FastCreate<Int32>(target, pi);
-                case TypeCode.Int64: return FastCreate<Int64>(target, pi);
-                case TypeCode.Boolean: return FastCreate<Boolean>(target, pi);
-                case TypeCode.Char: return FastCreate<Char>(target, pi);
-                case TypeCode.Byte: return FastCreate<Byte>(target, pi);
-                case TypeCode.Decimal: return FastCreate<Decimal>(target, pi);
-                case TypeCode.DateTime: return FastCreate<DateTime>(target, pi);
-                case TypeCode.Double: return FastCreate<Double>(target, pi);
-                case TypeCode.Single: return FastCreate<Single>(target, pi);
-                case TypeCode.UInt16: return FastCreate<UInt16>(target, pi);
-                case TypeCode.UInt32: return FastCreate<UInt32>(target, pi);
-                case TypeCode.UInt64: return FastCreate<UInt64>(target, pi);
-                case TypeCode.String: return FastCreate<String>(target, pi);
-                case TypeCode.SByte: return FastCreate<SByte>(target, pi);
-                default: return SlowCreate(target, pi);
-            }
-        }
-
-        private static CallInstruction FastCreate<T0>(MethodInfo target, ParameterInfo[] pi) {
-            Type t = TryGetParameterOrReturnType(target, pi, 1);
-            if (t == null) {
-                if (target.ReturnType == typeof(void)) {
-                    return new ActionCallInstruction<T0>(target);
-                }
-                return new FuncCallInstruction<T0>(target);
-            }
-
-            if (t.IsEnum()) return SlowCreate(target, pi);
-            switch (t.GetTypeCode()) {
-                case TypeCode.Object: {
-                    if (t != typeof(object) && (IndexIsNotReturnType(1, target, pi) || t.IsValueType())) {
-                        // if we're on the return type relaxed delegates makes it ok to use object
-                        goto default;
-                    }
-                    return FastCreate<T0, Object>(target, pi);
-                }
-                case TypeCode.Int16: return FastCreate<T0, Int16>(target, pi);
-                case TypeCode.Int32: return FastCreate<T0, Int32>(target, pi);
-                case TypeCode.Int64: return FastCreate<T0, Int64>(target, pi);
-                case TypeCode.Boolean: return FastCreate<T0, Boolean>(target, pi);
-                case TypeCode.Char: return FastCreate<T0, Char>(target, pi);
-                case TypeCode.Byte: return FastCreate<T0, Byte>(target, pi);
-                case TypeCode.Decimal: return FastCreate<T0, Decimal>(target, pi);
-                case TypeCode.DateTime: return FastCreate<T0, DateTime>(target, pi);
-                case TypeCode.Double: return FastCreate<T0, Double>(target, pi);
-                case TypeCode.Single: return FastCreate<T0, Single>(target, pi);
-                case TypeCode.UInt16: return FastCreate<T0, UInt16>(target, pi);
-                case TypeCode.UInt32: return FastCreate<T0, UInt32>(target, pi);
-                case TypeCode.UInt64: return FastCreate<T0, UInt64>(target, pi);
-                case TypeCode.String: return FastCreate<T0, String>(target, pi);
-                case TypeCode.SByte: return FastCreate<T0, SByte>(target, pi);
-                default: return SlowCreate(target, pi);
-            }
-        }
-
-        private static CallInstruction FastCreate<T0, T1>(MethodInfo target, ParameterInfo[] pi) {
-            Type t = TryGetParameterOrReturnType(target, pi, 2);
-            if (t == null) {
-                if (target.ReturnType == typeof(void)) {
-                    return new ActionCallInstruction<T0, T1>(target);
-                }
-                return new FuncCallInstruction<T0, T1>(target);
-            }
-
-            if (t.IsEnum()) return SlowCreate(target, pi);
-            switch (t.GetTypeCode()) {
-                case TypeCode.Object: {
-                    Debug.Assert(pi.Length == 2);
-                    if (t.IsValueType()) goto default;
-
-                    return new FuncCallInstruction<T0, T1, Object>(target);
-                }
-                case TypeCode.Int16: return new FuncCallInstruction<T0, T1, Int16>(target);
-                case TypeCode.Int32: return new FuncCallInstruction<T0, T1, Int32>(target);
-                case TypeCode.Int64: return new FuncCallInstruction<T0, T1, Int64>(target);
-                case TypeCode.Boolean: return new FuncCallInstruction<T0, T1, Boolean>(target);
-                case TypeCode.Char: return new FuncCallInstruction<T0, T1, Char>(target);
-                case TypeCode.Byte: return new FuncCallInstruction<T0, T1, Byte>(target);
-                case TypeCode.Decimal: return new FuncCallInstruction<T0, T1, Decimal>(target);
-                case TypeCode.DateTime: return new FuncCallInstruction<T0, T1, DateTime>(target);
-                case TypeCode.Double: return new FuncCallInstruction<T0, T1, Double>(target);
-                case TypeCode.Single: return new FuncCallInstruction<T0, T1, Single>(target);
-                case TypeCode.UInt16: return new FuncCallInstruction<T0, T1, UInt16>(target);
-                case TypeCode.UInt32: return new FuncCallInstruction<T0, T1, UInt32>(target);
-                case TypeCode.UInt64: return new FuncCallInstruction<T0, T1, UInt64>(target);
-                case TypeCode.String: return new FuncCallInstruction<T0, T1, String>(target);
-                case TypeCode.SByte: return new FuncCallInstruction<T0, T1, SByte>(target);
-                default: return SlowCreate(target, pi);
-            }
-        }
-
-        private static Type GetHelperType(MethodInfo info, Type[] arrTypes) {
-            Type t;
-            if (info.ReturnType == typeof(void)) {
-                switch (arrTypes.Length) {
-                    case 0: t = typeof(ActionCallInstruction); break;
-                    case 1: t = typeof(ActionCallInstruction<>).MakeGenericType(arrTypes); break;
-                    case 2: t = typeof(ActionCallInstruction<,>).MakeGenericType(arrTypes); break;
-                    case 3: t = typeof(ActionCallInstruction<,,>).MakeGenericType(arrTypes); break;
-                    case 4: t = typeof(ActionCallInstruction<,,,>).MakeGenericType(arrTypes); break;
-                    case 5: t = typeof(ActionCallInstruction<,,,,>).MakeGenericType(arrTypes); break;
-                    case 6: t = typeof(ActionCallInstruction<,,,,,>).MakeGenericType(arrTypes); break;
-                    case 7: t = typeof(ActionCallInstruction<,,,,,,>).MakeGenericType(arrTypes); break;
-                    case 8: t = typeof(ActionCallInstruction<,,,,,,,>).MakeGenericType(arrTypes); break;
-                    case 9: t = typeof(ActionCallInstruction<,,,,,,,,>).MakeGenericType(arrTypes); break;
-                    default: throw new InvalidOperationException();
-                }
-            } else {
-                switch (arrTypes.Length) {
-                    case 1: t = typeof(FuncCallInstruction<>).MakeGenericType(arrTypes); break;
-                    case 2: t = typeof(FuncCallInstruction<,>).MakeGenericType(arrTypes); break;
-                    case 3: t = typeof(FuncCallInstruction<,,>).MakeGenericType(arrTypes); break;
-                    case 4: t = typeof(FuncCallInstruction<,,,>).MakeGenericType(arrTypes); break;
-                    case 5: t = typeof(FuncCallInstruction<,,,,>).MakeGenericType(arrTypes); break;
-                    case 6: t = typeof(FuncCallInstruction<,,,,,>).MakeGenericType(arrTypes); break;
-                    case 7: t = typeof(FuncCallInstruction<,,,,,,>).MakeGenericType(arrTypes); break;
-                    case 8: t = typeof(FuncCallInstruction<,,,,,,,>).MakeGenericType(arrTypes); break;
-                    case 9: t = typeof(FuncCallInstruction<,,,,,,,,>).MakeGenericType(arrTypes); break;
-                    case 10: t = typeof(FuncCallInstruction<,,,,,,,,,>).MakeGenericType(arrTypes); break;
-                    default: throw new InvalidOperationException();
-                }
-            }
-            return t;
-        }
-        public static MethodInfo CacheFunc<TRet>(Func<TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, TRet>(Func<T0, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, TRet>(Func<T0, T1, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, T2, TRet>(Func<T0, T1, T2, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, T2, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, T2, T3, TRet>(Func<T0, T1, T2, T3, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, TRet>(Func<T0, T1, T2, T3, T4, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, TRet>(Func<T0, T1, T2, T3, T4, T5, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, T7, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheFunc<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction(Action method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0>(Action<T0> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1>(Action<T0, T1> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1, T2>(Action<T0, T1, T2> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1, T2>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1, T2, T3>(Action<T0, T1, T2, T3> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1, T2, T3>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1, T2, T3, T4>(Action<T0, T1, T2, T3, T4> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5>(Action<T0, T1, T2, T3, T4, T5> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6>(Action<T0, T1, T2, T3, T4, T5, T6> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6, T7>(Action<T0, T1, T2, T3, T4, T5, T6, T7> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7>(method);
-            }
-            return info;
-        }
-
-        public static MethodInfo CacheAction<T0, T1, T2, T3, T4, T5, T6, T7, T8>(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> method) {
-            var info = method.GetMethodInfo();
-            lock (_cache) {
-                _cache[info] = new ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8>(method);
-            }
-            return info;
-        }
-
-    }
-
-    internal sealed class ActionCallInstruction : CallInstruction {
-        private readonly Action _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 0; } }
-
-        public ActionCallInstruction(Action target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action)target.CreateDelegate(typeof(Action));
-        }
-
-        public override object Invoke() {
-            _target();
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target();
-            frame.StackIndex -= 0;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0> : CallInstruction {
-        private readonly Action<T0> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 1; } }
-
-        public ActionCallInstruction(Action<T0> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0>)target.CreateDelegate(typeof(Action<T0>));
-        }
-
-        public override object Invoke(object arg0) {
-            _target(arg0 != null ? (T0)arg0 : default(T0));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 1;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1> : CallInstruction {
-        private readonly Action<T0, T1> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 2; } }
-
-        public ActionCallInstruction(Action<T0, T1> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1>)target.CreateDelegate(typeof(Action<T0, T1>));
-        }
-
-        public override object Invoke(object arg0, object arg1) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 2;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1, T2> : CallInstruction {
-        private readonly Action<T0, T1, T2> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 3; } }
-
-        public ActionCallInstruction(Action<T0, T1, T2> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1, T2>)target.CreateDelegate(typeof(Action<T0, T1, T2>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 3], (T1)frame.Data[frame.StackIndex - 2], (T2)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 3;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1, T2, T3> : CallInstruction {
-        private readonly Action<T0, T1, T2, T3> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 4; } }
-
-        public ActionCallInstruction(Action<T0, T1, T2, T3> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1, T2, T3>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 4], (T1)frame.Data[frame.StackIndex - 3], (T2)frame.Data[frame.StackIndex - 2], (T3)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 4;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4> : CallInstruction {
-        private readonly Action<T0, T1, T2, T3, T4> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 5; } }
-
-        public ActionCallInstruction(Action<T0, T1, T2, T3, T4> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1, T2, T3, T4>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 5], (T1)frame.Data[frame.StackIndex - 4], (T2)frame.Data[frame.StackIndex - 3], (T3)frame.Data[frame.StackIndex - 2], (T4)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 5;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5> : CallInstruction {
-        private readonly Action<T0, T1, T2, T3, T4, T5> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 6; } }
-
-        public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1, T2, T3, T4, T5>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 6], (T1)frame.Data[frame.StackIndex - 5], (T2)frame.Data[frame.StackIndex - 4], (T3)frame.Data[frame.StackIndex - 3], (T4)frame.Data[frame.StackIndex - 2], (T5)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 6;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6> : CallInstruction {
-        private readonly Action<T0, T1, T2, T3, T4, T5, T6> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 7; } }
-
-        public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1, T2, T3, T4, T5, T6>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 7], (T1)frame.Data[frame.StackIndex - 6], (T2)frame.Data[frame.StackIndex - 5], (T3)frame.Data[frame.StackIndex - 4], (T4)frame.Data[frame.StackIndex - 3], (T5)frame.Data[frame.StackIndex - 2], (T6)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 7;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7> : CallInstruction {
-        private readonly Action<T0, T1, T2, T3, T4, T5, T6, T7> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 8; } }
-
-        public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6, T7> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1, T2, T3, T4, T5, T6, T7>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6, T7>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 8], (T1)frame.Data[frame.StackIndex - 7], (T2)frame.Data[frame.StackIndex - 6], (T3)frame.Data[frame.StackIndex - 5], (T4)frame.Data[frame.StackIndex - 4], (T5)frame.Data[frame.StackIndex - 3], (T6)frame.Data[frame.StackIndex - 2], (T7)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 8;
-            return 1;
-        }
-    }
-
-    internal sealed class ActionCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8> : CallInstruction {
-        private readonly Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 9; } }
-
-        public ActionCallInstruction(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8> target) {
-            _target = target;
-        }
-
-        public ActionCallInstruction(MethodInfo target) {
-            _target = (Action<T0, T1, T2, T3, T4, T5, T6, T7, T8>)target.CreateDelegate(typeof(Action<T0, T1, T2, T3, T4, T5, T6, T7, T8>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) {
-            _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7), arg8 != null ? (T8)arg8 : default(T8));
-            return null;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            _target((T0)frame.Data[frame.StackIndex - 9], (T1)frame.Data[frame.StackIndex - 8], (T2)frame.Data[frame.StackIndex - 7], (T3)frame.Data[frame.StackIndex - 6], (T4)frame.Data[frame.StackIndex - 5], (T5)frame.Data[frame.StackIndex - 4], (T6)frame.Data[frame.StackIndex - 3], (T7)frame.Data[frame.StackIndex - 2], (T8)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 9;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<TRet> : CallInstruction {
-        private readonly Func<TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 0; } }
-
-        public FuncCallInstruction(Func<TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<TRet>)target.CreateDelegate(typeof(Func<TRet>));
-        }
-
-        public override object Invoke() {
-            return _target();
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 0] = _target();
-            frame.StackIndex -= -1;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, TRet> : CallInstruction {
-        private readonly Func<T0, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 1; } }
-
-        public FuncCallInstruction(Func<T0, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, TRet>)target.CreateDelegate(typeof(Func<T0, TRet>));
-        }
-
-        public override object Invoke(object arg0) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 1] = _target((T0)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 0;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, TRet> : CallInstruction {
-        private readonly Func<T0, T1, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 2; } }
-
-        public FuncCallInstruction(Func<T0, T1, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, TRet>)target.CreateDelegate(typeof(Func<T0, T1, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 2] = _target((T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 1;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, T2, TRet> : CallInstruction {
-        private readonly Func<T0, T1, T2, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 3; } }
-
-        public FuncCallInstruction(Func<T0, T1, T2, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, T2, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 3] = _target((T0)frame.Data[frame.StackIndex - 3], (T1)frame.Data[frame.StackIndex - 2], (T2)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 2;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, T2, T3, TRet> : CallInstruction {
-        private readonly Func<T0, T1, T2, T3, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 4; } }
-
-        public FuncCallInstruction(Func<T0, T1, T2, T3, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, T2, T3, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 4] = _target((T0)frame.Data[frame.StackIndex - 4], (T1)frame.Data[frame.StackIndex - 3], (T2)frame.Data[frame.StackIndex - 2], (T3)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 3;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, TRet> : CallInstruction {
-        private readonly Func<T0, T1, T2, T3, T4, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 5; } }
-
-        public FuncCallInstruction(Func<T0, T1, T2, T3, T4, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, T2, T3, T4, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 5] = _target((T0)frame.Data[frame.StackIndex - 5], (T1)frame.Data[frame.StackIndex - 4], (T2)frame.Data[frame.StackIndex - 3], (T3)frame.Data[frame.StackIndex - 2], (T4)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 4;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, TRet> : CallInstruction {
-        private readonly Func<T0, T1, T2, T3, T4, T5, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 6; } }
-
-        public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, T2, T3, T4, T5, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 6] = _target((T0)frame.Data[frame.StackIndex - 6], (T1)frame.Data[frame.StackIndex - 5], (T2)frame.Data[frame.StackIndex - 4], (T3)frame.Data[frame.StackIndex - 3], (T4)frame.Data[frame.StackIndex - 2], (T5)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 5;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, TRet> : CallInstruction {
-        private readonly Func<T0, T1, T2, T3, T4, T5, T6, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 7; } }
-
-        public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, T2, T3, T4, T5, T6, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 7] = _target((T0)frame.Data[frame.StackIndex - 7], (T1)frame.Data[frame.StackIndex - 6], (T2)frame.Data[frame.StackIndex - 5], (T3)frame.Data[frame.StackIndex - 4], (T4)frame.Data[frame.StackIndex - 3], (T5)frame.Data[frame.StackIndex - 2], (T6)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 6;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, TRet> : CallInstruction {
-        private readonly Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 8; } }
-
-        public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, T7, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 8] = _target((T0)frame.Data[frame.StackIndex - 8], (T1)frame.Data[frame.StackIndex - 7], (T2)frame.Data[frame.StackIndex - 6], (T3)frame.Data[frame.StackIndex - 5], (T4)frame.Data[frame.StackIndex - 4], (T5)frame.Data[frame.StackIndex - 3], (T6)frame.Data[frame.StackIndex - 2], (T7)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 7;
-            return 1;
-        }
-    }
-
-    internal sealed class FuncCallInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> : CallInstruction {
-        private readonly Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> _target;
-        public override MethodInfo Info { get { return _target.GetMethodInfo(); } }
-        public override int ArgumentCount { get { return 9; } }
-
-        public FuncCallInstruction(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet> target) {
-            _target = target;
-        }
-
-        public FuncCallInstruction(MethodInfo target) {
-            _target = (Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>)target.CreateDelegate(typeof(Func<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>));
-        }
-
-        public override object Invoke(object arg0, object arg1, object arg2, object arg3, object arg4, object arg5, object arg6, object arg7, object arg8) {
-            return _target(arg0 != null ? (T0)arg0 : default(T0), arg1 != null ? (T1)arg1 : default(T1), arg2 != null ? (T2)arg2 : default(T2), arg3 != null ? (T3)arg3 : default(T3), arg4 != null ? (T4)arg4 : default(T4), arg5 != null ? (T5)arg5 : default(T5), arg6 != null ? (T6)arg6 : default(T6), arg7 != null ? (T7)arg7 : default(T7), arg8 != null ? (T8)arg8 : default(T8));
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 9] = _target((T0)frame.Data[frame.StackIndex - 9], (T1)frame.Data[frame.StackIndex - 8], (T2)frame.Data[frame.StackIndex - 7], (T3)frame.Data[frame.StackIndex - 6], (T4)frame.Data[frame.StackIndex - 5], (T5)frame.Data[frame.StackIndex - 4], (T6)frame.Data[frame.StackIndex - 3], (T7)frame.Data[frame.StackIndex - 2], (T8)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 8;
-            return 1;
-        }
-    }
-
-    internal sealed partial class MethodInfoCallInstruction : CallInstruction {
-        public override object Invoke() {
-            return InvokeWorker();
-        }
-        public override object Invoke(object arg0) {
-            return InvokeWorker(arg0);
-        }
-        public override object Invoke(object arg0, object arg1) {
-            return InvokeWorker(arg0, arg1);
-        }
-    }
-
-    // *** END GENERATED CODE ***
-
-    #endregion
-}

+ 0 - 300
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.cs

@@ -1,300 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-#if FEATURE_REFEMIT
-using System.Reflection.Emit;
-#endif
-using System.Security;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    public abstract partial class CallInstruction : Instruction {
-        public abstract MethodInfo Info { get; }
-
-        /// <summary>
-        /// The number of arguments including "this" for instance methods.
-        /// </summary>
-        public abstract int ArgumentCount { get; }
-
-        #region Construction
-
-        internal CallInstruction() { }
-        
-        private static readonly Dictionary<MethodInfo, CallInstruction> _cache = new Dictionary<MethodInfo, CallInstruction>();
-
-        /// <exception cref="SecurityException">Instruction can't be created due to insufficient privileges.</exception>
-        public static CallInstruction Create(MethodInfo info) {
-            return Create(info, info.GetParameters());
-        }
-
-        /// <exception cref="SecurityException">Instruction can't be created due to insufficient privileges.</exception>
-        public static CallInstruction Create(MethodInfo info, ParameterInfo[] parameters) {
-            int argumentCount = parameters.Length;
-            if (!info.IsStatic) {
-                argumentCount++;
-            }
-
-            // A workaround for CLR bug #796414 (Unable to create delegates for Array.Get/Set):
-            // T[]::Address - not supported by ETs due to T& return value
-            if (info.DeclaringType != null && info.DeclaringType.IsArray && (info.Name == "Get" || info.Name == "Set")) {
-                return GetArrayAccessor(info, argumentCount);
-            }
-
-#if FULL_AOT_RUNTIME
-            return new MethodInfoCallInstruction(info, argumentCount);
-#else
-            if (ReflectionUtils.IsDynamicMethod(info) || !info.IsStatic && info.DeclaringType.IsValueType()) {
-                return new MethodInfoCallInstruction(info, argumentCount);
-            }
-
-            if (argumentCount >= MaxHelpers) {
-                // no delegate for this size, fallback to reflection invoke
-                return new MethodInfoCallInstruction(info, argumentCount);
-            }
-
-            foreach (ParameterInfo pi in parameters) {
-                if (pi.ParameterType.IsByRef) {
-                    // we don't support ref args via generics.
-                    return new MethodInfoCallInstruction(info, argumentCount);
-                }
-            }
-
-            // see if we've created one w/ a delegate
-            CallInstruction res;
-            if (ShouldCache(info)) {
-                lock (_cache) {
-                    if (_cache.TryGetValue(info, out res)) {
-                        return res;
-                    }
-                }
-            }
-
-            // create it 
-            try {
-                if (argumentCount < MaxArgs) {
-                    res = FastCreate(info, parameters);
-                } else {
-                    res = SlowCreate(info, parameters);
-                }
-            } catch (TargetInvocationException tie) {
-                if (!(tie.InnerException is NotSupportedException)) {
-                    throw tie.InnerException;
-                }
-
-                res = new MethodInfoCallInstruction(info, argumentCount);
-            } catch (NotSupportedException) {
-                // if Delegate.CreateDelegate can't handle the method fallback to 
-                // the slow reflection version.  For example this can happen w/ 
-                // a generic method defined on an interface and implemented on a class or 
-                // a virtual generic method.
-                res = new MethodInfoCallInstruction(info, argumentCount);
-            }
-
-            // cache it for future users if it's a reasonable method to cache
-            if (ShouldCache(info)) {
-                lock (_cache) {
-                    _cache[info] = res;
-                }
-            }
-
-            return res;
-#endif
-        }
-
-        private static CallInstruction GetArrayAccessor(MethodInfo info, int argumentCount) {
-            Type arrayType = info.DeclaringType;
-            bool isGetter = info.Name == "Get";
-            switch (arrayType.GetArrayRank()) {
-                case 1:
-                    return Create(isGetter ?
-                        arrayType.GetMethod("GetValue", new[] { typeof(int)}) :
-                        new Action<Array, int, object>(ArrayItemSetter1).GetMethodInfo()
-                    );
-               
-                case 2: 
-                    return Create(isGetter ? 
-                        arrayType.GetMethod("GetValue", new[] { typeof(int), typeof(int) }) :
-                        new Action<Array, int, int, object>(ArrayItemSetter2).GetMethodInfo()
-                    );
-
-                case 3: 
-                    return Create(isGetter ?
-                        arrayType.GetMethod("GetValue", new[] { typeof(int), typeof(int), typeof(int) }) :
-                        new Action<Array, int, int, int, object>(ArrayItemSetter3).GetMethodInfo()
-                    );
-
-                default: 
-                    return new MethodInfoCallInstruction(info, argumentCount);
-            }
-        }
-
-        public static void ArrayItemSetter1(Array array, int index0, object value) {
-            array.SetValue(value, index0);
-        }
-
-        public static void ArrayItemSetter2(Array array, int index0, int index1, object value) {
-            array.SetValue(value, index0, index1);
-        }
-
-        public static void ArrayItemSetter3(Array array, int index0, int index1, int index2, object value) {
-            array.SetValue(value, index0, index1, index2);
-        }
-
-        private static bool ShouldCache(MethodInfo info) {            
-            return !ReflectionUtils.IsDynamicMethod(info);
-        }
-               
-        /// <summary>
-        /// Gets the next type or null if no more types are available.
-        /// </summary>
-        private static Type TryGetParameterOrReturnType(MethodInfo target, ParameterInfo[] pi, int index) {
-            if (!target.IsStatic) {
-                index--;
-                if (index < 0) {
-                    return target.DeclaringType;
-                }
-            }
-
-            if (index < pi.Length) {
-                // next in signature
-                return pi[index].ParameterType;
-            }
-
-            if (target.ReturnType == typeof(void) || index > pi.Length) {
-                // no more parameters
-                return null;
-            }
-
-            // last parameter on Invoke is return type
-            return target.ReturnType;
-        }
-
-        private static bool IndexIsNotReturnType(int index, MethodInfo target, ParameterInfo[] pi) {
-            return pi.Length != index || (pi.Length == index && !target.IsStatic);
-        }
-
-        /// <summary>
-        /// Uses reflection to create new instance of the appropriate ReflectedCaller
-        /// </summary>
-        private static CallInstruction SlowCreate(MethodInfo info, ParameterInfo[] pis) {
-            List<Type> types = new List<Type>();
-            if (!info.IsStatic) types.Add(info.DeclaringType);
-            foreach (ParameterInfo pi in pis) {
-                types.Add(pi.ParameterType);
-            }
-            if (info.ReturnType != typeof(void)) {
-                types.Add(info.ReturnType);
-            }
-            Type[] arrTypes = types.ToArray();
-
-            return (CallInstruction)Activator.CreateInstance(GetHelperType(info, arrTypes), info);
-        }
-
-        #endregion
-
-        #region Instruction
-
-        public sealed override int ProducedStack { get { return Info.ReturnType == typeof(void) ? 0 : 1; } }
-        public sealed override int ConsumedStack { get { return ArgumentCount; } }
-
-        public sealed override string InstructionName {
-            get { return "Call"; }
-        }
-
-        public override string ToString() {
-            return "Call(" + Info + ")";
-        }
-
-        #endregion
-    }
-
-    internal sealed partial class MethodInfoCallInstruction : CallInstruction {
-        private readonly MethodInfo _target;
-        private readonly int _argumentCount;
-
-        public override MethodInfo Info { get { return _target; } }
-        public override int ArgumentCount { get { return _argumentCount; } }
-
-        internal MethodInfoCallInstruction(MethodInfo target, int argumentCount) {
-            _target = target;
-            _argumentCount = argumentCount;
-        }
-        
-        public override object Invoke(params object[] args) {
-            return InvokeWorker(args);
-        }
-       
-        public override object InvokeInstance(object instance, params object[] args) {
-            if (_target.IsStatic) {
-                try {
-                    return _target.Invoke(null, args);
-                } catch (TargetInvocationException e) {
-                    throw ExceptionHelpers.UpdateForRethrow(e.InnerException);
-                }
-            }
-
-            try {
-                return _target.Invoke(instance, args);
-            } catch (TargetInvocationException e) {
-                throw ExceptionHelpers.UpdateForRethrow(e.InnerException);
-            }
-        }
-
-        private object InvokeWorker(params object[] args) {
-            if (_target.IsStatic) {
-                try {
-                    return _target.Invoke(null, args);
-                } catch (TargetInvocationException e) {
-                    throw ExceptionHelpers.UpdateForRethrow(e.InnerException);
-                }
-            }
-
-            try {
-                return _target.Invoke(args[0], GetNonStaticArgs(args));
-            } catch (TargetInvocationException e) {
-                throw ExceptionHelpers.UpdateForRethrow(e.InnerException);
-            }
-        }
-
-        private static object[] GetNonStaticArgs(object[] args) {
-            object[] newArgs = new object[args.Length - 1];
-            for (int i = 0; i < newArgs.Length; i++) {
-                newArgs[i] = args[i + 1];
-            }
-            return newArgs;
-        }
-
-        public sealed override int Run(InterpretedFrame frame) {
-            int first = frame.StackIndex - _argumentCount;
-            object[] args = new object[_argumentCount];
-            for (int i = 0; i < args.Length; i++) {
-                args[i] = frame.Data[first + i];
-            }
-
-            object ret = Invoke(args);
-            if (_target.ReturnType != typeof(void)) {
-                frame.Data[first] = ret;
-                frame.StackIndex = first + 1;
-            } else {
-                frame.StackIndex = first;
-            }
-            return 1;
-        }
-    }
-    
-}

+ 0 - 50
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ComparisonInstruction.cs

@@ -1,50 +0,0 @@
-// 
-// ArithmeticInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class ComparisonInstruction : ArithmeticInstruction {
-
-        protected bool LiftedToNull { get; set; }
-
-        protected override object Calculate (object l, object r)
-        {
-            if (l == null || r == null)
-                return DoNullComparison (l, r);
-
-            return DoCalculate (l, r);
-        }
-
-        protected abstract object DoNullComparison (object l, object r);
-        protected abstract object DoCalculate (object l, object r);
-    }
-}

+ 0 - 58
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ConstantInstruction.cs

@@ -1,58 +0,0 @@
-// 
-// ConstantInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    sealed class PushValueInstruction : Instruction {
-        object value;
-
-        public override int ConsumedStack { get { return 0; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public PushValueInstruction (object value)
-        {
-            this.value = value;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Push (value);
-            return +1;
-        }
-
-        public override string ToString() {
-            return "Push(" + value + ")";
-        }
-    }
-}

+ 0 - 623
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ControlFlowInstructions.cs

@@ -1,623 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_TASKS
-using System.Threading.Tasks;
-#endif
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Threading;
-using Microsoft.Scripting.Ast;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    using LoopFunc = Func<object[], StrongBox<object>[], InterpretedFrame, int>;
-
-    internal abstract class OffsetInstruction : Instruction {
-        internal const int Unknown = Int32.MinValue;
-        internal const int CacheSize = 32;
-
-        // the offset to jump to (relative to this instruction):
-        protected int _offset = Unknown;
-
-        public int Offset { get { return _offset; } }
-        public abstract Instruction[] Cache { get; }
-
-        public Instruction Fixup(int offset) {
-            Debug.Assert(_offset == Unknown && offset != Unknown);
-            _offset = offset;
-
-            var cache = Cache;
-            if (cache != null && offset >= 0 && offset < cache.Length) {
-                return cache[offset] ?? (cache[offset] = this);
-            }
-
-            return this;
-        }
-
-        public override string ToDebugString(int instructionIndex, object cookie, Func<int, int> labelIndexer, IList<object> objects) {
-            return ToString() + (_offset != Unknown ? " -> " + (instructionIndex + _offset).ToString() : "");
-        }
-
-        public override string ToString() {
-            return InstructionName + (_offset == Unknown ? "(?)" : "(" + _offset + ")");
-        }
-    }
-
-    internal sealed class BranchFalseInstruction : OffsetInstruction {
-        private static Instruction[] _cache;
-
-        public override Instruction[] Cache {
-            get {
-                if (_cache == null) {
-                    _cache = new Instruction[CacheSize];
-                }
-                return _cache;
-            }
-        }
-
-        internal BranchFalseInstruction() {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            Debug.Assert(_offset != Unknown);
-
-            if (!(bool)frame.Pop()) {
-                return _offset;
-            }
-
-            return +1;
-        }
-    }
-
-    internal sealed class BranchTrueInstruction : OffsetInstruction {
-        private static Instruction[] _cache;
-
-        public override Instruction[] Cache {
-            get {
-                if (_cache == null) {
-                    _cache = new Instruction[CacheSize];
-                }
-                return _cache;
-            }
-        }
-
-        internal BranchTrueInstruction() {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            Debug.Assert(_offset != Unknown);
-
-            if ((bool)frame.Pop()) {
-                return _offset;
-            }
-
-            return +1;
-        }
-    }
-
-	internal sealed class BranchNullInstruction : OffsetInstruction {
-		private static Instruction[] _cache;
-
-		public override Instruction[] Cache {
-			get {
-				if (_cache == null) {
-					_cache = new Instruction[CacheSize];
-				}
-				return _cache;
-			}
-		}
-
-		internal BranchNullInstruction() {
-		}
-
-		public override int ConsumedStack { get { return 1; } }
-
-		public override int Run(InterpretedFrame frame) {
-			Debug.Assert(_offset != Unknown);
-
-			if (frame.Pop() == null) {
-				return _offset;
-			}
-
-			return +1;
-		}
-	}
-
-    internal sealed class CoalescingBranchInstruction : OffsetInstruction {
-        private static Instruction[] _cache;
-
-        public override Instruction[] Cache {
-            get {
-                if (_cache == null) {
-                    _cache = new Instruction[CacheSize];
-                }
-                return _cache;
-            }
-        }
-
-        internal CoalescingBranchInstruction() {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            Debug.Assert(_offset != Unknown);
-
-            if (frame.Peek() != null) {
-                return _offset;
-            }
-
-            return +1;
-        }
-    }
-
-    internal class BranchInstruction : OffsetInstruction {
-        private static Instruction[][][] _caches;
-
-        public override Instruction[] Cache {
-            get {
-                if (_caches == null) {
-                    _caches = new Instruction[2][][] { new Instruction[2][], new Instruction[2][] };
-                }
-                return _caches[ConsumedStack][ProducedStack] ?? (_caches[ConsumedStack][ProducedStack] = new Instruction[CacheSize]);
-            }
-        }
-
-        internal readonly bool _hasResult;
-        internal readonly bool _hasValue;
-
-        internal BranchInstruction()
-            : this(false, false) {
-        }
-
-        public BranchInstruction(bool hasResult, bool hasValue) {
-            _hasResult = hasResult;
-            _hasValue = hasValue;
-        }
-
-        public override int ConsumedStack {
-            get { return _hasValue ? 1 : 0; }
-        }
-
-        public override int ProducedStack {
-            get { return _hasResult ? 1 : 0; }
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            Debug.Assert(_offset != Unknown);
-
-            return _offset;
-        }
-    }
-
-    internal abstract class IndexedBranchInstruction : Instruction {
-        protected const int CacheSize = 32;
-
-        internal readonly int _labelIndex;
-
-        public IndexedBranchInstruction(int labelIndex) {
-            _labelIndex = labelIndex;
-        }
-
-        public RuntimeLabel GetLabel(InterpretedFrame frame) {
-            return frame.Interpreter._labels[_labelIndex];
-        }
-
-        public override string ToDebugString(int instructionIndex, object cookie, Func<int, int> labelIndexer, IList<object> objects) {
-            int targetIndex = labelIndexer(_labelIndex);
-            return ToString() + (targetIndex != BranchLabel.UnknownIndex ? " -> " + targetIndex.ToString() : "");
-        }
-
-        public override string ToString() {
-            return InstructionName + "[" + _labelIndex + "]";
-        }
-    }
-
-    /// <summary>
-    /// This instruction implements a goto expression that can jump out of any expression. 
-    /// It pops values (arguments) from the evaluation stack that the expression tree nodes in between 
-    /// the goto expression and the target label node pushed and not consumed yet. 
-    /// A goto expression can jump into a node that evaluates arguments only if it carries 
-    /// a value and jumps right after the first argument (the carried value will be used as the first argument). 
-    /// Goto can jump into an arbitrary child of a BlockExpression since the block doesn’t accumulate values 
-    /// on evaluation stack as its child expressions are being evaluated.
-    /// 
-    /// Goto needs to execute any finally blocks on the way to the target label.
-    /// <example>
-    /// { 
-    ///     f(1, 2, try { g(3, 4, try { goto L } finally { ... }, 6) } finally { ... }, 7, 8)
-    ///     L: ... 
-    /// }
-    /// </example>
-    /// The goto expression here jumps to label L while having 4 items on evaluation stack (1, 2, 3 and 4). 
-    /// The jump needs to execute both finally blocks, the first one on stack level 4 the 
-    /// second one on stack level 2. So, it needs to jump the first finally block, pop 2 items from the stack, 
-    /// run second finally block and pop another 2 items from the stack and set instruction pointer to label L.
-    /// 
-    /// Goto also needs to rethrow ThreadAbortException iff it jumps out of a catch handler and 
-    /// the current thread is in "abort requested" state.
-    /// </summary>
-    internal sealed class GotoInstruction : IndexedBranchInstruction {
-        private const int Variants = 4;
-        private static readonly GotoInstruction[] Cache = new GotoInstruction[Variants * CacheSize];
-
-        private readonly bool _hasResult;
-
-        // TODO: We can remember hasValue in label and look it up when calculating stack balance. That would save some cache.
-        private readonly bool _hasValue;
-
-        // The values should technically be Consumed = 1, Produced = 1 for gotos that target a label whose continuation depth 
-        // is different from the current continuation depth. However, in case of forward gotos, we don't not know that is the 
-        // case until the label is emitted. By then the consumed and produced stack information is useless.
-        // The important thing here is that the stack balance is 0.
-        public override int ConsumedContinuations { get { return 0; } }
-        public override int ProducedContinuations { get { return 0; } }
-
-        public override int ConsumedStack {
-            get { return _hasValue ? 1 : 0; }
-        }
-
-        public override int ProducedStack {
-            get { return _hasResult ? 1 : 0; }
-        }
-
-        private GotoInstruction(int targetIndex, bool hasResult, bool hasValue)
-            : base(targetIndex) {
-            _hasResult = hasResult;
-            _hasValue = hasValue;
-        }
-
-        internal static GotoInstruction Create(int labelIndex, bool hasResult, bool hasValue) {
-            if (labelIndex < CacheSize) {
-                var index = Variants * labelIndex | (hasResult ? 2 : 0) | (hasValue ? 1 : 0);
-                return Cache[index] ?? (Cache[index] = new GotoInstruction(labelIndex, hasResult, hasValue));
-            }
-            return new GotoInstruction(labelIndex, hasResult, hasValue);
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            // Are we jumping out of catch/finally while aborting the current thread?
-            Interpreter.AbortThreadIfRequested(frame, _labelIndex);
-
-            // goto the target label or the current finally continuation:
-            return frame.Goto(_labelIndex, _hasValue ? frame.Pop() : Interpreter.NoValue);
-        }
-    }
-
-    internal sealed class EnterTryFinallyInstruction : IndexedBranchInstruction {
-        private readonly static EnterTryFinallyInstruction[] Cache = new EnterTryFinallyInstruction[CacheSize];
-
-        public override int ProducedContinuations { get { return 1; } }
-
-        private EnterTryFinallyInstruction(int targetIndex)
-            : base(targetIndex) {
-        }
-
-        internal static EnterTryFinallyInstruction Create(int labelIndex) {
-            if (labelIndex < CacheSize) {
-                return Cache[labelIndex] ?? (Cache[labelIndex] = new EnterTryFinallyInstruction(labelIndex));
-            }
-            return new EnterTryFinallyInstruction(labelIndex);
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            // Push finally. 
-            frame.PushContinuation(_labelIndex);
-            return 1;
-        }
-    }
-
-    /// <summary>
-    /// The first instruction of finally block.
-    /// </summary>
-    internal sealed class EnterFinallyInstruction : Instruction {
-        internal static readonly Instruction Instance = new EnterFinallyInstruction();
-
-        public override int ProducedStack { get { return 2; } }
-        public override int ConsumedContinuations { get { return 1; } }
-
-        private EnterFinallyInstruction() {
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.PushPendingContinuation();
-            frame.RemoveContinuation();
-            return 1;
-        }
-    }
-
-    /// <summary>
-    /// The last instruction of finally block.
-    /// </summary>
-    internal sealed class LeaveFinallyInstruction : Instruction {
-        internal static readonly Instruction Instance = new LeaveFinallyInstruction();
-
-        public override int ConsumedStack { get { return 2; } }
-        
-        private LeaveFinallyInstruction() {
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.PopPendingContinuation();
-
-            // jump to goto target or to the next finally:
-            return frame.YieldToPendingContinuation();
-        }
-    }
-
-    // no-op: we need this just to balance the stack depth.
-    internal sealed class EnterExceptionHandlerInstruction : Instruction {
-        internal static readonly EnterExceptionHandlerInstruction Void = new EnterExceptionHandlerInstruction(false);
-        internal static readonly EnterExceptionHandlerInstruction NonVoid = new EnterExceptionHandlerInstruction(true);
-
-        // True if try-expression is non-void.
-        private readonly bool _hasValue;
-
-        private EnterExceptionHandlerInstruction(bool hasValue) {
-            _hasValue = hasValue;
-        }
-
-        // If an exception is throws in try-body the expression result of try-body is not evaluated and loaded to the stack. 
-        // So the stack doesn't contain the try-body's value when we start executing the handler.
-        // However, while emitting instructions try block falls thru the catch block with a value on stack. 
-        // We need to declare it consumed so that the stack state upon entry to the handler corresponds to the real 
-        // stack depth after throw jumped to this catch block.
-        public override int ConsumedStack { get { return _hasValue ? 1 : 0; } }
-
-        // A variable storing the current exception is pushed to the stack by exception handling.
-        // Catch handlers: The value is immediately popped and stored into a local.
-        // Fault handlers: The value is kept on stack during fault handler evaluation.
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            // nop (the exception value is pushed by the interpreter in HandleCatch)
-            return 1;
-        }
-    }
-
-    /// <summary>
-    /// The last instruction of a catch exception handler.
-    /// </summary>
-    internal sealed class LeaveExceptionHandlerInstruction : IndexedBranchInstruction {
-        private static LeaveExceptionHandlerInstruction[] Cache = new LeaveExceptionHandlerInstruction[2 * CacheSize];
-
-        private readonly bool _hasValue;
-
-        // The catch block yields a value if the body is non-void. This value is left on the stack. 
-        public override int ConsumedStack {
-            get { return _hasValue ? 1 : 0; }
-        }
-
-        public override int ProducedStack {
-            get { return _hasValue ? 1 : 0; }
-        }
-
-        private LeaveExceptionHandlerInstruction(int labelIndex, bool hasValue)
-            : base(labelIndex) {
-            _hasValue = hasValue;
-        }
-
-        internal static LeaveExceptionHandlerInstruction Create(int labelIndex, bool hasValue) {
-            if (labelIndex < CacheSize) {
-                int index = (2 * labelIndex) | (hasValue ? 1 : 0);
-                return Cache[index] ?? (Cache[index] = new LeaveExceptionHandlerInstruction(labelIndex, hasValue));
-            }
-            return new LeaveExceptionHandlerInstruction(labelIndex, hasValue);
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            // CLR rethrows ThreadAbortException when leaving catch handler if abort is requested on the current thread.
-            Interpreter.AbortThreadIfRequested(frame, _labelIndex);
-            return GetLabel(frame).Index - frame.InstructionIndex;
-        }
-    }
-
-    /// <summary>
-    /// The last instruction of a fault exception handler.
-    /// </summary>
-    internal sealed class LeaveFaultInstruction : Instruction {
-        internal static readonly Instruction NonVoid = new LeaveFaultInstruction(true);
-        internal static readonly Instruction Void = new LeaveFaultInstruction(false);
-
-        private readonly bool _hasValue;
-
-        // The fault block has a value if the body is non-void, but the value is never used.
-        // We compile the body of a fault block as void.
-        // However, we keep the exception object that was pushed upon entering the fault block on the stack during execution of the block
-        // and pop it at the end.
-        public override int ConsumedStack {
-            get { return 1; }
-        }
-
-        // While emitting instructions a non-void try-fault expression is expected to produce a value. 
-        public override int ProducedStack {
-            get { return _hasValue ? 1 : 0; }
-        }
-
-        private LeaveFaultInstruction(bool hasValue) {
-            _hasValue = hasValue;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            // TODO: ThreadAbortException ?
-
-            object exception = frame.Pop();
-            ExceptionHandler handler;
-            return frame.Interpreter.GotoHandler(frame, exception, out handler);
-        }
-    }
-
-
-    internal sealed class ThrowInstruction : Instruction {
-        internal static readonly ThrowInstruction Throw = new ThrowInstruction(true, false);
-        internal static readonly ThrowInstruction VoidThrow = new ThrowInstruction(false, false);
-        internal static readonly ThrowInstruction Rethrow = new ThrowInstruction(true, true);
-        internal static readonly ThrowInstruction VoidRethrow = new ThrowInstruction(false, true);
-
-        private readonly bool _hasResult, _rethrow;
-
-        private ThrowInstruction(bool hasResult, bool isRethrow) {
-            _hasResult = hasResult;
-            _rethrow = isRethrow;
-        }
-
-        public override int ProducedStack {
-            get { return _hasResult ? 1 : 0; }
-        }
-
-        public override int ConsumedStack {
-            get {
-                return 1; 
-            }
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            var ex = (Exception)frame.Pop();
-            if (_rethrow) {
-                ExceptionHandler handler;
-                return frame.Interpreter.GotoHandler(frame, ex, out handler);
-            }
-            throw ex;
-        }
-    }
-
-    internal sealed class SwitchInstruction : Instruction {
-        private readonly Dictionary<int, int> _cases;
-
-        internal SwitchInstruction(Dictionary<int, int> cases) {
-            Assert.NotNull(cases);
-            _cases = cases;
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 0; } }
-
-        public override int Run(InterpretedFrame frame) {
-            int target;
-            return _cases.TryGetValue((int)frame.Pop(), out target) ? target : 1;
-        }
-    }
-
-    internal sealed class EnterLoopInstruction : Instruction {
-        private readonly int _instructionIndex;
-        private Dictionary<ParameterExpression, LocalVariable> _variables;
-        private Dictionary<ParameterExpression, LocalVariable> _closureVariables;
-        private LoopExpression _loop;
-        private int _loopEnd;
-        private int _compilationThreshold;
-
-        internal EnterLoopInstruction(LoopExpression loop, LocalVariables locals, int compilationThreshold, int instructionIndex) {
-            _loop = loop;
-            _variables = locals.CopyLocals();
-            _closureVariables = locals.ClosureVariables;
-            _compilationThreshold = compilationThreshold;
-            _instructionIndex = instructionIndex;
-        }
-
-        internal void FinishLoop(int loopEnd) {
-            _loopEnd = loopEnd;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            // Don't lock here, it's a frequently hit path.
-            //
-            // There could be multiple threads racing, but that is okay.
-            // Two bad things can happen:
-            //   * We miss decrements (some thread sets the counter forward)
-            //   * We might enter the "if" branch more than once.
-            //
-            // The first is okay, it just means we take longer to compile.
-            // The second we explicitly guard against inside of Compile().
-            // 
-            // We can't miss 0. The first thread that writes -1 must have read 0 and hence start compilation.
-            if (unchecked(_compilationThreshold--) == 0) {
-#if SILVERLIGHT
-                if (PlatformAdaptationLayer.IsCompactFramework) {
-                    _compilationThreshold = Int32.MaxValue;
-                    return 1;
-                }
-#endif
-                if (frame.Interpreter.CompileSynchronously) {
-                    Compile(frame);
-                } else {
-                    // Kick off the compile on another thread so this one can keep going,
-                    // Compile method backpatches the instruction when finished so we don't need to await the task.
-#if FEATURE_TASKS
-                    new Task(Compile, frame).Start();
-#else
-                    ThreadPool.QueueUserWorkItem(Compile, frame);
-#endif
-                }
-            }
-            return 1;
-        }
-
-        private bool Compiled {
-            get { return _loop == null; }
-        }
-
-        private void Compile(object frameObj) {
-            if (Compiled) {
-                return;
-            }
-
-            lock (this) {
-                if (Compiled) {
-                    return;
-                }
-
-                PerfTrack.NoteEvent(PerfTrack.Categories.Compiler, "Interpreted loop compiled");
-
-                InterpretedFrame frame = (InterpretedFrame)frameObj;
-                var compiler = new LoopCompiler(_loop, frame.Interpreter.LabelMapping, _variables, _closureVariables, _instructionIndex, _loopEnd);
-                var instructions = frame.Interpreter.Instructions.Instructions;
-
-                // replace this instruction with an optimized one:
-                Interlocked.Exchange(ref instructions[_instructionIndex], new CompiledLoopInstruction(compiler.CreateDelegate()));
-
-                // invalidate this instruction, some threads may still hold on it:
-                _loop = null;
-                _variables = null;
-                _closureVariables = null;
-            }
-        }
-    }
-
-    internal sealed class CompiledLoopInstruction : Instruction {
-        private readonly LoopFunc _compiledLoop;
-
-        public CompiledLoopInstruction(LoopFunc compiledLoop) {
-            Assert.NotNull(compiledLoop);
-            _compiledLoop = compiledLoop;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            return _compiledLoop(frame.Data, frame.Closure, frame);
-        }
-    }
-}

+ 0 - 132
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DivInstruction.cs

@@ -1,132 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class DivInstruction : Instruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        public override int ConsumedStack { get { return 2; } }
-        public override int ProducedStack { get { return 1; } }
-
-        private DivInstruction() {
-        }
-
-        internal sealed class DivInt32 : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = ScriptingRuntimeHelpers.Int32ToObject((Int32)l / (Int32)r);
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        internal sealed class DivInt16 : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = (Int16)((Int16)l / (Int16)r);
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        internal sealed class DivInt64 : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = (Int64)((Int64)l / (Int64)r);
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        internal sealed class DivUInt16 : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = (UInt16)((UInt16)l / (UInt16)r);
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        internal sealed class DivUInt32 : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = (UInt32)((UInt32)l / (UInt32)r);
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        internal sealed class DivUInt64 : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = (UInt64)((UInt64)l / (UInt64)r);
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        internal sealed class DivSingle : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = (Single)((Single)l / (Single)r);
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        internal sealed class DivDouble : DivInstruction {
-            public override int Run(InterpretedFrame frame) {
-                object l = frame.Data[frame.StackIndex - 2];
-                object r = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 2] = (Double)l / (Double)r;
-                frame.StackIndex--;
-                return 1;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new DivInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new DivInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new DivInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new DivUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new DivUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new DivUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new DivSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new DivDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Div()";
-        }
-    }
-}

+ 0 - 76
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructionN.cs

@@ -1,76 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using System.Runtime.CompilerServices;
-using System.Reflection;
-
-using Microsoft.Scripting.Utils;
-using System.Security;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal sealed partial class DynamicInstructionN : Instruction {
-        private readonly CallInstruction _targetInvocationInstruction;
-        private readonly object _targetDelegate;
-        private readonly CallSite _site;
-        private readonly int _argumentCount;
-        private readonly bool _isVoid;
-
-        public DynamicInstructionN(Type delegateType, CallSite site) {
-            var methodInfo = delegateType.GetMethod("Invoke");
-            var parameters = methodInfo.GetParameters();
-
-            // <Delegate>.Invoke is ok to target by a delegate in partial trust (SecurityException is not thrown):
-            _targetInvocationInstruction = CallInstruction.Create(methodInfo, parameters);
-            _site = site;
-            _argumentCount = parameters.Length - 1;
-            _targetDelegate = site.GetType().GetInheritedFields("Target").First().GetValue(site);
-        }
-
-        public DynamicInstructionN(Type delegateType, CallSite site, bool isVoid)
-            : this(delegateType, site) {
-            _isVoid = isVoid;
-        }
-
-        public override int ProducedStack { get { return _isVoid ? 0 : 1; } }
-        public override int ConsumedStack { get { return _argumentCount; } }
-
-        public override int Run(InterpretedFrame frame) {
-            int first = frame.StackIndex - _argumentCount;
-            object[] args = new object[1 + _argumentCount];
-            args[0] = _site;
-            for (int i = 0; i < _argumentCount; i++) {
-                args[1 + i] = frame.Data[first + i];
-            }
-
-            object ret = _targetInvocationInstruction.InvokeInstance(_targetDelegate, args);
-            if (_isVoid) {
-                frame.StackIndex = first;
-            } else {
-                frame.Data[first] = ret;
-                frame.StackIndex = first + 1;
-            }
-
-            return 1;
-        }
-
-        public override string ToString() {
-            return "DynamicInstructionN(" + _site + ")";
-        }
-    }
-}

+ 0 - 509
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructions.Generated.cs

@@ -1,509 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-
-using System;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal partial class DynamicInstructionN {
-        internal static Type GetDynamicInstructionType(Type delegateType) {
-            Type[] argTypes = delegateType.GetGenericArguments();
-            if (argTypes.Length == 0) return null;
-            Type genericType;
-            Type[] newArgTypes = ArrayUtils.RemoveFirst(argTypes);
-            switch (newArgTypes.Length) {
-                #region Generated Dynamic Instruction Types
-
-                // *** BEGIN GENERATED CODE ***
-                // generated by function: gen_types from: generate_dynamic_instructions.py
-
-                case 1: genericType = typeof(DynamicInstruction<>); break;
-                case 2: genericType = typeof(DynamicInstruction<,>); break;
-                case 3: genericType = typeof(DynamicInstruction<,,>); break;
-                case 4: genericType = typeof(DynamicInstruction<,,,>); break;
-                case 5: genericType = typeof(DynamicInstruction<,,,,>); break;
-                case 6: genericType = typeof(DynamicInstruction<,,,,,>); break;
-                case 7: genericType = typeof(DynamicInstruction<,,,,,,>); break;
-                case 8: genericType = typeof(DynamicInstruction<,,,,,,,>); break;
-                case 9: genericType = typeof(DynamicInstruction<,,,,,,,,>); break;
-                case 10: genericType = typeof(DynamicInstruction<,,,,,,,,,>); break;
-                case 11: genericType = typeof(DynamicInstruction<,,,,,,,,,,>); break;
-                case 12: genericType = typeof(DynamicInstruction<,,,,,,,,,,,>); break;
-                case 13: genericType = typeof(DynamicInstruction<,,,,,,,,,,,,>); break;
-                case 14: genericType = typeof(DynamicInstruction<,,,,,,,,,,,,,>); break;
-                case 15: genericType = typeof(DynamicInstruction<,,,,,,,,,,,,,,>); break;
-                case 16: genericType = typeof(DynamicInstruction<,,,,,,,,,,,,,,,>); break;
-
-                // *** END GENERATED CODE ***
-
-                #endregion
-                default:
-                    throw Assert.Unreachable;
-            }
-            
-            return genericType.MakeGenericType(newArgTypes);
-        }
-
-        internal static Instruction CreateUntypedInstruction(CallSiteBinder binder, int argCount) {
-            // DLR Ref.Emits an UpdateAndExecute delegate for sites with more than 10 parameters
-            if (argCount > 10 && PlatformAdaptationLayer.IsCompactFramework) {
-                return null;
-            }
-            
-            switch (argCount) {
-                #region Generated Untyped Dynamic Instructions
-
-                // *** BEGIN GENERATED CODE ***
-                // generated by function: gen_untyped from: generate_dynamic_instructions.py
-
-                case 0: return DynamicInstruction<object>.Factory(binder);
-                case 1: return DynamicInstruction<object, object>.Factory(binder);
-                case 2: return DynamicInstruction<object, object, object>.Factory(binder);
-                case 3: return DynamicInstruction<object, object, object, object>.Factory(binder);
-                case 4: return DynamicInstruction<object, object, object, object, object>.Factory(binder);
-                case 5: return DynamicInstruction<object, object, object, object, object, object>.Factory(binder);
-                case 6: return DynamicInstruction<object, object, object, object, object, object, object>.Factory(binder);
-                case 7: return DynamicInstruction<object, object, object, object, object, object, object, object>.Factory(binder);
-                case 8: return DynamicInstruction<object, object, object, object, object, object, object, object, object>.Factory(binder);
-                case 9: return DynamicInstruction<object, object, object, object, object, object, object, object, object, object>.Factory(binder);
-                case 10: return DynamicInstruction<object, object, object, object, object, object, object, object, object, object, object>.Factory(binder);
-                case 11: return DynamicInstruction<object, object, object, object, object, object, object, object, object, object, object, object>.Factory(binder);
-                case 12: return DynamicInstruction<object, object, object, object, object, object, object, object, object, object, object, object, object>.Factory(binder);
-                case 13: return DynamicInstruction<object, object, object, object, object, object, object, object, object, object, object, object, object, object>.Factory(binder);
-                case 14: return DynamicInstruction<object, object, object, object, object, object, object, object, object, object, object, object, object, object, object>.Factory(binder);
-                case 15: return DynamicInstruction<object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object>.Factory(binder);
-
-                // *** END GENERATED CODE ***
-
-                #endregion
-                
-                default: return null;
-            }
-        }
-    }
-
-    #region Generated Dynamic Instructions
-
-    // *** BEGIN GENERATED CODE ***
-    // generated by function: gen_instructions from: generate_dynamic_instructions.py
-
-    internal class DynamicInstruction<TRet> : Instruction {
-        private CallSite<Func<CallSite,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<TRet>(CallSite<Func<CallSite,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 0; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 0] = _site.Target(_site);
-            frame.StackIndex -= -1;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,TRet>(CallSite<Func<CallSite,T0,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 1] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 1]);
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,TRet>(CallSite<Func<CallSite,T0,T1,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 2; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 2] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 2], (T1)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 1;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,TRet>(CallSite<Func<CallSite,T0,T1,T2,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 3; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 3] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 3], (T1)frame.Data[frame.StackIndex - 2], (T2)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 2;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 4; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 4] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 4], (T1)frame.Data[frame.StackIndex - 3], (T2)frame.Data[frame.StackIndex - 2], (T3)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 3;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 5; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 5] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 5], (T1)frame.Data[frame.StackIndex - 4], (T2)frame.Data[frame.StackIndex - 3], (T3)frame.Data[frame.StackIndex - 2], (T4)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 4;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 6; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 6] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 6], (T1)frame.Data[frame.StackIndex - 5], (T2)frame.Data[frame.StackIndex - 4], (T3)frame.Data[frame.StackIndex - 3], (T4)frame.Data[frame.StackIndex - 2], (T5)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 5;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 7; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 7] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 7], (T1)frame.Data[frame.StackIndex - 6], (T2)frame.Data[frame.StackIndex - 5], (T3)frame.Data[frame.StackIndex - 4], (T4)frame.Data[frame.StackIndex - 3], (T5)frame.Data[frame.StackIndex - 2], (T6)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 6;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 8; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 8] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 8], (T1)frame.Data[frame.StackIndex - 7], (T2)frame.Data[frame.StackIndex - 6], (T3)frame.Data[frame.StackIndex - 5], (T4)frame.Data[frame.StackIndex - 4], (T5)frame.Data[frame.StackIndex - 3], (T6)frame.Data[frame.StackIndex - 2], (T7)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 7;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 9; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 9] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 9], (T1)frame.Data[frame.StackIndex - 8], (T2)frame.Data[frame.StackIndex - 7], (T3)frame.Data[frame.StackIndex - 6], (T4)frame.Data[frame.StackIndex - 5], (T5)frame.Data[frame.StackIndex - 4], (T6)frame.Data[frame.StackIndex - 3], (T7)frame.Data[frame.StackIndex - 2], (T8)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 8;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 10; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 10] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 10], (T1)frame.Data[frame.StackIndex - 9], (T2)frame.Data[frame.StackIndex - 8], (T3)frame.Data[frame.StackIndex - 7], (T4)frame.Data[frame.StackIndex - 6], (T5)frame.Data[frame.StackIndex - 5], (T6)frame.Data[frame.StackIndex - 4], (T7)frame.Data[frame.StackIndex - 3], (T8)frame.Data[frame.StackIndex - 2], (T9)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 9;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 11; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 11] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 11], (T1)frame.Data[frame.StackIndex - 10], (T2)frame.Data[frame.StackIndex - 9], (T3)frame.Data[frame.StackIndex - 8], (T4)frame.Data[frame.StackIndex - 7], (T5)frame.Data[frame.StackIndex - 6], (T6)frame.Data[frame.StackIndex - 5], (T7)frame.Data[frame.StackIndex - 4], (T8)frame.Data[frame.StackIndex - 3], (T9)frame.Data[frame.StackIndex - 2], (T10)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 10;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 12; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 12] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 12], (T1)frame.Data[frame.StackIndex - 11], (T2)frame.Data[frame.StackIndex - 10], (T3)frame.Data[frame.StackIndex - 9], (T4)frame.Data[frame.StackIndex - 8], (T5)frame.Data[frame.StackIndex - 7], (T6)frame.Data[frame.StackIndex - 6], (T7)frame.Data[frame.StackIndex - 5], (T8)frame.Data[frame.StackIndex - 4], (T9)frame.Data[frame.StackIndex - 3], (T10)frame.Data[frame.StackIndex - 2], (T11)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 11;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 13; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 13] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 13], (T1)frame.Data[frame.StackIndex - 12], (T2)frame.Data[frame.StackIndex - 11], (T3)frame.Data[frame.StackIndex - 10], (T4)frame.Data[frame.StackIndex - 9], (T5)frame.Data[frame.StackIndex - 8], (T6)frame.Data[frame.StackIndex - 7], (T7)frame.Data[frame.StackIndex - 6], (T8)frame.Data[frame.StackIndex - 5], (T9)frame.Data[frame.StackIndex - 4], (T10)frame.Data[frame.StackIndex - 3], (T11)frame.Data[frame.StackIndex - 2], (T12)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 12;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 14; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 14] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 14], (T1)frame.Data[frame.StackIndex - 13], (T2)frame.Data[frame.StackIndex - 12], (T3)frame.Data[frame.StackIndex - 11], (T4)frame.Data[frame.StackIndex - 10], (T5)frame.Data[frame.StackIndex - 9], (T6)frame.Data[frame.StackIndex - 8], (T7)frame.Data[frame.StackIndex - 7], (T8)frame.Data[frame.StackIndex - 6], (T9)frame.Data[frame.StackIndex - 5], (T10)frame.Data[frame.StackIndex - 4], (T11)frame.Data[frame.StackIndex - 3], (T12)frame.Data[frame.StackIndex - 2], (T13)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 13;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-    internal class DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet> : Instruction {
-        private CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>> _site;
-
-        public static Instruction Factory(CallSiteBinder binder) {
-            return new DynamicInstruction<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>>.Create(binder));
-        }
-
-        private DynamicInstruction(CallSite<Func<CallSite,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>> site) {
-            _site = site;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return 15; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex - 15] = _site.Target(_site, (T0)frame.Data[frame.StackIndex - 15], (T1)frame.Data[frame.StackIndex - 14], (T2)frame.Data[frame.StackIndex - 13], (T3)frame.Data[frame.StackIndex - 12], (T4)frame.Data[frame.StackIndex - 11], (T5)frame.Data[frame.StackIndex - 10], (T6)frame.Data[frame.StackIndex - 9], (T7)frame.Data[frame.StackIndex - 8], (T8)frame.Data[frame.StackIndex - 7], (T9)frame.Data[frame.StackIndex - 6], (T10)frame.Data[frame.StackIndex - 5], (T11)frame.Data[frame.StackIndex - 4], (T12)frame.Data[frame.StackIndex - 3], (T13)frame.Data[frame.StackIndex - 2], (T14)frame.Data[frame.StackIndex - 1]);
-            frame.StackIndex -= 14;
-            return 1;
-        }
-
-        public override string ToString() {
-            return "Dynamic(" + _site.Binder.ToString() + ")";
-        }
-    }
-
-
-    // *** END GENERATED CODE ***
-
-    #endregion
-
-
-}

+ 0 - 55
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicSplatInstruction.cs

@@ -1,55 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-
-using System;
-using System.Collections.Generic;
-using System.Runtime.CompilerServices;
-using System.Reflection;
-
-using Microsoft.Scripting.Utils;
-using Microsoft.Scripting.Ast;
-using Microsoft.Scripting.Runtime;
-
-namespace Microsoft.Scripting.Interpreter {
-    /// <summary>
-    /// Implements dynamic call site with many arguments. Wraps the arguments into <see cref="ArgumentArray"/>.
-    /// </summary>
-    internal sealed partial class DynamicSplatInstruction : Instruction {
-        private readonly CallSite<Func<CallSite, ArgumentArray, object>> _site;
-        private readonly int _argumentCount;
-
-        internal DynamicSplatInstruction(int argumentCount, CallSite<Func<CallSite, ArgumentArray, object>> site) {
-            _site = site;
-            _argumentCount = argumentCount;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return _argumentCount; } }
-
-        public override int Run(InterpretedFrame frame) {
-            int first = frame.StackIndex - _argumentCount;
-            object ret = _site.Target(_site, new ArgumentArray(frame.Data, first, _argumentCount));
-            frame.Data[first] = ret;
-            frame.StackIndex = first + 1;
-
-            return 1;
-        }
-
-        public override string ToString() {
-            return "DynamicSplatInstruction(" + _site + ")";
-        }
-    }
-}

+ 0 - 201
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs

@@ -1,201 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class EqualInstruction : ComparisonInstruction {
-        // Perf: EqualityComparer<T> but is 3/2 to 2 times slower.
-        private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _String, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
-        private static Instruction _BooleanLifted, _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted,
-            _ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
-
-        private EqualInstruction() {
-        }
-
-        protected override object DoNullComparison (object l, object r)
-        {
-            return LiftedToNull ? (object) null : (object) l == r;
-        }
-
-        internal sealed class EqualBoolean : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Boolean)l == (Boolean)r;
-            }
-        }
-
-        internal sealed class EqualSByte : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (SByte)l == (SByte)r;
-            }
-        }
-
-        internal sealed class EqualInt16 : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int16)l == (Int16)r;
-            }
-        }
-
-        internal sealed class EqualChar : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Char)l == (Char)r;
-            }
-        }
-
-        internal sealed class EqualString : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (String)l == (String)r;
-            }
-        }
-
-        internal sealed class EqualInt32 : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int32)l == (Int32)r;
-            }
-        }
-
-        internal sealed class EqualInt64 : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int64)l == (Int64)r;
-            }
-        }
-
-        internal sealed class EqualByte : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Byte)l == (Byte)r;
-            }
-        }
-
-        internal sealed class EqualUInt16 : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt16)l == (UInt16)r;
-            }
-        }
-
-        internal sealed class EqualUInt32 : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt32)l == (UInt32)r;
-            }
-        }
-
-        internal sealed class EqualUInt64 : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt64)l == (UInt64)r;
-            }
-        }
-
-        internal sealed class EqualSingle : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Single)l == (Single)r;
-            }
-        }
-
-        internal sealed class EqualDouble : EqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Double)l == (Double)r;
-            }
-        }
-
-        internal sealed class EqualReference : EqualInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return l == r;
-            }
-
-            protected override object DoCalculate (object l, object r)
-            {
-                throw Assert.Unreachable;
-            }
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
-        public static Instruction Create(Type type) {
-            // Boxed enums can be unboxed as their underlying types:
-            switch ((type.IsEnum() ? Enum.GetUnderlyingType(type) : type).GetTypeCode()) {
-                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new EqualBoolean());
-                case TypeCode.SByte: return _SByte ?? (_SByte = new EqualSByte());
-                case TypeCode.Byte: return _Byte ?? (_Byte = new EqualByte());
-                case TypeCode.Char: return _Char ?? (_Char = new EqualChar());
-                case TypeCode.String: return _String ?? (_String = new EqualString());
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new EqualInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new EqualInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new EqualInt64());
-
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new EqualInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new EqualInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new EqualInt64());
-
-                case TypeCode.Single: return _Single ?? (_Single = new EqualSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new EqualDouble());
-
-                case TypeCode.Object:
-                    if (!type.IsValueType()) {
-                        return _Reference ?? (_Reference = new EqualReference());
-                    }
-                    // TODO: Nullable<T>
-                    throw new NotImplementedException();
-
-                default:
-                    throw new NotImplementedException();
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            // Boxed enums can be unboxed as their underlying types:
-            switch ((type.IsEnum() ? Enum.GetUnderlyingType(type) : type).GetTypeCode()) {
-                case TypeCode.Boolean: return _BooleanLifted ?? (_BooleanLifted = new EqualBoolean() { LiftedToNull = true });
-                case TypeCode.SByte: return _SByteLifted ?? (_SByteLifted = new EqualSByte() { LiftedToNull = true });
-                case TypeCode.Byte: return _ByteLifted ?? (_ByteLifted = new EqualByte() { LiftedToNull = true });
-                case TypeCode.Char: return _CharLifted ?? (_CharLifted = new EqualChar() { LiftedToNull = true });
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new EqualInt16() { LiftedToNull = true });
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new EqualInt32() { LiftedToNull = true });
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new EqualInt64() { LiftedToNull = true });
-
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new EqualInt16() { LiftedToNull = true });
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new EqualInt32() { LiftedToNull = true });
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new EqualInt64() { LiftedToNull = true });
-
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new EqualSingle() { LiftedToNull = true });
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new EqualDouble() { LiftedToNull = true });
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Equal()";
-        }
-    }
-}

+ 0 - 94
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/FieldOperations.cs

@@ -1,94 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal sealed class LoadStaticFieldInstruction : Instruction {
-        private readonly FieldInfo _field;
-
-        public LoadStaticFieldInstruction(FieldInfo field) {
-            Debug.Assert(field.IsStatic);
-            _field = field;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Push(_field.GetValue(null));
-            return +1;
-        }
-    }
-
-    internal sealed class LoadFieldInstruction : Instruction {
-        private readonly FieldInfo _field;
-
-        public LoadFieldInstruction(FieldInfo field) {
-            Assert.NotNull(field);
-            _field = field;
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Push(_field.GetValue(frame.Pop()));
-            return +1;
-        }
-    }
-
-    internal sealed class StoreFieldInstruction : Instruction {
-        private readonly FieldInfo _field;
-
-        public StoreFieldInstruction(FieldInfo field) {
-            Assert.NotNull(field);
-            _field = field;
-        }
-
-        public override int ConsumedStack { get { return 2; } }
-        public override int ProducedStack { get { return 0; } }
-
-        public override int Run(InterpretedFrame frame) {
-            object value = frame.Pop();
-            object self = frame.Pop();
-            _field.SetValue(self, value);
-            return +1;
-        }
-    }
-
-    internal sealed class StoreStaticFieldInstruction : Instruction {
-        private readonly FieldInfo _field;
-
-        public StoreStaticFieldInstruction(FieldInfo field) {
-            Assert.NotNull(field);
-            _field = field;
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 0; } }
-
-        public override int Run(InterpretedFrame frame) {
-            object value = frame.Pop();
-            _field.SetValue(null, value);
-            return +1;
-        }
-    }
-}

+ 0 - 171
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs

@@ -1,171 +0,0 @@
-// 
-// GreaterThanInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    abstract class GreaterThanInstruction : ComparisonInstruction {
-        private static Instruction _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
-        private static Instruction _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted, _ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
-
-        private GreaterThanInstruction() {
-        }
-
-        protected override object DoNullComparison (object l, object r)
-        {
-            return LiftedToNull ? (object) null : (object) false;
-        }
-
-        internal sealed class GreaterThanSByte : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (SByte)l > (SByte)r;
-            }
-        }
-
-        internal sealed class GreaterThanInt16 : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int16)l > (Int16)r;
-            }
-        }
-
-        internal sealed class GreaterThanChar : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Char)l > (Char)r;
-            }
-        }
-
-        internal sealed class GreaterThanInt32 : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int32)l > (Int32)r;
-            }
-        }
-
-        internal sealed class GreaterThanInt64 : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int64)l > (Int64)r;
-            }
-        }
-
-        internal sealed class GreaterThanByte : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Byte)l > (Byte)r;
-            }
-        }
-
-        internal sealed class GreaterThanUInt16 : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt16)l > (UInt16)r;
-            }
-        }
-
-        internal sealed class GreaterThanUInt32 : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt32)l > (UInt32)r;
-            }
-        }
-
-        internal sealed class GreaterThanUInt64 : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt64)l > (UInt64)r;
-            }
-        }
-
-        internal sealed class GreaterThanSingle : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Single)l > (Single)r;
-            }
-        }
-
-        internal sealed class GreaterThanDouble : GreaterThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Double)l > (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByte ?? (_SByte = new GreaterThanSByte());
-                case TypeCode.Byte: return _Byte ?? (_Byte = new GreaterThanByte());
-                case TypeCode.Char: return _Char ?? (_Char = new GreaterThanChar());
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new GreaterThanInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new GreaterThanInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new GreaterThanInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new GreaterThanUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new GreaterThanUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new GreaterThanUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new GreaterThanSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new GreaterThanDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByteLifted ?? (_SByteLifted = new GreaterThanSByte() { LiftedToNull = true });
-                case TypeCode.Byte: return _ByteLifted ?? (_ByteLifted = new GreaterThanByte() { LiftedToNull = true });
-                case TypeCode.Char: return _CharLifted ?? (_CharLifted = new GreaterThanChar() { LiftedToNull = true });
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new GreaterThanInt16() { LiftedToNull = true });
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new GreaterThanInt32() { LiftedToNull = true });
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new GreaterThanInt64() { LiftedToNull = true });
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new GreaterThanUInt16() { LiftedToNull = true });
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new GreaterThanUInt32() { LiftedToNull = true });
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new GreaterThanUInt64() { LiftedToNull = true });
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new GreaterThanSingle() { LiftedToNull = true });
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new GreaterThanDouble() { LiftedToNull = true });
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "GreaterThan()";
-        }
-    }
-}

+ 0 - 171
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs

@@ -1,171 +0,0 @@
-// 
-// GreaterThanOrEqualInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    abstract class GreaterThanOrEqualInstruction : ComparisonInstruction {
-        private static Instruction _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
-        private static Instruction _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted, _ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
-
-        private GreaterThanOrEqualInstruction() {
-        }
-
-        protected override object DoNullComparison (object l, object r)
-        {
-            return LiftedToNull ? (object) null : (object) false;
-        }
-
-        internal sealed class GreaterThanOrEqualSByte : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (SByte)l >= (SByte)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualInt16 : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int16)l >= (Int16)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualChar : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Char)l >= (Char)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualInt32 : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int32)l >= (Int32)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualInt64 : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int64)l >= (Int64)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualByte : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Byte)l >= (Byte)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualUInt16 : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt16)l >= (UInt16)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualUInt32 : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt32)l >= (UInt32)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualUInt64 : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt64)l >= (UInt64)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualSingle : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Single)l >= (Single)r;
-            }
-        }
-
-        internal sealed class GreaterThanOrEqualDouble : GreaterThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Double)l >= (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByte ?? (_SByte = new GreaterThanOrEqualSByte());
-                case TypeCode.Byte: return _Byte ?? (_Byte = new GreaterThanOrEqualByte());
-                case TypeCode.Char: return _Char ?? (_Char = new GreaterThanOrEqualChar());
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new GreaterThanOrEqualInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new GreaterThanOrEqualInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new GreaterThanOrEqualInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new GreaterThanOrEqualUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new GreaterThanOrEqualUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new GreaterThanOrEqualUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new GreaterThanOrEqualSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new GreaterThanOrEqualDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByteLifted ?? (_SByteLifted = new GreaterThanOrEqualSByte() { LiftedToNull = true });
-                case TypeCode.Byte: return _ByteLifted ?? (_ByteLifted = new GreaterThanOrEqualByte() { LiftedToNull = true });
-                case TypeCode.Char: return _CharLifted ?? (_CharLifted = new GreaterThanOrEqualChar() { LiftedToNull = true });
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new GreaterThanOrEqualInt16() { LiftedToNull = true });
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new GreaterThanOrEqualInt32() { LiftedToNull = true });
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new GreaterThanOrEqualInt64() { LiftedToNull = true });
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new GreaterThanOrEqualUInt16() { LiftedToNull = true });
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new GreaterThanOrEqualUInt32() { LiftedToNull = true });
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new GreaterThanOrEqualUInt64() { LiftedToNull = true });
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new GreaterThanOrEqualSingle() { LiftedToNull = true });
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new GreaterThanOrEqualDouble() { LiftedToNull = true });
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "GreaterThanOrEqual()";
-        }
-    }
-}

+ 0 - 61
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/Instruction.cs

@@ -1,61 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    public interface IInstructionProvider {
-        void AddInstructions(LightCompiler compiler);
-    }
-
-    public abstract partial class Instruction {
-        public virtual int ConsumedStack { get { return 0; } }
-        public virtual int ProducedStack { get { return 0; } }
-        public virtual int ConsumedContinuations { get { return 0; } }
-        public virtual int ProducedContinuations { get { return 0; } }
-
-        public int StackBalance {
-            get { return ProducedStack - ConsumedStack; }
-        }
-
-        public int ContinuationsBalance {
-            get { return ProducedContinuations - ConsumedContinuations; }
-        }
-
-        public abstract int Run(InterpretedFrame frame);
-
-        public virtual string InstructionName {
-            get { return GetType().Name.Replace("Instruction", ""); }
-        }
-
-        public override string ToString() {
-            return InstructionName + "()";
-        }
-
-        public virtual string ToDebugString(int instructionIndex, object cookie, Func<int, int> labelIndexer, IList<object> objects) {
-            return ToString();
-        }
-
-        public virtual object GetDebugCookie(LightCompiler compiler) {
-            return null;
-        }
-    }
-}

+ 0 - 123
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs

@@ -1,123 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_NUMERICS
-using BigInt = System.Numerics.BigInteger;
-#endif
-
-using System;
-using System.Collections.Generic;
-
-using Microsoft.Scripting.Math;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    public abstract class InstructionFactory {
-        // TODO: weak table for types in a collectible assembly?
-        private static Dictionary<Type, InstructionFactory> _factories;
-
-        internal static InstructionFactory GetFactory(Type type) {
-            if (_factories == null) {
-                _factories = new Dictionary<Type, InstructionFactory>() {
-                    { typeof(object), InstructionFactory<object>.Factory },
-                    { typeof(bool), InstructionFactory<bool>.Factory },
-                    { typeof(byte), InstructionFactory<byte>.Factory },
-                    { typeof(sbyte), InstructionFactory<sbyte>.Factory },
-                    { typeof(short), InstructionFactory<short>.Factory },
-                    { typeof(ushort), InstructionFactory<ushort>.Factory },
-                    { typeof(int), InstructionFactory<int>.Factory },
-                    { typeof(uint), InstructionFactory<uint>.Factory },
-                    { typeof(long), InstructionFactory<long>.Factory },
-                    { typeof(ulong), InstructionFactory<ulong>.Factory },
-                    { typeof(float), InstructionFactory<float>.Factory },
-                    { typeof(double), InstructionFactory<double>.Factory },
-                    { typeof(char), InstructionFactory<char>.Factory },
-                    { typeof(string), InstructionFactory<string>.Factory },
-#if FEATURE_NUMERICS
-                    { typeof(BigInt), InstructionFactory<BigInt>.Factory },
-#endif
-#if !MONO_INTERPRETER
-                    { typeof(BigInteger), InstructionFactory<BigInteger>.Factory }  
-#endif
-                };
-            }
-
-            lock (_factories) {
-                InstructionFactory factory;
-                if (!_factories.TryGetValue(type, out factory)) {
-                    factory = (InstructionFactory)typeof(InstructionFactory<>).MakeGenericType(type).GetDeclaredField("Factory").GetValue(null);
-                    _factories[type] = factory;
-                }
-                return factory;
-            }
-        }
-
-        internal protected abstract Instruction GetArrayItem();
-        internal protected abstract Instruction SetArrayItem();
-        internal protected abstract Instruction TypeIs();
-        internal protected abstract Instruction TypeAs();
-        internal protected abstract Instruction DefaultValue();
-        internal protected abstract Instruction NewArray();
-        internal protected abstract Instruction NewArrayInit(int elementCount);
-        internal protected abstract Instruction WrapToNullable(Type elementType);
-    }
-
-    public sealed class InstructionFactory<T> : InstructionFactory {
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
-        public static readonly InstructionFactory Factory = new InstructionFactory<T>();
-
-        private Instruction _getArrayItem;
-        private Instruction _setArrayItem;
-        private Instruction _typeIs;
-        private Instruction _defaultValue;
-        private Instruction _newArray;
-        private Instruction _typeAs;
-        private Instruction _nullableWrap;
-
-        private InstructionFactory() { }
-
-        internal protected override Instruction GetArrayItem() {
-            return _getArrayItem ?? (_getArrayItem = new GetArrayItemInstruction<T>());
-        }
-
-        internal protected override Instruction SetArrayItem() {
-            return _setArrayItem ?? (_setArrayItem = new SetArrayItemInstruction<T>());
-        }
-
-        internal protected override Instruction TypeIs() {
-            return _typeIs ?? (_typeIs = new TypeIsInstruction<T>());
-        }
-
-        internal protected override Instruction TypeAs() {
-            return _typeAs ?? (_typeAs = new TypeAsInstruction<T>());
-        }
-
-        internal protected override Instruction DefaultValue() {
-            return _defaultValue ?? (_defaultValue = new DefaultValueInstruction<T>());
-        }
-
-        internal protected override Instruction NewArray() {
-            return _newArray ?? (_newArray = new NewArrayInstruction<T>());
-        }
-
-        internal protected override Instruction NewArrayInit(int elementCount) {
-            return new NewArrayInitInstruction<T>(elementCount);
-        }
-
-        internal protected override Instruction WrapToNullable(Type elementType) {
-            return _nullableWrap ?? (_nullableWrap = new WrapToNullableInstruction<T>(elementType));
-        }        
-    }
-}

+ 0 - 1074
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs

@@ -1,1074 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-// Enables instruction counting and displaying stats at process exit.
-// #define STATS
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Security;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
-    [DebuggerTypeProxy(typeof(InstructionArray.DebugView))]
-    public struct InstructionArray {
-        internal readonly int MaxStackDepth;
-        internal readonly int MaxContinuationDepth;
-        internal readonly Instruction[] Instructions;
-        internal readonly object[] Objects;
-        internal readonly RuntimeLabel[] Labels;
-
-        // list of (instruction index, cookie) sorted by instruction index:
-        internal readonly List<KeyValuePair<int, object>> DebugCookies;
-
-        internal InstructionArray(int maxStackDepth, int maxContinuationDepth, Instruction[] instructions, 
-            object[] objects, RuntimeLabel[] labels, List<KeyValuePair<int, object>> debugCookies) {
-
-            MaxStackDepth = maxStackDepth;
-            MaxContinuationDepth = maxContinuationDepth;
-            Instructions = instructions;
-            DebugCookies = debugCookies;
-            Objects = objects;
-            Labels = labels;
-        }
-
-        internal int Length {
-            get { return Instructions.Length; }
-        }
-
-        #region Debug View
-
-        internal sealed class DebugView {
-            private readonly InstructionArray _array;
-
-            public DebugView(InstructionArray array) {
-                _array = array;
-
-            }
-
-            [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
-            public InstructionList.DebugView.InstructionView[]/*!*/ A0 {
-                get {
-                    return InstructionList.DebugView.GetInstructionViews(
-                        _array.Instructions, 
-                        _array.Objects, 
-                        (index) => _array.Labels[index].Index, 
-                        _array.DebugCookies
-                    );
-                }
-            }
-        }
-
-        #endregion
-    }
-
-    [DebuggerTypeProxy(typeof(InstructionList.DebugView))]
-    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
-    public sealed class InstructionList {
-        private readonly List<Instruction> _instructions = new List<Instruction>();
-        private List<object> _objects;
-
-        private int _currentStackDepth;
-        private int _maxStackDepth;
-        private int _currentContinuationsDepth;
-        private int _maxContinuationDepth;
-        private int _runtimeLabelCount;
-        private List<BranchLabel> _labels;
-        
-        // list of (instruction index, cookie) sorted by instruction index:
-        private List<KeyValuePair<int, object>> _debugCookies = null;
-
-        #region Debug View
-
-        internal sealed class DebugView {
-            private readonly InstructionList _list;
-
-            public DebugView(InstructionList list) {
-                _list = list;
-            }
-
-            [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
-            public InstructionView[]/*!*/ A0 {
-                get {
-                    return GetInstructionViews(
-                        _list._instructions, 
-                        _list._objects, 
-                        (index) => _list._labels[index].TargetIndex, 
-                        _list._debugCookies
-                    );
-                }
-            }
-
-            internal static InstructionView[] GetInstructionViews(IList<Instruction> instructions, IList<object> objects,
-                Func<int, int> labelIndexer, IList<KeyValuePair<int, object>> debugCookies) {
-
-                var result = new List<InstructionView>();
-                int index = 0;
-                int stackDepth = 0;
-                int continuationsDepth = 0;
-
-                var cookieEnumerator = (debugCookies != null ? debugCookies : new KeyValuePair<int, object>[0]).GetEnumerator();
-                var hasCookie = cookieEnumerator.MoveNext();
-
-                for (int i = 0; i < instructions.Count; i++) {
-                    object cookie = null;
-                    while (hasCookie && cookieEnumerator.Current.Key == i) {
-                        cookie = cookieEnumerator.Current.Value;
-                        hasCookie = cookieEnumerator.MoveNext();
-                    }
-
-                    int stackDiff = instructions[i].StackBalance;
-                    int contDiff = instructions[i].ContinuationsBalance;
-                    string name = instructions[i].ToDebugString(i, cookie, labelIndexer, objects);
-                    result.Add(new InstructionView(instructions[i], name, i, stackDepth, continuationsDepth));
-                    
-                    index++;
-                    stackDepth += stackDiff;
-                    continuationsDepth += contDiff;
-                }
-                return result.ToArray();
-            }
-
-            [DebuggerDisplay("{GetValue(),nq}", Name = "{GetName(),nq}", Type = "{GetDisplayType(), nq}")]
-            internal struct InstructionView {
-                private readonly int _index;
-                private readonly int _stackDepth;
-                private readonly int _continuationsDepth;
-                private readonly string _name;
-                private readonly Instruction _instruction;
-
-                internal string GetName() {
-                    return _index.ToString() +
-                        (_continuationsDepth == 0 ? "" : " C(" + _continuationsDepth.ToString() + ")") +
-                        (_stackDepth == 0 ? "" : " S(" + _stackDepth.ToString() + ")");
-                }
-
-                internal string GetValue() {
-                    return _name;
-                }
-
-                internal string GetDisplayType() {
-                    return _instruction.ContinuationsBalance.ToString() + "/" + _instruction.StackBalance.ToString();
-                }
-
-                public InstructionView(Instruction instruction, string name, int index, int stackDepth, int continuationsDepth) {
-                    _instruction = instruction;
-                    _name = name;
-                    _index = index;
-                    _stackDepth = stackDepth;
-                    _continuationsDepth = continuationsDepth;
-                }
-            }
-        }
-                        
-        #endregion
-
-        #region Core Emit Ops
-
-        public void Emit(Instruction instruction) {
-            _instructions.Add(instruction);
-            UpdateStackDepth(instruction);
-        }
-
-        private void UpdateStackDepth(Instruction instruction) {
-            Debug.Assert(instruction.ConsumedStack >= 0 && instruction.ProducedStack >= 0 &&
-                instruction.ConsumedContinuations >= 0 && instruction.ProducedContinuations >= 0);
-
-            _currentStackDepth -= instruction.ConsumedStack;
-            Debug.Assert(_currentStackDepth >= 0);
-            _currentStackDepth += instruction.ProducedStack;
-            if (_currentStackDepth > _maxStackDepth) {
-                _maxStackDepth = _currentStackDepth;
-            }
-
-            _currentContinuationsDepth -= instruction.ConsumedContinuations;
-            Debug.Assert(_currentContinuationsDepth >= 0);
-            _currentContinuationsDepth += instruction.ProducedContinuations;
-            if (_currentContinuationsDepth > _maxContinuationDepth) {
-                _maxContinuationDepth = _currentContinuationsDepth;
-            }
-        }
-
-        /// <summary>
-        /// Attaches a cookie to the last emitted instruction.
-        /// </summary>
-        [Conditional("DEBUG")]
-        public void SetDebugCookie(object cookie) {
-#if DEBUG
-            if (_debugCookies == null) {
-                _debugCookies = new List<KeyValuePair<int, object>>();
-            }
-
-            Debug.Assert(Count > 0);
-            _debugCookies.Add(new KeyValuePair<int, object>(Count - 1, cookie));
-#endif
-        }
-
-        public int Count {
-            get { return _instructions.Count; }
-        }
-
-        public int CurrentStackDepth {
-            get { return _currentStackDepth; }
-        }
-
-        public int CurrentContinuationsDepth {
-            get { return _currentContinuationsDepth; }
-        }
-
-        public int MaxStackDepth {
-            get { return _maxStackDepth; }
-        }
-
-        internal Instruction GetInstruction(int index) {
-            return _instructions[index];
-        }
-
-#if STATS
-        private static Dictionary<string, int> _executedInstructions = new Dictionary<string, int>();
-        private static Dictionary<string, Dictionary<object, bool>> _instances = new Dictionary<string, Dictionary<object, bool>>();
-
-        static InstructionList() {
-            AppDomain.CurrentDomain.ProcessExit += new EventHandler((_, __) => {
-                PerfTrack.DumpHistogram(_executedInstructions);
-                Console.WriteLine("-- Total executed: {0}", _executedInstructions.Values.Aggregate(0, (sum, value) => sum + value));
-                Console.WriteLine("-----");
-
-                var referenced = new Dictionary<string, int>();
-                int total = 0;
-                foreach (var entry in _instances) {
-                    referenced[entry.Key] = entry.Value.Count;
-                    total += entry.Value.Count;
-                }
-
-                PerfTrack.DumpHistogram(referenced);
-                Console.WriteLine("-- Total referenced: {0}", total);
-                Console.WriteLine("-----");
-            });
-        }
-#endif
-        public InstructionArray ToArray() {
-#if STATS
-            lock (_executedInstructions) {
-                _instructions.ForEach((instr) => {
-                    int value = 0;
-                    var name = instr.GetType().Name;
-                    _executedInstructions.TryGetValue(name, out value);
-                    _executedInstructions[name] = value + 1;
-
-                    Dictionary<object, bool> dict;
-                    if (!_instances.TryGetValue(name, out dict)) {
-                        _instances[name] = dict = new Dictionary<object, bool>();
-                    }
-                    dict[instr] = true;
-                });
-            }
-#endif
-            return new InstructionArray(
-                _maxStackDepth,
-                _maxContinuationDepth,
-                _instructions.ToArray(),                
-                (_objects != null) ? _objects.ToArray() : null,
-                BuildRuntimeLabels(),
-                _debugCookies
-            );
-        }
-
-        #endregion
-
-        #region Stack Operations
-
-        private const int PushIntMinCachedValue = -100;
-        private const int PushIntMaxCachedValue = 100;
-        private const int CachedObjectCount = 256;
-
-        private static Instruction _null;
-        private static Instruction _true;
-        private static Instruction _false;
-        private static Instruction[] _ints;
-        private static Instruction[] _loadObjectCached;
-
-        public void EmitLoad(object value) {
-            EmitLoad(value, null);
-        }
-
-        public void EmitLoad(bool value) {
-            if ((bool)value) {
-                Emit(_true ?? (_true = new LoadObjectInstruction(value)));
-            } else {
-                Emit(_false ?? (_false = new LoadObjectInstruction(value)));
-            }
-        }
-
-        public void EmitLoad(object value, Type type) {
-            if (value == null) {
-                Emit(_null ?? (_null = new LoadObjectInstruction(null)));
-                return;
-            }
-
-            if (type == null || type.IsValueType()) {
-                if (value is bool) {
-                    EmitLoad((bool)value);
-                    return;
-                } 
-                
-                if (value is int) {
-                    int i = (int)value;
-                    if (i >= PushIntMinCachedValue && i <= PushIntMaxCachedValue) {
-                        if (_ints == null) {
-                            _ints = new Instruction[PushIntMaxCachedValue - PushIntMinCachedValue + 1];
-                        }
-                        i -= PushIntMinCachedValue;
-                        Emit(_ints[i] ?? (_ints[i] = new LoadObjectInstruction(value)));
-                        return;
-                    }
-                }
-            }
-
-            if (_objects == null) {
-                _objects = new List<object>();
-                if (_loadObjectCached == null) {
-                    _loadObjectCached = new Instruction[CachedObjectCount];
-                }
-            }
-
-            if (_objects.Count < _loadObjectCached.Length) {
-                uint index = (uint)_objects.Count;
-                _objects.Add(value);
-                Emit(_loadObjectCached[index] ?? (_loadObjectCached[index] = new LoadCachedObjectInstruction(index)));
-            } else {
-                Emit(new LoadObjectInstruction(value));
-            }
-        }
-
-        public void EmitDup() {
-            Emit(DupInstruction.Instance);
-        }
-
-        public void EmitPop() {
-            Emit(PopInstruction.Instance);
-        }
-
-        public void EmitStore(object value) {
-            Emit (new PushValueInstruction (value));
-        }
-
-        #endregion
-
-        #region Locals
-
-        internal void SwitchToBoxed(int index, int instructionIndex) {
-            var instruction = _instructions[instructionIndex] as IBoxableInstruction;
-
-            if (instruction != null) {
-                var newInstruction = instruction.BoxIfIndexMatches(index);
-                if (newInstruction != null) {
-                    _instructions[instructionIndex] = newInstruction;
-                }
-            }
-        }
-
-        private const int LocalInstrCacheSize = 64;
-
-        private static Instruction[] _loadLocal;
-        private static Instruction[] _loadLocalBoxed;
-        private static Instruction[] _loadLocalFromClosure;
-        private static Instruction[] _loadLocalFromClosureBoxed;
-        private static Instruction[] _assignLocal;
-        private static Instruction[] _storeLocal;
-        private static Instruction[] _assignLocalBoxed;
-        private static Instruction[] _storeLocalBoxed;
-        private static Instruction[] _assignLocalToClosure;
-        private static Instruction[] _initReference;
-        private static Instruction[] _initImmutableRefBox;
-        private static Instruction[] _parameterBox;
-        private static Instruction[] _parameter;
-
-        public void EmitLoadLocal(int index) {
-            if (_loadLocal == null) {
-                _loadLocal = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _loadLocal.Length) {
-                Emit(_loadLocal[index] ?? (_loadLocal[index] = new LoadLocalInstruction(index)));
-            } else {
-                Emit(new LoadLocalInstruction(index));
-            }
-        }
-
-        public void EmitLoadLocalBoxed(int index) {
-            Emit(LoadLocalBoxed(index));
-        }
-
-        internal static Instruction LoadLocalBoxed(int index) {
-            if (_loadLocalBoxed == null) {
-                _loadLocalBoxed = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _loadLocalBoxed.Length) {
-                return _loadLocalBoxed[index] ?? (_loadLocalBoxed[index] = new LoadLocalBoxedInstruction(index));
-            } else {
-                return new LoadLocalBoxedInstruction(index);
-            }
-        }
-
-        public void EmitLoadLocalFromClosure(int index) {
-            if (_loadLocalFromClosure == null) {
-                _loadLocalFromClosure = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _loadLocalFromClosure.Length) {
-                Emit(_loadLocalFromClosure[index] ?? (_loadLocalFromClosure[index] = new LoadLocalFromClosureInstruction(index)));
-            } else {
-                Emit(new LoadLocalFromClosureInstruction(index));
-            }
-        }
-
-        public void EmitLoadLocalFromClosureBoxed(int index) {
-            if (_loadLocalFromClosureBoxed == null) {
-                _loadLocalFromClosureBoxed = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _loadLocalFromClosureBoxed.Length) {
-                Emit(_loadLocalFromClosureBoxed[index] ?? (_loadLocalFromClosureBoxed[index] = new LoadLocalFromClosureBoxedInstruction(index)));
-            } else {
-                Emit(new LoadLocalFromClosureBoxedInstruction(index));
-            }
-        }
-
-        public void EmitAssignLocal(int index) {
-            if (_assignLocal == null) {
-                _assignLocal = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _assignLocal.Length) {
-                Emit(_assignLocal[index] ?? (_assignLocal[index] = new AssignLocalInstruction(index)));
-            } else {
-                Emit(new AssignLocalInstruction(index));
-            }
-        }
-
-        public void EmitStoreLocal(int index) {
-            if (_storeLocal == null) {
-                _storeLocal = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _storeLocal.Length) {
-                Emit(_storeLocal[index] ?? (_storeLocal[index] = new StoreLocalInstruction(index)));
-            } else {
-                Emit(new StoreLocalInstruction(index));
-            }
-        }
-
-        public void EmitAssignLocalBoxed(int index) {
-            Emit(AssignLocalBoxed(index));
-        }
-
-        internal static Instruction AssignLocalBoxed(int index) {
-            if (_assignLocalBoxed == null) {
-                _assignLocalBoxed = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _assignLocalBoxed.Length) {
-                return _assignLocalBoxed[index] ?? (_assignLocalBoxed[index] = new AssignLocalBoxedInstruction(index));
-            } else {
-                return new AssignLocalBoxedInstruction(index);
-            }
-        }
-
-        public void EmitStoreLocalBoxed(int index) {
-            Emit(StoreLocalBoxed(index));
-        }
-
-        internal static Instruction StoreLocalBoxed(int index) {
-            if (_storeLocalBoxed == null) {
-                _storeLocalBoxed = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _storeLocalBoxed.Length) {
-                return _storeLocalBoxed[index] ?? (_storeLocalBoxed[index] = new StoreLocalBoxedInstruction(index));
-            } else {
-                return new StoreLocalBoxedInstruction(index);
-            }
-        }
-
-        public void EmitAssignLocalToClosure(int index) {
-            if (_assignLocalToClosure == null) {
-                _assignLocalToClosure = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _assignLocalToClosure.Length) {
-                Emit(_assignLocalToClosure[index] ?? (_assignLocalToClosure[index] = new AssignLocalToClosureInstruction(index)));
-            } else {
-                Emit(new AssignLocalToClosureInstruction(index));
-            }
-        }
-
-        public void EmitStoreLocalToClosure(int index) {
-            EmitAssignLocalToClosure(index);
-            EmitPop();
-        }
-
-        public void EmitInitializeLocal(int index, Type type) {
-            object value = ScriptingRuntimeHelpers.GetPrimitiveDefaultValue(type);
-            if (value != null) {
-                Emit(new InitializeLocalInstruction.ImmutableValue(index, value));
-            } else if (type.IsValueType()) {
-                Emit(new InitializeLocalInstruction.MutableValue(index, type));
-            } else {
-                Emit(InitReference(index));
-            }
-        }
-
-        internal void EmitInitializeParameter(int index) {
-            Emit(Parameter(index));
-        }
-
-        internal static Instruction Parameter(int index) {
-            if (_parameter == null) {
-                _parameter = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _parameter.Length) {
-                return _parameter[index] ?? (_parameter[index] = new InitializeLocalInstruction.Parameter(index));
-            }
-
-            return new InitializeLocalInstruction.Parameter(index);
-        }
-
-        internal static Instruction ParameterBox(int index) {
-            if (_parameterBox == null) {
-                _parameterBox = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _parameterBox.Length) {
-                return _parameterBox[index] ?? (_parameterBox[index] = new InitializeLocalInstruction.ParameterBox(index));
-            }
-
-            return new InitializeLocalInstruction.ParameterBox(index);
-        }
-
-        internal static Instruction InitReference(int index) {
-            if (_initReference == null) {
-                _initReference = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _initReference.Length) {
-                return _initReference[index] ?? (_initReference[index] = new InitializeLocalInstruction.Reference(index));
-            }
-
-            return new InitializeLocalInstruction.Reference(index);
-        }
-
-        internal static Instruction InitImmutableRefBox(int index) {
-            if (_initImmutableRefBox == null) {
-                _initImmutableRefBox = new Instruction[LocalInstrCacheSize];
-            }
-
-            if (index < _initImmutableRefBox.Length) {
-                return _initImmutableRefBox[index] ?? (_initImmutableRefBox[index] = new InitializeLocalInstruction.ImmutableBox(index, null));
-            }
-
-            return new InitializeLocalInstruction.ImmutableBox(index, null);
-        }
-
-        public void EmitNewRuntimeVariables(int count) {
-            Emit(new RuntimeVariablesInstruction(count));
-        }
-
-        #endregion
-
-        #region Array Operations
-
-        public void EmitGetArrayItem(Type arrayType) {
-            Type elementType = arrayType.GetElementType();
-            if (elementType.IsClass() || elementType.IsInterface()) {
-                Emit(InstructionFactory<object>.Factory.GetArrayItem());
-            } else {
-                Emit(InstructionFactory.GetFactory(elementType).GetArrayItem());
-            }
-        }
-
-        public void EmitGetArrayLength(Type arrayType) {
-            Emit(GetArrayLengthInstruction.Create());
-        }
-
-        public void EmitSetArrayItem(Type arrayType) {
-            Type elementType = arrayType.GetElementType();
-            if (elementType.IsClass() || elementType.IsInterface()) {
-                Emit(InstructionFactory<object>.Factory.SetArrayItem());
-            } else {
-                Emit(InstructionFactory.GetFactory(elementType).SetArrayItem());
-            }
-        }
-
-        public void EmitNewArray(Type elementType) {
-            Emit(InstructionFactory.GetFactory(elementType).NewArray());
-        }
-
-        public void EmitNewArrayBounds(Type elementType, int rank) {
-            Emit(new NewArrayBoundsInstruction(elementType, rank));
-        }
-
-        public void EmitNewArrayInit(Type elementType, int elementCount) {
-            Emit(InstructionFactory.GetFactory(elementType).NewArrayInit(elementCount));
-        }
-
-        #endregion
-
-        #region Arithmetic Operations
-
-        public void EmitAdd(Type type, bool @checked) {
-            if (@checked) {
-                Emit(AddOvfInstruction.Create(type));
-            } else {
-                Emit(AddInstruction.Create(type));
-            }
-        }
-
-        public void EmitSub(Type type, bool @checked) {
-            if (@checked) {
-                Emit(SubOvfInstruction.Create(type));
-            } else {
-                Emit(SubInstruction.Create(type));
-            }
-        }
-
-        public void EmitMul(Type type, bool @checked) {
-            if (@checked) {
-                Emit(MulOvfInstruction.Create(type));
-            } else {
-                Emit(MulInstruction.Create(type));
-            }
-        }
-
-        public void EmitDiv(Type type) {
-            Emit(DivInstruction.Create(type));
-        }
-
-        public void EmitMod(Type type) {
-            Emit(ModInstruction.Create(type));
-        }
-
-        #endregion
-
-        public void EmitIncrement (Type type) {
-            Emit (new PushValueInstruction (1));
-            EmitAdd (type, false);
-        }
-
-        public void EmitShl(Type type, bool lifted) {
-            Emit(lifted ? ShlInstruction.CreateLifted(type) : ShlInstruction.Create(type));
-        }
-
-        public void EmitShr(Type type, bool lifted) {
-            Emit(lifted ? ShrInstruction.CreateLifted(type) : ShrInstruction.Create(type));
-        }
-
-        public void EmitOr(Type type, bool lifted) {
-            Emit(lifted ? OrInstruction.CreateLifted(type) : OrInstruction.Create(type));
-        }
-
-        public void EmitAnd(Type type, bool lifted) {
-            Emit(lifted ? AndInstruction.CreateLifted (type) : AndInstruction.Create(type));
-        }
-
-        public void EmitExclusiveOr(Type type, bool lifted) {
-            Emit(lifted ? XorInstruction.CreateLifted(type) : XorInstruction.Create(type));
-        }        
-
-        #region Comparisons
-
-		public void EmitEqual(Type type, bool liftedResult) {
-            Emit(liftedResult ?
-                EqualInstruction.CreateLifted(TypeUtils.GetNonNullableType (type)) :
-                EqualInstruction.Create(TypeUtils.GetNonNullableType (type)));
-        }
-
-        public void EmitNotEqual(Type type, bool liftedResult) {
-            Emit(liftedResult ?
-                NotEqualInstruction.CreateLifted(TypeUtils.GetNonNullableType (type)) :
-                NotEqualInstruction.Create(TypeUtils.GetNonNullableType (type)));
-        }
-
-        public void EmitLessThan(Type type, bool liftedResult) {
-            Emit(liftedResult ?
-                LessThanInstruction.CreateLifted(TypeUtils.GetNonNullableType (type)) :
-                LessThanInstruction.Create(TypeUtils.GetNonNullableType (type)));
-        }
-
-        public void EmitLessThanOrEqual(Type type, bool liftedResult) {
-            Emit(liftedResult ?
-                LessThanOrEqualInstruction.CreateLifted(TypeUtils.GetNonNullableType (type)) :
-                LessThanOrEqualInstruction.Create(TypeUtils.GetNonNullableType (type)));
-        }
-
-        public void EmitGreaterThan(Type type, bool liftedResult) {
-            Emit(liftedResult ?
-                GreaterThanInstruction.CreateLifted(TypeUtils.GetNonNullableType (type)) :
-                GreaterThanInstruction.Create(TypeUtils.GetNonNullableType (type)));
-        }
-
-        public void EmitGreaterThanOrEqual(Type type, bool liftedResult) {
-            Emit(liftedResult ?
-                GreaterThanOrEqualInstruction.CreateLifted(TypeUtils.GetNonNullableType (type)) :
-                GreaterThanOrEqualInstruction.Create(TypeUtils.GetNonNullableType (type)));
-        }
-
-        #endregion
-
-        #region Conversions
-
-        public void EmitNumericConvertChecked(TypeCode from, TypeCode to) {
-            Emit(new NumericConvertInstruction.Checked(from, to));
-        }
-
-        public void EmitNumericConvertUnchecked(TypeCode from, TypeCode to) {
-            Emit(new NumericConvertInstruction.Unchecked(from, to));
-        }
-
-        #endregion
-
-        #region Unary Operators
-
-        public void EmitNegate(Type type, bool @checked, bool lifted) {
-            if (@checked)
-                Emit(lifted ? NegateOvfInstruction.CreateLifted(type) : NegateOvfInstruction.Create(type));
-            else
-                Emit(lifted ? NegateInstruction.CreateLifted(type) : NegateInstruction.Create(type));            
-        }
-
-        public void EmitNot(Type type, bool lifted) {
-            Emit(lifted ? NotInstruction.CreateLifted (type) : NotInstruction.Create(type));
-        }
-
-        #endregion
-
-        #region Nullable operations
-
-        public void EmitWrap (Type elementType)
-        {
-            Emit(InstructionFactory.GetFactory(elementType).WrapToNullable (elementType));
-        }
-
-        #endregion
-
-        #region Types
-
-        public void EmitDefaultValue(Type type) {
-            Emit(InstructionFactory.GetFactory(type).DefaultValue());
-        }
-
-        public void EmitNew(ConstructorInfo constructorInfo) {
-            Emit(new NewInstruction(constructorInfo));
-        }
-
-        internal void EmitCreateDelegate(LightDelegateCreator creator) {
-            Emit(new CreateDelegateInstruction(creator));
-        }
-
-        public void EmitTypeEquals() {
-            Emit(TypeEqualsInstruction.Instance);
-        }
-
-        public void EmitTypeIs(Type type) {
-            Emit(InstructionFactory.GetFactory(type).TypeIs());
-        }
-
-        public void EmitTypeAs(Type type) {
-            Emit(InstructionFactory.GetFactory(type).TypeAs());
-        }
-
-        #endregion
-
-        #region Fields and Methods
-
-        private static readonly Dictionary<FieldInfo, Instruction> _loadFields = new Dictionary<FieldInfo, Instruction>();
-
-        public void EmitLoadField(FieldInfo field) {
-            Emit(GetLoadField(field));
-        }
-
-        private Instruction GetLoadField(FieldInfo field) {
-            lock (_loadFields) {
-                Instruction instruction;
-                if (!_loadFields.TryGetValue(field, out instruction)) {
-                    if (field.IsStatic) {
-                        instruction = new LoadStaticFieldInstruction(field);
-                    } else {
-                        instruction = new LoadFieldInstruction(field);
-                    }
-                    _loadFields.Add(field, instruction);
-                }
-                return instruction;
-            }
-        }
-        
-        public void EmitStoreField(FieldInfo field) {
-            if (field.IsStatic) {
-                Emit(new StoreStaticFieldInstruction(field));
-            } else {
-                Emit(new StoreFieldInstruction(field));
-            }
-        }
-
-        #endregion
-
-        #region Dynamic
-
-        public void EmitDynamic(Type type, CallSiteBinder binder) {
-            Emit(CreateDynamicInstruction(type, binder));
-        }
-
-        #region Generated Dynamic InstructionList Factory
-
-        // *** BEGIN GENERATED CODE ***
-        // generated by function: gen_instructionlist_factory from: generate_dynamic_instructions.py
-
-        public void EmitDynamic<T0, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TRet>.Factory(binder));
-        }
-
-        public void EmitDynamic<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TRet>(CallSiteBinder binder) {
-            Emit(DynamicInstruction<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TRet>.Factory(binder));
-        }
-
-
-        // *** END GENERATED CODE ***
-
-        #endregion
-
-        private static Dictionary<Type, Func<CallSiteBinder, Instruction>> _factories =
-            new Dictionary<Type, Func<CallSiteBinder, Instruction>>();
-
-        /// <exception cref="SecurityException">Instruction can't be created due to insufficient privileges.</exception>
-        internal static Instruction CreateDynamicInstruction(Type delegateType, CallSiteBinder binder) {
-            Func<CallSiteBinder, Instruction> factory;
-            lock (_factories) {
-                if (!_factories.TryGetValue(delegateType, out factory)) {
-                    if (delegateType.GetMethod("Invoke").ReturnType == typeof(void)) {
-                        // TODO: We should generally support void returning binders but the only
-                        // ones that exist are delete index/member who's perf isn't that critical.
-                        return new DynamicInstructionN(delegateType, CallSite.Create(delegateType, binder), true);
-                    }
-
-                    Type instructionType = DynamicInstructionN.GetDynamicInstructionType(delegateType);
-                    if (instructionType == null) {
-                        return new DynamicInstructionN(delegateType, CallSite.Create(delegateType, binder));
-                    }
-
-                    factory = (Func<CallSiteBinder, Instruction>)instructionType.GetMethod("Factory").CreateDelegate(typeof(Func<CallSiteBinder, Instruction>));
-                    _factories[delegateType] = factory;
-                }
-            }
-            return factory(binder);
-        }
-
-        #endregion
-
-        #region Control Flow
-
-        private static readonly RuntimeLabel[] EmptyRuntimeLabels = new RuntimeLabel[] { new RuntimeLabel(Interpreter.RethrowOnReturn, 0, 0) };
-
-        private RuntimeLabel[] BuildRuntimeLabels() {
-            if (_runtimeLabelCount == 0) {
-                return EmptyRuntimeLabels;
-            }
-
-            var result = new RuntimeLabel[_runtimeLabelCount + 1];
-            foreach (BranchLabel label in _labels) {
-                if (label.HasRuntimeLabel) {
-                    result[label.LabelIndex] = label.ToRuntimeLabel();
-                }
-            }
-            // "return and rethrow" label:
-            result[result.Length - 1] = new RuntimeLabel(Interpreter.RethrowOnReturn, 0, 0);
-            return result;
-        }
-
-        public BranchLabel MakeLabel() {
-            if (_labels == null) {
-                _labels = new List<BranchLabel>();
-            }
-
-            var label = new BranchLabel();
-            _labels.Add(label);
-            return label;
-        }
-
-        internal void FixupBranch(int branchIndex, int offset) {
-            _instructions[branchIndex] = ((OffsetInstruction)_instructions[branchIndex]).Fixup(offset);
-        }
-
-        private int EnsureLabelIndex(BranchLabel label) {
-            if (label.HasRuntimeLabel) {
-                return label.LabelIndex;
-            }
-
-            label.LabelIndex = _runtimeLabelCount;
-            _runtimeLabelCount++;
-            return label.LabelIndex;
-        }
-
-        public int MarkRuntimeLabel() {
-            BranchLabel handlerLabel = MakeLabel();
-            MarkLabel(handlerLabel);
-            return EnsureLabelIndex(handlerLabel);
-        }
-
-        public void MarkLabel(BranchLabel label) {
-            label.Mark(this);
-        }
-
-        public void EmitGoto(BranchLabel label, bool hasResult, bool hasValue) {
-            Emit(GotoInstruction.Create(EnsureLabelIndex(label), hasResult, hasValue));
-        }
-
-        private void EmitBranch(OffsetInstruction instruction, BranchLabel label) {
-            Emit(instruction);
-            label.AddBranch(this, Count - 1);
-        }
-
-        public void EmitBranch(BranchLabel label) {
-            EmitBranch(new BranchInstruction(), label);
-        }
-
-        public void EmitBranch(BranchLabel label, bool hasResult, bool hasValue) {
-            EmitBranch(new BranchInstruction(hasResult, hasValue), label);
-        }
-
-        public void EmitCoalescingBranch(BranchLabel leftNotNull) {
-            EmitBranch(new CoalescingBranchInstruction(), leftNotNull);
-        }
-
-        public void EmitBranchTrue(BranchLabel elseLabel) {
-            EmitBranch(new BranchTrueInstruction(), elseLabel);
-        }
-
-        public void EmitBranchFalse(BranchLabel elseLabel) {
-            EmitBranch(new BranchFalseInstruction(), elseLabel);
-        }
-
-        public void EmitBranchNull(BranchLabel elseLabel) {
-            EmitBranch(new BranchNullInstruction(), elseLabel);
-        }
-
-        public void EmitThrow() {
-            Emit(ThrowInstruction.Throw);
-        }
-
-        public void EmitThrowVoid() {
-            Emit(ThrowInstruction.VoidThrow);
-        }
-
-        public void EmitRethrow() {
-            Emit(ThrowInstruction.Rethrow);
-        }
-
-        public void EmitRethrowVoid() {
-            Emit(ThrowInstruction.VoidRethrow);
-        }
-
-        public void EmitEnterTryFinally(BranchLabel finallyStartLabel) {
-            Emit(EnterTryFinallyInstruction.Create(EnsureLabelIndex(finallyStartLabel)));
-        }
-
-        public void EmitEnterFinally() {
-            Emit(EnterFinallyInstruction.Instance);
-        }
-
-        public void EmitLeaveFinally() {
-            Emit(LeaveFinallyInstruction.Instance);
-        }
-
-        public void EmitLeaveFault(bool hasValue) {
-            Emit(hasValue ? LeaveFaultInstruction.NonVoid : LeaveFaultInstruction.Void);
-        }
-
-        public void EmitEnterExceptionHandlerNonVoid() {
-            Emit(EnterExceptionHandlerInstruction.NonVoid);
-        }
-
-        public void EmitEnterExceptionHandlerVoid() {
-            Emit(EnterExceptionHandlerInstruction.Void);
-        }
-
-        public void EmitLeaveExceptionHandler(bool hasValue, BranchLabel tryExpressionEndLabel) {
-            Emit(LeaveExceptionHandlerInstruction.Create(EnsureLabelIndex(tryExpressionEndLabel), hasValue));
-        }
-
-        public void EmitSwitch(Dictionary<int, int> cases) {
-            Emit(new SwitchInstruction(cases));
-        }
-
-        #endregion
-    }
-}

+ 0 - 309
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LabelInfo.cs

@@ -1,309 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-#if FEATURE_REFEMIT
-using System.Reflection.Emit;
-#endif
-using System.Text;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-
-    /// <summary>
-    /// Contains compiler state corresponding to a LabelTarget
-    /// See also LabelScopeInfo.
-    /// </summary>
-    internal sealed class LabelInfo {
-        // The tree node representing this label
-        private readonly LabelTarget _node;
-
-        // The BranchLabel label, will be mutated if Node is redefined
-        private BranchLabel _label;
-
-        // The blocks where this label is defined. If it has more than one item,
-        // the blocks can't be jumped to except from a child block
-        // If there's only 1 block (the common case) it's stored here, if there's multiple blocks it's stored
-        // as a HashSet<LabelScopeInfo> 
-        private object _definitions;
-
-        // Blocks that jump to this block
-        private readonly List<LabelScopeInfo> _references = new List<LabelScopeInfo>();
-
-        // True if at least one jump is across blocks
-        // If we have any jump across blocks to this label, then the
-        // LabelTarget can only be defined in one place
-        private bool _acrossBlockJump;
-
-        internal LabelInfo(LabelTarget node) {
-            _node = node;
-        }
-
-        internal BranchLabel GetLabel(LightCompiler compiler) {
-            EnsureLabel(compiler);
-            return _label;
-        }
-
-        internal void Reference(LabelScopeInfo block) {
-            _references.Add(block);
-            if (HasDefinitions) {
-                ValidateJump(block);
-            }
-        }
-
-        internal void Define(LabelScopeInfo block) {
-            // Prevent the label from being shadowed, which enforces cleaner
-            // trees. Also we depend on this for simplicity (keeping only one
-            // active IL Label per LabelInfo)
-            for (LabelScopeInfo j = block; j != null; j = j.Parent) {
-                if (j.ContainsTarget(_node)) {
-                    throw new InvalidOperationException(String.Format("Label target already defined: {0}", _node.Name));
-                }
-            }
-
-            AddDefinition(block);
-            block.AddLabelInfo(_node, this);
-
-            // Once defined, validate all jumps
-            if (HasDefinitions && !HasMultipleDefinitions) {
-                foreach (var r in _references) {
-                    ValidateJump(r);
-                }
-            } else {
-                // Was just redefined, if we had any across block jumps, they're
-                // now invalid
-                if (_acrossBlockJump) {
-                    throw new InvalidOperationException("Ambiguous jump");                    
-                }
-                // For local jumps, we need a new IL label
-                // This is okay because:
-                //   1. no across block jumps have been made or will be made
-                //   2. we don't allow the label to be shadowed
-                _label = null;
-            }
-        }
-
-        private void ValidateJump(LabelScopeInfo reference) {
-            // look for a simple jump out
-            for (LabelScopeInfo j = reference; j != null; j = j.Parent) {
-                if (DefinedIn(j)) {
-                    // found it, jump is valid!
-                    return;
-                }
-                if (j.Kind == LabelScopeKind.Filter) {
-                    break;
-                }
-            }
-
-            _acrossBlockJump = true;
-
-            if (HasMultipleDefinitions) {
-                throw new InvalidOperationException(String.Format("Ambiguous jump {0}", _node.Name));
-            }
-
-            // We didn't find an outward jump. Look for a jump across blocks
-            LabelScopeInfo def = FirstDefinition();
-            LabelScopeInfo common = CommonNode(def, reference, b => b.Parent);
-
-            // Validate that we aren't jumping across a finally
-            for (LabelScopeInfo j = reference; j != common; j = j.Parent) {
-                if (j.Kind == LabelScopeKind.Filter) {
-                    throw new InvalidOperationException("Control cannot leave filter test");
-                }
-            }
-
-            // Valdiate that we aren't jumping into a catch or an expression
-            for (LabelScopeInfo j = def; j != common; j = j.Parent) {
-                if (!j.CanJumpInto) {
-                    if (j.Kind == LabelScopeKind.Expression) {
-                        throw new InvalidOperationException("Control cannot enter an expression");
-                    } else {
-                        throw new InvalidOperationException("Control cannot enter try");
-                    }
-                }
-            }
-        }
-
-        internal void ValidateFinish() {
-            // Make sure that if this label was jumped to, it is also defined
-            if (_references.Count > 0 && !HasDefinitions) {
-                throw new InvalidOperationException("label target undefined");
-            }
-        }
-
-        private void EnsureLabel(LightCompiler compiler) {
-            if (_label == null) {
-                _label = compiler.Instructions.MakeLabel();
-            }
-        }        
-
-        private bool DefinedIn(LabelScopeInfo scope) {
-            if (_definitions == scope) {
-                return true;
-            }
-
-            HashSet<LabelScopeInfo> definitions = _definitions as HashSet<LabelScopeInfo>;
-            if (definitions != null) {
-                return definitions.Contains(scope);
-            }
-            return false;
-        }
-
-        private bool HasDefinitions {
-            get {
-                return _definitions != null;
-            }
-        }
-
-        private LabelScopeInfo FirstDefinition() {
-            LabelScopeInfo scope = _definitions as LabelScopeInfo;
-            if (scope != null) {
-                return scope;
-            }
-            return ((HashSet<LabelScopeInfo>)_definitions).First();
-        }
-
-        private void AddDefinition(LabelScopeInfo scope) {
-            if (_definitions == null) {
-                _definitions = scope;
-            } else {
-                HashSet<LabelScopeInfo> set = _definitions as HashSet<LabelScopeInfo>;
-                if(set == null) {
-                    _definitions = set = new HashSet<LabelScopeInfo>() { (LabelScopeInfo)_definitions };
-                }
-                set.Add(scope);
-            }
-        }
-
-        private bool HasMultipleDefinitions {
-            get {
-                return _definitions is HashSet<LabelScopeInfo>;
-            }
-        }
-
-        internal static T CommonNode<T>(T first, T second, Func<T, T> parent) where T : class {
-            var cmp = EqualityComparer<T>.Default;
-            if (cmp.Equals(first, second)) {
-                return first;
-            }
-            var set = new HashSet<T>(cmp);
-            for (T t = first; t != null; t = parent(t)) {
-                set.Add(t);
-            }
-            for (T t = second; t != null; t = parent(t)) {
-                if (set.Contains(t)) {
-                    return t;
-                }
-            }
-            return null;
-        }
-    }
-
-    public enum LabelScopeKind {
-        // any "statement like" node that can be jumped into
-        Statement,
-
-        // these correspond to the node of the same name
-        Block,
-        Switch,
-        Lambda,
-        Try,
-
-        // these correspond to the part of the try block we're in
-        Catch,
-        Finally,
-        Filter,
-
-        // the catch-all value for any other expression type
-        // (means we can't jump into it)
-        Expression,
-    }
-
-    //
-    // Tracks scoping information for LabelTargets. Logically corresponds to a
-    // "label scope". Even though we have arbitrary goto support, we still need
-    // to track what kinds of nodes that gotos are jumping through, both to
-    // emit property IL ("leave" out of a try block), and for validation, and
-    // to allow labels to be duplicated in the tree, as long as the jumps are
-    // considered "up only" jumps.
-    //
-    // We create one of these for every Expression that can be jumped into, as
-    // well as creating them for the first expression we can't jump into. The
-    // "Kind" property indicates what kind of scope this is.
-    //
-    internal sealed class LabelScopeInfo {
-        private HybridReferenceDictionary<LabelTarget, LabelInfo> Labels; // lazily allocated, we typically use this only once every 6th-7th block
-        internal readonly LabelScopeKind Kind;
-        internal readonly LabelScopeInfo Parent;
-
-        internal LabelScopeInfo(LabelScopeInfo parent, LabelScopeKind kind) {
-            Parent = parent;
-            Kind = kind;
-        }
-
-        /// <summary>
-        /// Returns true if we can jump into this node
-        /// </summary>
-        internal bool CanJumpInto {
-            get {
-                switch (Kind) {
-                    case LabelScopeKind.Block:
-                    case LabelScopeKind.Statement:
-                    case LabelScopeKind.Switch:
-                    case LabelScopeKind.Lambda:
-                        return true;
-                }
-                return false;
-            }
-        }
-
-
-        internal bool ContainsTarget(LabelTarget target) {
-            if (Labels == null) {
-                return false;
-            }
-
-            return Labels.ContainsKey(target);
-        }
-
-        internal bool TryGetLabelInfo(LabelTarget target, out LabelInfo info) {
-            if (Labels == null) {
-                info = null;
-                return false;
-            }
-
-            return Labels.TryGetValue(target, out info);
-        }
-
-        internal void AddLabelInfo(LabelTarget target, LabelInfo info) {
-            Debug.Assert(CanJumpInto);
-
-            if (Labels == null) {
-                Labels = new HybridReferenceDictionary<LabelTarget, LabelInfo>();
-            }
-
-            Labels[target] = info;
-        }
-    }
-}

+ 0 - 171
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs

@@ -1,171 +0,0 @@
-// 
-// LessThanInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    abstract class LessThanInstruction : ComparisonInstruction {
-        private static Instruction _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
-        private static Instruction _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted, _ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
-
-        private LessThanInstruction() {
-        }
-
-        protected override object DoNullComparison (object l, object r)
-        {
-            return LiftedToNull ? (object) null : (object) false;
-        }
-
-        internal sealed class LessThanSByte : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (SByte)l < (SByte)r;
-            }
-        }
-
-        internal sealed class LessThanInt16 : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int16)l < (Int16)r;
-            }
-        }
-
-        internal sealed class LessThanChar : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Char)l < (Char)r;
-            }
-        }
-
-        internal sealed class LessThanInt32 : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int32)l < (Int32)r;
-            }
-        }
-
-        internal sealed class LessThanInt64 : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int64)l < (Int64)r;
-            }
-        }
-
-        internal sealed class LessThanByte : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Byte)l < (Byte)r;
-            }
-        }
-
-        internal sealed class LessThanUInt16 : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt16)l < (UInt16)r;
-            }
-        }
-
-        internal sealed class LessThanUInt32 : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt32)l < (UInt32)r;
-            }
-        }
-
-        internal sealed class LessThanUInt64 : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt64)l < (UInt64)r;
-            }
-        }
-
-        internal sealed class LessThanSingle : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Single)l < (Single)r;
-            }
-        }
-
-        internal sealed class LessThanDouble : LessThanInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Double)l < (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByte ?? (_SByte = new LessThanSByte());
-                case TypeCode.Byte: return _Byte ?? (_Byte = new LessThanByte());
-                case TypeCode.Char: return _Char ?? (_Char = new LessThanChar());
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new LessThanInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new LessThanInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new LessThanInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new LessThanUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new LessThanUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new LessThanUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new LessThanSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new LessThanDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByteLifted ?? (_SByteLifted = new LessThanSByte() { LiftedToNull = true });
-                case TypeCode.Byte: return _ByteLifted ?? (_ByteLifted = new LessThanByte() { LiftedToNull = true });
-                case TypeCode.Char: return _CharLifted ?? (_CharLifted = new LessThanChar() { LiftedToNull = true });
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new LessThanInt16() { LiftedToNull = true });
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new LessThanInt32() { LiftedToNull = true });
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new LessThanInt64() { LiftedToNull = true });
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new LessThanUInt16() { LiftedToNull = true });
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new LessThanUInt32() { LiftedToNull = true });
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new LessThanUInt64() { LiftedToNull = true });
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new LessThanSingle() { LiftedToNull = true });
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new LessThanDouble() { LiftedToNull = true });
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "LessThan()";
-        }
-    }
-}

+ 0 - 171
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs

@@ -1,171 +0,0 @@
-// 
-// LessThanOrEqualInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    abstract class LessThanOrEqualInstruction : ComparisonInstruction {
-        private static Instruction _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
-        private static Instruction _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted, _ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
-
-        private LessThanOrEqualInstruction() {
-        }
-
-        protected override object DoNullComparison (object l, object r)
-        {
-            return LiftedToNull ? (object) null : (object) false;
-        }
-
-        internal sealed class LessThanOrEqualSByte : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (SByte)l <= (SByte)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualInt16 : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int16)l <= (Int16)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualChar : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Char)l <= (Char)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualInt32 : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int32)l <= (Int32)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualInt64 : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int64)l <= (Int64)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualByte : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Byte)l <= (Byte)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualUInt16 : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt16)l <= (UInt16)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualUInt32 : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt32)l <= (UInt32)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualUInt64 : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt64)l <= (UInt64)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualSingle : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Single)l <= (Single)r;
-            }
-        }
-
-        internal sealed class LessThanOrEqualDouble : LessThanOrEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Double)l <= (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByte ?? (_SByte = new LessThanOrEqualSByte());
-                case TypeCode.Byte: return _Byte ?? (_Byte = new LessThanOrEqualByte());
-                case TypeCode.Char: return _Char ?? (_Char = new LessThanOrEqualChar());
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new LessThanOrEqualInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new LessThanOrEqualInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new LessThanOrEqualInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new LessThanOrEqualUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new LessThanOrEqualUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new LessThanOrEqualUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new LessThanOrEqualSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new LessThanOrEqualDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.SByte: return _SByteLifted ?? (_SByteLifted = new LessThanOrEqualSByte() { LiftedToNull = true });
-                case TypeCode.Byte: return _ByteLifted ?? (_ByteLifted = new LessThanOrEqualByte() { LiftedToNull = true });
-                case TypeCode.Char: return _CharLifted ?? (_CharLifted = new LessThanOrEqualChar() { LiftedToNull = true });
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new LessThanOrEqualInt16() { LiftedToNull = true });
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new LessThanOrEqualInt32() { LiftedToNull = true });
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new LessThanOrEqualInt64() { LiftedToNull = true });
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new LessThanOrEqualUInt16() { LiftedToNull = true });
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new LessThanOrEqualUInt32() { LiftedToNull = true });
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new LessThanOrEqualUInt64() { LiftedToNull = true });
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new LessThanOrEqualSingle() { LiftedToNull = true });
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new LessThanOrEqualDouble() { LiftedToNull = true });
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "LessThanOrEqual()";
-        }
-    }
-}

+ 0 - 374
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LocalAccess.cs

@@ -1,374 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using System.Collections.Generic;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal interface IBoxableInstruction {
-        Instruction BoxIfIndexMatches(int index);
-    }
-
-    internal abstract class LocalAccessInstruction : Instruction {
-        internal readonly int _index;
-
-        protected LocalAccessInstruction(int index) {
-            _index = index;
-        }
-
-        public override string ToDebugString(int instructionIndex, object cookie, Func<int, int> labelIndexer, IList<object> objects) {
-            return cookie == null ? 
-                InstructionName + "(" + _index + ")" : 
-                InstructionName + "(" + cookie + ": " + _index + ")";
-        }
-    }
-
-    #region Load
-
-    internal sealed class LoadLocalInstruction : LocalAccessInstruction, IBoxableInstruction {
-        internal LoadLocalInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex++] = frame.Data[_index];
-            //frame.Push(frame.Data[_index]);
-            return +1;
-        }
-        
-        public Instruction BoxIfIndexMatches(int index) {
-            return (index == _index) ? InstructionList.LoadLocalBoxed(index) : null;
-        }
-    }
-
-    internal sealed class LoadLocalBoxedInstruction : LocalAccessInstruction {
-        internal LoadLocalBoxedInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var box = (StrongBox<object>)frame.Data[_index];
-            frame.Data[frame.StackIndex++] = box.Value;
-            return +1;
-        }
-    }
-
-    internal sealed class LoadLocalFromClosureInstruction : LocalAccessInstruction {
-        internal LoadLocalFromClosureInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var box = frame.Closure[_index];
-            frame.Data[frame.StackIndex++] = box.Value;
-            return +1;
-        }
-    }
-
-    internal sealed class LoadLocalFromClosureBoxedInstruction : LocalAccessInstruction {
-        internal LoadLocalFromClosureBoxedInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var box = frame.Closure[_index];
-            frame.Data[frame.StackIndex++] = box;
-            return +1;
-        }
-    }
-
-    #endregion
-
-    #region Store, Assign
-
-    internal sealed class AssignLocalInstruction : LocalAccessInstruction, IBoxableInstruction {
-        internal AssignLocalInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[_index] = frame.Peek();
-            return +1;
-        }
-
-        public Instruction BoxIfIndexMatches(int index) {
-            return (index == _index) ? InstructionList.AssignLocalBoxed(index) : null;
-        }
-    }
-
-    internal sealed class StoreLocalInstruction : LocalAccessInstruction, IBoxableInstruction {
-        internal StoreLocalInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[_index] = frame.Data[--frame.StackIndex];
-            //frame.Data[_index] = frame.Pop();
-            return +1;
-        }
-
-        public Instruction BoxIfIndexMatches(int index) {
-            return (index == _index) ? InstructionList.StoreLocalBoxed(index) : null;
-        }
-    }
-
-    internal sealed class AssignLocalBoxedInstruction : LocalAccessInstruction {
-        internal AssignLocalBoxedInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var box = (StrongBox<object>)frame.Data[_index];
-            box.Value = frame.Peek();
-            return +1;
-        }
-    }
-
-    internal sealed class StoreLocalBoxedInstruction : LocalAccessInstruction {
-        internal StoreLocalBoxedInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 0; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var box = (StrongBox<object>)frame.Data[_index];
-            box.Value = frame.Data[--frame.StackIndex];
-            return +1;
-        }
-    }
-
-    internal sealed class AssignLocalToClosureInstruction : LocalAccessInstruction {
-        internal AssignLocalToClosureInstruction(int index)
-            : base(index) {
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var box = frame.Closure[_index];
-            box.Value = frame.Peek();
-            return +1;
-        }
-    }
-
-    #endregion
-
-    #region Initialize
-
-    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1012:AbstractTypesShouldNotHaveConstructors")]
-    internal abstract class InitializeLocalInstruction : LocalAccessInstruction {
-        internal InitializeLocalInstruction(int index)
-            : base(index) {
-        }
-
-        internal sealed class Reference : InitializeLocalInstruction, IBoxableInstruction {
-            internal Reference(int index)
-                : base(index) {
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                frame.Data[_index] = null;
-                return 1;
-            }
-
-            public Instruction BoxIfIndexMatches(int index) {
-                return (index == _index) ? InstructionList.InitImmutableRefBox(index) : null;
-            }
-
-            public override string InstructionName {
-                get { return "InitRef"; }
-            }
-        }
-
-        internal sealed class ImmutableValue : InitializeLocalInstruction, IBoxableInstruction {
-            private readonly object _defaultValue;
-
-            internal ImmutableValue(int index, object defaultValue)
-                : base(index) {
-                _defaultValue = defaultValue;
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                frame.Data[_index] = _defaultValue;
-                return 1;
-            }
-
-            public Instruction BoxIfIndexMatches(int index) {
-                return (index == _index) ? new ImmutableBox(index, _defaultValue) : null;
-            }
-
-            public override string InstructionName {
-                get { return "InitImmutableValue"; }
-            }
-        }
-
-        internal sealed class ImmutableBox : InitializeLocalInstruction {
-            // immutable value:
-            private readonly object _defaultValue;
-
-            internal ImmutableBox(int index, object defaultValue)
-                : base(index) {
-                _defaultValue = defaultValue;
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                frame.Data[_index] = new StrongBox<object>(_defaultValue);
-                return 1;
-            }
-
-            public override string InstructionName {
-                get { return "InitImmutableBox"; }
-            }
-        }
-
-        internal sealed class ParameterBox : InitializeLocalInstruction {
-            public ParameterBox(int index)
-                : base(index) {
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                frame.Data[_index] = new StrongBox<object>(frame.Data[_index]);
-                return 1;
-            }
-
-        }
-
-        internal sealed class Parameter : InitializeLocalInstruction, IBoxableInstruction {
-            internal Parameter(int index)
-                : base(index) {
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                // nop
-                return 1;
-            }
-
-            public Instruction BoxIfIndexMatches(int index) {
-                if (index == _index) {
-                    return InstructionList.ParameterBox(index);
-                }
-                return null;
-            }
-
-            public override string InstructionName {
-                get { return "InitParameter"; }
-            }
-        }
-
-        internal sealed class MutableValue : InitializeLocalInstruction, IBoxableInstruction {
-            private readonly Type _type;
-
-            internal MutableValue(int index, Type type)
-                : base(index) {
-                _type = type;
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                try {
-                    frame.Data[_index] = Activator.CreateInstance(_type);
-                } catch (TargetInvocationException e) {
-                    ExceptionHelpers.UpdateForRethrow(e.InnerException);
-                    throw e.InnerException;
-                }
-
-                return 1;
-            }
-
-            public Instruction BoxIfIndexMatches(int index) {
-                return (index == _index) ? new MutableBox(index, _type) : null;
-            }
-
-            public override string InstructionName {
-                get { return "InitMutableValue"; }
-            }
-        }
-
-        internal sealed class MutableBox : InitializeLocalInstruction {
-            private readonly Type _type;
-
-            internal MutableBox(int index, Type type)
-                : base(index) {
-                _type = type;
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                frame.Data[_index] = new StrongBox<object>(Activator.CreateInstance(_type));
-                return 1;
-            }
-
-            public override string InstructionName {
-                get { return "InitMutableBox"; }
-            }
-        }
-    }
-
-    #endregion
-
-    #region RuntimeVariables
-
-    internal sealed class RuntimeVariablesInstruction : Instruction {
-        private readonly int _count;
-
-        public RuntimeVariablesInstruction(int count) {
-            _count = count;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-        public override int ConsumedStack { get { return _count; } }
-
-        public override int Run(InterpretedFrame frame) {
-            var ret = new IStrongBox[_count];
-            for (int i = ret.Length - 1; i >= 0; i--) {
-                ret[i] = (IStrongBox)frame.Pop();
-            }
-            frame.Push(RuntimeVariables.Create(ret));
-            return +1;
-        }
-
-        public override string ToString() {
-            return "GetRuntimeVariables()";
-        }
-    }
-
-    #endregion
-}

+ 0 - 118
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs

@@ -1,118 +0,0 @@
-// 
-// ModInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class ModInstruction : ArithmeticInstruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        private ModInstruction() {
-        }
-
-        internal sealed class ModInt32 : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l % (Int32)r));
-            }
-        }
-
-        internal sealed class ModInt16 : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16)unchecked((Int16)l % (Int16)r);
-            }
-        }
-
-        internal sealed class ModInt64 : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)unchecked((Int64)l % (Int64)r);
-            }
-        }
-
-        internal sealed class ModUInt16 : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16)unchecked((UInt16)l % (UInt16)r);
-            }
-        }
-
-        internal sealed class ModUInt32 : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)unchecked((UInt32)l % (UInt32)r);
-            }
-        }
-
-        internal sealed class ModUInt64 : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)unchecked((UInt64)l % (UInt64)r);
-            }
-        }
-
-        internal sealed class ModSingle : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Single)((Single)l % (Single)r);
-            }
-        }
-
-        internal sealed class ModDouble : ModInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Double)l % (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new ModInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new ModInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new ModInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new ModUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new ModUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new ModUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new ModSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new ModDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Mod()";
-        }
-    }
-}

+ 0 - 204
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs

@@ -1,204 +0,0 @@
-// 
-// MulInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class MulInstruction : ArithmeticInstruction {
-
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        private MulInstruction() {
-        }
-
-        internal sealed class MulInt32 : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l * (Int32)r));
-            }
-        }
-
-        internal sealed class MulInt16 : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16)unchecked((Int16)l * (Int16)r);
-            }
-        }
-
-        internal sealed class MulInt64 : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)unchecked((Int64)l * (Int64)r);
-            }
-        }
-
-        internal sealed class MulUInt16 : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16)unchecked((UInt16)l * (UInt16)r);
-            }
-        }
-
-        internal sealed class MulUInt32 : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)unchecked((UInt32)l * (UInt32)r);
-            }
-        }
-
-        internal sealed class MulUInt64 : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)unchecked((UInt64)l * (UInt64)r);
-            }
-        }
-
-        internal sealed class MulSingle : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Single)((Single)l * (Single)r);
-            }
-        }
-
-        internal sealed class MulDouble : MulInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Double)l * (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new MulInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new MulInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new MulInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new MulUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new MulUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new MulUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new MulSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new MulDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Mul()";
-        }
-    }
-
-    internal abstract class MulOvfInstruction : ArithmeticInstruction {
-
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        private MulOvfInstruction() {
-        }
-
-        internal sealed class MulOvfInt32 : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject(checked((Int32)l * (Int32)r));
-            }
-        }
-
-        internal sealed class MulOvfInt16 : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((Int16)((Int16)l * (Int16)r));
-            }
-        }
-
-        internal sealed class MulOvfInt64 : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((Int64)((Int64)l * (Int64)r));
-            }
-        }
-
-        internal sealed class MulOvfUInt16 : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt16)((UInt16)l * (UInt16)r));
-            }
-        }
-
-        internal sealed class MulOvfUInt32 : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt32)((UInt32)l * (UInt32)r));
-            }
-        }
-
-        internal sealed class MulOvfUInt64 : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt64)((UInt64)l * (UInt64)r));
-            }
-        }
-
-        internal sealed class MulOvfSingle : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Single)((Single)l * (Single)r);
-            }
-        }
-
-        internal sealed class MulOvfDouble : MulOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Double)l * (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new MulOvfInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new MulOvfInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new MulOvfInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new MulOvfUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new MulOvfUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new MulOvfUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new MulOvfSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new MulOvfDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "MulOvf()";
-        }
-    }
-}

+ 0 - 368
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NegateInstruction.cs

@@ -1,368 +0,0 @@
-// 
-// NegateInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class NegateInstruction : Instruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _Single, _Double;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _SingleLifted, _DoubleLifted;
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        private NegateInstruction() {
-        }
-
-        internal sealed class NegateInt32 : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = ScriptingRuntimeHelpers.Int32ToObject(unchecked(-(Int32)v));
-                return 1;
-            }
-        }
-
-        internal sealed class NegateInt16 : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int16)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int16)unchecked(-v);
-                return 1;
-            }
-        }
-
-        internal sealed class NegateInt64 : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int64)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int64)unchecked(-v);
-                return 1;
-            }
-        }
-
-        internal sealed class NegateUInt16 : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt16)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt16)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateUInt32 : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt32)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt32)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateSingle : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Single)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Single)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateDouble : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Double)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Double)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateInt32Lifted : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int32?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int32?)(unchecked(-v));
-                return 1;
-            }
-        }
-
-        internal sealed class NegateInt16Lifted : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int16?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int16?)unchecked(-v);
-                return 1;
-            }
-        }
-
-        internal sealed class NegateInt64Lifted : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int64?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int64?)unchecked(-v);
-                return 1;
-            }
-        }
-
-        internal sealed class NegateUInt16Lifted : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt16?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt16?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateUInt32Lifted : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt32?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt32?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateSingleLifted : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Single?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Single?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateDoubleLifted : NegateInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Double?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Double?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new NegateInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new NegateInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new NegateInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new NegateUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new NegateUInt32());
-                case TypeCode.Single: return _Single ?? (_Single = new NegateSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new NegateDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new NegateInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new NegateInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new NegateInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new NegateUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new NegateUInt32Lifted());
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new NegateSingleLifted());
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new NegateDoubleLifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Negate()";
-        }
-    }
-
-    internal abstract class NegateOvfInstruction : Instruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _Single, _Double;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _SingleLifted, _DoubleLifted;
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        private NegateOvfInstruction() {
-        }
-
-        internal sealed class NegateOvfInt32 : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int32)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = ScriptingRuntimeHelpers.Int32ToObject(checked(-v));
-                return 1;
-            }
-        }
-
-        internal sealed class NegateOvfInt16 : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int16)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = checked((Int16)(-v));
-                return 1;
-            }
-        }
-
-        internal sealed class NegateOvfInt64 : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int64)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = checked((Int64)(-v));
-                return 1;
-            }
-        }
-
-        internal sealed class NegateOvfUInt16 : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt16)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = checked((UInt16)(-v));
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateOvfUInt32 : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt32)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = checked((UInt32)(-v));
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateOvfSingle : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Single)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Single)checked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateOvfDouble : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Double)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Double)checked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateOvfInt32Lifted : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int32?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int32?)(unchecked(-v));
-                return 1;
-            }
-        }
-
-        internal sealed class NegateOvfInt16Lifted : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int16?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int16?)unchecked(-v);
-                return 1;
-            }
-        }
-
-        internal sealed class NegateOvfInt64Lifted : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int64?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int64?)unchecked(-v);
-                return 1;
-            }
-        }
-
-        internal sealed class NegateOvfUInt16Lifted : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt16?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt16?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateOvfUInt32Lifted : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt32?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt32?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateOvfSingleLifted : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Single?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Single?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        internal sealed class NegateOvfDoubleLifted : NegateOvfInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Double?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Double?)unchecked(-v);
-                return 1;
-
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new NegateOvfInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new NegateOvfInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new NegateOvfInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new NegateOvfUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new NegateOvfUInt32());
-                case TypeCode.Single: return _Single ?? (_Single = new NegateOvfSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new NegateOvfDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new NegateOvfInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new NegateOvfInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new NegateOvfInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new NegateOvfUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new NegateOvfUInt32Lifted());
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new NegateOvfSingleLifted());
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new NegateOvfDoubleLifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "NegateOvf()";
-        }
-    }
-}

+ 0 - 202
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs

@@ -1,202 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class NotEqualInstruction : ComparisonInstruction {
-        // Perf: EqualityComparer<T> but is 3/2 to 2 times slower.
-        private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _String, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
-        private static Instruction _BooleanLifted, _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted,
-            _ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
-
-        private NotEqualInstruction() {
-        }
-
-        protected override object DoNullComparison (object l, object r)
-        {
-            return LiftedToNull ? (object) null : (object) l != r;
-        }
-
-        internal sealed class NotEqualBoolean : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Boolean)l != (Boolean)r;
-            }
-        }
-
-        internal sealed class NotEqualSByte : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (SByte)l != (SByte)r;
-            }
-        }
-
-        internal sealed class NotEqualInt16 : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int16)l != (Int16)r;
-            }
-        }
-
-        internal sealed class NotEqualChar : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Char)l != (Char)r;
-            }
-        }
-
-        internal sealed class NotEqualString : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (String)l != (String)r;
-            }
-        }
-
-        internal sealed class NotEqualInt32 : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int32)l != (Int32)r;
-            }
-        }
-
-        internal sealed class NotEqualInt64 : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Int64)l != (Int64)r;
-            }
-        }
-
-        internal sealed class NotEqualByte : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Byte)l != (Byte)r;
-            }
-        }
-
-        internal sealed class NotEqualUInt16 : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt16)l != (UInt16)r;
-            }
-        }
-
-        internal sealed class NotEqualUInt32 : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt32)l != (UInt32)r;
-            }
-        }
-
-        internal sealed class NotEqualUInt64 : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (UInt64)l != (UInt64)r;
-            }
-        }
-
-        internal sealed class NotEqualSingle : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Single)l != (Single)r;
-            }
-        }
-
-        internal sealed class NotEqualDouble : NotEqualInstruction {
-            protected override object DoCalculate (object l, object r)
-            {
-                return (Double)l != (Double)r;
-            }
-        }
-
-        internal sealed class NotEqualReference : NotEqualInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return l != r;
-            }
-
-            protected override object DoCalculate (object l, object r)
-            {
-                throw Assert.Unreachable;
-            }
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
-        public static Instruction Create(Type type) {
-            // Boxed enums can be unboxed as their underlying types:
-            switch ((type.IsEnum() ? Enum.GetUnderlyingType(type) : type).GetTypeCode()) {
-                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new NotEqualBoolean());
-                case TypeCode.SByte: return _SByte ?? (_SByte = new NotEqualSByte());
-                case TypeCode.Byte: return _Byte ?? (_Byte = new NotEqualByte());
-                case TypeCode.Char: return _Char ?? (_Char = new NotEqualChar());
-                case TypeCode.String: return _String ?? (_String = new NotEqualString());
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new NotEqualInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new NotEqualInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new NotEqualInt64());
-
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new NotEqualInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new NotEqualInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new NotEqualInt64());
-
-                case TypeCode.Single: return _Single ?? (_Single = new NotEqualSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new NotEqualDouble());
-
-                case TypeCode.Object:
-                    if (!type.IsValueType()) {
-                        return _Reference ?? (_Reference = new NotEqualReference());
-                    }
-                    // TODO: Nullable<T>
-                    throw new NotImplementedException();
-
-                default:
-                    throw new NotImplementedException();
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            // Boxed enums can be unboxed as their underlying types:
-            switch ((type.IsEnum() ? Enum.GetUnderlyingType(type) : type).GetTypeCode()) {
-                case TypeCode.Boolean: return _BooleanLifted ?? (_BooleanLifted = new NotEqualBoolean() { LiftedToNull = true });
-                case TypeCode.SByte: return _SByteLifted ?? (_SByteLifted = new NotEqualSByte() { LiftedToNull = true });
-                case TypeCode.Byte: return _ByteLifted ?? (_ByteLifted = new NotEqualByte() { LiftedToNull = true });
-                case TypeCode.Char: return _CharLifted ?? (_CharLifted = new NotEqualChar() { LiftedToNull = true });
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new NotEqualInt16() { LiftedToNull = true });
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new NotEqualInt32() { LiftedToNull = true });
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new NotEqualInt64() { LiftedToNull = true });
-
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new NotEqualInt16() { LiftedToNull = true });
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new NotEqualInt32() { LiftedToNull = true });
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new NotEqualInt64() { LiftedToNull = true });
-
-                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new NotEqualSingle() { LiftedToNull = true });
-                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new NotEqualDouble() { LiftedToNull = true });
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "NotEqual()";
-        }
-    }
-}
-

+ 0 - 191
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotInstruction.cs

@@ -1,191 +0,0 @@
-// 
-// NotInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class NotInstruction : Instruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Boolean;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _BooleanLifted;
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        private NotInstruction() {
-        }
-
-        internal sealed class NotBoolean : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                frame.Push((bool)frame.Pop() ? ScriptingRuntimeHelpers.False : ScriptingRuntimeHelpers.True);
-                return 1;
-            }
-        }
-
-        internal sealed class NotInt32 : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int32)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = ScriptingRuntimeHelpers.Int32ToObject(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotInt16 : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int16)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int16)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotInt64 : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int64)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int64)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotUInt16 : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt64)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt64)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotUInt32 : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt32)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt32)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotUInt64 : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt64)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt64)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotBooleanLifted : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Boolean?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Boolean?)(!v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotInt32Lifted : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int32?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int32?)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotInt16Lifted : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int16?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int16?)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotInt64Lifted : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (Int64?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (Int64?)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotUInt16Lifted : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt64?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt64?)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotUInt32Lifted : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt32?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt32?)(~v);
-                return 1;
-            }
-        }
-
-        internal sealed class NotUInt64Lifted : NotInstruction {
-            public override int Run(InterpretedFrame frame) {
-                var v = (UInt64?)frame.Data[frame.StackIndex - 1];
-                frame.Data[frame.StackIndex - 1] = (UInt64?)(~v);
-                return 1;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new NotInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new NotInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new NotInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new NotUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new NotUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new NotUInt64());
-                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new NotBoolean());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new NotInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new NotInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new NotInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new NotUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new NotUInt32Lifted());
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new NotUInt64Lifted());
-                case TypeCode.Boolean: return _BooleanLifted ?? (_BooleanLifted = new NotBooleanLifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-        public override string ToString() {
-            return "Not()";
-        }
-    }
-}

+ 0 - 254
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NumericConvertInstruction.cs

@@ -1,254 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class NumericConvertInstruction : Instruction {
-        internal readonly TypeCode _from, _to;
-
-        protected NumericConvertInstruction(TypeCode from, TypeCode to) {
-            _from = from;
-            _to = to;
-        }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override string ToString() {
-            return InstructionName + "(" + _from + "->" + _to + ")";
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
-        public sealed class Unchecked : NumericConvertInstruction {
-            public override string InstructionName { get { return "UncheckedConvert"; } }
-
-            public Unchecked(TypeCode from, TypeCode to)
-                : base(from, to) {
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                frame.Push(Convert(frame.Pop()));
-                return +1;
-            }
-
-            private object Convert(object obj) {
-                switch (_from) {
-                    case TypeCode.Byte: return ConvertInt32((Byte)obj);
-                    case TypeCode.SByte: return ConvertInt32((SByte)obj);
-                    case TypeCode.Int16: return ConvertInt32((Int16)obj);
-                    case TypeCode.Char: return ConvertInt32((Char)obj);
-                    case TypeCode.Int32: return ConvertInt32((Int32)obj);
-                    case TypeCode.Int64: return ConvertInt64((Int64)obj);
-                    case TypeCode.UInt16: return ConvertInt32((UInt16)obj);
-                    case TypeCode.UInt32: return ConvertInt64((UInt32)obj);
-                    case TypeCode.UInt64: return ConvertUInt64((UInt64)obj);
-                    case TypeCode.Single: return ConvertDouble((Single)obj);
-                    case TypeCode.Double: return ConvertDouble((Double)obj);
-                    default: throw Assert.Unreachable;
-                }
-            }
-
-            private object ConvertInt32(int obj) {
-                unchecked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-
-            private object ConvertInt64(Int64 obj) {
-                unchecked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-
-            private object ConvertUInt64(UInt64 obj) {
-                unchecked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-
-            private object ConvertDouble(Double obj) {
-                unchecked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
-        public sealed class Checked : NumericConvertInstruction {
-            public override string InstructionName { get { return "CheckedConvert"; } }
-
-            public Checked(TypeCode from, TypeCode to)
-                : base(from, to) {
-            }
-
-            public override int Run(InterpretedFrame frame) {
-                frame.Push(Convert(frame.Pop()));
-                return +1;
-            }
-
-            private object Convert(object obj) {
-                switch (_from) {
-                    case TypeCode.Byte: return ConvertInt32((Byte)obj);
-                    case TypeCode.SByte: return ConvertInt32((SByte)obj);
-                    case TypeCode.Int16: return ConvertInt32((Int16)obj);
-                    case TypeCode.Char: return ConvertInt32((Char)obj);
-                    case TypeCode.Int32: return ConvertInt32((Int32)obj);
-                    case TypeCode.Int64: return ConvertInt64((Int64)obj);
-                    case TypeCode.UInt16: return ConvertInt32((UInt16)obj);
-                    case TypeCode.UInt32: return ConvertInt64((UInt32)obj);
-                    case TypeCode.UInt64: return ConvertUInt64((UInt64)obj);
-                    case TypeCode.Single: return ConvertDouble((Single)obj);
-                    case TypeCode.Double: return ConvertDouble((Double)obj);
-                    default: throw Assert.Unreachable;
-                }
-            }
-
-            private object ConvertInt32(int obj) {
-                checked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-
-            private object ConvertInt64(Int64 obj) {
-                checked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-
-            private object ConvertUInt64(UInt64 obj) {
-                checked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-
-            private object ConvertDouble(Double obj) {
-                checked {
-                    switch (_to) {
-                        case TypeCode.Byte: return (Byte)obj;
-                        case TypeCode.SByte: return (SByte)obj;
-                        case TypeCode.Int16: return (Int16)obj;
-                        case TypeCode.Char: return (Char)obj;
-                        case TypeCode.Int32: return (Int32)obj;
-                        case TypeCode.Int64: return (Int64)obj;
-                        case TypeCode.UInt16: return (UInt16)obj;
-                        case TypeCode.UInt32: return (UInt32)obj;
-                        case TypeCode.UInt64: return (UInt64)obj;
-                        case TypeCode.Single: return (Single)obj;
-                        case TypeCode.Double: return (Double)obj;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-        }
-    }
-}

+ 0 - 176
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs

@@ -1,176 +0,0 @@
-// 
-// OrInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class OrInstruction : ArithmeticInstruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Boolean;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _BooleanLifted;
-
-        private OrInstruction() {
-        }
-
-        internal sealed class OrInt32 : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject((Int32)l | (Int32)r);
-            }
-        }
-
-        internal sealed class OrInt16 : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16)((Int16)l | (Int16)r);
-            }
-        }
-
-        internal sealed class OrInt64 : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)((Int64)l | (Int64)r);
-            }
-        }
-
-        internal sealed class OrUInt16 : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16)((UInt16)l | (UInt16)r);
-            }
-        }
-
-        internal sealed class OrUInt32 : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)((UInt32)l | (UInt32)r);
-            }
-        }
-
-        internal sealed class OrUInt64 : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)((UInt64)l | (UInt64)r);
-            }
-        }
-
-        internal sealed class OrBoolean : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Boolean)((Boolean)l | (Boolean)r);
-            }
-        }
-
-        internal sealed class OrInt32Lifted : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32?)((Int32?)l | (Int32?)r);
-            }
-        }
-
-        internal sealed class OrInt16Lifted : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16?)((Int16?)l | (Int16?)r);
-            }
-        }
-
-        internal sealed class OrInt64Lifted : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64?)((Int64?)l | (Int64?)r);
-            }
-        }
-
-        internal sealed class OrUInt16Lifted : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16?)((Int16?)l | (Int16?)r);
-            }
-        }
-
-        internal sealed class OrUInt32Lifted : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32?)((UInt32?)l | (UInt32?)r);
-            }
-        }
-
-        internal sealed class OrUInt64Lifted : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64?)((UInt64?)l | (UInt64?)r);
-            }
-        }
-
-        internal sealed class OrBooleanLifted : OrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Boolean?)((Boolean?)l | (Boolean?)r);
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new OrInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new OrInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new OrInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new OrUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new OrUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new OrUInt64());
-                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new OrBoolean());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new OrInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new OrInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new OrInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new OrUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new OrUInt32Lifted());
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new OrUInt64Lifted());
-                case TypeCode.Boolean: return _BooleanLifted ?? (_BooleanLifted = new OrBooleanLifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Or()";
-        }
-    }
-}

+ 0 - 160
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs

@@ -1,160 +0,0 @@
-// 
-// ShlInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class ShlInstruction : ArithmeticInstruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted;
-
-        private ShlInstruction() {
-        }
-
-        internal sealed class ShlInt32 : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject((Int32)l << (Int32)r);
-            }
-        }
-
-        internal sealed class ShlInt16 : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32)((Int16)l << (Int32)r);
-            }
-        }
-
-        internal sealed class ShlInt64 : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)((Int64)l << (Int32)r);
-            }
-        }
-
-        internal sealed class ShlUInt16 : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32)((UInt16)l << (Int32)r);
-            }
-        }
-
-        internal sealed class ShlUInt32 : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)((UInt32)l << (Int32)r);
-            }
-        }
-
-        internal sealed class ShlUInt64 : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)((UInt64)l << (Int32)r);
-            }
-        }
-
-        internal sealed class ShlInt32Lifted : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32?)((Int32?)l << (Int32?)r);
-            }
-        }
-
-        internal sealed class ShlInt16Lifted : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32)((Int16?)l << (Int32?)r);
-            }
-        }
-
-        internal sealed class ShlInt64Lifted : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return  (Int64?)((Int64?)l << (Int32?)r);
-            }
-        }
-
-        internal sealed class ShlUInt16Lifted : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32?)((UInt16?)l << (Int32?)r);
-            }
-        }
-
-        internal sealed class ShlUInt32Lifted : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32?)((UInt32?)l << (Int32?)r);
-            }
-        }
-
-        internal sealed class ShlUInt64Lifted : ShlInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64?)((UInt64?)l << (Int32?)r);
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new ShlInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new ShlInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new ShlInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new ShlUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new ShlUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new ShlUInt64());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new ShlInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new ShlInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new ShlInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new ShlUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new ShlUInt32Lifted());
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new ShlUInt64Lifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Shl()";
-        }
-    }
-}

+ 0 - 160
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs

@@ -1,160 +0,0 @@
-// 
-// ShrInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class ShrInstruction : ArithmeticInstruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted;
-
-        private ShrInstruction() {
-        }
-
-        internal sealed class ShrInt32 : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject((Int32)l >> (Int32)r);
-            }
-        }
-
-        internal sealed class ShrInt16 : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32)((Int16)l >> (Int32)r);
-            }
-        }
-
-        internal sealed class ShrInt64 : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)((Int64)l >> (Int32)r);
-            }
-        }
-
-        internal sealed class ShrUInt16 : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32)((UInt16)l >> (Int32)r);
-            }
-        }
-
-        internal sealed class ShrUInt32 : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)((UInt32)l >> (Int32)r);
-            }
-        }
-
-        internal sealed class ShrUInt64 : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)((UInt64)l >> (Int32)r);
-            }
-        }
-
-        internal sealed class ShrInt32Lifted : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32?)((Int32?)l >> (Int32?)r);
-            }
-        }
-
-        internal sealed class ShrInt16Lifted : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32)((Int16?)l >> (Int32?)r);
-            }
-        }
-
-        internal sealed class ShrInt64Lifted : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64?)((Int64?)l >> (Int32?)r);
-            }
-        }
-
-        internal sealed class ShrUInt16Lifted : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32?)((UInt16?)l >> (Int32?)r);
-            }
-        }
-
-        internal sealed class ShrUInt32Lifted : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32?)((UInt32?)l >> (Int32?)r);
-            }
-        }
-
-        internal sealed class ShrUInt64Lifted : ShrInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64?)((UInt64?)l >> (Int32?)r);
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new ShrInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new ShrInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new ShrInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new ShrUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new ShrUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new ShrUInt64());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new ShrInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new ShrInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new ShrInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new ShrUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new ShrUInt32Lifted());
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new ShrUInt64Lifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Shr()";
-        }
-    }
-}

+ 0 - 118
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/StackOperations.cs

@@ -1,118 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System.Collections.Generic;
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Utils;
-namespace Microsoft.Scripting.Interpreter {
-    internal sealed class LoadObjectInstruction : Instruction {
-        private readonly object _value;
-
-        internal LoadObjectInstruction(object value) {
-            _value = value;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex++] = _value;
-            return +1;
-        }
-
-        public override string ToString() {
-            return "LoadObject(" + (_value ?? "null") + ")";
-        }
-    }
-
-    internal sealed class LoadCachedObjectInstruction : Instruction {
-        private readonly uint _index;
-
-        internal LoadCachedObjectInstruction(uint index) {
-            _index = index;
-        }
-
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex++] = frame.Interpreter._objects[_index];
-            return +1;
-        }
-
-        public override string ToDebugString(int instructionIndex, object cookie, Func<int, int> labelIndexer, IList<object> objects) {
-            return String.Format("LoadCached({0}: {1})", _index, objects[(int)_index]);
-        }
-        
-        public override string ToString() {
-            return "LoadCached(" + _index + ")";
-        }
-    }
-
-    internal sealed class PopInstruction : Instruction {
-        internal static readonly PopInstruction Instance = new PopInstruction();
-
-        private PopInstruction() { }
-
-        public override int ConsumedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Pop();
-            return +1;
-        }
-
-        public override string ToString() {
-            return "Pop()";
-        }
-    }
-
-    // NOTE: Consider caching if used frequently
-    internal sealed class PopNInstruction : Instruction {
-        private readonly int _n;
-
-        internal PopNInstruction(int n) {
-            _n = n;
-        }
-
-        public override int ConsumedStack { get { return _n; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Pop(_n);
-            return +1;
-        }
-
-        public override string ToString() {
-            return "Pop(" + _n + ")";
-        }
-    }
-
-    internal sealed class DupInstruction : Instruction {
-        internal readonly static DupInstruction Instance = new DupInstruction();
-
-        private DupInstruction() { }
-
-        public override int ConsumedStack { get { return 0; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Data[frame.StackIndex] = frame.Peek();
-			frame.StackIndex++;
-            return +1;
-        }
-
-        public override string ToString() {
-            return "Dup()";
-        }
-    }
-}

+ 0 - 204
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs

@@ -1,204 +0,0 @@
-// 
-// SubInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class SubInstruction : ArithmeticInstruction {
-
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        private SubInstruction() {
-        }
-
-        internal sealed class SubInt32 : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l - (Int32)r));
-            }
-        }
-
-        internal sealed class SubInt16 : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16)unchecked((Int16)l - (Int16)r);
-            }
-        }
-
-        internal sealed class SubInt64 : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)unchecked((Int64)l - (Int64)r);
-            }
-        }
-
-        internal sealed class SubUInt16 : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16)unchecked((UInt16)l - (UInt16)r);
-            }
-        }
-
-        internal sealed class SubUInt32 : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32)unchecked((UInt32)l - (UInt32)r);
-            }
-        }
-
-        internal sealed class SubUInt64 : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)unchecked((UInt64)l - (UInt64)r);
-            }
-        }
-
-        internal sealed class SubSingle : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Single)((Single)l - (Single)r);
-            }
-        }
-
-        internal sealed class SubDouble : SubInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Double)l - (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new SubInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new SubInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new SubInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new SubUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new SubUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new SubUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new SubSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new SubDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Sub()";
-        }
-    }
-
-    internal abstract class SubOvfInstruction : ArithmeticInstruction {
-
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
-
-        private SubOvfInstruction() {
-        }
-
-        internal sealed class SubOvfInt32 : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject(checked((Int32)l - (Int32)r));
-            }
-        }
-
-        internal sealed class SubOvfInt16 : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((Int16)((Int16)l - (Int16)r));
-            }
-        }
-
-        internal sealed class SubOvfInt64 : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((Int64)((Int64)l - (Int64)r));
-            }
-        }
-
-        internal sealed class SubOvfUInt16 : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt16)((UInt16)l - (UInt16)r));
-            }
-        }
-
-        internal sealed class SubOvfUInt32 : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt32)((UInt32)l - (UInt32)r));
-            }
-        }
-
-        internal sealed class SubOvfUInt64 : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return checked((UInt64)((UInt64)l - (UInt64)r));
-            }
-        }
-
-        internal sealed class SubOvfSingle : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Single)((Single)l - (Single)r);
-            }
-        }
-
-        internal sealed class SubOvfDouble : SubOvfInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Double)l - (Double)r;
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new SubOvfInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new SubOvfInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new SubOvfInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new SubOvfUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new SubOvfUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new SubOvfUInt64());
-                case TypeCode.Single: return _Single ?? (_Single = new SubOvfSingle());
-                case TypeCode.Double: return _Double ?? (_Double = new SubOvfDouble());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "SubOvf()";
-        }
-    }
-}

+ 0 - 193
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/TypeOperations.cs

@@ -1,193 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-using System.Linq;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal sealed class CreateDelegateInstruction : Instruction {
-        private readonly LightDelegateCreator _creator;
-
-        internal CreateDelegateInstruction(LightDelegateCreator delegateCreator) {
-            _creator = delegateCreator;
-        }
-
-        public override int ConsumedStack { get { return _creator.Interpreter.ClosureSize; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            StrongBox<object>[] closure;
-            if (ConsumedStack > 0) {
-                closure = new StrongBox<object>[ConsumedStack];
-                for (int i = closure.Length - 1; i >= 0; i--) {
-                    closure[i] = (StrongBox<object>)frame.Pop();
-                }
-            } else {
-                closure = null;
-            }
-
-            Delegate d = _creator.CreateDelegate(closure);
-
-            frame.Push(d);
-            return +1;
-        }
-    }
-
-    internal sealed class NewInstruction : Instruction {
-        private readonly ConstructorInfo _constructor;
-        private readonly int _argCount;
-
-        public NewInstruction(ConstructorInfo constructor) {
-            _constructor = constructor;
-            _argCount = constructor.GetParameters().Length;
-
-        }
-        public override int ConsumedStack { get { return _argCount; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            object[] args = new object[_argCount];
-            for (int i = _argCount - 1; i >= 0; i--) {
-                args[i] = frame.Pop();
-            }
-
-            object ret;
-            try {
-                ret = _constructor.Invoke(args);
-            } catch (TargetInvocationException e) {
-                ExceptionHelpers.UpdateForRethrow(e.InnerException);
-                throw e.InnerException;
-            }
-
-            frame.Push(ret);
-            return +1;
-        }
-
-        public override string ToString() {
-            return "New " + _constructor.DeclaringType.Name + "(" + _constructor + ")";
-        }
-    }
-
-    internal sealed class DefaultValueInstruction<T> : Instruction {
-        internal DefaultValueInstruction() { }
-
-        public override int ConsumedStack { get { return 0; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            frame.Push(default(T));
-            return +1;
-        }
-
-        public override string ToString() {
-            return "New " + typeof(T);
-        }
-    }
-
-    internal sealed class TypeIsInstruction<T> : Instruction {
-        internal TypeIsInstruction() { }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            // unfortunately Type.IsInstanceOfType() is 35-times slower than "is T" so we use generic code:
-            frame.Push(ScriptingRuntimeHelpers.BooleanToObject(frame.Pop() is T));
-            return +1;
-        }
-
-        public override string ToString() {
-            return "TypeIs " + typeof(T).Name; 
-        }
-    }
-
-    internal sealed class TypeAsInstruction<T> : Instruction {
-        internal TypeAsInstruction() { }
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        public override int Run(InterpretedFrame frame) {
-            // can't use as w/o generic constraint
-            object value = frame.Pop();
-            if (value is T) {
-                frame.Push(value);
-            } else {
-                frame.Push(null);
-            }
-            return +1;
-        }
-
-        public override string ToString() {
-            return "TypeAs " + typeof(T).Name;
-        }
-    }
-
-    internal sealed class TypeEqualsInstruction : Instruction {
-        public static readonly TypeEqualsInstruction Instance = new TypeEqualsInstruction();
-
-        public override int ConsumedStack { get { return 2; } }
-        public override int ProducedStack { get { return 1; } }
-
-        private TypeEqualsInstruction() {
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            object type = frame.Pop();
-            object obj = frame.Pop();
-            frame.Push(ScriptingRuntimeHelpers.BooleanToObject(obj != null && (object)obj.GetType() == type));
-            return +1;
-        }
-
-        public override string InstructionName {
-            get { return "TypeEquals()"; }
-        }
-    }
-
-    internal sealed class WrapToNullableInstruction<T> : Instruction {
-
-        readonly Type elementType;
-        ConstructorInfo ctor;
-
-        public override int ConsumedStack { get { return 1; } }
-        public override int ProducedStack { get { return 1; } }
-
-        internal WrapToNullableInstruction(Type elementType) {
-            this.elementType = elementType;
-        }
-
-        public override int Run(InterpretedFrame frame) {
-            var r = frame.Data[frame.StackIndex - 1];
-
-            // Don't need to wrap null values
-            if (r == null)
-                return 1;
-
-            ctor = typeof (Nullable<>).MakeGenericType (elementType).GetDeclaredConstructors ().First ();
-            frame.Data[frame.StackIndex - 1] = ctor.Invoke (new [] { r });
-            return 1;
-        }
-
-        public override string InstructionName {
-            get { return "WrapTo " + typeof(T) + "?"; }
-        }
-    }
-}

+ 0 - 176
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs

@@ -1,176 +0,0 @@
-// 
-// XorInstruction.cs:
-//
-// Authors: Marek Safar ([email protected])
-//     
-// Copyright 2014 Xamarin Inc
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    internal abstract class XorInstruction : ArithmeticInstruction {
-        private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Boolean;
-        private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _BooleanLifted;
-
-        private XorInstruction() {
-        }
-
-        internal sealed class XorInt32 : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return ScriptingRuntimeHelpers.Int32ToObject((Int32)l ^ (Int32)r);
-            }
-        }
-
-        internal sealed class XorInt16 : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int16)((Int16)l ^ (Int16)r);
-            }
-        }
-
-        internal sealed class XorInt64 : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64)((Int64)l ^ (Int64)r);
-            }
-        }
-
-        internal sealed class XorUInt16 : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16)((UInt16)l ^ (UInt16)r);
-            }
-        }
-
-        internal sealed class XorUInt32 : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return  (UInt32)((UInt32)l ^ (UInt32)r);
-            }
-        }
-
-        internal sealed class XorUInt64 : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64)((UInt64)l ^ (UInt64)r);
-            }
-        }
-
-        internal sealed class XorBoolean : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Boolean)((Boolean)l ^ (Boolean)r);
-            }
-        }
-
-        internal sealed class XorInt32Lifted : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int32?)((Int32?)l ^ (Int32?)r);
-            }
-        }
-
-        internal sealed class XorInt16Lifted : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return  (Int16?)((Int16?)l ^ (Int16?)r);
-            }
-        }
-
-        internal sealed class XorInt64Lifted : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Int64?)((Int64?)l ^ (Int64?)r);
-            }
-        }
-
-        internal sealed class XorUInt16Lifted : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt16?)((UInt16?)l ^ (UInt16?)r);
-            }
-        }
-
-        internal sealed class XorUInt32Lifted : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt32?)((UInt32?)l ^ (UInt32?)r);
-            }
-        }
-
-        internal sealed class XorUInt64Lifted : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (UInt64?)((UInt64?)l ^ (UInt64?)r);
-            }
-        }
-
-        internal sealed class XorBooleanLifted : XorInstruction {
-            protected override object Calculate (object l, object r)
-            {
-                return (Boolean?)((Boolean?)l ^ (Boolean?)r);
-            }
-        }
-
-        public static Instruction Create(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16 ?? (_Int16 = new XorInt16());
-                case TypeCode.Int32: return _Int32 ?? (_Int32 = new XorInt32());
-                case TypeCode.Int64: return _Int64 ?? (_Int64 = new XorInt64());
-                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new XorUInt16());
-                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new XorUInt32());
-                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new XorUInt64());
-                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new XorBoolean());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public static Instruction CreateLifted(Type type) {
-            Debug.Assert(!type.IsEnum());
-            switch (type.GetTypeCode()) {
-                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new XorInt16Lifted());
-                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new XorInt32Lifted());
-                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new XorInt64Lifted());
-                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new XorUInt16Lifted());
-                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new XorUInt32Lifted());
-                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new XorUInt64Lifted());
-                case TypeCode.Boolean: return _BooleanLifted ?? (_BooleanLifted = new XorBooleanLifted());
-
-                default:
-                    throw Assert.Unreachable;
-            }
-        }
-
-        public override string ToString() {
-            return "Xor()";
-        }
-    }
-}

+ 0 - 297
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/InterpretedFrame.cs

@@ -1,297 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Threading;
-using Microsoft.Scripting.Utils;
-using Microsoft.Scripting.Runtime;
-
-namespace Microsoft.Scripting.Interpreter {
-#if CLR45
-    using InterpretedFrameThreadLocal = ThreadLocal<InterpretedFrame>;
-#else
-    using InterpretedFrameThreadLocal = Microsoft.Scripting.Utils.ThreadLocal<InterpretedFrame>;
-#endif
-
-    public sealed class InterpretedFrame {
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
-        public static readonly InterpretedFrameThreadLocal CurrentFrame = new InterpretedFrameThreadLocal();
-
-        internal readonly Interpreter Interpreter;
-        internal InterpretedFrame _parent;
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
-        private int[] _continuations;
-        private int _continuationIndex;
-        private int _pendingContinuation;
-        private object _pendingValue;
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
-        public readonly object[] Data;
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")]
-        public readonly StrongBox<object>[] Closure;
-
-        public int StackIndex;
-        public int InstructionIndex;
-
-        // When a ThreadAbortException is raised from interpreted code this is the first frame that caught it.
-        // No handlers within this handler re-abort the current thread when left.
-        public ExceptionHandler CurrentAbortHandler;
-
-        internal InterpretedFrame(Interpreter interpreter, StrongBox<object>[] closure) {
-            Interpreter = interpreter;
-            StackIndex = interpreter.LocalCount;
-            Data = new object[StackIndex + interpreter.Instructions.MaxStackDepth];
-
-            int c = interpreter.Instructions.MaxContinuationDepth;
-            if (c > 0) {
-                _continuations = new int[c];
-            }
-
-            Closure = closure;
-        }
-
-        public DebugInfo GetDebugInfo(int instructionIndex) {
-            return DebugInfo.GetMatchingDebugInfo(Interpreter._debugInfos, instructionIndex);
-        }
-
-        public string Name {
-            get { return Interpreter._name; }
-        }
-
-        #region Data Stack Operations
-
-        public void Push(object value) {
-            Data[StackIndex++] = value;
-        }
-
-        public void Push(bool value) {
-            Data[StackIndex++] = value ? ScriptingRuntimeHelpers.True : ScriptingRuntimeHelpers.False;
-        }
-
-        public void Push(int value) {
-            Data[StackIndex++] = ScriptingRuntimeHelpers.Int32ToObject(value);
-        }
-
-        public object Pop() {
-            return Data[--StackIndex];
-        }
-
-        public object Pop(int n) {
-            int si = StackIndex - n;
-            StackIndex = si;
-            return Data[si];
-        }
-
-        internal void SetStackDepth(int depth) {
-            StackIndex = Interpreter.LocalCount + depth;
-        }
-
-        public object Peek() {
-            return Data[StackIndex - 1];
-        }
-
-        public void Dup() {
-            int i = StackIndex;
-            Data[i] = Data[i - 1];
-            StackIndex = i + 1;
-        }
-
-        #endregion
-
-        #region Stack Trace
-
-        public InterpretedFrame Parent {
-            get { return _parent; }
-        }
-
-        public static bool IsInterpretedFrame(MethodBase method) {
-            ContractUtils.RequiresNotNull(method, "method");
-            return method.DeclaringType == typeof(Interpreter) && method.Name == "Run";
-        }
-
-#if FEATURE_STACK_TRACE
-        /// <summary>
-        /// A single interpreted frame might be represented by multiple subsequent Interpreter.Run CLR frames.
-        /// This method filters out the duplicate CLR frames.
-        /// </summary>
-        public static IEnumerable<StackFrame> GroupStackFrames(IEnumerable<StackFrame> stackTrace) {
-            bool inInterpretedFrame = false;
-            foreach (StackFrame frame in stackTrace) {
-                if (InterpretedFrame.IsInterpretedFrame(frame.GetMethod())) {
-                    if (inInterpretedFrame) {
-                        continue;
-                    }
-                    inInterpretedFrame = true;
-                } else {
-                    inInterpretedFrame = false;
-                }
-                yield return frame;
-            }
-        }
-#endif
-
-        public IEnumerable<InterpretedFrameInfo> GetStackTraceDebugInfo() {
-            var frame = this;
-            do {
-                yield return new InterpretedFrameInfo(frame.Name, frame.GetDebugInfo(frame.InstructionIndex));
-                frame = frame.Parent;
-            } while (frame != null);
-        }
-
-        internal void SaveTraceToException(Exception exception) {
-            if (exception.GetData(typeof(InterpretedFrameInfo)) == null) {
-                exception.SetData(typeof(InterpretedFrameInfo), new List<InterpretedFrameInfo>(GetStackTraceDebugInfo()).ToArray());
-            }
-        }
-
-        public static InterpretedFrameInfo[] GetExceptionStackTrace(Exception exception) {
-            return exception.GetData(typeof(InterpretedFrameInfo)) as InterpretedFrameInfo[];
-        }
-
-#if DEBUG
-        internal string[] Trace {
-            get {
-                var trace = new List<string>();
-                var frame = this;
-                do {
-                    trace.Add(frame.Name);
-                    frame = frame.Parent;
-                } while (frame != null);
-                return trace.ToArray();
-            }
-        }
-#endif
-
-#if CLR45
-        internal InterpretedFrameThreadLocal Enter() {
-            var currentFrame = InterpretedFrame.CurrentFrame;
-            _parent = currentFrame.Value;
-            currentFrame.Value = this;
-            return currentFrame;
-        }
-
-        internal void Leave(InterpretedFrameThreadLocal currentFrame) {
-            currentFrame.Value = _parent;
-        }
-#else
-        internal InterpretedFrameThreadLocal.StorageInfo Enter() {
-            var currentFrame = InterpretedFrame.CurrentFrame.GetStorageInfo();
-            _parent = currentFrame.Value;
-            currentFrame.Value = this;
-            return currentFrame;
-        }
-
-        internal void Leave(InterpretedFrameThreadLocal.StorageInfo currentFrame) {
-            currentFrame.Value = _parent;
-        }
-#endif
-        #endregion
-
-        #region Continuations
-
-        public void RemoveContinuation() {
-            _continuationIndex--;
-        }
-
-        public void PushContinuation(int continuation) {
-            _continuations[_continuationIndex++] = continuation;
-        }
-
-        public int YieldToCurrentContinuation() {
-            var target = Interpreter._labels[_continuations[_continuationIndex - 1]];
-            SetStackDepth(target.StackDepth);
-            return target.Index - InstructionIndex;
-        }
-
-        public int YieldToPendingContinuation() {
-            Debug.Assert(_pendingContinuation >= 0);
-
-            RuntimeLabel pendingTarget = Interpreter._labels[_pendingContinuation];
-
-            // the current continuation might have higher priority (continuationIndex is the depth of the current continuation):
-            if (pendingTarget.ContinuationStackDepth < _continuationIndex) {
-                RuntimeLabel currentTarget = Interpreter._labels[_continuations[_continuationIndex - 1]];
-                SetStackDepth(currentTarget.StackDepth);
-                return currentTarget.Index - InstructionIndex;
-            }
-
-            SetStackDepth(pendingTarget.StackDepth);
-            if (_pendingValue != Interpreter.NoValue) {
-                Data[StackIndex - 1] = _pendingValue;
-            }
-            return pendingTarget.Index - InstructionIndex;
-        }
-
-        internal void PushPendingContinuation() {
-            Push(_pendingContinuation);
-            Push(_pendingValue);
-#if DEBUG
-            _pendingContinuation = -1;
-#endif
-        }
-
-        internal void PopPendingContinuation() {
-            _pendingValue = Pop();
-            _pendingContinuation = (int)Pop();
-        }
-
-        private static MethodInfo _Goto;
-        private static MethodInfo _VoidGoto;
-
-        internal static MethodInfo GotoMethod {
-            get { return _Goto ?? (_Goto = typeof(InterpretedFrame).GetMethod("Goto")); }
-        }
-
-        internal static MethodInfo VoidGotoMethod {
-            get { return _VoidGoto ?? (_VoidGoto = typeof(InterpretedFrame).GetMethod("VoidGoto")); }
-        }
-
-        public int VoidGoto(int labelIndex) {
-            return Goto(labelIndex, Interpreter.NoValue);
-        }
-
-        public int Goto(int labelIndex, object value) {
-            // TODO: we know this at compile time (except for compiled loop):
-            RuntimeLabel target = Interpreter._labels[labelIndex];
-            if (_continuationIndex == target.ContinuationStackDepth) {
-                SetStackDepth(target.StackDepth);
-                if (value != Interpreter.NoValue) {
-                    Data[StackIndex - 1] = value;
-                }
-                return target.Index - InstructionIndex;
-            }
-
-            // if we are in the middle of executing jump we forget the previous target and replace it by a new one:
-            _pendingContinuation = labelIndex;
-            _pendingValue = value;
-            return YieldToCurrentContinuation();
-        }
-
-        #endregion
-
-    }
-}

+ 0 - 262
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs

@@ -1,262 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Threading;
-
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-using System.Diagnostics;
-using System.Collections.Generic;
-
-namespace Microsoft.Scripting.Interpreter {
-    /// <summary>
-    /// A simple forth-style stack machine for executing Expression trees
-    /// without the need to compile to IL and then invoke the JIT.  This trades
-    /// off much faster compilation time for a slower execution performance.
-    /// For code that is only run a small number of times this can be a 
-    /// sweet spot.
-    /// 
-    /// The core loop in the interpreter is the RunInstructions method.
-    /// </summary>
-    internal sealed class Interpreter {
-        internal static readonly object NoValue = new object();
-        internal const int RethrowOnReturn = Int32.MaxValue;
-
-        // zero: sync compilation
-        // negative: default
-        internal readonly int _compilationThreshold;
-
-        private readonly int _localCount;
-        private readonly HybridReferenceDictionary<LabelTarget, BranchLabel> _labelMapping;
-        private readonly Dictionary<ParameterExpression, LocalVariable> _closureVariables;
-
-        private readonly InstructionArray _instructions;
-        internal readonly object[] _objects;
-        internal readonly RuntimeLabel[] _labels;
-
-        internal readonly string _name;
-        private readonly ExceptionHandler[] _handlers;
-        internal readonly DebugInfo[] _debugInfos;
-
-        internal Interpreter(string name, LocalVariables locals, HybridReferenceDictionary<LabelTarget, BranchLabel> labelMapping,
-            InstructionArray instructions, ExceptionHandler[] handlers, DebugInfo[] debugInfos, int compilationThreshold) {
-
-            _name = name;
-            _localCount = locals.LocalCount;
-            _closureVariables = locals.ClosureVariables;
-
-            _instructions = instructions;
-            _objects = instructions.Objects;
-            _labels = instructions.Labels;
-            _labelMapping = labelMapping;
-
-            _handlers = handlers;
-            _debugInfos = debugInfos;
-            _compilationThreshold = compilationThreshold;
-        }
-
-        internal int ClosureSize {
-            get {
-                if (_closureVariables == null) {
-                    return 0;
-                }
-                return _closureVariables.Count;
-            }
-        }
-
-        internal int LocalCount {
-            get {
-                return _localCount;
-            }
-        }
-
-        internal bool CompileSynchronously {
-            get { return _compilationThreshold <= 1; }
-        }
-
-        internal InstructionArray Instructions {
-            get { return _instructions; }
-        }
-
-        internal Dictionary<ParameterExpression, LocalVariable> ClosureVariables {
-            get { return _closureVariables; } 
-        }
-
-        internal HybridReferenceDictionary<LabelTarget, BranchLabel> LabelMapping {
-            get { return _labelMapping; }
-        }
-
-        /// <summary>
-        /// Runs instructions within the given frame.
-        /// </summary>
-        /// <remarks>
-        /// Interpreted stack frames are linked via Parent reference so that each CLR frame of this method corresponds 
-        /// to an interpreted stack frame in the chain. It is therefore possible to combine CLR stack traces with 
-        /// interpreted stack traces by aligning interpreted frames to the frames of this method.
-        /// Each group of subsequent frames of Run method corresponds to a single interpreted frame.
-        /// </remarks>
-        [SpecialName, MethodImpl(MethodImplOptions.NoInlining)]
-        public void Run(InterpretedFrame frame) {
-            while (true) {
-                try {
-                    var instructions = _instructions.Instructions;
-                    int index = frame.InstructionIndex;
-                    while (index < instructions.Length) {
-                        index += instructions[index].Run(frame);
-                        frame.InstructionIndex = index;
-                    }
-                    return;
-                } catch (Exception exception) {
-                    switch (HandleException(frame, exception)) {
-                        case ExceptionHandlingResult.Rethrow: throw;
-                        case ExceptionHandlingResult.Continue: continue;
-                        case ExceptionHandlingResult.Return: return;
-                    }
-                }
-            }
-        }
-
-        private ExceptionHandlingResult HandleException(InterpretedFrame frame, Exception exception) {
-            frame.SaveTraceToException(exception);
-            ExceptionHandler handler;
-            frame.InstructionIndex += GotoHandler(frame, exception, out handler);
-
-            if (handler == null || handler.IsFault) {
-                // run finally/fault blocks:
-                Run(frame);
-
-                // a finally block can throw an exception caught by a handler, which cancels the previous exception:
-                if (frame.InstructionIndex == RethrowOnReturn) {
-                    return ExceptionHandlingResult.Rethrow;
-                }
-                return ExceptionHandlingResult.Return;
-            }
-            
-#if FEATURE_THREAD
-            // stay in the current catch so that ThreadAbortException is not rethrown by CLR:
-            var abort = exception as ThreadAbortException;
-            if (abort != null) {
-                _anyAbortException = abort;
-                frame.CurrentAbortHandler = handler;
-            }
-#endif
-            while (true) {
-                try {
-                    var instructions = _instructions.Instructions;
-                    int index = frame.InstructionIndex;
-
-                    while (index < instructions.Length) {
-                        var curInstr = instructions[index];                        
-
-                        index += curInstr.Run(frame);
-                        frame.InstructionIndex = index;
-                        
-                        if (curInstr is LeaveExceptionHandlerInstruction) {
-                            // we've completed handling of this exception
-                            return ExceptionHandlingResult.Continue;
-                        }
-                    }
-
-                    if (frame.InstructionIndex == RethrowOnReturn) {
-                        return ExceptionHandlingResult.Rethrow;
-                    }
-
-                    return ExceptionHandlingResult.Return;
-                } catch (Exception nestedException) {                    
-                    switch (HandleException(frame, nestedException)) {
-                        case ExceptionHandlingResult.Rethrow: throw;
-                        case ExceptionHandlingResult.Continue: continue;
-                        case ExceptionHandlingResult.Return: return ExceptionHandlingResult.Return;
-                        default: throw Assert.Unreachable;
-                    }
-                }
-            }
-        }
-
-        enum ExceptionHandlingResult {
-            Rethrow,
-            Continue,
-            Return
-        }
-
-#if FEATURE_THREAD
-        // To get to the current AbortReason object on Thread.CurrentThread 
-        // we need to use ExceptionState property of any ThreadAbortException instance.
-        [ThreadStatic]
-        private static ThreadAbortException _anyAbortException = null;
-
-        internal static void AbortThreadIfRequested(InterpretedFrame frame, int targetLabelIndex) {
-            var abortHandler = frame.CurrentAbortHandler;
-            if (abortHandler != null && !abortHandler.IsInside(frame.Interpreter._labels[targetLabelIndex].Index)) {
-                frame.CurrentAbortHandler = null;
-
-                var currentThread = Thread.CurrentThread;
-                if ((currentThread.ThreadState & System.Threading.ThreadState.AbortRequested) != 0) {
-                    Debug.Assert(_anyAbortException != null);
-
-#if FEATURE_EXCEPTION_STATE
-                    // The current abort reason needs to be preserved.
-                    currentThread.Abort(_anyAbortException.ExceptionState);
-#else
-                    currentThread.Abort();
-#endif
-                }
-            }
-        }
-#else
-        internal static void AbortThreadIfRequested(InterpretedFrame frame, int targetLabelIndex) {
-            // nop
-        }
-#endif
-
-        internal ExceptionHandler GetBestHandler(int instructionIndex, Type exceptionType) {
-            ExceptionHandler best = null;
-            foreach (var handler in _handlers) {
-                if (handler.Matches(exceptionType, instructionIndex)) {
-                    if (handler.IsBetterThan(best)) {
-                        best = handler;
-                    }
-                }
-            }
-            return best;
-        }
-
-        internal int ReturnAndRethrowLabelIndex {
-            get {
-                // the last label is "return and rethrow" label:
-                Debug.Assert(_labels[_labels.Length - 1].Index == RethrowOnReturn);
-                return _labels.Length - 1;
-            }
-        }
-
-        internal int GotoHandler(InterpretedFrame frame, object exception, out ExceptionHandler handler) {
-            handler = GetBestHandler(frame.InstructionIndex, exception.GetType());
-            if (handler == null) {
-                return frame.Goto(ReturnAndRethrowLabelIndex, Interpreter.NoValue);
-            } else {
-                return frame.Goto(handler.LabelIndex, exception);
-            }
-        }
-    }
-}

+ 0 - 1736
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs

@@ -1,1736 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-using Microsoft.Scripting.Ast;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-#if FEATURE_REFEMIT
-using System.Reflection.Emit;
-#endif
-
-using AstUtils = Microsoft.Scripting.Ast.Utils;
-using Microsoft.Scripting.Utils;
-using Microsoft.Scripting.Runtime;
-using System.Security;
-
-namespace Microsoft.Scripting.Interpreter {
-    public sealed class ExceptionHandler {
-        public readonly Type ExceptionType;
-        public readonly int StartIndex;
-        public readonly int EndIndex;
-        public readonly int LabelIndex;
-        public readonly int HandlerStartIndex;
-
-        public bool IsFault { get { return ExceptionType == null; } }
-
-        internal ExceptionHandler(int start, int end, int labelIndex, int handlerStartIndex, Type exceptionType) {
-            StartIndex = start;
-            EndIndex = end;
-            LabelIndex = labelIndex;
-            ExceptionType = exceptionType;
-            HandlerStartIndex = handlerStartIndex;
-        }
-
-        public bool Matches(Type exceptionType, int index) {
-            if (index >= StartIndex && index < EndIndex) {
-                if (ExceptionType == null || ExceptionType.IsAssignableFrom(exceptionType)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
-        public bool IsBetterThan(ExceptionHandler other) {
-            if (other == null) return true;
-
-            if (StartIndex == other.StartIndex && EndIndex == other.EndIndex) {
-                return HandlerStartIndex < other.HandlerStartIndex;
-            }
-
-            if (StartIndex > other.StartIndex) {
-                Debug.Assert(EndIndex <= other.EndIndex);
-                return true;
-            } else if (EndIndex < other.EndIndex) {
-                Debug.Assert(StartIndex == other.StartIndex);
-                return true;
-            } else {
-                return false;
-            }
-        }
-
-        internal bool IsInside(int index) {
-            return index >= StartIndex && index < EndIndex;
-        }
-
-        public override string ToString() {
-            return String.Format("{0} [{1}-{2}] [{3}->]",
-                (IsFault ? "fault" : "catch(" + ExceptionType.Name + ")"),
-                StartIndex, EndIndex,
-                HandlerStartIndex
-            );
-        }
-    }
-
-    [Serializable]
-    public class DebugInfo {
-        // TODO: readonly
-
-        public int StartLine, EndLine;
-        public int Index;
-        public string FileName;
-        public bool IsClear;
-        private static readonly DebugInfoComparer _debugComparer = new DebugInfoComparer();
-
-        private class DebugInfoComparer : IComparer<DebugInfo> {
-            //We allow comparison between int and DebugInfo here
-            int IComparer<DebugInfo>.Compare(DebugInfo d1, DebugInfo d2) {
-                if (d1.Index > d2.Index) return 1;
-                else if (d1.Index == d2.Index) return 0;
-                else return -1;
-            }
-        }
-        
-        public static DebugInfo GetMatchingDebugInfo(DebugInfo[] debugInfos, int index) {
-            //Create a faked DebugInfo to do the search
-            DebugInfo d = new DebugInfo { Index = index };
-
-            //to find the closest debug info before the current index
-
-            int i = Array.BinarySearch<DebugInfo>(debugInfos, d, _debugComparer);
-            if (i < 0) {
-                //~i is the index for the first bigger element
-                //if there is no bigger element, ~i is the length of the array
-                i = ~i;
-                if (i == 0) {
-                    return null;
-                }
-                //return the last one that is smaller
-                i = i - 1;
-            }
-
-            return debugInfos[i];
-        }
-
-        public override string ToString() {
-            if (IsClear) {
-                return String.Format("{0}: clear", Index);
-            } else {
-                return String.Format("{0}: [{1}-{2}] '{3}'", Index, StartLine, EndLine, FileName);
-            }
-        }
-    }
-
-    // TODO:
-    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")]
-    [Serializable]
-    public struct InterpretedFrameInfo {
-        public readonly string MethodName;
-        
-        // TODO:
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
-        public readonly DebugInfo DebugInfo;
-
-        public InterpretedFrameInfo(string methodName, DebugInfo info) {
-            MethodName = methodName;
-            DebugInfo = info;
-        }
-
-        public override string ToString() {
-            return MethodName + (DebugInfo != null ? ": " + DebugInfo.ToString() : null);
-        }
-    }
-
-    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
-    public sealed class LightCompiler {
-        internal const int DefaultCompilationThreshold = 32;
-
-        // zero: sync compilation
-        private readonly int _compilationThreshold;
-
-        private readonly InstructionList _instructions;
-        private readonly LocalVariables _locals = new LocalVariables();
-
-        private readonly List<ExceptionHandler> _handlers = new List<ExceptionHandler>();
-        
-        private readonly List<DebugInfo> _debugInfos = new List<DebugInfo>();
-        private readonly HybridReferenceDictionary<LabelTarget, LabelInfo> _treeLabels = new HybridReferenceDictionary<LabelTarget, LabelInfo>();
-        private LabelScopeInfo _labelBlock = new LabelScopeInfo(null, LabelScopeKind.Lambda);
-
-        private readonly Stack<ParameterExpression> _exceptionForRethrowStack = new Stack<ParameterExpression>();
-
-        // Set to true to force compiliation of this lambda.
-        // This disables the interpreter for this lambda. We still need to
-        // walk it, however, to resolve variables closed over from the parent
-        // lambdas (because they may be interpreted).
-        private bool _forceCompile;
-
-        private readonly LightCompiler _parent;
-
-        private static LocalDefinition[] EmptyLocals = new LocalDefinition[0];
-
-        internal LightCompiler(int compilationThreshold) {
-            _instructions = new InstructionList();
-            _compilationThreshold = compilationThreshold < 0 ? DefaultCompilationThreshold : compilationThreshold;
-        }
-
-        private LightCompiler(LightCompiler parent)
-            : this(parent._compilationThreshold) {
-            _parent = parent;
-        }
-
-        public InstructionList Instructions {
-            get { return _instructions; }
-        }
-
-        public LocalVariables Locals {
-            get { return _locals; }
-        }
-
-        internal static Expression Unbox(Expression strongBoxExpression) {
-            return Expression.Field(strongBoxExpression, typeof(StrongBox<object>).GetDeclaredField("Value"));
-        }
-
-        internal LightDelegateCreator CompileTop(LambdaExpression node) {
-            foreach (var p in node.Parameters) {
-                var local = _locals.DefineLocal(p, 0);
-                _instructions.EmitInitializeParameter(local.Index);
-            }
-
-            Compile(node.Body);
-            
-            // pop the result of the last expression:
-            if (node.Body.Type != typeof(void) && node.ReturnType == typeof(void)) {
-                _instructions.EmitPop();
-            }
-
-            Debug.Assert(_instructions.CurrentStackDepth == (node.ReturnType != typeof(void) ? 1 : 0));
-
-            return new LightDelegateCreator(MakeInterpreter(node.Name), node);
-        }
-
-        internal LightDelegateCreator CompileTop(LightLambdaExpression node) {
-            foreach (var p in node.Parameters) {
-                var local = _locals.DefineLocal(p, 0);
-                _instructions.EmitInitializeParameter(local.Index);
-            }
-
-            Compile(node.Body);
-
-            // pop the result of the last expression:
-            if (node.Body.Type != typeof(void) && node.ReturnType == typeof(void)) {
-                _instructions.EmitPop();
-            }
-
-            Debug.Assert(_instructions.CurrentStackDepth == (node.ReturnType != typeof(void) ? 1 : 0));
-
-            return new LightDelegateCreator(MakeInterpreter(node.Name), node);
-        }
-
-        private Interpreter MakeInterpreter(string lambdaName) {
-            if (_forceCompile) {
-                return null;
-            }
-
-            var handlers = _handlers.ToArray();
-            var debugInfos = _debugInfos.ToArray();
-
-            return new Interpreter(lambdaName, _locals, GetBranchMapping(), _instructions.ToArray(), handlers, debugInfos, _compilationThreshold);
-        }
-
-
-        private void CompileConstantExpression(Expression expr) {
-            var node = (ConstantExpression)expr;
-            _instructions.EmitLoad(node.Value, node.Type);
-        }
-
-        private void CompileDefaultExpression(Expression expr) {
-            CompileDefaultExpression(expr.Type);
-        }
-
-        private void CompileDefaultExpression(Type type) {
-            if (type != typeof(void)) {
-                if (type.IsValueType()) {
-                    object value = ScriptingRuntimeHelpers.GetPrimitiveDefaultValue(type);
-                    if (value != null) {
-                        _instructions.EmitLoad(value);
-                    } else {
-                        _instructions.EmitDefaultValue(type);
-                    }
-                } else {
-                    _instructions.EmitLoad(null);
-                }
-            }
-        }
-
-        private LocalVariable EnsureAvailableForClosure(ParameterExpression expr) {
-            LocalVariable local;
-            if (_locals.TryGetLocalOrClosure(expr, out local)) {
-                if (!local.InClosure && !local.IsBoxed) {
-                    _locals.Box(expr, _instructions);
-                }
-                return local;
-            } else if (_parent != null) {
-                _parent.EnsureAvailableForClosure(expr);
-                return _locals.AddClosureVariable(expr);
-            } else {
-                throw new InvalidOperationException("unbound variable: " + expr);
-            }
-        }
-
-        private void EnsureVariable(ParameterExpression variable) {
-            if (!_locals.ContainsVariable(variable)) {
-                EnsureAvailableForClosure(variable);
-            }
-        }
-
-        private LocalVariable ResolveLocal(ParameterExpression variable) {
-            LocalVariable local;
-            if (!_locals.TryGetLocalOrClosure(variable, out local)) {
-                local = EnsureAvailableForClosure(variable);
-            }
-            return local;
-        }
-
-        public void CompileGetVariable(ParameterExpression variable) {
-            LocalVariable local = ResolveLocal(variable);
-
-            if (local.InClosure) {
-                _instructions.EmitLoadLocalFromClosure(local.Index);
-            } else if (local.IsBoxed) {
-                _instructions.EmitLoadLocalBoxed(local.Index);
-            } else {
-                _instructions.EmitLoadLocal(local.Index);
-            }
-
-            _instructions.SetDebugCookie(variable.Name);
-        }
-
-        public void CompileGetBoxedVariable(ParameterExpression variable) {
-            LocalVariable local = ResolveLocal(variable);
-
-            if (local.InClosure) {
-                _instructions.EmitLoadLocalFromClosureBoxed(local.Index);
-            } else {
-                Debug.Assert(local.IsBoxed);
-                _instructions.EmitLoadLocal(local.Index);
-            }
-
-            _instructions.SetDebugCookie(variable.Name);
-        }
-
-        public void CompileSetVariable(ParameterExpression variable, bool isVoid) {
-            LocalVariable local = ResolveLocal(variable);
-
-            if (local.InClosure) {
-                if (isVoid) {
-                    _instructions.EmitStoreLocalToClosure(local.Index);
-                } else {
-                    _instructions.EmitAssignLocalToClosure(local.Index);
-                }
-            } else if (local.IsBoxed) {
-                if (isVoid) {
-                    _instructions.EmitStoreLocalBoxed(local.Index);
-                } else {
-                    _instructions.EmitAssignLocalBoxed(local.Index);
-                }
-            } else {
-                if (isVoid) {
-                    _instructions.EmitStoreLocal(local.Index);
-                } else {
-                    _instructions.EmitAssignLocal(local.Index);
-                }
-            }
-
-            _instructions.SetDebugCookie(variable.Name);
-        }
-
-        public void CompileParameterExpression(Expression expr) {
-            var node = (ParameterExpression)expr;
-            CompileGetVariable(node);
-        }
-
-        private void CompileBlockExpression(Expression expr, bool asVoid) {
-            var node = (BlockExpression)expr;
-            var end = CompileBlockStart(node);
-
-            var lastExpression = node.Expressions[node.Expressions.Count - 1];
-            Compile(lastExpression, asVoid);
-            CompileBlockEnd(end);
-        }
-
-        private LocalDefinition[] CompileBlockStart(BlockExpression node) {
-            var start = _instructions.Count;
-            
-            LocalDefinition[] locals;
-            var variables = node.Variables;
-            if (variables.Count != 0) {
-                // TODO: basic flow analysis so we don't have to initialize all
-                // variables.
-                locals = new LocalDefinition[variables.Count];
-                int localCnt = 0;
-                foreach (var variable in variables) {
-                    var local = _locals.DefineLocal(variable, start);
-                    locals[localCnt++] = local;
-
-                    _instructions.EmitInitializeLocal(local.Index, variable.Type);
-                    _instructions.SetDebugCookie(variable.Name);
-                }
-            } else {
-                locals = EmptyLocals;
-            }
-
-            for (int i = 0; i < node.Expressions.Count - 1; i++) {
-                CompileAsVoid(node.Expressions[i]);
-            }
-            return locals;
-        }
-
-        private void CompileBlockEnd(LocalDefinition[] locals) {
-            foreach (var local in locals) {
-                _locals.UndefineLocal(local, _instructions.Count);
-            }
-        }
-
-        private void CompileIndexExpression(Expression expr) {
-            var index = (IndexExpression)expr;
-
-            // instance:
-            if (index.Object != null) {
-                Compile(index.Object);
-            }
-
-            // indexes, byref args not allowed.
-            foreach (var arg in index.Arguments) {
-                Compile(arg);
-            }
-
-            if (index.Indexer != null) {
-                EmitCall(index.Indexer.GetGetMethod(true));
-            } else if (index.Arguments.Count != 1) {
-                EmitCall(index.Object.Type.GetMethod("Get", BindingFlags.Public | BindingFlags.Instance));
-            } else {
-                _instructions.EmitGetArrayItem(index.Object.Type);
-            }
-        }
-
-        private void CompileIndexAssignment(BinaryExpression node, bool asVoid) {
-            var index = (IndexExpression)node.Left;
-
-            if (!asVoid) {
-                throw new NotImplementedException();
-            }
-
-            // instance:
-            if (index.Object != null) {
-                Compile(index.Object);
-            }
-
-            // indexes, byref args not allowed.
-            foreach (var arg in index.Arguments) {
-                Compile(arg);
-            }
-
-            // value:
-            Compile(node.Right);
-
-            if (index.Indexer != null) {
-                EmitCall(index.Indexer.GetSetMethod(true));
-            } else if (index.Arguments.Count != 1) {
-                EmitCall(index.Object.Type.GetMethod("Set", BindingFlags.Public | BindingFlags.Instance));
-            } else {
-                _instructions.EmitSetArrayItem(index.Object.Type);
-            }
-        }
-
-        private void CompileMemberAssignment(BinaryExpression node, bool asVoid) {
-            var member = (MemberExpression)node.Left;
-
-            PropertyInfo pi = member.Member as PropertyInfo;
-            if (pi != null) {
-                var method = pi.GetSetMethod(true);
-                Compile(member.Expression);
-                Compile(node.Right);
-
-                int start = _instructions.Count;
-                if (!asVoid) {
-                    LocalDefinition local = _locals.DefineLocal(Expression.Parameter(node.Right.Type), start);
-                    _instructions.EmitAssignLocal(local.Index);
-                    EmitCall(method);
-                    _instructions.EmitLoadLocal(local.Index);
-                    _locals.UndefineLocal(local, _instructions.Count);
-                } else {
-                    EmitCall(method);
-                }
-                return;
-            }
-
-            FieldInfo fi = member.Member as FieldInfo;
-            if (fi != null) {
-                if (member.Expression != null) {
-                    Compile(member.Expression);
-                }
-                Compile(node.Right);
-
-                int start = _instructions.Count;
-                if (!asVoid) {
-                    LocalDefinition local = _locals.DefineLocal(Expression.Parameter(node.Right.Type), start);
-                    _instructions.EmitAssignLocal(local.Index);
-                    _instructions.EmitStoreField(fi);
-                    _instructions.EmitLoadLocal(local.Index);
-                    _locals.UndefineLocal(local, _instructions.Count);
-                } else {
-                    _instructions.EmitStoreField(fi);
-                }
-                return;
-            }
-
-            throw new NotImplementedException();
-        }
-
-        private void CompileVariableAssignment(BinaryExpression node, bool asVoid) {
-            this.Compile(node.Right);
-
-            var target = (ParameterExpression)node.Left;
-            CompileSetVariable(target, asVoid);
-        }
-
-        private void CompileAssignBinaryExpression(Expression expr, bool asVoid) {
-            var node = (BinaryExpression)expr;
-
-            switch (node.Left.NodeType) {
-                case ExpressionType.Index:
-                    CompileIndexAssignment(node, asVoid); 
-                    break;
-
-                case ExpressionType.MemberAccess:
-                    CompileMemberAssignment(node, asVoid); 
-                    break;
-
-                case ExpressionType.Parameter:
-                case ExpressionType.Extension:
-                    CompileVariableAssignment(node, asVoid); 
-                    break;
-
-                default:
-                    throw new InvalidOperationException("Invalid lvalue for assignment: " + node.Left.NodeType);
-            }
-        }
-
-        private void CompileBinaryExpression(Expression expr) {
-            var node = (BinaryExpression)expr;
-
-            if (node.Method != null) {
-                Compile(node.Left);
-                Compile(node.Right);
-                EmitCall(node.Method);
-            } else {
-                switch (node.NodeType) {
-                    case ExpressionType.ArrayIndex:
-                        Debug.Assert(node.Right.Type == typeof(int));
-                        Compile(node.Left);
-                        Compile(node.Right);
-                        _instructions.EmitGetArrayItem(node.Left.Type);
-                        return;
-
-                    case ExpressionType.Add:
-                    case ExpressionType.AddChecked:
-                    case ExpressionType.Subtract:
-                    case ExpressionType.SubtractChecked:
-                    case ExpressionType.Multiply:
-                    case ExpressionType.MultiplyChecked:
-                    case ExpressionType.Divide:
-                    case ExpressionType.Modulo:
-                        CompileArithmetic(node.NodeType, node.Left, node.Right);
-                        return;
-
-                    case ExpressionType.Equal:
-                        CompileEqual(node.Left, node.Right, node.IsLiftedToNull);
-                        return;
-
-                    case ExpressionType.NotEqual:
-                        CompileNotEqual(node.Left, node.Right, node.IsLiftedToNull);
-                        return;
-
-                    case ExpressionType.LessThan:
-                    case ExpressionType.LessThanOrEqual:
-                    case ExpressionType.GreaterThan:
-                    case ExpressionType.GreaterThanOrEqual:
-						CompileComparison(node.NodeType, node.Left, node.Right, node.IsLiftedToNull);
-                        return;
-
-                    case ExpressionType.LeftShift:
-                    case ExpressionType.RightShift:
-                        CompileShift(node.NodeType, node.Left, node.Right, node.IsLifted);
-                        return;
-
-                    case ExpressionType.And:
-                    case ExpressionType.Or:
-                    case ExpressionType.ExclusiveOr:
-                        CompileLogical(node.NodeType, node.Left, node.Right, node.IsLifted);
-                        return;
-
-                    default:
-                        throw new NotImplementedException(node.NodeType.ToString());
-                }
-            }
-        }
-
-        private void CompileEqual(Expression left, Expression right, bool liftedResult) {
-            Debug.Assert(left.Type == right.Type || !left.Type.IsValueType() && !right.Type.IsValueType());
-            Compile(left);
-            Compile(right);
-            _instructions.EmitEqual(left.Type, liftedResult);
-        }
-
-        private void CompileNotEqual(Expression left, Expression right, bool liftedResult) {
-            Debug.Assert(left.Type == right.Type || !left.Type.IsValueType() && !right.Type.IsValueType());
-            Compile(left);
-            Compile(right);
-            _instructions.EmitNotEqual(left.Type, liftedResult);
-        }
-
-		private void CompileComparison(ExpressionType nodeType, Expression left, Expression right, bool liftedResult) {
-            Debug.Assert(left.Type == right.Type && TypeUtils.IsNumeric(left.Type));
-
-            Compile(left);
-            Compile(right);
-            
-            switch (nodeType) {
-                case ExpressionType.LessThan: _instructions.EmitLessThan(left.Type, liftedResult); break;
-                case ExpressionType.LessThanOrEqual: _instructions.EmitLessThanOrEqual(left.Type, liftedResult); break;
-                case ExpressionType.GreaterThan: _instructions.EmitGreaterThan(left.Type, liftedResult); break;
-                case ExpressionType.GreaterThanOrEqual: _instructions.EmitGreaterThanOrEqual(left.Type, liftedResult); break;
-                default: throw Assert.Unreachable;
-            }
-        }
-
-        private void CompileArithmetic(ExpressionType nodeType, Expression left, Expression right) {
-            Debug.Assert(left.Type == right.Type && TypeUtils.IsArithmetic(left.Type));
-            Compile(left);
-            Compile(right);
-            switch (nodeType) {
-                case ExpressionType.Add: _instructions.EmitAdd(left.Type, false); break;
-                case ExpressionType.AddChecked: _instructions.EmitAdd(left.Type, true); break;
-                case ExpressionType.Subtract: _instructions.EmitSub(left.Type, false); break;
-                case ExpressionType.SubtractChecked: _instructions.EmitSub(left.Type, true); break;
-                case ExpressionType.Multiply: _instructions.EmitMul(left.Type, false); break;
-                case ExpressionType.MultiplyChecked: _instructions.EmitMul(left.Type, true); break;
-                case ExpressionType.Divide: _instructions.EmitDiv(left.Type); break;
-                case ExpressionType.Modulo: _instructions.EmitMod(left.Type); break;
-                default: throw Assert.Unreachable;
-            }
-        }
-
-        private void CompileShift(ExpressionType nodeType, Expression left, Expression right, bool lifted) {
-            Debug.Assert(right.Type == typeof (int) || right.Type == typeof (int?));
-            Compile(left);
-            Compile(right);
-            switch (nodeType) {
-                case ExpressionType.LeftShift: _instructions.EmitShl(TypeUtils.GetNonNullableType (left.Type), lifted); break;
-                case ExpressionType.RightShift: _instructions.EmitShr(TypeUtils.GetNonNullableType (left.Type), lifted); break;
-                default: throw Assert.Unreachable;
-            }
-        }
-
-        private void CompileLogical(ExpressionType nodeType, Expression left, Expression right, bool lifted) {
-            Debug.Assert(left.Type == right.Type); // && TypeUtils.IsIntegerOrBool(left.Type));
-            Compile(left);
-            Compile(right);
-            switch (nodeType) {
-                case ExpressionType.And: _instructions.EmitAnd(TypeUtils.GetNonNullableType (left.Type), lifted); break;
-                case ExpressionType.Or: _instructions.EmitOr(TypeUtils.GetNonNullableType (left.Type), lifted); break;
-                case ExpressionType.ExclusiveOr: _instructions.EmitExclusiveOr(TypeUtils.GetNonNullableType (left.Type), lifted); break;
-                default: throw Assert.Unreachable;
-            }
-        }
-
-        private void CompileConvertUnaryExpression(Expression expr) {
-            var node = (UnaryExpression)expr;
-            if (node.Method != null) {
-                Compile(node.Operand);
-
-				if (node.IsLifted)
-					throw new NotImplementedException ();
-
-                // We should be able to ignore Int32ToObject
-                if (node.Method != Runtime.ScriptingRuntimeHelpers.Int32ToObjectMethod) {
-                    EmitCall(node.Method);
-                }
-            } else if (node.Type == typeof(void)) {
-                CompileAsVoid(node.Operand);
-            } else {
-                Compile(node.Operand);
-                CompileConvertToType(node.Operand.Type, node.Type, node.NodeType == ExpressionType.ConvertChecked);
-            }
-        }
-
-        private void CompileConvertToType(Type typeFrom, Type typeTo, bool isChecked) {
-            Debug.Assert(typeFrom != typeof(void) && typeTo != typeof(void));
-
-            if (TypeUtils.AreEquivalent(typeTo, typeFrom)) {
-                return;
-            }
-
-            if (TypeUtils.IsNullableType (typeTo)) {
-                typeFrom = TypeUtils.GetNonNullableType (typeFrom);
-                typeTo = TypeUtils.GetNonNullableType (typeTo);
-
-                var nullValue = _instructions.MakeLabel();
-                var end = _instructions.MakeLabel();
-
-                _instructions.EmitDup ();
-                _instructions.EmitBranchNull(nullValue);
-                CompileConvertToType (typeFrom, typeTo, isChecked);
-                _instructions.EmitWrap (typeTo);
-                _instructions.MarkLabel(nullValue);
-                return;
-            }
-
-            if (TypeUtils.IsNullableType (typeFrom)) {
-                if (typeTo.IsClass)
-                    return;
-
-                // TODO: should throw same exception as (int)(int?)null
-                throw new NotImplementedException ();
-            }
-
-            TypeCode from = typeFrom.GetTypeCode();
-            TypeCode to = typeTo.GetTypeCode();
-            if (TypeUtils.IsNumeric(from) && TypeUtils.IsNumeric(to)) {
-                if (isChecked) {
-                    _instructions.EmitNumericConvertChecked(from, to);
-                } else {
-                    _instructions.EmitNumericConvertUnchecked(from, to);
-                }
-                return;
-            }
-
-            // TODO: Conversions to a super-class or implemented interfaces are no-op. 
-            // A conversion to a non-implemented interface or an unrelated class, etc. should fail.
-            return;
-        }
-
-        private void CompileNegateExpression(UnaryExpression node, bool @checked, bool lifted) {
-            Compile(node.Operand);
-            _instructions.EmitNegate(TypeUtils.GetNonNullableType (node.Type), @checked, lifted);
-        }
-
-        private void CompileNotExpression(UnaryExpression node, bool lifted) {
-            Compile(node.Operand);
-            _instructions.EmitNot(TypeUtils.GetNonNullableType (node.Type), lifted);
-        }
-
-        private void CompileUnaryExpression(Expression expr) {
-            var node = (UnaryExpression)expr;
-            
-            if (node.Method != null) {
-                Compile(node.Operand);
-                EmitCall(node.Method);
-            } else {
-                switch (node.NodeType) {
-                    case ExpressionType.ArrayLength:
-                        Compile(node.Operand);
-                        _instructions.EmitGetArrayLength (node.Type);
-                        return;
-                    case ExpressionType.Negate:
-                        CompileNegateExpression(node, false, node.IsLifted);
-                        return;
-                    case ExpressionType.NegateChecked:
-                        CompileNegateExpression(node, true, node.IsLifted);
-                        return;                    
-                    case ExpressionType.Not:
-                        CompileNotExpression(node, node.IsLifted);
-                        return;
-                    case ExpressionType.UnaryPlus:
-                        // unary plus is a nop:
-                        Compile(node.Operand);                    
-                        return;
-                    case ExpressionType.TypeAs:
-                        CompileTypeAsExpression(node);
-                        return;
-                    default:
-                        throw new NotImplementedException(node.NodeType.ToString());
-                }
-            }
-        }
-
-        private void CompileAndAlsoBinaryExpression(Expression expr) {
-            CompileLogicalBinaryExpression(expr, true);
-        }
-
-        private void CompileOrElseBinaryExpression(Expression expr) {
-            CompileLogicalBinaryExpression(expr, false);
-        }
-
-        private void CompileLogicalBinaryExpression(Expression expr, bool andAlso) {
-            var node = (BinaryExpression)expr;
-            if (node.Method != null) {
-                throw new NotImplementedException();
-            }
-
-            Debug.Assert(node.Left.Type == node.Right.Type);
-
-            if (node.Left.Type == typeof(bool)) {
-                var elseLabel = _instructions.MakeLabel();
-                var endLabel = _instructions.MakeLabel();
-                Compile(node.Left);
-                if (andAlso) {
-                    _instructions.EmitBranchFalse(elseLabel);
-                } else {
-                    _instructions.EmitBranchTrue(elseLabel);
-                }
-                Compile(node.Right);
-                _instructions.EmitBranch(endLabel, false, true);
-                _instructions.MarkLabel(elseLabel);
-                _instructions.EmitLoad(!andAlso);
-                _instructions.MarkLabel(endLabel);
-                return;
-            }
-
-            Debug.Assert(node.Left.Type == typeof(bool?));
-            throw new NotImplementedException();
-        }
-
-        private void CompileConditionalExpression(Expression expr, bool asVoid) {
-            var node = (ConditionalExpression)expr;
-            Compile(node.Test);
-
-            if (node.IfTrue == AstUtils.Empty()) {
-                var endOfFalse = _instructions.MakeLabel();
-                _instructions.EmitBranchTrue(endOfFalse);
-                Compile(node.IfFalse, asVoid);
-                _instructions.MarkLabel(endOfFalse);
-            } else {
-                var endOfTrue = _instructions.MakeLabel();
-                _instructions.EmitBranchFalse(endOfTrue);
-                Compile(node.IfTrue, asVoid);
-
-                if (node.IfFalse != AstUtils.Empty()) {
-                    var endOfFalse = _instructions.MakeLabel();
-                    _instructions.EmitBranch(endOfFalse, false, !asVoid);
-                    _instructions.MarkLabel(endOfTrue);
-                    Compile(node.IfFalse, asVoid);
-                    _instructions.MarkLabel(endOfFalse);
-                } else {
-                    _instructions.MarkLabel(endOfTrue);
-                }
-            }
-        }
-
-        #region Loops
-
-        private void CompileLoopExpression(Expression expr) {
-            var node = (LoopExpression)expr;
-            var enterLoop = new EnterLoopInstruction(node, _locals, _compilationThreshold, _instructions.Count);
-
-            PushLabelBlock(LabelScopeKind.Statement);
-            LabelInfo breakLabel = DefineLabel(node.BreakLabel);
-            LabelInfo continueLabel = DefineLabel(node.ContinueLabel);
-
-            _instructions.MarkLabel(continueLabel.GetLabel(this));
-
-            // emit loop body:
-            _instructions.Emit(enterLoop);
-            CompileAsVoid(node.Body);
-
-            // emit loop branch:
-            _instructions.EmitBranch(continueLabel.GetLabel(this), expr.Type != typeof(void), false);
-
-            _instructions.MarkLabel(breakLabel.GetLabel(this));
-
-            PopLabelBlock(LabelScopeKind.Statement);
-
-            enterLoop.FinishLoop(_instructions.Count);
-        }
-
-        #endregion
-
-        private void CompileSwitchExpression(Expression expr) {
-            var node = (SwitchExpression)expr;
-
-            // Currently only supports int test values, with no method
-            if (node.SwitchValue.Type != typeof(int) || node.Comparison != null) {
-                throw new NotImplementedException();
-            }
-
-            // Test values must be constant
-            if (!node.Cases.All(c => c.TestValues.All(t => t is ConstantExpression))) {
-                throw new NotImplementedException();
-            }
-            LabelInfo end = DefineLabel(null);
-            bool hasValue = node.Type != typeof(void);
-
-            Compile(node.SwitchValue);
-            var caseDict = new Dictionary<int, int>();
-            int switchIndex = _instructions.Count;
-            _instructions.EmitSwitch(caseDict);
-
-            if (node.DefaultBody != null) {
-                Compile(node.DefaultBody);
-            } else {
-                Debug.Assert(!hasValue);
-            }
-            _instructions.EmitBranch(end.GetLabel(this), false, hasValue);
-
-            for (int i = 0; i < node.Cases.Count; i++) {
-                var switchCase = node.Cases[i];
-
-                int caseOffset = _instructions.Count - switchIndex;
-                foreach (ConstantExpression testValue in switchCase.TestValues) {
-                    caseDict[(int)testValue.Value] = caseOffset;
-                }
-
-                Compile(switchCase.Body);
-
-                if (i < node.Cases.Count - 1) {
-                    _instructions.EmitBranch(end.GetLabel(this), false, hasValue);
-                }
-            }
-
-            _instructions.MarkLabel(end.GetLabel(this));
-        }
-
-        private void CompileLabelExpression(Expression expr) {
-            var node = (LabelExpression)expr;
-
-            // If we're an immediate child of a block, our label will already
-            // be defined. If not, we need to define our own block so this
-            // label isn't exposed except to its own child expression.
-            LabelInfo label = null;
-
-            if (_labelBlock.Kind == LabelScopeKind.Block) {
-                _labelBlock.TryGetLabelInfo(node.Target, out label);
-
-                // We're in a block but didn't find our label, try switch
-                if (label == null && _labelBlock.Parent.Kind == LabelScopeKind.Switch) {
-                    _labelBlock.Parent.TryGetLabelInfo(node.Target, out label);
-                }
-
-                // if we're in a switch or block, we should've found the label
-                Debug.Assert(label != null);
-            }
-
-            if (label == null) {
-                label = DefineLabel(node.Target);
-            }
-
-            if (node.DefaultValue != null) {
-                if (node.Target.Type == typeof(void)) {
-                    CompileAsVoid(node.DefaultValue);
-                } else {
-                    Compile(node.DefaultValue);
-                }
-            }
-
-            _instructions.MarkLabel(label.GetLabel(this));
-        }
-
-        private void CompileGotoExpression(Expression expr) {
-            var node = (GotoExpression)expr;
-            var labelInfo = ReferenceLabel(node.Target);
-
-            if (node.Value != null) {
-                Compile(node.Value);
-            }
-
-            _instructions.EmitGoto(labelInfo.GetLabel(this), node.Type != typeof(void), node.Value != null && node.Value.Type != typeof(void));
-        }
-
-        public BranchLabel GetBranchLabel(LabelTarget target) {
-            return ReferenceLabel(target).GetLabel(this);
-        }
-
-        public void PushLabelBlock(LabelScopeKind type) {
-            _labelBlock = new LabelScopeInfo(_labelBlock, type);
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "kind")]
-        public void PopLabelBlock(LabelScopeKind kind) {
-            Debug.Assert(_labelBlock != null && _labelBlock.Kind == kind);
-            _labelBlock = _labelBlock.Parent;
-        }
-
-        private LabelInfo EnsureLabel(LabelTarget node) {
-            LabelInfo result;
-            if (!_treeLabels.TryGetValue(node, out result)) {
-                _treeLabels[node] = result = new LabelInfo(node);
-            }
-            return result;
-        }
-
-        private LabelInfo ReferenceLabel(LabelTarget node) {
-            LabelInfo result = EnsureLabel(node);
-            result.Reference(_labelBlock);
-            return result;
-        }
-
-        internal LabelInfo DefineLabel(LabelTarget node) {
-            if (node == null) {
-                return new LabelInfo(null);
-            }
-            LabelInfo result = EnsureLabel(node);
-            result.Define(_labelBlock);
-            return result;
-        }
-
-        private bool TryPushLabelBlock(Expression node) {
-            // Anything that is "statement-like" -- e.g. has no associated
-            // stack state can be jumped into, with the exception of try-blocks
-            // We indicate this by a "Block"
-            // 
-            // Otherwise, we push an "Expression" to indicate that it can't be
-            // jumped into
-            switch (node.NodeType) {
-                default:
-                    if (_labelBlock.Kind != LabelScopeKind.Expression) {
-                        PushLabelBlock(LabelScopeKind.Expression);
-                        return true;
-                    }
-                    return false;
-                case ExpressionType.Label:
-                    // LabelExpression is a bit special, if it's directly in a
-                    // block it becomes associate with the block's scope. Same
-                    // thing if it's in a switch case body.
-                    if (_labelBlock.Kind == LabelScopeKind.Block) {
-                        var label = ((LabelExpression)node).Target;
-                        if (_labelBlock.ContainsTarget(label)) {
-                            return false;
-                        }
-                        if (_labelBlock.Parent.Kind == LabelScopeKind.Switch &&
-                            _labelBlock.Parent.ContainsTarget(label)) {
-                            return false;
-                        }
-                    }
-                    PushLabelBlock(LabelScopeKind.Statement);
-                    return true;
-                case ExpressionType.Block:
-                    PushLabelBlock(LabelScopeKind.Block);
-                    // Labels defined immediately in the block are valid for
-                    // the whole block.
-                    if (_labelBlock.Parent.Kind != LabelScopeKind.Switch) {
-                        DefineBlockLabels(node);
-                    }
-                    return true;
-                case ExpressionType.Switch:
-                    PushLabelBlock(LabelScopeKind.Switch);
-                    // Define labels inside of the switch cases so theyare in
-                    // scope for the whole switch. This allows "goto case" and
-                    // "goto default" to be considered as local jumps.
-                    var @switch = (SwitchExpression)node;
-                    foreach (SwitchCase c in @switch.Cases) {
-                        DefineBlockLabels(c.Body);
-                    }
-                    DefineBlockLabels(@switch.DefaultBody);
-                    return true;
-
-                // Remove this when Convert(Void) goes away.
-                case ExpressionType.Convert:
-                    if (node.Type != typeof(void)) {
-                        // treat it as an expression
-                        goto default;
-                    }
-                    PushLabelBlock(LabelScopeKind.Statement);
-                    return true;
-
-                case ExpressionType.Conditional:
-                case ExpressionType.Loop:
-                case ExpressionType.Goto:
-                    PushLabelBlock(LabelScopeKind.Statement);
-                    return true;
-            }
-        }
-
-        private void DefineBlockLabels(Expression node) {
-            var block = node as BlockExpression;
-            if (block == null) {
-                return;
-            }
-
-            for (int i = 0, n = block.Expressions.Count; i < n; i++) {
-                Expression e = block.Expressions[i];
-
-                var label = e as LabelExpression;
-                if (label != null) {
-                    DefineLabel(label.Target);
-                }
-            }
-        }
-
-        private HybridReferenceDictionary<LabelTarget, BranchLabel> GetBranchMapping() {
-            var newLabelMapping = new HybridReferenceDictionary<LabelTarget, BranchLabel>(_treeLabels.Count);
-            foreach (var kvp in _treeLabels) {
-                newLabelMapping[kvp.Key] = kvp.Value.GetLabel(this);
-            }
-            return newLabelMapping;
-        }
-
-        private void CompileThrowUnaryExpression(Expression expr, bool asVoid) {
-            var node = (UnaryExpression)expr;
-
-            if (node.Operand == null) {
-                CompileParameterExpression(_exceptionForRethrowStack.Peek());
-                if (asVoid) {
-                    _instructions.EmitRethrowVoid();
-                } else {
-                    _instructions.EmitRethrow();
-                }
-            } else {
-                Compile(node.Operand);
-                if (asVoid) {
-                    _instructions.EmitThrowVoid();
-                } else {
-                    _instructions.EmitThrow();
-                }
-            }
-
-        }
-
-        // TODO: remove (replace by true fault support)
-        private bool EndsWithRethrow(Expression expr) {
-            if (expr.NodeType == ExpressionType.Throw) {
-                var node = (UnaryExpression)expr;
-                return node.Operand == null;
-            }
-
-            BlockExpression block = expr as BlockExpression;
-            if (block != null) {
-                return EndsWithRethrow(block.Expressions[block.Expressions.Count - 1]);
-            }
-            return false;
-        }
-
-
-        // TODO: remove (replace by true fault support)
-        private void CompileAsVoidRemoveRethrow(Expression expr) {
-            int stackDepth = _instructions.CurrentStackDepth;
-
-            if (expr.NodeType == ExpressionType.Throw) {
-                Debug.Assert(((UnaryExpression)expr).Operand == null);
-                return;
-            }
-
-            var node = (BlockExpression)expr;
-            var end = CompileBlockStart(node);
-
-            CompileAsVoidRemoveRethrow(node.Expressions[node.Expressions.Count - 1]);
-
-            Debug.Assert(stackDepth == _instructions.CurrentStackDepth);
-
-            CompileBlockEnd(end);
-        }
-
-        private void CompileTryExpression(Expression expr) {
-            var node = (TryExpression)expr;
-
-            BranchLabel end = _instructions.MakeLabel();
-            BranchLabel gotoEnd = _instructions.MakeLabel();
-
-            int tryStart = _instructions.Count;
-
-            BranchLabel startOfFinally = null;
-            if (node.Finally != null) {
-                startOfFinally = _instructions.MakeLabel();
-                _instructions.EmitEnterTryFinally(startOfFinally);
-            }
-
-            PushLabelBlock(LabelScopeKind.Try);
-            Compile(node.Body);
-
-            bool hasValue = node.Body.Type != typeof(void);
-            int tryEnd = _instructions.Count;
-
-            // handlers jump here:
-            _instructions.MarkLabel(gotoEnd);
-            _instructions.EmitGoto(end, hasValue, hasValue);
-            
-            // keep the result on the stack:     
-            if (node.Handlers.Count > 0) {
-                // TODO: emulates faults (replace by true fault support)
-                if (node.Finally == null && node.Handlers.Count == 1) {
-                    var handler = node.Handlers[0];
-                    if (handler.Filter == null && handler.Test == typeof(Exception) && handler.Variable == null) {
-                        if (EndsWithRethrow(handler.Body)) {
-                            if (hasValue) {
-                                _instructions.EmitEnterExceptionHandlerNonVoid();
-                            } else {
-                                _instructions.EmitEnterExceptionHandlerVoid();
-                            }
-
-                            // at this point the stack balance is prepared for the hidden exception variable:
-                            int handlerLabel = _instructions.MarkRuntimeLabel();
-                            int handlerStart = _instructions.Count;
-
-                            CompileAsVoidRemoveRethrow(handler.Body);
-                            _instructions.EmitLeaveFault(hasValue);
-                            _instructions.MarkLabel(end);
-
-                            _handlers.Add(new ExceptionHandler(tryStart, tryEnd, handlerLabel, handlerStart, null));
-                            PopLabelBlock(LabelScopeKind.Try);
-                            return;
-                        }
-                    }
-                }
-
-                foreach (var handler in node.Handlers) {
-                    PushLabelBlock(LabelScopeKind.Catch);
-
-                    if (handler.Filter != null) {
-                        //PushLabelBlock(LabelScopeKind.Filter);
-                        throw new NotImplementedException();
-                        //PopLabelBlock(LabelScopeKind.Filter);
-                    }
-
-                    var parameter = handler.Variable ?? Expression.Parameter(handler.Test);
-
-                    var local = _locals.DefineLocal(parameter, _instructions.Count);
-                    _exceptionForRethrowStack.Push(parameter);
-
-                    // add a stack balancing nop instruction (exception handling pushes the current exception):
-                    if (hasValue) {
-                        _instructions.EmitEnterExceptionHandlerNonVoid();
-                    } else {
-                        _instructions.EmitEnterExceptionHandlerVoid();
-                    }
-
-                    // at this point the stack balance is prepared for the hidden exception variable:
-                    int handlerLabel = _instructions.MarkRuntimeLabel();
-                    int handlerStart = _instructions.Count;
-
-                    CompileSetVariable(parameter, true);
-                    Compile(handler.Body);
-
-                    _exceptionForRethrowStack.Pop();
-
-                    // keep the value of the body on the stack:
-                    Debug.Assert(hasValue == (handler.Body.Type != typeof(void)));
-                    _instructions.EmitLeaveExceptionHandler(hasValue, gotoEnd);
-
-                    _handlers.Add(new ExceptionHandler(tryStart, tryEnd, handlerLabel, handlerStart, handler.Test));
-
-                    PopLabelBlock(LabelScopeKind.Catch);
-                
-                    _locals.UndefineLocal(local, _instructions.Count);
-                }
-
-                if (node.Fault != null) {
-                    throw new NotImplementedException();
-                }
-            }
-            
-            if (node.Finally != null) {
-                PushLabelBlock(LabelScopeKind.Finally);
-
-                _instructions.MarkLabel(startOfFinally);
-                _instructions.EmitEnterFinally();
-                CompileAsVoid(node.Finally);
-                _instructions.EmitLeaveFinally();
-
-                PopLabelBlock(LabelScopeKind.Finally);
-            }
-
-            _instructions.MarkLabel(end);
-
-            PopLabelBlock(LabelScopeKind.Try);
-        }
-
-        private void CompileDynamicExpression(Expression expr) {
-            var node = (DynamicExpression)expr;
-
-            foreach (var arg in node.Arguments) {
-                Compile(arg);
-            }
-
-            _instructions.EmitDynamic(node.DelegateType, node.Binder);
-        }
-
-        private void CompileMethodCallExpression(Expression expr) {
-            var node = (MethodCallExpression)expr;
-            
-            var parameters = node.Method.GetParameters();
-
-            // TODO:
-            // Support pass by reference.
-            // Note that LoopCompiler needs to be updated too.
-
-            // force compilation for now for ref types
-            // also could be a mutable value type, Delegate.CreateDelegate and MethodInfo.Invoke both can't handle this, we
-            // need to generate code.
-            if (!CollectionUtils.TrueForAll(parameters, (p) => !p.ParameterType.IsByRef) ||
-                (!node.Method.IsStatic && node.Method.DeclaringType.IsValueType && node.Method.DeclaringType.Assembly != typeof (object).Assembly)) {
-#if MONO_INTERPRETER
-                throw new NotImplementedException ("Interpreter of ref types");
-#else
-                _forceCompile = true;
-#endif
-            }
-
-            // CF bug workaround
-            // TODO: can we do better if the delegate targets LightLambda.Run* method?
-            if (PlatformAdaptationLayer.IsCompactFramework && 
-                node.Method.Name == "Invoke" && typeof(Delegate).IsAssignableFrom(node.Object.Type) && !node.Method.IsStatic) {
-                    
-                Compile(
-                    AstUtils.Convert(
-                        Expression.Call(
-                            node.Object,
-                            node.Object.Type.GetMethod("DynamicInvoke"),
-                            Expression.NewArrayInit(typeof(object), node.Arguments.Map((e) => AstUtils.Convert(e, typeof(object))))
-                        ),
-                        node.Type
-                    )
-                );
-
-            } else {
-                if (!node.Method.IsStatic) {
-                    Compile(node.Object);
-                }
-
-                foreach (var arg in node.Arguments) {
-                    Compile(arg);
-                }
-
-                EmitCall(node.Method, parameters);
-            }
-        }
-
-        public void EmitCall(MethodInfo method) {
-            EmitCall(method, method.GetParameters());
-        }
-
-        public void EmitCall(MethodInfo method, ParameterInfo[] parameters) {
-            Instruction instruction;
-
-            try {
-                instruction = CallInstruction.Create(method, parameters);
-            } catch (SecurityException) {
-                _forceCompile = true;
-                
-                _instructions.Emit(new PopNInstruction((method.IsStatic ? 0 : 1) + parameters.Length));
-                if (method.ReturnType != typeof(void)) {
-                    _instructions.EmitLoad(null);
-                }
-
-                return;
-            }
-
-            _instructions.Emit(instruction);
-        }
-
-        private void CompileNewExpression(Expression expr) {
-            var node = (NewExpression)expr;
-
-            if (node.Constructor != null) {
-                var parameters = node.Constructor.GetParameters();
-                if (!CollectionUtils.TrueForAll(parameters, (p) => !p.ParameterType.IsByRef)
-#if FEATURE_LCG
-                     || node.Constructor.DeclaringType == typeof(DynamicMethod)
-#endif
-                ) {
-                    _forceCompile = true;
-                }
-            }
-
-            if (node.Constructor != null) {
-                foreach (var arg in node.Arguments) {
-                    this.Compile(arg);
-                }
-                _instructions.EmitNew(node.Constructor);
-            } else {
-                Debug.Assert(expr.Type.IsValueType());
-                _instructions.EmitDefaultValue(node.Type);
-            }
-        }
-
-        private void CompileMemberExpression(Expression expr) {
-            var node = (MemberExpression)expr;
-
-            var member = node.Member;
-            FieldInfo fi = member as FieldInfo;
-            if (fi != null) {
-                if (fi.IsLiteral) {
-                    _instructions.EmitLoad(fi.GetRawConstantValue(), fi.FieldType);
-                } else if (fi.IsStatic) {
-                    if (fi.IsInitOnly) {
-                        _instructions.EmitLoad(fi.GetValue(null), fi.FieldType);
-                    } else {
-                        _instructions.EmitLoadField(fi);
-                    }
-                } else {
-                    Compile(node.Expression);
-                    _instructions.EmitLoadField(fi);
-                }
-                return;
-            }
-
-            PropertyInfo pi = member as PropertyInfo;
-            if (pi != null) {
-                var method = pi.GetGetMethod(true);
-                if (node.Expression != null) {
-                    Compile(node.Expression);
-                }
-                EmitCall(method);
-                return;
-            }
-
-
-            throw new System.NotImplementedException();
-        }
-
-        private void CompileNewArrayExpression(Expression expr) {
-            var node = (NewArrayExpression)expr;
-
-            foreach (var arg in node.Expressions) {
-                Compile(arg);
-            }
-
-            Type elementType = node.Type.GetElementType();
-            int rank = node.Expressions.Count;
-
-            if (node.NodeType == ExpressionType.NewArrayInit) {
-                _instructions.EmitNewArrayInit(elementType, rank);
-            } else if (node.NodeType == ExpressionType.NewArrayBounds) {
-                if (rank == 1) {
-                    _instructions.EmitNewArray(elementType);
-                } else {
-                    _instructions.EmitNewArrayBounds(elementType, rank);
-                }
-            } else {
-                throw new System.NotImplementedException();
-            }
-        }
-
-        private void CompileExtensionExpression(Expression expr) {
-            var instructionProvider = expr as IInstructionProvider;
-            if (instructionProvider != null) {
-                instructionProvider.AddInstructions(this);
-                return;
-            }
-
-            if (expr.CanReduce) {
-                Compile(expr.Reduce());
-            } else {
-                throw new System.NotImplementedException();
-            }
-        }
-
-
-        private void CompileDebugInfoExpression(Expression expr) {
-            var node = (DebugInfoExpression)expr;
-            int start = _instructions.Count;
-            var info = new DebugInfo()
-            {
-                Index = start,
-                FileName = node.Document.FileName,
-                StartLine = node.StartLine,
-                EndLine = node.EndLine,
-                IsClear = node.IsClear
-            };
-            _debugInfos.Add(info);
-        }
-
-        private void CompileRuntimeVariablesExpression(Expression expr) {
-            // Generates IRuntimeVariables for all requested variables
-            var node = (RuntimeVariablesExpression)expr;
-            foreach (var variable in node.Variables) {
-                EnsureAvailableForClosure(variable);
-                CompileGetBoxedVariable(variable);
-            }
-
-            _instructions.EmitNewRuntimeVariables(node.Variables.Count);
-        }
-
-
-        private void CompileLambdaExpression(Expression expr) {
-            var node = (LambdaExpression)expr;
-            var compiler = new LightCompiler(this);
-            var creator = compiler.CompileTop(node);
-
-            if (compiler._locals.ClosureVariables != null) {
-                foreach (ParameterExpression variable in compiler._locals.ClosureVariables.Keys) {
-                    CompileGetBoxedVariable(variable);
-                }
-            }
-            _instructions.EmitCreateDelegate(creator);
-        }
-
-		private void CompileQuotedLambdaExpression(Expression expr) {
-			_instructions.EmitStore (expr);
-		}
-
-        private void CompileCoalesceBinaryExpression(Expression expr) {
-            var node = (BinaryExpression)expr;
-
-            if (TypeUtils.IsNullableType(node.Left.Type)) {
-                throw new NotImplementedException();
-            } else if (node.Conversion != null) {
-                throw new NotImplementedException();
-            } else {
-                var leftNotNull = _instructions.MakeLabel();
-                Compile(node.Left);
-                _instructions.EmitCoalescingBranch(leftNotNull);
-                _instructions.EmitPop();
-                Compile(node.Right);
-                _instructions.MarkLabel(leftNotNull);
-            }
-        }
-
-        private void CompileInvocationExpression(Expression expr) {
-            var node = (InvocationExpression)expr;
-
-            // TODO: LambdaOperand optimization (see compiler)
-            if (typeof(LambdaExpression).IsAssignableFrom(node.Expression.Type)) {
-                throw new System.NotImplementedException();
-            }
-
-            // TODO: do not create a new Call Expression
-            if (PlatformAdaptationLayer.IsCompactFramework) {
-                // Workaround for a bug in Compact Framework
-                Compile(
-                    AstUtils.Convert(
-                        Expression.Call(
-                            node.Expression,
-                            node.Expression.Type.GetMethod("DynamicInvoke"),
-                            Expression.NewArrayInit(typeof(object), node.Arguments.Map((e) => AstUtils.Convert(e, typeof(object))))
-                        ),
-                        node.Type
-                    )
-                );
-            } else {
-                CompileMethodCallExpression(Expression.Call(node.Expression, node.Expression.Type.GetMethod("Invoke"), node.Arguments));
-            }
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "expr")]
-        private void CompileListInitExpression(Expression expr) {
-            throw new System.NotImplementedException();
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "expr")]
-        private void CompileMemberInitExpression(Expression expr) {
-            throw new System.NotImplementedException();
-        }
-
-		private void CompileQuoteUnaryExpression(Expression expr) {
-			var qe = (UnaryExpression)expr;
-			CompileQuotedLambdaExpression (qe.Operand);
-        }
-
-        private void CompileUnboxUnaryExpression(Expression expr) {
-            var node = (UnaryExpression)expr;
-            // unboxing is a nop:
-            Compile(node.Operand);
-        }
-
-        private void CompileTypeEqualExpression(Expression expr) {
-            Debug.Assert(expr.NodeType == ExpressionType.TypeEqual);
-            var node = (TypeBinaryExpression)expr;
-
-            Compile(node.Expression);
-            _instructions.EmitLoad(node.TypeOperand);
-            _instructions.EmitTypeEquals();
-        }
-
-        private void CompileTypeAsExpression(UnaryExpression node) {
-            Compile(node.Operand);
-            _instructions.EmitTypeAs(node.Type);
-        }
-
-        private void CompileTypeIsExpression(Expression expr) {
-            Debug.Assert(expr.NodeType == ExpressionType.TypeIs);
-            var node = (TypeBinaryExpression)expr;
-
-            Compile(node.Expression);
-            if (node.Expression.Type == typeof (void)) {
-                _instructions.Emit (InstructionFactory<bool>.Factory.DefaultValue ());
-                return;
-            }
-
-            // use TypeEqual for sealed types:
-            if (node.TypeOperand.IsSealed()) {
-                _instructions.EmitLoad(node.TypeOperand);
-                _instructions.EmitTypeEquals();
-            } else {
-                _instructions.EmitTypeIs(node.TypeOperand);
-            }
-        }
-
-        private void CompileReducibleExpression(Expression expr) {
-            switch (expr.NodeType) {
-            case ExpressionType.PreIncrementAssign:
-                _instructions.EmitIncrement (expr.Type);
-                break;
-            default:
-                throw Assert.Unreachable;
-            }
-        }
-
-        internal void Compile(Expression expr, bool asVoid) {
-            if (asVoid) {
-                CompileAsVoid(expr);
-            } else {
-                Compile(expr);
-            }
-        }
-
-        internal void CompileAsVoid(Expression expr) {
-            bool pushLabelBlock = TryPushLabelBlock(expr);
-            int startingStackDepth = _instructions.CurrentStackDepth;
-            switch (expr.NodeType) {
-                case ExpressionType.Assign:
-                    CompileAssignBinaryExpression(expr, true);
-                    break;
-
-                case ExpressionType.Block:
-                    CompileBlockExpression(expr, true);
-                    break;
-
-                case ExpressionType.Throw:
-                    CompileThrowUnaryExpression(expr, true);
-                    break;
-
-                case ExpressionType.Constant:
-                case ExpressionType.Default:
-                case ExpressionType.Parameter:
-                    // no-op
-                    break;
-
-                default:
-                    CompileNoLabelPush(expr);
-                    if (expr.Type != typeof(void)) {
-                        _instructions.EmitPop();
-                    }
-                    break;
-            }
-            Debug.Assert(_instructions.CurrentStackDepth == startingStackDepth);
-            if (pushLabelBlock) {
-                PopLabelBlock(_labelBlock.Kind);
-            }
-        }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
-        private void CompileNoLabelPush(Expression expr) {
-            int startingStackDepth = _instructions.CurrentStackDepth;
-            switch (expr.NodeType) {
-                case ExpressionType.Add: CompileBinaryExpression(expr); break;
-                case ExpressionType.AddChecked: CompileBinaryExpression(expr); break;
-                case ExpressionType.And: CompileBinaryExpression(expr); break;
-                case ExpressionType.AndAlso: CompileAndAlsoBinaryExpression(expr); break;
-                case ExpressionType.ArrayLength: CompileUnaryExpression(expr); break;
-                case ExpressionType.ArrayIndex: CompileBinaryExpression(expr); break;
-                case ExpressionType.Call: CompileMethodCallExpression(expr); break;
-                case ExpressionType.Coalesce: CompileCoalesceBinaryExpression(expr); break;
-                case ExpressionType.Conditional: CompileConditionalExpression(expr, expr.Type == typeof(void)); break;
-                case ExpressionType.Constant: CompileConstantExpression(expr); break;
-                case ExpressionType.Convert: CompileConvertUnaryExpression(expr); break;
-                case ExpressionType.ConvertChecked: CompileConvertUnaryExpression(expr); break;
-                case ExpressionType.Divide: CompileBinaryExpression(expr); break;
-                case ExpressionType.Equal: CompileBinaryExpression(expr); break;
-                case ExpressionType.ExclusiveOr: CompileBinaryExpression(expr); break;
-                case ExpressionType.GreaterThan: CompileBinaryExpression(expr); break;
-                case ExpressionType.GreaterThanOrEqual: CompileBinaryExpression(expr); break;
-                case ExpressionType.Invoke: CompileInvocationExpression(expr); break;
-                case ExpressionType.Lambda: CompileLambdaExpression(expr); break;
-                case ExpressionType.LeftShift: CompileBinaryExpression(expr); break;
-                case ExpressionType.LessThan: CompileBinaryExpression(expr); break;
-                case ExpressionType.LessThanOrEqual: CompileBinaryExpression(expr); break;
-                case ExpressionType.ListInit: CompileListInitExpression(expr); break;
-                case ExpressionType.MemberAccess: CompileMemberExpression(expr); break;
-                case ExpressionType.MemberInit: CompileMemberInitExpression(expr); break;
-                case ExpressionType.Modulo: CompileBinaryExpression(expr); break;
-                case ExpressionType.Multiply: CompileBinaryExpression(expr); break;
-                case ExpressionType.MultiplyChecked: CompileBinaryExpression(expr); break;
-                case ExpressionType.Negate: CompileUnaryExpression(expr); break;
-                case ExpressionType.UnaryPlus: CompileUnaryExpression(expr); break;
-                case ExpressionType.NegateChecked: CompileUnaryExpression(expr); break;
-                case ExpressionType.New: CompileNewExpression(expr); break;
-                case ExpressionType.NewArrayInit: CompileNewArrayExpression(expr); break;
-                case ExpressionType.NewArrayBounds: CompileNewArrayExpression(expr); break;
-                case ExpressionType.Not: CompileUnaryExpression(expr); break;
-                case ExpressionType.NotEqual: CompileBinaryExpression(expr); break;
-                case ExpressionType.Or: CompileBinaryExpression(expr); break;
-                case ExpressionType.OrElse: CompileOrElseBinaryExpression(expr); break;
-                case ExpressionType.Parameter: CompileParameterExpression(expr); break;
-                case ExpressionType.Power: CompileBinaryExpression(expr); break;
-                case ExpressionType.Quote: CompileQuoteUnaryExpression(expr); break;
-                case ExpressionType.RightShift: CompileBinaryExpression(expr); break;
-                case ExpressionType.Subtract: CompileBinaryExpression(expr); break;
-                case ExpressionType.SubtractChecked: CompileBinaryExpression(expr); break;
-                case ExpressionType.TypeAs: CompileUnaryExpression(expr); break;
-                case ExpressionType.TypeIs: CompileTypeIsExpression(expr); break;
-                case ExpressionType.Assign: CompileAssignBinaryExpression(expr, expr.Type == typeof(void)); break;
-                case ExpressionType.Block: CompileBlockExpression(expr, expr.Type == typeof(void)); break;
-                case ExpressionType.DebugInfo: CompileDebugInfoExpression(expr); break;
-                case ExpressionType.Decrement: CompileUnaryExpression(expr); break;
-                case ExpressionType.Dynamic: CompileDynamicExpression(expr); break;
-                case ExpressionType.Default: CompileDefaultExpression(expr); break;
-                case ExpressionType.Extension: CompileExtensionExpression(expr); break;
-                case ExpressionType.Goto: CompileGotoExpression(expr); break;
-                case ExpressionType.Increment: CompileUnaryExpression(expr); break;
-                case ExpressionType.Index: CompileIndexExpression(expr); break;
-                case ExpressionType.Label: CompileLabelExpression(expr); break;
-                case ExpressionType.RuntimeVariables: CompileRuntimeVariablesExpression(expr); break;
-                case ExpressionType.Loop: CompileLoopExpression(expr); break;
-                case ExpressionType.Switch: CompileSwitchExpression(expr); break;
-                case ExpressionType.Throw: CompileThrowUnaryExpression(expr, expr.Type == typeof(void)); break;
-                case ExpressionType.Try: CompileTryExpression(expr); break;
-                case ExpressionType.Unbox: CompileUnboxUnaryExpression(expr); break;
-                case ExpressionType.TypeEqual: CompileTypeEqualExpression(expr); break;
-                case ExpressionType.OnesComplement: CompileUnaryExpression(expr); break;
-                case ExpressionType.IsTrue: CompileUnaryExpression(expr); break;
-                case ExpressionType.IsFalse: CompileUnaryExpression(expr); break;
-                case ExpressionType.AddAssign:
-                case ExpressionType.AndAssign:
-                case ExpressionType.DivideAssign:
-                case ExpressionType.ExclusiveOrAssign:
-                case ExpressionType.LeftShiftAssign:
-                case ExpressionType.ModuloAssign:
-                case ExpressionType.MultiplyAssign:
-                case ExpressionType.OrAssign:
-                case ExpressionType.PowerAssign:
-                case ExpressionType.RightShiftAssign:
-                case ExpressionType.SubtractAssign:
-                case ExpressionType.AddAssignChecked:
-                case ExpressionType.MultiplyAssignChecked:
-                case ExpressionType.SubtractAssignChecked:
-                case ExpressionType.PreIncrementAssign:
-                case ExpressionType.PreDecrementAssign:
-                case ExpressionType.PostIncrementAssign:
-                case ExpressionType.PostDecrementAssign:
-                    CompileReducibleExpression(expr); break;
-                default: throw Assert.Unreachable;
-            };
-            Debug.Assert(_instructions.CurrentStackDepth == startingStackDepth + (expr.Type == typeof(void) ? 0 : 1));
-        }
-
-        public void Compile(Expression expr) {
-            bool pushLabelBlock = TryPushLabelBlock(expr);
-            CompileNoLabelPush(expr);
-            if (pushLabelBlock) {
-                PopLabelBlock(_labelBlock.Kind);
-            }
-        }
-
-    }
-}

+ 0 - 198
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs

@@ -1,198 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-using Microsoft.Scripting.Ast;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Threading;
-using Microsoft.Scripting.Generation;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    
-    /// <summary>
-    /// Manages creation of interpreted delegates. These delegates will get
-    /// compiled if they are executed often enough.
-    /// </summary>
-    internal sealed class LightDelegateCreator {
-        // null if we are forced to compile
-        private readonly Interpreter _interpreter;
-        private readonly Expression _lambda;
-
-#if !MONO_INTERPRETER
-        // Adaptive compilation support:
-        private Type _compiledDelegateType;
-        private Delegate _compiled;
-        private readonly object _compileLock = new object();
-#endif
-        internal LightDelegateCreator(Interpreter interpreter, LambdaExpression lambda) {
-            Assert.NotNull(lambda);
-            _interpreter = interpreter;
-            _lambda = lambda;
-        }
-
-        internal LightDelegateCreator(Interpreter interpreter, LightLambdaExpression lambda) {
-            Assert.NotNull(lambda);
-            _interpreter = interpreter;
-            _lambda = lambda;
-        }
-
-        internal Interpreter Interpreter {
-            get { return _interpreter; }
-        }
-
-        private bool HasClosure {
-            get { return _interpreter != null && _interpreter.ClosureSize > 0; }
-        }
-#if !MONO_INTERPRETER
-        internal bool HasCompiled {
-            get { return _compiled != null; }
-        }
-
-        /// <summary>
-        /// true if the compiled delegate has the same type as the lambda;
-        /// false if the type was changed for interpretation.
-        /// </summary>
-        internal bool SameDelegateType {
-            get { return _compiledDelegateType == DelegateType; }
-        }
-#endif
-        internal Delegate CreateDelegate() {
-            return CreateDelegate(null);
-        }
-
-        internal Delegate CreateDelegate(StrongBox<object>[] closure) {
-#if !MONO_INTERPRETER
-            if (_compiled != null) {
-                // If the delegate type we want is not a Func/Action, we can't
-                // use the compiled code directly. So instead just fall through
-                // and create an interpreted LightLambda, which will pick up
-                // the compiled delegate on its first run.
-                //
-                // Ideally, we would just rebind the compiled delegate using
-                // Delegate.CreateDelegate. Unfortunately, it doesn't work on
-                // dynamic methods.
-                if (SameDelegateType) {
-                    return CreateCompiledDelegate(closure);
-                }
-            }
-
-            if (_interpreter == null) {
-                // We can't interpret, so force a compile
-                Compile(null);
-                Delegate compiled = CreateCompiledDelegate(closure);
-                Debug.Assert(compiled.GetType() == DelegateType);
-                return compiled;
-            }
-#endif
-            // Otherwise, we'll create an interpreted LightLambda
-            return new LightLambda(this, closure, _interpreter._compilationThreshold).MakeDelegate(DelegateType);
-        }
-
-        private Type DelegateType {
-            get {
-                LambdaExpression le = _lambda as LambdaExpression;
-                if (le != null) {
-                    return le.Type;
-                }
-
-                return ((LightLambdaExpression)_lambda).Type;
-            }
-        }
-
-#if !MONO_INTERPRETER
-        /// <summary>
-        /// Used by LightLambda to get the compiled delegate.
-        /// </summary>
-        internal Delegate CreateCompiledDelegate(StrongBox<object>[] closure) {
-            Debug.Assert(HasClosure == (closure != null));
-
-            if (HasClosure) {
-                // We need to apply the closure to get the actual delegate.
-                var applyClosure = (Func<StrongBox<object>[], Delegate>)_compiled;
-                return applyClosure(closure);
-            }
-            return _compiled;
-        }
-
-        /// <summary>
-        /// Create a compiled delegate for the LightLambda, and saves it so
-        /// future calls to Run will execute the compiled code instead of
-        /// interpreting.
-        /// </summary>
-        internal void Compile(object state) {
-            if (_compiled != null) {
-                return;
-            }
-
-            // Compilation is expensive, we only want to do it once.
-            lock (_compileLock) {
-                if (_compiled != null) {
-                    return;
-                }
-
-                PerfTrack.NoteEvent(PerfTrack.Categories.Compiler, "Interpreted lambda compiled");
-                
-                // Interpreter needs a standard delegate type.
-                // So change the lambda's delegate type to Func<...> or
-                // Action<...> so it can be called from the LightLambda.Run
-                // methods.
-                LambdaExpression lambda = (_lambda as LambdaExpression) ?? (LambdaExpression)((LightLambdaExpression)_lambda).Reduce();
-                if (_interpreter != null) {
-                    _compiledDelegateType = GetFuncOrAction(lambda);
-                    lambda = Expression.Lambda(_compiledDelegateType, lambda.Body, lambda.Name, lambda.Parameters);
-                }
-
-                if (HasClosure) {
-                    _compiled = LightLambdaClosureVisitor.BindLambda(lambda, _interpreter.ClosureVariables);
-                } else {
-                    _compiled = lambda.Compile();
-                }
-            }
-        }
-
-        private static Type GetFuncOrAction(LambdaExpression lambda) {
-            Type delegateType;
-            bool isVoid = lambda.ReturnType == typeof(void);
-
-            if (isVoid && lambda.Parameters.Count == 2 &&
-                lambda.Parameters[0].IsByRef && lambda.Parameters[1].IsByRef) {
-                return typeof(ActionRef<,>).MakeGenericType(lambda.Parameters.Map(p => p.Type));
-            } else {
-                Type[] types = lambda.Parameters.Map(p => p.IsByRef ? p.Type.MakeByRefType() : p.Type);
-                if (isVoid) {
-                    if (Expression.TryGetActionType(types, out delegateType)) {
-                        return delegateType;
-                    }
-                } else {
-                    types = types.AddLast(lambda.ReturnType);
-                    if (Expression.TryGetFuncType(types, out delegateType)) {
-                        return delegateType;
-                    }
-                }
-                return lambda.Type;
-            }
-        }
-#endif
-    }
-}

+ 0 - 756
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.Generated.cs

@@ -1,756 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-
-using System;
-using System.Runtime.CompilerServices;
-using System.Reflection;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    public partial class LightLambda {
-        #region Generated LightLambda Run Methods
-
-        // *** BEGIN GENERATED CODE ***
-        // generated by function: gen_run_methods from: generate_dynamic_instructions.py
-
-        internal const int MaxParameters = 16;
-        internal TRet Run0<TRet>() {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<TRet>)_compiled)();
-            }
-#endif
-            var frame = MakeFrame();
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid0() {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action)_compiled)();
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun0<TRet>(LightLambda lambda) {
-            return new Func<TRet>(lambda.Run0<TRet>);
-        }
-        internal static Delegate MakeRunVoid0(LightLambda lambda) {
-            return new Action(lambda.RunVoid0);
-        }
-        internal TRet Run1<T0,TRet>(T0 arg0) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,TRet>)_compiled)(arg0);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid1<T0>(T0 arg0) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0>)_compiled)(arg0);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun1<T0,TRet>(LightLambda lambda) {
-            return new Func<T0,TRet>(lambda.Run1<T0,TRet>);
-        }
-        internal static Delegate MakeRunVoid1<T0>(LightLambda lambda) {
-            return new Action<T0>(lambda.RunVoid1<T0>);
-        }
-        internal TRet Run2<T0,T1,TRet>(T0 arg0,T1 arg1) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,TRet>)_compiled)(arg0, arg1);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid2<T0,T1>(T0 arg0,T1 arg1) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1>)_compiled)(arg0, arg1);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun2<T0,T1,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,TRet>(lambda.Run2<T0,T1,TRet>);
-        }
-        internal static Delegate MakeRunVoid2<T0,T1>(LightLambda lambda) {
-            return new Action<T0,T1>(lambda.RunVoid2<T0,T1>);
-        }
-        internal TRet Run3<T0,T1,T2,TRet>(T0 arg0,T1 arg1,T2 arg2) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,TRet>)_compiled)(arg0, arg1, arg2);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid3<T0,T1,T2>(T0 arg0,T1 arg1,T2 arg2) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2>)_compiled)(arg0, arg1, arg2);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun3<T0,T1,T2,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,TRet>(lambda.Run3<T0,T1,T2,TRet>);
-        }
-        internal static Delegate MakeRunVoid3<T0,T1,T2>(LightLambda lambda) {
-            return new Action<T0,T1,T2>(lambda.RunVoid3<T0,T1,T2>);
-        }
-        internal TRet Run4<T0,T1,T2,T3,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,TRet>)_compiled)(arg0, arg1, arg2, arg3);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid4<T0,T1,T2,T3>(T0 arg0,T1 arg1,T2 arg2,T3 arg3) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3>)_compiled)(arg0, arg1, arg2, arg3);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun4<T0,T1,T2,T3,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,TRet>(lambda.Run4<T0,T1,T2,T3,TRet>);
-        }
-        internal static Delegate MakeRunVoid4<T0,T1,T2,T3>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3>(lambda.RunVoid4<T0,T1,T2,T3>);
-        }
-        internal TRet Run5<T0,T1,T2,T3,T4,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid5<T0,T1,T2,T3,T4>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4>)_compiled)(arg0, arg1, arg2, arg3, arg4);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun5<T0,T1,T2,T3,T4,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,TRet>(lambda.Run5<T0,T1,T2,T3,T4,TRet>);
-        }
-        internal static Delegate MakeRunVoid5<T0,T1,T2,T3,T4>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4>(lambda.RunVoid5<T0,T1,T2,T3,T4>);
-        }
-        internal TRet Run6<T0,T1,T2,T3,T4,T5,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid6<T0,T1,T2,T3,T4,T5>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun6<T0,T1,T2,T3,T4,T5,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,TRet>(lambda.Run6<T0,T1,T2,T3,T4,T5,TRet>);
-        }
-        internal static Delegate MakeRunVoid6<T0,T1,T2,T3,T4,T5>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5>(lambda.RunVoid6<T0,T1,T2,T3,T4,T5>);
-        }
-        internal TRet Run7<T0,T1,T2,T3,T4,T5,T6,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid7<T0,T1,T2,T3,T4,T5,T6>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun7<T0,T1,T2,T3,T4,T5,T6,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,TRet>(lambda.Run7<T0,T1,T2,T3,T4,T5,T6,TRet>);
-        }
-        internal static Delegate MakeRunVoid7<T0,T1,T2,T3,T4,T5,T6>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6>(lambda.RunVoid7<T0,T1,T2,T3,T4,T5,T6>);
-        }
-        internal TRet Run8<T0,T1,T2,T3,T4,T5,T6,T7,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid8<T0,T1,T2,T3,T4,T5,T6,T7>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun8<T0,T1,T2,T3,T4,T5,T6,T7,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,TRet>(lambda.Run8<T0,T1,T2,T3,T4,T5,T6,T7,TRet>);
-        }
-        internal static Delegate MakeRunVoid8<T0,T1,T2,T3,T4,T5,T6,T7>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7>(lambda.RunVoid8<T0,T1,T2,T3,T4,T5,T6,T7>);
-        }
-        internal TRet Run9<T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid9<T0,T1,T2,T3,T4,T5,T6,T7,T8>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7,T8>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun9<T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>(lambda.Run9<T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet>);
-        }
-        internal static Delegate MakeRunVoid9<T0,T1,T2,T3,T4,T5,T6,T7,T8>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7,T8>(lambda.RunVoid9<T0,T1,T2,T3,T4,T5,T6,T7,T8>);
-        }
-        internal TRet Run10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>(lambda.Run10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet>);
-        }
-        internal static Delegate MakeRunVoid10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>(lambda.RunVoid10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>);
-        }
-        internal TRet Run11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>(lambda.Run11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,TRet>);
-        }
-        internal static Delegate MakeRunVoid11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(lambda.RunVoid11<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>);
-        }
-        internal TRet Run12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>(lambda.Run12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,TRet>);
-        }
-        internal static Delegate MakeRunVoid12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(lambda.RunVoid12<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>);
-        }
-        internal TRet Run13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            frame.Data[12] = arg12;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            frame.Data[12] = arg12;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>(lambda.Run13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,TRet>);
-        }
-        internal static Delegate MakeRunVoid13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(lambda.RunVoid13<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>);
-        }
-        internal TRet Run14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12,T13 arg13) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            frame.Data[12] = arg12;
-            frame.Data[13] = arg13;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12,T13 arg13) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            frame.Data[12] = arg12;
-            frame.Data[13] = arg13;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>(lambda.Run14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,TRet>);
-        }
-        internal static Delegate MakeRunVoid14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(lambda.RunVoid14<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>);
-        }
-        internal TRet Run15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12,T13 arg13,T14 arg14) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                return ((Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            frame.Data[12] = arg12;
-            frame.Data[13] = arg13;
-            frame.Data[14] = arg14;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-            return (TRet)frame.Pop();
-        }
-
-        internal void RunVoid15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(T0 arg0,T1 arg1,T2 arg2,T3 arg3,T4 arg4,T5 arg5,T6 arg6,T7 arg7,T8 arg8,T9 arg9,T10 arg10,T11 arg11,T12 arg12,T13 arg13,T14 arg14) {
-#if !MONO_INTERPRETER
-            if (_compiled != null || TryGetCompiled()) {
-                ((Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>)_compiled)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14);
-                return;
-            }
-#endif
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            frame.Data[2] = arg2;
-            frame.Data[3] = arg3;
-            frame.Data[4] = arg4;
-            frame.Data[5] = arg5;
-            frame.Data[6] = arg6;
-            frame.Data[7] = arg7;
-            frame.Data[8] = arg8;
-            frame.Data[9] = arg9;
-            frame.Data[10] = arg10;
-            frame.Data[11] = arg11;
-            frame.Data[12] = arg12;
-            frame.Data[13] = arg13;
-            frame.Data[14] = arg14;
-            var current = frame.Enter();
-            try { _interpreter.Run(frame); } finally { frame.Leave(current); }
-        }
-
-        internal static Delegate MakeRun15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>(LightLambda lambda) {
-            return new Func<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>(lambda.Run15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,TRet>);
-        }
-        internal static Delegate MakeRunVoid15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(LightLambda lambda) {
-            return new Action<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>(lambda.RunVoid15<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>);
-        }
-
-        // *** END GENERATED CODE ***
-
-        #endregion
-
-    }
-}

+ 0 - 280
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs

@@ -1,280 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_TASKS
-using System.Threading.Tasks;
-#endif
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Reflection;
-#if FEATURE_REFEMIT
-using System.Reflection.Emit;
-#endif
-using System.Runtime.CompilerServices;
-using System.Security;
-using System.Threading;
-
-using Microsoft.Scripting.Generation;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
-using AstUtils = Microsoft.Scripting.Ast.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-
-    public sealed class LightLambdaCompileEventArgs : EventArgs {
-        public Delegate Compiled { get; private set; }
-
-        internal LightLambdaCompileEventArgs(Delegate compiled) {
-            Compiled = compiled;
-        }
-    }
-
-    public partial class LightLambda {
-        private readonly StrongBox<object>[] _closure;
-        private readonly Interpreter _interpreter;
-        private static readonly CacheDict<Type, Func<LightLambda, Delegate>> _runCache = new CacheDict<Type, Func<LightLambda, Delegate>>(100);
-
-        // Adaptive compilation support
-        private readonly LightDelegateCreator _delegateCreator;
-#if MONO_INTERPRETER
-        const Delegate _compiled = null;
-#else
-        private Delegate _compiled;
-#endif
-        private int _compilationThreshold;
-
-#if !MONO_INTERPRETER
-        /// <summary>
-        /// Provides notification that the LightLambda has been compiled.
-        /// </summary>
-        public event EventHandler<LightLambdaCompileEventArgs> Compile;
-#endif
-
-        internal LightLambda(LightDelegateCreator delegateCreator, StrongBox<object>[] closure, int compilationThreshold) {
-            _delegateCreator = delegateCreator;
-            _closure = closure;
-            _interpreter = delegateCreator.Interpreter;
-            _compilationThreshold = compilationThreshold;
-        }
-
-        private static Func<LightLambda, Delegate> GetRunDelegateCtor(Type delegateType) {
-            lock (_runCache) {
-                Func<LightLambda, Delegate> fastCtor;
-                if (_runCache.TryGetValue(delegateType, out fastCtor)) {
-                    return fastCtor;
-                }
-                return MakeRunDelegateCtor(delegateType);
-            }
-        }
-
-        private static Func<LightLambda, Delegate> MakeRunDelegateCtor(Type delegateType) {
-            var method = delegateType.GetMethod("Invoke");
-            var paramInfos = method.GetParameters();
-            Type[] paramTypes;
-            string name = "Run";
-
-            if (paramInfos.Length >= MaxParameters) {
-                return null;
-            }
-
-            if (method.ReturnType == typeof(void)) {
-                name += "Void";
-                paramTypes = new Type[paramInfos.Length];
-            } else {
-                paramTypes = new Type[paramInfos.Length + 1];
-                paramTypes[paramTypes.Length - 1] = method.ReturnType;
-            }
-
-            MethodInfo runMethod;
-
-            if (method.ReturnType == typeof(void) && paramTypes.Length == 2 &&
-                paramInfos[0].ParameterType.IsByRef && paramInfos[1].ParameterType.IsByRef) {
-                runMethod = typeof(LightLambda).GetMethod("RunVoidRef2", BindingFlags.NonPublic | BindingFlags.Instance);
-                paramTypes[0] = paramInfos[0].ParameterType.GetElementType();
-                paramTypes[1] = paramInfos[1].ParameterType.GetElementType();
-            } else if (method.ReturnType == typeof(void) && paramTypes.Length == 0) {
-                runMethod = typeof(LightLambda).GetMethod("RunVoid0", BindingFlags.NonPublic | BindingFlags.Instance);
-            } else {
-                for (int i = 0; i < paramInfos.Length; i++) {
-                    paramTypes[i] = paramInfos[i].ParameterType;
-                    if (paramTypes[i].IsByRef) {
-                        return null;
-                    }
-                }
-
-                if (DelegateHelpers.MakeDelegate(paramTypes) == delegateType) {
-                    name = "Make" + name + paramInfos.Length;
-                    
-                    MethodInfo ctorMethod = typeof(LightLambda).GetMethod(name, BindingFlags.NonPublic | BindingFlags.Static).MakeGenericMethod(paramTypes);
-                    return _runCache[delegateType] = (Func<LightLambda, Delegate>)ctorMethod.CreateDelegate(typeof(Func<LightLambda, Delegate>));
-                }
-
-                runMethod = typeof(LightLambda).GetMethod(name + paramInfos.Length, BindingFlags.NonPublic | BindingFlags.Instance);
-            }
-
-#if FEATURE_LCG && !SILVERLIGHT && !WP75
-            try {
-                DynamicMethod dm = new DynamicMethod("FastCtor", typeof(Delegate), new[] { typeof(LightLambda) }, typeof(LightLambda), true);
-                var ilgen = dm.GetILGenerator();
-                ilgen.Emit(OpCodes.Ldarg_0);
-                ilgen.Emit(OpCodes.Ldftn, runMethod.IsGenericMethodDefinition ? runMethod.MakeGenericMethod(paramTypes) : runMethod);
-                ilgen.Emit(OpCodes.Newobj, delegateType.GetConstructor(new[] { typeof(object), typeof(IntPtr) }));
-                ilgen.Emit(OpCodes.Ret);
-                return _runCache[delegateType] = (Func<LightLambda, Delegate>)dm.CreateDelegate(typeof(Func<LightLambda, Delegate>));
-            } catch (SecurityException) {
-            }
-#endif
-
-            // we don't have permission for restricted skip visibility dynamic methods, use the slower Delegate.CreateDelegate.
-            var targetMethod = runMethod.IsGenericMethodDefinition ? runMethod.MakeGenericMethod(paramTypes) : runMethod;
-            return _runCache[delegateType] = lambda => targetMethod.CreateDelegate(delegateType, lambda);
-        }
-    
-        //TODO enable sharing of these custom delegates
-        private Delegate CreateCustomDelegate(Type delegateType) {
-            PerfTrack.NoteEvent(PerfTrack.Categories.Compiler, "Synchronously compiling a custom delegate");
-
-            var method = delegateType.GetMethod("Invoke");
-            var paramInfos = method.GetParameters();
-            var parameters = new ParameterExpression[paramInfos.Length];
-            var parametersAsObject = new Expression[paramInfos.Length];
-            for (int i = 0; i < paramInfos.Length; i++) {
-                ParameterExpression parameter = Expression.Parameter(paramInfos[i].ParameterType, paramInfos[i].Name);
-                parameters[i] = parameter;
-                parametersAsObject[i] = Expression.Convert(parameter, typeof(object));
-            }
-
-            var data = Expression.NewArrayInit(typeof(object), parametersAsObject);
-            var self = AstUtils.Constant(this);
-            var runMethod = typeof(LightLambda).GetMethod("Run");
-            var body = Expression.Convert(Expression.Call(self, runMethod, data), method.ReturnType);
-            var lambda = Expression.Lambda(delegateType, body, parameters);
-            return lambda.Compile();
-        }
-
-        internal Delegate MakeDelegate(Type delegateType) {            
-            Func<LightLambda, Delegate> fastCtor = GetRunDelegateCtor(delegateType);
-            if (fastCtor != null) {
-                return fastCtor(this);
-            } else {
-                return CreateCustomDelegate(delegateType);
-            }
-        }
-
-        private bool TryGetCompiled() {
-#if !MONO_INTERPRETER
-            // Use the compiled delegate if available.
-            if (_delegateCreator.HasCompiled) {
-                _compiled = _delegateCreator.CreateCompiledDelegate(_closure);
-
-                // Send it to anyone who's interested.
-                var compileEvent = Compile;
-                if (compileEvent != null && _delegateCreator.SameDelegateType) {
-                    compileEvent(this, new LightLambdaCompileEventArgs(_compiled));
-                }
-
-                return true;
-            }
-
-            // Don't lock here, it's a frequently hit path.
-            //
-            // There could be multiple threads racing, but that is okay.
-            // Two bad things can happen:
-            //   * We miss decrements (some thread sets the counter forward)
-            //   * We might enter the "if" branch more than once.
-            //
-            // The first is okay, it just means we take longer to compile.
-            // The second we explicitly guard against inside of Compile().
-            //
-            // We can't miss 0. The first thread that writes -1 must have read 0 and hence start compilation.
-            if (unchecked(_compilationThreshold--) == 0) {
-#if SILVERLIGHT
-                if (PlatformAdaptationLayer.IsCompactFramework) {
-                    _compilationThreshold = Int32.MaxValue;
-                    return false;
-                }
-#endif
-                if (_interpreter.CompileSynchronously) {
-                    _delegateCreator.Compile(null);
-                    return TryGetCompiled();
-                } else {
-                    // Kick off the compile on another thread so this one can keep going
-#if FEATURE_TASKS
-                    new Task(_delegateCreator.Compile, null).Start();
-#else
-                    ThreadPool.QueueUserWorkItem(_delegateCreator.Compile, null);
-#endif
-                }
-            }
-#endif
-            return false;
-        }
-
-        private InterpretedFrame MakeFrame() {
-            return new InterpretedFrame(_interpreter, _closure);
-        }
-
-        internal void RunVoidRef2<T0, T1>(ref T0 arg0, ref T1 arg1) {
-            if (_compiled != null || TryGetCompiled()) {
-                ((ActionRef<T0, T1>)_compiled)(ref arg0, ref arg1);
-                return;
-            }
-
-            // copy in and copy out for today...
-            var frame = MakeFrame();
-            frame.Data[0] = arg0;
-            frame.Data[1] = arg1;
-            var currentFrame = frame.Enter();
-            try {
-                _interpreter.Run(frame);
-            } finally {
-                frame.Leave(currentFrame);
-                arg0 = (T0)frame.Data[0];
-                arg1 = (T1)frame.Data[1];
-            }
-        }
-
-#if !MONO_INTERPRETER
-        public object Run(params object[] arguments) {
-            if (_compiled != null || TryGetCompiled()) {
-                try {
-                    return _compiled.DynamicInvoke(arguments);
-                } catch (TargetInvocationException e) {
-                    throw ExceptionHelpers.UpdateForRethrow(e.InnerException);
-                }
-            }
-
-            var frame = MakeFrame();
-            for (int i = 0; i < arguments.Length; i++) {
-                frame.Data[i] = arguments[i];
-            }
-            var currentFrame = frame.Enter();
-            try {
-                _interpreter.Run(frame);
-            } finally {
-                frame.Leave(currentFrame);
-            }
-            return frame.Pop();
-        }
-#endif
-    }
-}

+ 0 - 260
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambdaClosureVisitor.cs

@@ -1,260 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Utils;
-using AstUtils = Microsoft.Scripting.Ast.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-
-    /// <summary>
-    /// Visits a LambdaExpression, replacing the constants with direct accesses
-    /// to their StrongBox fields. This is very similar to what
-    /// ExpressionQuoter does for LambdaCompiler.
-    /// 
-    /// Also inserts debug information tracking similar to what the interpreter
-    /// would do.
-    /// </summary>
-    internal sealed class LightLambdaClosureVisitor : ExpressionVisitor {
-        /// <summary>
-        /// Local variable mapping.
-        /// </summary>
-        private readonly Dictionary<ParameterExpression, LocalVariable> _closureVars;
-
-        /// <summary>
-        /// The variable that holds onto the StrongBox{object}[] closure from
-        /// the interpreter
-        /// </summary>
-        private readonly ParameterExpression _closureArray;
-
-        /// <summary>
-        /// A stack of variables that are defined in nested scopes. We search
-        /// this first when resolving a variable in case a nested scope shadows
-        /// one of our variable instances.
-        /// </summary>
-        private readonly Stack<HashSet<ParameterExpression>> _shadowedVars = new Stack<HashSet<ParameterExpression>>();
-
-        private LightLambdaClosureVisitor(Dictionary<ParameterExpression, LocalVariable> closureVariables, ParameterExpression closureArray) {
-            Assert.NotNull(closureVariables, closureArray);
-            _closureArray = closureArray;
-            _closureVars = closureVariables;
-        }
-
-        /// <summary>
-        /// Walks the lambda and produces a higher order function, which can be
-        /// used to bind the lambda to a closure array from the interpreter.
-        /// </summary>
-        /// <param name="lambda">The lambda to bind.</param>
-        /// <param name="closureVariables">Variables which are being accessed defined in the outer scope.</param>
-        /// <returns>A delegate that can be called to produce a delegate bound to the passed in closure array.</returns>
-        internal static Func<StrongBox<object>[], Delegate> BindLambda(LambdaExpression lambda, Dictionary<ParameterExpression, LocalVariable> closureVariables) {
-            // 1. Create rewriter
-            var closure = Expression.Parameter(typeof(StrongBox<object>[]), "closure");
-            var visitor = new LightLambdaClosureVisitor(closureVariables, closure);
-
-            // 2. Visit the lambda
-            lambda = (LambdaExpression)visitor.Visit(lambda);
-
-            // 3. Create a higher-order function which fills in the parameters
-            var result = Expression.Lambda<Func<StrongBox<object>[], Delegate>>(lambda, closure);
-
-            // 4. Compile it
-            return result.Compile();
-        }
-
-        #region closures
-
-        protected override Expression VisitLambda<T>(Expression<T> node) {
-            _shadowedVars.Push(new HashSet<ParameterExpression>(node.Parameters));
-            Expression b = Visit(node.Body);
-            _shadowedVars.Pop();
-            if (b == node.Body) {
-                return node;
-            }
-            return Expression.Lambda<T>(b, node.Name, node.TailCall, node.Parameters);
-        }
-
-        protected override Expression VisitBlock(BlockExpression node) {
-            if (node.Variables.Count > 0) {
-                _shadowedVars.Push(new HashSet<ParameterExpression>(node.Variables));
-            }
-            var b = Visit(node.Expressions);
-            if (node.Variables.Count > 0) {
-                _shadowedVars.Pop();
-            }
-            if (b == node.Expressions) {
-                return node;
-            }
-            return Expression.Block(node.Variables, b);
-        }
-
-        protected override CatchBlock VisitCatchBlock(CatchBlock node) {
-            if (node.Variable != null) {
-                _shadowedVars.Push(new HashSet<ParameterExpression>(new[] { node.Variable }));
-            }
-            Expression b = Visit(node.Body);
-            Expression f = Visit(node.Filter);
-            if (node.Variable != null) {
-                _shadowedVars.Pop();
-            }
-            if (b == node.Body && f == node.Filter) {
-                return node;
-            }
-            return Expression.MakeCatchBlock(node.Test, node.Variable, b, f);
-        }
-
-        protected override Expression VisitRuntimeVariables(RuntimeVariablesExpression node) {
-            int count = node.Variables.Count;
-            var boxes = new List<Expression>();
-            var vars = new List<ParameterExpression>();
-            var indexes = new int[count];
-            for (int i = 0; i < count; i++) {
-                Expression box = GetClosureItem(node.Variables[i], false);
-                if (box == null) {
-                    indexes[i] = vars.Count;
-                    vars.Add(node.Variables[i]);
-                } else {
-                    indexes[i] = -1 - boxes.Count;
-                    boxes.Add(box);
-                }
-            }
-
-            // No variables were rewritten. Just return the original node.
-            if (boxes.Count == 0) {
-                return node;
-            }
-
-            var boxesArray = Expression.NewArrayInit(typeof(IStrongBox), boxes);
-
-            // All of them were rewritten. Just return the array, wrapped in a
-            // read-only collection.
-            if (vars.Count == 0) {
-                return Expression.Invoke(
-                    Expression.Constant((Func<IStrongBox[], IRuntimeVariables>)RuntimeVariables.Create),
-                    boxesArray
-                );
-            }
-
-            // Otherwise, we need to return an object that merges them
-            Func<IRuntimeVariables, IRuntimeVariables, int[], IRuntimeVariables> helper = MergedRuntimeVariables.Create;
-            return Expression.Invoke(AstUtils.Constant(helper), Expression.RuntimeVariables(vars), boxesArray, AstUtils.Constant(indexes));
-        }
-
-        protected override Expression VisitParameter(ParameterExpression node) {
-            Expression closureItem = GetClosureItem(node, true);
-            if (closureItem == null) {
-                return node;
-            }
-            // Convert can go away if we switch to strongly typed StrongBox
-            return Ast.Utils.Convert(closureItem, node.Type);
-        }
-
-        protected override Expression VisitBinary(BinaryExpression node) {
-            if (node.NodeType == ExpressionType.Assign &&
-                node.Left.NodeType == ExpressionType.Parameter) {
-
-                var variable = (ParameterExpression)node.Left;
-                Expression closureItem = GetClosureItem(variable, true);
-                if (closureItem != null) {
-                    // We need to convert to object to store the value in the box.
-                    return Expression.Block(
-                        new[] { variable },
-                        Expression.Assign(variable, Visit(node.Right)),
-                        Expression.Assign(closureItem, Ast.Utils.Convert(variable, typeof(object))),
-                        variable
-                    );
-                }
-            }
-            return base.VisitBinary(node);
-        }
-
-        private Expression GetClosureItem(ParameterExpression variable, bool unbox) {
-            // Skip variables that are shadowed by a nested scope/lambda
-            foreach (HashSet<ParameterExpression> hidden in _shadowedVars) {
-                if (hidden.Contains(variable)) {
-                    return null;
-                }
-            }
-
-            LocalVariable loc;
-            if (!_closureVars.TryGetValue(variable, out loc)) {
-                throw new InvalidOperationException("unbound variable: " + variable.Name);
-            }
-
-            var result = loc.LoadFromArray(null, _closureArray);
-            return (unbox) ? LightCompiler.Unbox(result) : result;
-        }
-
-        protected override Expression VisitExtension(Expression node) {
-            // Reduce extensions now so we can find embedded variables
-            return Visit(node.ReduceExtensions());
-        }
-
-
-        #region MergedRuntimeVariables
-
-        /// <summary>
-        /// Provides a list of variables, supporing read/write of the values
-        /// </summary>
-        private sealed class MergedRuntimeVariables : IRuntimeVariables {
-            private readonly IRuntimeVariables _first;
-            private readonly IRuntimeVariables _second;
-
-            // For reach item, the index into the first or second list
-            // Positive values mean the first array, negative means the second
-            private readonly int[] _indexes;
-
-            private MergedRuntimeVariables(IRuntimeVariables first, IRuntimeVariables second, int[] indexes) {
-                _first = first;
-                _second = second;
-                _indexes = indexes;
-            }
-
-            internal static IRuntimeVariables Create(IRuntimeVariables first, IRuntimeVariables second, int[] indexes) {
-                return new MergedRuntimeVariables(first, second, indexes);
-            }
-
-            int IRuntimeVariables.Count {
-                get { return _indexes.Length; }
-            }
-
-            object IRuntimeVariables.this[int index] {
-                get {
-                    index = _indexes[index];
-                    return (index >= 0) ? _first[index] : _second[-1 - index];
-                }
-                set {
-                    index = _indexes[index];
-                    if (index >= 0) {
-                        _first[index] = value;
-                    } else {
-                        _second[-1 - index] = value;
-                    }
-                }
-            }
-        }
-        #endregion
-
-        #endregion
-    }
-}

+ 0 - 266
mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LocalVariables.cs

@@ -1,266 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation. 
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
- * copy of the license can be found in the License.html file at the root of this distribution. If 
- * you cannot locate the  Apache License, Version 2.0, please send an email to 
- * [email protected]. By using this source code in any fashion, you are agreeing to be bound 
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-#if FEATURE_CORE_DLR
-using System.Linq.Expressions;
-#else
-using Microsoft.Scripting.Ast;
-#endif
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Interpreter {
-    public sealed class LocalVariable {
-        private const int IsBoxedFlag = 1;
-        private const int InClosureFlag = 2;
-
-        public readonly int Index;
-        private int _flags;
-
-        public bool IsBoxed {
-            get { return (_flags & IsBoxedFlag) != 0; }
-            set {
-                if (value) {
-                    _flags |= IsBoxedFlag;
-                } else {
-                    _flags &= ~IsBoxedFlag;
-                }
-            }
-        }
-
-        public bool InClosure {
-            get { return (_flags & InClosureFlag) != 0; }
-        }
-
-        public bool InClosureOrBoxed {
-            get { return InClosure | IsBoxed; }
-        }
-
-        internal LocalVariable(int index, bool closure, bool boxed) {
-            Index = index;
-            _flags = (closure ? InClosureFlag : 0) | (boxed ? IsBoxedFlag : 0);
-        }
-
-        internal Expression LoadFromArray(Expression frameData, Expression closure) {
-            Expression result = Expression.ArrayAccess(InClosure ? closure : frameData, Expression.Constant(Index));
-            return IsBoxed ? Expression.Convert(result, typeof(StrongBox<object>)) : result;
-        }
-
-        public override string ToString() {
-            return String.Format("{0}: {1} {2}", Index, IsBoxed ? "boxed" : null, InClosure ? "in closure" : null);
-        }
-    }
-
-    public struct LocalDefinition {
-        private readonly int _index;
-        private readonly ParameterExpression _parameter;
-
-        internal LocalDefinition(int localIndex, ParameterExpression parameter) {
-            _index = localIndex;
-            _parameter = parameter;
-        }
-
-        public int Index {
-            get {
-                return _index;
-            }
-        }
-
-        public ParameterExpression Parameter {
-            get {
-                return _parameter;
-            }
-        }
-
-        public override bool Equals(object obj) {
-            if (obj is LocalDefinition) {
-                LocalDefinition other = (LocalDefinition)obj;
-                return other.Index == Index && other.Parameter == Parameter;
-            }
-
-            return false;
-        }
-
-        public override int GetHashCode() {
-            if (_parameter == null) {
-                return 0;
-            }
-            return _parameter.GetHashCode() ^ _index.GetHashCode();
-        }
-
-        public static bool operator ==(LocalDefinition self, LocalDefinition other) {
-            return self.Index == other.Index && self.Parameter == other.Parameter;
-        }
-
-        public static bool operator !=(LocalDefinition self, LocalDefinition other) {
-            return self.Index != other.Index || self.Parameter != other.Parameter;
-        }
-    }
-
-    public sealed class LocalVariables {
-        private readonly HybridReferenceDictionary<ParameterExpression, VariableScope> _variables = new HybridReferenceDictionary<ParameterExpression, VariableScope>();
-        private Dictionary<ParameterExpression, LocalVariable> _closureVariables;
-
-        private int _localCount, _maxLocalCount;
-
-        internal LocalVariables() {
-        }
-
-        public LocalDefinition DefineLocal(ParameterExpression variable, int start) {
-            ContractUtils.RequiresNotNull(variable, "variable");
-            ContractUtils.Requires(start >= 0, "start", "start must be positive");
-
-            LocalVariable result = new LocalVariable(_localCount++, false, false);
-            _maxLocalCount = System.Math.Max(_localCount, _maxLocalCount);
-
-            VariableScope existing, newScope;
-            if (_variables.TryGetValue(variable, out existing)) {
-                newScope = new VariableScope(result, start, existing);
-                if (existing.ChildScopes == null) {
-                    existing.ChildScopes = new List<VariableScope>();
-                }
-                existing.ChildScopes.Add(newScope);
-            } else {
-                newScope = new VariableScope(result, start, null);
-            }
-
-            _variables[variable] = newScope;
-            return new LocalDefinition(result.Index, variable);
-        }
-
-        public void UndefineLocal(LocalDefinition definition, int end) {
-            var scope = _variables[definition.Parameter];
-            scope.Stop = end;
-            if (scope.Parent != null) {
-                _variables[definition.Parameter] = scope.Parent;
-            } else {
-                _variables.Remove(definition.Parameter);
-            }
-            
-            _localCount--;
-        }
-
-        internal void Box(ParameterExpression variable, InstructionList instructions) {
-            var scope = _variables[variable];
-
-            LocalVariable local = scope.Variable;
-            Debug.Assert(!local.IsBoxed && !local.InClosure);
-            _variables[variable].Variable.IsBoxed = true;
-                
-            int curChild = 0;
-            for (int i = scope.Start; i < scope.Stop && i < instructions.Count; i++) {
-                if (scope.ChildScopes != null && scope.ChildScopes[curChild].Start == i) {
-                    // skip boxing in the child scope
-                    var child = scope.ChildScopes[curChild];
-                    i = child.Stop;
-
-                    curChild++;
-                    continue;
-                }
-
-                instructions.SwitchToBoxed(local.Index, i);
-            }
-        }
-
-        public int LocalCount {
-            get { return _maxLocalCount; }
-        }
-
-        public int GetOrDefineLocal(ParameterExpression var) {
-            int index = GetLocalIndex(var);
-            if (index == -1) {
-                return DefineLocal(var, 0).Index;
-            }
-            return index;
-        }
-
-        public int GetLocalIndex(ParameterExpression var) {
-            VariableScope loc;
-            return _variables.TryGetValue(var, out loc) ? loc.Variable.Index : -1;
-        }
-
-        public bool TryGetLocalOrClosure(ParameterExpression var, out LocalVariable local) {
-            VariableScope scope;
-            if (_variables.TryGetValue(var, out scope)) {
-                local = scope.Variable;
-                return true;
-            }
-            if (_closureVariables != null && _closureVariables.TryGetValue(var, out local)) {
-                return true;
-            }
-
-            local = null;
-            return false;
-        }
-
-        /// <summary>
-        /// Gets a copy of the local variables which are defined in the current scope.
-        /// </summary>
-        /// <returns></returns>
-        internal Dictionary<ParameterExpression, LocalVariable> CopyLocals() {
-            var res = new Dictionary<ParameterExpression, LocalVariable>(_variables.Count);
-            foreach (var keyValue in _variables) {
-                res[keyValue.Key] = keyValue.Value.Variable;
-            }
-            return res;
-        }
-
-        /// <summary>
-        /// Checks to see if the given variable is defined within the current local scope.
-        /// </summary>
-        internal bool ContainsVariable(ParameterExpression variable) {
-            return _variables.ContainsKey(variable);
-        }
-
-        /// <summary>
-        /// Gets the variables which are defined in an outer scope and available within the current scope.
-        /// </summary>
-        internal Dictionary<ParameterExpression, LocalVariable> ClosureVariables {
-            get {
-                return _closureVariables;
-            }
-        }
-        
-        internal LocalVariable AddClosureVariable(ParameterExpression variable) {
-            if (_closureVariables == null) {
-                _closureVariables = new Dictionary<ParameterExpression, LocalVariable>();
-            }
-            LocalVariable result = new LocalVariable(_closureVariables.Count, true, false);
-            _closureVariables.Add(variable, result);
-            return result;
-        }
-
-        /// <summary>
-        /// Tracks where a variable is defined and what range of instructions it's used in
-        /// </summary>
-        private sealed class VariableScope {
-            public readonly int Start;
-            public int Stop = Int32.MaxValue;
-            public readonly LocalVariable Variable;
-            public readonly VariableScope Parent;
-            public List<VariableScope> ChildScopes;
-
-            public VariableScope(LocalVariable variable, int start, VariableScope parent) {
-                Variable = variable;
-                Start = start;
-                Parent = parent;
-            }
-        }
-    }
-}

Some files were not shown because too many files changed in this diff