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

5.0.0: Rename utility functions breaking API change #30

Merged
merged 6 commits into from
Jul 28, 2024
Merged

Conversation

AndrewRayCode
Copy link
Collaborator

@AndrewRayCode AndrewRayCode commented Jul 7, 2024

This introduces breaking changs to the utility API functions renameBindings, renameFunctions, and renameTypes and changes their signatures to take the specific scope index, rather than the full scope.

This also changes the signature of the mangle() function to no longer be passed the AST node in question to be mangled. @shaderfrog/core used this as a hack to set a property directly on AST nodes (.doNotDescope) to avoid other functions from touching it.

It also exports new individual utility functions renameBinding etc, and a helper debug function.

These changes are largely in service of @shaderfrog/core to support better AST manipulation by allowing for the renameFunctions to modify scope indices. This is to keep the scopes in sync with the manipulated AST, which allows for more utility functions to work on scope, and avoid re-visiting an AST to find variables after an AST manipulation.

@AndrewRayCode AndrewRayCode changed the title Changing rename functions to also rename the scope index, and not mutate 5.0.0: Rename utility functions breaking API change Jul 28, 2024
]);
expect(ast.scopes[0].types.StructName.references).toHaveLength(16);
expect(ast.scopes[0].types.StructName_x.references).toHaveLength(16);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

:) so much nicer

@AndrewRayCode AndrewRayCode merged commit 62017d8 into main Jul 28, 2024
1 check passed
@AndrewRayCode AndrewRayCode deleted the rename-beta branch July 28, 2024 20: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.

1 participant