Esempio n. 1
0
int MVM_repr_register_dynamic_repr(MVMThreadContext *tc, MVMREPROps *repr) {
    MVMReprRegistry *entry;
    MVMString *name;

    uv_mutex_lock(&tc->instance->mutex_repr_registry);

    name = MVM_string_ascii_decode_nt(tc, tc->instance->VMString, repr->name);
    MVM_string_flatten(tc, name);
    MVM_HASH_GET(tc, tc->instance->repr_hash, name, entry);
    if (entry) {
        uv_mutex_unlock(&tc->instance->mutex_repr_registry);
        return 0;
    }

    if (!(tc->instance->num_reprs < MVM_REPR_MAX_COUNT)) {
        uv_mutex_unlock(&tc->instance->mutex_repr_registry);
        MVM_exception_throw_adhoc(tc,
                "Cannot register more than %u representations",
                MVM_REPR_MAX_COUNT);
    }

    repr->ID = tc->instance->num_reprs++;
    register_repr(tc, repr, name);

    uv_mutex_unlock(&tc->instance->mutex_repr_registry);
    return 1;
}
Esempio n. 2
0
/* Initializes the representations registry, building up all of the various
 * representations. */
void REPR_initialize_registry(PARROT_INTERP) {
    PMC *dyn_reg_func;
    
    /* Allocate name to ID map, and anchor it with the GC. */
    repr_name_to_id_map = Parrot_pmc_new(interp, enum_class_Hash);
    Parrot_pmc_gc_register(interp, repr_name_to_id_map);

    /* Add all core representations. */
    register_repr(interp, Parrot_str_new_constant(interp, "KnowHOWREPR"), 
        KnowHOWREPR_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6opaque"), 
        P6opaque_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6int"), 
        P6int_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6num"), 
        P6num_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6str"), 
        P6str_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "HashAttrStore"), 
        HashAttrStore_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "Uninstantiable"),
        Uninstantiable_initialize(interp));

    /* Set up object for dynamically registering extra representations. */
    dyn_reg_func = Parrot_pmc_new(interp, enum_class_Pointer);
    VTABLE_set_pointer(interp, dyn_reg_func, REPR_register_dynamic);
    VTABLE_set_pmc_keyed_str(interp, interp->root_namespace,
        Parrot_str_new_constant(interp, "_REGISTER_REPR"), dyn_reg_func);
}
Esempio n. 3
0
/* Initializes the representations registry, building up all of the various
 * representations. */
void REPR_initialize_registry(PARROT_INTERP) {
    /* Allocate name to ID map, and anchor it with the GC. */
    repr_name_to_id_map = pmc_new(interp, enum_class_Hash);
    Parrot_pmc_gc_register(interp, repr_name_to_id_map);

    /* Add all representations. */
    register_repr(interp, Parrot_str_new_constant(interp, "KnowHOWREPR"), 
        KnowHOWREPR_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6opaque"), 
        P6opaque_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6int"), 
        P6int_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6num"), 
        P6num_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "P6str"), 
        P6str_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "HashAttrStore"), 
        HashAttrStore_initialize(interp));
    register_repr(interp, Parrot_str_new_constant(interp, "Uninstantiable"),
        Uninstantiable_initialize(interp));
}
Esempio n. 4
0
/* Dynamically registers a representation (that is, one defined outside of
 * the 6model core). */
static INTVAL REPR_register_dynamic(PARROT_INTERP, STRING *name, REPROps * (*reg) (PARROT_INTERP, void *, void *)) {
    REPROps *repr = reg(interp, wrap_object, create_stable);
    register_repr(interp, name, repr);
    return repr->ID;
}
Esempio n. 5
0
/* Initializes the representations registry, building up all of the various
 * representations. */
void MVM_repr_initialize_registry(MVMThreadContext *tc) {    
    /* Add all core representations. (If order changed, update reprs.h IDs.) */
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "MVMString"),
        MVMString_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "VMArray"),
        MVMArray_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "VMHash"),
        MVMHash_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "MVMCFunction"),
        MVMCFunction_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "KnowHOWREPR"),
        MVMKnowHOWREPR_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "P6opaque"),
        MVMP6opaque_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "MVMCode"),
        MVMCode_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "MVMOSHandle"),
        MVMOSHandle_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "P6int"),
        P6int_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "P6num"),
        P6num_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "Uninstantiable"),
        Uninstantiable_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "HashAttrStore"),
        HashAttrStore_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "KnowHOWAttributeREPR"),
        MVMKnowHOWAttributeREPR_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "P6str"),
        P6str_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "MVMThread"),
        MVMThread_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "VMIter"),
        MVMIter_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "MVMContext"),
        MVMContext_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "SCRef"),
        MVMSCRef_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "Lexotic"),
        MVMLexotic_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "MVMCallCapture"),
        MVMCallCapture_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "P6bigint"),
        P6bigint_initialize(tc));
    register_repr(tc,
        MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "NFA"),
        MVMNFA_initialize(tc));
}