mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
d8b6b257f4
This simplifies the process of constructing and encoding layout bitmaps. Instead of creating big integers and merging them, we can create a pre-sized bitmap and set positions within it. This also changes the encoding logic to allow larger layouts to be encoded inline. We would previously not encode a layout inline unless the size was less than the width of the data field. This is overly conservative. A layout can be encoded inline as long as: 1. The size fits within the size field. 2. All set bits in the bitmap fit into the data field.
84 lines
1.1 KiB
Go
84 lines
1.1 KiB
Go
package main
|
|
|
|
var (
|
|
scalar1 *byte
|
|
scalar2 *int32
|
|
scalar3 *int64
|
|
scalar4 *float32
|
|
|
|
array1 *[3]byte
|
|
array2 *[71]byte
|
|
array3 *[3]*byte
|
|
|
|
struct1 *struct{}
|
|
struct2 *struct {
|
|
x int
|
|
y int
|
|
}
|
|
struct3 *struct {
|
|
x *byte
|
|
y [60]uintptr
|
|
z *byte
|
|
}
|
|
struct4 *struct {
|
|
x *byte
|
|
y [61]uintptr
|
|
}
|
|
struct5 *struct {
|
|
x *byte
|
|
y [30]uintptr
|
|
}
|
|
|
|
slice1 []byte
|
|
slice2 []*int
|
|
slice3 [][]byte
|
|
)
|
|
|
|
func newScalar() {
|
|
scalar1 = new(byte)
|
|
scalar2 = new(int32)
|
|
scalar3 = new(int64)
|
|
scalar4 = new(float32)
|
|
}
|
|
|
|
func newArray() {
|
|
array1 = new([3]byte)
|
|
array2 = new([71]byte)
|
|
array3 = new([3]*byte)
|
|
}
|
|
|
|
func newStruct() {
|
|
struct1 = new(struct{})
|
|
struct2 = new(struct {
|
|
x int
|
|
y int
|
|
})
|
|
struct3 = new(struct {
|
|
x *byte
|
|
y [60]uintptr
|
|
z *byte
|
|
})
|
|
struct4 = new(struct {
|
|
x *byte
|
|
y [61]uintptr
|
|
})
|
|
struct5 = new(struct {
|
|
x *byte
|
|
y [30]uintptr
|
|
})
|
|
}
|
|
|
|
func newFuncValue() *func() {
|
|
return new(func())
|
|
}
|
|
|
|
func makeSlice() {
|
|
slice1 = make([]byte, 5)
|
|
slice2 = make([]*int, 5)
|
|
slice3 = make([][]byte, 5)
|
|
}
|
|
|
|
func makeInterface(v complex128) interface{} {
|
|
return v // always stored in an allocation
|
|
}
|