Add ReadModule(), which reads full binary module#35
Merged
Conversation
Previously the only way to read a module was lazily, section by section. That's still the most efficient way to read a module, but if you know that you'll need the full contents anyway, it's nicer to have a function that reads all the sections into their components directly. This change renames `ReadModule` to `ReadLazyModule`, and introduces a new `ReadModule` function that reads into the existing `binary::Module` struct. This required a few other changes: * The binary visitor was accidentally removing some of the locations; * Some module reading errors are only logged to the `wasp::Errors` struct, so you can't easily know whether reading the module succeeded unless you query that struct. The `TextErrors` and `BinaryErrors` derived classes already had this ability (`has_error()`), so now it is a virtual method on `wasp::Errors` too (renamed to `HasError()`)
sbc100
approved these changes
Dec 3, 2020
| protected: | ||
| void HandlePushContext(Location loc, string_view desc); | ||
| void HandlePopContext(); | ||
| void HandleOnError(Location loc, string_view message); |
Member
There was a problem hiding this comment.
Do we not have warning that requires override ?
Member
Author
There was a problem hiding this comment.
I guess not, seems that -Wsuggest-override will do it though.
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.
Previously the only way to read a module was lazily, section by section.
That's still the most efficient way to read a module, but if you know
that you'll need the full contents anyway, it's nicer to have a function
that reads all the sections into their components directly.
This change renames
ReadModuletoReadLazyModule, and introduces anew
ReadModulefunction that reads into the existingbinary::Modulestruct.
This required a few other changes:
The binary visitor was accidentally removing some of the locations;
Some module reading errors are only logged to the
wasp::Errorsstruct, so you can't easily know whether reading the module succeeded
unless you query that struct. The
TextErrorsandBinaryErrorsderived classes already had this ability (
has_error()), so now it is avirtual method on
wasp::Errorstoo (renamed toHasError())