[Git][ghc/ghc][wip/js-th] Rename stuff

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Mon Jan 23 14:49:46 UTC 2023



Sylvain Henry pushed to branch wip/js-th at Glasgow Haskell Compiler / GHC


Commits:
5a3641e7 by Sylvain Henry at 2023-01-23T15:54:00+01:00
Rename stuff

- - - - -


6 changed files:

- compiler/GHC.hs
- compiler/GHC/Runtime/Interpreter/JS.hs
- compiler/GHC/Runtime/Interpreter/Types.hs
- thrunner.js → ghc-interp.js
- hadrian/src/Base.hs
- hadrian/src/Rules/Generate.hs


Changes:

=====================================
compiler/GHC.hs
=====================================
@@ -702,7 +702,7 @@ setTopSessionDynFlags dflags = do
          loader <- liftIO Loader.uninitializedLoader
          let cfg = JSInterpConfig
               { jsInterpNodeConfig = defaultNodeJsSettings
-              , jsInterpTopDir     = topDir dflags
+              , jsInterpScript     = topDir dflags </> "ghc-interp.js"
               , jsInterpTmpFs      = hsc_tmpfs hsc_env
               , jsInterpTmpDir     = tmpDir dflags
               , jsInterpLogger     = hsc_logger hsc_env


=====================================
compiler/GHC/Runtime/Interpreter/JS.hs
=====================================
@@ -57,9 +57,9 @@ import Foreign.C.String
 -- Running node
 ---------------------------------------------------------
 
--- | Start NodeJS interactively with thrunner.js loaded in
+-- | Start NodeJS interactively with "ghc-interp.js" script loaded in
 startTHRunnerProcess :: FilePath -> NodeJsSettings -> IO (Handle,InterpProcess)
-startTHRunnerProcess topdir settings = do
+startTHRunnerProcess interp_js settings = do
   interp_in <- newIORef undefined
 
   let createProc cp = do
@@ -77,7 +77,7 @@ startTHRunnerProcess topdir settings = do
           return hdl
 
   (hdl, rh, wh) <- runWithPipes createProc (nodeProgram settings)
-                                           [topdir </> "thrunner.js"]
+                                           [interp_js]
                                            (nodeExtraArgs settings)
   std_in <- readIORef interp_in
 
@@ -91,7 +91,8 @@ startTHRunnerProcess topdir settings = do
 
 -- | Spawn a JS interpreter
 --
--- Run NodeJS with thrunner.js and its deps (including the rts) loaded.
+-- Run NodeJS with "ghc-interp.js" loaded in. Then load GHCi.Server and its deps
+-- (including the rts) and run GHCi.Server.defaultServer.
 spawnJSInterp :: JSInterpConfig -> IO (ExtInterpInstance JSInterpExtra)
 spawnJSInterp cfg = do
   let logger= jsInterpLogger cfg
@@ -103,7 +104,7 @@ spawnJSInterp cfg = do
   let logger      = jsInterpLogger cfg
   let codegen_cfg = jsInterpCodegenCfg cfg
   let unit_env    = jsInterpUnitEnv cfg
-  (std_in, proc) <- startTHRunnerProcess (jsInterpTopDir cfg) (jsInterpNodeConfig cfg)
+  (std_in, proc) <- startTHRunnerProcess (jsInterpScrip cfg) (jsInterpNodeConfig cfg)
   js_state <- newMVar (JSState
                 { jsLinkState     = emptyLinkPlan
                 , jsServerStarted = False


=====================================
compiler/GHC/Runtime/Interpreter/Types.hs
=====================================
@@ -146,7 +146,7 @@ defaultNodeJsSettings = NodeJsSettings
 
 data JSInterpConfig = JSInterpConfig
   { jsInterpNodeConfig :: !NodeJsSettings  -- ^ NodeJS settings
-  , jsInterpTopDir     :: !FilePath        -- ^ GHC's topdir containing thrunner.js
+  , jsInterpScript     :: !FilePath        -- ^ Path to "ghc-interp.js" script
   , jsInterpTmpFs      :: !TmpFs
   , jsInterpTmpDir     :: !TempDir
   , jsInterpLogger     :: !Logger


=====================================
thrunner.js → ghc-interp.js
=====================================
@@ -1,21 +1,18 @@
 /*
   GHC JS Interpreter
 
-  Read commands on stdin:
-    LOAD foo.js\n   : load foo.js file
-    RUN_SERVER\n    : run GHCi.Server.defaultServer
+  Read commands on stdin (ending with \n):
+    LOAD foo.js   : load foo.js file
+    RUN_SERVER    : run GHCi.Server.defaultServer
 
   Once the Haskell server is started with RUN_SERVER, the JS server no longer
-  reads commands on stdin. Everything must go throught the Haskell server (which
+  reads commands on stdin. Everything must go through the Haskell server (which
   uses pipes for communication)
 */
 
 var h$THfs = require('fs');
 var h$THvm = require('vm');
 
-global.require = require;
-global.module  = module;
-
 function h$debug_log(s) {
   // switch this to 'true' to enable some debug messages
   if (false) {
@@ -44,6 +41,8 @@ function h$lookupClosure(v) {
 // give access to these functions to the dynamically linked code
 globalThis.h$loadJS = h$loadJS;
 globalThis.h$lookupClosure = h$lookupClosure;
+global.require = require;
+global.module  = module;
 
 
 function h$initInterp() {


=====================================
hadrian/src/Base.hs
=====================================
@@ -130,7 +130,7 @@ ghcLibDeps stage iplace = do
     ps <- mapM (\f -> stageLibPath stage <&> (-/- f))
         [ "llvm-targets"
         , "llvm-passes"
-        , "thrunner.js"
+        , "ghc-interp.js"
         , "settings"
         ]
     cxxStdLib <- systemCxxStdLibConfPath (PackageDbLoc stage iplace)


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -199,7 +199,7 @@ copyRules = do
         prefix -/- "ghci-usage.txt"    <~ return "driver"
         prefix -/- "llvm-targets"      <~ return "."
         prefix -/- "llvm-passes"       <~ return "."
-        prefix -/- "thrunner.js"       <~ return "."
+        prefix -/- "ghc-interp.js"     <~ return "."
         prefix -/- "template-hsc.h" <~ return (pkgPath hsc2hs -/- "data")
 
         prefix -/- "html/**"           <~ return "utils/haddock/haddock-api/resources"



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a3641e7933f43a71db8ccf0e568d75830094291

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5a3641e7933f43a71db8ccf0e568d75830094291
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230123/8fa8ab04/attachment-0001.html>


More information about the ghc-commits mailing list