| 1 | module main |
| 2 | |
| 3 | struct TypeShape { |
| 4 | kind int |
| 5 | width int |
| 6 | elem_type int |
| 7 | len int |
| 8 | fields []int |
| 9 | field_names []string |
| 10 | params []int |
| 11 | ret_type int |
| 12 | is_c_struct bool |
| 13 | is_union bool |
| 14 | is_unsigned bool |
| 15 | } |
| 16 | |
| 17 | fn fixed_array_size(types []TypeShape, typ_id int) int { |
| 18 | typ := types[typ_id] |
| 19 | if typ.kind == 4 { |
| 20 | return typ.len * 4 |
| 21 | } |
| 22 | return 0 |
| 23 | } |
| 24 | |
| 25 | fn main() { |
| 26 | types := [ |
| 27 | TypeShape{ |
| 28 | kind: 4 |
| 29 | elem_type: 1 |
| 30 | len: 128 |
| 31 | fields: []int{} |
| 32 | params: []int{} |
| 33 | }, |
| 34 | ] |
| 35 | println(fixed_array_size(types, 0)) |
| 36 | } |
| 37 |