private void setup(Block procBlock) { if (!procBlock.isGiven()) { throw getRuntime().newArgumentError("tried to create Proc object without a block"); } if (isLambda()) { // TODO: warn "tried to create Proc object without a block" } if (isThread()) { // binding for incoming proc must not share frame Binding oldBinding = procBlock.getBinding(); Binding newBinding = new Binding( oldBinding.getSelf(), oldBinding.getFrame().duplicate(), oldBinding.getVisibility(), oldBinding.getDynamicScope(), oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine()); block = new Block(procBlock.getBody(), newBinding); // modify the block with a new backref/lastline-grabbing scope StaticScope oldScope = block.getBody().getStaticScope(); StaticScope newScope = oldScope.duplicate(); block.getBody().setStaticScope(newScope); } else { // just use as is block = procBlock; } // force file/line info into the new block's binding block.getBinding().setFile(block.getBody().getFile()); block.getBinding().setLine(block.getBody().getLine()); block.type = type; block.setProcObject(this); // pre-request dummy scope to avoid clone overhead in lightweight blocks block.getBinding().getDummyScope(block.getBody().getStaticScope()); }