private DynamicMethod createProcMethod(Ruby runtime, String name, Visibility visibility, Block block) { block = block.cloneBlockAndFrame(); block.getBinding().getFrame().setKlazz(this); block.getBinding().getFrame().setName(name); block.getBinding().setMethod(name); // a normal block passed to define_method changes to do arity checking; make it a lambda RubyProc proc = runtime.newProc(Block.Type.LAMBDA, block); // various instructions can tell this scope is not an ordinary block but a block representing // a method definition. block.getBody().getStaticScope().makeArgumentScope(); return new ProcMethod(this, proc, visibility, name); }
private DynamicMethod createProcMethod(Ruby runtime, String name, Visibility visibility, Block block) { block = block.cloneBlockAndFrame(); block.getBinding().getFrame().setKlazz(this); block.getBinding().getFrame().setName(name); block.getBinding().setMethod(name); // a normal block passed to define_method changes to do arity checking; make it a lambda RubyProc proc = runtime.newProc(Block.Type.LAMBDA, block); // various instructions can tell this scope is not an ordinary block but a block representing // a method definition. block.getBody().getStaticScope().makeArgumentScope(); return new ProcMethod(this, proc, visibility, name); }
private DynamicMethod createProcMethod(String name, Visibility visibility, RubyProc proc) { Block block = proc.getBlock(); block.getBinding().getFrame().setKlazz(this); block.getBinding().getFrame().setName(name); block.getBinding().setMethod(name); StaticScope scope = block.getBody().getStaticScope(); // for zsupers in define_method (blech!) we tell the proc scope to act as the "argument" scope scope.makeArgumentScope(); Arity arity = block.arity(); // just using required is broken...but no more broken than before zsuper refactoring scope.setRequiredArgs(arity.required()); if(!arity.isFixed()) { scope.setRestArg(arity.required()); } return new ProcMethod(this, proc, visibility); }
private DynamicMethod createProcMethod(String name, Visibility visibility, RubyProc proc) { Block block = proc.getBlock(); block.getBinding().getFrame().setKlazz(this); block.getBinding().getFrame().setName(name); block.getBinding().setMethod(name); StaticScope scope = block.getBody().getStaticScope(); // for zsupers in define_method (blech!) we tell the proc scope to act as the "argument" scope scope.makeArgumentScope(); Arity arity = block.arity(); // just using required is broken...but no more broken than before zsuper refactoring scope.setRequiredArgs(arity.required()); if(!arity.isFixed()) { scope.setRestArg(arity.required()); } return new ProcMethod(this, proc, visibility); }