interp: remove map support

The interp package is in many cases able to execute map functions in the
runtime directly. This is probably slower than adding special support
for them in the interp package and also doesn't cover all cases (most
importantly, map keys that contain pointers) but removing this code also
removes a large amount of code that needs to be maintained and is
susceptible to hard-to-find bugs.

As a side effect, this resulted in different output of the
testdata/map.go test because the test relied on the existing iteration
order of TinyGo maps. I've updated the test to not rely on this test,
making the output compatible with what the Go toolchain would output.
This commit is contained in:
Ayke van Laethem
2021-04-20 23:40:16 +02:00
committed by Ron Evans
parent c1c3be1aa7
commit 768a15c1dd
7 changed files with 35 additions and 472 deletions
+9 -1
View File
@@ -1,5 +1,7 @@
package main
import "sort"
var testmap1 = map[string]int{"data": 3}
var testmap2 = map[string]int{
"one": 1,
@@ -112,7 +114,13 @@ func main() {
func readMap(m map[string]int, key string) {
println("map length:", len(m))
println("map read:", key, "=", m[key])
for k, v := range m {
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
v := m[k]
println(" ", k, "=", v)
}
}