@@ -31,6 +31,7 @@ import Numeric
32data JsStmt
32data JsStmt
34 | JsExprStmt JsExpr
35 | JsExprStmt JsExpr
35 | JsFun Text
36 | JsFun Text
@@ -94,7 +95,6 @@ data JsExpr
94 | JsForeign Text
95 | JsForeign Text
96 | JsB2I JsExpr
97 | JsB2I JsExpr
98 | JsForce JsExpr
98 | JsForce JsExpr
99 deriving (Show, Eq, Data, Typeable)
99 deriving (Show, Eq, Data, Typeable)
@@ -152,6 +152,7 @@ jsSetVar n x = JsSet (JsVar n) x
153jsStmt2Text :: JsStmt -> Text
153jsStmt2Text :: JsStmt -> Text
154jsStmt2Text JsEmpty = ""
154jsStmt2Text JsEmpty = ""
155+jsStmt2Text (JsComment c) = T.unlines $ map ("// " `T.append`) $ T.lines c
155jsStmt2Text (JsExprStmt e) = T.concat [jsAst2Text e, ";"]
156jsStmt2Text (JsExprStmt e) = T.concat [jsAst2Text e, ";"]
156jsStmt2Text (JsReturn x) = T.concat ["return ", jsAst2Text x, ";"]
157jsStmt2Text (JsReturn x) = T.concat ["return ", jsAst2Text x, ";"]
157jsStmt2Text (JsDecVar name exp) =
158jsStmt2Text (JsDecVar name exp) =
@@ -283,7 +284,6 @@ jsAst2Text (JsForeign code args) =
283 args_repl (T.replace ("%" `T.append` T.pack (show i)) (T.concat ["(", t, ")"]) c) (i + 1) r
284 args_repl (T.replace ("%" `T.append` T.pack (show i)) (T.concat ["(", t, ")"]) c) (i + 1) r
284 in T.concat ["(", args_repl code 0 (map jsAst2Text args), ")"]
285 in T.concat ["(", args_repl code 0 (map jsAst2Text args), ")"]
285jsAst2Text (JsB2I x) = jsAst2Text $ JsBinOp "+" x (JsInt 0)
286jsAst2Text (JsB2I x) = jsAst2Text $ JsBinOp "+" x (JsInt 0)
286−jsAst2Text (JsComment c) = T.concat ["/*", c, "*/"]
287jsAst2Text (JsForce e) = T.concat ["js_idris_force(", jsAst2Text e, ")"]
287jsAst2Text (JsForce e) = T.concat ["js_idris_force(", jsAst2Text e, ")"]
289jsLazy :: JsExpr -> JsExpr
289jsLazy :: JsExpr -> JsExpr