@@ -1327,27 +1327,32 @@ getGlobalCons js = foldJS match (++) [] js
1330+getIncludes :: [FilePath] -> IO [String]
1331+getIncludes = mapM readFile
1330codegenJavaScript
1333codegenJavaScript
1331 :: JSTarget
1334 :: JSTarget
1332 -> [(Name, SDecl)]
1335 -> [(Name, SDecl)]
1333 -> FilePath
1337 -> FilePath
1334 -> OutputType
1338 -> OutputType
1335 -> IO ()
1339 -> IO ()
1336−codegenJavaScript target definitions filename outputType = do
1340+codegenJavaScript target definitions includes filename outputType = do
1337 let (header, runtime) = case target of
1341 let (header, runtime) = case target of
1339 ("#!/usr/bin/env node\n", "-node")
1343 ("#!/usr/bin/env node\n", "-node")
1340 JavaScript ->
1344 JavaScript ->
1341 ("", "-browser")
1345 ("", "-browser")
1346+ included <- getIncludes includes
1342 path <- (++) <$> getDataDir <*> (pure "/jsrts/")
1347 path <- (++) <$> getDataDir <*> (pure "/jsrts/")
1343 idrRuntime <- readFile $ path ++ "Runtime-common.js"
1348 idrRuntime <- readFile $ path ++ "Runtime-common.js"
1344 tgtRuntime <- readFile $ concat [path, "Runtime", runtime, ".js"]
1349 tgtRuntime <- readFile $ concat [path, "Runtime", runtime, ".js"]
1345 jsbn <- readFile $ path ++ "jsbn/jsbn.js"
1350 jsbn <- readFile $ path ++ "jsbn/jsbn.js"
1346 writeFile filename $ header ++ (
1351 writeFile filename $ header ++ (
1347− intercalate "\n" $ [ jsbn
1352+ intercalate "\n" $ included ++ [ jsbn
1348− , idrRuntime
1353+ , idrRuntime
1349− , tgtRuntime
1354+ , tgtRuntime
1350− ] ++ functions
1355+ ] ++ functions
1353 setPermissions filename (emptyPermissions { readable = True
1358 setPermissions filename (emptyPermissions { readable = True