aboutsummaryrefslogtreecommitdiffstats
path: root/misc/yosysjs/yosysjs.js
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-02-19 13:36:54 +0100
committerClifford Wolf <clifford@clifford.at>2015-02-19 13:36:54 +0100
commite0e6d130cd083a8285ea2991629e0049023da234 (patch)
tree7be213913f1145b536f7b696e95e300ef67c834f /misc/yosysjs/yosysjs.js
parent08c0fe164fefb28dc209d35e7bd757538311d2e6 (diff)
downloadyosys-e0e6d130cd083a8285ea2991629e0049023da234.tar.gz
yosys-e0e6d130cd083a8285ea2991629e0049023da234.tar.bz2
yosys-e0e6d130cd083a8285ea2991629e0049023da234.zip
YosysJS stuff
Diffstat (limited to 'misc/yosysjs/yosysjs.js')
-rw-r--r--misc/yosysjs/yosysjs.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/misc/yosysjs/yosysjs.js b/misc/yosysjs/yosysjs.js
index 87c951183..a1181493e 100644
--- a/misc/yosysjs/yosysjs.js
+++ b/misc/yosysjs/yosysjs.js
@@ -45,6 +45,7 @@ var YosysJS = new function() {
ys.verbose = false;
ys.logprint = false;
ys.echo = false;
+ ys.errmsg = "";
if (typeof(reference_element) == 'string' && reference_element != "")
reference_element = document.getElementById(reference_element);
@@ -151,12 +152,20 @@ var YosysJS = new function() {
ys.write("");
ys.write(ys.prompt() + cmd);
}
- mod.ccall('run', '', ['string'], [cmd]);
+ try {
+ mod.ccall('run', '', ['string'], [cmd]);
+ } catch (e) {
+ ys.errmsg = mod.ccall('errmsg', 'string', [], []);;
+ }
return ys.print_buffer;
}
ys.read_file = function(filename) {
- return ys.window.FS.readFile(filename, {encoding: 'utf8'});
+ try {
+ return ys.window.FS.readFile(filename, {encoding: 'utf8'});
+ } catch (e) {
+ return "";
+ }
}
ys.write_file = function(filename, text) {
@@ -167,6 +176,12 @@ var YosysJS = new function() {
return ys.window.FS.readdir(dirname);
}
+ ys.remove_file = function(filename) {
+ try {
+ ys.window.FS.unlink(filename);
+ } catch (e) { }
+ }
+
doc.open()
doc.write('<script type="text/javascript" src="' + this.url_prefix + 'yosys.js"></' + 'script>');
doc.close()