/
field_method.go
51 lines (41 loc) · 939 Bytes
/
field_method.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package class
import (
"encoding/binary"
"io"
)
type Field struct {
fieldMethod
}
type Method struct {
fieldMethod
}
type fieldMethod struct {
AccessFlags
NameIndex ConstPoolIndex
DescriptorIndex ConstPoolIndex
Attributes
}
func readFieldMethod(r io.Reader, constPool ConstantPool) (*fieldMethod, error) {
fom := &fieldMethod{}
err := multiError([]error{
binary.Read(r, byteOrder, &fom.AccessFlags),
binary.Read(r, byteOrder, &fom.NameIndex),
binary.Read(r, byteOrder, &fom.DescriptorIndex),
})
if err != nil {
return nil, err
}
fom.Attributes, err = readAttributes(r, constPool)
if err != nil {
return nil, err
}
return fom, nil
}
func (fom fieldMethod) Dump(w io.Writer) error {
return multiError([]error{
binary.Write(w, byteOrder, fom.AccessFlags),
binary.Write(w, byteOrder, fom.NameIndex),
binary.Write(w, byteOrder, fom.DescriptorIndex),
writeAttributes(w, fom.Attributes),
})
}