From 90bc007fd70e7883b2e535942e6024fea97fbe9a Mon Sep 17 00:00:00 2001
From: Florian Angerer <florian.angerer@oracle.com>
Date: Tue, 22 Aug 2017 16:40:38 +0200
Subject: [PATCH] Fix: missing specialization in CastDoubleNode.

---
 .../com/oracle/truffle/r/nodes/unary/CastDoubleNode.java | 9 +--------
 .../oracle/truffle/r/nodes/unary/CastIntegerNode.java    | 9 ++++-----
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java
index 39060fa71a..40e9f22fcd 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastDoubleNode.java
@@ -37,7 +37,6 @@ import com.oracle.truffle.r.runtime.RType;
 import com.oracle.truffle.r.runtime.data.RComplex;
 import com.oracle.truffle.r.runtime.data.RComplexVector;
 import com.oracle.truffle.r.runtime.data.RDataFactory;
-import com.oracle.truffle.r.runtime.data.RDoubleSequence;
 import com.oracle.truffle.r.runtime.data.RDoubleVector;
 import com.oracle.truffle.r.runtime.data.RList;
 import com.oracle.truffle.r.runtime.data.RRawVector;
@@ -164,13 +163,7 @@ public abstract class CastDoubleNode extends CastDoubleBaseNode {
     }
 
     @Specialization
-    protected RDoubleVector doDoubleVector(RDoubleVector operand) {
-        return operand;
-    }
-
-    @Specialization
-    protected RDoubleSequence doDoubleVector(RDoubleSequence operand) {
-        // sequence does not have attributes - nothing to copy or drop
+    protected RAbstractDoubleVector doDoubleVector(RAbstractDoubleVector operand) {
         return operand;
     }
 
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java
index de06208d8a..0d7552c06c 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/unary/CastIntegerNode.java
@@ -166,14 +166,13 @@ public abstract class CastIntegerNode extends CastIntegerBaseNode {
     }
 
     @Specialization
-    protected RIntVector doDoubleVector(RAbstractDoubleVector operand) {
-        naCheck.enable(operand);
-        return vectorCopy(operand, naCheck.convertDoubleVectorToIntData(operand), naCheck.neverSeenNA());
+    protected RAbstractIntVector doDoubleVector(RAbstractDoubleVector operand) {
+        return castWithReuse(operand, index -> naCheck.convertDoubleToInt(operand.getDataAt(index)));
     }
 
     @Specialization
-    protected RIntVector doRawVector(RAbstractRawVector operand) {
-        return createResultVector(operand, index -> RRuntime.raw2int(operand.getDataAt(index)));
+    protected RAbstractIntVector doRawVector(RAbstractRawVector operand) {
+        return castWithReuse(operand, index -> RRuntime.raw2int(operand.getDataAt(index)));
     }
 
     @Specialization
-- 
GitLab