on master help sign in
Merge pull request #914 from raichoo/javascript
a8ce161Edwin Brady
CHANGELOG+3
@@ -4,6 +4,9 @@ New in 0.9.12:
4* Proof search now works for metavariables in types, giving some interactive
4* Proof search now works for metavariables in types, giving some interactive
5 type inference.
5 type inference.
6* New 'Lazy' type, replacing laziness annotations.
6* New 'Lazy' type, replacing laziness annotations.
7+* JavaScript and Node codegen now understand the %include directive
8+* Concept up 'null' is now understood in the JavaScript and Node codegen
9+* Lots of performance patches for generated JavaScript
7
10
8New in 0.9.11:
11New in 0.9.11:
9--------------
12--------------
src/IRTS/CodegenJavaScript.hs+10−5
@@ -1327,27 +1327,32 @@ getGlobalCons js = foldJS match (++) [] js
1327 []
1327 []
1328
1328
1329
1329
1330+getIncludes :: [FilePath] -> IO [String]
1331+getIncludes = mapM readFile
1332+
1330codegenJavaScript
1333codegenJavaScript
1331 :: JSTarget
1334 :: JSTarget
1332 -> [(Name, SDecl)]
1335 -> [(Name, SDecl)]
1336+ -> [FilePath]
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
1338 Node ->
1342 Node ->
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
1351 )
1356 )
1352
1357
1353 setPermissions filename (emptyPermissions { readable = True
1358 setPermissions filename (emptyPermissions { readable = True
src/IRTS/Compiler.hs+2−2
@@ -86,9 +86,9 @@ compile codegen f tm
86 ViaJava ->
86 ViaJava ->
87 codegenJava [] c f hdrs libs outty
87 codegenJava [] c f hdrs libs outty
88 ViaJavaScript ->
88 ViaJavaScript ->
89− codegenJavaScript JavaScript c f outty
89+ codegenJavaScript JavaScript c hdrs f outty
90 ViaNode ->
90 ViaNode ->
91− codegenJavaScript Node c f outty
91+ codegenJavaScript Node c hdrs f outty
92 ViaLLVM -> codegenLLVM c triple cpu optimize f outty
92 ViaLLVM -> codegenLLVM c triple cpu optimize f outty
93 Bytecode -> dumpBC c f
93 Bytecode -> dumpBC c f
94 Error e -> ierror e
94 Error e -> ierror e