@@ -561,6 +561,38 @@ func (v *MapValue) PutString(keyBuf, keyLen, valPtr Value) {
561
561
v .Values = append (v .Values , & LocalValue {v .Eval , value })
562
562
}
563
563
564
+ // PutBinary does a map assign operation.
565
+ func (v * MapValue ) PutBinary (keyPtr , valPtr Value ) {
566
+ if ! v .Underlying .IsNil () {
567
+ panic ("map already created" )
568
+ }
569
+
570
+ var value llvm.Value
571
+ switch valPtr := valPtr .(type ) {
572
+ case * PointerCastValue :
573
+ value = valPtr .Underlying .Load ()
574
+ if v .ValueType .IsNil () {
575
+ v .ValueType = value .Type ()
576
+ if int (v .Eval .TargetData .TypeAllocSize (v .ValueType )) != v .ValueSize {
577
+ panic ("interp: map store value type has the wrong size" )
578
+ }
579
+ } else {
580
+ if value .Type () != v .ValueType {
581
+ panic ("interp: map store value type is inconsistent" )
582
+ }
583
+ }
584
+ default :
585
+ panic ("interp: todo: handle map value pointer" )
586
+ }
587
+
588
+ key := keyPtr .(* PointerCastValue ).Underlying .Load ()
589
+ v .KeyType = key .Type ()
590
+
591
+ // TODO: avoid duplicate keys
592
+ v .Keys = append (v .Keys , & LocalValue {v .Eval , key })
593
+ v .Values = append (v .Values , & LocalValue {v .Eval , value })
594
+ }
595
+
564
596
// Get FNV-1a hash of this string.
565
597
//
566
598
// https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash
0 commit comments