Implement panic()

This commit is contained in:
Ayke van Laethem
2018-04-20 23:59:55 +02:00
parent d812873e60
commit db66039dfe
2 changed files with 29 additions and 0 deletions
+17
View File
@@ -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)
}