-
Notifications
You must be signed in to change notification settings - Fork 914
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always use ModuleSuper and rewrite define_method
The changes here attempt to get more super calls using a static name, so we can eliminate dependency on a call frame to get that name. * super in a block in any method will start out as a ModuleSuper using the name from the method. * define_method clones and rewrites the block to retarget any super calls to the newly defined name. * all super instructions get rewritten to the appropriate type for the target class, instance/class/module Remaining cases that use UnresolvedSuper may only be the ones where super is invalid, such as a block at top-level or within a class or module body.
- Loading branch information
Showing
9 changed files
with
188 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
core/src/main/java/org/jruby/ir/instructions/SuperInstr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.jruby.ir.instructions; | ||
|
||
import org.jruby.RubyInstanceConfig; | ||
import org.jruby.RubySymbol; | ||
import org.jruby.ir.IRFlags; | ||
import org.jruby.ir.IRScope; | ||
import org.jruby.ir.IRVisitor; | ||
import org.jruby.ir.Operation; | ||
import org.jruby.ir.operands.Operand; | ||
import org.jruby.ir.operands.Variable; | ||
import org.jruby.ir.operands.WrappedIRClosure; | ||
import org.jruby.ir.persistence.IRReaderDecoder; | ||
import org.jruby.ir.runtime.IRRuntimeHelpers; | ||
import org.jruby.ir.transformations.inlining.CloneInfo; | ||
import org.jruby.parser.StaticScope; | ||
import org.jruby.runtime.Block; | ||
import org.jruby.runtime.CallSite; | ||
import org.jruby.runtime.CallType; | ||
import org.jruby.runtime.DynamicScope; | ||
import org.jruby.runtime.ThreadContext; | ||
import org.jruby.runtime.builtin.IRubyObject; | ||
|
||
import java.util.EnumSet; | ||
|
||
public abstract class SuperInstr extends CallInstr { | ||
private final boolean isLiteralBlock; | ||
|
||
// clone constructor | ||
protected SuperInstr(IRScope scope, Operation op, Variable result, Operand receiver, RubySymbol name, Operand[] args, | ||
Operand closure, boolean potentiallyRefined, CallSite callSite, long callSiteId) { | ||
super(scope, op, CallType.SUPER, result, name, receiver, args, closure, potentiallyRefined, callSite, callSiteId); | ||
|
||
isLiteralBlock = closure instanceof WrappedIRClosure; | ||
} | ||
|
||
// normal constructor | ||
public SuperInstr(IRScope scope, Operation op, Variable result, Operand definingModule, RubySymbol name, Operand[] args, Operand closure, | ||
boolean isPotentiallyRefined) { | ||
super(scope, op, CallType.SUPER, result, name, definingModule, args, closure, isPotentiallyRefined); | ||
|
||
isLiteralBlock = closure instanceof WrappedIRClosure; | ||
} | ||
|
||
public abstract Operand getDefiningModule(); | ||
} |
Oops, something went wrong.