fixes #4299 #12492 #10849; lambda lifting for JS backend (#23484)

fixes #4299 
fixes #12492 
fixes #10849

It binds `function` with `env`: `function.bind(:env)` to ease codegen
for now
This commit is contained in:
ringabout
2024-04-11 15:14:56 +08:00
committed by GitHub
parent 2bd2f28858
commit 779bc8474b
10 changed files with 118 additions and 71 deletions

View File

@@ -781,3 +781,15 @@ if (!Math.trunc) {
};
}
""".}
proc cmpClosures(a, b: JSRef): bool {.compilerproc, asmNoStackFrame.} =
# Both `a` and `b` need to be a closure
{.emit: """
if (`a` !== null && `a`.ClP_0 !== undefined &&
`b` !== null && `b`.ClP_0 !== undefined) {
return `a`.ClP_0 == `b`.ClP_0 && `a`.ClE_0 == `b`.ClE_0;
} else {
return `a` == `b`;
}
"""
.}