@@ -173,6 +173,11 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
173
173
174
174
public static RubyModule finishKernelModule (ThreadContext context , RubyModule Kernel , RubyInstanceConfig config ) {
175
175
Kernel .defineMethods (context , RubyKernel .class );
176
+
177
+ if (context .runtime .getInstanceConfig ().getProfile ().allowClass ("IO" )) {
178
+ Kernel .defineMethods (context , RubyKernel .KernelIO .class );
179
+ }
180
+
176
181
Kernel .setFlag (RubyModule .NEEDSIMPL_F , false ); //Kernel is the only normal Module that doesn't need an implementor
177
182
178
183
var runtime = context .runtime ;
@@ -204,6 +209,103 @@ public IRubyObject call(ThreadContext context1, IRubyObject self, RubyModule cla
204
209
return Kernel ;
205
210
}
206
211
212
+ public interface KernelIO {
213
+ @ JRubyMethod (name = "`" , module = true , visibility = PRIVATE )
214
+ static IRubyObject backquote (ThreadContext context , IRubyObject recv , IRubyObject str ) {
215
+ return RubyKernel .backquote (context , recv , str );
216
+ }
217
+
218
+ @ JRubyMethod (optional = 1 , checkArity = false )
219
+ static IRubyObject display (ThreadContext context , IRubyObject self , IRubyObject [] args ) {
220
+ return RubyKernel .display (context , self , args );
221
+ }
222
+
223
+ @ JRubyMethod (optional = 1 , keywords = true , checkArity = false , module = true , visibility = PRIVATE )
224
+ static IRubyObject gets (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
225
+ return RubyKernel .gets (context , recv , args );
226
+ }
227
+
228
+ @ JRubyMethod (rest = true , module = true , visibility = PRIVATE )
229
+ static IRubyObject p (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
230
+ return RubyKernel .p (context , recv , args );
231
+ }
232
+
233
+ @ JRubyMethod (module = true , visibility = PRIVATE , reads = LASTLINE )
234
+ static IRubyObject print (ThreadContext context , IRubyObject recv ) {
235
+ return RubyKernel .print (context , recv );
236
+ }
237
+
238
+ @ JRubyMethod (module = true , visibility = PRIVATE )
239
+ static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject arg0 ) {
240
+ return RubyKernel .print (context , recv , arg0 );
241
+ }
242
+
243
+ @ JRubyMethod (module = true , visibility = PRIVATE )
244
+ static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 ) {
245
+ return RubyKernel .print (context , recv , arg0 , arg1 );
246
+ }
247
+
248
+ @ JRubyMethod (module = true , visibility = PRIVATE )
249
+ static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 , IRubyObject arg2 ) {
250
+ return RubyKernel .print (context , recv , arg0 , arg1 , arg2 );
251
+ }
252
+
253
+ @ JRubyMethod (rest = true , module = true , visibility = PRIVATE , reads = LASTLINE )
254
+ static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
255
+ return RubyKernel .print (context , recv , args );
256
+ }
257
+
258
+ @ JRubyMethod (rest = true , module = true , visibility = PRIVATE )
259
+ static IRubyObject printf (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
260
+ return RubyKernel .printf (context , recv , args );
261
+ }
262
+
263
+ @ JRubyMethod (module = true , visibility = PRIVATE )
264
+ static IRubyObject putc (ThreadContext context , IRubyObject recv , IRubyObject ch ) {
265
+ return RubyKernel .putc (context , recv , ch );
266
+ }
267
+
268
+ @ JRubyMethod (module = true , visibility = PRIVATE )
269
+ static IRubyObject puts (ThreadContext context , IRubyObject recv ) {
270
+ return RubyKernel .puts (context , recv );
271
+ }
272
+
273
+ @ JRubyMethod (module = true , visibility = PRIVATE )
274
+ static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject arg0 ) {
275
+ return RubyKernel .puts (context , recv , arg0 );
276
+ }
277
+
278
+ @ JRubyMethod (module = true , visibility = PRIVATE )
279
+ static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 ) {
280
+ return RubyKernel .puts (context , recv , arg0 , arg1 );
281
+ }
282
+
283
+ @ JRubyMethod (module = true , visibility = PRIVATE )
284
+ static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 , IRubyObject arg2 ) {
285
+ return RubyKernel .puts (context , recv , arg0 , arg1 , arg2 );
286
+ }
287
+
288
+ @ JRubyMethod (rest = true , module = true , visibility = PRIVATE )
289
+ static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
290
+ return RubyKernel .print (context , recv , args );
291
+ }
292
+
293
+ @ JRubyMethod (optional = 1 , keywords = true , checkArity = false , module = true , visibility = PRIVATE )
294
+ static IRubyObject readline (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
295
+ return RubyKernel .readline (context , recv , args );
296
+ }
297
+
298
+ @ JRubyMethod (optional = 1 , keywords = true , checkArity = false , module = true , visibility = PRIVATE )
299
+ static IRubyObject readlines (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
300
+ return RubyKernel .readlines (context , recv , args );
301
+ }
302
+
303
+ @ JRubyMethod (name = {"sprintf" , "format" }, required = 1 , rest = true , checkArity = false , module = true , visibility = PRIVATE )
304
+ static IRubyObject sprintf (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
305
+ return RubyKernel .sprintf (context , recv , args );
306
+ }
307
+ }
308
+
207
309
/**
208
310
* Cache built-in versions of several core methods, to improve performance by using identity comparison (==) rather
209
311
* than going ahead with dynamic dispatch.
@@ -346,7 +448,6 @@ public static IRubyObject getc(ThreadContext context, IRubyObject recv) {
346
448
}
347
449
348
450
// MRI: rb_f_gets
349
- @ JRubyMethod (optional = 1 , keywords = true , checkArity = false , module = true , visibility = PRIVATE )
350
451
public static IRubyObject gets (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
351
452
var ArgsFile = argsFile (context );
352
453
@@ -664,7 +765,6 @@ public static IRubyObject new_string(ThreadContext context, IRubyObject recv, IR
664
765
}
665
766
666
767
// MRI: rb_f_p
667
- @ JRubyMethod (rest = true , module = true , visibility = PRIVATE )
668
768
public static IRubyObject p (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
669
769
return RubyThread .uninterruptible (context , args , RubyKernel ::pBody );
670
770
}
@@ -713,7 +813,6 @@ public static IRubyObject public_method(ThreadContext context, IRubyObject recv,
713
813
714
814
/** rb_f_putc
715
815
*/
716
- @ JRubyMethod (module = true , visibility = PRIVATE )
717
816
public static IRubyObject putc (ThreadContext context , IRubyObject recv , IRubyObject ch ) {
718
817
IRubyObject defout = globalVariables (context ).get ("$>" );
719
818
if (recv == defout ) {
@@ -722,7 +821,6 @@ public static IRubyObject putc(ThreadContext context, IRubyObject recv, IRubyObj
722
821
return sites (context ).putc .call (context , defout , defout , ch );
723
822
}
724
823
725
- @ JRubyMethod (module = true , visibility = PRIVATE )
726
824
public static IRubyObject puts (ThreadContext context , IRubyObject recv ) {
727
825
IRubyObject defout = globalVariables (context ).get ("$>" );
728
826
@@ -733,7 +831,6 @@ public static IRubyObject puts(ThreadContext context, IRubyObject recv) {
733
831
return sites (context ).puts .call (context , defout , defout );
734
832
}
735
833
736
- @ JRubyMethod (module = true , visibility = PRIVATE )
737
834
public static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject arg0 ) {
738
835
IRubyObject defout = globalVariables (context ).get ("$>" );
739
836
@@ -744,7 +841,6 @@ public static IRubyObject puts(ThreadContext context, IRubyObject recv, IRubyObj
744
841
return sites (context ).puts .call (context , defout , defout , arg0 );
745
842
}
746
843
747
- @ JRubyMethod (module = true , visibility = PRIVATE )
748
844
public static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 ) {
749
845
IRubyObject defout = globalVariables (context ).get ("$>" );
750
846
@@ -755,7 +851,6 @@ public static IRubyObject puts(ThreadContext context, IRubyObject recv, IRubyObj
755
851
return sites (context ).puts .call (context , defout , defout , arg0 , arg1 );
756
852
}
757
853
758
- @ JRubyMethod (module = true , visibility = PRIVATE )
759
854
public static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 , IRubyObject arg2 ) {
760
855
IRubyObject defout = globalVariables (context ).get ("$>" );
761
856
@@ -766,7 +861,6 @@ public static IRubyObject puts(ThreadContext context, IRubyObject recv, IRubyObj
766
861
return sites (context ).puts .call (context , defout , defout , arg0 , arg1 , arg2 );
767
862
}
768
863
769
- @ JRubyMethod (rest = true , module = true , visibility = PRIVATE )
770
864
public static IRubyObject puts (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
771
865
IRubyObject defout = globalVariables (context ).get ("$>" );
772
866
@@ -778,33 +872,27 @@ public static IRubyObject puts(ThreadContext context, IRubyObject recv, IRubyObj
778
872
}
779
873
780
874
// rb_f_print
781
- @ JRubyMethod (module = true , visibility = PRIVATE , reads = LASTLINE )
782
875
public static IRubyObject print (ThreadContext context , IRubyObject recv ) {
783
876
return RubyIO .print0 (context , globalVariables (context ).get ("$>" ));
784
877
}
785
878
786
- @ JRubyMethod (module = true , visibility = PRIVATE )
787
879
public static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject arg0 ) {
788
880
return RubyIO .print1 (context , globalVariables (context ).get ("$>" ), arg0 );
789
881
}
790
882
791
- @ JRubyMethod (module = true , visibility = PRIVATE )
792
883
public static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 ) {
793
884
return RubyIO .print2 (context , globalVariables (context ).get ("$>" ), arg0 , arg1 );
794
885
}
795
886
796
- @ JRubyMethod (module = true , visibility = PRIVATE )
797
887
public static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject arg0 , IRubyObject arg1 , IRubyObject arg2 ) {
798
888
return RubyIO .print3 (context , globalVariables (context ).get ("$>" ), arg0 , arg1 , arg2 );
799
889
}
800
890
801
- @ JRubyMethod (rest = true , module = true , visibility = PRIVATE , reads = LASTLINE )
802
891
public static IRubyObject print (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
803
892
return RubyIO .print (context , globalVariables (context ).get ("$>" ), args );
804
893
}
805
894
806
895
// rb_f_printf
807
- @ JRubyMethod (rest = true , module = true , visibility = PRIVATE )
808
896
public static IRubyObject printf (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
809
897
if (args .length == 0 ) return context .nil ;
810
898
@@ -821,7 +909,6 @@ public static IRubyObject printf(ThreadContext context, IRubyObject recv, IRubyO
821
909
return context .nil ;
822
910
}
823
911
824
- @ JRubyMethod (optional = 1 , keywords = true , checkArity = false , module = true , visibility = PRIVATE )
825
912
public static IRubyObject readline (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
826
913
IRubyObject line = gets (context , recv , args );
827
914
@@ -832,7 +919,6 @@ public static IRubyObject readline(ThreadContext context, IRubyObject recv, IRub
832
919
return line ;
833
920
}
834
921
835
- @ JRubyMethod (optional = 1 , keywords = true , checkArity = false , module = true , visibility = PRIVATE )
836
922
public static IRubyObject readlines (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
837
923
return RubyArgsFile .readlines (context , argsFile (context ), args );
838
924
}
@@ -1007,7 +1093,6 @@ public static RubyBoolean blockGiven(ThreadContext context, IRubyObject recv, Bl
1007
1093
return asBoolean (context , frameBlock .isGiven ());
1008
1094
}
1009
1095
1010
- @ JRubyMethod (name = {"sprintf" , "format" }, required = 1 , rest = true , checkArity = false , module = true , visibility = PRIVATE )
1011
1096
public static IRubyObject sprintf (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
1012
1097
if (args .length == 0 ) throw argumentError (context , "sprintf must have at least one argument" );
1013
1098
@@ -1786,7 +1871,6 @@ private static int getTestCommand(ThreadContext context, IRubyObject arg0) {
1786
1871
return cmd ;
1787
1872
}
1788
1873
1789
- @ JRubyMethod (name = "`" , module = true , visibility = PRIVATE )
1790
1874
public static IRubyObject backquote (ThreadContext context , IRubyObject recv , IRubyObject str ) {
1791
1875
Ruby runtime = context .runtime ;
1792
1876
@@ -2248,7 +2332,6 @@ public static IRubyObject dup(IRubyObject self) {
2248
2332
return ((RubyBasicObject )self ).dup ();
2249
2333
}
2250
2334
2251
- @ JRubyMethod (optional = 1 , checkArity = false )
2252
2335
public static IRubyObject display (ThreadContext context , IRubyObject self , IRubyObject [] args ) {
2253
2336
Arity .checkArgumentCount (context , args , 0 , 1 );
2254
2337
0 commit comments