on master help sign in
Merge pull request #4617 from unalos/master
ecf297aNiklas Larsson
jsrts/Runtime-javascript.js+6−2
@@ -7,5 +7,9 @@ $JSRTS.prim_systemInfo = function (index) {
7 }
7 }
8 return "";
8 return "";
9};
9};
10+
10−$JSRTS.prim_writeStr = function (x) { return console.log(x) }
11+$JSRTS.prim_writeStr = function (x) { return console.log(x) };
12+
11−$JSRTS.prim_readStr = function () { return prompt('Prelude.getLine') };
13+$JSRTS.prim_readStr = function () { return prompt('Prelude.getLine') };
14+
15+$JSRTS.die = function (message) { throw new Error(message) };
jsrts/Runtime-node.js+10−1
@@ -1,5 +1,7 @@
1$JSRTS.os = require('os');
1$JSRTS.os = require('os');
2+
2$JSRTS.fs = require('fs');
3$JSRTS.fs = require('fs');
4+
3$JSRTS.prim_systemInfo = function (index) {
5$JSRTS.prim_systemInfo = function (index) {
4 switch (index) {
6 switch (index) {
5 case 0:
7 case 0:
@@ -9,7 +11,9 @@ $JSRTS.prim_systemInfo = function (index) {
9 }
11 }
10 return "";
12 return "";
11};
13};
14+
12−$JSRTS.prim_writeStr = function (x) { return process.stdout.write(x) }
15+$JSRTS.prim_writeStr = function (x) { return process.stdout.write(x) };
16+
13$JSRTS.prim_readStr = function () {
17$JSRTS.prim_readStr = function () {
14 var ret = '';
18 var ret = '';
15 var b = new Buffer(1024);
19 var b = new Buffer(1024);
@@ -28,4 +32,9 @@ $JSRTS.prim_readStr = function () {
28 }
32 }
29 }
33 }
30 return ret;
34 return ret;
35+};
36+
37+$JSRTS.die = function (message) {
38+ console.error(message);
39+ process.exit(-1);
31};
40};
src/IRTS/Compiler.hs+1−1
@@ -533,7 +533,7 @@ irTree top args tree = do
533
533
534irSC :: Name -> Vars -> SC -> Idris LExp
534irSC :: Name -> Vars -> SC -> Idris LExp
535irSC top vs (STerm t) = irTerm top vs [] t
535irSC top vs (STerm t) = irTerm top vs [] t
536−irSC top vs (UnmatchedCase str) = return $ LLazyExp $ LError str
536+irSC top vs (UnmatchedCase str) = return $ LError str
537
537
538irSC top vs (ProjCase tm alts) = do
538irSC top vs (ProjCase tm alts) = do
539 tm' <- irTerm top vs [] tm
539 tm' <- irTerm top vs [] tm
src/IRTS/JavaScript/AST.hs+1−1
@@ -202,7 +202,7 @@ jsStmt2Text (JsSwitchCase exp l d) =
202 default2Text Nothing = ""
202 default2Text Nothing = ""
203 default2Text (Just z) =
203 default2Text (Just z) =
204 T.concat ["default:\n", indent $ T.concat [jsStmt2Text z, ";\nbreak;\n"]]
204 T.concat ["default:\n", indent $ T.concat [jsStmt2Text z, ";\nbreak;\n"]]
205−jsStmt2Text (JsError t) = T.concat ["throw new Error( ", jsAst2Text t, ");"]
205+jsStmt2Text (JsError t) = T.concat ["$JSRTS.die(", jsAst2Text t, ");\n"]
206jsStmt2Text (JsForever x) =
206jsStmt2Text (JsForever x) =
207 T.concat ["for(;;) {\n", indent $ jsStmt2Text x, "}\n"]
207 T.concat ["for(;;) {\n", indent $ jsStmt2Text x, "}\n"]
208jsStmt2Text JsContinue = "continue;"
208jsStmt2Text JsContinue = "continue;"