mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
Implement panic()
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package runtime
|
||||
|
||||
// #include <stdio.h>
|
||||
// #include <stdlib.h>
|
||||
import "C"
|
||||
|
||||
const Compiler = "tgo"
|
||||
@@ -39,3 +40,19 @@ func printspace() {
|
||||
func printnl() {
|
||||
C.putchar('\n')
|
||||
}
|
||||
|
||||
func printitf(msg interface{}) {
|
||||
switch msg := msg.(type) {
|
||||
case string:
|
||||
print(msg)
|
||||
default:
|
||||
print("???")
|
||||
}
|
||||
}
|
||||
|
||||
func _panic(message interface{}) {
|
||||
printstring("panic: ")
|
||||
printitf(message)
|
||||
printnl()
|
||||
C.exit(1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user