Skip to content

Transpile continue down for firmware below 11.5 - #489

Merged
TwitchBronBron merged 9 commits into
masterfrom
feature/continue-statement
Sep 8, 2026
Merged

TwitchBronBron merged 9 commits into
masterfrom
feature/continue-statement

Conversation

@TwitchBronBron

@TwitchBronBron TwitchBronBron commented Jan 20, 2022 •

Copy link
Copy Markdown
Member

Roku OS 11.5 added continue for/continue while. Before this, a project targeting older firmware could write continue and get output that hard-fails on device.

  • transpiled files rewrite continue into a goto to a label at the end of the loop body; labels are lazy, so loops without a continue emit nothing new
  • files that aren't transpiled (.brs without allowBrighterScriptInBrightScript) get an error instead, since there's nothing to rewrite
  • new CONTINUE_MIN_FIRMWARE_VERSION constant, reusing the existing featureRequiresMinFirmwareVersion diagnostic

The syntax/validation work originally on this branch landed separately in #697; this replaces it with the downlevel support that was still missing.

Verified with npm run test:nocover (3058 passing) and npm run lint.

TwitchBronBron and others added 2 commits September 4, 2026 14:40
# Conflicts:
#	src/DiagnosticMessages.ts
#	src/lexer/TokenKind.ts
#	src/parser/BrsTranspileState.ts
#	src/parser/Parser.ts
#	src/parser/Statement.ts
#	src/parser/tests/statement/Continue.spec.ts
Roku OS 11.5 introduced `continue for`/`continue while`. Projects
targeting older firmware could still write it and get output that
hard-fails on device.

Transpiled files now rewrite each `continue` into a `goto` targeting a
label at the end of the enclosing loop body. Files that aren't
transpiled can't be rewritten, so those get an error instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@TwitchBronBron TwitchBronBron changed the title Feature/continue statement Transpile continue down for firmware below 11.5 Sep 8, 2026
TwitchBronBron and others added 4 commits September 8, 2026 11:53
"Downlevel" is TypeScript-compiler jargon that appeared nowhere else in
this repo. The new name states the firmware fact instead of the action,
matching the plain vocabulary used elsewhere (minFirmwareVersion,
"requires Roku firmware version X").

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Firmware version checks were scattered: BrsTranspileState carried its own
continue getter, BrsFileValidator did inline semver comparisons, and
Parser kept a duplicate 15.3 threshold with its own coercion.

Collect them into one capability table describing what the target
firmware natively understands. These are device facts, not decisions --
each caller still picks its own reaction, and they differ: a missing
continueStatement is transpiled away, while a missing optionalChaining
can only be reported.

getFirmwareCapabilities() takes a raw version string so Parser, which has
no Program reference, can share it; Program caches the result.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The getter re-read program.firmwareCapabilities on every access, implying
the value could change partway through a transpile. It can't -- it's
derived from config. Capture it in the constructor alongside bslibPrefix
and mark it readonly so reassignment is a compile error.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@TwitchBronBron
TwitchBronBron marked this pull request as ready for review September 8, 2026 19:38
@TwitchBronBron
TwitchBronBron merged commit de232a0 into master Sep 8, 2026
10 checks passed
@TwitchBronBron
TwitchBronBron deleted the feature/continue-statement branch September 8, 2026 19:38
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Activity Board Sep 8, 2026
TwitchBronBron added a commit that referenced this pull request Sep 9, 2026
Ports every master commit since 0.73.1 (through 0.73.3). Where master's code
collided with v1's rewrites, v1's architecture wins and the change was
re-implemented against it rather than taken verbatim.

Features ported:
- `continue` transpiles to a goto label for firmware below 11.5 (#489)
- go-to-definition for file path strings in BRS/BS/XML (#1648)
- `isTerminal`/`previousInChain` on AstNode (#1788)
- nested curly braces in template strings (#1539)
- regex literals after `${` and `,` (#1789)
- wrong-cased XML tag diagnostic (#1793)
- duplicate/crashing "find all references" fix (#1791)
- duplicate sourceMappingURL fix (#1786)
- findAncestor type-guard inference (#1787)
- lexer token-text interning (#1712)
- memory-aware default for max worker threads (#1798)
- js-yaml override bumped to ^4.3.2 (#1796)

Notable adaptations:
- master's whitespace fast-path skipped `addToken`, which in v1 is also what
  routes a token into `leadingTrivia`. Kept the Token allocation (trivia depends
  on it) and took only the interning half of that optimization.
- #1798 rewrote WorkerPool around master's simpler worker tracking. v1 has an
  `isDead` crashed-worker feature master lacks, so only the
  `getDefaultMaxWorkerThreads` logic was ported, on top of v1's tracking.
- `no-unsafe-argument` is a warning, not an error: master enabled it after
  cleaning up v0's call sites, and v1's rewrites carry ~76 more that were never
  part of that cleanup.
- three tests from master assert v0 behavior v1 changed on purpose
  (Comment tokens are trivia, `getReferences` returns `[]` not null, and the
  NamespacedVariableNameExpression chain step is gone). Updated to v1's contract.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant