compiler: support for byte arrays as keys in maps

This commit is contained in:
Konstantin Yegupov
2019-01-31 01:12:57 +10:00
committed by Ayke van Laethem
parent f8a1e5f449
commit 504c82a0e7
4 changed files with 25 additions and 0 deletions
+7
View File
@@ -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())
}