Skip to content
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

Enable serialization of source locations for AstSerdeOptions #1211

Closed
wants to merge 106 commits into from

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Jan 23, 2024

This PR implements the additional serialize_source_locations property in the AstSerdeOptions, allowing to choose whether source locations should be serialized.
According to this, serialization of source locations was implemented in the ProgramAst and ModuleAst structures.

bobbinth and others added 30 commits October 11, 2023 21:06
The sentence describing the column $k_0$ had its order reversed, and the
table headers were incorrectly named as $x_i$ and $y_i$ instead of $a_i$
and $b_i$ as described in the introduction.
… info

This commit changes the `import_info` fields of ProgramAst and ModuleAst
to remove the `Option` wrapper, since it does not appear to serve a
specific purpose, and both complicates access to the imports, and
requires redundant code in a few places to access common information
from the imports. It also required fallible checks in a few places where
empty module import info would be suitable as a fallback.

After this change, one can access the ModuleImports struct directly on
both ProgramAst and ModuleAst via the `import_info` function, which
returns a reference to the field. Redundant functions in both structs
were removed if they are already provided by ModuleImports.
docs(mdbook): minor change in the bitwise chiplet
Expand capabilities of the `debug` instruction
…dler

Add `emit` instruction and host event handler
* ContextId type

* propagate MemoryContextId

* fix tests

* MemoryContextId -> ContextId

* move definition

* Remove derive-more dependency

* fix repl

* fmt

* docstring

* import newline

* Remove `Sub` from `ContextId`

* blank line

* section name change

* blank line

* use `ContextId::root()`

* fmt

* memory context -> execution context
@Fumuran Fumuran requested a review from bobbinth January 23, 2024 17:12
@Fumuran Fumuran linked an issue Jan 23, 2024 that may be closed by this pull request
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! Not a full review yet - but I left a few comments inline.

I'm also wondering if we should add something like a minify() method to ProgramAst and ModuleAst. This would basically take the current structures and remove all import and source location data (i.e., data which is not strictly need to compile the code).

assembly/src/ast/serde.rs Outdated Show resolved Hide resolved

// serialize source locations if required
if options.serialize_source_locations {
self.write_source_locations(target);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we get rid of write_source_locations method and move the code here? Is there a reason we'd need it after these chagnes?


// deserialize source locations if required
if options.serialize_source_locations {
module_ast.load_source_locations(source)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above: should we get rid of load_source_locations as a separate method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comments here as above regarding needing load_source_locations and write_source_locations as separate functions (or at least as separate public functions).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these functions (in both ModuleAst and ProgramAst) are used in tests (in assert_correct_program_serialization() and assert_correct_module_serialization functions), so I'm not sure that we should (re)move them. Write and Read functions for ModuleAst are also used in Module in library crate.

Comment on lines 308 to 309
// write the flag whether the source locations should be serialized
target.write_bool(self.has_source_locations);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we replace has_source_locations in MaslLibrary with full serde_options? This way, we treat both options (and potential future options consistently).

@plafer
Copy link
Contributor

plafer commented Apr 29, 2024

@Overcastan are you still working on this?

@bobbinth
Copy link
Contributor

We can probably close this as it will not longer be relevant in MAST-based serialization.

@bobbinth bobbinth closed this Apr 29, 2024
@bobbinth bobbinth deleted the andrew-serialize-source-location branch June 26, 2024 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable serialization of source locations for AstSerdeOptions
9 participants