mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 02:57:46 +00:00
compiler: rewrite defer support to better support them
This costs a bit in code size, but should be more flexible for the future to implement recover() and running deferred functions while panicking.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package runtime
|
||||
|
||||
import "unsafe"
|
||||
|
||||
type deferContext unsafe.Pointer
|
||||
|
||||
type _defer struct {
|
||||
callback func(*_defer)
|
||||
next *_defer
|
||||
}
|
||||
|
||||
func rundefers(stack *_defer) {
|
||||
for stack != nil {
|
||||
stack.callback(stack)
|
||||
stack = stack.next
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user