compiler: add support for the go keyword on interface methods

This is a feature that was long missing, but because of the previous
refactor, it is now trivial to implement.
This commit is contained in:
Ayke van Laethem
2021-10-24 20:58:03 +02:00
committed by Ron Evans
parent a4afc3b4b0
commit 9e1b4de999
6 changed files with 115 additions and 4 deletions
+9 -4
View File
@@ -79,7 +79,15 @@ func (b *builder) createGo(instr *ssa.Go) {
}
b.createBuiltin(argTypes, argValues, builtin.Name(), instr.Pos())
return
} else if !instr.Call.IsInvoke() {
} else if instr.Call.IsInvoke() {
// This is a method call on an interface value.
itf := b.getValue(instr.Call.Value)
itfTypeCode := b.CreateExtractValue(itf, 0, "")
itfValue := b.CreateExtractValue(itf, 1, "")
funcPtr = b.getInvokeFunction(&instr.Call)
params = append([]llvm.Value{itfValue}, params...) // start with receiver
params = append(params, itfTypeCode) // end with typecode
} else {
// This is a function pointer.
// At the moment, two extra params are passed to the newly started
// goroutine:
@@ -99,9 +107,6 @@ func (b *builder) createGo(instr *ssa.Go) {
panic("unknown scheduler type")
}
prefix = b.fn.RelString(nil)
} else {
b.addError(instr.Pos(), "todo: go on interface call")
return
}
paramBundle := b.emitPointerPack(params)