Skip to content

Commit 8f536de

Browse files
committed
Switch binding of natively typed attributes over to the new REPR API. Seems to work fine.
1 parent 281bfbf commit 8f536de

File tree

9 files changed

+83
-142
lines changed

9 files changed

+83
-142
lines changed

src/6model/reprs/HashAttrStore.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,7 @@ static void bind_attribute(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *n
7171
"Cannot access attributes in a type object");
7272
VTABLE_set_pmc_keyed_str(interp, instance->body.store, name, value);
7373
}
74-
static void bind_attribute_int(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, INTVAL value) {
75-
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
76-
"HashAttrStore representation does not support native attribute storage");
77-
}
78-
static void bind_attribute_num(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, FLOATVAL value) {
79-
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
80-
"HashAttrStore representation does not support native attribute storage");
81-
}
82-
static void bind_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, STRING *value) {
74+
static void bind_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, void *value) {
8375
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
8476
"HashAttrStore representation does not support native attribute storage");
8577
}
@@ -185,9 +177,7 @@ REPROps * HashAttrStore_initialize(PARROT_INTERP) {
185177
this_repr->get_attribute_boxed = get_attribute_boxed;
186178
this_repr->get_attribute_ref = get_attribute_ref;
187179
this_repr->bind_attribute = bind_attribute;
188-
this_repr->bind_attribute_int = bind_attribute_int;
189-
this_repr->bind_attribute_num = bind_attribute_num;
190-
this_repr->bind_attribute_str = bind_attribute_str;
180+
this_repr->bind_attribute_ref = bind_attribute_ref;
191181
this_repr->hint_for = hint_for;
192182
this_repr->clone = repr_clone;
193183
this_repr->set_int = set_int;

src/6model/reprs/KnowHOWREPR.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,7 @@ static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *clas
7777
static void bind_attribute(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) {
7878
die_no_attrs(interp);
7979
}
80-
static void bind_attribute_int(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, INTVAL value) {
81-
die_no_attrs(interp);
82-
}
83-
static void bind_attribute_num(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, FLOATVAL value) {
84-
die_no_attrs(interp);
85-
}
86-
static void bind_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, STRING *value) {
80+
static void bind_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, void *value) {
8781
die_no_attrs(interp);
8882
}
8983

@@ -185,9 +179,7 @@ REPROps * KnowHOWREPR_initialize(PARROT_INTERP) {
185179
this_repr->get_attribute_boxed = get_attribute_boxed;
186180
this_repr->get_attribute_ref = get_attribute_ref;
187181
this_repr->bind_attribute = bind_attribute;
188-
this_repr->bind_attribute_int = bind_attribute_int;
189-
this_repr->bind_attribute_num = bind_attribute_num;
190-
this_repr->bind_attribute_str = bind_attribute_str;
182+
this_repr->bind_attribute_ref = bind_attribute_ref;
191183
this_repr->hint_for = hint_for;
192184
this_repr->clone = repr_clone;
193185
this_repr->set_int = set_int;

src/6model/reprs/P6int.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,7 @@ static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *clas
6969
static void bind_attribute(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) {
7070
die_no_attrs(interp);
7171
}
72-
static void bind_attribute_int(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, INTVAL value) {
73-
die_no_attrs(interp);
74-
}
75-
static void bind_attribute_num(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, FLOATVAL value) {
76-
die_no_attrs(interp);
77-
}
78-
static void bind_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, STRING *value) {
72+
static void bind_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, void *value) {
7973
die_no_attrs(interp);
8074
}
8175

