v / vlib / v2 / gen / arm64 / tests / large_struct_partial_init_push.v
57 lines · 51 sloc · 873 bytes · e7738c112c787d477501fa4a87edd0e1d72159bd
Raw
1module main
2
3enum TypeKindShape {
4 void_t
5 int_t
6 float_t
7 ptr_t
8 array_t
9 struct_t
10 func_t
11 label_t
12 metadata_t
13}
14
15struct TypeShape {
16 kind TypeKindShape
17 width int
18 elem_type int
19 len int
20 fields []int
21 field_names []string
22 params []int
23 ret_type int
24 is_c_struct bool
25 is_union bool
26 is_unsigned bool
27}
28
29struct TypeStoreShape {
30mut:
31 types []TypeShape
32 cache map[string]int
33}
34
35fn (mut ts TypeStoreShape) register(t TypeShape) int {
36 id := ts.types.len
37 ts.types << t
38 return id
39}
40
41fn (mut ts TypeStoreShape) get_array(elem int, length int) int {
42 return ts.register(TypeShape{
43 kind: .array_t
44 elem_type: elem
45 len: length
46 })
47}
48
49fn main() {
50 mut ts := TypeStoreShape{}
51 ts.cache = map[string]int{}
52 id := ts.get_array(1, 128)
53 typ := ts.types[id]
54 println(typ.len)
55 println(typ.elem_type)
56 println(int(typ.kind))
57}
58