-
Notifications
You must be signed in to change notification settings - Fork 323
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
Generate BuiltinMethods from simple method and constructor signatures #3444
Conversation
A low-hanging fruit where we can automate the generation of many @BuiltinMethod nodes simply from the runtime's methods signatures. This change introduces another annotation, @Builtin, to distinguish from @BuiltinType and @BuiltinMethod processing. @Builtin processing will always be the first stage of processing and its output will be fed to the latter. Note that the return type of Array.length() is changed from `int` to `long` because we probably don't want to add a ton of specializations for the former (see comparator nodes for details) and it is fine to cast it in a small number of places. Progress is visible in the number of deleted hardcoded classes. This is an incremental step towards #181499077.
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.
Nice.
lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/BuiltinsProcessor.java
Outdated
Show resolved
Hide resolved
lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/BuiltinsProcessor.java
Outdated
Show resolved
Hide resolved
out.println("import " + ownerClazz.fullyQualifiedName() + ";"); | ||
out.println(); | ||
out.println( | ||
"@BuiltinMethod(type = \"" |
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.
A processor that generates code for another processor - that's metacyclic!
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.
lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/BuiltinsProcessor.java
Outdated
Show resolved
Hide resolved
Overriding supported version in processors manually is the only way to keep it quiet when using Frgaal. Thanks for the suggestion Jaroslav!
Extended the initial approach to also generate `Foo.new` builtin methods when @Builtin is added to the constructor. `NewNode` for `Array` is now gone. For consistency, the generated one will now be called `NewArrayNode`.
Now also handling simple constructors = profit! |
This is the 2nd part of DSL improvements that allow us to generate a lot of builtins-related boilerplate code. - [x] generate multiple method nodes for methods/constructors with varargs - [x] expanded processing to allow for @Builtin to be added to classes and and generate @BuiltinType classes - [x] generate code that wraps exceptions to panic via `wrapException` annotation element (see @Builtin.WrapException` Also rewrote @Builtin annotations to be more structured and introduced some nesting, such as @Builtin.Method or @Builtin.WrapException. This is part of incremental work and a follow up on #3444. # Important Notes Notice the number of boilerplate classes removed to see the impact. For now only applied to `Array` but should be applicable to other types.
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.
Awesome! Not sure about the pkg
field though, any way for us to get rid of it? And just slap these "somewhere" by convention?
Pull Request Description
A low-hanging fruit where we can automate the generation of many
@BuiltinMethod nodes simply from the runtime's methods signatures.
This change introduces another annotation, @Builtin, to distinguish from
@BuiltinType and @BuiltinMethod processing. @Builtin processing will
always be the first stage of processing and its output will be fed to
the latter.
Note that the return type of Array.length() is changed from
int
tolong
because we probably don't want to add a ton of specializationsfor the former (see comparator nodes for details) and it is fine to cast
it in a small number of places.
Progress is visible in the number of deleted hardcoded classes.
This is an incremental step towards #181499077.
Important notes
This process does not attempt to cover all cases. Not yet, at least.
We only handle simple methods and constructors (see removed
Array
boilerplate methods).Checklist
Please include the following checklist in your PR:
./run dist
and./run watch
.