defer support; llgo/ssa: IfThen
This commit is contained in:
25
cl/_testgo/defer/in.go
Normal file
25
cl/_testgo/defer/in.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
func f(s string) bool {
|
||||
return len(s) > 5
|
||||
}
|
||||
|
||||
func fail() {
|
||||
panic("error")
|
||||
}
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
println("hi")
|
||||
if e := recover(); e != nil {
|
||||
println(e.(string))
|
||||
}
|
||||
}()
|
||||
if s := "hello"; f(s) {
|
||||
defer println(s)
|
||||
} else {
|
||||
defer println("world")
|
||||
fail()
|
||||
}
|
||||
defer println("bye")
|
||||
}
|
||||
0
cl/_testgo/defer/out.ll
Normal file
0
cl/_testgo/defer/out.ll
Normal file
@@ -796,6 +796,8 @@ func (p *context) compileInstr(b llssa.Builder, instr ssa.Instruction) {
|
||||
key := p.compileValue(b, v.Key)
|
||||
val := p.compileValue(b, v.Value)
|
||||
b.MapUpdate(m, key, val)
|
||||
case *ssa.Defer:
|
||||
p.call(b, llssa.Defer, &v.Call)
|
||||
case *ssa.Go:
|
||||
p.call(b, llssa.Go, &v.Call)
|
||||
case *ssa.Panic:
|
||||
|
||||
Reference in New Issue
Block a user