@@ -164,9 +158,7 @@ REPROps * P6int_initialize(PARROT_INTERP) {
164158
this_repr->get_attribute_boxed = get_attribute_boxed;
165159
this_repr->get_attribute_ref = get_attribute_ref;
166160
this_repr->bind_attribute = bind_attribute;
167-
this_repr->bind_attribute_int = bind_attribute_int;
168-
this_repr->bind_attribute_num = bind_attribute_num;
169-
this_repr->bind_attribute_str = bind_attribute_str;
161+
this_repr->bind_attribute_ref = bind_attribute_ref;
170162
this_repr->hint_for = hint_for;
171163
this_repr->clone = repr_clone;
172164
this_repr->set_int = set_int;

src/6model/reprs/P6num.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,7 @@ static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *clas
7070
static void bind_attribute(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) {
7171
die_no_attrs(interp);
7272
}
73-
static void bind_attribute_int(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, INTVAL value) {
74-
die_no_attrs(interp);
75-
}
76-
static void bind_attribute_num(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, FLOATVAL value) {
77-
die_no_attrs(interp);
78-
}
79-
static void bind_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, STRING *value) {
73+
static void bind_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, void *value) {
8074
die_no_attrs(interp);
8175
}
8276

@@ -165,9 +159,7 @@ REPROps * P6num_initialize(PARROT_INTERP) {
165159
this_repr->get_attribute_boxed = get_attribute_boxed;
166160
this_repr->get_attribute_ref = get_attribute_ref;
167161
this_repr->bind_attribute = bind_attribute;
168-
this_repr->bind_attribute_int = bind_attribute_int;
169-
this_repr->bind_attribute_num = bind_attribute_num;
170-
this_repr->bind_attribute_str = bind_attribute_str;
162+
this_repr->bind_attribute_ref = bind_attribute_ref;
171163
this_repr->hint_for = hint_for;
172164
this_repr->clone = repr_clone;
173165
this_repr->set_int = set_int;

src/6model/reprs/P6opaque.c

Lines changed: 13 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -487,63 +487,23 @@ static void bind_attribute(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *n
487487
no_such_attribute(interp, "bind", class_handle, name);
488488
}
489489
}
490-
static void bind_attribute_int(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, INTVAL value) {
491-
P6opaqueInstance *instance = (P6opaqueInstance *)PMC_data(obj);
492-
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)STABLE(obj)->REPR_data;
493-
INTVAL slot;
494-
495-
/* Ensure it is a defined object. */
496-
if (PObj_flag_TEST(private0, obj))
497-
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
498-
"Cannot access attributes in a type object");
499-
500-
/* Try the slot allocation first. */
501-
slot = hint >= 0 && !(repr_data->mi) ? hint :
502-
try_get_slot(interp, repr_data, class_handle, name);
503-
if (slot >= 0) {
504-
set_int_at_offset(instance, sizeof(P6opaqueInstance) + repr_data->attribute_offsets[slot], value);
505-
}
506-
else {
507-
/* Otherwise, complain that the attribute doesn't exist. */
508-
no_such_attribute(interp, "bind", class_handle, name);
509-
}
510-
}
511-
static void bind_attribute_num(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, FLOATVAL value) {
512-
P6opaqueInstance *instance = (P6opaqueInstance *)PMC_data(obj);
513-
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)STABLE(obj)->REPR_data;
514-
INTVAL slot;
515-
516-
/* Ensure it is a defined object. */
517-
if (PObj_flag_TEST(private0, obj))
518-
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
519-
"Cannot access attributes in a type object");
520-
521-
/* Try the slot allocation first. */
522-
slot = hint >= 0 && !(repr_data->mi) ? hint :
523-
try_get_slot(interp, repr_data, class_handle, name);
524-
if (slot >= 0) {
525-
set_num_at_offset(instance, sizeof(P6opaqueInstance) + repr_data->attribute_offsets[slot], value);
526-
}
527-
else {
528-
/* Otherwise, complain that the attribute doesn't exist. */
529-
no_such_attribute(interp, "bind", class_handle, name);
530-
}
531-
}
532-
static void bind_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, STRING *value) {
533-
P6opaqueInstance *instance = (P6opaqueInstance *)PMC_data(obj);
534-
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)STABLE(obj)->REPR_data;
490+
static void bind_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, void *value) {
491+
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)st->REPR_data;
535492
INTVAL slot;
536493

