on master help sign in
javascript: temporary workaround to fix some issues with chars
commit10b971c804ba0c486c0ab0339627e8813ee106c8 authorraichoo <raichoo@googlemail.com> dateSun 19 Jan 2014, 16:40 (13 years ago) parent2b55660
1 file changed+8
src/IRTS/CodegenJavaScript.hs+8
src/IRTS/CodegenJavaScript.hs+8
@@ -64,6 +64,7 @@ data JS = JSRaw String
6464 | JSArray [JS]
6565 | JSObject [(String, JS)]
6666 | JSString String
67+ | JSChar String
6768 | JSNum JSNum
6869 | JSAssign JS JS
6970 | JSAlloc String (Maybe JS)
@@ -153,6 +154,9 @@ compileJS (JSObject fields) =
153154compileJS (JSString str) =
154155 show str
155156
157+compileJS (JSChar chr) =
158+ chr
159+
156160compileJS (JSNum num)
157161 | JSInt i <- num = show i
158162 | JSFloat f <- num = show f
@@ -241,6 +245,7 @@ jsLet name value body =
241245 )
242246 ) [value]
243247
248+
244249jsSubst :: String -> JS -> JS -> JS
245250jsSubst var new (JSVar old)
246251 | var == translateVariableName old = new
@@ -757,6 +762,9 @@ translateSpecialName name
757762translateConstant :: Const -> JS
758763translateConstant (I i) = JSNum (JSInt i)
759764translateConstant (Fl f) = JSNum (JSFloat f)
765+translateConstant (Ch '\DEL') = JSChar "'\\u007F'"
766+translateConstant (Ch '\a') = JSChar "'\\u0007'"
767+translateConstant (Ch '\SO') = JSChar "'\\u000E'"
760768translateConstant (Ch c) = JSString [c]
761769translateConstant (Str s) = JSString s
762770translateConstant (AType (ATInt ITNative)) = JSType JSIntTy