diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RConnectionMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RConnectionMR.java new file mode 100644 index 0000000000000000000000000000000000000000..45df6f9f1920f0b49d8069efb5df6fb6bed57ed2 --- /dev/null +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RConnectionMR.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2017, 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.TruffleObject; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.engine.TruffleRLanguage; +import com.oracle.truffle.r.runtime.conn.RConnection; + +@MessageResolution(receiverType = RConnection.class, language = TruffleRLanguage.class) +public class RConnectionMR { + @CanResolve + public abstract static class RConnection extends Node { + + protected static boolean test(TruffleObject receiver) { + return receiver instanceof RConnection; + } + } + +} 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 0c91b000ba52e6f8a9319b5296345a20f1661dd3..428399f41fd83bad08cf5d86c59d0f6e86287b1f 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 @@ -28,6 +28,7 @@ import com.oracle.truffle.api.interop.ForeignAccess; import com.oracle.truffle.api.interop.MessageResolution; import com.oracle.truffle.r.engine.TruffleRLanguage; import com.oracle.truffle.r.runtime.RInternalError; +import com.oracle.truffle.r.runtime.conn.RConnection; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RForeignAccessFactory; import com.oracle.truffle.r.runtime.data.RDouble; @@ -92,6 +93,8 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { return RDoubleMRForeign.ACCESS; } else if (obj instanceof CharSXPWrapper) { return CharSXPWrapperMRForeign.ACCESS; + } else if (obj instanceof RConnection) { + return RConnectionMRForeign.ACCESS; } else { if (obj instanceof RAbstractVector) { return ForeignAccess.create(RAbstractVector.class, new RAbstractVectorAccessFactory()); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/conn/RConnection.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/conn/RConnection.java index 1314faf88542c234a282bf6b2c961586f455ea08..df7d420c8b6200f86b2afaa6d244e1e3bfef8c1c 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/conn/RConnection.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/conn/RConnection.java @@ -31,12 +31,13 @@ import java.nio.channels.ByteChannel; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.r.runtime.conn.ConnectionSupport.BaseRConnection; import com.oracle.truffle.r.runtime.context.RContext; +import com.oracle.truffle.r.runtime.data.RTruffleObject; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; /** * Denotes an R {@code connection} instance used in the {@code base} I/O library. */ -public interface RConnection extends AutoCloseable { +public interface RConnection extends AutoCloseable, RTruffleObject { static BaseRConnection fromIndex(int con) { return RContext.getInstance().stateRConnection.getConnection(con, true);