compiler: implement make([]T, ...)

This commit is contained in:
Ayke van Laethem
2018-09-06 09:46:58 +02:00
parent ef2c406127
commit 094c5561b6
3 changed files with 54 additions and 1 deletions
+9 -1
View File
@@ -99,10 +99,18 @@ func lookupBoundsCheck(length, index int) {
}
}
// Check for bounds in *ssa.Slice
// 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()
}
}
// Check for bounds in *ssa.MakeSlice.
func sliceBoundsCheckMake(length, capacity uint) {
if !(0 <= length && length <= capacity) {
printstring("panic: runtime error: slice size out of range\n")
abort()
}
}