diff options
Diffstat (limited to 'misc/yosysjs/yosyswrk.js')
-rw-r--r-- | misc/yosysjs/yosyswrk.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/misc/yosysjs/yosyswrk.js b/misc/yosysjs/yosyswrk.js index 1d77b3d25..b6173439f 100644 --- a/misc/yosysjs/yosyswrk.js +++ b/misc/yosysjs/yosyswrk.js @@ -1,3 +1,13 @@ +var Module = {}; +var verbose_mode = false; +var text_buffer = ""; + +Module["printErr"] = Module["print"] = function(text) { + if (verbose_mode) + console.log(text); + text_buffer += text + "\n"; +} + importScripts('yosys.js'); onmessage = function(e) { @@ -5,12 +15,16 @@ onmessage = function(e) { var response = { "idx": request.idx, "args": [] }; if (request.mode == "run") { + response["errmsg"] = ""; try { + text_buffer = ""; Module.ccall('run', '', ['string'], [request.cmd]); - response.args.push(""); } catch (e) { - response.args.push(mod.ccall('errmsg', 'string', [], [])); + response.errmsg = Module.ccall('errmsg', 'string', [], []); } + response.args.push(text_buffer); + response.args.push(response.errmsg); + text_buffer = ""; } if (request.mode == "read_file") { @@ -37,6 +51,12 @@ onmessage = function(e) { } catch (e) { } } + if (request.mode == "verbose") { + if (request.value) + console.log(text_buffer); + verbose_mode = request.value; + } + postMessage([response]); } |