From 930650e30aa27cf8516520715db87918c74ad341 Mon Sep 17 00:00:00 2001
From: Christian Humer <christian.humer@oracle.com>
Date: Wed, 19 Aug 2015 13:38:53 +0200
Subject: [PATCH] Implement error handling against interface types instead of
 implementation types.

---
 .../truffle/r/runtime/RErrorHandling.java     | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java
index 834bade4a2..9a3bb9c4ce 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RErrorHandling.java
@@ -19,6 +19,7 @@ import com.oracle.truffle.api.source.*;
 import com.oracle.truffle.r.runtime.RError.Message;
 import com.oracle.truffle.r.runtime.context.*;
 import com.oracle.truffle.r.runtime.data.*;
+import com.oracle.truffle.r.runtime.data.model.*;
 import com.oracle.truffle.r.runtime.env.*;
 import com.oracle.truffle.r.runtime.nodes.*;
 
@@ -225,6 +226,18 @@ public class RErrorHandling {
         getRErrorHandlingState().restartStack = RDataFactory.createPairList(restart, getRestartStack());
     }
 
+    private static String castString(Object value) {
+        if (value instanceof String) {
+            return (String) value;
+        } else if (value instanceof RAbstractStringVector) {
+            RAbstractStringVector c = (RAbstractStringVector) value;
+            if (c.getLength() > 0) {
+                return c.getDataAt(0);
+            }
+        }
+        return null;
+    }
+
     private static Object restartExit(RList restart) {
         return restart.getDataAt(0);
     }
@@ -535,7 +548,11 @@ public class RErrorHandling {
 
         // ensured in ROptions
 
-        int w = ((RIntVector) RContext.getInstance().stateROptions.getValue("warn")).getDataAt(0);
+        Object value = RContext.getInstance().stateROptions.getValue("warn");
+        int w = 0;
+        if (value != RNull.instance) {
+            w = ((RAbstractIntVector) value).getDataAt(0);
+        }
         if (w == RRuntime.INT_NA) {
             w = 0;
         }
-- 
GitLab