mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
Basic support for slices
This commit is contained in:
+11
-2
@@ -19,11 +19,20 @@ func _panic(message interface{}) {
|
||||
abort()
|
||||
}
|
||||
|
||||
func boundsCheck(outOfRange bool) {
|
||||
if outOfRange {
|
||||
// Check for bounds in *ssa.IndexAddr and *ssa.Lookup.
|
||||
func lookupBoundsCheck(length, index int) {
|
||||
if index < 0 || index >= length {
|
||||
// printstring() here is safe as this function is excluded from bounds
|
||||
// checking.
|
||||
printstring("panic: runtime error: index out of range\n")
|
||||
abort()
|
||||
}
|
||||
}
|
||||
|
||||
// Check for bounds in *ssa.Slice
|
||||
func sliceBoundsCheck(length, low, high uint) {
|
||||
if !(0 <= low && low <= high && high <= length) {
|
||||
printstring("panic: runtime error: slice out of range\n")
|
||||
abort()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user