Skip to content
Snippets Groups Projects
Select Git revision
  • d189f48e4decf7ca4f4adfc168ee1a72f3074d73
  • master default protected
  • fix-warnings
  • tvbgone-fixes
  • genofire/ble-follow-py
  • schneider/ble-stability-new-phy-adv
  • schneider/ble-stability
  • msgctl/gfx_rle
  • schneider/ble-stability-new-phy
  • add_menu_vibration
  • plaetzchen/ios-workaround
  • blinkisync-as-preload
  • schneider/max30001-pycardium
  • schneider/max30001-epicaridum
  • schneider/max30001
  • schneider/stream-locks
  • schneider/fundamental-test
  • schneider/ble-buffers
  • schneider/maxim-sdk-update
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • v1.11
  • v1.10
  • 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
36 results

bootstrap.sh

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    runtime.c 37.69 KiB
    // in principle, rt_xxx functions are called only by vm/native/viper and make assumptions about args
    // mp_xxx functions are safer and can be called by anyone
    // note that rt_assign_xxx are called only from emit*, and maybe we can rename them to reflect this
    
    #include <stdint.h>
    #include <stdlib.h>
    #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 "runtime0.h"
    #include "runtime.h"
    #include "map.h"
    #include "builtin.h"
    #include "objarray.h"
    #include "bc.h"
    
    #if 0 // print debugging info
    #define DEBUG_PRINT (1)
    #define WRITE_CODE (1)
    #define DEBUG_printf(args...) printf(args)
    #define DEBUG_OP_printf(args...) printf(args)
    #else // don't print debugging info
    #define DEBUG_printf(args...) (void)0
    #define DEBUG_OP_printf(args...) (void)0
    #endif
    
    // locals and globals need to be pointers because they can be the same in outer module scope
    static mp_map_t *map_locals;
    static mp_map_t *map_globals;
    static mp_map_t map_builtins;
    static mp_map_t map_loaded_modules; // TODO: expose as sys.modules
    
    typedef enum {
        MP_CODE_NONE,
        MP_CODE_BYTE,
        MP_CODE_NATIVE,
        MP_CODE_INLINE_ASM,
    } mp_code_kind_t;
    
    typedef struct _mp_code_t {
        struct {
            mp_code_kind_t kind : 8;
            bool is_generator : 1;
        };
        struct {
            uint n_args : 16;
            uint n_state : 16;
        };
        union {
            struct {
                byte *code;
                uint len;
            } u_byte;
            struct {
                mp_fun_t fun;
            } u_native;
            struct {
                void *fun;
            } u_inline_asm;
        };
    } mp_code_t;
    
    static uint next_unique_code_id;
    static machine_uint_t unique_codes_alloc = 0;