Skip to content
Snippets Groups Projects
Commit d4a64a40 authored by Florian Angerer's avatar Florian Angerer
Browse files

Implemented message resolution for RMissing/REmpty.

parent ab975c8a
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.engine.TruffleRLanguage;
import com.oracle.truffle.r.runtime.data.REmpty;
@MessageResolution(receiverType = REmpty.class, language = TruffleRLanguage.class)
public class REmptyMR {
@Resolve(message = "IS_BOXED")
public abstract static class REmptyIsBoxedNode extends Node {
protected Object access(@SuppressWarnings("unused") REmpty receiver) {
return false;
}
}
@Resolve(message = "HAS_SIZE")
public abstract static class REmptyHasSizeNode extends Node {
protected Object access(@SuppressWarnings("unused") REmpty receiver) {
return false;
}
}
@Resolve(message = "IS_NULL")
public abstract static class REmptyIsNullNode extends Node {
protected Object access(@SuppressWarnings("unused") REmpty receiver) {
return false;
}
}
@CanResolve
public abstract static class REmptyCheck extends Node {
protected static boolean test(TruffleObject receiver) {
return receiver instanceof REmpty;
}
}
}
...@@ -35,16 +35,18 @@ import com.oracle.truffle.r.runtime.context.RContext; ...@@ -35,16 +35,18 @@ import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.context.RForeignAccessFactory; import com.oracle.truffle.r.runtime.context.RForeignAccessFactory;
import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames;
import com.oracle.truffle.r.runtime.data.RDouble; import com.oracle.truffle.r.runtime.data.RDouble;
import com.oracle.truffle.r.runtime.data.REmpty;
import com.oracle.truffle.r.runtime.data.RExternalPtr; import com.oracle.truffle.r.runtime.data.RExternalPtr;
import com.oracle.truffle.r.runtime.data.RFunction; import com.oracle.truffle.r.runtime.data.RFunction;
import com.oracle.truffle.r.runtime.data.RInteger; import com.oracle.truffle.r.runtime.data.RInteger;
import com.oracle.truffle.r.runtime.data.RInteropScalar; import com.oracle.truffle.r.runtime.data.RInteropScalar;
import com.oracle.truffle.r.runtime.data.RLanguage; import com.oracle.truffle.r.runtime.data.RLanguage;
import com.oracle.truffle.r.runtime.data.RList; import com.oracle.truffle.r.runtime.data.RList;
import com.oracle.truffle.r.runtime.data.RMissing;
import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.RPairList; import com.oracle.truffle.r.runtime.data.RPairList;
import com.oracle.truffle.r.runtime.data.RS4Object;
import com.oracle.truffle.r.runtime.data.RPromise; import com.oracle.truffle.r.runtime.data.RPromise;
import com.oracle.truffle.r.runtime.data.RS4Object;
import com.oracle.truffle.r.runtime.data.RSymbol; import com.oracle.truffle.r.runtime.data.RSymbol;
import com.oracle.truffle.r.runtime.data.RTruffleObject; import com.oracle.truffle.r.runtime.data.RTruffleObject;
import com.oracle.truffle.r.runtime.data.RUnboundValue; import com.oracle.truffle.r.runtime.data.RUnboundValue;
...@@ -127,6 +129,10 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { ...@@ -127,6 +129,10 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory {
return ActiveBindingMRForeign.ACCESS; return ActiveBindingMRForeign.ACCESS;
} else if (obj instanceof RInteropScalar) { } else if (obj instanceof RInteropScalar) {
return RInteropScalarMRForeign.ACCESS; return RInteropScalarMRForeign.ACCESS;
} else if (obj instanceof RMissing) {
return RMissingMRForeign.ACCESS;
} else if (obj instanceof REmpty) {
return REmptyMRForeign.ACCESS;
} else { } else {
if (obj instanceof RAbstractVector) { if (obj instanceof RAbstractVector) {
......
/*
* 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.engine.TruffleRLanguage;
import com.oracle.truffle.r.runtime.data.RMissing;
@MessageResolution(receiverType = RMissing.class, language = TruffleRLanguage.class)
public class RMissingMR {
@Resolve(message = "IS_BOXED")
public abstract static class RMissingIsBoxedNode extends Node {
protected Object access(@SuppressWarnings("unused") RMissing receiver) {
return false;
}
}
@Resolve(message = "HAS_SIZE")
public abstract static class RMissingHasSizeNode extends Node {
protected Object access(@SuppressWarnings("unused") RMissing receiver) {
return false;
}
}
@Resolve(message = "IS_NULL")
public abstract static class RMissingIsNullNode extends Node {
protected Object access(@SuppressWarnings("unused") RMissing receiver) {
return false;
}
}
@CanResolve
public abstract static class RMissingCheck extends Node {
protected static boolean test(TruffleObject receiver) {
return receiver instanceof RMissing;
}
}
}
...@@ -31,6 +31,7 @@ import com.oracle.truffle.api.interop.Resolve; ...@@ -31,6 +31,7 @@ import com.oracle.truffle.api.interop.Resolve;
import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnknownIdentifierException;
import com.oracle.truffle.api.interop.UnsupportedMessageException; import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.metadata.ScopeProvider.AbstractScope; import com.oracle.truffle.api.metadata.ScopeProvider.AbstractScope;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.ArgumentsSignature;
...@@ -39,6 +40,7 @@ import com.oracle.truffle.r.runtime.RInternalError; ...@@ -39,6 +40,7 @@ import com.oracle.truffle.r.runtime.RInternalError;
import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.RFunction; import com.oracle.truffle.r.runtime.data.RFunction;
import com.oracle.truffle.r.runtime.data.RStringVector; import com.oracle.truffle.r.runtime.data.RStringVector;
import com.oracle.truffle.r.runtime.data.RTypedValue;
import com.oracle.truffle.r.runtime.env.REnvironment.PutException; import com.oracle.truffle.r.runtime.env.REnvironment.PutException;
/** /**
...@@ -224,6 +226,9 @@ public final class RScope extends AbstractScope { ...@@ -224,6 +226,9 @@ public final class RScope extends AbstractScope {
if (varMap.env == null) { if (varMap.env == null) {
throw UnsupportedMessageException.raise(Message.WRITE); throw UnsupportedMessageException.raise(Message.WRITE);
} }
if (!(value instanceof RTypedValue)) {
throw UnsupportedTypeException.raise(new Object[]{value});
}
try { try {
varMap.env.put(name, value); varMap.env.put(name, value);
return value; return value;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment