-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Clean up p5.strands transpiler code #8694
Description
Increasing access
In p5.strands, one of the steps in the process of turning your code into shader code is to transpile your JavaScript into slightly different JavaScript using internal p5.strands functions instead of, for example, math operators.
This code started much simpler, with a single pass mapping different Acorn syntax node types to different structure. Now, it involves multiple passes, sometimes building up some info first before doing actual transpilation. It is stretching the organizational limits of the file and could use some cleanup to be easier for contributors to dive into.
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
Feature enhancement details
Ideally I'd like to see the core transpiler function be a lot simpler, deferring each pass to another function. That way we can document what it's doing at a high level in that outermost function in comments, and then gradually get more detailed as we dig into the different pass functions. There's also a number of repeated patterns that we can possibly extract and find some more structure in.
We have pretty good test coverage of the features of p5.strands, so we can feel reasonably certain that a refactor is successful if the tests pass.
Note that this is not a good issue for new contributors, as it deals with relatively advanced code, but help from more established contributors is appreciated!