mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-09-22 06:29:37 +03:00
javascript: schedule continuation every 1000 calls
using stdout with node has a curious side effect. It allocates memory that will only be reclaimed after a new event has been scheduled. Therefore we set a timeout every 1000 calls that will execute the remaining code.
This commit is contained in:
parent
8c283520f3
commit
ac7c313fe6
@ -2,7 +2,6 @@ var i$putStr = function(s) {
|
||||
console.log(s);
|
||||
};
|
||||
|
||||
|
||||
var i$systemInfo = function(index) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
|
@ -104,3 +104,14 @@ var i$fromCharCode = function(chr) {
|
||||
else
|
||||
return String.fromCharCode(chr);
|
||||
}
|
||||
|
||||
var i$RUN = function () {
|
||||
for (var i = 0; i < 1000 && i$callstack.length; i++) {
|
||||
var func = i$callstack.pop();
|
||||
var args = i$callstack.pop();
|
||||
func.apply(this,args);
|
||||
};
|
||||
|
||||
if (i$callstack.length)
|
||||
setTimeout(i$RUN, 0);
|
||||
}
|
||||
|
@ -250,12 +250,7 @@ codegenJS_all target definitions includes libs filename outputType = do
|
||||
, JSApp (
|
||||
JSIdent (translateName (sMN 0 "runMain"))
|
||||
) [JSNew "i$POINTER" [JSNum (JSInt 0)]]
|
||||
, JSWhile (JSProj jsCALLSTACK "length") (
|
||||
JSSeq [ JSAlloc "func" (Just jsPOP)
|
||||
, JSAlloc "args" (Just jsPOP)
|
||||
, JSApp (JSProj (JSIdent "func") "apply") [JSThis, JSIdent "args"]
|
||||
]
|
||||
)
|
||||
, JSApp (JSIdent "i$RUN") []
|
||||
]
|
||||
|
||||
invokeMain :: T.Text
|
||||
|
Loading…
Reference in New Issue
Block a user