Implemented structs
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user