-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
248 additions
and
76 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
64 changes: 64 additions & 0 deletions
64
core/src/main/java/org/jruby/ir/instructions/LoadImplicitClosureInstr.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,64 @@ | ||
package org.jruby.ir.instructions; | ||
|
||
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.transformations.inlining.CloneInfo; | ||
import org.jruby.ir.transformations.inlining.InlineCloneInfo; | ||
import org.jruby.ir.transformations.inlining.SimpleCloneInfo; | ||
import org.jruby.parser.StaticScope; | ||
import org.jruby.runtime.Block; | ||
import org.jruby.runtime.DynamicScope; | ||
import org.jruby.runtime.ThreadContext; | ||
import org.jruby.runtime.builtin.IRubyObject; | ||
|
||
/* Receive the closure argument (either implicit or explicit in Ruby source code) */ | ||
public class LoadImplicitClosureInstr extends Instr implements ResultInstr, FixedArityInstr { | ||
private Variable result; | ||
|
||
public LoadImplicitClosureInstr(Variable result) { | ||
super(Operation.LOAD_IMPLICT_CLOSURE); | ||
|
||
assert result != null: "LoadImplicitClosureInstr result is null"; | ||
|
||
this.result = result; | ||
} | ||
|
||
@Override | ||
public Operand[] getOperands() { | ||
return EMPTY_OPERANDS; | ||
} | ||
|
||
@Override | ||
public Variable getResult() { | ||
return result; | ||
} | ||
|
||
@Override | ||
public void updateResult(Variable v) { | ||
this.result = v; | ||
} | ||
|
||
@Override | ||
public Instr clone(CloneInfo info) { | ||
if (info instanceof SimpleCloneInfo) return new LoadImplicitClosureInstr(info.getRenamedVariable(result)); | ||
|
||
// SSS FIXME: This code below is for inlining and is untested. | ||
|
||
InlineCloneInfo ii = (InlineCloneInfo) info; | ||
|
||
// SSS FIXME: This is not strictly correct -- we have to wrap the block into an | ||
// operand type that converts the static code block to a proc which is a closure. | ||
if (ii.getCallClosure() instanceof WrappedIRClosure) return NopInstr.NOP; | ||
|
||
return new CopyInstr(ii.getRenamedVariable(result), ii.getCallClosure()); | ||
} | ||
|
||
@Override | ||
public void visit(IRVisitor visitor) { | ||
visitor.LoadImplicitClosure(this); | ||
} | ||
} |
Oops, something went wrong.