Skip to content

[ParseableInterfaces] Handle lazy vars #21996

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

Merged
merged 3 commits into from
Jan 22, 2019

Conversation

harlanhaskins
Copy link
Contributor

For lazy vars, we need to make public the top-level entry point, and the fact that the lazy storage contributes to the layout of a type (if it’s fixed layout, or if the type is not resilient.) We also shouldn’t ever print lazy in a parseable interface.

Since we need to parse these identifiers, give them a new name, $__lazy_storage_{propname}, which is parseable only in parseable interfaces so it doesn’t conflict with other properties.

@harlanhaskins
Copy link
Contributor Author

The first commit is kinda noisy, so I'd recommend reviewing commit-by-commit.

@harlanhaskins
Copy link
Contributor Author

I also need to write a client test for this, which I will do in a follow-up PR that also re-enables test/ParseableInterfaces/stored-properties-client.swift.

SmallString<64> NameBuf = VD->getName().str();
NameBuf += ".storage";
SmallString<64> NameBuf;
NameBuf += "$__lazy_storage_";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: maybe separate the prefix from the name even harder? ObjC does _$_ between sections, so __lazy_storage_$_foo or $__lazy_storage_$_foo. The former also makes it even less likely to conflict with a debugger variable, which probably only has the $ at the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm hesitant to write it without the $ at the beginning, as that makes it a valid identifier. Do you think the potential name conflict matters there?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I forgot we allowed $ in non-initial positions. Okay.

Harlan Haskins added 3 commits January 22, 2019 11:02
Previously, the Lexer kept a single flag whether we’re lexing Swift or SIL. Instead, keep track if we’re parsing Swift, SIL, or a Swiftinterface file. .swiftinterface files allow $-prefixed identifiers anywhere.
We’re printing a new name for lazy storage in parseable interfaces,
`$__lazy_storage_$_{propname}`. This is intentionally $-prefixed so it cannot
conflict with variables written in source, but it doesn’t use a `.` anymore
because parseable interfaces need to be...parseable.
For lazy vars, we need to make public the top-level entry point, and the fact
that the lazy storage contributes to the layout of a type (if it’s fixed
layout, or if the type is not resilient.) We also shouldn’t ever print `lazy`
in a parseable interface.

Since we need to parse these identifiers, give them a new name,
`$__lazy_storage_$_{propname}`, which is parseable only in parseable interfaces
so it doesn’t conflict with other properties.
@harlanhaskins
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - fbc0bb5d439deeaee447a3c939cf7d16cc2a2683

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - fbc0bb5d439deeaee447a3c939cf7d16cc2a2683

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.

3 participants