Exemple #1
0
  Object* rbx_create_block_multi(STATE, CompiledMethod* cm, int index, 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->static_scope());

    VMMethod* vmm = closest->cm->backend_method();
    return BlockEnvironment::under_call_frame(state, cm, vmm, closest, index);
  }