runtime: move panic functions to a separate file
Этот коммит содержится в:
родитель
65358ed3c9
коммит
01635b5efd
2 изменённых файлов: 34 добавлений и 33 удалений
34
src/runtime/panic.go
Обычный файл
34
src/runtime/panic.go
Обычный файл
|
@ -0,0 +1,34 @@
|
|||
package runtime
|
||||
|
||||
func _panic(message interface{}) {
|
||||
printstring("panic: ")
|
||||
printitf(message)
|
||||
printnl()
|
||||
abort()
|
||||
}
|
||||
|
||||
// Check for bounds in *ssa.Index, *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()
|
||||
}
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
}
|
|
@ -81,36 +81,3 @@ func memequal(x, y unsafe.Pointer, n uintptr) bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func _panic(message interface{}) {
|
||||
printstring("panic: ")
|
||||
printitf(message)
|
||||
printnl()
|
||||
abort()
|
||||
}
|
||||
|
||||
// Check for bounds in *ssa.Index, *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()
|
||||
}
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче