diff options
author | Clifford Wolf <clifford@clifford.at> | 2015-06-28 17:47:58 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-06-28 17:47:58 +0200 |
commit | 358e41591891fc74045860b0c3364cb155726b30 (patch) | |
tree | 1e5e7dea6ab3f898d17863a126660795bdd088ce /misc/yosysjs/yosyswrk.js | |
parent | df0163cd2b0dfd7c825f13ecb1c22f4f4d494a3b (diff) | |
download | yosys-358e41591891fc74045860b0c3364cb155726b30.tar.gz yosys-358e41591891fc74045860b0c3364cb155726b30.tar.bz2 yosys-358e41591891fc74045860b0c3364cb155726b30.zip |
Added YosysJS.create_worker()
Diffstat (limited to 'misc/yosysjs/yosyswrk.js')
-rw-r--r-- | misc/yosysjs/yosyswrk.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/misc/yosysjs/yosyswrk.js b/misc/yosysjs/yosyswrk.js new file mode 100644 index 000000000..1d77b3d25 --- /dev/null +++ b/misc/yosysjs/yosyswrk.js @@ -0,0 +1,43 @@ +importScripts('yosys.js'); + +onmessage = function(e) { + var request = e.data[0]; + var response = { "idx": request.idx, "args": [] }; + + if (request.mode == "run") { + try { + Module.ccall('run', '', ['string'], [request.cmd]); + response.args.push(""); + } catch (e) { + response.args.push(mod.ccall('errmsg', 'string', [], [])); + } + } + + if (request.mode == "read_file") { + try { + response.args.push(FS.readFile(request.filename, {encoding: 'utf8'})); + } catch (e) { } + } + + if (request.mode == "write_file") { + try { + FS.writeFile(request.filename, request.text, {encoding: 'utf8'}); + } catch (e) { } + } + + if (request.mode == "read_dir") { + try { + response.args.push(FS.readdir(request.dirname)); + } catch (e) { } + } + + if (request.mode == "remove_file") { + try { + FS.unlink(request.filename); + } catch (e) { } + } + + postMessage([response]); +} + +postMessage([{ "idx": 0, "args": [] }]); |