Implemented struct size calculation after a scan

This commit is contained in:
2025-02-07 16:26:24 +01:00
parent c28eace966
commit 63a2752c56
7 changed files with 48 additions and 24 deletions

View File

@ -33,27 +33,12 @@ func (s *Scanner) scanStruct(file *fs.File, tokens token.List, i int) (int, erro
fieldName := tokens[i].Text(file.Bytes)
i++
fieldTypeName := tokens[i].Text(file.Bytes)
fieldType := types.Int
switch fieldTypeName {
case "Int", "Int64":
case "Int32":
fieldType = types.Int32
case "Int16":
fieldType = types.Int16
case "Int8":
fieldType = types.Int8
default:
panic("not implemented")
}
i++
structure.AddField(&types.Field{
Type: fieldType,
Name: fieldName,
TypeName: fieldTypeName,
Position: token.Position(fieldPosition),
Offset: structure.Size(),
})
}