Implemented struct size calculation after a scan
This commit is contained in:
@ -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(),
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user