From e4ff6949548e4f186bd5cfd79a0eea477b4ee212 Mon Sep 17 00:00:00 2001 From: "Vittore F. Scolari" Date: Wed, 13 May 2020 00:48:25 +0200 Subject: [PATCH] Setup inlined CStruct assigned during construction Fixes https://github.com/rakudo/rakudo/issues/3687 --- src/6model/reprs/CStruct.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/6model/reprs/CStruct.c b/src/6model/reprs/CStruct.c index c775ec69c2..c20dc1606c 100644 --- a/src/6model/reprs/CStruct.c +++ b/src/6model/reprs/CStruct.c @@ -609,7 +609,15 @@ static void bind_attribute(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, if (REPR(value)->ID != MVM_REPR_ID_MVMCStruct) MVM_exception_throw_adhoc(tc, "Can only store CStruct attribute in CStruct slot in CStruct"); - cobj = ((MVMCStruct *)value)->body.cstruct; + if (repr_data->attribute_locations[slot] & MVM_CSTRUCT_ATTR_INLINED) { + memcpy((char *)body->cstruct + repr_data->struct_offsets[slot], + ((MVMCStruct *)value)->body.cstruct, + ((MVMCStructREPRData *)STABLE(value)->REPR_data)->struct_size); + ((MVMCStruct *)value)->body.cstruct = (char *)body->cstruct + repr_data->struct_offsets[slot]; + break; + } + else + cobj = ((MVMCStruct *)value)->body.cstruct; } else if (type == MVM_CSTRUCT_ATTR_CPPSTRUCT) { if (REPR(value)->ID != MVM_REPR_ID_MVMCPPStruct)