Skip to content
Snippets Groups Projects
Commit 20a7cf4e authored by Tomas Stupka's avatar Tomas Stupka
Browse files

added MessageResolution for RComplex and RRaw

parent dfacd070
Branches
No related tags found
No related merge requests found
/*
* Copyright (c) 2016, 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.Resolve;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.r.runtime.data.RComplex;
@MessageResolution(receiverType = RComplex.class)
public class RComplexMR {
@Resolve(message = "IS_BOXED")
public abstract static class RComplexIsBoxedNode extends Node {
protected Object access(@SuppressWarnings("unused") RComplex receiver) {
return false;
}
}
@Resolve(message = "HAS_SIZE")
public abstract static class RComplexHasSizeNode extends Node {
protected Object access(@SuppressWarnings("unused") RComplex receiver) {
return false;
}
}
@Resolve(message = "KEY_INFO")
public abstract static class RComplexKeyInfoNode extends Node {
protected Object access(@SuppressWarnings("unused") RComplex receiver, @SuppressWarnings("unused") Object identifier) {
return 0;
}
}
@CanResolve
public abstract static class RComplexCheck extends Node {
protected static boolean test(TruffleObject receiver) {
return receiver instanceof RComplex;
}
}
}
......@@ -31,6 +31,7 @@ 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.RArgsValuesAndNames;
import com.oracle.truffle.r.runtime.data.RComplex;
import com.oracle.truffle.r.runtime.data.RDouble;
import com.oracle.truffle.r.runtime.data.REmpty;
import com.oracle.truffle.r.runtime.data.RExpression;
......@@ -44,6 +45,7 @@ import com.oracle.truffle.r.runtime.data.RMissing;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.RPairList;
import com.oracle.truffle.r.runtime.data.RPromise;
import com.oracle.truffle.r.runtime.data.RRaw;
import com.oracle.truffle.r.runtime.data.RS4Object;
import com.oracle.truffle.r.runtime.data.RSymbol;
import com.oracle.truffle.r.runtime.data.RTruffleObject;
......@@ -92,6 +94,10 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory {
return RIntegerMRForeign.ACCESS;
} else if (obj instanceof RDouble) {
return RDoubleMRForeign.ACCESS;
} else if (obj instanceof RComplex) {
return RComplexMRForeign.ACCESS;
} else if (obj instanceof RRaw) {
return RRawMRForeign.ACCESS;
} else if (obj instanceof RConnection) {
return RConnectionMRForeign.ACCESS;
} else if (obj instanceof RContext) {
......
/*
* Copyright (c) 2016, 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.Resolve;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.r.runtime.data.RRaw;
@MessageResolution(receiverType = RRaw.class)
public class RRawMR {
@Resolve(message = "IS_BOXED")
public abstract static class RRawIsBoxedNode extends Node {
protected Object access(@SuppressWarnings("unused") RRaw receiver) {
return true;
}
}
@Resolve(message = "UNBOX")
public abstract static class RRawUnboxNode extends Node {
protected Object access(@SuppressWarnings("unused") RRaw receiver) {
return receiver.getValue();
}
}
@Resolve(message = "HAS_SIZE")
public abstract static class RRawHasSizeNode extends Node {
protected Object access(@SuppressWarnings("unused") RRaw receiver) {
return false;
}
}
@Resolve(message = "KEY_INFO")
public abstract static class RRawKeyInfoNode extends Node {
protected Object access(@SuppressWarnings("unused") RRaw receiver, @SuppressWarnings("unused") Object identifier) {
return 0;
}
}
@CanResolve
public abstract static class RComplexCheck extends Node {
protected static boolean test(TruffleObject receiver) {
return receiver instanceof RRaw;
}
}
}
/*
* Copyright (c) 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.test.engine.interop;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.runtime.data.RComplex;
import org.junit.Test;
public class RComplexMRTest extends AbstractMRTest {
@Override
protected TruffleObject[] createTruffleObjects() throws Exception {
return new TruffleObject[]{RComplex.valueOf(1, 1)};
}
@Test
@Override
public void testIsNull() throws Exception {
super.testIsNull(); // force inherited tests from AbstractMRTest
}
@Override
protected boolean isBoxed(TruffleObject obj) {
return false;
}
@Override
protected boolean isPointer(TruffleObject obj) {
return false;
}
@Override
protected boolean hasSize(TruffleObject obj) {
return false;
}
@Override
protected TruffleObject createEmptyTruffleObject() throws Exception {
return null;
}
}
/*
* Copyright (c) 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.test.engine.interop;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.runtime.data.RRaw;
import org.junit.Test;
public class RRawMRTest extends AbstractMRTest {
@Override
protected TruffleObject[] createTruffleObjects() throws Exception {
return new TruffleObject[]{RRaw.valueOf((byte) 1)};
}
@Test
@Override
public void testIsNull() throws Exception {
super.testIsNull(); // force inherited tests from AbstractMRTest
}
@Override
protected boolean isBoxed(TruffleObject obj) {
return true;
}
@Override
protected boolean isPointer(TruffleObject obj) {
return false;
}
@Override
protected boolean hasSize(TruffleObject obj) {
return false;
}
@Override
protected Object getUnboxed(TruffleObject obj) {
return ((RRaw) obj).getValue();
}
@Override
protected TruffleObject createEmptyTruffleObject() throws Exception {
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment