本文整理汇总了C++中STABLE函数的典型用法代码示例。如果您正苦于以下问题:C++ STABLE函数的具体用法?C++ STABLE怎么用?C++ STABLE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STABLE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MVM_6model_can_method
void MVM_6model_can_method(MVMThreadContext *tc, MVMObject *obj, MVMString *name, MVMRegister *res) {
MVMObject *HOW, *find_method, *code;
MVMCallsite *findmeth_callsite;
MVMint64 can_cached = MVM_6model_can_method_cache_only(tc, obj, name);
if (can_cached == 0 || can_cached == 1) {
res->i64 = can_cached;
return;
}
/* If no method in cache and the cache is not authoritative, need to make
* a late-bound call to find_method. */
HOW = MVM_6model_get_how(tc, STABLE(obj));
find_method = MVM_6model_find_method_cache_only(tc, HOW,
tc->instance->str_consts.find_method);
if (MVM_is_null(tc, find_method)) {
/* This'll count as a "no"... */
res->i64 = 0;
return;
}
/* Set up the call, using the result register as the target. A little bad
* as we're really talking about */
code = MVM_frame_find_invokee(tc, find_method, NULL);
findmeth_callsite = MVM_callsite_get_common(tc, MVM_CALLSITE_ID_FIND_METHOD);
MVM_args_setup_thunk(tc, res, MVM_RETURN_OBJ, findmeth_callsite);
tc->cur_frame->special_return = late_bound_can_return;
tc->cur_frame->special_return_data = res;
tc->cur_frame->args[0].o = HOW;
tc->cur_frame->args[1].o = obj;
tc->cur_frame->args[2].s = name;
STABLE(code)->invoke(tc, code, findmeth_callsite, tc->cur_frame->args);
}
示例2: new_type
/* Creates a new type with this HOW as its meta-object. */
static void new_type(PARROT_INTERP, PMC *nci) {
PMC * unused;
/* We first create a new HOW instance. */
PMC *capture = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC *self = VTABLE_get_pmc_keyed_int(interp, capture, 0);
PMC *HOW = REPR(self)->allocate(interp, STABLE(self));
/* See if we have a representation name; if not default to P6opaque. */
STRING *repr_name = VTABLE_exists_keyed_str(interp, capture, repr_str) ?
VTABLE_get_string_keyed_str(interp, capture, repr_str) :
p6opaque_str;
/* Create a new type object of the desired REPR. (Note that we can't
* default to KnowHOWREPR here, since it doesn't know how to actually
* store attributes, it's just for bootstrapping knowhow's. */
REPROps *repr_to_use = REPR_get_by_name(interp, repr_name);
PMC *type_object = repr_to_use->type_object_for(interp, HOW);
/* See if we were given a name; put it into the meta-object if so. */
STRING *name = VTABLE_exists_keyed_str(interp, capture, name_str) ?
VTABLE_get_string_keyed_str(interp, capture, name_str) :
empty_str;
REPR(HOW)->initialize(interp, STABLE(HOW), OBJECT_BODY(HOW));
((KnowHOWREPRInstance *)PMC_data(HOW))->body.name = name;
PARROT_GC_WRITE_BARRIER(interp, HOW);
/* Set .WHO to an empty hash. */
STABLE(type_object)->WHO = Parrot_pmc_new(interp, enum_class_Hash);
PARROT_GC_WRITE_BARRIER(interp, STABLE_PMC(type_object));
/* Put it into capture to act as return value. */
unused = Parrot_pcc_build_call_from_c_args(interp, capture, "P", type_object);
}
示例3: bind_attribute_boxed
/* Binds the given value to the specified attribute. */
static void bind_attribute_boxed(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) {
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)st->REPR_data;
INTVAL slot;
/* Try the slot allocation first. */
slot = hint >= 0 && !(repr_data->mi) ? hint :
try_get_slot(interp, repr_data, class_handle, name);
if (slot >= 0) {
STable *st = repr_data->flattened_stables[slot];
if (st) {
if (value->vtable->base_type == smo_id && st == STABLE(value))
st->REPR->copy_to(interp, st, OBJECT_BODY(value),
(char *)data + repr_data->attribute_offsets[slot]);
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Type mismatch when storing value to attribute '%Ss' on class '%Ss'",
name, VTABLE_get_string(interp, introspection_call(interp,
class_handle, STABLE(class_handle)->HOW,
Parrot_str_new_constant(interp, "name"), 0)));
}
else {
set_pmc_at_offset(data, repr_data->attribute_offsets[slot], value);
}
}
else {
/* Otherwise, complain that the attribute doesn't exist. */
no_such_attribute(interp, "bind", class_handle, name);
}
}
示例4: MVM_repr_alloc_init
MVMObject * MVM_repr_alloc_init(MVMThreadContext *tc, MVMObject *type) {
MVMObject *obj = REPR(type)->allocate(tc, STABLE(type));
if (REPR(obj)->initialize) {
MVMROOT(tc, obj, {
REPR(obj)->initialize(tc, STABLE(obj), obj, OBJECT_BODY(obj));
});
示例5: code_pair_store_internal
static void code_pair_store_internal(MVMThreadContext *tc, MVMObject *cont, MVMRegister value, MVMCallsite *cs) {
CodePairContData *data = (CodePairContData *)STABLE(cont)->container_data;
MVMObject *code = MVM_frame_find_invokee(tc, data->store_code, NULL);
MVM_args_setup_thunk(tc, NULL, MVM_RETURN_VOID, cs);
tc->cur_frame->args[0].o = cont;
tc->cur_frame->args[1] = value;
STABLE(code)->invoke(tc, code, cs, tc->cur_frame->args);
}
示例6: code_pair_fetch_internal
static void code_pair_fetch_internal(MVMThreadContext *tc, MVMObject *cont, MVMRegister *res, MVMReturnType res_type) {
CodePairContData *data = (CodePairContData *)STABLE(cont)->container_data;
MVMObject *code = MVM_frame_find_invokee(tc, data->fetch_code, NULL);
MVMCallsite *inv_arg_callsite = MVM_callsite_get_common(tc, MVM_CALLSITE_ID_INV_ARG);
MVM_args_setup_thunk(tc, res, res_type, inv_arg_callsite);
tc->cur_frame->args[0].o = cont;
STABLE(code)->invoke(tc, code, inv_arg_callsite, tc->cur_frame->args);
}
示例7: rakudo_scalar_store
static void rakudo_scalar_store(MVMThreadContext *tc, MVMObject *cont, MVMObject *value) {
RakudoContData *data = (RakudoContData *)STABLE(cont)->container_data;
MVMObject *code = MVM_frame_find_invokee(tc, data->store, NULL);
MVMCallsite *cs = MVM_callsite_get_common(tc, MVM_CALLSITE_ID_TWO_OBJ);
MVM_args_setup_thunk(tc, NULL, MVM_RETURN_VOID, cs);
tc->cur_frame->args[0].o = cont;
tc->cur_frame->args[1].o = value;
STABLE(code)->invoke(tc, code, cs, tc->cur_frame->args);
}
示例8: attr_new
/* Attribute new method. */
static void attr_new(PARROT_INTERP, PMC *nci) {
PMC * unused;
PMC *capture = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
PMC *type = VTABLE_get_pmc_keyed_int(interp, capture, 0);
STRING *name = VTABLE_get_string_keyed_str(interp, capture, name_str);
PMC *self = REPR(type)->allocate(interp, STABLE(type));
REPR(self)->box_funcs->set_str(interp, STABLE(self), OBJECT_BODY(self), name);
unused = Parrot_pcc_build_call_from_c_args(interp, capture, "P", self);
}
示例9: code_pair_fetch
static void code_pair_fetch(MVMThreadContext *tc, MVMObject *cont, MVMRegister *res) {
CodePairContData *data = (CodePairContData *)STABLE(cont)->container_data;
MVMObject *code = MVM_frame_find_invokee(tc, data->fetch_code, NULL);
MVM_args_setup_thunk(tc, res, MVM_RETURN_OBJ, &fetch_arg_callsite);
tc->cur_frame->args[0].o = cont;
STABLE(code)->invoke(tc, code, &fetch_arg_callsite, tc->cur_frame->args);
}
示例10: try_find_spesh_candidate
/* Determines if there's a matching spesh candidate for a callee and a given
* set of argument info. */
static MVMint32 try_find_spesh_candidate(MVMThreadContext *tc, MVMCode *code, MVMSpeshCallInfo *arg_info) {
MVMStaticFrameBody *sfb = &(code->body.sf->body);
MVMint32 num_spesh = sfb->num_spesh_candidates;
MVMint32 i, j;
for (i = 0; i < num_spesh; i++) {
MVMSpeshCandidate *cand = &sfb->spesh_candidates[i];
if (cand->cs == arg_info->cs) {
/* Matching callsite, now see if we have enough information to
* test the guards. */
MVMint32 guard_failed = 0;
for (j = 0; j < cand->num_guards; j++) {
MVMint32 slot = cand->guards[j].slot;
MVMSpeshFacts *facts = slot < MAX_ARGS_FOR_OPT ? arg_info->arg_facts[slot] : NULL;
MVMSTable *want_st = (MVMSTable *)cand->guards[j].match;
if (!facts) {
guard_failed = 1;
break;
}
switch (cand->guards[j].kind) {
case MVM_SPESH_GUARD_CONC:
if (!(facts->flags & MVM_SPESH_FACT_CONCRETE) ||
!(facts->flags & MVM_SPESH_FACT_KNOWN_TYPE) ||
STABLE(facts->type) != want_st)
guard_failed = 1;
break;
case MVM_SPESH_GUARD_TYPE:
if (!(facts->flags & MVM_SPESH_FACT_TYPEOBJ) ||
!(facts->flags & MVM_SPESH_FACT_KNOWN_TYPE) ||
STABLE(facts->type) != want_st)
guard_failed = 1;
break;
case MVM_SPESH_GUARD_DC_CONC:
if (!(facts->flags & MVM_SPESH_FACT_DECONT_CONCRETE) ||
!(facts->flags & MVM_SPESH_FACT_KNOWN_DECONT_TYPE) ||
STABLE(facts->decont_type) != want_st)
guard_failed = 1;
break;
case MVM_SPESH_GUARD_DC_TYPE:
if (!(facts->flags & MVM_SPESH_FACT_DECONT_TYPEOBJ) ||
!(facts->flags & MVM_SPESH_FACT_KNOWN_DECONT_TYPE) ||
STABLE(facts->decont_type) != want_st)
guard_failed = 1;
break;
default:
guard_failed = 1;
break;
}
if (guard_failed)
break;
}
if (!guard_failed)
return i;
}
}
return -1;
}
示例11: SixModelObject_setup_knowhow_attribute
/* Sets up a very simple attribute meta-object. Just supports having a
* name, and even uses the P6str representation to store it, so that's
* really all that it supports. */
PMC * SixModelObject_setup_knowhow_attribute(PARROT_INTERP, PMC *sc, PMC *knowhow) {
PMC *old_ctx, *cappy, *meth, *knowhow_attr, *how;
/* Create a new KnowHOWAttribute type using P6str repr.. */
meth = STABLE(knowhow)->find_method(interp, knowhow,
Parrot_str_new_constant(interp, "new_type"), NO_HINT);
old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
cappy = Parrot_pmc_new(interp, enum_class_CallContext);
VTABLE_push_pmc(interp, cappy, knowhow);
VTABLE_set_string_keyed_str(interp, cappy, name_str,
Parrot_str_new_constant(interp, "KnowHOWAttribute"));
VTABLE_set_string_keyed_str(interp, cappy, repr_str,
Parrot_str_new_constant(interp, "P6str"));
Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
cappy = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
knowhow_attr = VTABLE_get_pmc_keyed_int(interp, cappy, 0);
how = STABLE(knowhow_attr)->HOW;
/* Add new method. */
meth = STABLE(how)->find_method(interp, how,
Parrot_str_new_constant(interp, "add_method"), NO_HINT);
cappy = Parrot_pmc_new(interp, enum_class_CallContext);
VTABLE_push_pmc(interp, cappy, how);
VTABLE_push_pmc(interp, cappy, knowhow_attr);
VTABLE_push_string(interp, cappy, Parrot_str_new_constant(interp, "new"));
VTABLE_push_pmc(interp, cappy, wrap_c(interp, F2DPTR(attr_new)));
Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
/* Add name method. */
cappy = Parrot_pmc_new(interp, enum_class_CallContext);
VTABLE_push_pmc(interp, cappy, how);
VTABLE_push_pmc(interp, cappy, knowhow_attr);
VTABLE_push_string(interp, cappy, name_str);
VTABLE_push_pmc(interp, cappy, wrap_c(interp, F2DPTR(attr_name)));
Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
/* Compose. */
meth = STABLE(knowhow)->find_method(interp, how,
Parrot_str_new_constant(interp, "compose"), NO_HINT);
cappy = Parrot_pmc_new(interp, enum_class_CallContext);
VTABLE_push_pmc(interp, cappy, how);
VTABLE_push_pmc(interp, cappy, knowhow_attr);
Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
/* Associate the created object with the intial core serialization
* context. */
VTABLE_set_pmc_keyed_int(interp, sc, 2, knowhow_attr);
SC_PMC(knowhow_attr) = sc;
STABLE(knowhow_attr)->sc = sc;
return knowhow_attr;
}
示例12: code_pair_store
static void code_pair_store(MVMThreadContext *tc, MVMObject *cont, MVMObject *obj) {
CodePairContData *data = (CodePairContData *)STABLE(cont)->container_data;
MVMObject *code = MVM_frame_find_invokee(tc, data->store_code, NULL);
MVM_args_setup_thunk(tc, NULL, MVM_RETURN_VOID, &store_arg_callsite);
tc->cur_frame->args[0].o = cont;
tc->cur_frame->args[1].o = obj;
STABLE(code)->invoke(tc, code, &store_arg_callsite, tc->cur_frame->args);
}
示例13: MVM_gc_mark_collectable
/* Marks a collectable item (object, type object, STable). */
void MVM_gc_mark_collectable(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMCollectable *new_addr) {
MVMuint16 i;
MVM_gc_worklist_add(tc, worklist, &new_addr->sc);
if (!(new_addr->flags & (MVM_CF_TYPE_OBJECT | MVM_CF_STABLE))) {
/* Need to view it as an object in here. */
MVMObject *new_addr_obj = (MVMObject *)new_addr;
/* Add the STable to the worklist. */
MVM_gc_worklist_add(tc, worklist, &new_addr_obj->st);
/* If needed, mark it. This will add addresses to the worklist
* that will need updating. Note that we are passing the address
* of the object *after* copying it since those are the addresses
* we care about updating; the old chunk of memory is now dead! */
if (MVM_GC_DEBUG_ENABLED(MVM_GC_DEBUG_COLLECT) && !STABLE(new_addr_obj))
MVM_panic(MVM_exitcode_gcnursery, "Found an outdated reference to address %p", new_addr);
if (REPR(new_addr_obj)->gc_mark)
REPR(new_addr_obj)->gc_mark(tc, STABLE(new_addr_obj), OBJECT_BODY(new_addr_obj), worklist);
}
else if (new_addr->flags & MVM_CF_TYPE_OBJECT) {
/* Add the STable to the worklist. */
MVM_gc_worklist_add(tc, worklist, &((MVMObject *)new_addr)->st);
}
else if (new_addr->flags & MVM_CF_STABLE) {
/* Add all references in the STable to the work list. */
MVMSTable *new_addr_st = (MVMSTable *)new_addr;
MVM_gc_worklist_add(tc, worklist, &new_addr_st->HOW);
MVM_gc_worklist_add(tc, worklist, &new_addr_st->WHAT);
MVM_gc_worklist_add(tc, worklist, &new_addr_st->method_cache);
for (i = 0; i < new_addr_st->vtable_length; i++)
MVM_gc_worklist_add(tc, worklist, &new_addr_st->vtable[i]);
for (i = 0; i < new_addr_st->type_check_cache_length; i++)
MVM_gc_worklist_add(tc, worklist, &new_addr_st->type_check_cache[i]);
if (new_addr_st->container_spec)
if (new_addr_st->container_spec->gc_mark_data)
new_addr_st->container_spec->gc_mark_data(tc, new_addr_st, worklist);
if (new_addr_st->boolification_spec)
MVM_gc_worklist_add(tc, worklist, &new_addr_st->boolification_spec->method);
if (new_addr_st->invocation_spec) {
MVM_gc_worklist_add(tc, worklist, &new_addr_st->invocation_spec->class_handle);
MVM_gc_worklist_add(tc, worklist, &new_addr_st->invocation_spec->attr_name);
MVM_gc_worklist_add(tc, worklist, &new_addr_st->invocation_spec->invocation_handler);
}
MVM_gc_worklist_add(tc, worklist, &new_addr_st->WHO);
/* If it needs to have its REPR data marked, do that. */
if (new_addr_st->REPR->gc_mark_repr_data)
new_addr_st->REPR->gc_mark_repr_data(tc, new_addr_st, worklist);
}
else {
MVM_panic(MVM_exitcode_gcnursery, "Internal error: impossible case encountered in GC marking");
}
}
示例14: code_pair_fetch
static void code_pair_fetch(MVMThreadContext *tc, MVMObject *cont, MVMRegister *res) {
CodePairContData *data = (CodePairContData *)STABLE(cont)->container_data;
MVMObject *code = MVM_frame_find_invokee(tc, data->fetch_code);
tc->cur_frame->return_value = res;
tc->cur_frame->return_type = MVM_RETURN_OBJ;
tc->cur_frame->return_address = *(tc->interp_cur_op);
tc->cur_frame->args[0].o = cont;
STABLE(code)->invoke(tc, code, &fetch_arg_callsite, tc->cur_frame->args);
}
示例15: bootstrap_KnowHOW
/* Bootstraps the KnowHOW type. */
static void bootstrap_KnowHOW(MVMThreadContext *tc) {
MVMObject *VMString = tc->instance->VMString;
MVMObject *BOOTArray = tc->instance->boot_types->BOOTArray;
MVMObject *BOOTHash = tc->instance->boot_types->BOOTHash;
/* Create our KnowHOW type object. Note we don't have a HOW just yet, so
* pass in NULL. */
MVMREPROps *REPR = MVM_repr_get_by_id(tc, MVM_REPR_ID_KnowHOWREPR);
MVMObject *knowhow = REPR->type_object_for(tc, NULL);
/* We create a KnowHOW instance that can describe itself. This means
* (once we tie the knot) that .HOW.HOW.HOW.HOW etc will always return
* that, which closes the model up. Note that the STable for it must
* be allocated first, since that holds the allocation size. */
MVMKnowHOWREPR *knowhow_how;
MVMSTable *st = MVM_gc_allocate_stable(tc, REPR, NULL);
st->WHAT = (MVMObject *)knowhow;
st->size = sizeof(MVMKnowHOWREPR);
knowhow_how = (MVMKnowHOWREPR *)REPR->allocate(tc, st);
st->HOW = (MVMObject *)knowhow_how;
knowhow_how->common.st = st;
/* Add various methods to the KnowHOW's HOW. */
REPR->initialize(tc, NULL, (MVMObject *)knowhow_how, &knowhow_how->body);
add_knowhow_how_method(tc, knowhow_how, "new_type", new_type);
add_knowhow_how_method(tc, knowhow_how, "add_method", add_method);
add_knowhow_how_method(tc, knowhow_how, "add_attribute", add_attribute);
add_knowhow_how_method(tc, knowhow_how, "compose", compose);
add_knowhow_how_method(tc, knowhow_how, "attributes", attributes);
add_knowhow_how_method(tc, knowhow_how, "methods", methods);
add_knowhow_how_method(tc, knowhow_how, "name", name);
/* Set name KnowHOW for the KnowHOW's HOW. */
knowhow_how->body.name = MVM_string_ascii_decode_nt(tc, VMString, "KnowHOW");
/* Set this built up HOW as the KnowHOW's HOW. */
STABLE(knowhow)->HOW = (MVMObject *)knowhow_how;
/* Give it an authoritative method cache; this in turn will make the
* method dispatch bottom out. */
STABLE(knowhow)->method_cache = knowhow_how->body.methods;
STABLE(knowhow)->mode_flags = MVM_METHOD_CACHE_AUTHORITATIVE;
STABLE(knowhow_how)->method_cache = knowhow_how->body.methods;
STABLE(knowhow_how)->mode_flags = MVM_METHOD_CACHE_AUTHORITATIVE;
/* Associate the created objects with the initial core serialization
* context. */
/* XXX TODO */
/* Stash the created KnowHOW. */
tc->instance->KnowHOW = (MVMObject *)knowhow;
MVM_gc_root_add_permanent(tc, (MVMCollectable **)&tc->instance->KnowHOW);
}