org.jruby.ir.instructions.RecordEndBlockInstr Maven / Gradle / Ivy
package org.jruby.ir.instructions;
import org.jruby.ir.IRClosure;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.IRScope;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.transformations.inlining.InlinerInfo;
import org.jruby.runtime.Block;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
public class RecordEndBlockInstr extends Instr {
private IRScope declaringScope;
private IRClosure endBlockClosure;
public RecordEndBlockInstr(IRScope declaringScope, IRClosure endBlockClosure) {
super(Operation.RECORD_END_BLOCK);
this.declaringScope = declaringScope;
this.endBlockClosure = endBlockClosure;
}
@Override
public Operand[] getOperands() {
return EMPTY_OPERANDS;
}
@Override
public String toString() {
return getOperation().toString() + "(" + endBlockClosure.getName() + ")";
}
@Override
public Instr cloneForInlining(InlinerInfo ii) {
// SSS FIXME: Correct in all situations??
return new RecordEndBlockInstr(declaringScope, endBlockClosure);
}
@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) {
declaringScope.getTopLevelScope().recordEndBlock(endBlockClosure);
return null;
}
@Override
public void visit(IRVisitor visitor) {
visitor.RecordEndBlockInstr(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy