@@ -1327,27 +1327,32 @@ getGlobalCons js = foldJS match (++) [] js
13271327 []
13281328
13291329
1330+getIncludes :: [FilePath] -> IO [String]
1331+getIncludes = mapM readFile
1332+
13301333codegenJavaScript
13311334 :: JSTarget
13321335 -> [(Name, SDecl)]
1336+ -> [FilePath]
13331337 -> FilePath
13341338 -> OutputType
13351339 -> IO ()
1336−codegenJavaScript target definitions filename outputType = do
1340+codegenJavaScript target definitions includes filename outputType = do
13371341 let (header, runtime) = case target of
13381342 Node ->
13391343 ("#!/usr/bin/env node\n", "-node")
13401344 JavaScript ->
13411345 ("", "-browser")
1346+ included <- getIncludes includes
13421347 path <- (++) <$> getDataDir <*> (pure "/jsrts/")
13431348 idrRuntime <- readFile $ path ++ "Runtime-common.js"
13441349 tgtRuntime <- readFile $ concat [path, "Runtime", runtime, ".js"]
13451350 jsbn <- readFile $ path ++ "jsbn/jsbn.js"
13461351 writeFile filename $ header ++ (
1347− intercalate "\n" $ [ jsbn
1348− , idrRuntime
1349− , tgtRuntime
1350− ] ++ functions
1352+ intercalate "\n" $ included ++ [ jsbn
1353+ , idrRuntime
1354+ , tgtRuntime
1355+ ] ++ functions
13511356 )
13521357
13531358 setPermissions filename (emptyPermissions { readable = True