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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2014-03-04 22:40:25 +0400
committerMarek Safar <marek.safar@gmail.com>2014-03-04 22:40:25 +0400
commit2f909cf433bbaab590e1c8c18d4001ab36aa4bce (patch)
tree6e4acab9cb8415a812cc2a0ba5adbe898c8ab7c7 /mcs/class/dlr
parent6f96d2d9736274f19822dd66aa954b2d24a7009f (diff)
[interpreter] Size reduction
Diffstat (limited to 'mcs/class/dlr')
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs19
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs13
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs156
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs133
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AritmeticInstruction.cs50
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ComparisonInstruction.cs50
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs178
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs153
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs153
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs2
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs153
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs153
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs77
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs156
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs178
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs131
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs113
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs113
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs156
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs131
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Math/Complex64.cs4
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/MathUtils.cs7
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/ReflectionUtils.cs2
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs5
24 files changed, 776 insertions, 1510 deletions
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs
index 7c75d149125..881f0a3351c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Ast/ConstantExpression.cs
@@ -61,18 +61,24 @@ namespace Microsoft.Scripting.Ast {
return NullLiteral;
}
+#if !MONO_INTERPRETER
BigInteger bi = value as BigInteger;
if ((object)bi != null) {
return BigIntegerConstant(bi);
+#endif
+
#if FEATURE_NUMERICS
- } else if (value is BigInt) {
+ if (value is BigInt)
return BigIntConstant((BigInt)value);
- } else if (value is Complex) {
+ if (value is Complex)
return ComplexConstant((Complex)value);
#endif
- } else if (value is Complex64) {
+
+#if !MONO_INTERPRETER
+ if (value is Complex64)
return Complex64Constant((Complex64)value);
- } else if (value is Type) {
+#endif
+ if (value is Type) {
return Expression.Constant(value, typeof(Type));
} else if (value is ConstructorInfo) {
return Expression.Constant(value, typeof(ConstructorInfo));
@@ -112,6 +118,7 @@ namespace Microsoft.Scripting.Ast {
}
}
+#if !MONO_INTERPRETER
private static Expression BigIntegerConstant(BigInteger value) {
int ival;
if (value.AsInt32(out ival)) {
@@ -167,7 +174,7 @@ namespace Microsoft.Scripting.Ast {
);
#endif
}
-
+#endif
private static Expression CreateArray<T>(T[] array) {
// TODO: could we use blobs?
Expression[] init = new Expression[array.Length];
@@ -201,6 +208,7 @@ namespace Microsoft.Scripting.Ast {
}
#endif
+#if !MONO_INTERPRETER
private static Expression Complex64Constant(Complex64 value) {
if (value.Real != 0.0) {
if (value.Imag != 0.0) {
@@ -222,5 +230,6 @@ namespace Microsoft.Scripting.Ast {
);
}
}
+#endif
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs
index 919d1b5b5e5..5f3cba2ff6e 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs
@@ -29,6 +29,7 @@ using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Reflection;
+using System.Threading;
#if FEATURE_REFEMIT
using System.Reflection.Emit;
#endif
@@ -47,8 +48,8 @@ namespace Microsoft.Scripting.Generation {
public delegate void ActionRef<T0, T1>(ref T0 arg0, ref T1 arg1);
public static class CompilerHelpers {
- public static readonly MethodAttributes PublicStatic = MethodAttributes.Public | MethodAttributes.Static;
- private static readonly MethodInfo _CreateInstanceMethod = typeof(ScriptingRuntimeHelpers).GetMethod("CreateInstance");
+ public const MethodAttributes PublicStatic = MethodAttributes.Public | MethodAttributes.Static;
+ private static MethodInfo _CreateInstanceMethod;
private static int _Counter; // for generating unique names for lambda methods
@@ -110,7 +111,10 @@ namespace Microsoft.Scripting.Generation {
if (mb.IsGenericMethod) {
MethodInfo mi = mb as MethodInfo;
- if (mi.GetGenericMethodDefinition() == _CreateInstanceMethod) {
+ if (_CreateInstanceMethod == null)
+ Interlocked.CompareExchange (ref _CreateInstanceMethod, typeof(ScriptingRuntimeHelpers).GetMethod ("CreateInstance"), null);
+
+ if (mi.GetGenericMethodDefinition() == _CreateInstanceMethod) {
return true;
}
}
@@ -875,7 +879,7 @@ namespace Microsoft.Scripting.Generation {
)
);
}
-
+#if !MONO_INTERPRETER
#region Factories
#if !FEATURE_NUMERICS
[CLSCompliant(false)]
@@ -902,5 +906,6 @@ namespace Microsoft.Scripting.Generation {
#endif
#endregion
+#endif
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs
index 3846e4d215f..1cdb14a387c 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs
@@ -19,92 +19,66 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class AddInstruction : Instruction {
- private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ internal abstract class AddInstruction : AritmeticInstruction {
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
+ private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
private AddInstruction() {
}
internal sealed class AddInt32 : AddInstruction {
- 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(unchecked((Int32)l + (Int32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l + (Int32)r));
}
}
internal sealed class AddInt16 : AddInstruction {
- 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)unchecked((Int16)l + (Int16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16)unchecked((Int16)l + (Int16)r);
}
}
internal sealed class AddInt64 : AddInstruction {
- 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)unchecked((Int64)l + (Int64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)unchecked((Int64)l + (Int64)r);
}
}
internal sealed class AddUInt16 : AddInstruction {
- 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)unchecked((UInt16)l + (UInt16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16)unchecked((UInt16)l + (UInt16)r);
}
}
internal sealed class AddUInt32 : AddInstruction {
- 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)unchecked((UInt32)l + (UInt32)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)unchecked((UInt32)l + (UInt32)r);
}
}
internal sealed class AddUInt64 : AddInstruction {
- 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)unchecked((UInt64)l + (UInt64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)unchecked((UInt64)l + (UInt64)r);
}
}
internal sealed class AddSingle : AddInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Single)((Single)l + (Single)r);
}
}
internal sealed class AddDouble : AddInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Double)l + (Double)r;
}
}
@@ -130,92 +104,66 @@ namespace Microsoft.Scripting.Interpreter {
}
}
- internal abstract class AddOvfInstruction : Instruction {
- private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ internal abstract class AddOvfInstruction : AritmeticInstruction {
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
+ private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
private AddOvfInstruction() {
}
internal sealed class AddOvfInt32 : AddOvfInstruction {
- 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(checked((Int32)l + (Int32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject(checked((Int32)l + (Int32)r));
}
}
internal sealed class AddOvfInt16 : AddOvfInstruction {
- 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] = checked((Int16)((Int16)l + (Int16)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((Int16)((Int16)l + (Int16)r));
}
}
internal sealed class AddOvfInt64 : AddOvfInstruction {
- 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] = checked((Int64)((Int64)l + (Int64)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((Int64)((Int64)l + (Int64)r));
}
}
internal sealed class AddOvfUInt16 : AddOvfInstruction {
- 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] = checked((UInt16)((UInt16)l + (UInt16)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt16)((UInt16)l + (UInt16)r));
}
}
internal sealed class AddOvfUInt32 : AddOvfInstruction {
- 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] = checked((UInt32)((UInt32)l + (UInt32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt32)((UInt32)l + (UInt32)r));
}
}
internal sealed class AddOvfUInt64 : AddOvfInstruction {
- 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] = checked((UInt64)((UInt64)l + (UInt64)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt64)((UInt64)l + (UInt64)r));
}
}
internal sealed class AddOvfSingle : AddOvfInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Single)((Single)l + (Single)r);
}
}
internal sealed class AddOvfDouble : AddOvfInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Double)l + (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs
index 2b423f581f0..b8f21ccca21 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AndInstruction.cs
@@ -1,5 +1,5 @@
//
-// AndbInstruction.cs:
+// AndInstruction.cs:
//
// Authors: Marek Safar (marek.safar@gmail.com)
//
@@ -32,153 +32,108 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class AndInstruction : Instruction {
+ internal abstract class AndInstruction : AritmeticInstruction {
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 2; } }
- public override int ProducedStack { get { return 1; } }
-
private AndInstruction() {
}
internal sealed class AndInt32 : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int32)frame.Data[frame.StackIndex - 2];
- var r = (Int32)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = ScriptingRuntimeHelpers.Int32ToObject(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject((Int32)l & (Int32)r);
}
}
internal sealed class AndInt16 : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int16)frame.Data[frame.StackIndex - 2];
- var r = (Int16)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int16)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16)((Int16)l & (Int16)r);
}
}
internal sealed class AndInt64 : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int64)frame.Data[frame.StackIndex - 2];
- var r = (Int64)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)((Int64)l & (Int64)r);
}
}
internal sealed class AndUInt16 : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt16)frame.Data[frame.StackIndex - 2];
- var r = (UInt16)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt16)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16)((UInt16)l & (UInt16)r);
}
}
internal sealed class AndUInt32 : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt32)frame.Data[frame.StackIndex - 2];
- var r = (UInt32)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)((UInt32)l & (UInt32)r);
}
}
internal sealed class AndUInt64 : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt64)frame.Data[frame.StackIndex - 2];
- var r = (UInt64)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)((UInt64)l & (UInt64)r);
}
}
internal sealed class AndBoolean : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Boolean)frame.Data[frame.StackIndex - 2];
- var r = (Boolean)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Boolean)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Boolean)((Boolean)l & (Boolean)r);
}
}
internal sealed class AndInt32Lifted : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int32?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32?)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32?)((Int32?)l & (Int32?)r);
}
}
internal sealed class AndInt16Lifted : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int16?)frame.Data[frame.StackIndex - 2];
- var r = (Int16?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int16?)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16?)((Int16?)l & (Int16?)r);
}
}
internal sealed class AndInt64Lifted : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int64?)frame.Data[frame.StackIndex - 2];
- var r = (Int64?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64?)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64?)((Int64?)l & (Int64?)r);
}
}
internal sealed class AndUInt16Lifted : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt16?)frame.Data[frame.StackIndex - 2];
- var r = (UInt16?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt16?)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16?)((UInt16?)l & (UInt16?)r);
}
}
internal sealed class AndUInt32Lifted : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt32?)frame.Data[frame.StackIndex - 2];
- var r = (UInt32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32?)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32?)((UInt32?)l & (UInt32?)r);
}
}
internal sealed class AndUInt64Lifted : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt64?)frame.Data[frame.StackIndex - 2];
- var r = (UInt64?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64?)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64?)((UInt64?)l & (UInt64?)r);
}
}
internal sealed class AndBooleanLifted : AndInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Boolean?)frame.Data[frame.StackIndex - 2];
- var r = (Boolean?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Boolean?)(l & r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return ((Boolean?)l & (Boolean?)r);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AritmeticInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AritmeticInstruction.cs
new file mode 100644
index 00000000000..03e6694737b
--- /dev/null
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AritmeticInstruction.cs
@@ -0,0 +1,50 @@
+//
+// AritmeticInstruction.cs:
+//
+// Authors: Marek Safar (marek.safar@gmail.com)
+//
+// 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 AritmeticInstruction : 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;
+ }
+ }
+}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ComparisonInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ComparisonInstruction.cs
new file mode 100644
index 00000000000..622e86038b2
--- /dev/null
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ComparisonInstruction.cs
@@ -0,0 +1,50 @@
+//
+// AritmeticInstruction.cs:
+//
+// Authors: Marek Safar (marek.safar@gmail.com)
+//
+// 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 : AritmeticInstruction {
+
+ 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);
+ }
+}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
index 38e904d3eae..cc89ee3d444 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs
@@ -22,191 +22,113 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class EqualInstruction : Instruction {
+ internal abstract class EqualInstruction : ComparisonInstruction {
// Perf: EqualityComparer<T> but is 3/2 to 2 times slower.
private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
private static Instruction _BooleanLifted, _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted,
_ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private EqualInstruction() {
}
- public bool LiftedToNull { get; set; }
+ protected override object DoNullComparison (object l, object r)
+ {
+ return LiftedToNull ? (object) null : (object) l == r;
+ }
internal sealed class EqualBoolean : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Boolean)l == (Boolean)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Boolean)l == (Boolean)r;
}
}
internal sealed class EqualSByte : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (SByte)l == (SByte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (SByte)l == (SByte)r;
}
}
internal sealed class EqualInt16 : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Int16)l == (Int16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int16)l == (Int16)r;
}
}
internal sealed class EqualChar : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Char)l == (Char)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Char)l == (Char)r;
}
}
internal sealed class EqualInt32 : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Int32)l == (Int32)r;
-
- frame.StackIndex--;
- return +1; }
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int32)l == (Int32)r;
+ }
}
internal sealed class EqualInt64 : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Int64)l == (Int64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int64)l == (Int64)r;
}
}
internal sealed class EqualByte : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Byte)l == (Byte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Byte)l == (Byte)r;
}
}
internal sealed class EqualUInt16 : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (UInt16)l == (UInt16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt16)l == (UInt16)r;
}
}
internal sealed class EqualUInt32 : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (UInt32)l == (UInt32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt32)l == (UInt32)r;
}
}
internal sealed class EqualUInt64 : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (UInt64)l == (UInt64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt64)l == (UInt64)r;
}
}
internal sealed class EqualSingle : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Single)l == (Single)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Single)l == (Single)r;
}
}
internal sealed class EqualDouble : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l == r;
- else
- frame.Data[frame.StackIndex - 2] = (Double)l == (Double)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Double)l == (Double)r;
}
}
internal sealed class EqualReference : EqualInstruction {
- public override int Run(InterpretedFrame frame) {
- frame.Push(frame.Pop() == frame.Pop());
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return l == r;
+ }
+
+ protected override object DoCalculate (object l, object r)
+ {
+ throw Assert.Unreachable;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs
index 8849613fd51..48d69a85ae6 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs
@@ -35,169 +35,92 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- public abstract class GreaterThanInstruction : Instruction {
+ 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;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private GreaterThanInstruction() {
}
- public bool LiftedToNull { get; set; }
+ protected override object DoNullComparison (object l, object r)
+ {
+ return LiftedToNull ? (object) null : (object) false;
+ }
internal sealed class GreaterThanSByte : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (SByte)l > (SByte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (SByte)l > (SByte)r;
}
}
internal sealed class GreaterThanInt16 : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int16)l > (Int16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int16)l > (Int16)r;
}
}
internal sealed class GreaterThanChar : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Char)l > (Char)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Char)l > (Char)r;
}
}
internal sealed class GreaterThanInt32 : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int32)l > (Int32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int32)l > (Int32)r;
}
}
internal sealed class GreaterThanInt64 : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int64)l > (Int64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int64)l > (Int64)r;
}
}
internal sealed class GreaterThanByte : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Byte)l > (Byte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Byte)l > (Byte)r;
}
}
internal sealed class GreaterThanUInt16 : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt16)l > (UInt16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt16)l > (UInt16)r;
}
}
internal sealed class GreaterThanUInt32 : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt32)l > (UInt32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt32)l > (UInt32)r;
}
}
internal sealed class GreaterThanUInt64 : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt64)l > (UInt64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt64)l > (UInt64)r;
}
}
internal sealed class GreaterThanSingle : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Single)l > (Single)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Single)l > (Single)r;
}
}
internal sealed class GreaterThanDouble : GreaterThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Double)l > (Double)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Double)l > (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs
index de2da8fd965..fd3f5ecdb17 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanOrEqualInstruction.cs
@@ -35,169 +35,92 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- public abstract class GreaterThanOrEqualInstruction : Instruction {
+ 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;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private GreaterThanOrEqualInstruction() {
}
- public bool LiftedToNull { get; set; }
+ protected override object DoNullComparison (object l, object r)
+ {
+ return LiftedToNull ? (object) null : (object) false;
+ }
internal sealed class GreaterThanOrEqualSByte : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (SByte)l >= (SByte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (SByte)l >= (SByte)r;
}
}
internal sealed class GreaterThanOrEqualInt16 : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int16)l >= (Int16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int16)l >= (Int16)r;
}
}
internal sealed class GreaterThanOrEqualChar : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Char)l >= (Char)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Char)l >= (Char)r;
}
}
internal sealed class GreaterThanOrEqualInt32 : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int32)l >= (Int32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int32)l >= (Int32)r;
}
}
internal sealed class GreaterThanOrEqualInt64 : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int64)l >= (Int64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int64)l >= (Int64)r;
}
}
internal sealed class GreaterThanOrEqualByte : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Byte)l >= (Byte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Byte)l >= (Byte)r;
}
}
internal sealed class GreaterThanOrEqualUInt16 : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt16)l >= (UInt16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt16)l >= (UInt16)r;
}
}
internal sealed class GreaterThanOrEqualUInt32 : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt32)l >= (UInt32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt32)l >= (UInt32)r;
}
}
internal sealed class GreaterThanOrEqualUInt64 : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt64)l >= (UInt64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt64)l >= (UInt64)r;
}
}
internal sealed class GreaterThanOrEqualSingle : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Single)l >= (Single)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Single)l >= (Single)r;
}
}
internal sealed class GreaterThanOrEqualDouble : GreaterThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Double)l >= (Double)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Double)l >= (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs
index 5f916ce64b6..4a1f464a53e 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionFactory.cs
@@ -48,7 +48,9 @@ namespace Microsoft.Scripting.Interpreter {
#if FEATURE_NUMERICS
{ typeof(BigInt), InstructionFactory<BigInt>.Factory },
#endif
+#if !MONO_INTERPRETER
{ typeof(BigInteger), InstructionFactory<BigInteger>.Factory }
+#endif
};
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs
index 3bde7a4ee8f..586deb8bd23 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs
@@ -35,169 +35,92 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- public abstract class LessThanInstruction : Instruction {
+ 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;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private LessThanInstruction() {
}
- public bool LiftedToNull { get; set; }
+ protected override object DoNullComparison (object l, object r)
+ {
+ return LiftedToNull ? (object) null : (object) false;
+ }
internal sealed class LessThanSByte : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (SByte)l < (SByte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (SByte)l < (SByte)r;
}
}
internal sealed class LessThanInt16 : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int16)l < (Int16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int16)l < (Int16)r;
}
}
internal sealed class LessThanChar : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Char)l < (Char)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Char)l < (Char)r;
}
}
internal sealed class LessThanInt32 : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int32)l < (Int32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int32)l < (Int32)r;
}
}
internal sealed class LessThanInt64 : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int64)l < (Int64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int64)l < (Int64)r;
}
}
internal sealed class LessThanByte : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Byte)l < (Byte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Byte)l < (Byte)r;
}
}
internal sealed class LessThanUInt16 : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt16)l < (UInt16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt16)l < (UInt16)r;
}
}
internal sealed class LessThanUInt32 : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt32)l < (UInt32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt32)l < (UInt32)r;
}
}
internal sealed class LessThanUInt64 : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt64)l < (UInt64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt64)l < (UInt64)r;
}
}
internal sealed class LessThanSingle : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Single)l < (Single)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Single)l < (Single)r;
}
}
internal sealed class LessThanDouble : LessThanInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Double)l < (Double)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Double)l < (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs
index 6c120f59349..a441ee52a2b 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanOrEqualInstruction.cs
@@ -35,169 +35,92 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- public abstract class LessThanOrEqualInstruction : Instruction {
+ 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;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private LessThanOrEqualInstruction() {
}
- public bool LiftedToNull { get; set; }
+ protected override object DoNullComparison (object l, object r)
+ {
+ return LiftedToNull ? (object) null : (object) false;
+ }
internal sealed class LessThanOrEqualSByte : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (SByte)l <= (SByte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (SByte)l <= (SByte)r;
}
}
internal sealed class LessThanOrEqualInt16 : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int16)l <= (Int16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int16)l <= (Int16)r;
}
}
internal sealed class LessThanOrEqualChar : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Char)l <= (Char)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Char)l <= (Char)r;
}
}
internal sealed class LessThanOrEqualInt32 : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int32)l <= (Int32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int32)l <= (Int32)r;
}
}
internal sealed class LessThanOrEqualInt64 : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Int64)l <= (Int64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int64)l <= (Int64)r;
}
}
internal sealed class LessThanOrEqualByte : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Byte)l <= (Byte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Byte)l <= (Byte)r;
}
}
internal sealed class LessThanOrEqualUInt16 : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt16)l <= (UInt16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt16)l <= (UInt16)r;
}
}
internal sealed class LessThanOrEqualUInt32 : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt32)l <= (UInt32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt32)l <= (UInt32)r;
}
}
internal sealed class LessThanOrEqualUInt64 : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (UInt64)l <= (UInt64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt64)l <= (UInt64)r;
}
}
internal sealed class LessThanOrEqualSingle : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Single)l <= (Single)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Single)l <= (Single)r;
}
}
internal sealed class LessThanOrEqualDouble : LessThanOrEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) false;
- else
- frame.Data[frame.StackIndex - 2] = (Double)l <= (Double)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Double)l <= (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs
index 4e8bb37138c..1718a7299cb 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ModInstruction.cs
@@ -32,92 +32,65 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class ModInstruction : Instruction {
+ internal abstract class ModInstruction : AritmeticInstruction {
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 ModInstruction() {
}
internal sealed class ModInt32 : ModInstruction {
- 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(unchecked((Int32)l % (Int32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l % (Int32)r));
}
}
internal sealed class ModInt16 : ModInstruction {
- 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)unchecked((Int16)l % (Int16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16)unchecked((Int16)l % (Int16)r);
}
}
internal sealed class ModInt64 : ModInstruction {
- 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)unchecked((Int64)l % (Int64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)unchecked((Int64)l % (Int64)r);
}
}
internal sealed class ModUInt16 : ModInstruction {
- 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)unchecked((UInt16)l % (UInt16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16)unchecked((UInt16)l % (UInt16)r);
}
}
internal sealed class ModUInt32 : ModInstruction {
- 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)unchecked((UInt32)l % (UInt32)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)unchecked((UInt32)l % (UInt32)r);
}
}
internal sealed class ModUInt64 : ModInstruction {
- 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)unchecked((UInt64)l % (UInt64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)unchecked((UInt64)l % (UInt64)r);
}
}
internal sealed class ModSingle : ModInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Single)((Single)l % (Single)r);
}
}
internal sealed class ModDouble : ModInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Double)l % (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs
index 745e1a0bcad..526b24e54d5 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/MulInstruction.cs
@@ -32,92 +32,66 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class MulInstruction : Instruction {
- private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ internal abstract class MulInstruction : AritmeticInstruction {
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
+ private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
private MulInstruction() {
}
internal sealed class MulInt32 : MulInstruction {
- 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(unchecked((Int32)l * (Int32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l * (Int32)r));
}
}
internal sealed class MulInt16 : MulInstruction {
- 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)unchecked((Int16)l * (Int16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16)unchecked((Int16)l * (Int16)r);
}
}
internal sealed class MulInt64 : MulInstruction {
- 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)unchecked((Int64)l * (Int64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)unchecked((Int64)l * (Int64)r);
}
}
internal sealed class MulUInt16 : MulInstruction {
- 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)unchecked((UInt16)l * (UInt16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16)unchecked((UInt16)l * (UInt16)r);
}
}
internal sealed class MulUInt32 : MulInstruction {
- 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)unchecked((UInt32)l * (UInt32)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)unchecked((UInt32)l * (UInt32)r);
}
}
internal sealed class MulUInt64 : MulInstruction {
- 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)unchecked((UInt64)l * (UInt64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)unchecked((UInt64)l * (UInt64)r);
}
}
internal sealed class MulSingle : MulInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Single)((Single)l * (Single)r);
}
}
internal sealed class MulDouble : MulInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Double)l * (Double)r;
}
}
@@ -143,92 +117,66 @@ namespace Microsoft.Scripting.Interpreter {
}
}
- internal abstract class MulOvfInstruction : Instruction {
- private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ internal abstract class MulOvfInstruction : AritmeticInstruction {
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
+ private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
private MulOvfInstruction() {
}
internal sealed class MulOvfInt32 : MulOvfInstruction {
- 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(checked((Int32)l * (Int32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject(checked((Int32)l * (Int32)r));
}
}
internal sealed class MulOvfInt16 : MulOvfInstruction {
- 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] = checked((Int16)((Int16)l * (Int16)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((Int16)((Int16)l * (Int16)r));
}
}
internal sealed class MulOvfInt64 : MulOvfInstruction {
- 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] = checked((Int64)((Int64)l * (Int64)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((Int64)((Int64)l * (Int64)r));
}
}
internal sealed class MulOvfUInt16 : MulOvfInstruction {
- 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] = checked((UInt16)((UInt16)l * (UInt16)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt16)((UInt16)l * (UInt16)r));
}
}
internal sealed class MulOvfUInt32 : MulOvfInstruction {
- 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] = checked((UInt32)((UInt32)l * (UInt32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt32)((UInt32)l * (UInt32)r));
}
}
internal sealed class MulOvfUInt64 : MulOvfInstruction {
- 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] = checked((UInt64)((UInt64)l * (UInt64)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt64)((UInt64)l * (UInt64)r));
}
}
internal sealed class MulOvfSingle : MulOvfInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Single)((Single)l * (Single)r);
}
}
internal sealed class MulOvfDouble : MulOvfInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Double)l * (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
index 2bd1224374f..396c3ff7159 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs
@@ -22,191 +22,113 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class NotEqualInstruction : Instruction {
+ internal abstract class NotEqualInstruction : ComparisonInstruction {
// Perf: EqualityComparer<T> but is 3/2 to 2 times slower.
private static Instruction _Reference, _Boolean, _SByte, _Int16, _Char, _Int32, _Int64, _Byte, _UInt16, _UInt32, _UInt64, _Single, _Double;
private static Instruction _BooleanLifted, _SByteLifted, _Int16Lifted, _CharLifted, _Int32Lifted, _Int64Lifted,
_ByteLifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted, _SingleLifted, _DoubleLifted;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private NotEqualInstruction() {
}
- public bool LiftedToNull { get; set; }
+ protected override object DoNullComparison (object l, object r)
+ {
+ return LiftedToNull ? (object) null : (object) l != r;
+ }
internal sealed class NotEqualBoolean : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Boolean)l != (Boolean)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Boolean)l != (Boolean)r;
}
}
internal sealed class NotEqualSByte : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (SByte)l != (SByte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (SByte)l != (SByte)r;
}
}
internal sealed class NotEqualInt16 : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Int16)l != (Int16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int16)l != (Int16)r;
}
}
internal sealed class NotEqualChar : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Char)l != (Char)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Char)l != (Char)r;
}
}
internal sealed class NotEqualInt32 : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Int32)l != (Int32)r;
-
- frame.StackIndex--;
- return +1; }
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int32)l != (Int32)r;
+ }
}
internal sealed class NotEqualInt64 : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Int64)l != (Int64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Int64)l != (Int64)r;
}
}
internal sealed class NotEqualByte : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Byte)l != (Byte)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Byte)l != (Byte)r;
}
}
internal sealed class NotEqualUInt16 : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (UInt16)l != (UInt16)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt16)l != (UInt16)r;
}
}
internal sealed class NotEqualUInt32 : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (UInt32)l != (UInt32)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt32)l != (UInt32)r;
}
}
internal sealed class NotEqualUInt64 : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (UInt64)l != (UInt64)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (UInt64)l != (UInt64)r;
}
}
internal sealed class NotEqualSingle : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Single)l != (Single)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Single)l != (Single)r;
}
}
internal sealed class NotEqualDouble : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- object l = frame.Data[frame.StackIndex - 2];
- object r = frame.Data[frame.StackIndex - 1];
- if (l == null || r == null)
- frame.Data[frame.StackIndex - 2] = LiftedToNull ? (object) null : (object) l != r;
- else
- frame.Data[frame.StackIndex - 2] = (Double)l != (Double)r;
-
- frame.StackIndex--;
- return +1;
+ protected override object DoCalculate (object l, object r)
+ {
+ return (Double)l != (Double)r;
}
}
internal sealed class NotEqualReference : NotEqualInstruction {
- public override int Run(InterpretedFrame frame) {
- frame.Push(frame.Pop() != frame.Pop());
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return l != r;
+ }
+
+ protected override object DoCalculate (object l, object r)
+ {
+ throw Assert.Unreachable;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs
index baaad40fb70..03d89974eaf 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/OrInstruction.cs
@@ -32,153 +32,108 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class OrInstruction : Instruction {
+ internal abstract class OrInstruction : AritmeticInstruction {
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 2; } }
- public override int ProducedStack { get { return 1; } }
-
private OrInstruction() {
}
internal sealed class OrInt32 : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = frame.Data[frame.StackIndex - 2];
- var r = frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = ScriptingRuntimeHelpers.Int32ToObject((Int32)l | (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject((Int32)l | (Int32)r);
}
}
internal sealed class OrInt16 : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = frame.Data[frame.StackIndex - 2];
- var r = frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int16)((Int16)l | (Int16)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16)((Int16)l | (Int16)r);
}
}
internal sealed class OrInt64 : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = frame.Data[frame.StackIndex - 2];
- var r = frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64)((Int64)l | (Int64)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)((Int64)l | (Int64)r);
}
}
internal sealed class OrUInt16 : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = frame.Data[frame.StackIndex - 2];
- var r = frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt16)((UInt16)l | (UInt16)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16)((UInt16)l | (UInt16)r);
}
}
internal sealed class OrUInt32 : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = frame.Data[frame.StackIndex - 2];
- var r = frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32)((UInt32)l | (UInt32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)((UInt32)l | (UInt32)r);
}
}
internal sealed class OrUInt64 : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = frame.Data[frame.StackIndex - 2];
- var r = frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64)((UInt64)l | (UInt64)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)((UInt64)l | (UInt64)r);
}
}
internal sealed class OrBoolean : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = frame.Data[frame.StackIndex - 2];
- var r = frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Boolean)((Boolean)l | (Boolean)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Boolean)((Boolean)l | (Boolean)r);
}
}
internal sealed class OrInt32Lifted : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int32?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32?)(l | r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32?)((Int32?)l | (Int32?)r);
}
}
internal sealed class OrInt16Lifted : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int16?)frame.Data[frame.StackIndex - 2];
- var r = (Int16?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int16?)(l | r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16?)((Int16?)l | (Int16?)r);
}
}
internal sealed class OrInt64Lifted : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int64?)frame.Data[frame.StackIndex - 2];
- var r = (Int64?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64?)(l | r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64?)((Int64?)l | (Int64?)r);
}
}
internal sealed class OrUInt16Lifted : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt16?)frame.Data[frame.StackIndex - 2];
- var r = (UInt16?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt16?)(l | r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16?)((Int16?)l | (Int16?)r);
}
}
internal sealed class OrUInt32Lifted : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt32?)frame.Data[frame.StackIndex - 2];
- var r = (UInt32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32?)(l | r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32?)((UInt32?)l | (UInt32?)r);
}
}
internal sealed class OrUInt64Lifted : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt64?)frame.Data[frame.StackIndex - 2];
- var r = (UInt64?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64?)(l | r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64?)((UInt64?)l | (UInt64?)r);
}
}
internal sealed class OrBooleanLifted : OrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Boolean?)frame.Data[frame.StackIndex - 2];
- var r = (Boolean?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Boolean?)(l | r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Boolean?)((Boolean?)l | (Boolean?)r);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs
index 5406dd01b00..419be4fcc74 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShlInstruction.cs
@@ -32,133 +32,94 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class ShlInstruction : Instruction {
+ internal abstract class ShlInstruction : AritmeticInstruction {
private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64;
private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private ShlInstruction() {
}
internal sealed class ShlInt32 : ShlInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject((Int32)l << (Int32)r);
}
}
internal sealed class ShlInt16 : ShlInstruction {
- 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] = (Int32)((Int16)l << (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32)((Int16)l << (Int32)r);
}
}
internal sealed class ShlInt64 : ShlInstruction {
- 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 << (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)((Int64)l << (Int32)r);
}
}
internal sealed class ShlUInt16 : ShlInstruction {
- 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] = (Int32)((UInt16)l << (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32)((UInt16)l << (Int32)r);
}
}
internal sealed class ShlUInt32 : ShlInstruction {
- 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 << (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)((UInt32)l << (Int32)r);
}
}
internal sealed class ShlUInt64 : ShlInstruction {
- 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 << (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)((UInt64)l << (Int32)r);
}
}
internal sealed class ShlInt32Lifted : ShlInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int32?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32?)(l << r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32?)((Int32?)l << (Int32?)r);
}
}
internal sealed class ShlInt16Lifted : ShlInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int16?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32)(l << r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32)((Int16?)l << (Int32?)r);
}
}
internal sealed class ShlInt64Lifted : ShlInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int64?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64?)(l << r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64?)((Int64?)l << (Int32?)r);
}
}
internal sealed class ShlUInt16Lifted : ShlInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt16?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32?)(l << r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32?)((UInt16?)l << (Int32?)r);
}
}
internal sealed class ShlUInt32Lifted : ShlInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt32?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32?)(l << r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32?)((UInt32?)l << (Int32?)r);
}
}
internal sealed class ShlUInt64Lifted : ShlInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt64?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64?)(l << r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64?)((UInt64?)l << (Int32?)r);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs
index 5099a41c18b..9af9f363e5d 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ShrInstruction.cs
@@ -32,133 +32,94 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class ShrInstruction : Instruction {
+ internal abstract class ShrInstruction : AritmeticInstruction {
private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64;
private static Instruction _Int16Lifted, _Int32Lifted, _Int64Lifted, _UInt16Lifted, _UInt32Lifted, _UInt64Lifted;
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
-
private ShrInstruction() {
}
internal sealed class ShrInt32 : ShrInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject((Int32)l >> (Int32)r);
}
}
internal sealed class ShrInt16 : ShrInstruction {
- 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] = (Int32)((Int16)l >> (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32)((Int16)l >> (Int32)r);
}
}
internal sealed class ShrInt64 : ShrInstruction {
- 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 >> (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)((Int64)l >> (Int32)r);
}
}
internal sealed class ShrUInt16 : ShrInstruction {
- 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] = (Int32)((UInt16)l >> (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32)((UInt16)l >> (Int32)r);
}
}
internal sealed class ShrUInt32 : ShrInstruction {
- 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 >> (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)((UInt32)l >> (Int32)r);
}
}
internal sealed class ShrUInt64 : ShrInstruction {
- 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 >> (Int32)r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)((UInt64)l >> (Int32)r);
}
}
internal sealed class ShrInt32Lifted : ShrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int32?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32?)(l >> r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32?)((Int32?)l >> (Int32?)r);
}
}
internal sealed class ShrInt16Lifted : ShrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int16?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32)(l >> r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32)((Int16?)l >> (Int32?)r);
}
}
internal sealed class ShrInt64Lifted : ShrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int64?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64?)(l >> r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64?)((Int64?)l >> (Int32?)r);
}
}
internal sealed class ShrUInt16Lifted : ShrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt16?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32?)(l >> r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32?)((UInt16?)l >> (Int32?)r);
}
}
internal sealed class ShrUInt32Lifted : ShrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt32?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32?)(l >> r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32?)((UInt32?)l >> (Int32?)r);
}
}
internal sealed class ShrUInt64Lifted : ShrInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt64?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64?)(l >> r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64?)((UInt64?)l >> (Int32?)r);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs
index 8ca97e97f7e..2c088e4fb09 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/SubInstruction.cs
@@ -32,92 +32,66 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class SubInstruction : Instruction {
- private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ internal abstract class SubInstruction : AritmeticInstruction {
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
+ private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
private SubInstruction() {
}
internal sealed class SubInt32 : SubInstruction {
- 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(unchecked((Int32)l - (Int32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject(unchecked((Int32)l - (Int32)r));
}
}
internal sealed class SubInt16 : SubInstruction {
- 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)unchecked((Int16)l - (Int16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16)unchecked((Int16)l - (Int16)r);
}
}
internal sealed class SubInt64 : SubInstruction {
- 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)unchecked((Int64)l - (Int64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)unchecked((Int64)l - (Int64)r);
}
}
internal sealed class SubUInt16 : SubInstruction {
- 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)unchecked((UInt16)l - (UInt16)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16)unchecked((UInt16)l - (UInt16)r);
}
}
internal sealed class SubUInt32 : SubInstruction {
- 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)unchecked((UInt32)l - (UInt32)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)unchecked((UInt32)l - (UInt32)r);
}
}
internal sealed class SubUInt64 : SubInstruction {
- 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)unchecked((UInt64)l - (UInt64)r);
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)unchecked((UInt64)l - (UInt64)r);
}
}
internal sealed class SubSingle : SubInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Single)((Single)l - (Single)r);
}
}
internal sealed class SubDouble : SubInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Double)l - (Double)r;
}
}
@@ -143,92 +117,66 @@ namespace Microsoft.Scripting.Interpreter {
}
}
- internal abstract class SubOvfInstruction : Instruction {
- private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
+ internal abstract class SubOvfInstruction : AritmeticInstruction {
- public override int ConsumedStack { get { return 2; } }
- public override int ProducedStack { get { return 1; } }
+ private static Instruction _Int16, _Int32, _Int64, _UInt16, _UInt32, _UInt64, _Single, _Double;
private SubOvfInstruction() {
}
internal sealed class SubOvfInt32 : SubOvfInstruction {
- 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(checked((Int32)l - (Int32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject(checked((Int32)l - (Int32)r));
}
}
internal sealed class SubOvfInt16 : SubOvfInstruction {
- 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] = checked((Int16)((Int16)l - (Int16)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((Int16)((Int16)l - (Int16)r));
}
}
internal sealed class SubOvfInt64 : SubOvfInstruction {
- 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] = checked((Int64)((Int64)l - (Int64)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((Int64)((Int64)l - (Int64)r));
}
}
internal sealed class SubOvfUInt16 : SubOvfInstruction {
- 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] = checked((UInt16)((UInt16)l - (UInt16)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt16)((UInt16)l - (UInt16)r));
}
}
internal sealed class SubOvfUInt32 : SubOvfInstruction {
- 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] = checked((UInt32)((UInt32)l - (UInt32)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt32)((UInt32)l - (UInt32)r));
}
}
internal sealed class SubOvfUInt64 : SubOvfInstruction {
- 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] = checked((UInt64)((UInt64)l - (UInt64)r));
- frame.StackIndex--;
- return +1;
+ protected override object Calculate (object l, object r)
+ {
+ return checked((UInt64)((UInt64)l - (UInt64)r));
}
}
internal sealed class SubOvfSingle : SubOvfInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Single)((Single)l - (Single)r);
}
}
internal sealed class SubOvfDouble : SubOvfInstruction {
- 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;
+ protected override object Calculate (object l, object r)
+ {
+ return (Double)l - (Double)r;
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs
index 21f285c02e6..8ad9f606f65 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/XorInstruction.cs
@@ -32,153 +32,108 @@ using Microsoft.Scripting.Runtime;
using Microsoft.Scripting.Utils;
namespace Microsoft.Scripting.Interpreter {
- internal abstract class XorInstruction : Instruction {
+ internal abstract class XorInstruction : AritmeticInstruction {
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 2; } }
- public override int ProducedStack { get { return 1; } }
-
private XorInstruction() {
}
internal sealed class XorInt32 : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int32)frame.Data[frame.StackIndex - 2];
- var r = (Int32)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = ScriptingRuntimeHelpers.Int32ToObject(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return ScriptingRuntimeHelpers.Int32ToObject((Int32)l ^ (Int32)r);
}
}
internal sealed class XorInt16 : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int16)frame.Data[frame.StackIndex - 2];
- var r = (Int16)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int16)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16)((Int16)l ^ (Int16)r);
}
}
internal sealed class XorInt64 : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int64)frame.Data[frame.StackIndex - 2];
- var r = (Int64)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64)((Int64)l ^ (Int64)r);
}
}
internal sealed class XorUInt16 : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt16)frame.Data[frame.StackIndex - 2];
- var r = (UInt16)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt16)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16)((UInt16)l ^ (UInt16)r);
}
}
internal sealed class XorUInt32 : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt32)frame.Data[frame.StackIndex - 2];
- var r = (UInt32)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32)((UInt32)l ^ (UInt32)r);
}
}
internal sealed class XorUInt64 : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt64)frame.Data[frame.StackIndex - 2];
- var r = (UInt64)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64)((UInt64)l ^ (UInt64)r);
}
}
internal sealed class XorBoolean : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Boolean)frame.Data[frame.StackIndex - 2];
- var r = (Boolean)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Boolean)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Boolean)((Boolean)l ^ (Boolean)r);
}
}
internal sealed class XorInt32Lifted : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int32?)frame.Data[frame.StackIndex - 2];
- var r = (Int32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int32?)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int32?)((Int32?)l ^ (Int32?)r);
}
}
internal sealed class XorInt16Lifted : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int16?)frame.Data[frame.StackIndex - 2];
- var r = (Int16?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int16?)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int16?)((Int16?)l ^ (Int16?)r);
}
}
internal sealed class XorInt64Lifted : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Int64?)frame.Data[frame.StackIndex - 2];
- var r = (Int64?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Int64?)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Int64?)((Int64?)l ^ (Int64?)r);
}
}
internal sealed class XorUInt16Lifted : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt16?)frame.Data[frame.StackIndex - 2];
- var r = (UInt16?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt16?)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt16?)((UInt16?)l ^ (UInt16?)r);
}
}
internal sealed class XorUInt32Lifted : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt32?)frame.Data[frame.StackIndex - 2];
- var r = (UInt32?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt32?)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt32?)((UInt32?)l ^ (UInt32?)r);
}
}
internal sealed class XorUInt64Lifted : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (UInt64?)frame.Data[frame.StackIndex - 2];
- var r = (UInt64?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (UInt64?)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (UInt64?)((UInt64?)l ^ (UInt64?)r);
}
}
internal sealed class XorBooleanLifted : XorInstruction {
- public override int Run(InterpretedFrame frame) {
- var l = (Boolean?)frame.Data[frame.StackIndex - 2];
- var r = (Boolean?)frame.Data[frame.StackIndex - 1];
- frame.Data[frame.StackIndex - 2] = (Boolean?)(l ^ r);
- frame.StackIndex--;
- return 1;
+ protected override object Calculate (object l, object r)
+ {
+ return (Boolean?)((Boolean?)l ^ (Boolean?)r);
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Math/Complex64.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Math/Complex64.cs
index bb6da752e40..6a57c23f15a 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Math/Complex64.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Math/Complex64.cs
@@ -21,6 +21,8 @@ using BigInt = System.Numerics.BigInteger;
#endif
namespace Microsoft.Scripting.Math {
+
+#if !MONO_INTERPRETER
/// <summary>
/// Implementation of the complex number data type.
/// </summary>
@@ -273,4 +275,6 @@ namespace Microsoft.Scripting.Math {
return this == ((Complex64)obj);
}
}
+#endif
+
} \ No newline at end of file
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/MathUtils.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/MathUtils.cs
index 3b164273526..435fb259b6b 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/MathUtils.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/MathUtils.cs
@@ -683,7 +683,7 @@ namespace Microsoft.Scripting.Utils {
return four;
}
-
+#if !MONO_INTERPRETER
#if !FEATURE_NUMERICS
public static BigInteger GetRandBits(this Random generator, int bits) {
ContractUtils.Requires(bits > 0);
@@ -825,7 +825,6 @@ namespace Microsoft.Scripting.Utils {
);
}
#endif
-
public static bool TryToFloat64(this BigInteger self, out double result) {
return StringUtils.TryParseDouble(
self.ToString(10),
@@ -865,7 +864,7 @@ namespace Microsoft.Scripting.Utils {
return index * 8 + BitLength((int)bytes[index]);
}
#endif
-
+#endif
// Like GetBitCount(Abs(x)), except 0 maps to 0
public static int BitLength(long x) {
if (x == 0) {
@@ -1163,6 +1162,7 @@ namespace Microsoft.Scripting.Utils {
#endregion
+#if !MONO_INTERPRETER
#region Complex
#if !FEATURE_NUMERICS
@@ -1224,6 +1224,7 @@ namespace Microsoft.Scripting.Utils {
#endif
#endregion
+#endif
}
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/ReflectionUtils.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/ReflectionUtils.cs
index 95e23e634a8..342f258a62d 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/ReflectionUtils.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Utils/ReflectionUtils.cs
@@ -138,7 +138,7 @@ namespace Microsoft.Scripting.Utils {
public static class ReflectionUtils {
#region Accessibility
- public static BindingFlags AllMembers = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
+ public const BindingFlags AllMembers = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
public static bool IsPublic(this PropertyInfo property) {
return property.GetGetMethod(nonPublic: false) != null
diff --git a/mcs/class/dlr/Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs b/mcs/class/dlr/Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs
index d197e8ee4be..4659f3d0f39 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Scripting/PlatformAdaptationLayer.cs
@@ -53,6 +53,9 @@ namespace Microsoft.Scripting {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
public static readonly PlatformAdaptationLayer Default = new PlatformAdaptationLayer();
+#if MONO_INTERPRETER
+ public const bool IsCompactFramework = false;
+#else
public static readonly bool IsCompactFramework =
#if WIN8
false;
@@ -61,6 +64,8 @@ namespace Microsoft.Scripting {
Environment.OSVersion.Platform == PlatformID.Xbox;
#endif
+#endif
+
#if SILVERLIGHT
// this dictionary is readonly after initialization: