wip; Trinket M0 compiles
This commit is contained in:
parent
2ff8667e75
commit
0dca530b70
6
py/obj.c
6
py/obj.c
|
@ -231,7 +231,11 @@ void mp_obj_print_exception_with_limit(const mp_print_t *print, mp_obj_t exc, mp
|
|||
mp_print_str(print, "\n");
|
||||
}
|
||||
|
||||
bool mp_obj_is_true(mp_obj_t arg) {
|
||||
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc) {
|
||||
mp_obj_print_exception_with_limit(print, exc, 0);
|
||||
}
|
||||
|
||||
bool PLACE_IN_ITCM(mp_obj_is_true)(mp_obj_t arg) {
|
||||
if (arg == mp_const_false) {
|
||||
return 0;
|
||||
} else if (arg == mp_const_true) {
|
||||
|
|
|
@ -336,42 +336,36 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
|
|||
MP_DEFINE_EXCEPTION(AssertionError, Exception)
|
||||
MP_DEFINE_EXCEPTION(AttributeError, Exception)
|
||||
// MP_DEFINE_EXCEPTION(BufferError, Exception)
|
||||
// MP_DEFINE_EXCEPTION(EnvironmentError, Exception) use OSError instead
|
||||
MP_DEFINE_EXCEPTION(EOFError, Exception)
|
||||
MP_DEFINE_EXCEPTION(ImportError, Exception)
|
||||
// MP_DEFINE_EXCEPTION(IOError, Exception) use OSError instead
|
||||
MP_DEFINE_EXCEPTION(LookupError, Exception)
|
||||
MP_DEFINE_EXCEPTION(IndexError, LookupError)
|
||||
MP_DEFINE_EXCEPTION(KeyError, LookupError)
|
||||
MP_DEFINE_EXCEPTION(MemoryError, Exception)
|
||||
MP_DEFINE_EXCEPTION(NameError, Exception)
|
||||
/*
|
||||
MP_DEFINE_EXCEPTION(UnboundLocalError, NameError)
|
||||
*/
|
||||
// MP_DEFINE_EXCEPTION(UnboundLocalError, NameError)
|
||||
MP_DEFINE_EXCEPTION(OSError, Exception)
|
||||
/*
|
||||
MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
|
||||
MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
|
||||
MP_DEFINE_EXCEPTION(ConnectionError, OSError)
|
||||
MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError)
|
||||
MP_DEFINE_EXCEPTION(ConnectionAbortedError, ConnectionError)
|
||||
MP_DEFINE_EXCEPTION(ConnectionRefusedError, ConnectionError)
|
||||
MP_DEFINE_EXCEPTION(ConnectionResetError, ConnectionError)
|
||||
MP_DEFINE_EXCEPTION(InterruptedError, OSError)
|
||||
MP_DEFINE_EXCEPTION(IsADirectoryError, OSError)
|
||||
MP_DEFINE_EXCEPTION(NotADirectoryError, OSError)
|
||||
MP_DEFINE_EXCEPTION(PermissionError, OSError)
|
||||
MP_DEFINE_EXCEPTION(ProcessLookupError, OSError)
|
||||
MP_DEFINE_EXCEPTION(TimeoutError, OSError)
|
||||
MP_DEFINE_EXCEPTION(FileExistsError, OSError)
|
||||
// MP_DEFINE_EXCEPTION(ConnectionAbortedError, ConnectionError)
|
||||
// MP_DEFINE_EXCEPTION(ConnectionRefusedError, ConnectionError)
|
||||
// MP_DEFINE_EXCEPTION(ConnectionResetError, ConnectionError)
|
||||
// MP_DEFINE_EXCEPTION(FileExistsError, OSError)
|
||||
MP_DEFINE_EXCEPTION(FileNotFoundError, OSError)
|
||||
MP_DEFINE_EXCEPTION(ReferenceError, Exception)
|
||||
*/
|
||||
// MP_DEFINE_EXCEPTION(InterruptedError, OSError)
|
||||
// MP_DEFINE_EXCEPTION(IsADirectoryError, OSError)
|
||||
// MP_DEFINE_EXCEPTION(NotADirectoryError, OSError)
|
||||
// MP_DEFINE_EXCEPTION(PermissionError, OSError)
|
||||
// MP_DEFINE_EXCEPTION(ProcessLookupError, OSError)
|
||||
// MP_DEFINE_EXCEPTION(ReferenceError, Exception)
|
||||
MP_DEFINE_EXCEPTION(TimeoutError, OSError)
|
||||
MP_DEFINE_EXCEPTION(RuntimeError, Exception)
|
||||
MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError)
|
||||
MP_DEFINE_EXCEPTION(SyntaxError, Exception)
|
||||
MP_DEFINE_EXCEPTION(IndentationError, SyntaxError)
|
||||
/*
|
||||
MP_DEFINE_EXCEPTION(TabError, IndentationError)
|
||||
*/
|
||||
// MP_DEFINE_EXCEPTION(TabError, IndentationError)
|
||||
// MP_DEFINE_EXCEPTION(SystemError, Exception)
|
||||
MP_DEFINE_EXCEPTION(TypeError, Exception)
|
||||
#if MICROPY_EMIT_NATIVE
|
||||
|
|
|
@ -161,6 +161,18 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
|
|||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t self_in) {
|
||||
assert(mp_obj_is_type(self_in, &mp_type_module));
|
||||
mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
return self->globals;
|
||||
}
|
||||
|
||||
void mp_obj_module_set_globals(mp_obj_t self_in, mp_obj_dict_t *globals) {
|
||||
assert(mp_obj_is_type(self_in, &mp_type_module));
|
||||
mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
self->globals = globals;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// Global module table and related functions
|
||||
|
||||
|
|
11
py/runtime.c
11
py/runtime.c
|
@ -62,6 +62,8 @@ const mp_obj_module_t mp_module___main__ = {
|
|||
.globals = (mp_obj_dict_t *)&MP_STATE_VM(dict_main),
|
||||
};
|
||||
|
||||
MP_REGISTER_MODULE(MP_QSTR___main__, mp_module___main__);
|
||||
|
||||
void mp_init(void) {
|
||||
qstr_init();
|
||||
|
||||
|
@ -144,6 +146,11 @@ void mp_init(void) {
|
|||
MP_STATE_VM(sys_exitfunc) = mp_const_none;
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_SYS_PS1_PS2
|
||||
MP_STATE_VM(sys_mutable[MP_SYS_MUTABLE_PS1]) = MP_OBJ_NEW_QSTR(MP_QSTR__gt__gt__gt__space_);
|
||||
MP_STATE_VM(sys_mutable[MP_SYS_MUTABLE_PS2]) = MP_OBJ_NEW_QSTR(MP_QSTR__dot__dot__dot__space_);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_SYS_SETTRACE
|
||||
MP_STATE_THREAD(prof_trace_callback) = MP_OBJ_NULL;
|
||||
MP_STATE_THREAD(prof_callback_is_executing) = false;
|
||||
|
@ -1810,3 +1817,7 @@ NORETURN MP_COLD void mp_raise_recursion_depth(void) {
|
|||
mp_raise_RuntimeError(MP_ERROR_TEXT("maximum recursion depth exceeded"));
|
||||
}
|
||||
#endif
|
||||
|
||||
NORETURN MP_COLD void mp_raise_ZeroDivisionError(void) {
|
||||
mp_raise_msg(&mp_type_ZeroDivisionError, MP_ERROR_TEXT("division by zero"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue