Пример #1
0
  Object* rbx_create_block_multi(STATE, CompiledCode* cm, int count, ...) {
    va_list ap;

    CallFrame* closest = 0;
    VariableScope* top = 0;
    VariableScope* parent = 0;

    va_start(ap, count);
    for(int i = 0; i < count; i++) {
      closest = va_arg(ap, CallFrame*);
      closest->scope->set_parent(parent);
      parent = closest->promote_scope(state);

      if(!top) {
        top = parent;
      } else {
        closest->flags |= CallFrame::cMultipleScopes;
        closest->top_scope_ = top;
      }
    }
    va_end(ap);

    // TODO: We don't need to be doing this everytime.
    cm->scope(state, closest->constant_scope());

    VMMethod* vmm = closest->cm->backend_method();
    GCTokenImpl gct;
    return BlockEnvironment::under_call_frame(state, gct, cm, vmm, closest);
  }
Пример #2
0
  Object* rbx_create_block_multi(STATE, CompiledCode* code, int count, ...) {
    va_list ap;

    CallFrame* closest = 0;
    VariableScope* top = 0;
    VariableScope* parent = 0;

    va_start(ap, count);
    for(int i = 0; i < count; i++) {
      closest = va_arg(ap, CallFrame*);
      closest->scope->set_parent(parent);
      parent = closest->promote_scope(state);

      if(!top) {
        top = parent;
      } else {
        closest->flags |= CallFrame::cMultipleScopes;
        closest->top_scope_ = top;
      }
    }
    va_end(ap);

    assert(closest);
    MachineCode* mcode = closest->compiled_code->machine_code();
    GCTokenImpl gct;
    return BlockEnvironment::under_call_frame(state, gct, code, mcode, closest);
  }
Пример #3
0
  Tuple* Thread::context(STATE) {
    utilities::thread::SpinLock::LockGuard lg(init_lock_);

    VM* vm = vm_;
    if(!vm) return nil<Tuple>();

    CallFrame* cf = vm->saved_call_frame()->top_ruby_frame();

    VariableScope* scope = cf->promote_scope(state);

    return Tuple::from(state, 3, Fixnum::from(cf->ip()), cf->compiled_code, scope);
  }
Пример #4
0
 VariableScope* VariableScope::of_sender(STATE, CallFrame* call_frame) {
   CallFrame* dest = static_cast<CallFrame*>(call_frame->previous);
   // Skip any frames for native methods
   while(dest->native_method_p()) { dest = dest->previous; }
   return dest->promote_scope(state);
 }
Пример #5
0
 VariableScope* VariableScope::of_sender(STATE, CallFrame* call_frame) {
   CallFrame* dest = static_cast<CallFrame*>(call_frame->previous);
   return dest->promote_scope(state);
 }