mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 14:13:23 +00:00
Added YosysJS.create_worker()
This commit is contained in:
parent
df0163cd2b
commit
358e415918
3 changed files with 145 additions and 33 deletions
43
misc/yosysjs/yosyswrk.js
Normal file
43
misc/yosysjs/yosyswrk.js
Normal file
|
@ -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": [] }]);
|
Loading…
Add table
Add a link
Reference in a new issue