Type assertion: add support for 2nd return value

This commit is contained in:
Marc Vertes
2018-12-01 17:56:55 +01:00
parent c75807dec9
commit 487e24e829
5 changed files with 110 additions and 4 deletions

View File

@@ -90,6 +90,27 @@ func typeAssert(n *Node) {
}
}
func typeAssert2(n *Node) {
value := genValue(n.child[0]) // input value
value0 := genValue(n.anc.child[0]) // returned result
value1 := genValue(n.anc.child[1]) // returned status
next := getExec(n.tnext)
if n.child[0].typ.cat == ValueT {
n.exec = func(f *Frame) Builtin {
value0(f).Set(value(f).Elem())
value1(f).SetBool(true)
return next
}
} else {
n.exec = func(f *Frame) Builtin {
value0(f).Set(value(f))
value1(f).SetBool(true)
return next
}
}
}
func convert(n *Node) {
i := n.findex
var value func(*Frame) reflect.Value