Basic support for slices

This commit is contained in:
Ayke van Laethem
2018-08-18 20:05:58 +02:00
parent 86a3aea868
commit 8b6cb204cd
4 changed files with 172 additions and 51 deletions
+11 -2
View File
@@ -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()
}
}