mirror of
https://github.com/golang/go
synced 2024-11-18 16:14:46 -07:00
go/ssa/interp: handle nil *hashmap cleanly
Change-Id: I2cb8eef79bc011b209b3df0b859bcddefd4c8337 Reviewed-on: https://go-review.googlesource.com/32818 Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
2e348630fd
commit
58ec10c513
@ -113,3 +113,11 @@ func (m *hashmap) len() int {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// entries returns a rangeable map of entries.
|
||||
func (m *hashmap) entries() map[int]*entry {
|
||||
if m != nil {
|
||||
return m.table
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -1098,7 +1098,7 @@ func rangeIter(x value, t types.Type) iter {
|
||||
// reflect.(Value).MapKeys machinery.
|
||||
it := make(mapIter)
|
||||
go func() {
|
||||
for _, e := range x.table {
|
||||
for _, e := range x.entries() {
|
||||
for e != nil {
|
||||
it <- [2]value{e.key, e.value}
|
||||
e = e.next
|
||||
|
@ -333,7 +333,7 @@ func ext۰reflect۰Value۰MapKeys(fr *frame, args []value) value {
|
||||
}
|
||||
|
||||
case *hashmap:
|
||||
for _, e := range v.table {
|
||||
for _, e := range v.entries() {
|
||||
for ; e != nil; e = e.next {
|
||||
keys = append(keys, makeReflectValue(tKey, e.key))
|
||||
}
|
||||
@ -365,7 +365,7 @@ func ext۰reflect۰Value۰Pointer(fr *frame, args []value) value {
|
||||
case []value:
|
||||
return reflect.ValueOf(v).Pointer()
|
||||
case *hashmap:
|
||||
return reflect.ValueOf(v.table).Pointer()
|
||||
return reflect.ValueOf(v.entries()).Pointer()
|
||||
case map[value]value:
|
||||
return reflect.ValueOf(v).Pointer()
|
||||
case *ssa.Function:
|
||||
|
@ -384,7 +384,7 @@ func writeValue(buf *bytes.Buffer, v value) {
|
||||
case *hashmap:
|
||||
buf.WriteString("map[")
|
||||
sep := " "
|
||||
for _, e := range v.table {
|
||||
for _, e := range v.entries() {
|
||||
for e != nil {
|
||||
buf.WriteString(sep)
|
||||
sep = " "
|
||||
|
Loading…
Reference in New Issue
Block a user