@@ -23,84 +23,6 @@ type TypeCache struct {
2323 CompatFlags map [string ]SszCompatFlag
2424}
2525
26- // SszTypeFlag is a flag indicating whether a type has a specific SSZ type feature
27- type SszTypeFlag uint8
28-
29- const (
30- SszTypeFlagIsDynamic SszTypeFlag = 1 << iota // Whether the type is a dynamic type (or has nested dynamic types)
31- SszTypeFlagHasLimit // Whether the type has a max size tag
32- SszTypeFlagHasDynamicSize // Whether this type or any of its nested types uses dynamic spec size value that differs from the default
33- SszTypeFlagHasDynamicMax // Whether this type or any of its nested types uses dynamic spec max value that differs from the default
34- SszTypeFlagHasSizeExpr // Whether this type or any of its nested types uses a dynamic expression to calculate the size or max size
35- SszTypeFlagHasMaxExpr // Whether this type or any of its nested types uses a dynamic expression to calculate the max size
36- SszTypeFlagHasBitSize // Whether the type has a bit size tag
37- )
38-
39- // SszCompatFlag is a flag indicating whether a type implements a specific SSZ compatibility interface
40- type SszCompatFlag uint16
41-
42- const (
43- SszCompatFlagFastSSZMarshaler SszCompatFlag = 1 << iota // Whether the type implements fastssz.Marshaler
44- SszCompatFlagFastSSZHasher // Whether the type implements fastssz.HashRoot
45- SszCompatFlagHashTreeRootWith // Whether the type implements HashTreeRootWith
46- SszCompatFlagDynamicMarshaler // Whether the type implements DynamicMarshaler
47- SszCompatFlagDynamicUnmarshaler // Whether the type implements DynamicUnmarshaler
48- SszCompatFlagDynamicSizer // Whether the type implements DynamicSizer
49- SszCompatFlagDynamicHashRoot // Whether the type implements DynamicHashRoot
50- SszCompatFlagDynamicEncoder // Whether the type implements DynamicEncoder
51- SszCompatFlagDynamicDecoder // Whether the type implements DynamicDecoder
52- )
53-
54- type GoTypeFlag uint8
55-
56- const (
57- GoTypeFlagIsPointer GoTypeFlag = 1 << iota // Whether the type is a pointer type
58- GoTypeFlagIsByteArray // Whether the type is a byte array
59- GoTypeFlagIsString // Whether the type is a string type
60- GoTypeFlagIsTime // Whether the type is a time.Time type
61- )
62-
63- // TypeDescriptor represents a cached, optimized descriptor for a type's SSZ encoding/decoding
64- type TypeDescriptor struct {
65- Type reflect.Type `json:"-"` // Reflect type
66- CodegenInfo * any `json:"-"` // Codegen information
67- Kind reflect.Kind `json:"kind"` // Reflect kind of the type
68- Size uint32 `json:"size"` // SSZ size (-1 if dynamic)
69- Len uint32 `json:"len"` // Length of array/slice / static size of container
70- Limit uint64 `json:"limit"` // Limit of array/slice (ssz-max tag)
71- ContainerDesc * ContainerDescriptor `json:"container,omitempty"` // For structs
72- UnionVariants map [uint8 ]* TypeDescriptor `json:"union,omitempty"` // Union variant types by index (for CompatibleUnion)
73- ElemDesc * TypeDescriptor `json:"field,omitempty"` // For slices/arrays
74- HashTreeRootWithMethod * reflect.Method `json:"-"` // Cached HashTreeRootWith method for performance
75- SizeExpression * string `json:"size_expr,omitempty"` // The dynamic expression used to calculate the size of the type
76- MaxExpression * string `json:"max_expr,omitempty"` // The dynamic expression used to calculate the max size of the type
77- BitSize uint32 `json:"bit_size,omitempty"` // Bit size for bit vector types (ssz-bitsize tag)
78- SszType SszType `json:"type"` // SSZ type of the type
79- SszTypeFlags SszTypeFlag `json:"flags"` // SSZ type flags
80- SszCompatFlags SszCompatFlag `json:"compat"` // SSZ compatibility flags
81- GoTypeFlags GoTypeFlag `json:"go_flags"` // Additional go type flags
82- }
83-
84- // FieldDescriptor represents a cached descriptor for a struct field
85- type ContainerDescriptor struct {
86- Fields []FieldDescriptor `json:"fields"` // For structs
87- DynFields []DynFieldDescriptor `json:"dyn_fields"` // Dynamic struct fields
88- }
89-
90- // FieldDescriptor represents a cached descriptor for a struct field
91- type FieldDescriptor struct {
92- Name string `json:"name"` // Name of the field
93- Type * TypeDescriptor `json:"type"` // Type descriptor
94- SszIndex uint16 `json:"index,omitempty"` // SSZ index for progressive containers
95- }
96-
97- // DynFieldDescriptor represents a dynamic field descriptor for a struct
98- type DynFieldDescriptor struct {
99- Field * FieldDescriptor `json:"field"`
100- HeaderOffset uint32 `json:"offset"`
101- Index int16 `json:"index"` // Index of the field in the struct
102- }
103-
10426// NewTypeCache creates a new type cache
10527func NewTypeCache (specs sszutils.DynamicSpecs ) * TypeCache {
10628 return & TypeCache {
0 commit comments