|
20 | 20 | import com.oracle.truffle.api.dsl.Bind;
|
21 | 21 | import com.oracle.truffle.api.dsl.Cached.Shared;
|
22 | 22 | import com.oracle.truffle.api.dsl.Fallback;
|
| 23 | +import com.oracle.truffle.api.dsl.GenerateCached; |
| 24 | +import com.oracle.truffle.api.dsl.GenerateInline; |
23 | 25 | import com.oracle.truffle.api.dsl.NeverDefault;
|
24 | 26 | import com.oracle.truffle.api.frame.Frame;
|
25 | 27 | import com.oracle.truffle.api.interop.InteropLibrary;
|
|
69 | 71 | import org.truffleruby.core.hash.library.PackedHashStoreLibrary;
|
70 | 72 | import org.truffleruby.core.inlined.AlwaysInlinedMethodNode;
|
71 | 73 | import org.truffleruby.core.kernel.KernelNodesFactory.SameOrEqualNodeFactory;
|
72 |
| -import org.truffleruby.core.kernel.KernelNodesFactory.SingletonMethodsNodeFactory; |
73 | 74 | import org.truffleruby.core.klass.RubyClass;
|
74 | 75 | import org.truffleruby.core.method.MethodFilter;
|
75 | 76 | import org.truffleruby.core.method.RubyMethod;
|
@@ -1270,9 +1271,9 @@ protected RubyArray methodsRegular(Object self, boolean regular,
|
1270 | 1271 | }
|
1271 | 1272 |
|
1272 | 1273 | @Specialization(guards = "!regular")
|
1273 |
| - protected RubyArray methodsSingleton(VirtualFrame frame, Object self, boolean regular, |
| 1274 | + protected RubyArray methodsSingleton(Object self, boolean regular, |
1274 | 1275 | @Cached SingletonMethodsNode singletonMethodsNode) {
|
1275 |
| - return singletonMethodsNode.executeSingletonMethods(frame, self, false); |
| 1276 | + return singletonMethodsNode.execute(this, self, false); |
1276 | 1277 | }
|
1277 | 1278 |
|
1278 | 1279 | }
|
@@ -1554,34 +1555,40 @@ protected RubyMethod singletonMethod(Object self, Object nameObject,
|
1554 | 1555 | @CoreMethod(names = "singleton_methods", optional = 1)
|
1555 | 1556 | @NodeChild(value = "object", type = RubyNode.class)
|
1556 | 1557 | @NodeChild(value = "includeAncestors", type = RubyBaseNodeWithExecute.class)
|
1557 |
| - public abstract static class SingletonMethodsNode extends CoreMethodNode { |
1558 |
| - |
1559 |
| - @NeverDefault |
1560 |
| - public static SingletonMethodsNode create() { |
1561 |
| - return SingletonMethodsNodeFactory.create(null, null); |
1562 |
| - } |
1563 |
| - |
1564 |
| - public abstract RubyArray executeSingletonMethods(VirtualFrame frame, Object self, boolean includeAncestors); |
| 1558 | + public abstract static class KernelSingletonMethodsNode extends CoreMethodNode { |
1565 | 1559 |
|
1566 | 1560 | @CreateCast("includeAncestors")
|
1567 | 1561 | protected RubyBaseNodeWithExecute coerceToBoolean(RubyBaseNodeWithExecute includeAncestors) {
|
1568 | 1562 | return BooleanCastWithDefaultNode.create(true, includeAncestors);
|
1569 | 1563 | }
|
1570 | 1564 |
|
1571 |
| - @TruffleBoundary |
1572 | 1565 | @Specialization
|
1573 | 1566 | protected RubyArray singletonMethods(Object self, boolean includeAncestors,
|
| 1567 | + @Cached SingletonMethodsNode singletonMethodsNode) { |
| 1568 | + return singletonMethodsNode.execute(this, self, includeAncestors); |
| 1569 | + } |
| 1570 | + } |
| 1571 | + |
| 1572 | + @GenerateCached(false) |
| 1573 | + @GenerateInline |
| 1574 | + public abstract static class SingletonMethodsNode extends RubyBaseNode { |
| 1575 | + |
| 1576 | + public abstract RubyArray execute(Node node, Object self, boolean includeAncestors); |
| 1577 | + |
| 1578 | + @TruffleBoundary |
| 1579 | + @Specialization |
| 1580 | + protected static RubyArray singletonMethods(Node node, Object self, boolean includeAncestors, |
1574 | 1581 | @Cached MetaClassNode metaClassNode) {
|
1575 |
| - final RubyClass metaClass = metaClassNode.execute(this, self); |
| 1582 | + final RubyClass metaClass = metaClassNode.execute(node, self); |
1576 | 1583 |
|
1577 | 1584 | if (!metaClass.isSingleton) {
|
1578 |
| - return createEmptyArray(); |
| 1585 | + return createEmptyArray(node); |
1579 | 1586 | }
|
1580 | 1587 |
|
1581 | 1588 | Object[] objects = metaClass.fields
|
1582 |
| - .filterSingletonMethods(getLanguage(), includeAncestors, MethodFilter.PUBLIC_PROTECTED) |
| 1589 | + .filterSingletonMethods(getLanguage(node), includeAncestors, MethodFilter.PUBLIC_PROTECTED) |
1583 | 1590 | .toArray();
|
1584 |
| - return createArray(objects); |
| 1591 | + return createArray(node, objects); |
1585 | 1592 | }
|
1586 | 1593 |
|
1587 | 1594 | }
|
|
0 commit comments