diff options
author | Konstantin Yegupov <[email protected]> | 2019-01-31 01:12:57 +1000 |
---|---|---|
committer | Ayke van Laethem <[email protected]> | 2019-01-31 16:35:22 +0100 |
commit | 504c82a0e7edab55d2c9b326309151a9d7f32750 (patch) | |
tree | 4c0f67b1c90352576701e261d6824daa2a93c586 /interp/values.go | |
parent | f8a1e5f4491b8206b23f351721c9b10e37526c8c (diff) | |
download | tinygo-504c82a0e7edab55d2c9b326309151a9d7f32750.tar.gz tinygo-504c82a0e7edab55d2c9b326309151a9d7f32750.zip |
compiler: support for byte arrays as keys in maps
Diffstat (limited to 'interp/values.go')
-rw-r--r-- | interp/values.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/interp/values.go b/interp/values.go index c4f6e302d..a6b5336aa 100644 --- a/interp/values.go +++ b/interp/values.go @@ -451,6 +451,13 @@ func (v *MapValue) Value() llvm.Value { keyBuf[i] = byte(n) n >>= 8 } + } else if key.Type().TypeKind() == llvm.ArrayTypeKind && + key.Type().ElementType().TypeKind() == llvm.IntegerTypeKind && + key.Type().ElementType().IntTypeWidth() == 8 { + keyBuf = make([]byte, v.Eval.TargetData.TypeAllocSize(key.Type())) + for i := range keyBuf { + keyBuf[i] = byte(llvm.ConstExtractValue(llvmKey, []uint32{uint32(i)}).ZExtValue()) + } } else { panic("interp: map key type not implemented: " + key.Type().String()) } |