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-02-26 13:44:51 +0400
committerMarek Safar <marek.safar@gmail.com>2014-02-26 13:44:51 +0400
commit32317ae40500badf75b41f8ceb28556c227c1a16 (patch)
tree7cb48f629302ab48f82b1308c3fe58c22d6a0ca3 /mcs/class/dlr
parent0246bd17297841a1f92ab1675d8212e3eafcc656 (diff)
[dlr] Add interpreter increment emit
Diffstat (limited to 'mcs/class/dlr')
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ConstantInstruction.cs61
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs5
-rw-r--r--mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs9
3 files changed, 73 insertions, 2 deletions
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ConstantInstruction.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ConstantInstruction.cs
new file mode 100644
index 00000000000..c200ab12144
--- /dev/null
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ConstantInstruction.cs
@@ -0,0 +1,61 @@
+//
+// ConstantInstruction.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.Collections.Generic;
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using Microsoft.Scripting.Runtime;
+using Microsoft.Scripting.Utils;
+
+namespace Microsoft.Scripting.Interpreter {
+ abstract class ConstantInstruction : Instruction {
+
+ public override int ConsumedStack { get { return 0; } }
+ public override int ProducedStack { get { return 1; } }
+ }
+
+ sealed class PushIntegerValueInstruction : ConstantInstruction {
+ int value;
+
+ public PushIntegerValueInstruction (int value)
+ {
+ this.value = value;
+ }
+
+ public override int Run(InterpretedFrame frame) {
+ frame.Push (value);
+ return +1;
+ }
+
+ public override string ToString() {
+ return "Push(" + value + ")";
+ }
+ }
+}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs
index 28746e65c6b..9dd35973edb 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs
@@ -664,6 +664,11 @@ namespace Microsoft.Scripting.Interpreter {
#endregion
+ public void EmitIncrement (Type type) {
+ Emit (new PushIntegerValueInstruction (1));
+ EmitAdd (type, false);
+ }
+
public void EmitShl(Type type, bool lifted) {
Emit(lifted ? ShlInstruction.CreateLifted(type) : ShlInstruction.Create(type));
}
diff --git a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs
index 32a1bd4e91e..fe0ff2c8af4 100644
--- a/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs
+++ b/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs
@@ -1575,9 +1575,14 @@ namespace Microsoft.Scripting.Interpreter {
}
}
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "expr")]
private void CompileReducibleExpression(Expression expr) {
- throw new System.NotImplementedException();
+ switch (expr.NodeType) {
+ case ExpressionType.PreIncrementAssign:
+ _instructions.EmitIncrement (expr.Type);
+ break;
+ default:
+ throw Assert.Unreachable;
+ }
}
internal void Compile(Expression expr, bool asVoid) {