Skip to content

Commit ff90e08

Browse files
committed
Make a few more final fields of CoreLibrary public too
1 parent 0a92ca5 commit ff90e08

20 files changed

+27
-47
lines changed

src/main/java/org/truffleruby/RubyLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ protected Iterable<Scope> findLocalScopes(RubyContext context, Node node, Frame
277277

278278
@Override
279279
protected Iterable<Scope> findTopScopes(RubyContext context) {
280-
return Collections.singletonList(GlobalScope.getGlobalScope(context.getCoreLibrary().getGlobalVariables()));
280+
return Collections.singletonList(GlobalScope.getGlobalScope(context.getCoreLibrary().globalVariables));
281281
}
282282

283283
public String getTruffleLanguageHome() {

src/main/java/org/truffleruby/builtins/CoreMethodNodeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private static void addMethod(RubyContext context, DynamicObject module,
232232
private static SharedMethodInfo makeSharedMethodInfo(RubyContext context, LexicalScope lexicalScope,
233233
DynamicObject module, String name, Arity arity) {
234234
return new SharedMethodInfo(
235-
context.getCoreLibrary().getSourceSection(),
235+
context.getCoreLibrary().sourceSection,
236236
lexicalScope,
237237
arity,
238238
module,

src/main/java/org/truffleruby/core/CoreLibrary.java

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class CoreLibrary {
9191

9292
private final RubyContext context;
9393

94-
private final SourceSection sourceSection;
94+
public final SourceSection sourceSection;
9595

9696
public final DynamicObject argumentErrorClass;
9797
public final DynamicObject arrayClass;
@@ -199,9 +199,9 @@ public class CoreLibrary {
199199
public final DynamicObject mainObject;
200200
public final DynamicObject nil;
201201

202-
private final GlobalVariables globalVariables;
202+
public final GlobalVariables globalVariables;
203203

204-
private final FrameDescriptor emptyDescriptor;
204+
public final FrameDescriptor emptyDescriptor;
205205

206206
@CompilationFinal private DynamicObject eagainWaitReadable;
207207
@CompilationFinal private DynamicObject eagainWaitWritable;
@@ -222,7 +222,7 @@ public class CoreLibrary {
222222

223223
private final ConcurrentMap<String, Boolean> patchFiles;
224224

225-
private final String coreLoadPath;
225+
public final String coreLoadPath;
226226

227227
@TruffleBoundary
228228
private SourceSection initCoreSourceSection(RubyContext context) {
@@ -838,7 +838,7 @@ public void loadRubyCoreLibraryAndPostBoot() {
838838
state = State.LOADED;
839839
}
840840

841-
final RubySource source = loadCoreFile(getCoreLoadPath() + file);
841+
final RubySource source = loadCoreFile(coreLoadPath + file);
842842
final RubyRootNode rootNode = context
843843
.getCodeLoader()
844844
.parse(source, ParserContext.TOP_LEVEL, null, null, true, node);
@@ -897,7 +897,7 @@ private void afterLoadCoreLibrary() {
897897
// Initialize $0 so it is set to a String as RubyGems expect, also when not run from the RubyLauncher
898898
DynamicObject dollarZeroValue = StringOperations
899899
.createString(context, StringOperations.encodeRope("-", USASCIIEncoding.INSTANCE, CodeRange.CR_7BIT));
900-
getContext().getCoreLibrary().getGlobalVariables().getStorage("$0").setValueInternal(dollarZeroValue);
900+
globalVariables.getStorage("$0").setValueInternal(dollarZeroValue);
901901
}
902902

903903
@TruffleBoundary
@@ -974,26 +974,6 @@ public static boolean fitsIntoUnsignedInteger(long value) {
974974
return value == (value & 0xffffffffL) || value < 0 && value >= Integer.MIN_VALUE;
975975
}
976976

977-
public RubyContext getContext() {
978-
return context;
979-
}
980-
981-
public SourceSection getSourceSection() {
982-
return sourceSection;
983-
}
984-
985-
public String getCoreLoadPath() {
986-
return coreLoadPath;
987-
}
988-
989-
public FrameDescriptor getEmptyDescriptor() {
990-
return emptyDescriptor;
991-
}
992-
993-
public GlobalVariables getGlobalVariables() {
994-
return globalVariables;
995-
}
996-
997977
public DynamicObject getLoadPath() {
998978
return (DynamicObject) loadPathReader.getValue(globalVariables);
999979
}

src/main/java/org/truffleruby/core/kernel/KernelNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1901,7 +1901,7 @@ public abstract static class KernelGlobalVariablesNode extends CoreMethodArrayAr
19011901
@TruffleBoundary
19021902
@Specialization
19031903
protected DynamicObject globalVariables() {
1904-
final String[] keys = coreLibrary().getGlobalVariables().keys();
1904+
final String[] keys = coreLibrary().globalVariables.keys();
19051905
final Object[] store = new Object[keys.length];
19061906
for (int i = 0; i < keys.length; i++) {
19071907
store[i] = getSymbol(keys[i]);

src/main/java/org/truffleruby/core/kernel/TruffleKernelNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public abstract static class DefineHookedVariableInnerNode extends CoreMethodArr
153153
@Specialization(guards = { "isRubySymbol(name)", "isRubyProc(getter)", "isRubyProc(setter)" })
154154
protected DynamicObject defineHookedVariableInnerNode(DynamicObject name, DynamicObject getter,
155155
DynamicObject setter, DynamicObject isDefined) {
156-
getContext().getCoreLibrary().getGlobalVariables().define(
156+
getContext().getCoreLibrary().globalVariables.define(
157157
Layouts.SYMBOL.getString(name),
158158
getter,
159159
setter,

src/main/java/org/truffleruby/core/method/MethodNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private DynamicObject createProc(RootCallTarget callTarget, InternalMethod metho
263263
final Object[] packedArgs = RubyArguments.pack(null, null, method, null, receiver, null, EMPTY_ARGUMENTS);
264264
final MaterializedFrame declarationFrame = Truffle
265265
.getRuntime()
266-
.createMaterializedFrame(packedArgs, coreLibrary().getEmptyDescriptor());
266+
.createMaterializedFrame(packedArgs, coreLibrary().emptyDescriptor);
267267
return ProcOperations.createRubyProc(
268268
coreLibrary().procFactory,
269269
ProcType.LAMBDA,

src/main/java/org/truffleruby/core/symbol/SymbolNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected DynamicObject createProc(DeclarationContext declarationContext, Intern
141141
// binding as this simplifies the logic elsewhere in the runtime.
142142
final MaterializedFrame declarationFrame = Truffle
143143
.getRuntime()
144-
.createMaterializedFrame(args, coreLibrary().getEmptyDescriptor());
144+
.createMaterializedFrame(args, coreLibrary().emptyDescriptor);
145145
final RubyRootNode rootNode = new RubyRootNode(
146146
getContext(),
147147
sourceSection,

src/main/java/org/truffleruby/extra/TruffleGraalNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected DynamicObject copyCapturedLocals(DynamicObject proc) {
127127
// declaration frame (to allow Proc#binding) so we shall create an empty one.
128128
final MaterializedFrame newDeclarationFrame = Truffle
129129
.getRuntime()
130-
.createMaterializedFrame(args, coreLibrary().getEmptyDescriptor());
130+
.createMaterializedFrame(args, coreLibrary().emptyDescriptor);
131131

132132
return coreLibrary().procFactory.newInstance(Layouts.PROC.build(
133133
Layouts.PROC.getType(proc),

src/main/java/org/truffleruby/language/TruffleBootNodes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ private void setArgvGlobals(StringNodes.MakeStringNode makeStringNode) {
164164
String key = global_values[i];
165165
String value = global_values[i + 1];
166166

167-
getContext().getCoreLibrary().getGlobalVariables().define(
167+
getContext().getCoreLibrary().globalVariables.define(
168168
"$" + key,
169169
makeStringNode.executeMake(value, UTF8Encoding.INSTANCE, CodeRange.CR_UNKNOWN));
170170
}
171171

172172
String[] global_flags = getContext().getOptions().ARGV_GLOBAL_FLAGS;
173173
for (String flag : global_flags) {
174-
getContext().getCoreLibrary().getGlobalVariables().define("$" + flag, true);
174+
getContext().getCoreLibrary().globalVariables.define("$" + flag, true);
175175
}
176176
}
177177
}
@@ -211,7 +211,7 @@ private RubySource loadMainSourceSettingDollarZero(StringNodes.MakeStringNode ma
211211
throw new JavaException(e);
212212
}
213213

214-
getContext().getCoreLibrary().getGlobalVariables().getStorage("$0").setValueInternal(dollarZeroValue);
214+
getContext().getCoreLibrary().globalVariables.getStorage("$0").setValueInternal(dollarZeroValue);
215215
return source;
216216
}
217217

src/main/java/org/truffleruby/language/globals/AliasGlobalVarNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public AliasGlobalVarNode(String oldName, String newName) {
2525

2626
@Override
2727
public Object execute(VirtualFrame frame) {
28-
getContext().getCoreLibrary().getGlobalVariables().alias(oldName, newName);
28+
getContext().getCoreLibrary().globalVariables.alias(oldName, newName);
2929
return nil();
3030
}
3131

0 commit comments

Comments
 (0)