mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 16:33:40 +00:00
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:
committed by
Ron Evans
parent
a4afc3b4b0
commit
9e1b4de999
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user