-
Notifications
You must be signed in to change notification settings - Fork 379
[WIP] Support embedding of inline source strings in NIR #1632
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
base: main
Are you sure you want to change the base?
Conversation
|
Related: #657 |
|
This reminds me of "inline-c" for GHC haskell. Which has definitely been proved to be useful. The name "ExternalSource" sounds odd to me. The How about mirroring haskell and using "InlineSource"? |
|
@coreyoconnor good point, I didn't put too much thought into it. I'll go with your proposal. |
- add new annotation InlineSource(source,language) - add new NIR tag InlineSource - handle tag in BinarySerializer/BinaryDeserializer - collect all InlineSource attrs during linking - add Config.inlineSourceHooks; registered hooks are called with the list of InlineSource attrs after optimization is completed - provide sbt settingKey nativeInlineSourcesHooks to register hooks that should be called after optimization is completed
6b94630 to
588c924
Compare
|
Do we need this at this point? |
|
Honestly I feel like this would be a good idea if the annotations were on functions – for cases where there is naked struct passing the forwarders are very mechanical and I wish they just lived in the Scala source as well, instead of having to ship a C file: https://gist.github.com/keynmol/642af3a015d3aa05cefdadfb8635f5d3#file-clay-glue-c-L9-L12 |
|
sn-bindgen would still need to generate c source code, just in a different place, without autocomplete, source highlighting, etc. |
Description:
This PR provides a new annotation
InlineSource(language: String, source: String)which allows to embed source snippets into the NIR generated for a class or object, e.g.These source snippets can then be processed with sbt plugins by registering an
InlineSourceHookto the task keynativeInlineSourceHooks.Use Cases:
InlineSourcesnippet that contains the C wrapper around some C++ type).Changes:
InlineSource(source,language)InlineSrcAttr