-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
def self.new(*) super end This introduces a problem with ScopeModule not really having a scope to figure out what its module is anymore (the scope was inlined away). The answer is to use the inlining candidate type and for non-zero ScopeModules it is to subtract one from scopeDepth? (I am less sure about this). With this change, self.new still does not properly inline but this seems like a step in the right direction (and I want @subbuss to see the approach).
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import org.jruby.ir.persistence.IRReaderDecoder; | ||
import org.jruby.ir.persistence.IRWriterEncoder; | ||
import org.jruby.ir.transformations.inlining.CloneInfo; | ||
import org.jruby.ir.transformations.inlining.InlineCloneInfo; | ||
import org.jruby.parser.StaticScope; | ||
import org.jruby.runtime.DynamicScope; | ||
import org.jruby.runtime.Helpers; | ||
|
@@ -45,6 +46,13 @@ public void addUsedVariables(List<Variable> l) { | |
|
||
@Override | ||
public Operand cloneForInlining(CloneInfo ii) { | ||
if (ii instanceof InlineCloneInfo) { | ||
if (scopeModuleDepth == 0) { // replace scope with inlined candidate receiver | ||
return ((InlineCloneInfo) ii).getRenamedSelfVariable(null); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
subbuss
Contributor
|
||
} else { // otherwise we only lost one scope from inlining...subtract one. | ||
return ModuleFor(scopeModuleDepth - 1); | ||
} | ||
} | ||
return this; | ||
} | ||
|
||
|
Can this happen? ClassBody is the only non-singleton class body => for all other scope types that is being inlined into the host scope, ScopeModule will always have scopeModuleDepth > 1. So, this scenario should not happen and you should assert.