On Thursday 10 July 2008 17:33:23 Patrick R. Michaud (via RT) wrote: > There are a couple of issues with PMCProxy: > > 1. The PMCProxy returned from a get_class opcode isn't > the same as one obtained from using typeof on an instance > of the type. > > 2. Each invocation of typeof returns a new GC-able PMCProxy PMC.. > > Here's the PIR: > > $ cat x.pir > .sub main :main > $P0 = get_class 'Integer' > $P1 = new $P0 > $P2 = typeof $P1 > > $I0 = issame $P0, $P2 > say $I0 # should be 1 > > $P3 = typeof $P1 > $P4 = typeof $P1 > > $I0 = issame $P3, $P4 > say $I0 # should be 1 > .end > > $ ./parrot x.pir > 0 > 0
Here's a first approach. It breaks a couple of tests, but it's a start: t/pmc/object-meths (Wstat: 1280 Tests: 37 Failed: 5) Failed tests: 1-4, 16 t/oo/proxy (Wstat: 256 Tests: 5 Failed: 1) Failed test: 3 I believe a solution is to make a Class PMC stick the appropriate PMCProxy in its attached NameSpace's class slot when created, but I haven't tested that (and won't have a chance for a few hours). -- c
=== src/pmc/default.pmc ================================================================== --- src/pmc/default.pmc (revision 29269) +++ src/pmc/default.pmc (local) @@ -994,11 +994,8 @@ */ VTABLE PMC *get_class() { - /* Create a proxy */ - INTVAL type = VTABLE_type(interp, SELF); - PMC *type_num = pmc_new(interp, enum_class_Integer); - VTABLE_set_integer_native(interp, type_num, type); - return pmc_new_init(interp, enum_class_PMCProxy, type_num); + PMC *ns = VTABLE_get_namespace(interp, SELF); + return VTABLE_get_class(interp, ns); } VTABLE PMC *get_attr_str(STRING *name) {