| 759 | } |
| 760 | |
| 761 | func indexMap(sctx *super.Context, typ *super.TypeMap, mapBytes scode.Bytes, key super.Value) super.Value { |
| 762 | if key.IsMissing() { |
| 763 | return sctx.Missing() |
| 764 | } |
| 765 | if key.Type() != typ.KeyType { |
| 766 | if union, ok := super.TypeUnder(typ.KeyType).(*super.TypeUnion); ok { |
| 767 | if tag := union.TagOf(key.Type()); tag >= 0 { |
| 768 | var b scode.Builder |
| 769 | super.BuildUnion(&b, union.TagOf(key.Type()), key.Bytes()) |
| 770 | if valBytes, ok := lookupKey(mapBytes, b.Bytes().Body()); ok { |
| 771 | return deunion(typ.ValType, valBytes) |
| 772 | } |
| 773 | } |
| 774 | } |
| 775 | return sctx.Missing() |
| 776 | } |
| 777 | if valBytes, ok := lookupKey(mapBytes, key.Bytes()); ok { |
| 778 | return deunion(typ.ValType, valBytes) |
| 779 | } |
| 780 | return sctx.Missing() |
| 781 | } |
| 782 | |
| 783 | func deunion(typ super.Type, b scode.Bytes) super.Value { |
| 784 | if union, ok := typ.(*super.TypeUnion); ok { |