compiler, reflect: properly handle embedded structs

This commit is contained in:
Damian Gryski
2023-03-06 11:49:20 -08:00
committed by Ayke
parent 15109a2924
commit 93fb897feb
2 changed files with 98 additions and 36 deletions
+4
View File
@@ -57,6 +57,7 @@ const (
structFieldFlagAnonymous = 1 << iota
structFieldFlagHasTag
structFieldFlagIsExported
structFieldFlagIsEmbedded
)
// createMakeInterface emits the LLVM IR for the *ssa.MakeInterface instruction.
@@ -243,6 +244,9 @@ func (c *compilerContext) getTypeCode(typ types.Type) llvm.Value {
if token.IsExported(field.Name()) {
flags |= structFieldFlagIsExported
}
if field.Embedded() {
flags |= structFieldFlagIsEmbedded
}
data := string(flags) + field.Name() + "\x00"
if typ.Tag(i) != "" {
if len(typ.Tag(i)) > 0xff {