-
-
Notifications
You must be signed in to change notification settings - Fork 48
fix: intermediate representation of array expression #2021
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
base: main
Are you sure you want to change the base?
Conversation
|
pkg.pr.new packages benchmark commit |
…sion/TypeGPU into fix/arrayExpr-resolve-delay
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (330 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
| return snip(value, UnknownData, /* origin */ 'constant'); | ||
| } | ||
|
|
||
| // defers the resolution of array expressions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either JSDoc or remove IMO
| constructor( | ||
| public readonly elementType: AnyWgslData, | ||
| public readonly type: AnyWgslData, | ||
| public readonly elements: Snippet[], | ||
| ) { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| constructor( | |
| public readonly elementType: AnyWgslData, | |
| public readonly type: AnyWgslData, | |
| public readonly elements: Snippet[], | |
| ) { | |
| } | |
| constructor( | |
| public readonly type: WgslArray<AnyWgslData>, | |
| public readonly elements: Snippet[], | |
| ) {} |
| } | ||
|
|
||
| const arrayType = `array<${ | ||
| ctx.resolve(this.elementType).value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ctx.resolve(this.elementType).value | |
| ctx.resolve(this.type.elementType).value |
| stitch`${arrayType}(${values})`, | ||
| arrayOf(elemType as wgsl.AnyWgslData, values.length), | ||
| new ArrayExpression( | ||
| elemType as wgsl.AnyWgslData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information is redundant since the arrayType contains it
| elemType as wgsl.AnyWgslData, |
Before:
NODE.arrayExprwas encountered in the wgsl generator. Since the resulting snippet's value was a string, we couldn't really access array values.Now:
NODE.arrayExprreturns an intermediate representation (ArrayExpression). Thereby, we delayed its resolution.Additional changes:
NODE.callArrayExpressionNODE.callCloses #2017.