on master help sign in
javascript: added more types
commit45adece9366c91d12d9978d6e5668a010750649c authorraichoo <raichoo@googlemail.com> dateWed 16 Jan 2013, 17:55 (14 years ago) parentba9b358
1 file changed+12−3
src/IRTS/CodegenJavaScript.hs+12−3
src/IRTS/CodegenJavaScript.hs+12−3
@@ -50,6 +50,9 @@ idrRuntime =
5050 , "__IDR__.Int = new __IDR__.Type('Int');"
5151 , "__IDR__.Char = new __IDR__.Type('Char');"
5252 , "__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');"
5356
5457 , "__IDR__.Tailcall = function(f) { this.f = f };"
5558
@@ -160,6 +163,9 @@ translateConstant (Str s) = show s
160163translateConstant IType = "__IDR__.Int"
161164translateConstant ChType = "__IDR__.Char"
162165translateConstant StrType = "__IDR__.String"
166+translateConstant BIType = "__IDR__.Integer"
167+translateConstant FlType = "__IDR__.Float"
168+translateConstant Forgot = "__IDR__.Forgot"
163169translateConstant c =
164170 "(function(){throw 'Unimplemented Const: " ++ show c ++ "';})()"
165171
@@ -362,9 +368,12 @@ translateCase modname _ (SDefaultCase e) =
362368 createIfBlock "true" (translateExpression modname e)
363369
364370translateCase modname var (SConstCase ty e)
365− | ChType <- ty = translateTypeMatch modname var "Char" e
366− | StrType <- ty = translateTypeMatch modname var "String" e
367− | IType <- ty = translateTypeMatch modname var "Int" e
371+ | ChType <- ty = matchHelper "Char"
372+ | StrType <- ty = matchHelper "String"
373+ | IType <- ty = matchHelper "Int"
374+ | BIType <- ty = matchHelper "Integer"
375+ | FlType <- ty = matchHelper "Float"
376+ | Forgot <- ty = matchHelper "Forgot"
368377 where
369378 matchHelper tyName = translateTypeMatch modname var tyName e
370379