Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
 package org.jruby.ir.instructions.calladapter;
 

Author(s):
enebo
public abstract class ClosureCallAdapter extends CallAdapter {
    private Operand closure;
    
    public ClosureCallAdapter(CallSite callSiteOperand closure) {
        super(callSite);
        
        this. = closure;
    }
    
    protected Block prepareBlock(ThreadContext contextIRubyObject selfDynamicScope currDynScopeObject[] temp) {
        if ( == nullreturn .;
 
        Object value = .retrieve(contextselfcurrDynScopetemp);
        
        Block block;
        if (value instanceof Block) {
            block = (Blockvalue;
        } else if (value instanceof RubyProc) {
            block = ((RubyProcvalue).getBlock();
        } else if (value instanceof RubyMethod) {
            block = ((RubyProc)((RubyMethod)value).to_proc(contextnull)).getBlock();
        } else if ((value instanceof IRubyObject) && ((IRubyObject)value).isNil()) {
            block = .;
        } else if (value instanceof IRubyObject) {
            block = ((RubyProc)TypeConverter.convertToType((IRubyObject)valuecontext.runtime.getProc(), "to_proc"true)).getBlock();
        } else {
            throw new RuntimeException("Unhandled case in CallInstr:prepareBlock.  Got block arg: " + value);
        }
        return block;
    }    
New to GrepCode? Check out our FAQ X