Doesn't do anything useful yet as running deferred calls are not
executed during panic. Only implemented to get code to compile.
Этот коммит содержится в:
Ayke van Laethem 2018-10-20 18:00:12 +02:00
родитель 7c2a6169b0
коммит 239504d9f4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED
2 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -1787,6 +1787,8 @@ func (c *Compiler) parseBuiltin(frame *Frame, args []ssa.Value, callName string)
c.createRuntimeCall("printnl", nil, "") c.createRuntimeCall("printnl", nil, "")
} }
return llvm.Value{}, nil // print() or println() returns void return llvm.Value{}, nil // print() or println() returns void
case "recover":
return c.createRuntimeCall("_recover", nil, ""), nil
case "ssa:wrapnilchk": case "ssa:wrapnilchk":
// TODO: do an actual nil check? // TODO: do an actual nil check?
return c.parseExpr(frame, args[0]) return c.parseExpr(frame, args[0])

Просмотреть файл

@ -15,6 +15,13 @@ func runtimePanic(msg string) {
abort() abort()
} }
// Try to recover a panicking goroutine.
func _recover() interface{} {
// Deferred functions are currently not executed during panic, so there is
// no way this can return anything besides nil.
return nil
}
// Check for bounds in *ssa.Index, *ssa.IndexAddr and *ssa.Lookup. // Check for bounds in *ssa.Index, *ssa.IndexAddr and *ssa.Lookup.
func lookupBoundsCheck(length lenType, index int) { func lookupBoundsCheck(length lenType, index int) {
if index < 0 || index >= int(length) { if index < 0 || index >= int(length) {