From a45a57127bb7eaceae92e0edf057c053eb4d5367 Mon Sep 17 00:00:00 2001 From: "Serge S. Gulin" <gulin.serge@gmail.com> Date: Sat, 23 Mar 2024 16:36:34 +0300 Subject: [PATCH] JS: thread.js requires h$fds and h$fdReady to be declared for static code analysis, minimal code copied from GHCJS (fixes #24602) I've just copied some old pieces of GHCJS from publicly available sources (See https://github.com/Taneb/shims/blob/a6dd0202dcdb86ad63201495b8b5d9763483eb35/src/io.js#L607). Also I didn't put details to h$fds. I took minimal and left only its object initialization: `var h$fds = {};` --- rts/js/thread.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/rts/js/thread.js b/rts/js/thread.js index dace09883179..d54907b945a3 100644 --- a/rts/js/thread.js +++ b/rts/js/thread.js @@ -179,6 +179,32 @@ function h$threadStatus(t) { RETURN_UBX_TUP3(t.status, 0, 1); } +// Required by Google Closure Compiler static code analysis +var h$fds = {}; + +// Copied from GHCJS because it is required by Google Closure Compiler +// static code analysis +function h$fdReady(fd, write, msecs, isSock) { + var f = h$fds[fd]; + if(write) { + if(f.writeReady) { + return 1; + } else if(msecs === 0) { + return 0; + } else { + throw "h$fdReady: blocking not implemented"; + } + } else { + if(f.readReady) { + return 1; + } else if(msecs === 0) { + return 0; + } else { + throw "h$fdReady: blocking not implemented"; + } + } +} + function h$waitRead(fd) { h$fds[fd].waitRead.push(h$currentThread); h$currentThread.interruptible = true; @@ -798,7 +824,7 @@ function h$runThreadSliceCatch(c) { h$currentThread is the thread to run h$stack is the stack of this thread h$sp is the stack pointer - + any global variables needed to pass arguments have been set the caller has to update the thread state object */ @@ -898,7 +924,7 @@ function h$run(a) { /** @constructor */ function h$WouldBlock() { - + } h$WouldBlock.prototype.toString = function() { @@ -968,7 +994,7 @@ function h$runSyncReturn(a, cont) { /* run a Haskell IO action synchronously, ignoring the result or any exception in the Haskell code - + - a: the IO action - cont: continue async if blocked -- GitLab