コード例 #1
0
ファイル: ThreadContext.java プロジェクト: jlieske/jruby
  // XXX: Again, screwy evaling under previous frame's scope
  public void preExecuteUnder(RubyModule executeUnderClass, Block block) {
    Frame frame = getCurrentFrame();

    pushRubyClass(executeUnderClass);
    DynamicScope scope = getCurrentScope();
    StaticScope sScope = new BlockStaticScope(scope.getStaticScope());
    sScope.setModule(executeUnderClass);
    pushScope(DynamicScope.newDynamicScope(sScope, scope));
    pushCallFrame(frame.getKlazz(), frame.getName(), frame.getSelf(), block);
    getCurrentFrame().setVisibility(getPreviousFrame().getVisibility());
  }
コード例 #2
0
ファイル: ThreadContext.java プロジェクト: jlieske/jruby
 public void preClassEval(StaticScope staticScope, RubyModule type) {
   pushRubyClass(type);
   pushFrameCopy();
   getCurrentFrame().setSelf(type);
   getCurrentFrame().setVisibility(Visibility.PUBLIC);
   pushScope(DynamicScope.newDynamicScope(staticScope, null));
 }
コード例 #3
0
ファイル: ThreadContext.java プロジェクト: jlieske/jruby
 public void preCompiledClass(RubyModule type, StaticScope staticScope) {
   pushRubyClass(type);
   pushFrameCopy();
   getCurrentFrame().setSelf(type);
   getCurrentFrame().setVisibility(Visibility.PUBLIC);
   staticScope.setModule(type);
   pushScope(DynamicScope.newDynamicScope(staticScope));
 }
コード例 #4
0
ファイル: Block.java プロジェクト: danshep/jruby
 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!
   EvalType evalType = ((IRBlockBody) body).getEvalType();
   DynamicScope newScope =
       DynamicScope.newDynamicScope(body.getStaticScope(), parentScope, evalType);
   if (type == Block.Type.LAMBDA) newScope.setLambda(true);
   return newScope;
 }
コード例 #5
0
ファイル: ThreadContext.java プロジェクト: jlieske/jruby
 public void preMethodScopeOnly(RubyModule clazz, StaticScope staticScope) {
   RubyModule implementationClass = staticScope.getModule();
   // FIXME: This is currently only here because of some problems with IOOutputStream writing to a
   // "bare" runtime without a proper scope
   if (implementationClass == null) {
     implementationClass = clazz;
   }
   pushScope(DynamicScope.newDynamicScope(staticScope));
   pushRubyClass(implementationClass);
 }
コード例 #6
0
ファイル: ThreadContext.java プロジェクト: jlieske/jruby
 public void preMethodFrameAndScope(
     RubyModule clazz, String name, IRubyObject self, Block block, StaticScope staticScope) {
   RubyModule implementationClass = staticScope.getModule();
   // FIXME: This is currently only here because of some problems with IOOutputStream writing to a
   // "bare" runtime without a proper scope
   if (implementationClass == null) {
     implementationClass = clazz;
   }
   pushCallFrame(clazz, name, self, block);
   pushScope(DynamicScope.newDynamicScope(staticScope));
   pushRubyClass(implementationClass);
 }
コード例 #7
0
ファイル: Binding.java プロジェクト: ryenus/jruby
  public final DynamicScope getEvalScope(Ruby runtime) {
    // We create one extra dynamicScope on a binding so that when we 'eval "b=1", binding' the
    // 'b' will get put into this new dynamic scope.  The original scope does not see the new
    // 'b' and successive evals with this binding will.  I take it having the ability to have
    // succesive binding evals be able to share same scope makes sense from a programmers
    // perspective.   One crappy outcome of this design is it requires Dynamic and Static
    // scopes to be mutable for this one case.

    // Note: In Ruby 1.9 all of this logic can go away since they will require explicit
    // bindings for evals.

    // We only define one special dynamic scope per 'logical' binding.  So all bindings for
    // the same scope should share the same dynamic scope.  This allows multiple evals with
    // different different bindings in the same scope to see the same stuff.

    // No eval scope set, so we create one
    if (evalScopeBinding.evalScope == null) {

      // If the next scope out has the same binding scope as this scope it means
      // we are evaling within an eval and in that case we should be sharing the same
      // binding scope.
      DynamicScope parent = dynamicScope.getNextCapturedScope();

      if (parent != null && parent.getEvalScope(runtime) == dynamicScope) {
        evalScopeBinding.evalScope = dynamicScope;
      } else {
        // bindings scopes must always be ManyVars scopes since evals can grow them
        evalScopeBinding.evalScope =
            new ManyVarsDynamicScope(
                runtime.getStaticScopeFactory().newEvalScope(dynamicScope.getStaticScope()),
                dynamicScope);
      }
    }

    return evalScopeBinding.evalScope;
  }
コード例 #8
0
ファイル: ThreadContext.java プロジェクト: jlieske/jruby
 public Frame preYieldSpecificBlock(Binding binding, StaticScope scope, RubyModule klass) {
   Frame lastFrame = preYieldNoScope(binding, klass);
   // new scope for this invocation of the block, based on parent scope
   pushScope(DynamicScope.newDynamicScope(scope, binding.getDynamicScope()));
   return lastFrame;
 }
コード例 #9
0
ファイル: ThreadContext.java プロジェクト: jlieske/jruby
 public void preScopeNode(StaticScope staticScope) {
   pushScope(DynamicScope.newDynamicScope(staticScope, getCurrentScope()));
 }
コード例 #10
0
ファイル: Binding.java プロジェクト: ryenus/jruby
 public DynamicScope getDummyScope(StaticScope staticScope) {
   if (dummyScope == null || dummyScope.getStaticScope() != staticScope) {
     return dummyScope = DynamicScope.newDummyScope(staticScope, dynamicScope);
   }
   return dummyScope;
 }
コード例 #11
0
ファイル: Binding.java プロジェクト: ryenus/jruby
 public Binding deepClone() {
   return new Binding(this, dynamicScope.cloneScope(), this);
 }