47
47
import org .truffleruby .core .array .RubyArray ;
48
48
import org .truffleruby .core .cast .BooleanCastWithDefaultNode ;
49
49
import org .truffleruby .core .cast .NameToJavaStringNode ;
50
+ import org .truffleruby .core .cast .SingleValueCastNode ;
50
51
import org .truffleruby .core .cast .ToIntNode ;
51
52
import org .truffleruby .core .cast .ToPathNodeGen ;
52
53
import org .truffleruby .core .cast .ToStrNode ;
@@ -1682,21 +1683,22 @@ protected boolean isMethodDefined(RubyModule module, String name, boolean inheri
1682
1683
@ CoreMethod (names = "module_function" , rest = true , visibility = Visibility .PRIVATE , alwaysInlined = true )
1683
1684
public abstract static class ModuleFunctionNode extends AlwaysInlinedMethodNode {
1684
1685
@ Specialization (guards = "names.length == 0" )
1685
- protected RubyModule frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1686
+ protected Object frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1686
1687
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ,
1687
1688
@ Cached BranchProfile errorProfile ) {
1688
1689
checkNotClass (module , errorProfile );
1689
1690
needCallerFrame (callerFrame , "Module#module_function with no arguments" );
1690
1691
DeclarationContext .setCurrentVisibility (callerFrame , Visibility .MODULE_FUNCTION );
1691
- return module ;
1692
+ return nil ;
1692
1693
}
1693
1694
1694
1695
@ Specialization (guards = "names.length > 0" )
1695
- protected RubyModule methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1696
+ protected Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1696
1697
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ,
1697
1698
@ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
1698
1699
@ Cached BranchProfile errorProfile ,
1699
- @ Cached LoopConditionProfile loopProfile ) {
1700
+ @ Cached LoopConditionProfile loopProfile ,
1701
+ @ Cached SingleValueCastNode singleValueCastNode ) {
1700
1702
checkNotClass (module , errorProfile );
1701
1703
int i = 0 ;
1702
1704
try {
@@ -1707,7 +1709,7 @@ protected RubyModule methods(Frame callerFrame, RubyModule module, Object[] ruby
1707
1709
} finally {
1708
1710
profileAndReportLoopCount (loopProfile , i );
1709
1711
}
1710
- return module ;
1712
+ return singleValueCastNode . executeSingleValue ( names ) ;
1711
1713
}
1712
1714
1713
1715
private void checkNotClass (RubyModule module , BranchProfile errorProfile ) {
@@ -1769,21 +1771,22 @@ protected RubyArray nesting() {
1769
1771
@ CoreMethod (names = "public" , rest = true , visibility = Visibility .PRIVATE , alwaysInlined = true )
1770
1772
public abstract static class PublicNode extends AlwaysInlinedMethodNode {
1771
1773
@ Specialization (guards = "names.length == 0" )
1772
- protected RubyModule frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1774
+ protected Object frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1773
1775
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ) {
1774
1776
needCallerFrame (callerFrame , "Module#public with no arguments" );
1775
1777
DeclarationContext .setCurrentVisibility (callerFrame , Visibility .PUBLIC );
1776
- return module ;
1778
+ return nil ;
1777
1779
}
1778
1780
1779
1781
@ Specialization (guards = "names.length > 0" )
1780
- protected RubyModule methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1782
+ protected Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1781
1783
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ,
1782
- @ Cached SetMethodVisibilityNode setMethodVisibilityNode ) {
1784
+ @ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
1785
+ @ Cached SingleValueCastNode singleValueCastNode ) {
1783
1786
for (Object name : names ) {
1784
1787
setMethodVisibilityNode .execute (module , name , Visibility .PUBLIC );
1785
1788
}
1786
- return module ;
1789
+ return singleValueCastNode . executeSingleValue ( names ) ;
1787
1790
}
1788
1791
}
1789
1792
@@ -1810,21 +1813,22 @@ protected RubyModule publicClassMethod(RubyModule module, Object[] names) {
1810
1813
@ CoreMethod (names = "private" , rest = true , visibility = Visibility .PRIVATE , alwaysInlined = true )
1811
1814
public abstract static class PrivateNode extends AlwaysInlinedMethodNode {
1812
1815
@ Specialization (guards = "names.length == 0" )
1813
- protected RubyModule frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1816
+ protected Object frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1814
1817
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ) {
1815
1818
needCallerFrame (callerFrame , "Module#private with no arguments" );
1816
1819
DeclarationContext .setCurrentVisibility (callerFrame , Visibility .PRIVATE );
1817
- return module ;
1820
+ return nil ;
1818
1821
}
1819
1822
1820
1823
@ Specialization (guards = "names.length > 0" )
1821
- protected RubyModule methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1824
+ protected Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
1822
1825
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ,
1823
- @ Cached SetMethodVisibilityNode setMethodVisibilityNode ) {
1826
+ @ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
1827
+ @ Cached SingleValueCastNode singleValueCastNode ) {
1824
1828
for (Object name : names ) {
1825
1829
setMethodVisibilityNode .execute (module , name , Visibility .PRIVATE );
1826
1830
}
1827
- return module ;
1831
+ return singleValueCastNode . executeSingleValue ( names ) ;
1828
1832
}
1829
1833
}
1830
1834
@@ -2114,21 +2118,22 @@ protected RubyModule publicConstant(RubyModule module, Object[] args) {
2114
2118
@ CoreMethod (names = "protected" , rest = true , visibility = Visibility .PRIVATE , alwaysInlined = true )
2115
2119
public abstract static class ProtectedNode extends AlwaysInlinedMethodNode {
2116
2120
@ Specialization (guards = "names.length == 0" )
2117
- protected RubyModule frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
2121
+ protected Object frame (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
2118
2122
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ) {
2119
2123
needCallerFrame (callerFrame , "Module#protected with no arguments" );
2120
2124
DeclarationContext .setCurrentVisibility (callerFrame , Visibility .PROTECTED );
2121
- return module ;
2125
+ return nil ;
2122
2126
}
2123
2127
2124
2128
@ Specialization (guards = "names.length > 0" )
2125
- protected RubyModule methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
2129
+ protected Object methods (Frame callerFrame , RubyModule module , Object [] rubyArgs , RootCallTarget target ,
2126
2130
@ Bind ("getPositionalArguments(rubyArgs, false)" ) Object [] names ,
2127
- @ Cached SetMethodVisibilityNode setMethodVisibilityNode ) {
2131
+ @ Cached SetMethodVisibilityNode setMethodVisibilityNode ,
2132
+ @ Cached SingleValueCastNode singleValueCastNode ) {
2128
2133
for (Object name : names ) {
2129
2134
setMethodVisibilityNode .execute (module , name , Visibility .PROTECTED );
2130
2135
}
2131
- return module ;
2136
+ return singleValueCastNode . executeSingleValue ( names ) ;
2132
2137
}
2133
2138
}
2134
2139
0 commit comments