@@ -2016,7 +2016,8 @@ private CacheEntry searchWithCacheAndRefinements(String id, boolean cacheUndef,
20162016 }
20172017
20182018 // MRI: refined_method_original_method_entry
2019- private CacheEntry refinedMethodOriginalMethodEntry (Map <RubyModule , RubyModule > refinements , String id , boolean cacheUndef , CacheEntry entry ) {
2019+ private CacheEntry refinedMethodOriginalMethodEntry (Map <RubyModule , RubyModule > refinements , String id ,
2020+ boolean cacheUndef , CacheEntry entry ) {
20202021 RubyModule superClass ;
20212022
20222023 DynamicMethod method = entry .method ;
@@ -2377,6 +2378,7 @@ protected void invalidateConstantCache(ThreadContext context, String constantNam
23772378 context .runtime .getConstantInvalidator (constantName ).invalidate ();
23782379 }
23792380
2381+ @ Deprecated (since = "10.0" )
23802382 protected void invalidateConstantCaches (Set <String > constantNames ) {
23812383 if (constantNames .size () > 0 ) {
23822384 Ruby runtime = getRuntime ();
@@ -2966,8 +2968,9 @@ private DynamicMethod createProcMethod(Ruby runtime, String name, Visibility vis
29662968 return new ProcMethod (this , proc , visibility , name );
29672969 }
29682970
2971+ @ Deprecated (since = "10.0" )
29692972 public IRubyObject name () {
2970- return name (getRuntime (). getCurrentContext ());
2973+ return name (getCurrentContext ());
29712974 }
29722975
29732976 @ JRubyMethod (name = "name" )
@@ -3080,7 +3083,7 @@ public RubyArray ancestors() {
30803083 }
30813084
30823085 public List <IRubyObject > getAncestorList () {
3083- ArrayList <IRubyObject > list = new ArrayList <IRubyObject >();
3086+ ArrayList <IRubyObject > list = new ArrayList <>();
30843087
30853088 for (RubyModule module = this ; module != null ; module = module .getSuperClass ()) {
30863089 // FIXME this is silly. figure out how to delegate the getNonIncludedClass()
@@ -3210,24 +3213,23 @@ public final IRubyObject freeze(ThreadContext context) {
32103213 return super .freeze (context );
32113214 }
32123215
3216+ @ Deprecated (since = "10.0" )
3217+ public IRubyObject op_le (IRubyObject arg ) {
3218+ return op_le (getCurrentContext (), arg );
3219+ }
3220+
32133221 /**
32143222 * MRI: rb_class_inherited_p
32153223 */
32163224 @ JRubyMethod (name = "<=" )
3217- public IRubyObject op_le (IRubyObject arg ) {
3218- Ruby runtime = getRuntime ();
3219- RubyModule argMod = castAsModule (runtime .getCurrentContext (), arg , "compared with non class/module" );
3220-
3221- if (searchAncestor (argMod .getMethodLocation ()) != null ) {
3222- return runtime .getTrue ();
3223- }
3225+ public IRubyObject op_le (ThreadContext context , IRubyObject arg ) {
3226+ RubyModule argMod = castAsModule (context , arg , "compared with non class/module" );
32243227
3228+ if (searchAncestor (argMod .getMethodLocation ()) != null ) return context .tru ;
32253229 /* not mod < arg; check if mod > arg */
3226- if (argMod .searchAncestor (this ) != null ) {
3227- return runtime .getFalse ();
3228- }
3230+ if (argMod .searchAncestor (this ) != null ) return context .fals ;
32293231
3230- return runtime . getNil () ;
3232+ return context . nil ;
32313233 }
32323234
32333235 // MRI: class_search_ancestor
@@ -3242,28 +3244,42 @@ protected RubyModule searchAncestor(RubyModule c) {
32423244 return null ;
32433245 }
32443246
3247+ @ Deprecated (since = "10.0" )
3248+ public IRubyObject op_lt (IRubyObject obj ) {
3249+ return op_lt (getCurrentContext (), obj );
3250+ }
3251+
32453252 /** rb_mod_lt
32463253 *
32473254 */
32483255 @ JRubyMethod (name = "<" )
3249- public IRubyObject op_lt (IRubyObject obj ) {
3250- return obj == this ? getRuntime ().getFalse () : op_le (obj );
3256+ public IRubyObject op_lt (ThreadContext context , IRubyObject obj ) {
3257+ return obj == this ? context .fals : op_le (context , obj );
3258+ }
3259+
3260+ @ Deprecated (since = "10.0" )
3261+ public IRubyObject op_ge (IRubyObject obj ) {
3262+ return op_ge (getCurrentContext (), obj );
32513263 }
32523264
32533265 /** rb_mod_ge
32543266 *
32553267 */
32563268 @ JRubyMethod (name = ">=" )
3257- public IRubyObject op_ge (IRubyObject obj ) {
3258- return castAsModule (getRuntime ().getCurrentContext (), obj , "compared with non class/module" ).op_le (this );
3269+ public IRubyObject op_ge (ThreadContext context , IRubyObject obj ) {
3270+ return castAsModule (context , obj , "compared with non class/module" ).op_le (context , this );
3271+ }
3272+
3273+ public IRubyObject op_gt (IRubyObject obj ) {
3274+ return op_gt (getCurrentContext (), obj );
32593275 }
32603276
32613277 /** rb_mod_gt
32623278 *
32633279 */
32643280 @ JRubyMethod (name = ">" )
3265- public IRubyObject op_gt (IRubyObject obj ) {
3266- return this == obj ? getRuntime (). getFalse () : op_ge (obj );
3281+ public IRubyObject op_gt (ThreadContext context , IRubyObject obj ) {
3282+ return this == obj ? context . fals : op_ge (context , obj );
32673283 }
32683284
32693285 /** rb_mod_cmp
@@ -3391,7 +3407,7 @@ public IRubyObject attr(ThreadContext context, IRubyObject[] args) {
33913407
33923408 @ Deprecated
33933409 public IRubyObject attr_reader (IRubyObject [] args ) {
3394- return attr_reader (getRuntime (). getCurrentContext (), args );
3410+ return attr_reader (getCurrentContext (), args );
33953411 }
33963412
33973413 /** rb_mod_attr_reader
@@ -3436,7 +3452,7 @@ public IRubyObject attr_writer(ThreadContext context, IRubyObject[] args) {
34363452
34373453 @ Deprecated
34383454 public IRubyObject attr_accessor (IRubyObject [] args ) {
3439- return attr_accessor (getRuntime (). getCurrentContext (), args );
3455+ return attr_accessor (getCurrentContext (), args );
34403456 }
34413457
34423458 /** rb_mod_attr_accessor
@@ -3611,7 +3627,7 @@ public RubyArray protected_instance_methods(ThreadContext context, IRubyObject[]
36113627
36123628 @ Deprecated
36133629 public RubyArray private_instance_methods (IRubyObject [] args ) {
3614- return private_instance_methods (getRuntime (). getCurrentContext (), args );
3630+ return private_instance_methods (getCurrentContext (), args );
36153631 }
36163632
36173633 /** rb_class_private_instance_methods
@@ -4583,14 +4599,15 @@ private IRubyObject constGetCommon(ThreadContext context, IRubyObject symbol, bo
45834599 boolean firstConstant = true ;
45844600 while ( ( sep = name .indexOf ("::" ) ) != -1 ) {
45854601 final String segment = name .substring (0 , sep );
4586- IRubyObject obj = mod .getConstant (context , validateConstant (segment , symbol ), inherit , inherit );
4602+ IRubyObject obj = mod .getConstant (context , validateConstant (context , segment , symbol ), inherit , inherit );
45874603 if (!(obj instanceof RubyModule )) throw typeError (context , segment + " does not refer to class/module" );
45884604 mod = (RubyModule ) obj ;
45894605 name = name .substring (sep + 2 );
45904606 firstConstant = false ;
45914607 }
45924608
4593- return mod .getConstant (context , validateConstant (name , symbol ), firstConstant && inherit , firstConstant && inherit );
4609+ return mod .getConstant (context ,
4610+ validateConstant (context , name , symbol ), firstConstant && inherit , firstConstant && inherit );
45944611 }
45954612
45964613 public static boolean isValidConstantPath (RubyString str ) {
@@ -4662,13 +4679,14 @@ public IRubyObject const_source_location(ThreadContext context, IRubyObject[] ar
46624679
46634680 while ( ( sep = name .indexOf ("::" ) ) != -1 ) {
46644681 final String segment = name .substring (0 , sep );
4665- IRubyObject obj = mod .getConstant (context , validateConstant (segment , symbol ), inherit , inherit );
4682+ IRubyObject obj = mod .getConstant (context , validateConstant (context , segment , symbol ), inherit , inherit );
46664683 if (!(obj instanceof RubyModule )) throw typeError (context , segment + " does not refer to class/module" );
46674684 mod = (RubyModule ) obj ;
46684685 name = name .substring (sep + 2 );
46694686 }
46704687
4671- SourceLocation location = mod .getConstantSourceLocation (validateConstant (name , symbol ), inherit , inherit );
4688+ SourceLocation location = mod .getConstantSourceLocation (context ,
4689+ validateConstant (context , name , symbol ), inherit , inherit );
46724690
46734691 if (location != null && location .getFile () != null ) {
46744692 return location .getFile ().equals (BUILTIN_CONSTANT ) ?
@@ -4733,7 +4751,7 @@ public IRubyObject const_missing(ThreadContext context, IRubyObject rubyName, Bl
47334751
47344752 if (privateConstReference != null ) {
47354753 context .setPrivateConstantReference (null );
4736- throw getRuntime () .newNameError ("private constant " + privateConstReference + "::" + rubyName + " referenced" , privateConstReference , rubyName );
4754+ throw context . runtime .newNameError ("private constant " + privateConstReference + "::" + rubyName + " referenced" , privateConstReference , rubyName );
47374755 }
47384756
47394757 if (this != objectClass (context )) {
@@ -4988,6 +5006,11 @@ public IRubyObject fastSetClassVar(final String internedName, final IRubyObject
49885006 return setClassVar (getCurrentContext (), internedName , value );
49895007 }
49905008
5009+ @ Deprecated (since = "10.0" )
5010+ public IRubyObject getClassVar (String name ) {
5011+ return getClassVar (getCurrentContext (), name );
5012+ }
5013+
49915014 /**
49925015 * Retrieve the specified class variable, searching through this module, included modules, and supermodules.
49935016 *
@@ -4996,12 +5019,10 @@ public IRubyObject fastSetClassVar(final String internedName, final IRubyObject
49965019 * @param name The name of the variable to retrieve
49975020 * @return The variable's value, or throws NameError if not found
49985021 */
4999- public IRubyObject getClassVar (String name ) {
5000- IRubyObject value = getClassVarQuiet (name );
5022+ public IRubyObject getClassVar (ThreadContext context , String name ) {
5023+ IRubyObject value = getClassVarQuiet (context , name );
50015024
5002- if (value == null ) {
5003- throw getRuntime ().newNameError ("uninitialized class variable %1$s in %2$s" , this , name );
5004- }
5025+ if (value == null ) throw context .runtime .newNameError ("uninitialized class variable %1$s in %2$s" , this , name );
50055026
50065027 return value ;
50075028 }
@@ -5012,7 +5033,7 @@ public IRubyObject getClassVar(IRubyObject nameObject, String name) {
50125033 }
50135034
50145035 public IRubyObject getClassVar (ThreadContext context , IRubyObject nameObject , String name ) {
5015- IRubyObject value = getClassVarQuiet (name );
5036+ IRubyObject value = getClassVarQuiet (context , name );
50165037
50175038 if (value == null ) {
50185039 throw context .runtime .newNameError ("uninitialized class variable %1$s in %2$s" , this , nameObject );
@@ -5021,7 +5042,12 @@ public IRubyObject getClassVar(ThreadContext context, IRubyObject nameObject, St
50215042 return value ;
50225043 }
50235044
5045+ @ Deprecated (since = "10.0" )
50245046 public IRubyObject getClassVarQuiet (String name ) {
5047+ return getClassVarQuiet (getCurrentContext (), name );
5048+ }
5049+
5050+ private IRubyObject getClassVarQuiet (ThreadContext context , String name ) {
50255051 assert IdUtil .isClassVariable (name );
50265052 RubyModule module = this ;
50275053 RubyModule highest = null ;
@@ -5037,7 +5063,7 @@ public IRubyObject getClassVarQuiet(String name) {
50375063 if (lowest != highest ) {
50385064 if (!highest .isPrepended ()) {
50395065 if (lowest .getOrigin ().getRealModule () != highest .getOrigin ().getRealModule ()) {
5040- throw getRuntime (). newRuntimeError ( str (getRuntime () , "class variable " + name + " of " ,
5066+ throw runtimeError ( context , str (context . runtime , "class variable " + name + " of " ,
50415067 lowest .getOrigin (), " is overtaken by " , highest .getOrigin ()));
50425068 }
50435069
@@ -5053,7 +5079,7 @@ public IRubyObject getClassVarQuiet(String name) {
50535079
50545080 @ Deprecated
50555081 public IRubyObject fastGetClassVar (String internedName ) {
5056- return getClassVar (internedName );
5082+ return getClassVar (getCurrentContext (), internedName );
50575083 }
50585084
50595085 /**
@@ -5168,11 +5194,17 @@ public IRubyObject getConstant(ThreadContext context, String name, boolean inher
51685194 return getConstant (context , name , inherit , true );
51695195 }
51705196
5197+ @ Deprecated (since = "10.0" )
51715198 public SourceLocation getConstantSourceLocation (String name , boolean inherit , boolean includeObject ) {
5199+ return getConstantSourceLocation (getCurrentContext (), name , inherit , includeObject );
5200+ }
5201+
5202+ public SourceLocation getConstantSourceLocation (ThreadContext context , String name , boolean inherit , boolean includeObject ) {
51725203 SourceLocation location = iterateConstantEntryNoConstMissing (name , this , inherit );
5204+ var Object = objectClass (context );
51735205
51745206 if (location == null && !isClass () && includeObject ) {
5175- location = iterateConstantEntryNoConstMissing (name , getRuntime (). getObject () , inherit );
5207+ location = iterateConstantEntryNoConstMissing (name , Object , inherit );
51765208 }
51775209
51785210 return location ;
@@ -5268,6 +5300,7 @@ private IRubyObject getConstantSkipAutoload(ThreadContext context, String name,
52685300 return constant ;
52695301 }
52705302
5303+ // runtime-free
52715304 private static SourceLocation iterateConstantEntryNoConstMissing (String name , RubyModule init , boolean inherit ) {
52725305 for (RubyModule mod = init ; mod != null ; mod = mod .getSuperClass ()) {
52735306 ConstantEntry entry = mod .constantEntryFetch (name );
@@ -5748,7 +5781,7 @@ public static boolean testModuleMatch(ThreadContext context, IRubyObject arg0, i
57485781 //
57495782
57505783 /**
5751- * Behaves similarly to {@link #getClassVar(String)}. Searches this
5784+ * Behaves similarly to {@link #getClassVar(ThreadContext, String)}. Searches this
57525785 * class/module <em>and its ancestors</em> for the specified internal
57535786 * variable.
57545787 *
@@ -5764,7 +5797,7 @@ public boolean hasInternalModuleVariable(final String name) {
57645797 return false ;
57655798 }
57665799 /**
5767- * Behaves similarly to {@link #getClassVar(String)}. Searches this
5800+ * Behaves similarly to {@link #getClassVar(ThreadContext, String)}. Searches this
57685801 * class/module <em>and its ancestors</em> for the specified internal
57695802 * variable.
57705803 *
@@ -5873,6 +5906,7 @@ public boolean fastHasClassVariable(String internedName) {
58735906 return hasClassVariable (internedName );
58745907 }
58755908
5909+ // runtime-free
58765910 public IRubyObject fetchClassVariable (String name ) {
58775911 assert IdUtil .isClassVariable (name );
58785912 return getClassVariablesForRead ().get (name );
@@ -6139,21 +6173,21 @@ protected final String validateConstant(ThreadContext context, IRubyObject name)
61396173 }).idString ();
61406174 }
61416175
6142- // FIXME: This should really be working with symbol segments (errorName is FQN).
6176+ @ Deprecated ( since = "10.0" )
61436177 protected final String validateConstant (String name , IRubyObject errorName ) {
6144- if (IdUtil .isValidConstantName (name )) return name ;
6145-
6146- Ruby runtime = getRuntime ();
6178+ return validateConstant (getCurrentContext (), name , errorName );
6179+ }
61476180
6148- Encoding resultEncoding = runtime .getDefaultInternalEncoding ();
6149- if (resultEncoding == null ) resultEncoding = runtime .getDefaultExternalEncoding ();
6181+ // FIXME: This should really be working with symbol segments (errorName is FQN).
6182+ private final String validateConstant (ThreadContext context , String name , IRubyObject errorName ) {
6183+ if (IdUtil .isValidConstantName (name )) return name ;
61506184
61516185 // MRI is more complicated than this and distinguishes between ID and non-ID.
61526186 RubyString nameString = errorName .asString ();
61536187
61546188 return RubySymbol .retrieveIDSymbol (nameString , (sym , newSym ) -> {
61556189 if (!sym .validConstantName ()) {
6156- throw getRuntime (). newNameError (str (getRuntime () , "wrong constant name " , sym ), sym );
6190+ throw context . runtime . newNameError (str (context . runtime , "wrong constant name " , sym ), sym );
61576191 }
61586192 }).idString ();
61596193 }
@@ -6191,6 +6225,7 @@ protected IRubyObject constantTableFetch(String name) {
61916225 return entry .value ;
61926226 }
61936227
6228+ // runtime-free
61946229 protected ConstantEntry constantEntryFetch (String name ) {
61956230 return getConstantMap ().get (name );
61966231 }
0 commit comments