mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
interp: implement runtime.sliceCopy
This implements the copy() built-in function. It may not work in all cases, but should work in most cases. This commit gets the following 3 packages to compile, according to tinygo-site/imports/main.go: * encoding/base32 * encoding/base64 * encoding/pem (was blocked by encoding/base64)
This commit is contained in:
Vendored
+18
@@ -13,6 +13,11 @@ func main() {
|
||||
println("v5:", len(v5), v5 == nil)
|
||||
println("v6:", v6)
|
||||
println("v7:", cap(v7), string(v7))
|
||||
|
||||
println(uint8SliceSrc[0])
|
||||
println(uint8SliceDst[0])
|
||||
println(intSliceSrc[0])
|
||||
println(intSliceDst[0])
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -30,4 +35,17 @@ var (
|
||||
v5 = map[string]int{}
|
||||
v6 = float64(v1) < 2.6
|
||||
v7 = []byte("foo")
|
||||
|
||||
uint8SliceSrc = []uint8{3, 100}
|
||||
uint8SliceDst []uint8
|
||||
intSliceSrc = []int16{5, 123, 1024}
|
||||
intSliceDst []int16
|
||||
)
|
||||
|
||||
func init() {
|
||||
uint8SliceDst = make([]uint8, len(uint8SliceSrc))
|
||||
copy(uint8SliceDst, uint8SliceSrc)
|
||||
|
||||
intSliceDst = make([]int16, len(intSliceSrc))
|
||||
copy(intSliceDst, intSliceSrc)
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -7,3 +7,7 @@ v4: 0 true
|
||||
v5: 0 false
|
||||
v6: false
|
||||
v7: 3 foo
|
||||
3
|
||||
3
|
||||
5
|
||||
5
|
||||
|
||||
Reference in New Issue
Block a user