diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2024-09-09 20:20:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-09 14:20:40 +0200 |
commit | 3a55bae53fe80728ce625dd5366aee5da9cf6463 (patch) | |
tree | 0f1855da16e640c1d20037d2b66f117d06105c4b /compiler | |
parent | fcee829d85605d6d401f15966a283b0041631308 (diff) | |
download | Nim-3a55bae53fe80728ce625dd5366aee5da9cf6463.tar.gz |
enable closures tests for JS & implement `finished` for JS (#23521)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/jsgen.nim | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 91862777a..713944def 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -611,6 +611,17 @@ template unaryExpr(p: PProc, n: PNode, r: var TCompRes, magic, frmt: string) = r.res = frmt % [a, tmp] r.kind = resExpr +proc genBreakState(p: PProc, n: PNode, r: var TCompRes) = + var a: TCompRes = default(TCompRes) + # mangle `:state` properly somehow + if n.kind == nkClosure: + gen(p, n[1], a) + r.res = "(($1).HEX3Astate < 0)" % [rdLoc(a)] + else: + gen(p, n, a) + r.res = "((($1.ClE_0).HEX3Astate) < 0)" % [rdLoc(a)] + r.kind = resExpr + proc arithAux(p: PProc, n: PNode, r: var TCompRes, op: TMagic) = var x, y: TCompRes = default(TCompRes) @@ -3054,16 +3065,7 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) = of nkGotoState, nkState: globalError(p.config, n.info, "not implemented") of nkBreakState: - var a: TCompRes = default(TCompRes) - if n[0].kind == nkClosure: - gen(p, n[0][1], a) - let sym = n[0][1].typ[0].n[0].sym - r.res = "(($1).$2 < 0)" % [rdLoc(a), mangleName(p.module, sym)] - else: - gen(p, n[0], a) - let sym = n[0].typ[0].n[0].sym - r.res = "((($1.ClE_0).$2) < 0)" % [rdLoc(a), mangleName(p.module, sym)] - r.kind = resExpr + genBreakState(p, n[0], r) of nkPragmaBlock: gen(p, n.lastSon, r) of nkComesFrom: discard "XXX to implement for better stack traces" |