Skip to content

Commit

Permalink
We should always have a staticScope in hand
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Dec 19, 2024
1 parent 4e925df commit 7554ac6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
11 changes: 11 additions & 0 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -1659,15 +1659,26 @@ public static RubyHash dupKwargsHashAndPopulateFromArray(ThreadContext context,

@JIT
public static IRubyObject searchConst(ThreadContext context, StaticScope staticScope, String constName, boolean noPrivateConsts) {
<<<<<<< Updated upstream
RubyModule object = objectClass(context);
IRubyObject constant = staticScope == null ? object.getConstant(constName) : staticScope.getConstantInner(constName);
=======
IRubyObject constant = staticScope.getScopedConstant(context, constName);
>>>>>>> Stashed changes

// Inheritance lookup
RubyModule module = null;
if (constant == null) {
<<<<<<< Updated upstream
// SSS FIXME: Is this null check case correct?
module = staticScope == null ? object : staticScope.getModule();
constant = noPrivateConsts ? module.getConstantFromNoConstMissing(constName, false) : module.getConstantNoConstMissing(constName);
=======
module = staticScope.getModule();
constant = noPrivateConsts ?
module.getConstantFromNoConstMissing(constName, false) :
module.getConstantNoConstMissing(context, constName);
>>>>>>> Stashed changes
}

// Call const_missing or cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,31 @@ private RubySymbol getSymbolicName(ThreadContext context) {

public IRubyObject searchConst(ThreadContext context, StaticScope staticScope) {
// Lexical lookup
<<<<<<< Updated upstream
RubyModule object = objectClass(context);

// get switchpoint before value
SwitchPoint switchPoint = getSwitchPointForConstant(context.runtime);
IRubyObject constant = (staticScope == null) ? object.getConstant(name) : staticScope.getConstantInner(name);
=======
// get switchpoint before value
SwitchPoint switchPoint = getSwitchPointForConstant(context.runtime);
IRubyObject constant = staticScope.getScopedConstant(context, name);
>>>>>>> Stashed changes

// Inheritance lookup
RubyModule module = null;
if (constant == null) {
<<<<<<< Updated upstream
// SSS FIXME: Is this null check case correct?
module = staticScope == null ? object : staticScope.getModule();
constant = publicOnly ? module.getConstantFromNoConstMissing(name, false) : module.getConstantNoConstMissing(name);
=======
module = staticScope.getModule();
constant = publicOnly ?
module.getConstantFromNoConstMissing(name, false) :
module.getConstantNoConstMissing(context, name);
>>>>>>> Stashed changes
}

// Call const_missing or cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,26 @@ public ConstantLookupSite(RubySymbol name) {

private IRubyObject cacheSearchConst(ThreadContext context, StaticScope staticScope, boolean publicOnly) {
// Lexical lookup
RubyModule object = objectClass(context);
String id = this.id;
<<<<<<< Updated upstream
IRubyObject constant = (staticScope == null) ? object.getConstant(id) : staticScope.getConstantInner(id);
=======
IRubyObject constant = staticScope.getScopedConstant(context, id);
>>>>>>> Stashed changes

// Inheritance lookup
RubyModule module = null;
if (constant == null) {
<<<<<<< Updated upstream
// SSS FIXME: Is this null check case correct?
module = staticScope == null ? object : staticScope.getModule();
constant = publicOnly ? module.getConstantFromNoConstMissing(id, false) : module.getConstantNoConstMissing(id);
=======
module = staticScope.getModule();
constant = publicOnly ?
module.getConstantFromNoConstMissing(id, false) :
module.getConstantNoConstMissing(context, id);
>>>>>>> Stashed changes
}

// Call const_missing or cache
Expand Down

0 comments on commit 7554ac6

Please sign in to comment.