on master help sign in
removed commented code
415c94cRui Barreiro
src/IRTS/JavaScript/AST.hs+1−17
@@ -42,9 +42,7 @@ data JsAST = JsEmpty
42 | JsErrorExp JsAST
42 | JsErrorExp JsAST
43 | JsBinOp Text JsAST JsAST
43 | JsBinOp Text JsAST JsAST
44 | JsForeign Text [JsAST]
44 | JsForeign Text [JsAST]
45− -- | JsB2I JsAST
46 | JsWhileTrue JsAST
45 | JsWhileTrue JsAST
47− -- | JsFor (JsAST, JsAST, JsAST) JsAST
48 | JsContinue
46 | JsContinue
49 | JsBreak
47 | JsBreak
50 | JsTrue
48 | JsTrue
@@ -115,14 +113,6 @@ jsAst2Text (JsFun name args body) =
115 , indent $ jsAst2Text body
113 , indent $ jsAst2Text body
116 , "}\n"
114 , "}\n"
117 ]
115 ]
118−{-jsAst2Text (JsCurryFun name args body) =
119− T.concat [ "var ", name, " = \n"
120− , indent $ T.concat [ "(function(){\n"
121− , indent $ curryDef args body
122− , "})()"
123− ]
124− ]
125−-}
126jsAst2Text (JsReturn x) = T.concat [ "return ", jsAst2Text x]
116jsAst2Text (JsReturn x) = T.concat [ "return ", jsAst2Text x]
127jsAst2Text (JsApp fn args) = T.concat [fn, "(", T.intercalate ", " $ map jsAst2Text args, ")"]
117jsAst2Text (JsApp fn args) = T.concat [fn, "(", T.intercalate ", " $ map jsAst2Text args, ")"]
128jsAst2Text (JsCurryApp fn []) = jsAst2Text fn
118jsAst2Text (JsCurryApp fn []) = jsAst2Text fn
@@ -139,7 +129,7 @@ jsAst2Text (JsSeq JsEmpty y) = jsAst2Text y
139jsAst2Text (JsSeq x JsEmpty) = jsAst2Text x
129jsAst2Text (JsSeq x JsEmpty) = jsAst2Text x
140jsAst2Text (JsSeq x y) = T.concat [jsAst2Text x, ";\n", jsAst2Text y]
130jsAst2Text (JsSeq x y) = T.concat [jsAst2Text x, ";\n", jsAst2Text y]
141jsAst2Text (JsConst name exp) = T.concat [ "var ", name, " = ", jsAst2Text exp] -- using var instead of const until ES6
131jsAst2Text (JsConst name exp) = T.concat [ "var ", name, " = ", jsAst2Text exp] -- using var instead of const until ES6
142−jsAst2Text (JsLet name exp) = T.concat [ "var ", name, " = ", jsAst2Text exp] -- using var instead of const until ES6
132+jsAst2Text (JsLet name exp) = T.concat [ "var ", name, " = ", jsAst2Text exp] -- using var instead of let until ES6
143jsAst2Text (JsSetVar name exp) = T.concat [ name, " = ", jsAst2Text exp]
133jsAst2Text (JsSetVar name exp) = T.concat [ name, " = ", jsAst2Text exp]
144jsAst2Text (JsArrayProj i exp) = T.concat [ jsAst2Text exp, "[", jsAst2Text i, "]"]
134jsAst2Text (JsArrayProj i exp) = T.concat [ jsAst2Text exp, "[", jsAst2Text i, "]"]
145jsAst2Text (JsInt i) = T.pack $ show i ++ "|0"
135jsAst2Text (JsInt i) = T.pack $ show i ++ "|0"
@@ -162,17 +152,11 @@ jsAst2Text (JsForeign code args) =
162 let args_repl c i [] = c
152 let args_repl c i [] = c
163 args_repl c i (t:r) = args_repl (T.replace ("%" `T.append` T.pack (show i)) t c) (i+1) r
153 args_repl c i (t:r) = args_repl (T.replace ("%" `T.append` T.pack (show i)) t c) (i+1) r
164 in T.concat ["(", args_repl code 0 (map jsAst2Text args), ")"]
154 in T.concat ["(", args_repl code 0 (map jsAst2Text args), ")"]
165−--jsAst2Text (JsB2I x) = jsAst2Text $ JsBinOp "+" x (JsNum 0)
166jsAst2Text (JsWhileTrue w) =
155jsAst2Text (JsWhileTrue w) =
167 T.concat [ "while(true){\n"
156 T.concat [ "while(true){\n"
168 , indent $ jsAst2Text w
157 , indent $ jsAst2Text w
169 , "}\n"
158 , "}\n"
170 ]
159 ]
171−{-jsAst2Text (JsFor (x,y,z) w) =
172− T.concat [ "for(", jsAst2Text x , "; ",jsAst2Text y, "; ",jsAst2Text z,"){\n"
173− , indent $ jsAst2Text w
174− , "}\n"
175− ]-}
176jsAst2Text JsContinue =
160jsAst2Text JsContinue =
177 "continue"
161 "continue"
178jsAst2Text JsBreak =
162jsAst2Text JsBreak =
src/IRTS/JavaScript/LangTransforms.hs+1−1
@@ -75,7 +75,7 @@ usedFunctions alldefs done names =
75usedDecls :: Map Name LDecl -> [Name] -> Map Name LDecl
75usedDecls :: Map Name LDecl -> [Name] -> Map Name LDecl
76usedDecls dcls start =
76usedDecls dcls start =
77 let used = reverse $ start ++ usedFunctions dcls (Set.fromList start) start
77 let used = reverse $ start ++ usedFunctions dcls (Set.fromList start) start
78− in restrictKeys dcls (Set.fromList used) --catMaybes $ map (\x -> Map.lookup x dcls) used
78+ in restrictKeys dcls (Set.fromList used)
79
79
80getUsedConstructors :: Map Name LDecl -> Set Name
80getUsedConstructors :: Map Name LDecl -> Set Name
81getUsedConstructors x = Set.fromList [ n | LCon _ _ n _ <- universeBi x]
81getUsedConstructors x = Set.fromList [ n | LCon _ _ n _ <- universeBi x]