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

Adds isInstance flag #1187

Merged
merged 2 commits into from
May 15, 2024
Merged

Adds isInstance flag #1187

merged 2 commits into from
May 15, 2024

Conversation

markwpearce
Copy link
Collaborator

Adds the isInstance flag on symbol extra data for when a symbol represents an instance of a type.

This is useful for walking all variable expressions, and being able to check if that expression is an instance of the type or a reference to the actual type (or class constructor).

eg:

class Klass
end class

sub test(k as Klass)  ' k is an instance, Klass is not, but both are of ClassType("klass")
end sub

const finalTypeNameLower = type?.toString().split('.').pop().toLowerCase();
const symbolNameLower = symbol?.name.toLowerCase();
let nameMatchesType = symbolNameLower === finalTypeNameLower;
const isInstance = extraData?.isInstance;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Example of use of the isInstance flag

@TwitchBronBron TwitchBronBron merged commit 94c671e into release-1.0.0 May 15, 2024
5 checks passed
@TwitchBronBron TwitchBronBron deleted the isInstance_flag branch May 15, 2024 16:18
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.

None yet

2 participants