Implemented structs
This commit is contained in:
parent
50fc8c6249
commit
e36d9fade3
32 changed files with 267 additions and 63 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue