70
70
import org .truffleruby .core .module .ModuleNodesFactory .GeneratedReaderNodeFactory ;
71
71
import org .truffleruby .core .module .ModuleNodesFactory .GeneratedWriterNodeFactory ;
72
72
import org .truffleruby .core .module .ModuleNodesFactory .IsSubclassOfOrEqualToNodeFactory ;
73
- import org .truffleruby .core .module .ModuleNodesFactory .SetMethodVisibilityNodeGen ;
74
73
import org .truffleruby .core .proc .RubyProc ;
75
74
import org .truffleruby .core .string .RubyString ;
76
75
import org .truffleruby .core .string .StringHelperNodes ;
@@ -1643,7 +1642,7 @@ protected static Object methods(Frame callerFrame, RubyModule module, Object[] r
1643
1642
int i = 0 ;
1644
1643
try {
1645
1644
for (; loopProfile .inject (node , i < names .length ); ++i ) {
1646
- setMethodVisibilityNode .execute (module , names [i ], Visibility .MODULE_FUNCTION );
1645
+ setMethodVisibilityNode .execute (node , module , names [i ], Visibility .MODULE_FUNCTION );
1647
1646
TruffleSafepoint .poll (node );
1648
1647
}
1649
1648
} finally {
@@ -1719,29 +1718,29 @@ protected Object frame(Frame callerFrame, RubyModule module, Object[] rubyArgs,
1719
1718
}
1720
1719
1721
1720
@ Specialization (guards = "names.length > 0" )
1722
- protected Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1721
+ protected static Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1723
1722
@ Bind ("getPositionalArguments(rubyArgs)" ) Object [] names ,
1724
1723
@ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
1725
- @ Cached SingleValueCastNode singleValueCastNode ) {
1724
+ @ Cached SingleValueCastNode singleValueCastNode ,
1725
+ @ Bind ("this" ) Node node ) {
1726
1726
for (Object name : names ) {
1727
- setMethodVisibilityNode .execute (module , name , Visibility .PUBLIC );
1727
+ setMethodVisibilityNode .execute (node , module , name , Visibility .PUBLIC );
1728
1728
}
1729
- return singleValueCastNode .execute (this , names );
1729
+ return singleValueCastNode .execute (node , names );
1730
1730
}
1731
1731
}
1732
1732
1733
1733
@ CoreMethod (names = "public_class_method" , rest = true )
1734
1734
public abstract static class PublicClassMethodNode extends CoreMethodArrayArgumentsNode {
1735
1735
1736
- @ Child private SetMethodVisibilityNode setMethodVisibilityNode = SetMethodVisibilityNode .create ();
1737
-
1738
1736
@ Specialization
1739
1737
protected RubyModule publicClassMethod (RubyModule module , Object [] names ,
1738
+ @ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
1740
1739
@ Cached SingletonClassNode singletonClassNode ) {
1741
1740
final RubyClass singletonClass = singletonClassNode .execute (module );
1742
1741
1743
1742
for (Object name : names ) {
1744
- setMethodVisibilityNode .execute (singletonClass , name , Visibility .PUBLIC );
1743
+ setMethodVisibilityNode .execute (this , singletonClass , name , Visibility .PUBLIC );
1745
1744
}
1746
1745
1747
1746
return module ;
@@ -1761,14 +1760,15 @@ protected Object frame(Frame callerFrame, RubyModule module, Object[] rubyArgs,
1761
1760
}
1762
1761
1763
1762
@ Specialization (guards = "names.length > 0" )
1764
- protected Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1763
+ protected static Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1765
1764
@ Bind ("getPositionalArguments(rubyArgs)" ) Object [] names ,
1766
1765
@ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
1767
- @ Cached SingleValueCastNode singleValueCastNode ) {
1766
+ @ Cached SingleValueCastNode singleValueCastNode ,
1767
+ @ Bind ("this" ) Node node ) {
1768
1768
for (Object name : names ) {
1769
- setMethodVisibilityNode .execute (module , name , Visibility .PRIVATE );
1769
+ setMethodVisibilityNode .execute (node , module , name , Visibility .PRIVATE );
1770
1770
}
1771
- return singleValueCastNode .execute (this , names );
1771
+ return singleValueCastNode .execute (node , names );
1772
1772
}
1773
1773
}
1774
1774
@@ -1792,15 +1792,14 @@ protected Object prependFeatures(RubyModule features, RubyModule target,
1792
1792
@ CoreMethod (names = "private_class_method" , rest = true )
1793
1793
public abstract static class PrivateClassMethodNode extends CoreMethodArrayArgumentsNode {
1794
1794
1795
- @ Child private SetMethodVisibilityNode setMethodVisibilityNode = SetMethodVisibilityNode .create ();
1796
-
1797
1795
@ Specialization
1798
1796
protected RubyModule privateClassMethod (VirtualFrame frame , RubyModule module , Object [] names ,
1797
+ @ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
1799
1798
@ Cached SingletonClassNode singletonClassNode ) {
1800
1799
final RubyClass singletonClass = singletonClassNode .execute (module );
1801
1800
1802
1801
for (Object name : names ) {
1803
- setMethodVisibilityNode .execute (singletonClass , name , Visibility .PRIVATE );
1802
+ setMethodVisibilityNode .execute (this , singletonClass , name , Visibility .PRIVATE );
1804
1803
}
1805
1804
1806
1805
return module ;
@@ -2047,14 +2046,15 @@ protected Object frame(Frame callerFrame, RubyModule module, Object[] rubyArgs,
2047
2046
}
2048
2047
2049
2048
@ Specialization (guards = "names.length > 0" )
2050
- protected Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
2049
+ protected static Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
2051
2050
@ Bind ("getPositionalArguments(rubyArgs)" ) Object [] names ,
2052
2051
@ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
2053
- @ Cached SingleValueCastNode singleValueCastNode ) {
2052
+ @ Cached SingleValueCastNode singleValueCastNode ,
2053
+ @ Bind ("this" ) Node node ) {
2054
2054
for (Object name : names ) {
2055
- setMethodVisibilityNode .execute (module , name , Visibility .PROTECTED );
2055
+ setMethodVisibilityNode .execute (node , module , name , Visibility .PROTECTED );
2056
2056
}
2057
- return singleValueCastNode .execute (this , names );
2057
+ return singleValueCastNode .execute (node , names );
2058
2058
}
2059
2059
}
2060
2060
@@ -2231,28 +2231,25 @@ protected RubyArray refinements(RubyModule self) {
2231
2231
}
2232
2232
2233
2233
@ GenerateUncached
2234
+ @ GenerateCached (false )
2235
+ @ GenerateInline
2234
2236
@ ImportStatic (ArrayGuards .class )
2235
2237
public abstract static class SetMethodVisibilityNode extends RubyBaseNode {
2236
2238
2237
- @ NeverDefault
2238
- public static SetMethodVisibilityNode create () {
2239
- return SetMethodVisibilityNodeGen .create ();
2240
- }
2241
-
2242
- public abstract void execute (RubyModule module , Object name , Visibility visibility );
2239
+ public abstract void execute (Node node , RubyModule module , Object name , Visibility visibility );
2243
2240
2244
2241
@ TruffleBoundary
2245
2242
@ Specialization (guards = "!isRubyArray(name)" )
2246
- protected void setMethodVisibility (RubyModule module , Object name , Visibility visibility ,
2243
+ protected static void setMethodVisibility (Node node , RubyModule module , Object name , Visibility visibility ,
2247
2244
@ Cached @ Shared NameToJavaStringNode nameToJavaStringNode ) {
2248
- final String methodName = nameToJavaStringNode .execute (this , name );
2245
+ final String methodName = nameToJavaStringNode .execute (node , name );
2249
2246
2250
- final InternalMethod method = module .fields .deepMethodSearch (getContext (), methodName );
2247
+ final InternalMethod method = module .fields .deepMethodSearch (getContext (node ), methodName );
2251
2248
2252
2249
if (method == null ) {
2253
2250
throw new RaiseException (
2254
- getContext (),
2255
- coreExceptions ().nameErrorUndefinedMethod (methodName , module , this ));
2251
+ getContext (node ),
2252
+ coreExceptions (node ).nameErrorUndefinedMethod (methodName , module , node ));
2256
2253
}
2257
2254
2258
2255
// Do nothing if the method already exists with the same visibility, like MRI
@@ -2262,20 +2259,22 @@ protected void setMethodVisibility(RubyModule module, Object name, Visibility vi
2262
2259
2263
2260
/* If the method was already defined in this class, that's fine {@link addMethod} will overwrite it,
2264
2261
* otherwise we do actually want to add a copy of the method with a different visibility to this module. */
2265
- module .addMethodIgnoreNameVisibility (getContext (), method , visibility , this );
2262
+ module .addMethodIgnoreNameVisibility (getContext (node ), method , visibility , node );
2266
2263
}
2267
2264
2268
2265
@ TruffleBoundary
2269
2266
@ Specialization
2270
- protected void setMethodVisibilityArray (RubyModule module , RubyArray array , Visibility visibility ,
2267
+ protected static void setMethodVisibilityArray (
2268
+ Node node , RubyModule module , RubyArray array , Visibility visibility ,
2271
2269
@ Cached @ Shared NameToJavaStringNode nameToJavaStringNode ) {
2272
2270
for (Object name : ArrayOperations .toIterable (array )) {
2273
2271
setMethodVisibility (
2272
+ node ,
2274
2273
module ,
2275
2274
name ,
2276
2275
visibility ,
2277
2276
nameToJavaStringNode );
2278
- TruffleSafepoint .poll (this );
2277
+ TruffleSafepoint .poll (node );
2279
2278
}
2280
2279
}
2281
2280
0 commit comments