on master help sign in
javascript: added more types
45adeceraichoo
src/IRTS/CodegenJavaScript.hs+12−3
@@ -50,6 +50,9 @@ idrRuntime =
50 , "__IDR__.Int = new __IDR__.Type('Int');"
50 , "__IDR__.Int = new __IDR__.Type('Int');"
51 , "__IDR__.Char = new __IDR__.Type('Char');"
51 , "__IDR__.Char = new __IDR__.Type('Char');"
52 , "__IDR__.String = new __IDR__.Type('String');"
52 , "__IDR__.String = new __IDR__.Type('String');"
53+ , "__IDR__.Integer = new __IDR__.Type('Integer');"
54+ , "__IDR__.Float = new __IDR__.Type('Float');"
55+ , "__IDR__.Forgot = new __IDR__.Type('Forgot');"
53
56
54 , "__IDR__.Tailcall = function(f) { this.f = f };"
57 , "__IDR__.Tailcall = function(f) { this.f = f };"
55
58
@@ -160,6 +163,9 @@ translateConstant (Str s) = show s
160translateConstant IType = "__IDR__.Int"
163translateConstant IType = "__IDR__.Int"
161translateConstant ChType = "__IDR__.Char"
164translateConstant ChType = "__IDR__.Char"
162translateConstant StrType = "__IDR__.String"
165translateConstant StrType = "__IDR__.String"
166+translateConstant BIType = "__IDR__.Integer"
167+translateConstant FlType = "__IDR__.Float"
168+translateConstant Forgot = "__IDR__.Forgot"
163translateConstant c =
169translateConstant c =
164 "(function(){throw 'Unimplemented Const: " ++ show c ++ "';})()"
170 "(function(){throw 'Unimplemented Const: " ++ show c ++ "';})()"
165
171
@@ -362,9 +368,12 @@ translateCase modname _ (SDefaultCase e) =
362 createIfBlock "true" (translateExpression modname e)
368 createIfBlock "true" (translateExpression modname e)
363
369
364translateCase modname var (SConstCase ty e)
370translateCase modname var (SConstCase ty e)
365− | ChType <- ty = translateTypeMatch modname var "Char" e
371+ | ChType <- ty = matchHelper "Char"
366− | StrType <- ty = translateTypeMatch modname var "String" e
372+ | StrType <- ty = matchHelper "String"
367− | IType <- ty = translateTypeMatch modname var "Int" e
373+ | IType <- ty = matchHelper "Int"
374+ | BIType <- ty = matchHelper "Integer"
375+ | FlType <- ty = matchHelper "Float"
376+ | Forgot <- ty = matchHelper "Forgot"
368 where
377 where
369 matchHelper tyName = translateTypeMatch modname var tyName e
378 matchHelper tyName = translateTypeMatch modname var tyName e
370
379