Skip to content

Commit f126661

Browse files
committed
Update get_attribute_ref prototype to return bit width of attribute.
1 parent 83e2a14 commit f126661

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

src/6model/repr_registry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static void die_no_attrs(PARROT_INTERP, STRING *repr_name) {
3333
static PMC * default_get_attribute_boxed(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint) {
3434
die_no_attrs(interp, st->REPR->name);
3535
}
36-
static void * default_get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint) {
36+
static void * default_get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL *bits, INTVAL hint) {
3737
die_no_attrs(interp, st->REPR->name);
3838
}
3939
static void default_bind_attribute_boxed(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint, PMC *value) {

src/6model/reprs/CStruct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static PMC * get_attribute_boxed(PARROT_INTERP, STable *st, void *data, PMC *cla
474474
/* Otherwise, complain that the attribute doesn't exist. */
475475
no_such_attribute(interp, "get", class_handle, name);
476476
}
477-
static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint) {
477+
static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL *bits, INTVAL hint) {
478478
CStructREPRData *repr_data = (CStructREPRData *)st->REPR_data;
479479
CStructBody *body = (CStructBody *)data;
480480
INTVAL slot;

src/6model/reprs/HashAttrStore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static PMC * get_attribute_boxed(PARROT_INTERP, STable *st, void *data, PMC *cla
5858
HashAttrStoreBody *body = (HashAttrStoreBody *)data;
5959
return VTABLE_get_pmc_keyed_str(interp, body->store, name);
6060
}
61-
static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint) {
61+
static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL *bits, INTVAL hint) {
6262
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
6363
"HashAttrStore representation does not support value type attributes");
6464
}

src/6model/reprs/P6opaque.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static PMC * get_attribute_boxed(PARROT_INTERP, STable *st, void *data, PMC *cla
520520
no_such_attribute(interp, "get", class_handle, name);
521521
}
522522

523-
static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL hint) {
523+
static void * get_attribute_ref(PARROT_INTERP, STable *st, void *data, PMC *class_handle, STRING *name, INTVAL *bits, INTVAL hint) {
524524
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)st->REPR_data;
525525
INTVAL slot;
526526

src/6model/sixmodelobject.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ typedef struct SixModel_REPROps_Attribute {
158158
PMC *class_handle, STRING *name, INTVAL hint);
159159

160160
/* Gets a reference to the memory location of an attribute. Note
161-
* that this is only valid so long as the object itself is alive. */
161+
* that this is only valid so long as the object itself is alive. If
162+
* bits is a non-NULL pointer, the pointed-to INTVAL will contain the
163+
* bit-width of the attribute. */
162164
void * (*get_attribute_ref) (PARROT_INTERP, STable *st, void *data,
163-
PMC *class_handle, STRING *name, INTVAL hint);
165+
PMC *class_handle, STRING *name, INTVAL *bits, INTVAL hint);
164166

165167
/* Binds the given object value to the specified attribute. If it's
166168
* a reference type attribute, this just simply sets the value in
@@ -215,7 +217,10 @@ typedef struct SixModel_REPROps_Boxing {
215217
} REPROps_Boxing;
216218
typedef struct SixModel_REPROps_Indexing {
217219
/* Get the address of the element at the specified position. May return null if
218-
* nothing is there, or throw to indicate out of bounds, or vivify. */
220+
* nothing is there, or throw to indicate out of bounds, or vivify. If
221+
* bits is a non-NULL pointer, the pointed-to INTVAL will contain the
222+
* bit-width of the attribute. */
223+
/*void * (*at_pos_ref) (PARROT_INTERP, STable *st, void *data, INTVAL index, INTVAL *bits);*/
219224
void * (*at_pos_ref) (PARROT_INTERP, STable *st, void *data, INTVAL index);
220225

221226
/* Get a boxed object representing the element at the specified position. If the

src/ops/nqp.ops

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ inline op repr_get_attr_int(out INT, invar PMC, invar PMC, in STR) :base_core {
551551
PMC *ch = decontainerize(interp, $3);
552552
if ($2->vtable->base_type == smo_id) {
553553
if (IS_CONCRETE($2))
554-
$1 = *((INTVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NO_HINT));
554+
$1 = *((INTVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NULL, NO_HINT));
555555
else
556556
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
557557
"Cannot look up attributes in a type object");
@@ -575,7 +575,7 @@ inline op repr_get_attr_num(out NUM, invar PMC, invar PMC, in STR) :base_core {
575575
PMC *ch = decontainerize(interp, $3);
576576
if ($2->vtable->base_type == smo_id) {
577577
if (IS_CONCRETE($2))
578-
$1 = *((FLOATVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NO_HINT));
578+
$1 = *((FLOATVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NULL, NO_HINT));
579579
else
580580
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
581581
"Cannot look up attributes in a type object");
@@ -600,7 +600,7 @@ inline op repr_get_attr_str(out STR, invar PMC, invar PMC, in STR) :base_core {
600600
PMC *ch = decontainerize(interp, $3);
601601
if ($2->vtable->base_type == smo_id) {
602602
if (IS_CONCRETE($2))
603-
$1 = *((STRING **)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NO_HINT));
603+
$1 = *((STRING **)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NULL, NO_HINT));
604604
else
605605
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
606606
"Cannot look up attributes in a type object");
@@ -757,7 +757,7 @@ inline op repr_get_attr_int(out INT, invar PMC, invar PMC, in STR, in INT) :base
757757
PMC *ch = decontainerize(interp, $3);
758758
if ($2->vtable->base_type == smo_id) {
759759
if (IS_CONCRETE($2))
760-
$1 = *((INTVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, $5));
760+
$1 = *((INTVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NULL, $5));
761761
else
762762
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
763763
"Cannot look up attributes in a type object");
@@ -782,7 +782,7 @@ inline op repr_get_attr_num(out NUM, invar PMC, invar PMC, in STR, in INT) :base
782782
PMC *ch = decontainerize(interp, $3);
783783
if ($2->vtable->base_type == smo_id) {
784784
if (IS_CONCRETE($2))
785-
$1 = *((FLOATVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, $5));
785+
$1 = *((FLOATVAL *)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NULL, $5));
786786
else
787787
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
788788
"Cannot look up attributes in a type object");
@@ -807,7 +807,7 @@ inline op repr_get_attr_str(out STR, invar PMC, invar PMC, in STR, in INT) :base
807807
PMC *ch = decontainerize(interp, $3);
808808
if ($2->vtable->base_type == smo_id) {
809809
if (IS_CONCRETE($2))
810-
$1 = *((STRING **)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, $5));
810+
$1 = *((STRING **)REPR($2)->attr_funcs->get_attribute_ref(interp, STABLE($2), OBJECT_BODY($2), ch, $4, NULL, $5));
811811
else
812812
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
813813
"Cannot look up attributes in a type object");

0 commit comments

Comments
 (0)