本文整理汇总了C++中CompiledMethod::primitive方法的典型用法代码示例。如果您正苦于以下问题:C++ CompiledMethod::primitive方法的具体用法?C++ CompiledMethod::primitive怎么用?C++ CompiledMethod::primitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompiledMethod
的用法示例。
在下文中一共展示了CompiledMethod::primitive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_cmethod
void test_cmethod() {
std::string str = "M\n1\nn\nx\n12\nobject_equal\nx\n4\ntest\ni\n1\n0\nI\na\nI\n0\nI\n0\nI\n0\nn\np\n2\nI\n1\nI\n2\np\n1\np\n3\nI\n0\nI\n1\nI\n1\nx\n8\nnot_real\np\n1\nx\n4\nblah\n";
mar->sstream.str(str);
Object* obj = mar->unmarshal();
TS_ASSERT(kind_of<CompiledMethod>(obj));
CompiledMethod* cm = as<CompiledMethod>(obj);
TS_ASSERT_EQUALS(cm->ivars(), Qnil);
TS_ASSERT_EQUALS(cm->primitive(), state->symbol("object_equal"));
TS_ASSERT_EQUALS(cm->name(), state->symbol("test"));
TS_ASSERT(tuple_equals(cm->iseq()->opcodes(), Tuple::from(state, 1, Fixnum::from(0))));
TS_ASSERT_EQUALS(cm->stack_size(), Fixnum::from(10));
TS_ASSERT_EQUALS(cm->local_count(), Fixnum::from(0));
TS_ASSERT_EQUALS(cm->required_args(), Fixnum::from(0));
TS_ASSERT_EQUALS(cm->total_args(), Fixnum::from(0));
TS_ASSERT_EQUALS(cm->splat(), Qnil);
TS_ASSERT(tuple_equals(cm->literals(), Tuple::from(state, 2, Fixnum::from(1), Fixnum::from(2))));
TS_ASSERT(tuple_equals(cm->lines(), Tuple::from(state, 1,
Tuple::from(state, 3, Fixnum::from(0), Fixnum::from(1), Fixnum::from(1)))));
TS_ASSERT_EQUALS(cm->file(), state->symbol("not_real"));
TS_ASSERT(tuple_equals(cm->local_names(), Tuple::from(state, 1, state->symbol("blah"))));
}
示例2: get_cmethod
CompiledMethod* UnMarshaller::get_cmethod() {
size_t ver;
stream >> ver;
CompiledMethod* cm = CompiledMethod::create(state);
cm->ivars(state, unmarshal());
cm->primitive(state, (Symbol*)unmarshal());
cm->name(state, (Symbol*)unmarshal());
cm->iseq(state, (InstructionSequence*)unmarshal());
cm->stack_size(state, (Fixnum*)unmarshal());
cm->local_count(state, (Fixnum*)unmarshal());
cm->required_args(state, (Fixnum*)unmarshal());
cm->total_args(state, (Fixnum*)unmarshal());
cm->splat(state, unmarshal());
cm->literals(state, (Tuple*)unmarshal());
cm->exceptions(state, (Tuple*)unmarshal());
cm->lines(state, (Tuple*)unmarshal());
cm->file(state, (Symbol*)unmarshal());
cm->local_names(state, (Tuple*)unmarshal());
cm->post_marshal(state);
return cm;
}