cl: callRuntimeInit; runtime: TracePanic
This commit is contained in:
@@ -19,6 +19,7 @@ package runtime
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/internal/abi"
|
||||
"github.com/goplus/llgo/internal/runtime/c"
|
||||
)
|
||||
|
||||
@@ -27,18 +28,15 @@ func Alloc(size uintptr) unsafe.Pointer {
|
||||
return c.Malloc(size)
|
||||
}
|
||||
|
||||
/*
|
||||
// Panic panics with a value.
|
||||
func Panic(v Interface) {
|
||||
c.Printf(c.String("Panic!!!\n"))
|
||||
// TracePanic prints panic message.
|
||||
func TracePanic(v Interface) {
|
||||
c.Printf(c.Str("Panic(%p)\n"), v.tab._type)
|
||||
kind := abi.Kind(v.tab._type.Kind_)
|
||||
switch {
|
||||
case kind == abi.String:
|
||||
s := (*String)(v.data)
|
||||
cs := c.Alloca(uintptr(s.len) + 1)
|
||||
c.Memcpy(cs, s.data, uintptr(s.len))
|
||||
(*[1 << 30]int8)(cs)[s.len] = 0
|
||||
c.Printf(c.String("%s\n"), cs)
|
||||
c.Printf(c.Str("panic: %s\n"), CStrCopy(cs, *s))
|
||||
}
|
||||
// TODO(xsw): other message type
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user