-
Notifications
You must be signed in to change notification settings - Fork 951
compiler: add support for the go keyword on interface methods #2202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4abe316
to
e2f6ad2
Compare
Updated to fix merge conflicts and (hopefully) fix the CI failures. |
This commit simplifies the IR a little bit: instead of calling pseudo-functions runtime.interfaceImplements and runtime.interfaceMethod, real declared functions are being called that are then defined in the interface lowering pass. This should simplify the interaction between various transformation passes. It also reduces the number of lines of code, which is generally a good thing.
This is a feature that was long missing, but because of the previous refactor, it is now trivial to implement.
e2f6ad2
to
d3043c7
Compare
uintptrType := mod.Context().IntType(llvm.NewTargetData(mod.DataLayout()).PointerSize() * 8) | ||
|
||
defer llvm.VerifyModule(mod, llvm.PrintMessageAction) | ||
// Look up the (reflect.Value).Implements() method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I am missing something: why can't we look this function up by name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is named something like interface:{Align:func:{}{basic:int},AssignableTo:func:{named:reflect.Type}{basic:bool},Bits:func:{}{basic:int},Comparable:func:{}{basic:bool},ConvertibleTo:func:{named:reflect.Type}{basic:bool},Elem:func:{}{named:reflect.Type},Field:func:{basic:int}{named:reflect.StructField},FieldAlign:func:{}{basic:int},Implements:func:{named:reflect.Type}{basic:bool},Key:func:{}{named:reflect.Type},Kind:func:{}{named:reflect.Kind},Len:func:{}{basic:int},Name:func:{}{basic:string},NumField:func:{}{basic:int},NumMethod:func:{}{basic:int},Size:func:{}{basic:uintptr},String:func:{}{basic:string}}.Implements$invoke
and therefore depends on the precise set of methods in src/reflect/type.go.
So yeah, we could check that name directly, but every change to the reflect.Type
interface would also need a change here. Doable, but kind of a burden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think I misunderstood what this was doing. Alright.
I think most of this looks fine, just a bit confused (see the question i posted above) |
Might have been better to rebase @aykevl can you please take a look? Thanks! |
Most of this PR is a refactor of interface lowering, to make future changes possible. The result of it is that it is now trivial to add support for the go keyword on interface methods, as requested in #1961.