mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
avr: use i16 for lengths
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// +build avr
|
||||
|
||||
package runtime
|
||||
|
||||
const GOARCH = "avr"
|
||||
|
||||
// The length type used inside strings and slices.
|
||||
type lenType uint16
|
||||
|
||||
// The bitness of the CPU (e.g. 8, 32, 64).
|
||||
const TargetBits = 8
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build wasm
|
||||
// +build wasm,!avr
|
||||
|
||||
package runtime
|
||||
|
||||
|
||||
@@ -16,15 +16,15 @@ func runtimePanic(msg string) {
|
||||
}
|
||||
|
||||
// Check for bounds in *ssa.Index, *ssa.IndexAddr and *ssa.Lookup.
|
||||
func lookupBoundsCheck(length, index int) {
|
||||
if index < 0 || index >= length {
|
||||
func lookupBoundsCheck(length lenType, index int) {
|
||||
if index < 0 || index >= int(length) {
|
||||
runtimePanic("index out of range")
|
||||
}
|
||||
}
|
||||
|
||||
// Check for bounds in *ssa.Slice.
|
||||
func sliceBoundsCheck(length, low, high uint) {
|
||||
if !(0 <= low && low <= high && high <= length) {
|
||||
func sliceBoundsCheck(length lenType, low, high uint) {
|
||||
if !(0 <= low && low <= high && high <= uint(length)) {
|
||||
runtimePanic("slice out of range")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user