Skip to content

Commit f633a05

Browse files
authored
Merge pull request jruby#8541 from enebo/set_constant
most of constant settin and RubyModule to be TCified
2 parents f468e96 + 0bfa19c commit f633a05

File tree

182 files changed

+2712
-2054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+2712
-2054
lines changed

core/src/main/java/org/jruby/AbstractRubyMethod.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public IRubyObject inspect(IRubyObject receiver) {
181181
RubyString str = newString(context, "#<");
182182
String sharp = "#";
183183

184-
str.catString(getType().getName()).catString(": ");
184+
str.catString(getType().getName(context)).catString(": ");
185185

186186
RubyModule definedClass;
187187
RubyModule mklass = originModule;
@@ -215,16 +215,16 @@ public IRubyObject inspect(IRubyObject receiver) {
215215
} else {
216216
if (receiver instanceof RubyClass) {
217217
str.catString("#<");
218-
str.cat(mklass.rubyName());
218+
str.cat(mklass.rubyName(context));
219219
str.catString(":");
220-
str.cat(((RubyClass) receiver).rubyName());
220+
str.cat(((RubyClass) receiver).rubyName(context));
221221
str.catString(">");
222222
} else {
223-
str.cat(mklass.rubyName());
223+
str.cat(mklass.rubyName(context));
224224
}
225225
if (definedClass != mklass) {
226226
str.catString("(");
227-
str.cat(definedClass.rubyName());
227+
str.cat(definedClass.rubyName(context));
228228
str.catString(")");
229229
}
230230
}

core/src/main/java/org/jruby/BasicObjectStub.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.jruby.runtime.builtin.Variable;
4343

4444
import static org.jruby.api.Convert.asBoolean;
45+
import static org.jruby.api.Create.newString;
4546
import static org.jruby.api.Error.typeError;
4647
import static org.jruby.runtime.invokedynamic.MethodNames.INSPECT;
4748
import static org.jruby.runtime.Helpers.invokedynamic;
@@ -198,7 +199,7 @@ public static RubyString convertToString(IRubyObject self) {
198199

199200
public static IRubyObject anyToString(IRubyObject self) {
200201
final RubyClass metaClass = getMetaClass(self);
201-
String cname = metaClass.getRealClass().getName();
202+
String cname = metaClass.getRealClass().getName(metaClass.getRuntime().getCurrentContext());
202203
/* 6:tags 16:addr 1:eos */
203204
return metaClass.runtime.newString("#<" + cname + ":0x" + Integer.toHexString(System.identityHashCode(self)) + '>');
204205
}
@@ -230,27 +231,27 @@ public static IRubyObject dup(IRubyObject self) {
230231
}
231232

232233
public static IRubyObject inspect(IRubyObject self) {
233-
final Ruby runtime = getRuntime(self);
234+
var context = getRuntime(self).getCurrentContext();;
234235
if (hasVariables(self)) {
235236
StringBuilder part = new StringBuilder();
236-
String cname = getMetaClass(self).getRealClass().getName();
237+
String cname = getMetaClass(self).getRealClass().getName(context);
237238
part.append("#<").append(cname).append(":0x");
238239
part.append(Integer.toHexString(System.identityHashCode(self)));
239240

240-
if (runtime.isInspecting(self)) {
241+
if (context.runtime.isInspecting(self)) {
241242
/* 6:tags 16:addr 1:eos */
242243
part.append(" ...>");
243-
return runtime.newString(part.toString());
244+
return newString(context, part.toString());
244245
}
245246
try {
246-
runtime.registerInspecting(self);
247-
return runtime.newString(inspectObj(self, part).toString());
247+
context.runtime.registerInspecting(self);
248+
return newString(context, inspectObj(self, part).toString());
248249
} finally {
249-
runtime.unregisterInspecting(self);
250+
context.runtime.unregisterInspecting(self);
250251
}
251252
}
252253

253-
return Helpers.invoke(runtime.getCurrentContext(), self, "to_s");
254+
return Helpers.invoke(context, self, "to_s");
254255
}
255256

256257

core/src/main/java/org/jruby/IncludedModule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.Map;
44

5+
import org.jruby.runtime.ThreadContext;
56
import org.jruby.runtime.builtin.IRubyObject;
67

78
public class IncludedModule extends RubyClass implements DelegatedModule {
@@ -35,8 +36,8 @@ public void setMetaClass(RubyClass newRubyClass) {
3536
}
3637

3738
@Override
38-
public String getName() {
39-
return origin.getName();
39+
public String getName(ThreadContext context) {
40+
return origin.getName(context);
4041
}
4142

4243
@Override

core/src/main/java/org/jruby/IncludedModuleWrapper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.Set;
4040

4141
import org.jruby.internal.runtime.methods.DynamicMethod;
42+
import org.jruby.runtime.ThreadContext;
4243
import org.jruby.runtime.Visibility;
4344
import org.jruby.runtime.builtin.IRubyObject;
4445
import org.jruby.runtime.builtin.Variable;
@@ -80,12 +81,11 @@ public IncludedModuleWrapper(Ruby runtime, RubyClass superClass, RubyModule orig
8081
@Override
8182
@Deprecated
8283
public IncludedModuleWrapper newIncludeClass(RubyClass superClass) {
83-
IncludedModuleWrapper includedModule = new IncludedModuleWrapper(getRuntime(), superClass, getOrigin());
84+
var context = getCurrentContext();
85+
IncludedModuleWrapper includedModule = new IncludedModuleWrapper(context.runtime, superClass, getOrigin());
8486

8587
// include its parent (and in turn that module's parents)
86-
if (getSuperClass() != null) {
87-
includedModule.includeModule(getSuperClass());
88-
}
88+
if (getSuperClass() != null) includedModule.includeModule(context, getSuperClass());
8989

9090
return includedModule;
9191
}
@@ -161,8 +161,8 @@ protected IRubyObject constantTableRemove(String name) {
161161
}
162162

163163
@Override
164-
protected IRubyObject getAutoloadConstant(String name, boolean forceLoad) {
165-
return origin.getAutoloadConstant(name, forceLoad);
164+
protected IRubyObject getAutoloadConstant(ThreadContext context, String name, boolean forceLoad) {
165+
return origin.getAutoloadConstant(context, name, forceLoad);
166166
}
167167

168168
@Override

core/src/main/java/org/jruby/NativeException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static RubyClass createClass(ThreadContext context, RubyClass baseClass,
7272
RubyClass NativeException = defineClass(context, CLASS_NAME, baseClass, NativeException::new).
7373
defineMethods(context, NativeException.class);
7474

75-
Object.deprecateConstant(context.runtime, CLASS_NAME);
75+
Object.deprecateConstant(context, CLASS_NAME);
7676

7777
return NativeException;
7878
}

core/src/main/java/org/jruby/PrependedModule.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import org.jruby.internal.runtime.methods.DynamicMethod;
3838
import org.jruby.internal.runtime.methods.RefinedMarker;
39+
import org.jruby.runtime.ThreadContext;
3940
import org.jruby.runtime.builtin.IRubyObject;
4041

4142
/**
@@ -120,8 +121,8 @@ public void setMetaClass(RubyClass newRubyClass) {
120121
}
121122

122123
@Override
123-
public String getName() {
124-
return origin.getName();
124+
public String getName(ThreadContext context) {
125+
return origin.getName(context);
125126
}
126127

127128
@Override
@@ -148,9 +149,10 @@ public RubyModule getNonIncludedClass() {
148149
public IRubyObject id() {
149150
return origin.id();
150151
}
152+
151153
@Override
152-
public void addMethod(String id, DynamicMethod method) {
153-
super.addMethod(id, method);
154+
public void addMethod(ThreadContext context, String id, DynamicMethod method) {
155+
super.addMethod(context, id, method);
154156
method.setDefinedClass(origin);
155157
}
156158

@@ -192,8 +194,8 @@ protected IRubyObject constantTableRemove(String name) {
192194
}
193195

194196
@Override
195-
protected IRubyObject getAutoloadConstant(String name, boolean forceLoad) {
196-
return origin.getAutoloadConstant(name, forceLoad);
197+
protected IRubyObject getAutoloadConstant(ThreadContext context, String name, boolean forceLoad) {
198+
return origin.getAutoloadConstant(context, name, forceLoad);
197199
}
198200

199201
@Override

0 commit comments

Comments
 (0)