summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-04-11 15:14:56 +0800
committerGitHub <noreply@github.com>2024-04-11 09:14:56 +0200
commit779bc8474b0e4d5d77d2619bd50eaa0fc111d1e6 (patch)
treed52d43d6a688b3cb93f2838c154e9096752489b8 /lib/system
parent2bd2f2885873f5eb2c722b3647fd11ee480a2452 (diff)
downloadNim-779bc8474b0e4d5d77d2619bd50eaa0fc111d1e6.tar.gz
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
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/jssys.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index 868abfd53..fb9481ffd 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -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`;
+    }
+  """
+  .}