merge Field/Extract; prog.Tuple/Zero; TypeAssert refactor

This commit is contained in:
xushiwei
2024-05-23 01:10:13 +08:00
parent 6442ab2f20
commit a4c4324ba3
5 changed files with 174 additions and 68 deletions

View File

@@ -160,6 +160,22 @@ func (b Builder) Return(results ...Expr) {
}
}
// The Extract instruction yields component Index of Tuple.
//
// This is used to access the results of instructions with multiple
// return values, such as Call, TypeAssert, Next, UnOp(ARROW) and
// IndexExpr(Map).
//
// Example printed form:
//
// t1 = extract t0 #1
func (b Builder) Extract(x Expr, i int) (ret Expr) {
if debugInstr {
log.Printf("Extract %v, %d\n", x.impl, i)
}
return b.getField(x, i)
}
// Jump emits a jump instruction.
func (b Builder) Jump(jmpb BasicBlock) {
if b.Func != jmpb.fn {