537-
/* Ensure it is a defined object. */
538-
if (PObj_flag_TEST(private0, obj))
539-
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
540-
"Cannot access attributes in a type object");
541-
542-
/* Try the slot allocation first. */
494+
/* Try to find the slot. */
543495
slot = hint >= 0 && !(repr_data->mi) ? hint :
544496
try_get_slot(interp, repr_data, class_handle, name);
545497
if (slot >= 0) {
546-
set_str_at_offset(instance, sizeof(P6opaqueInstance) + repr_data->attribute_offsets[slot], value);
498+
STable *st = repr_data->flattened_stables[slot];
499+
if (st)
500+
st->REPR->copy_to(interp, st, value, (char *)data + repr_data->attribute_offsets[slot]);
501+
else
502+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
503+
"Can not bind by reference to non-flattened attribute '%Ss' on class '%Ss'",
504+
name, VTABLE_get_string(interp, introspection_call(interp,
505+
class_handle, STABLE(class_handle)->HOW,
506+
Parrot_str_new_constant(interp, "name"), 0)));
547507
}
548508
else {
549509
/* Otherwise, complain that the attribute doesn't exist. */
@@ -851,9 +811,7 @@ REPROps * P6opaque_initialize(PARROT_INTERP) {
851811
this_repr->get_attribute_boxed = get_attribute_boxed;
852812
this_repr->get_attribute_ref = get_attribute_ref;
853813
this_repr->bind_attribute = bind_attribute;
854-
this_repr->bind_attribute_int = bind_attribute_int;
855-
this_repr->bind_attribute_num = bind_attribute_num;
856-
this_repr->bind_attribute_str = bind_attribute_str;
814+
this_repr->bind_attribute_ref = bind_attribute_ref;
857815
this_repr->hint_for = hint_for;
858816
this_repr->clone = repr_clone;
859817
this_repr->set_int = set_int;

src/6model/reprs/P6str.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,7 @@ static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *clas
7070
static void bind_attribute(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) {
7171
die_no_attrs(interp);
7272
}
73-
static void bind_attribute_int(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, INTVAL value) {
74-
die_no_attrs(interp);
75-
}
76-
static void bind_attribute_num(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, FLOATVAL value) {
77-
die_no_attrs(interp);
78-
}
79-
static void bind_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, STRING *value) {
73+
static void bind_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, void *value) {
8074
die_no_attrs(interp);
8175
}
8276

@@ -172,9 +166,7 @@ REPROps * P6str_initialize(PARROT_INTERP) {
172166
this_repr->get_attribute_boxed = get_attribute_boxed;
173167
this_repr->get_attribute_ref = get_attribute_ref;
174168
this_repr->bind_attribute = bind_attribute;
175-
this_repr->bind_attribute_int = bind_attribute_int;
176-
this_repr->bind_attribute_num = bind_attribute_num;
177-
this_repr->bind_attribute_str = bind_attribute_str;
169+
this_repr->bind_attribute_ref = bind_attribute_ref;
178170
this_repr->hint_for = hint_for;
179171
this_repr->clone = repr_clone;
180172
this_repr->set_int = set_int;

src/6model/reprs/Uninstantiable.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,7 @@ static STRING * get_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, ST
7676
static void bind_attribute(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) {
7777
die_no_attrs(interp);
7878
}
79-
static void bind_attribute_int(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, INTVAL value) {
80-
die_no_attrs(interp);
81-
}
82-
static void bind_attribute_num(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, FLOATVAL value) {
83-
die_no_attrs(interp);
84-
}
85-
static void bind_attribute_str(PARROT_INTERP, PMC *obj, PMC *class_handle, STRING *name, INTVAL hint, STRING *value) {
79+
static void bind_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, void *value) {
8680
die_no_attrs(interp);
8781
}
8882

@@ -171,9 +165,7 @@ REPROps * Uninstantiable_initialize(PARROT_INTERP) {
171165
this_repr->get_attribute_boxed = get_attribute_boxed;
172166
this_repr->get_attribute_ref = get_attribute_ref;
173167
this_repr->bind_attribute = bind_attribute;
174-
this_repr->bind_attribute_int = bind_attribute_int;
175-
this_repr->bind_attribute_num = bind_attribute_num;
176-
this_repr->bind_attribute_str = bind_attribute_str;
168+
this_repr->bind_attribute_ref = bind_attribute_ref;
177169
this_repr->hint_for = hint_for;
178170
this_repr->clone = repr_clone;
179171
this_repr->set_int = set_int;

src/6model/sixmodelobject.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,12 @@ struct SixModel_REPROps {
184184
/* Binds the given object value to the specified attribute. */
185185
void (*bind_attribute) (PARROT_INTERP, PMC *Object, PMC *ClassHandle, STRING *Name, INTVAL Hint, PMC *Value);
186186

187-
/* Binds the given int value to the specified attribute. */
188-
void (*bind_attribute_int) (PARROT_INTERP, PMC *Object, PMC *ClassHandle, STRING *Name, INTVAL Hint, INTVAL Value);
189-
190-
/* Binds the given num value to the specified attribute. */
191-
void (*bind_attribute_num) (PARROT_INTERP, PMC *Object, PMC *ClassHandle, STRING *Name, INTVAL Hint, FLOATVAL Value);
192-
193-
/* Binds the given str value to the specified attribute. */
194-
void (*bind_attribute_str) (PARROT_INTERP, PMC *Object, PMC *ClassHandle, STRING *Name, INTVAL Hint, STRING *Value);
187+
/* Binds a flattened in attribute to the value at the passed reference.
188+
* Like with the get_attribute_ref function, presumably the thing calling
189+
* this knows about the type of the attribute it is supplying data for.
190+
* copy_to will be used to copy the data in to place. */
191+
void (*bind_attribute_ref) (PARROT_INTERP, STable *st, void *data,
192+
PMC *class_handle, STRING *name, INTVAL hint, void *value);
195193

196194
/* Gets the hint for the given attribute ID. */
197195
INTVAL (*hint_for) (PARROT_INTERP, PMC *Object, PMC *ClassHandle, STRING *Name);

src/ops/nqp.ops

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,17 @@ a native int - the repr is not obligated to do boxing/unboxing for you.
374374
*/
375375
inline op repr_bind_attr_int(in PMC, in PMC, in STR, in INT) :base_core {
376376
PMC *ch = decontainerize(interp, $2);
377-
if ($1->vtable->base_type == smo_id)
378-
REPR($1)->bind_attribute_int(interp, $1, ch, $3, NO_HINT, $4);
379-
else
377+
if ($1->vtable->base_type == smo_id) {
378+
if (IS_CONCRETE($1))
379+
REPR($1)->bind_attribute_ref(interp, STABLE($1), OBJECT_BODY($1), ch, $3, NO_HINT, &$4);
380+
else
381+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
382+
"Cannot bind to attributes in a type object");
383+
}
384+
else {
380385
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
381386
"Can only use repr_bind_attr_int on a SixModelObject");
387+
}
382388
}
383389

384390
/*
@@ -393,11 +399,17 @@ a native num - the repr is not obligated to do boxing/unboxing for you.
393399
*/
394400
inline op repr_bind_attr_num(in PMC, in PMC, in STR, in NUM) :base_core {
395401
PMC *ch = decontainerize(interp, $2);
396-
if ($1->vtable->base_type == smo_id)
397-
REPR($1)->bind_attribute_num(interp, $1, ch, $3, NO_HINT, $4);
398-
else
402+
if ($1->vtable->base_type == smo_id) {
403+
if (IS_CONCRETE($1))
404+
REPR($1)->bind_attribute_ref(interp, STABLE($1), OBJECT_BODY($1), ch, $3, NO_HINT, &$4);
405+
else
406+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
407+
"Cannot bind to attributes in a type object");
408+
}
409+
else {
399410
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
400411
"Can only use repr_bind_attr_num on a SixModelObject");
412+
}
401413
}
402414

