public DynamicScope allocScope(DynamicScope parentScope) { // SSS: Important! Use getStaticScope() to use a copy of the static-scope stored in the block-body. // Do not use 'closure.getStaticScope()' -- that returns the original copy of the static scope. // This matters because blocks created for Thread bodies modify the static-scope field of the block-body // that records additional state about the block body. // // FIXME: Rather than modify static-scope, it seems we ought to set a field in block-body which is then // used to tell dynamic-scope that it is a dynamic scope for a thread body. Anyway, to be revisited later! DynamicScope newScope = DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, body.getEvalType()); if (type == Block.Type.LAMBDA) newScope.setLambda(true); return newScope; }
public DynamicScope allocScope(DynamicScope parentScope) { // SSS: Important! Use getStaticScope() to use a copy of the static-scope stored in the block-body. // Do not use 'closure.getStaticScope()' -- that returns the original copy of the static scope. // This matters because blocks created for Thread bodies modify the static-scope field of the block-body // that records additional state about the block body. // // FIXME: Rather than modify static-scope, it seems we ought to set a field in block-body which is then // used to tell dynamic-scope that it is a dynamic scope for a thread body. Anyway, to be revisited later! DynamicScope newScope = DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, body.getEvalType()); if (type == Block.Type.LAMBDA) newScope.setLambda(true); return newScope; }
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); }
StaticScope oldScope = block.getBody().getStaticScope(); StaticScope newScope = oldScope.duplicate(); block.getBody().setStaticScope(newScope); block.getBinding().getDummyScope(block.getBody().getStaticScope());
StaticScope oldScope = block.getBody().getStaticScope(); StaticScope newScope = oldScope.duplicate(); block.getBody().setStaticScope(newScope); block.getBinding().getDummyScope(block.getBody().getStaticScope());
StaticScope oldScope = block.getBody().getStaticScope(); StaticScope newScope = getRuntime().getStaticScopeFactory().newBlockScope(oldScope.getEnclosingScope(), oldScope.getVariables()); newScope.setPreviousCRefScope(oldScope.getPreviousCRefScope()); block.getBinding().getDummyScope(block.getBody().getStaticScope());
StaticScope oldScope = block.getBody().getStaticScope(); StaticScope newScope = getRuntime().getStaticScopeFactory().newBlockScope(oldScope.getEnclosingScope(), oldScope.getVariables()); newScope.setPreviousCRefScope(oldScope.getPreviousCRefScope()); block.getBinding().getDummyScope(block.getBody().getStaticScope());