on master help sign in
Bug fix for infinite loop while executing a callback in the Javascript runtime.
3bbaf1eAaron Craelius
src/IRTS/CodegenJavaScript.hs+1−2
@@ -604,7 +604,7 @@ jsBASETOP _ 0 = JSAssign jsSTACKBASE jsSTACKTOP
604jsBASETOP _ n = JSAssign jsSTACKBASE (JSBinOp "+" jsSTACKTOP (JSNum (JSInt n)))
604jsBASETOP _ n = JSAssign jsSTACKBASE (JSBinOp "+" jsSTACKTOP (JSNum (JSInt n)))
605
605
606jsNULL :: CompileInfo -> Reg -> JS
606jsNULL :: CompileInfo -> Reg -> JS
607−jsNULL _ r = JSDelete (translateReg r)
607+jsNULL _ r = JSClear (translateReg r)
608
608
609jsERROR :: CompileInfo -> String -> JS
609jsERROR :: CompileInfo -> String -> JS
610jsERROR _ = JSError
610jsERROR _ = JSError
@@ -1277,4 +1277,3 @@ toFType (FApp c [_,ity])
1277toFType (FApp c [_,fty])
1277toFType (FApp c [_,fty])
1278 | c == sUN "JS_FnT" = toFnType fty
1278 | c == sUN "JS_FnT" = toFnType fty
1279toFType t = error (show t ++ " not yet defined in toFType")
1279toFType t = error (show t ++ " not yet defined in toFType")
1280−
src/IRTS/JavaScript/AST.hs+4−1
@@ -77,6 +77,7 @@ data JS = JSRaw String
77 | JSFFI String [JS]
77 | JSFFI String [JS]
78 | JSAnnotation JSAnnotation JS
78 | JSAnnotation JSAnnotation JS
79 | JSDelete JS
79 | JSDelete JS
80+ | JSClear JS
80 | JSNoop
81 | JSNoop
81 deriving Eq
82 deriving Eq
82
83
@@ -133,6 +134,9 @@ compileJS' indent (JSAnnotation annotation js) =
133compileJS' indent (JSDelete js) =
134compileJS' indent (JSDelete js) =
134 "delete " `T.append` compileJS' 0 js
135 "delete " `T.append` compileJS' 0 js
135
136
137+compileJS' indent (JSClear js) =
138+ compileJS' 0 js `T.append` " = undefined"
139+
136compileJS' indent (JSFFI raw args) =
140compileJS' indent (JSFFI raw args) =
137 ffi raw (map (T.unpack . compileJS' indent) args)
141 ffi raw (map (T.unpack . compileJS' indent) args)
138
142
@@ -398,4 +402,3 @@ jsPackSBits16 js = JSNew "Int16Array" [JSArray [js]]
398
402
399jsPackSBits32 :: JS -> JS
403jsPackSBits32 :: JS -> JS
400jsPackSBits32 js = JSNew "Int32Array" [JSArray [js]]
404jsPackSBits32 js = JSNew "Int32Array" [JSArray [js]]
401−