Merge branch 'omega-dev-e14' of github.com:Omega-Numworks/Omega into omega-dev-e14

This commit is contained in:
Quentin Guidée
2020-07-15 12:09:28 +02:00
4 changed files with 19236 additions and 19193 deletions

View File

@@ -69,6 +69,7 @@ help:
@echo " make PLATFORM=simulator TARGET=macos"
@echo " make PLATFORM=simulator TARGET=web"
@echo " make PLATFORM=simulator TARGET=windows"
@echo " make PLATFORM=simulator TARGET=3ds"
.PHONY: doc
doc:

View File

@@ -2,11 +2,11 @@
ifndef NO_PIMP
PLS_IGNORE := $(shell >&2 printf "\e[91m\e[1m ____ \n")
PLS_IGNORE := $(shell >&2 printf " / __ \\____ ___ ___ ____ _____ _ \n")
PLS_IGNORE := $(shell >&2 printf " / / / / __ \`__ \\/ _ \\/ __ \`/ __ \`/ \n")
PLS_IGNORE := $(shell >&2 printf " / /_/ / / / / / / __/ /_/ / /_/ / \n")
PLS_IGNORE := $(shell >&2 printf " \\____/_/ /_/ /_/\\___/\\__, /\\__,_/ \n")
PLS_IGNORE := $(shell >&2 printf " /____/ \n")
PLS_IGNORE := $(shell >&2 printf "\e[91m\e[1m / __ \\____ ___ ___ ____ _____ _ \n")
PLS_IGNORE := $(shell >&2 printf "\e[91m\e[1m / / / / __ \`__ \\/ _ \\/ __ \`/ __ \`/ \n")
PLS_IGNORE := $(shell >&2 printf "\e[91m\e[1m / /_/ / / / / / / __/ /_/ / /_/ / \n")
PLS_IGNORE := $(shell >&2 printf "\e[91m\e[1m \\____/_/ /_/ /_/\\___/\\__, /\\__,_/ \n")
PLS_IGNORE := $(shell >&2 printf "\e[91m\e[1m /____/ \n")
PLS_IGNORE := $(shell >&2 printf "\e[33m - Omega does what Epsilon't \e[0m\n")
PLS_IGNORE := $(shell >&2 printf "\n")
PLS_IGNORE := $(shell >&2 printf "\e[32mBuilding O$(OMEGA_VERSION)-E$(EPSILON_VERSION)\n")

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,38 @@
#include <string.h>
#include <setjmp.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
void python_error_start(const char* type) {
EM_ASM({
Module.___temp_python_error = new Object();
Module.___temp_python_error["stacktrace"] = new Array();
Module.___temp_python_error["type"] = Module.UTF8ToString($0);
}, type);
}
void python_error_add_trace(const char* file, int line, const char* block) {
EM_ASM({
var temp_obj = new Object();
temp_obj["file"] = Module.UTF8ToString($0);
temp_obj["line"] = $1;
temp_obj["block"] = Module.UTF8ToString($2);
Module.___temp_python_error.stacktrace.push(temp_obj);
}, file, line, block);
}
void python_error_end() {
EM_ASM({
if (typeof Module.onPythonError === "function") {
Module.onPythonError(Module.___temp_python_error);
}
delete Module.___temp_python_error;
});
}
#endif
/* py/parsenum.h is a C header which uses C keyword restrict.
* It does not exist in C++ so we define it here in order to be able to include
* py/parsenum.h header. */
@@ -65,6 +97,10 @@ bool MicroPython::ExecutionEnvironment::runCode(const char * str) {
* because we want to print custom information, we copied and modified the
* content of mp_obj_print_exception instead of calling it. */
if (mp_obj_is_exception_instance((mp_obj_t)nlr.ret_val)) {
#ifdef __EMSCRIPTEN__
mp_obj_exception_t* the_exception = (mp_obj_exception_t*) MP_OBJ_TO_PTR((mp_obj_t)nlr.ret_val);
python_error_start(qstr_str(the_exception->base.type->name));
#endif
size_t n, *values;
mp_obj_exception_get_traceback((mp_obj_t)nlr.ret_val, &n, &values);
if (n > 0) {
@@ -74,6 +110,9 @@ bool MicroPython::ExecutionEnvironment::runCode(const char * str) {
if (values[i] == 0) {
mp_printf(&mp_plat_print, " Last command\n");
} else {
#ifdef __EMSCRIPTEN__
python_error_add_trace((const char*) qstr_str(values[i]), (int) values[i + 1], (const char*) qstr_str(values[i+2]));
#endif
#if MICROPY_ENABLE_SOURCE_LINE
mp_printf(&mp_plat_print, " File \"%q\", line %d", values[i], (int)values[i + 1]);
#else
@@ -90,6 +129,9 @@ bool MicroPython::ExecutionEnvironment::runCode(const char * str) {
}
}
}
#ifdef __EMSCRIPTEN__
python_error_end();
#endif
}
mp_obj_print_helper(&mp_plat_print, (mp_obj_t)nlr.ret_val, PRINT_EXC);
mp_print_str(&mp_plat_print, "\n");