
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.
74 строки
1,1 КиБ
Text
74 строки
1,1 КиБ
Text
map length: 2
|
|
map read: answer = 42
|
|
answer = 42
|
|
foo = 3
|
|
map length: 1
|
|
map read: data = 3
|
|
data = 3
|
|
map length: 12
|
|
map read: three = 3
|
|
eight = 8
|
|
eleven = 11
|
|
five = 5
|
|
four = 4
|
|
nine = 9
|
|
one = 1
|
|
seven = 7
|
|
six = 6
|
|
ten = 10
|
|
three = 3
|
|
twelve = 12
|
|
two = 2
|
|
map length: 12
|
|
map read: ten = 10
|
|
eight = 8
|
|
eleven = 11
|
|
five = 5
|
|
four = 4
|
|
nine = 9
|
|
one = 1
|
|
seven = 7
|
|
six = 6
|
|
ten = 10
|
|
three = 3
|
|
twelve = 12
|
|
two = 2
|
|
map length: 11
|
|
map read: seven = 7
|
|
eight = 8
|
|
eleven = 11
|
|
five = 5
|
|
four = 4
|
|
nine = 9
|
|
one = 1
|
|
seven = 7
|
|
ten = 10
|
|
three = 3
|
|
twelve = 12
|
|
two = 2
|
|
lookup with comma-ok: eight 8 true
|
|
lookup with comma-ok: nokey 0 false
|
|
false true 2
|
|
true false 0
|
|
nilmap: 0
|
|
4
|
|
42
|
|
4321
|
|
5555
|
|
itfMap[3]: 0
|
|
itfMap[3.14]: 3
|
|
itfMap[8]: 8
|
|
itfMap[uint8(8)]: 80
|
|
itfMap["eight"]: 800
|
|
itfMap[[2]int{5, 2}]: 52
|
|
itfMap[true]: 1
|
|
itfMap[8]: 0
|
|
floatMap[42]: 84
|
|
floatMap[43]: 0
|
|
floatMap[42]: 0
|
|
structMap[{"tau", 6.28}]: 5
|
|
structMap[{"Tau", 6.28}]: 0
|
|
structMap[{"tau", 3.14}]: 0
|
|
structMap[{"tau", 6.28}]: 0
|
|
tested preallocated map
|
|
tested growing of a map
|