Fix a number of errors in loops#308
Open
Mingun wants to merge 17 commits intokaitai-io:masterfrom
Open
Conversation
|
Thank you for fixing this and closing the PR. I apologize for not following up on my PR last year. I'm happy we have this consistent behavior across languages. |
… special variables in expressions
… `SwitchIfOps.switchCases` PerlCompiler implements SwitchIfOps so this call already was performed
…on place <each changed compiler> extends EveryReadIsExpression extends CommonReads GoCompiler extends GoReads extends CommonReads
…et in `CommonReads.attrParse0`
…d here If that not the case, then a bug in compiler is present. Exception is better rather than generating incorrect code
…e it only can be used We do not want that type validation calculate type of actually undefined variable
The `_` variable used not only as getter to the last parsed value in repeat-until expression, but also as getter of the value to check in the `valid` expression. So it is better to name this field as just "type of the `_`"
Previous behavior (everything with 1 in last column was fixed): |Language|Initial|Incremented|`_index` of first iteration |--------|-------|-----------|--------------------------- |C++ |0 |before |1 |C# |0 |before |1 |Go |1 |after |1 |Java |0 |before |1 |JS |0 |before |1 |Lua |0 |after |0 |Nim |0? |after |0 (variable declared without initializer) |Perl |- |- |- (variable was not declared) |PHP |0 |before |1 |Python |0 |after |0 |Ruby |0 |before |1 |Rust |0 |before |1 Fixes kaitai-io/kaitai_struct#958
…ndRepeatExprHeader` and `condRepeatExprFooter`
…_io` is redefined
…dRepeatEosHeader` and `condRepeatEosFooter`
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR the result of revision of how generation of repeated attributes is implemented due to which a number of bugs was found and fixed:
TypeValidatorincorrectly define_variable for all kinds of loops, but it is generated only forrepeat-untilloopsrepeat-exprloops on each iteration, whereas other languages performs such calculations only once. Now they are also calculate count only once_indexvariable inrepeat: eosloopsio: ...is usedThis PR supersedes #234
Also, some refactoring was done: removed unused parameters and documented methods that generates loops.
Besides,
_currentIteratorTypewas renamed to_typeOfUnderscore(this is the variable that holds type of the_variable in expression language) because it is used also invalid: exprkey to refer to the element that just was parsed.