403415
/*
@@ -412,8 +424,13 @@ a native str - the repr is not obligated to do boxing/unboxing for you.
412424
*/
413425
inline op repr_bind_attr_str(in PMC, in PMC, in STR, in STR) :base_core {
414426
PMC *ch = decontainerize(interp, $2);
415-
if ($1->vtable->base_type == smo_id)
416-
REPR($1)->bind_attribute_str(interp, $1, ch, $3, NO_HINT, $4);
427+
if ($1->vtable->base_type == smo_id) {
428+
if (IS_CONCRETE($1))
429+
REPR($1)->bind_attribute_ref(interp, STABLE($1), OBJECT_BODY($1), ch, $3, NO_HINT, &$4);
430+
else
431+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
432+
"Cannot bind to attributes in a type object");
433+
}
417434
else
418435
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
419436
"Can only use repr_bind_attr_str on a SixModelObject");
@@ -552,11 +569,17 @@ a native int - the repr is not obligated to do boxing/unboxing for you.
552569
*/
553570
inline op repr_bind_attr_int(in PMC, in PMC, in STR, in INT, in INT) :base_core {
554571
PMC *ch = decontainerize(interp, $2);
555-
if ($1->vtable->base_type == smo_id)
556-
REPR($1)->bind_attribute_int(interp, $1, ch, $3, $4, $5);
557-
else
572+
if ($1->vtable->base_type == smo_id) {
573+
if (IS_CONCRETE($1))
574+
REPR($1)->bind_attribute_ref(interp, STABLE($1), OBJECT_BODY($1), ch, $3, $4, &$5);
575+
else
576+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
577+
"Cannot bind to attributes in a type object");
578+
}
579+
else {
558580
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
559581
"Can only use repr_bind_attr_int on a SixModelObject");
582+
}
560583
}
561584

