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

added specialization for TruffleObject-s to typeof builtin

parent 6c3678f5
Branches
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ package com.oracle.truffle.r.nodes.unary; ...@@ -25,6 +25,7 @@ package com.oracle.truffle.r.nodes.unary;
import com.oracle.truffle.api.CompilerAsserts; import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.RType; import com.oracle.truffle.r.runtime.RType;
import com.oracle.truffle.r.runtime.data.RMissing; import com.oracle.truffle.r.runtime.data.RMissing;
...@@ -81,6 +82,15 @@ public abstract class TypeofNode extends UnaryNode { ...@@ -81,6 +82,15 @@ public abstract class TypeofNode extends UnaryNode {
return operand.getRType(); return operand.getRType();
} }
@Specialization(guards = "isForeignObject(object)")
protected RType doTruffleObject(@SuppressWarnings("unused") TruffleObject object) {
return RType.TruffleObject;
}
protected static boolean isForeignObject(Object obj) {
return RRuntime.isForeignObject(obj);
}
public static RType getTypeof(Object operand) { public static RType getTypeof(Object operand) {
CompilerAsserts.neverPartOfCompilation(); CompilerAsserts.neverPartOfCompilation();
return ((RTypedValue) RRuntime.asAbstractVector(operand)).getRType(); return ((RTypedValue) RRuntime.asAbstractVector(operand)).getRType();
......
...@@ -46,7 +46,8 @@ public enum RType { ...@@ -46,7 +46,8 @@ public enum RType {
ExternalPtr("externalptr", -1), ExternalPtr("externalptr", -1),
S4Object("S4", -1), S4Object("S4", -1),
Connection("connection", -1), Connection("connection", -1),
Dots("...", -1); Dots("...", -1),
TruffleObject("truffle.object", -1);
public static final int NO_PRECEDENCE = -1; public static final int NO_PRECEDENCE = -1;
public static final int NUMBER_OF_PRECEDENCES = 9; public static final int NUMBER_OF_PRECEDENCES = 9;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment