From ba48e43f0aa17c5db78bbff0a6efe309c4003297 Mon Sep 17 00:00:00 2001
From: Julien Lopez <julien.lopez@lri.fr>
Date: Mon, 29 May 2017 10:48:08 +0200
Subject: [PATCH] Fix in RToQIR

---
 .../truffle/r/nodes/qirinterface/QIRInterface.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java
index eb6b4daac8..f198ec405a 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java
@@ -222,10 +222,8 @@ public final class QIRInterface {
         if (value instanceof REnvironment) {
             REnvironment env = (REnvironment) value;
             final Object queryId = env.get("queryId");
-            if (queryId != null) { // The object is a query
-                final int qid = ((Long) queryId).intValue();
-                return normalize(RContext.queries.get(qid), RContext.envs.get(qid));
-            }
+            if (queryId != null) // The object is a query
+                return normalize(RContext.queries.get((Integer) queryId), RContext.envs.get((Integer) queryId));
             final String tableName = (String) env.get("tableName");
             final String schemaName = (String) env.get("schemaName");
             final String dbName = (String) env.get("dbName");
@@ -291,7 +289,9 @@ public final class QIRInterface {
         }
         if (value instanceof RPromise) {
             final RPromise fun = (RPromise) value;
-            return RToQIRType(src, fun.getValue());
+            if (fun.isEvaluated())
+                return RToQIRType(src, fun.getValue());
+            return RToQIRType(src, fun.getClosure().eval(fun.getFrame()));
         }
         throw new RuntimeException("Unsupported value: " + value);
     }
-- 
GitLab