From 144d60494bf449f3b83dc78298939c608f333c4d Mon Sep 17 00:00:00 2001 From: Mick Jordan <mick.jordan@oracle.com> Date: Fri, 9 Dec 2016 15:19:03 -0800 Subject: [PATCH] add RUnboundValue to ForeignAccess --- .../interop/RForeignAccessFactoryImpl.java | 5 +- .../r/engine/interop/RUnboundValueMR.java | 64 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RUnboundValueMR.java diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java index 539084c106..604725de03 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java @@ -52,6 +52,7 @@ import com.oracle.truffle.r.runtime.data.RRawVector; import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RSymbol; import com.oracle.truffle.r.runtime.data.RTruffleObject; +import com.oracle.truffle.r.runtime.data.RUnboundValue; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; import com.oracle.truffle.r.runtime.env.REnvironment; import com.oracle.truffle.r.runtime.ffi.DLL; @@ -94,7 +95,7 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { RRawVector.class, RComplexVector.class, RStringVector.class, RLogicalVector.class, RFunction.class, RNull.class, REnvironment.class, RList.class, RSymbol.class, - RPairList.class, RExternalPtr.class, + RPairList.class, RExternalPtr.class, RUnboundValue.class, DLLInfo.class, DotSymbol.class}; private static final class ForeignAccessState { @@ -205,6 +206,8 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { foreignAccess = RSymbolMRForeign.createAccess(); } else if (RExternalPtr.class.isAssignableFrom(clazz)) { foreignAccess = RExternalPtrMRForeign.createAccess(); + } else if (RUnboundValue.class.isAssignableFrom(clazz)) { + foreignAccess = RUnboundValueMRForeign.createAccess(); } else { if (RAbstractVector.class.isAssignableFrom(clazz)) { foreignAccess = ForeignAccess.create(RAbstractVector.class, new RAbstractVectorAccessFactory()); diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RUnboundValueMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RUnboundValueMR.java new file mode 100644 index 0000000000..ff0c179f53 --- /dev/null +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RUnboundValueMR.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.engine.interop; + +import com.oracle.truffle.api.interop.CanResolve; +import com.oracle.truffle.api.interop.MessageResolution; +import com.oracle.truffle.api.interop.Resolve; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.engine.TruffleRLanguage; +import com.oracle.truffle.r.runtime.data.RUnboundValue; + +@MessageResolution(receiverType = RUnboundValue.class, language = TruffleRLanguage.class) +public class RUnboundValueMR { + @Resolve(message = "IS_BOXED") + public abstract static class RUnboundValueIsBoxedNode extends Node { + protected Object access(@SuppressWarnings("unused") RUnboundValue receiver) { + return false; + } + } + + @Resolve(message = "HAS_SIZE") + public abstract static class RUnboundValueHasSizeNode extends Node { + protected Object access(@SuppressWarnings("unused") RUnboundValue receiver) { + return false; + } + } + + @Resolve(message = "IS_NULL") + public abstract static class RUnboundValueIsNullNode extends Node { + protected Object access(@SuppressWarnings("unused") RUnboundValue receiver) { + return false; + } + } + + @CanResolve + public abstract static class RUnboundValueCheck extends Node { + + protected static boolean test(TruffleObject receiver) { + return receiver instanceof RUnboundValue; + } + } + +} -- GitLab