Repository navigation
Transpile continue down for firmware below 11.5 - #489
Merged
Merged
Conversation
TwitchBronBron
force-pushed
the
master
branch
from
October 28, 2022 17:03
ebfb3e5 to
e98ca6d
Compare
# 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>
"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
marked this pull request as ready for review
September 8, 2026 19:38
Merged
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roku OS 11.5 added
continue for/continue while. Before this, a project targeting older firmware could writecontinueand get output that hard-fails on device.continueinto agototo a label at the end of the loop body; labels are lazy, so loops without acontinueemit nothing new.brswithoutallowBrighterScriptInBrightScript) get an error instead, since there's nothing to rewriteCONTINUE_MIN_FIRMWARE_VERSIONconstant, reusing the existingfeatureRequiresMinFirmwareVersiondiagnosticThe 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) andnpm run lint.