Skip to content

Commit

Permalink
Merge pull request #1116 from kazcw/cant-has-incomplete-type
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 9, 2019
2 parents 3494e82 + 36469a6 commit 4e2ee39
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/6model/reprs/CPPStruct.c
Expand Up @@ -218,6 +218,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMSTable *st,
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCArrayREPRData *carray_repr_data = (MVMCArrayREPRData *)STABLE(type)->REPR_data;
if (!carray_repr_data) {
MVM_exception_throw_adhoc(tc,
"CPPStruct: can't inline a CArray attribute before its type's definition");
}
bits = carray_repr_data->elem_size * 8;
repr_data->attribute_locations[i] |= MVM_CSTRUCT_ATTR_INLINED;

Expand Down Expand Up @@ -245,6 +249,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMSTable *st,
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCStructREPRData *cstruct_repr_data = (MVMCStructREPRData *)STABLE(type)->REPR_data;
if (!cstruct_repr_data) {
MVM_exception_throw_adhoc(tc,
"CPPStruct: can't inline a CStruct attribute before its type's definition");
}
bits = cstruct_repr_data->struct_size * 8;
align = cstruct_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CPPSTRUCT_ATTR_INLINED;
Expand All @@ -257,6 +265,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMSTable *st,
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCPPStructREPRData *cppstruct_repr_data = (MVMCPPStructREPRData *)STABLE(type)->REPR_data;
if (!cppstruct_repr_data) {
MVM_exception_throw_adhoc(tc,
"CPPStruct: can't inline a CPPStruct attribute before its type's definition");
}
bits = cppstruct_repr_data->struct_size * 8;
align = cppstruct_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CPPSTRUCT_ATTR_INLINED;
Expand All @@ -269,6 +281,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMSTable *st,
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCUnionREPRData *cunion_repr_data = (MVMCUnionREPRData *)STABLE(type)->REPR_data;
if (!cunion_repr_data) {
MVM_exception_throw_adhoc(tc,
"CPPStruct: can't inline a CUnion attribute before its type's definition");
}
bits = cunion_repr_data->struct_size * 8;
align = cunion_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CPPSTRUCT_ATTR_INLINED;
Expand Down
16 changes: 16 additions & 0 deletions src/6model/reprs/CStruct.c
Expand Up @@ -215,6 +215,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCArrayREPRData *carray_repr_data = (MVMCArrayREPRData *)STABLE(type)->REPR_data;
if (!carray_repr_data) {
MVM_exception_throw_adhoc(tc,
"CStruct: can't inline a CArray attribute before its type's definition");
}
bits = carray_repr_data->elem_size * 8;
repr_data->attribute_locations[i] |= MVM_CSTRUCT_ATTR_INLINED;

Expand Down Expand Up @@ -248,6 +252,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCStructREPRData *cstruct_repr_data = (MVMCStructREPRData *)STABLE(type)->REPR_data;
if (!cstruct_repr_data) {
MVM_exception_throw_adhoc(tc,
"CStruct: can't inline a CStruct attribute before its type's definition");
}
bits = cstruct_repr_data->struct_size * 8;
align = cstruct_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CSTRUCT_ATTR_INLINED;
Expand All @@ -260,6 +268,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCPPStructREPRData *cppstruct_repr_data = (MVMCPPStructREPRData *)STABLE(type)->REPR_data;
if (!cppstruct_repr_data) {
MVM_exception_throw_adhoc(tc,
"CStruct: can't inline a CPPStruct attribute before its type's definition");
}
bits = cppstruct_repr_data->struct_size * 8;
align = cppstruct_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CSTRUCT_ATTR_INLINED;
Expand All @@ -272,6 +284,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
MVM_ASSIGN_REF(tc, &(st->header), repr_data->member_types[i], type);
if (inlined) {
MVMCUnionREPRData *cunion_repr_data = (MVMCUnionREPRData *)STABLE(type)->REPR_data;
if (!cunion_repr_data) {
MVM_exception_throw_adhoc(tc,
"CStruct: can't inline a CUnion attribute before its type's definition");
}
bits = cunion_repr_data->struct_size * 8;
align = cunion_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CSTRUCT_ATTR_INLINED;
Expand Down
13 changes: 13 additions & 0 deletions src/6model/reprs/CUnion.c
Expand Up @@ -129,6 +129,7 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
MVMint64 inlined = !MVM_is_null(tc, inlined_val) && MVM_repr_get_int(tc, inlined_val);
MVMint32 bits = sizeof(void *) * 8;
MVMint32 align = ALIGNOF(void *);

if (!MVM_is_null(tc, type)) {
/* See if it's a type that we know how to handle in a C struct. */
const MVMStorageSpec *spec = REPR(type)->get_storage_spec(tc, STABLE(type));
Expand Down Expand Up @@ -179,6 +180,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
repr_data->member_types[i] = type;
if (inlined) {
MVMCStructREPRData *cstruct_repr_data = (MVMCStructREPRData *)STABLE(type)->REPR_data;
if (!cstruct_repr_data) {
MVM_exception_throw_adhoc(tc,
"CUnion: can't inline a CStruct attribute before its type's definition");
}
bits = cstruct_repr_data->struct_size * 8;
align = cstruct_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CUNION_ATTR_INLINED;
Expand All @@ -191,6 +196,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
repr_data->member_types[i] = type;
if (inlined) {
MVMCPPStructREPRData *cppstruct_repr_data = (MVMCPPStructREPRData *)STABLE(type)->REPR_data;
if (!cppstruct_repr_data) {
MVM_exception_throw_adhoc(tc,
"CUnion: can't inline a CPPStruct attribute before its type's definition");
}
bits = cppstruct_repr_data->struct_size * 8;
align = cppstruct_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CUNION_ATTR_INLINED;
Expand All @@ -203,6 +212,10 @@ static void compute_allocation_strategy(MVMThreadContext *tc, MVMObject *repr_in
repr_data->member_types[i] = type;
if (inlined) {
MVMCUnionREPRData *cunion_repr_data = (MVMCUnionREPRData *)STABLE(type)->REPR_data;
if (!cunion_repr_data) {
MVM_exception_throw_adhoc(tc,
"CUnion: can't inline a CUnion attribute before its type's definition");
}
bits = cunion_repr_data->struct_size * 8;
align = cunion_repr_data->struct_align;
repr_data->attribute_locations[i] |= MVM_CUNION_ATTR_INLINED;
Expand Down

0 comments on commit 4e2ee39

Please sign in to comment.