diff options
author | Clifford Wolf <clifford@clifford.at> | 2015-02-19 13:36:54 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-02-19 13:36:54 +0100 |
commit | e0e6d130cd083a8285ea2991629e0049023da234 (patch) | |
tree | 7be213913f1145b536f7b696e95e300ef67c834f /kernel | |
parent | 08c0fe164fefb28dc209d35e7bd757538311d2e6 (diff) | |
download | yosys-e0e6d130cd083a8285ea2991629e0049023da234.tar.gz yosys-e0e6d130cd083a8285ea2991629e0049023da234.tar.bz2 yosys-e0e6d130cd083a8285ea2991629e0049023da234.zip |
YosysJS stuff
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/driver.cc | 17 | ||||
-rw-r--r-- | kernel/log.cc | 19 | ||||
-rw-r--r-- | kernel/log.h | 1 |
3 files changed, 32 insertions, 5 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc index d0ebdde77..dda27c6a6 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -78,6 +78,7 @@ USING_YOSYS_NAMESPACE extern "C" int main(int, char**); extern "C" void run(const char*); +extern "C" const char *errmsg(); extern "C" const char *prompt(); int main(int, char**) @@ -92,7 +93,21 @@ int main(int, char**) void run(const char *command) { - run_pass(command); + int selSize = GetSize(yosys_get_design()->selection_stack); + try { + log_last_error = "Internal error (see JavaScript console for details)"; + run_pass(command); + log_last_error = ""; + } catch (...) { + while (GetSize(yosys_get_design()->selection_stack) > selSize) + yosys_get_design()->selection_stack.pop_back(); + throw; + } +} + +const char *errmsg() +{ + return log_last_error.c_str(); } const char *prompt() diff --git a/kernel/log.cc b/kernel/log.cc index ada2cabb2..bf92daced 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -48,6 +48,7 @@ bool log_error_stderr = false; bool log_cmd_error_throw = false; bool log_quiet_warnings = false; int log_verbose_level; +string log_last_error; vector<int> header_count; pool<RTLIL::IdString> log_id_cache; @@ -173,6 +174,10 @@ void logv_warning(const char *format, va_list ap) void logv_error(const char *format, va_list ap) { +#ifdef EMSCRIPTEN + auto backup_log_files = log_files; +#endif + if (log_errfile != NULL) log_files.push_back(log_errfile); @@ -181,10 +186,16 @@ void logv_error(const char *format, va_list ap) if (f == stdout) f = stderr; - log("ERROR: "); - logv(format, ap); + log_last_error = vstringf(format, ap); + log("ERROR: %s", log_last_error.c_str()); log_flush(); + +#ifdef EMSCRIPTEN + log_files = backup_log_files; + throw 0; +#else exit(1); +#endif } void log(const char *format, ...) @@ -224,8 +235,8 @@ void log_cmd_error(const char *format, ...) va_start(ap, format); if (log_cmd_error_throw) { - log("ERROR: "); - logv(format, ap); + log_last_error = vstringf(format, ap); + log("ERROR: %s", log_last_error.c_str()); log_flush(); throw log_cmd_error_exception(); } diff --git a/kernel/log.h b/kernel/log.h index fd35c7bf7..16ad7b6c9 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -50,6 +50,7 @@ extern bool log_error_stderr; extern bool log_cmd_error_throw; extern bool log_quiet_warnings; extern int log_verbose_level; +extern string log_last_error; void logv(const char *format, va_list ap); void logv_header(const char *format, va_list ap); |