Skip to content

feat: Identifier and Bool nodes in tinyest - #2973

Draft
aleksanderkatan wants to merge 40 commits into
feat/computed-propertiesfrom
feat/bool-and-ident-nodes
Draft

aleksanderkatan wants to merge 40 commits into
feat/computed-propertiesfrom
feat/bool-and-ident-nodes

Conversation

@aleksanderkatan

@aleksanderkatan aleksanderkatan commented Sep 4, 2026

Copy link
Copy Markdown
Member

Changes:

  • Allow for identifier and boolean nodes to be wrapped in dedicated nodes instead of being plain boolean/string.
  • Add transpile option to use verbose nodes.
  • Update tseynit/obfuscate/wgslGenerator accordingly.

@aleksanderkatan
aleksanderkatan changed the base branch from main to impr/separate-acorn-babel-parsers September 4, 2026 09:50
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/eslint-plugin-typegpu@acaacca2a6c8a8eeb49fb11bbe9eea46e9219c2a
https://pkg.pr.new/software-mansion/TypeGPU/tinyest@acaacca2a6c8a8eeb49fb11bbe9eea46e9219c2a
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@acaacca2a6c8a8eeb49fb11bbe9eea46e9219c2a
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@acaacca2a6c8a8eeb49fb11bbe9eea46e9219c2a
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@acaacca2a6c8a8eeb49fb11bbe9eea46e9219c2a
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@acaacca2a6c8a8eeb49fb11bbe9eea46e9219c2a
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@acaacca2a6c8a8eeb49fb11bbe9eea46e9219c2a

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased (max 0.22%) ❔ Unknown
0 319 6 0

No notable changes.

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Resolution Time Benchmark

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [1.03, 2.15, 5.00, 6.80, 8.22, 12.91, 25.50, 26.19]
  line [0.99, 2.09, 4.30, 7.01, 7.66, 14.15, 27.38, 26.23]
  line [0.98, 1.95, 4.50, 6.33, 7.57, 12.83, 24.54, 24.36]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.29, 0.54, 0.73, 0.89, 1.19, 1.31, 1.51, 1.67]
  line [0.30, 0.49, 0.69, 0.83, 1.18, 1.20, 1.45, 1.59]
  line [0.26, 0.48, 0.71, 0.86, 1.16, 1.18, 1.47, 1.62]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [1.05, 2.59, 4.98, 8.55, 13.47, 28.14, 59.45, 121.06]
  line [0.83, 2.58, 3.87, 7.62, 13.16, 27.77, 59.43, 120.46]
  line [0.95, 2.26, 3.48, 7.06, 12.82, 26.44, 57.18, 114.92]
Loading

@aleksanderkatan aleksanderkatan mentioned this pull request Sep 4, 2026
7 tasks
@cieplypolar
cieplypolar force-pushed the impr/separate-acorn-babel-parsers branch from 7bfa8f1 to 2493b19 Compare September 4, 2026 15:10
@cieplypolar
cieplypolar force-pushed the impr/separate-acorn-babel-parsers branch from 0875f09 to ad791e6 Compare September 4, 2026 15:26
@aleksanderkatan
aleksanderkatan force-pushed the feat/bool-and-ident-nodes branch from f185e99 to bb25ec2 Compare September 14, 2026 12:50
@aleksanderkatan
aleksanderkatan removed this pull request from stack #2976 September 14, 2026 12:51
@aleksanderkatan
aleksanderkatan changed the base branch from impr/separate-acorn-babel-parsers to feat/computed-properties September 14, 2026 12:51
@aleksanderkatan
aleksanderkatan force-pushed the feat/bool-and-ident-nodes branch from bb25ec2 to 80d8699 Compare September 14, 2026 13:17
@aleksanderkatan

Copy link
Copy Markdown
Member Author

@pullfrog review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

Verbose-node support is incomplete in two places. The wgslGenerator one is a latent correctness bug: extractObject never unwraps the new identifier node, so in verboseNodes mode a reassigned variable is not promoted to var and the generator can emit invalid WGSL.

Reviewed changes

Adds dedicated identifier and booleanLiteral nodes to tinyest plus an opt-in verboseNodes transpilation option, then threads the new encoding through the stringifier, the WGSL generator, and the obfuscator.

  • New node typesNodeTypeCatalog gains identifier: 9 and booleanLiteral: 107; Identifier = string | readonly [9, string] and Bool = boolean | readonly [107, boolean], with Expression/Literal/Let/Const/MemberAccess widened to accept both encodings.
  • TranspilationOptions.verboseNodestranspileAcornFn/transpileBabelFn/transpileAcornNode/transpileBabelNode accept options (type exported from the package index); the deprecated transpileFn/transpileNode pass {}.
  • Parser supportIdentifier, external chains, acorn Literal, and babel BooleanLiteral emit the verbose nodes when the option is on.
  • Consumer supporttseynit.stringifyNode, wgslGenerator (_expression, member access, let/const, for...of), and obfuscate handle the new nodes; snapshots cover the transpilers, stringifier, and obfuscator.

ℹ️ No test exercises verbose nodes through codegen

Every added test stops at the transpiler, obfuscator, or stringifier layer; none resolves a verboseNodes AST into WGSL. That is why the extractObject miss above is not caught.

Technical details
# Verbose-path codegen coverage

## Affected sites
- `packages/typegpu/tests/` — no test drives a verbose AST through `WgslGenerator` / `tgpu.resolve`.
- `packages/typegpu/src/tgsl/wgslGenerator.ts:1998``extractObject` only recognizes string identifiers.

## Required outcome
- Add at least one codegen test covering verbose identifiers: a reassignment that must become `var`, and a `for...of` loop variable.

## Open questions for the human
- Is `verboseNodes` intended to become the production encoding (e.g. enabled by the plugin)? If so these wgslGenerator gaps block that step; if it stays test-only they can be follow-up.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

}
}

function extractId(ident: tinyest.Identifier): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

extractId unwraps the new [NODE.identifier, name] shape, but extractObject just above (wgslGenerator.ts:1998) still returns only when typeof object === 'string'. In verboseNodes mode every identifier is a node, so tryMarkModified silently no-ops and a reassigned variable is never added to scope.modifiedVariables, staying let instead of var (wgslGenerator.ts:1160) — invalid WGSL. Unwrap the identifier the same way extractId does.

if (node[0] === NODE.let) {
if (node[2] !== undefined) {
return `${ident}let ${node[1]} = ${stringifyExpression(node[2], ident)};`;
return `${ident}let ${stringifyExpression(node[1], ident)} = ${stringifyExpression(node[2], ident)};`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This branch now routes the binding through stringifyExpression, but the no-initializer branches on lines 42 and 49 still interpolate node[1] directly, and the for...of loop variable on line 76 does the same. With verboseNodes, node[1] is a [9, name] tuple, so they print as let 9,a; and for (const 9,x of …). Route the binding through stringifyExpression in all three spots.

@cieplypolar
cieplypolar force-pushed the feat/computed-properties branch 2 times, most recently from 1c24007 to 5ef352c Compare September 14, 2026 15:54
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.

2 participants