cgen: fix 32-bit voidptr for map key (#7759)

pull/7882/head
Nick Treleaven 2021-01-05 01:59:01 +00:00 committed by GitHub
parent 3dae44db73
commit 2fc50a4045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -2314,7 +2314,7 @@ fn (mut g Gen) map_fn_ptrs(key_typ table.TypeSymbol) (string, string, string, st
mut clone_fn := '' mut clone_fn := ''
mut free_fn := '&map_free_nop' mut free_fn := '&map_free_nop'
match key_typ.kind { match key_typ.kind {
.byte, .bool, .i8, .char { .byte, .i8, .char {
hash_fn = '&map_hash_int_1' hash_fn = '&map_hash_int_1'
key_eq_fn = '&map_eq_int_1' key_eq_fn = '&map_eq_int_1'
clone_fn = '&map_clone_int_1' clone_fn = '&map_clone_int_1'
@ -2329,7 +2329,15 @@ fn (mut g Gen) map_fn_ptrs(key_typ table.TypeSymbol) (string, string, string, st
key_eq_fn = '&map_eq_int_4' key_eq_fn = '&map_eq_int_4'
clone_fn = '&map_clone_int_4' clone_fn = '&map_clone_int_4'
} }
.byteptr, .charptr, .voidptr, .u64, .i64 { .voidptr {
ts := if g.pref.m64 {
&g.table.types[table.u64_type_idx]
} else {
&g.table.types[table.u32_type_idx]
}
return g.map_fn_ptrs(ts)
}
.u64, .i64 {
hash_fn = '&map_hash_int_8' hash_fn = '&map_hash_int_8'
key_eq_fn = '&map_eq_int_8' key_eq_fn = '&map_eq_int_8'
clone_fn = '&map_clone_int_8' clone_fn = '&map_clone_int_8'