Skip to content

compiler: accept pointer operand to @export #19446

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

Closed
wants to merge 17 commits into from

Conversation

mlugg
Copy link
Member

@mlugg mlugg commented Mar 26, 2024

This PR is based off of #19437 - I just did that to avoid any potential conflicts, it doesn't strictly need to be. The actual changes here are fairly straightforward.

Starting with e68601d, see commit messages for details.

mlugg added 17 commits March 26, 2024 13:48
`Decl` can no longer store un-interned values, so this field is now
unnecessary. The type can instead be fetched with the new `typeOf`
helper method, which just gets the type of the Decl's `Value`.
…utable memory

Perhaps someday, we will make Sema operate on mutable values more
generally. For now, it makes sense to split out this representation,
since it is only used in comptime pointer accesses.

There are some currently unused methods on `MutableValue` which will
be used once I rewrite the comptime pointer access logic to be less
terrible.

The commit following this one will - at long last - delete the legacy
Value representation
Good riddance!

Most of these changes are trivial. There's a fix for a minor bug this
exposed in `Value.readFromPackedMemory`, but aside from that, it's all
just things like changing `intern` calls to `toIntern`.
This commit also performs some refactors to `TypedValue.print` in
preparation for improved comptime pointer access logic. Once that logic
exists, `TypedValue.print` can use Sema to access pointers for more
helpful printing.

This commit also implements proposal ziglang#19435, because the existing logic
there relied on some blatantly incorrect code in `Value.sliceLen`.

Resolves: ziglang#19435
Legacy anon decls now have three uses:
* Type owner decls
* Function owner decls
* `@export` and `@extern`

Therefore, there are no longer any cases where we wish to explicitly
omit legacy anon decls from the binary. This means we can remove the
concept of an "alive" vs "dead" `Decl`, which also allows us to remove
the separate `anon_work_queue` in `Compilation`.
Now that the legacy `Value` representation is eliminated, we can begin
to phase out the redundant `TypedValue` type.
…n decls

Also removes some unnecessary uses of legacy anon decls for constructing
the array of test functions for the test runner.
The only logic which remained in this file was the Value printing logic.
This has been moved into a new `print_value.zig`.
Notably, this improves string printing from
`@as(*[5:0]u8, &@as([5:0]u8, "hello".*))` to `@as(*[5:0]u8, "hello")`,
omitting the pointless ref-deref pair.
This commit does not yet migrate uses of this builtin.

Resolves: ziglang#14911
Also adds updated test case coverage for invalid uses of @export.
@mlugg mlugg requested a review from Snektron as a code owner March 26, 2024 22:10
@andrewrk
Copy link
Member

andrewrk commented May 9, 2024

looks like this was never finished

@andrewrk andrewrk closed this May 9, 2024
@mlugg mlugg deleted the export-ptr branch May 18, 2025 20:08
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.

2 participants