/*
 *  call-seq:
 *     prc.binding    => binding
 *  
 *  Returns the binding associated with <i>prc</i>. Note that
 *  <code>Kernel#eval</code> accepts either a <code>Proc</code> or a
 *  <code>Binding</code> object as its second parameter.
 *     
 *     def fred(param)
 *       proc {}
 *     end
 *     
 *     b = fred(99)
 *     eval("param", b.binding)   #=> 99
 */
static VALUE
proc_binding(VALUE self)
{
    rb_proc_t *proc;
    VALUE bindval = binding_alloc(rb_cBinding);
    rb_binding_t *bind;

    GetProcPtr(self, proc);
    GetBindingPtr(bindval, bind);

    if (TYPE(proc->block.iseq) == T_NODE) {
        rb_raise(rb_eArgError, "Can't create Binding from C level Proc");
    }

    bind->env = proc->envval;
    return bindval;
}