Fix calling methods on pointers to types in other units

This commit is contained in:
Sasha Koshka 2024-03-13 11:51:51 -04:00
parent d2c8fdd05c
commit 0ea05e5836
2 changed files with 6 additions and 8 deletions

View File

@ -62,7 +62,7 @@ func (this *generator) generateMethodCallVal (call *entity.MethodCall) (llvm.Val
if pointerType, ok := call.Source.Type().(*entity.TypePointer); ok {
if sourceType, ok := pointerType.Referenced.(*entity.TypeNamed); ok {
method, err := this.method(entity.Key {
Unit: sourceType.Unit(),
Unit: sourceType.Type.Unit(),
Name: sourceType.Name,
Method: call.Name,
})
@ -72,6 +72,7 @@ func (this *generator) generateMethodCallVal (call *entity.MethodCall) (llvm.Val
args[0] = source
return this.blockManager.NewCall(method, method.Signature, args...), nil
}
if err != nil { return nil, err }
}
}

View File

@ -148,14 +148,11 @@ declare void @"9U3Q1r5tPJSXoVNdBSzCow==::T.method"(ptr %this)
func TestUnitMethodPtr (test *testing.T) {
testUnits (test,
`%"9U3Q1r5tPJSXoVNdBSzCow==::T" = type i64
define void @main() {
`define void @main() {
0:
%1 = alloca %"9U3Q1r5tPJSXoVNdBSzCow==::T"
%2 = alloca ptr
store ptr %1, ptr %2
%3 = load ptr, ptr %2
call void @"9U3Q1r5tPJSXoVNdBSzCow==::T.method"(ptr %3)
%1 = alloca ptr
%2 = load ptr, ptr %1
call void @"9U3Q1r5tPJSXoVNdBSzCow==::T.method"(ptr %2)
ret void
}
declare void @"9U3Q1r5tPJSXoVNdBSzCow==::T.method"(ptr %this)