Skip to content

Commit e67c701

Browse files
committed
Add missing Truffle::Interop methods
1 parent 0cc2bab commit e67c701

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

src/main/java/org/truffleruby/interop/InteropNodes.java

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,15 @@ private Object doImport(String name) {
12621262
// endregion
12631263

12641264
// region Language
1265+
@CoreMethod(names = "has_language?", onSingleton = true, required = 1)
1266+
public abstract static class HasLanguageNode extends InteropCoreMethodArrayArgumentsNode {
1267+
@Specialization(limit = "getCacheLimit()")
1268+
protected boolean hasLanguage(Object receiver,
1269+
@CachedLibrary("receiver") InteropLibrary interop) {
1270+
return interop.hasLanguage(receiver);
1271+
}
1272+
}
1273+
12651274
@CoreMethod(names = "language", onSingleton = true, required = 1)
12661275
public abstract static class GetLanguageNode extends InteropCoreMethodArrayArgumentsNode {
12671276

@@ -1659,31 +1668,22 @@ protected int identityHashCode(Object value,
16591668
// endregion
16601669

16611670
// region Scope
1662-
@Primitive(name = "current_scope")
1663-
public abstract static class GetCurrentScopeNode extends PrimitiveArrayArgumentsNode {
1664-
1665-
@Specialization
1666-
protected Object getScope(VirtualFrame frame,
1667-
@CachedLibrary(limit = "1") NodeLibrary nodeLibrary,
1668-
@Cached TranslateInteropExceptionNode translateInteropException) {
1669-
try {
1670-
return nodeLibrary.getScope(this, frame, true);
1671-
} catch (UnsupportedMessageException e) {
1672-
throw translateInteropException.execute(e);
1673-
}
1671+
@CoreMethod(names = "scope?", onSingleton = true, required = 1)
1672+
public abstract static class IsScopeNode extends InteropCoreMethodArrayArgumentsNode {
1673+
@Specialization(limit = "getCacheLimit()")
1674+
protected boolean isScope(Object receiver,
1675+
@CachedLibrary("receiver") InteropLibrary interop) {
1676+
return interop.isScope(receiver);
16741677
}
1675-
16761678
}
16771679

1678-
@Primitive(name = "top_scope")
1679-
public abstract static class GetTopScopeNode extends PrimitiveArrayArgumentsNode {
1680-
1681-
@Specialization
1682-
protected Object getTopScope(
1683-
@CachedContext(RubyLanguage.class) RubyContext context) {
1684-
return context.getTopScopeObject();
1680+
@CoreMethod(names = "has_scope_parent?", onSingleton = true, required = 1)
1681+
public abstract static class HasScopeParentNode extends InteropCoreMethodArrayArgumentsNode {
1682+
@Specialization(limit = "getCacheLimit()")
1683+
protected boolean hasScopeParent(Object receiver,
1684+
@CachedLibrary("receiver") InteropLibrary interop) {
1685+
return interop.hasScopeParent(receiver);
16851686
}
1686-
16871687
}
16881688

16891689
@CoreMethod(names = "scope_parent", onSingleton = true, required = 1)
@@ -1704,6 +1704,29 @@ protected Object getScope(Object scope,
17041704
}
17051705
}
17061706
}
1707+
1708+
@Primitive(name = "current_scope")
1709+
public abstract static class GetCurrentScopeNode extends PrimitiveArrayArgumentsNode {
1710+
@Specialization
1711+
protected Object getScope(VirtualFrame frame,
1712+
@CachedLibrary(limit = "1") NodeLibrary nodeLibrary,
1713+
@Cached TranslateInteropExceptionNode translateInteropException) {
1714+
try {
1715+
return nodeLibrary.getScope(this, frame, true);
1716+
} catch (UnsupportedMessageException e) {
1717+
throw translateInteropException.execute(e);
1718+
}
1719+
}
1720+
}
1721+
1722+
@Primitive(name = "top_scope")
1723+
public abstract static class GetTopScopeNode extends PrimitiveArrayArgumentsNode {
1724+
@Specialization
1725+
protected Object getTopScope(
1726+
@CachedContext(RubyLanguage.class) RubyContext context) {
1727+
return context.getTopScopeObject();
1728+
}
1729+
}
17071730
// endregion scope
17081731

17091732
}

0 commit comments

Comments
 (0)