Beispiel #1
0
  VariableScope* StackVariables::create_heap_alias(STATE, CallFrame* call_frame,
                                                   bool full)
  {
    if(on_heap_) return on_heap_;

    MachineCode* mcode = call_frame->compiled_code->machine_code();
    VariableScope* scope = state->new_object_dirty<VariableScope>(G(variable_scope));

    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, nil<VariableScope>());
    }

    scope->self(state, self_);
    scope->block(state, block_);
    scope->module(state, module_);
    scope->method(state, call_frame->compiled_code);
    scope->heap_locals(state, Tuple::create(state, mcode->number_of_locals));
    scope->last_match(state, last_match_);
    scope->fiber(state, state->vm()->current_fiber.get());

    scope->number_of_locals_ = mcode->number_of_locals;

    if(full) {
      scope->isolated_ = false;
    } else {
      scope->isolated_ = true;
    }

    scope->locals_ = locals_;
    scope->dynamic_locals(state, nil<LookupTable>());

    scope->set_block_as_method(call_frame->block_as_method_p());

    on_heap_ = scope;

    return scope;
  }
  VariableScope* StackVariables::create_heap_alias(STATE, CallFrame* call_frame,
                                                   bool full)
  {
    if(on_heap_) return on_heap_;

    VMMethod* vmm = call_frame->cm->backend_method();
    VariableScope* scope = state->new_object<VariableScope>(G(variable_scope));

    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, nil<VariableScope>());
    }

    scope->self(state, self_);
    scope->block(state, block_);
    scope->module(state, module_);
    scope->method(state, call_frame->cm);
    scope->heap_locals(state, Tuple::create(state, vmm->number_of_locals));
    scope->last_match(state, last_match_);

    scope->number_of_locals_ = vmm->number_of_locals;

    if(full) {
      scope->isolated_ = false;
    } else {
      scope->isolated_ = true;
    }

    scope->locals_ = locals_;

    scope->set_block_as_method(call_frame->block_as_method_p());

    on_heap_ = scope;

    return scope;
  }
Beispiel #3
0
  VariableScope* StackVariables::create_heap_alias(STATE,
      CallFrame* call_frame, bool full)
  {
    if(on_heap_) return on_heap_;

    VMMethod* vmm = call_frame->cm->backend_method();
    VariableScope* scope = state->new_struct<VariableScope>(
        G(variable_scope), vmm->number_of_locals * sizeof(Object*));

    if(parent_) {
      scope->parent(state, parent_);
    } else {
      scope->parent(state, (VariableScope*)Qnil);
    }

    scope->self(state, self_);
    scope->block(state, block_);
    scope->module(state, module_);
    scope->method(state, call_frame->cm);

    scope->number_of_locals_ = vmm->number_of_locals;

    if(full) {
      scope->isolated_ = false;
      scope->point_locals_to(locals_);
    } else {
      scope->isolated_ = true;
      scope->point_locals_to(scope->heap_locals_);
    }

    scope->set_block_as_method(call_frame->block_as_method_p());

    on_heap_ = scope;

    return scope;
  }