-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update KaitaiStruct compiler and runtime to 0.9 #16
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't like this entire invocation, but I understand that Java does not support default parameter values, so it cannot be made much better. Assigning
null
to everything can cause errors if there would be an attempt to use theconfig
for some other compiler class thanJavaCompiler
, but so far, so good.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.
The config is intended to use with the
JavaCompiler
only, there is not supposed to call it for other languages, we need it is only for getting the Java code for compilation.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 understand, and the actual form looks kind of OK given the circumstances, but there is a hidden assumption that the
RuntimeConfig
object will tolerate being in partially-invalid state (for example in Scala, it would not be possible to passnull
to a param with typeString
orCppRuntimeConfig
).We know this is not a problem because we can inspect the compiler code and find out that the
JavaCompiler
only reads propertiesconfig.{java,readStoresPos,autoRead}
,Main.importAndPrecompile()
only readsconfig.opaqueTypes
andMain.compile()
only passes theconfig
toJavaCompiler
(evenvutally overridingdebug
if/meta/ks-debug
is set). But I don't like that these assumptions are hidden. If you could write a short comment that such initializedRuntimeConfig
can only be used to initializeJavaCompiler
, I would be more happy about that.In an ideal world, Java would support default parameter values and named parameters, so you could do just
new RuntimeConfig(autoRead = false, readStoresPos = true, opaqueTypes = true, java = new JavaRuntimeConfig(...))
, not care about other values and they would be filled with sensible defaults set inRuntimeConfig.scala:91-103
- so it would be safe. But this is unfortunately not the case.