enable closures tests for JS & implement finished for JS (#23521)

This commit is contained in:
ringabout
2024-09-09 20:20:40 +08:00
committed by GitHub
parent fcee829d85
commit 3a55bae53f
13 changed files with 79 additions and 28 deletions

View File

@@ -2350,8 +2350,14 @@ when notJSnotNims:
`result` = `x`.ClE_0;
""".}
proc finished*[T: iterator {.closure.}](x: T): bool {.noSideEffect, inline, magic: "Finished".} =
## It can be used to determine if a first class iterator has finished.
proc finished*[T: iterator {.closure.}](x: T): bool {.noSideEffect, inline, magic: "Finished".} =
## It can be used to determine if a first class iterator has finished.
when defined(js):
# TODO: mangle `:state`
{.emit: """
`result` = (`x`.ClE_0).HEX3Astate < 0;
""".}
else:
{.emit: """
`result` = ((NI*) `x`.ClE_0)[1] < 0;
""".}