-
-
Notifications
You must be signed in to change notification settings - Fork 924
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up fat ZSuper into an if-nest and thin ZSuper instructions
* The only difference between ZSuper and UnresolvedSuper instructions is that ZSuper seems to get its block from the frame if one is not provided to it explicitly.
- Loading branch information
Showing
7 changed files
with
140 additions
and
119 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
61 changes: 61 additions & 0 deletions
61
core/src/main/java/org/jruby/ir/instructions/ArgScopeDepthInstr.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,61 @@ | ||
package org.jruby.ir.instructions; | ||
|
||
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.transformations.inlining.InlinerInfo; | ||
import org.jruby.parser.StaticScope; | ||
import org.jruby.runtime.DynamicScope; | ||
import org.jruby.runtime.ThreadContext; | ||
import org.jruby.runtime.builtin.IRubyObject; | ||
|
||
public class ArgScopeDepthInstr extends Instr implements ResultInstr,FixedArityInstr { | ||
private Operand arg; | ||
private Variable result; | ||
|
||
public ArgScopeDepthInstr(Variable result) { | ||
super(Operation.ARG_SCOPE_DEPTH); | ||
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 cloneForInlining(InlinerInfo ii) { | ||
return new ArgScopeDepthInstr(ii.getRenamedVariable(result)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return result + " = " + super.toString(); | ||
} | ||
|
||
@Override | ||
public void visit(IRVisitor visitor) { | ||
visitor.ArgScopeDepthInstr(this); | ||
} | ||
|
||
@Override | ||
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) { | ||
int i = 0; | ||
while (!currDynScope.getStaticScope().isArgumentScope()) { | ||
currDynScope = currDynScope.getParentScope(); | ||
i++; | ||
} | ||
return context.runtime.newFixnum(i); | ||
} | ||
} |
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