Skip to content
Snippets Groups Projects
Select Git revision
  • b64e91b8f1746dfaf422b026b744824861e28cf9
  • master default protected
  • backslash
  • nickname-match-configs
  • genofire/leds_rgb_get_state
  • genofire/rockets-state
  • genofire/ble-follow-py
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • genofire/haule-ble-fs-deactive
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • ios-workarounds
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • koalo/wip/i2c-for-python
  • v1.9
  • v1.8
  • v1.7
  • v1.6
  • v1.5
  • v1.4
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
34 results

core1-dispatcher.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    runtime.c 41.35 KiB
    #include <stdio.h>
    #include <string.h>
    #include <assert.h>
    
    #include "nlr.h"
    #include "misc.h"
    #include "mpconfig.h"
    #include "qstr.h"
    #include "obj.h"
    #include "objtuple.h"
    #include "objmodule.h"
    #include "parsenum.h"
    #include "runtime0.h"
    #include "runtime.h"
    #include "emitglue.h"
    #include "builtin.h"
    #include "builtintables.h"
    #include "bc.h"
    #include "smallint.h"
    #include "objgenerator.h"
    
    #if 0 // print debugging info
    #define DEBUG_PRINT (1)
    #define DEBUG_printf DEBUG_printf
    #define DEBUG_OP_printf(...) DEBUG_printf(__VA_ARGS__)
    #else // don't print debugging info
    #define DEBUG_printf(...) (void)0
    #define DEBUG_OP_printf(...) (void)0
    #endif
    
    // locals and globals need to be pointers because they can be the same in outer module scope
    STATIC mp_obj_dict_t *dict_locals;
    STATIC mp_obj_dict_t *dict_globals;
    
    // dictionary for the __main__ module
    STATIC mp_obj_dict_t dict_main;
    
    const mp_obj_module_t mp_module___main__ = {
        .base = { &mp_type_module },
        .name = MP_QSTR___main__,
        .globals = (mp_obj_dict_t*)&dict_main,
    };
    
    void mp_init(void) {
        mp_emit_glue_init();
    
        // init global module stuff
        mp_module_init();
    
        // initialise the __main__ module
        mp_obj_dict_init(&dict_main, 1);
        mp_obj_dict_store(&dict_main, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__));
    
        // locals = globals for outer module (see Objects/frameobject.c/PyFrame_New())
        dict_locals = dict_globals = &dict_main;
    
    #if MICROPY_CPYTHON_COMPAT
        // Precreate sys module, so "import sys" didn't throw exceptions.
        mp_obj_t m_sys = mp_obj_new_module(MP_QSTR_sys);
        // Avoid warning of unused var
        (void)m_sys;
    #endif
        // init sys.path
        // for efficiency, left to platform-specific startup code
        //mp_sys_path = mp_obj_new_list(0, NULL);
        //mp_store_attr(m_sys, MP_QSTR_path, mp_sys_path);
    }
    
    void mp_deinit(void) {
        //mp_obj_dict_free(&dict_main);