3 * Copyright (C) 2003-2009, Parrot Foundation.
7 * Sample SubProxy class
9 * s. src/dynpmc/main.pasm for usage
13 * the real class enum is created at load time
15 #define enum_class_SubProxy -1
17 pmclass SubProxy dynpmc extends Sub auto_attrs {
21 PObj_get_FLAGS(SELF) |= PObj_private0_FLAG;
24 VTABLE void set_pmc(PMC *key) {
28 VTABLE opcode_t* invoke(void* next) {
29 if (PObj_get_FLAGS(SELF) & PObj_private0_FLAG) {
31 PMC *key = PMC_data_typed(SELF, PMC *);
33 PMC *rsub_pmc, *sub_pmc;
34 Parrot_Sub_attributes *rsub, *my_sub;
37 Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "SubProxy: no key");
39 file = VTABLE_get_string(INTERP, key);
41 Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "SubProxy: no file");
43 sub_pmc = key_next(INTERP, key);
45 Parrot_ex_throw_from_c_args(INTERP, NULL, 1, "SubProxy: no sub");
47 Parrot_load_bytecode(INTERP, file);
48 rsub_pmc = VTABLE_get_pmc_keyed(INTERP,
49 INTERP->root_namespace, sub_pmc);
51 if (!VTABLE_defined(INTERP, rsub_pmc))
52 Parrot_ex_throw_from_c_args(INTERP, NULL, 1,
53 "SubProxy: sub not found");
55 PObj_get_FLAGS(SELF) &= ~PObj_private0_FLAG;
56 PMC_get_sub(INTERP, SELF, my_sub);
57 PMC_get_sub(INTERP, rsub_pmc, rsub);
58 my_sub->seg = rsub->seg;
59 my_sub->start_offs = rsub->start_offs;
60 my_sub->end_offs = rsub->end_offs;
69 * c-file-style: "parrot"
71 * vim: expandtab shiftwidth=4: