Implemented struct size calculation after a scan
This commit is contained in:
parent
8fe663ece1
commit
162ddbefef
7 changed files with 48 additions and 24 deletions
|
@ -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(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue