/* can't really use xsubpp here... */ extern XS(blizkost_callable_trampoline) { #ifdef dVAR dVAR; #endif dXSARGS; PMC *callable; blizkost_nexus *nexus; int i; PMC *args, *posret, *namret; blizkost_get_bound_pmc(my_perl, &nexus, (SV *)cv, &callable); if (nexus->dying) exit_fatal(1, "Attempted reentry of Parrot code during global destruction"); PERL_UNUSED_VAR(ax); SP -= items; PUTBACK; args = Parrot_pmc_new_init_int(nexus->parrot_interp, enum_class_ResizablePMCArray, items); for (i = 0; i < items; i++) { SV *svarg = ST(i); PMC *pmcarg = blizkost_wrap_sv(nexus, svarg); VTABLE_set_pmc_keyed_int(nexus->parrot_interp, args, i, pmcarg); } Parrot_pcc_invoke_sub_from_c_args(nexus->parrot_interp, callable, "Pf->PsPsn", args, &posret, &namret); blizkost_slurpy_to_stack(nexus, posret, namret); SPAGAIN; }
PARROT_INLINE PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT static PMC * get_pmc_proxy(PARROT_INTERP, INTVAL type) { ASSERT_ARGS(get_pmc_proxy) PMC * type_class; /* Check if not a PMC or invalid type number */ if (type > interp->n_vtable_max || type <= 0) return PMCNULL; type_class = interp->vtables[type]->pmc_class; if (type != enum_class_Class && type_class->vtable->base_type == enum_class_Class) { return type_class; } else { PMC * const parrot_hll = Parrot_ns_get_namespace_keyed_str(interp, interp->root_namespace, CONST_STRING(interp, "parrot")); PMC * const pmc_ns = Parrot_ns_make_namespace_keyed_str(interp, parrot_hll, interp->vtables[type]->whoami); PMC * proxy = VTABLE_get_class(interp, pmc_ns); /* Create proxy if not found */ if (PMC_IS_NULL(proxy)) { proxy = Parrot_pmc_new_init_int(interp, enum_class_PMCProxy, type); Parrot_pcc_invoke_method_from_c_args(interp, pmc_ns, CONST_STRING(interp, "set_class"), "P->", proxy); } return proxy; } }
void Parrot_nci_load_core_thunks(PARROT_INTERP) { PMC * const iglobals = interp->iglobals; PMC *nci_funcs; PMC *temp_pmc; PARROT_ASSERT(!(PMC_IS_NULL(iglobals))); nci_funcs = VTABLE_get_pmc_keyed_int(interp, iglobals, IGLOBALS_NCI_FUNCS); PARROT_ASSERT(!(PMC_IS_NULL(nci_funcs))); { const int n = 1; static const int sig[] = { 5, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_char); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 5, 6, 5, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_char_short_char); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 16, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_double); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 16, 16, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_double_double); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 15, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_float); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 15, 15, 15, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_float_float_float); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 7, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_int); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 4; static const int sig[] = { 7, 7, 7, 7, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_int_int_int_int); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 7, 30, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_int_ptr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 7, 30, 30, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_int_ptr_ptr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 7, 6, 5, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_int_short_char); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 7, 31, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_int_cstr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 8, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_long); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 30, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_ptr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 30, 7, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_ptr_int); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 30, 7, 7, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_ptr_int_int); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 5; static const int sig[] = { 30, 7, 7, 7, 7, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_ptr_int_int_int_int); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 30, 7, 30, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_ptr_int_ptr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 30, 30, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_ptr_ptr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 30, 30, 3, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_ptr_ptr_STRING); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 6, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_short); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 6, 6, 5, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_short_short_char); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 31, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_cstr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 31, 31, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_cstr_cstr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 31, 31, 31, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_cstr_cstr_cstr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 1; static const int sig[] = { 29, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_void); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 4; static const int sig[] = { 29, 15, 15, 15, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_void_float_float_float); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 29, 30, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_void_ptr); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 2; static const int sig[] = { 29, 4, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_void_PMC); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 4; static const int sig[] = { 29, 30, 7, 7, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_void_ptr_int_int); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } { const int n = 3; static const int sig[] = { 29, 30, 4, }; PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, n); int i; for (i = 0; i < n; i++) VTABLE_set_integer_keyed_int(interp, sig_pmc, i, sig[i]); temp_pmc = Parrot_pmc_new(interp, enum_class_UnManagedStruct); VTABLE_set_pointer(interp, temp_pmc, (void *)pcf_void_ptr_PMC); VTABLE_set_pmc_keyed(interp, nci_funcs, sig_pmc, temp_pmc); } }
add_compreg)> Get an IMCC compiler PMC. Register it under its preferred name if C<add_compreg> is 1. =cut */ PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT static PMC * get_compreg_pmc(PARROT_INTERP, int is_pasm, int add_compreg) { ASSERT_ARGS(get_compreg_pmc) PMC * const comp = Parrot_pmc_new_init_int(interp, enum_class_IMCCompiler, is_pasm); if (add_compreg) { STRING * const name = VTABLE_get_string(interp, comp); Parrot_interp_set_compiler(interp, name, comp); } return comp; } /* =item C<Parrot_Int imcc_compile_file_api(Parrot_PMC interp_pmc, Parrot_PMC compiler, Parrot_String file, Parrot_PMC *pbc)> Compile a file using the given IMCCompiler PMC. =cut
=cut */ PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT static PMC* new_hll_entry(PARROT_INTERP, ARGIN(STRING *entry_name)) { ASSERT_ARGS(new_hll_entry) PMC * const hll_info = interp->HLL_info; const INTVAL id = VTABLE_elements(interp, hll_info); PMC *entry_id; PMC * const entry = Parrot_pmc_new_init_int(interp, enum_class_FixedPMCArray, e_HLL_MAX); if (entry_name && !STRING_IS_EMPTY(entry_name)) { VTABLE_set_pmc_keyed_str(interp, hll_info, entry_name, entry); } else VTABLE_push_pmc(interp, hll_info, entry); entry_id = Parrot_pmc_new_init_int(interp, enum_class_Integer, id); VTABLE_set_pmc_keyed_int(interp, entry, e_HLL_id, entry_id); VTABLE_push_pmc(interp, interp->HLL_entries, entry); return entry; }
/* Locates all of the attributes. Puts them onto a flattened, ordered * list of attributes (populating the passed flat_list). Also builds * the index mapping for doing named lookups. Note index is not related * to the storage position. */ static PMC * index_mapping_and_flat_list(PARROT_INTERP, PMC *WHAT, P6opaqueREPRData *repr_data) { PMC *flat_list = Parrot_pmc_new(interp, enum_class_ResizablePMCArray); PMC *class_list = Parrot_pmc_new(interp, enum_class_ResizablePMCArray); PMC *attr_map_list = Parrot_pmc_new(interp, enum_class_ResizablePMCArray); STRING *attributes_str = Parrot_str_new_constant(interp, "attributes"); STRING *parents_str = Parrot_str_new_constant(interp, "parents"); STRING *name_str = Parrot_str_new_constant(interp, "name"); STRING *mro_str = Parrot_str_new_constant(interp, "mro"); INTVAL current_slot = 0; INTVAL num_classes, i; P6opaqueNameMap * result = NULL; /* Get the MRO. */ PMC *mro = introspection_call(interp, WHAT, STABLE(WHAT)->HOW, mro_str, 0); INTVAL mro_idx = VTABLE_elements(interp, mro); /* Walk through the parents list. */ while (mro_idx) { /* Get current class in MRO. */ PMC *current_class = decontainerize(interp, VTABLE_get_pmc_keyed_int(interp, mro, --mro_idx)); PMC *HOW = STABLE(current_class)->HOW; /* Get its local parents. */ PMC *parents = introspection_call(interp, current_class, HOW, parents_str, 1); INTVAL num_parents = VTABLE_elements(interp, parents); /* Get attributes and iterate over them. */ PMC *attributes = introspection_call(interp, current_class, HOW, attributes_str, 1); PMC *attr_map = PMCNULL; PMC *attr_iter = VTABLE_get_iter(interp, attributes); while (VTABLE_get_bool(interp, attr_iter)) { /* Get attribute. */ PMC * attr = VTABLE_shift_pmc(interp, attr_iter); /* Get its name. */ PMC *name_pmc = accessor_call(interp, attr, name_str); STRING *name = VTABLE_get_string(interp, name_pmc); /* Allocate a slot. */ if (PMC_IS_NULL(attr_map)) attr_map = Parrot_pmc_new(interp, enum_class_Hash); VTABLE_set_pmc_keyed_str(interp, attr_map, name, Parrot_pmc_new_init_int(interp, enum_class_Integer, current_slot)); current_slot++; /* Push attr onto the flat list. */ VTABLE_push_pmc(interp, flat_list, attr); } /* Add to class list and map list. */ VTABLE_push_pmc(interp, class_list, current_class); VTABLE_push_pmc(interp, attr_map_list, attr_map); /* If there's more than one parent, flag that we in an MI * situation. */ if (num_parents > 1) repr_data->mi = 1; } /* We can now form the name map. */ num_classes = VTABLE_elements(interp, class_list); result = (P6opaqueNameMap *) mem_sys_allocate_zeroed(sizeof(P6opaqueNameMap) * (1 + num_classes)); for (i = 0; i < num_classes; i++) { result[i].class_key = VTABLE_get_pmc_keyed_int(interp, class_list, i); result[i].name_map = VTABLE_get_pmc_keyed_int(interp, attr_map_list, i); } repr_data->name_to_index_mapping = result; return flat_list; }
/* Locates all of the attributes. Puts them onto a flattened, ordered * list of attributes (populating the passed flat_list). Also builds * the index mapping for doing named lookups. Note index is not related * to the storage position. */ static PMC * index_mapping_and_flat_list(PARROT_INTERP, PMC *mro, CStructREPRData *repr_data) { PMC *flat_list = Parrot_pmc_new(interp, enum_class_ResizablePMCArray); PMC *class_list = Parrot_pmc_new(interp, enum_class_ResizablePMCArray); PMC *attr_map_list = Parrot_pmc_new(interp, enum_class_ResizablePMCArray); STRING *name_str = Parrot_str_new_constant(interp, "name"); INTVAL current_slot = 0; INTVAL num_classes, i; CStructNameMap * result = NULL; /* Walk through the parents list. */ INTVAL mro_idx = VTABLE_elements(interp, mro); while (mro_idx) { /* Get current class in MRO. */ PMC *type_info = VTABLE_get_pmc_keyed_int(interp, mro, --mro_idx); PMC *current_class = decontainerize(interp, VTABLE_get_pmc_keyed_int(interp, type_info, 0)); /* Get its local parents; make sure we're not doing MI. */ PMC *parents = VTABLE_get_pmc_keyed_int(interp, type_info, 2); INTVAL num_parents = VTABLE_elements(interp, parents); if (num_parents <= 1) { /* Get attributes and iterate over them. */ PMC *attributes = VTABLE_get_pmc_keyed_int(interp, type_info, 1); PMC *attr_map = PMCNULL; PMC *attr_iter = VTABLE_get_iter(interp, attributes); while (VTABLE_get_bool(interp, attr_iter)) { /* Get attribute. */ PMC * attr = VTABLE_shift_pmc(interp, attr_iter); /* Get its name. */ PMC *name_pmc = VTABLE_get_pmc_keyed_str(interp, attr, name_str); STRING *name = VTABLE_get_string(interp, name_pmc); /* Allocate a slot. */ if (PMC_IS_NULL(attr_map)) attr_map = Parrot_pmc_new(interp, enum_class_Hash); VTABLE_set_pmc_keyed_str(interp, attr_map, name, Parrot_pmc_new_init_int(interp, enum_class_Integer, current_slot)); current_slot++; /* Push attr onto the flat list. */ VTABLE_push_pmc(interp, flat_list, attr); } /* Add to class list and map list. */ VTABLE_push_pmc(interp, class_list, current_class); VTABLE_push_pmc(interp, attr_map_list, attr_map); } else { Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, "CStruct representation does not support multiple inheritance"); } } /* We can now form the name map. */ num_classes = VTABLE_elements(interp, class_list); result = (CStructNameMap *) mem_sys_allocate_zeroed(sizeof(CStructNameMap) * (1 + num_classes)); for (i = 0; i < num_classes; i++) { result[i].class_key = VTABLE_get_pmc_keyed_int(interp, class_list, i); result[i].name_map = VTABLE_get_pmc_keyed_int(interp, attr_map_list, i); } repr_data->name_to_index_mapping = result; return flat_list; }
void parrot_init_library_paths(PARROT_INTERP) { ASSERT_ARGS(parrot_init_library_paths) PMC *paths; STRING *entry; STRING *versionlib = NULL; STRING *builddir = NULL; PMC * const iglobals = interp->iglobals; PMC * const config_hash = VTABLE_get_pmc_keyed_int(interp, iglobals, (INTVAL)IGLOBALS_CONFIG_HASH); /* create the lib_paths array */ PMC * const lib_paths = Parrot_pmc_new_init_int(interp, enum_class_FixedPMCArray, PARROT_LIB_PATH_SIZE); VTABLE_set_pmc_keyed_int(interp, iglobals, IGLOBALS_LIB_PATHS, lib_paths); if (VTABLE_elements(interp, config_hash)) { STRING * const libkey = CONST_STRING(interp, "libdir"); STRING * const verkey = CONST_STRING(interp, "versiondir"); STRING * const builddirkey = CONST_STRING(interp, "build_dir"); STRING * const installed = CONST_STRING(interp, "installed"); versionlib = VTABLE_get_string_keyed_str(interp, config_hash, libkey); entry = VTABLE_get_string_keyed_str(interp, config_hash, verkey); versionlib = Parrot_str_concat(interp, versionlib, entry); if (!VTABLE_get_integer_keyed_str(interp, config_hash, installed)) builddir = VTABLE_get_string_keyed_str(interp, config_hash, builddirkey); } /* each is an array of strings */ /* define include paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_INCLUDE, paths); { /* EXPERIMENTAL: add include path from environment */ const char *envvar = Parrot_getenv(interp, Parrot_str_new_constant(interp, "PARROT_INCLUDE")); if (envvar != NULL && envvar[0]) { entry = Parrot_str_new(interp, envvar, 0); VTABLE_push_string(interp, paths, entry); } } if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/")); VTABLE_push_string(interp, paths, entry); entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/include/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/include/")); VTABLE_push_string(interp, paths, entry); } /* define library paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LIBRARY, paths); { /* EXPERIMENTAL: add library path from environment */ const char *envvar = Parrot_getenv(interp, Parrot_str_new_constant(interp, "PARROT_LIBRARY")); if (envvar != NULL && envvar[0]) { entry = Parrot_str_new(interp, envvar, 0); VTABLE_push_string(interp, paths, entry); } } if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/library/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/library/")); VTABLE_push_string(interp, paths, entry); } /* define languages paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LANG, paths); if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/languages/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/languages/")); VTABLE_push_string(interp, paths, entry); } /* define dynext paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_DYNEXT, paths); if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/dynext/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "dynext/"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/dynext/")); VTABLE_push_string(interp, paths, entry); } /* shared exts */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_DYN_EXTS, paths); /* no CONST_STRING here - the c2str.pl preprocessor needs "real strs" */ entry = Parrot_str_new_constant(interp, PARROT_LOAD_EXT); VTABLE_push_string(interp, paths, entry); /* OS/X has .dylib and .bundle */ if (!STREQ(PARROT_LOAD_EXT, PARROT_SHARE_EXT)) { entry = Parrot_str_new_constant(interp, PARROT_SHARE_EXT); VTABLE_push_string(interp, paths, entry); } #ifdef PARROT_PLATFORM_LIB_PATH_INIT_HOOK PARROT_PLATFORM_LIB_PATH_INIT_HOOK(interp, lib_paths); #endif }
PARROT_EXPORT PARROT_CANNOT_RETURN_NULL PMC * Parrot_nci_parse_signature(PARROT_INTERP, ARGIN(STRING *sig_str)) { ASSERT_ARGS(Parrot_nci_parse_signature) const size_t sig_length = Parrot_str_byte_length(interp, sig_str); PMC *sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, sig_length); size_t i; if (!sig_length) { sig_pmc = Parrot_pmc_new_init_int(interp, enum_class_FixedIntegerArray, 1); VTABLE_set_integer_keyed_int(interp, sig_pmc, 0, enum_type_void); return sig_pmc; } for (i = 0; i < sig_length; ++i) { const INTVAL c = Parrot_str_indexed(interp, sig_str, i); PARROT_DATA_TYPE e; PARROT_ASSERT(c == (char)c); switch ((char)c) { case 'f': e = enum_type_float; break; case 'd': e = enum_type_double; break; case 'N': e = enum_type_FLOATVAL; break; case 'c': /* char */ e = enum_type_char; break; case 's': /* short */ e = enum_type_short; break; case 'i': /* int */ e = enum_type_int; break; case 'l': /* long */ e = enum_type_long; break; case 'I': /* INTVAL */ e = enum_type_INTVAL; break; case '2': /* short PMC */ e = enum_type_pshort; break; case '3': /* int PMC */ e = enum_type_pint; break; case '4': /* long PMC */ e = enum_type_plong; break; case 'S': e = enum_type_STRING; break; case 't': /* string as cstring */ e = enum_type_cstr; break; case 'p': /* push pmc->data */ e = enum_type_ptr; break; case 'O': /* PMC invocant */ case 'P': /* push PMC * */ e = enum_type_PMC; break; case 'v': e = enum_type_void; break; default: Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_JIT_ERROR, "Unknown param Signature %c\n", (char)c); break; } VTABLE_set_integer_keyed_int(interp, sig_pmc, i, e); } return sig_pmc; }
void parrot_init_library_paths(PARROT_INTERP) { ASSERT_ARGS(parrot_init_library_paths) PMC *paths; STRING *entry; PMC * const iglobals = interp->iglobals; /* create the lib_paths array */ PMC * const lib_paths = Parrot_pmc_new_init_int(interp, enum_class_FixedPMCArray, PARROT_LIB_PATH_SIZE); VTABLE_set_pmc_keyed_int(interp, iglobals, IGLOBALS_LIB_PATHS, lib_paths); /* each is an array of strings */ /* define include paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_INCLUDE, paths); { /* EXPERIMENTAL: add include path from environment */ STRING *envvar = Parrot_getenv(interp, CONST_STRING(interp, "PARROT_INCLUDE")); Parrot_warn_experimental(interp, "PARROT_INCLUDE environment variable is experimental"); if (!STRING_IS_NULL(envvar) && !STRING_IS_EMPTY(envvar)) VTABLE_push_string(interp, paths, envvar); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); /* define library paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LIBRARY, paths); { /* EXPERIMENTAL: add library path from environment */ STRING *envvar = Parrot_getenv(interp, CONST_STRING(interp, "PARROT_LIBRARY")); Parrot_warn_experimental(interp, "PARROT_LIBRARY environment variable is experimental"); if (!STRING_IS_NULL(envvar) && !STRING_IS_EMPTY(envvar)) VTABLE_push_string(interp, paths, envvar); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); /* define languages paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LANG, paths); entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); /* define dynext paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_DYNEXT, paths); entry = CONST_STRING(interp, "dynext/"); VTABLE_push_string(interp, paths, entry); /* shared exts */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_DYN_EXTS, paths); /* no CONST_STRING here - the c2str.pl preprocessor needs "real strs" */ entry = Parrot_str_new_constant(interp, PARROT_LOAD_EXT); VTABLE_push_string(interp, paths, entry); /* OS/X has .dylib and .bundle */ if (!STREQ(PARROT_LOAD_EXT, PARROT_SHARE_EXT)) { entry = Parrot_str_new_constant(interp, PARROT_SHARE_EXT); VTABLE_push_string(interp, paths, entry); } #ifdef PARROT_PLATFORM_LIB_PATH_INIT_HOOK PARROT_PLATFORM_LIB_PATH_INIT_HOOK(interp, lib_paths); #endif }