mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +00:00
compiler, runtime: add layout parameter to runtime.alloc
This layout parameter is currently always nil and ignored, but will eventually contain a pointer to a memory layout. This commit also adds module verification to the transform tests, as I found out that it didn't (and therefore didn't initially catch all bugs).
This commit is contained in:
committed by
Ron Evans
parent
c454568688
commit
f24a93c51d
@@ -57,7 +57,7 @@ func stringConcat(x, y _string) _string {
|
||||
return x
|
||||
} else {
|
||||
length := x.length + y.length
|
||||
buf := alloc(length)
|
||||
buf := alloc(length, nil)
|
||||
memcpy(buf, unsafe.Pointer(x.ptr), x.length)
|
||||
memcpy(unsafe.Pointer(uintptr(buf)+x.length), unsafe.Pointer(y.ptr), y.length)
|
||||
return _string{ptr: (*byte)(buf), length: length}
|
||||
@@ -70,7 +70,7 @@ func stringFromBytes(x struct {
|
||||
len uintptr
|
||||
cap uintptr
|
||||
}) _string {
|
||||
buf := alloc(x.len)
|
||||
buf := alloc(x.len, nil)
|
||||
memcpy(buf, unsafe.Pointer(x.ptr), x.len)
|
||||
return _string{ptr: (*byte)(buf), length: x.len}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func stringToBytes(x _string) (slice struct {
|
||||
len uintptr
|
||||
cap uintptr
|
||||
}) {
|
||||
buf := alloc(x.length)
|
||||
buf := alloc(x.length, nil)
|
||||
memcpy(buf, unsafe.Pointer(x.ptr), x.length)
|
||||
slice.ptr = (*byte)(buf)
|
||||
slice.len = x.length
|
||||
@@ -98,7 +98,7 @@ func stringFromRunes(runeSlice []rune) (s _string) {
|
||||
}
|
||||
|
||||
// Allocate memory for the string.
|
||||
s.ptr = (*byte)(alloc(s.length))
|
||||
s.ptr = (*byte)(alloc(s.length, nil))
|
||||
|
||||
// Encode runes to UTF-8 and store the resulting bytes in the string.
|
||||
index := uintptr(0)
|
||||
|
||||
Reference in New Issue
Block a user