Implemented structs

This commit is contained in:
2025-02-04 18:16:31 +01:00
parent 4609a814df
commit 03a3bd8f02
32 changed files with 267 additions and 63 deletions

View File

@ -17,7 +17,7 @@ func (s *Scanner) scanStruct(file *fs.File, tokens token.List, i int) (int, erro
structName := tokens[i].Text(file.Bytes)
typ := &types.Type{
structure := &types.Struct{
Name: structName,
}
@ -39,14 +39,14 @@ func (s *Scanner) scanStruct(file *fs.File, tokens token.List, i int) (int, erro
fieldType := types.Parse(fieldTypeName)
i++
typ.Fields = append(typ.Fields, &types.Field{
structure.Fields = append(structure.Fields, &types.Field{
Type: fieldType,
Name: fieldName,
Position: token.Position(fieldPosition),
Offset: typ.Size,
Offset: structure.Size,
})
typ.Size += fieldType.Size
structure.Size += fieldType.TotalSize()
}
if tokens[i].Kind == token.BlockEnd {
@ -61,6 +61,6 @@ func (s *Scanner) scanStruct(file *fs.File, tokens token.List, i int) (int, erro
return i, errors.New(errors.MissingBlockEnd, file, tokens[i].Position)
}
s.types <- typ
s.types <- structure
return i, nil
}