本文整理汇总了C++中VMMethod::specialize方法的典型用法代码示例。如果您正苦于以下问题:C++ VMMethod::specialize方法的具体用法?C++ VMMethod::specialize怎么用?C++ VMMethod::specialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VMMethod
的用法示例。
在下文中一共展示了VMMethod::specialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_specialize_transforms_ivars_to_slots
void test_specialize_transforms_ivars_to_slots() {
CompiledMethod* cm = CompiledMethod::create(state);
Tuple* tup = Tuple::from(state, 1, state->symbol("@blah"));
cm->literals(state, tup);
InstructionSequence* iseq = InstructionSequence::create(state, 3);
iseq->opcodes()->put(state, 0, Fixnum::from(InstructionSequence::insn_push_ivar));
iseq->opcodes()->put(state, 1, Fixnum::from(0));
iseq->opcodes()->put(state, 2, Fixnum::from(InstructionSequence::insn_push_nil));
cm->iseq(state, iseq);
VMMethod* vmm = new VMMethod(state, cm);
Object::Info ti(ObjectType);
ti.slots[state->symbol("@blah")->index()] = 5;
ti.slot_locations.resize(6);
ti.slot_locations[5] = 33;
vmm->specialize(state, cm, &ti);
TS_ASSERT_EQUALS(vmm->total, 3U);
TS_ASSERT_EQUALS(vmm->opcodes[0], static_cast<unsigned int>(InstructionSequence::insn_push_my_offset));
TS_ASSERT_EQUALS(vmm->opcodes[1], 33U);
TS_ASSERT_EQUALS(vmm->opcodes[2], static_cast<unsigned int>(InstructionSequence::insn_push_nil));
}
示例2: under_context
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;
}