Skip to content

Commit 7a72f40

Browse files
author
Nicolas Laurent
committed
misc cleanup
1 parent 728e3d8 commit 7a72f40

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

src/main/java/org/truffleruby/language/constants/OrAssignConstantNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Object execute(VirtualFrame frame) {
5555
final RubyConstant constant = readConstant.getConstantIfDefined(module);
5656
final Object value = constant == null
5757
? null
58-
: readConstant.execute(frame, module, constant);
58+
: readConstant.getConstant(module, constant);
5959

6060
// Write if the constant is undefined or if its value is falsy.
6161
if (constant == null || !castToBoolean(value)) {

src/main/java/org/truffleruby/language/constants/ReadConstantNode.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,15 @@ public ReadConstantNode(RubyNode moduleNode, String name) {
4141

4242
@Override
4343
public Object execute(VirtualFrame frame) {
44-
final Object moduleObject = moduleNode.execute(frame);
45-
return lookupAndGetConstant(checkModule(moduleObject));
46-
}
47-
48-
public Object execute(VirtualFrame frame, RubyModule module, RubyConstant constant) {
49-
return getConstant(module, constant);
44+
return lookupAndGetConstant(evaluateModule(frame));
5045
}
5146

5247
private Object lookupAndGetConstant(RubyModule module) {
5348
return getGetConstantNode()
5449
.lookupAndResolveConstant(LexicalScope.IGNORE, module, name, getLookupConstantNode());
5550
}
5651

57-
private Object getConstant(RubyModule module, RubyConstant constant) {
52+
public Object getConstant(RubyModule module, RubyConstant constant) {
5853
return getGetConstantNode()
5954
.executeGetConstant(LexicalScope.IGNORE, module, name, constant, getLookupConstantNode());
6055
}
@@ -95,7 +90,7 @@ public Object isDefined(VirtualFrame frame, RubyLanguage language, RubyContext c
9590
final RubyConstant constant = getConstantIfDefined(module);
9691
return constant == null ? nil : coreStrings().CONSTANT.createInstance(getContext());
9792
} catch (RaiseException e) {
98-
return nil; // MRI swallows all exceptions in defined? (MRI Bug#5786)
93+
return nil; // MRI swallows all exceptions in defined? (https://bugs.ruby-lang.org/issues/5786)
9994
}
10095
}
10196

src/main/java/org/truffleruby/language/constants/WriteConstantNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public void assign(VirtualFrame frame, Object value) {
6161
}
6262

6363
private void assign(RubyModule module, Object value) {
64-
final RubyConstant previous = module.fields
65-
.setConstant(getContext(), this, name, value);
64+
final RubyConstant previous = module.fields.setConstant(getContext(), this, name, value);
6665
if (previous != null && previous.hasValue()) {
6766
warnAlreadyInitializedConstant(module, name, previous.getSourceSection());
6867
}

0 commit comments

Comments
 (0)