Exemple #1
0
  BlockEnvironment* BlockEnvironment::under_call_frame(STATE, CompiledMethod* cm,
      VMMethod* caller, CallFrame* call_frame, size_t index)
  {
    BlockEnvironment* be = state->new_object<BlockEnvironment>(G(blokenv));

    VMMethod* vmm = caller->blocks.at(index);
    if(!vmm) {
      vmm = cm->formalize(state);
      if(caller->type) {
        vmm->specialize(state, caller->type);
      }
      caller->blocks[index] = vmm;

      vmm->set_parent(caller);
    }

    be->scope(state, call_frame->promote_scope(state));
    be->top_scope(state, call_frame->top_scope(state));
    be->method(state, cm);
    be->module(state, call_frame->module());
    be->local_count(state, cm->local_count());
    be->vmm = vmm;
    BlockExecutor native = reinterpret_cast<BlockExecutor>(vmm->native_function);
    if(native) {
      be->execute = native;
    } else {
      be->execute = &BlockEnvironment::execute_interpreter;
    }
    return be;
  }
  BlockEnvironment* BlockEnvironment::under_call_frame(STATE,
      CompiledCode* ccode, MachineCode* caller)
  {

    MachineCode* mcode = ccode->machine_code();
    if(!mcode) {
      OnStack<1> os(state, ccode);
      mcode = ccode->internalize(state);
      if(!mcode) {
        Exception::internal_error(state, "invalid bytecode method");
        return 0;
      }
    }

    BlockEnvironment* be =
      state->memory()->new_object<BlockEnvironment>(state, G(blokenv));

    CallFrame* call_frame = state->vm()->call_frame();

    be->scope(state, call_frame->promote_scope(state));
    be->top_scope(state, call_frame->top_scope(state));
    be->compiled_code(state, ccode);
    be->constant_scope(state, call_frame->constant_scope());
    be->module(state, call_frame->module());

    return be;
  }
Exemple #3
0
  BlockEnvironment* BlockEnvironment::under_call_frame(STATE, GCToken gct,
      CompiledCode* ccode, MachineCode* caller,
      CallFrame* call_frame)
  {

    MachineCode* mcode = ccode->machine_code();
    if(!mcode) {
      OnStack<1> os(state, ccode);
      state->set_call_frame(call_frame);
      mcode = ccode->internalize(state, gct);
      if(!mcode) {
        Exception::internal_error(state, call_frame, "invalid bytecode method");
        return 0;
      }
    }

    mcode->set_parent(caller);

    BlockEnvironment* be = state->new_object_dirty<BlockEnvironment>(G(blokenv));
    be->scope(state, call_frame->promote_scope(state));
    be->top_scope(state, call_frame->top_scope(state));
    be->compiled_code(state, ccode);
    be->module(state, call_frame->module());
    be->metadata_container(state, nil<Tuple>());
    return be;
  }
Exemple #4
0
  BlockEnvironment* BlockEnvironment::dup(STATE) {
    BlockEnvironment* be = state->new_object_dirty<BlockEnvironment>(G(blokenv));

    be->scope(state, scope_);
    be->top_scope(state, top_scope_);
    be->compiled_code(state, compiled_code_);
    be->module(state, nil<Module>());
    return be;
  }
  BlockEnvironment* BlockEnvironment::dup(STATE) {
    BlockEnvironment* be =
      state->memory()->new_object<BlockEnvironment>(state, G(blokenv));

    be->scope(state, scope());
    be->top_scope(state, top_scope());
    be->compiled_code(state, compiled_code());
    be->constant_scope(state, constant_scope());
    be->module(state, nil<Module>());

    return be;
  }
  BlockEnvironment* BlockEnvironment::under_call_frame(STATE, CompiledMethod* cm,
      VMMethod* caller, CallFrame* call_frame, size_t index)
  {
    BlockEnvironment* be = state->new_object<BlockEnvironment>(G(blokenv));

    VMMethod* vmm = cm->internalize(state);
    if(!vmm) {
      Exception::internal_error(state, call_frame, "invalid bytecode method");
      return 0;
    }

    vmm->set_parent(caller);

    be->scope(state, call_frame->promote_scope(state));
    be->top_scope(state, call_frame->top_scope(state));
    be->code(state, cm);
    be->module(state, call_frame->module());
    return be;
  }