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; }
void BlockEnvironment::Info::show(STATE, Object* self, int level) { BlockEnvironment* be = as<BlockEnvironment>(self); class_header(state, self); indent_attribute(++level, "home"); be->home()->show(state, level); indent_attribute(level, "home_block"); be->home_block()->show(state, level); indent_attribute(level, "local_count"); be->local_count()->show(state, level); indent_attribute(level, "method"); be->method()->show(state, level); close_body(level); }
BlockEnvironment* BlockEnvironment::dup(STATE) { BlockEnvironment* be = state->new_object<BlockEnvironment>(G(blokenv)); be->execute = &BlockEnvironment::execute_interpreter; be->scope(state, scope_); be->top_scope(state, top_scope_); be->method(state, method_); be->local_count(state, local_count_); be->vmm = this->vmm; return be; }
BlockEnvironment* BlockEnvironment::under_context(STATE, CompiledMethod* cm, MethodContext* parent, MethodContext* active, size_t index) { BlockEnvironment* be = (BlockEnvironment*)state->new_object(G(blokenv)); VMMethod* vmm; if((vmm = active->vmm->blocks[index]) == NULL) { vmm = new VMMethod(state, cm); if(active->vmm->type) { vmm->specialize(state, active->vmm->type); } active->vmm->blocks[index] = vmm; } be->home(state, parent); be->home_block(state, active); be->method(state, cm); be->local_count(state, cm->local_count()); be->vmm = vmm; return be; }