562585
/*
@@ -571,11 +594,17 @@ a native num - the repr is not obligated to do boxing/unboxing for you.
571594
*/
572595
inline op repr_bind_attr_num(in PMC, in PMC, in STR, in INT, in NUM) :base_core {
573596
PMC *ch = decontainerize(interp, $2);
574-
if ($1->vtable->base_type == smo_id)
575-
REPR($1)->bind_attribute_num(interp, $1, ch, $3, $4, $5);
576-
else
597+
if ($1->vtable->base_type == smo_id) {
598+
if (IS_CONCRETE($1))
599+
REPR($1)->bind_attribute_ref(interp, STABLE($1), OBJECT_BODY($1), ch, $3, $4, &$5);
600+
else
601+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
602+
"Cannot bind to attributes in a type object");
603+
}
604+
else {
577605
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
578606
"Can only use repr_bind_attr_num on a SixModelObject");
607+
}
579608
}
580609

581610
/*
@@ -590,11 +619,17 @@ a native str - the repr is not obligated to do boxing/unboxing for you.
590619
*/
591620
inline op repr_bind_attr_str(in PMC, in PMC, in STR, in INT, in STR) :base_core {
592621
PMC *ch = decontainerize(interp, $2);
593-
if ($1->vtable->base_type == smo_id)
594-
REPR($1)->bind_attribute_str(interp, $1, ch, $3, $4, $5);
595-
else
622+
if ($1->vtable->base_type == smo_id) {
623+
if (IS_CONCRETE($1))
624+
REPR($1)->bind_attribute_ref(interp, STABLE($1), OBJECT_BODY($1), ch, $3, $4, &$5);
625+
else
626+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
627+
"Cannot bind to attributes in a type object");
628+
}
629+
else {
596630
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
597631
"Can only use repr_bind_attr_str on a SixModelObject");
632+
}
598633
PARROT_GC_WRITE_BARRIER(interp, $1);
599634
}
600635

0 commit comments

Comments
 (0)