Skip to content

Commit 732b4f3

Browse files
committed
Extend storage spec support so a REPR can describe the things it can/canny box.
1 parent c4f9df4 commit 732b4f3

File tree

8 files changed

+22
-0
lines changed

8 files changed

+22
-0
lines changed

src/6model/reprs/HashAttrStore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
174174
storage_spec spec;
175175
spec.inlineable = STORAGE_SPEC_REFERENCE;
176176
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
177+
spec.can_box = 0;
177178
return spec;
178179
}
179180

src/6model/reprs/KnowHOWREPR.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
165165
storage_spec spec;
166166
spec.inlineable = STORAGE_SPEC_REFERENCE;
167167
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
168+
spec.can_box = 0;
168169
return spec;
169170
}
170171

src/6model/reprs/P6int.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
156156
spec.inlineable = STORAGE_SPEC_INLINED;
157157
spec.bits = sizeof(INTVAL) * 8;
158158
spec.boxed_primitive = STORAGE_SPEC_BP_INT;
159+
spec.can_box = STORAGE_SPEC_CAN_BOX_INT;
159160
return spec;
160161
}
161162

src/6model/reprs/P6num.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
156156
spec.inlineable = STORAGE_SPEC_INLINED;
157157
spec.bits = sizeof(FLOATVAL) * 8;
158158
spec.boxed_primitive = STORAGE_SPEC_BP_NUM;
159+
spec.can_box = STORAGE_SPEC_CAN_BOX_NUM;
159160
return spec;
160161
}
161162

src/6model/reprs/P6opaque.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,17 @@ static void gc_free_repr(PARROT_INTERP, STable *st) {
800800

801801
/* Gets the storage specification for this representation. */
802802
static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
803+
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)st->REPR_data;
803804
storage_spec spec;
804805
spec.inlineable = STORAGE_SPEC_REFERENCE;
805806
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
807+
spec.can_box = 0;
808+
if (repr_data->unbox_int_offset)
809+
spec.can_box += STORAGE_SPEC_CAN_BOX_INT;
810+
if (repr_data->unbox_num_offset)
811+
spec.can_box += STORAGE_SPEC_CAN_BOX_NUM;
812+
if (repr_data->unbox_str_offset)
813+
spec.can_box += STORAGE_SPEC_CAN_BOX_STR;
806814
return spec;
807815
}
808816

src/6model/reprs/P6str.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
158158
spec.inlineable = STORAGE_SPEC_INLINED;
159159
spec.bits = sizeof(STRING *) * 8;
160160
spec.boxed_primitive = STORAGE_SPEC_BP_STR;
161+
spec.can_box = STORAGE_SPEC_CAN_BOX_STR;
161162
return spec;
162163
}
163164

src/6model/reprs/Uninstantiable.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ static storage_spec get_storage_spec(PARROT_INTERP, STable *st) {
154154
storage_spec spec;
155155
spec.inlineable = STORAGE_SPEC_REFERENCE;
156156
spec.boxed_primitive = STORAGE_SPEC_BP_NONE;
157+
spec.can_box = 0;
157158
return spec;
158159
}
159160

src/6model/storage_spec.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ typedef struct {
1919
* primitive type and can unbox, this says what primitive type
2020
* that they unbox to. */
2121
INTVAL boxed_primitive;
22+
23+
/* The types that this one can box/unbox to. */
24+
INTVAL can_box;
2225
} storage_spec;
2326

2427
/* Inlined or not. */
@@ -31,4 +34,9 @@ typedef struct {
3134
#define STORAGE_SPEC_BP_NUM 2
3235
#define STORAGE_SPEC_BP_STR 3
3336

37+
/* can_box bit field values. */
38+
#define STORAGE_SPEC_CAN_BOX_INT 1
39+
#define STORAGE_SPEC_CAN_BOX_NUM 2
40+
#define STORAGE_SPEC_CAN_BOX_STR 4
41+
3442
#endif

0 commit comments

Comments
 (0)