public void preClassEval(StaticScope staticScope, RubyModule type) { pushRubyClass(type); pushFrameCopy(); getCurrentFrame().setSelf(type); getCurrentFrame().setVisibility(Visibility.PUBLIC); getCurrentFrame().setName(null); pushScope(DynamicScope.newDynamicScope(staticScope, null)); }
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); }
public static Block createMethodBlock(MethodBlockBody body) { RubyModule module = body.method.getImplementationClass(); Frame frame = new Frame(); frame.setKlazz(module); frame.setName(body.method.getName()); frame.setSelf(body.receiver); frame.setVisibility(body.method.getVisibility()); Binding binding = new Binding( frame, body.getStaticScope().getDummyScope(), body.method.getName(), body.getFile(), body.getLine()); return new Block(body, binding); }
public static Block createMethodBlock(MethodBlockBody body) { RubyModule module = body.method.getImplementationClass(); Frame frame = new Frame(); frame.setKlazz(module); frame.setName(body.method.getName()); frame.setSelf(body.receiver); frame.setVisibility(body.method.getVisibility()); Binding binding = new Binding( frame, body.getStaticScope().getDummyScope(), body.method.getName(), body.getFile(), body.getLine()); return new Block(body, binding); }
public static Block createMethodBlock(ThreadContext context, IRubyObject self, DynamicScope dynamicScope, MethodBlock body) { RubyMethod method = body.method; RubyModule module = method.getMethod().getImplementationClass(); Frame frame = new Frame(); frame.setKlazz(module); frame.setName(method.getMethodName()); frame.setSelf(method.receiver(context)); frame.setVisibility(method.getMethod().getVisibility()); Binding binding = new Binding( frame, module, dynamicScope, new BacktraceElement(method.getMethodName(), body.getFile(), body.getLine())); return new Block(body, binding); }
public static Block createMethodBlock(ThreadContext context, IRubyObject self, DynamicScope dynamicScope, MethodBlock body) { RubyMethod method = body.method; RubyModule module = method.getMethod().getImplementationClass(); Frame frame = new Frame(); frame.setKlazz(module); frame.setName(method.getMethodName()); frame.setSelf(method.receiver(context)); frame.setVisibility(method.getMethod().getVisibility()); Binding binding = new Binding( frame, module, dynamicScope, new BacktraceElement(method.getMethodName(), body.getFile(), body.getLine())); return new Block(body, binding); }
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); }