Exemple #1
0
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code, mp_uint_t len,
    const mp_uint_t *const_table,
    #if MICROPY_PERSISTENT_CODE_SAVE
    uint16_t n_obj, uint16_t n_raw_code,
    #endif
    mp_uint_t scope_flags) {

    rc->kind = MP_CODE_BYTECODE;
    rc->scope_flags = scope_flags;
    rc->data.u_byte.bytecode = code;
    rc->data.u_byte.const_table = const_table;
    #if MICROPY_PERSISTENT_CODE_SAVE
    rc->data.u_byte.bc_len = len;
    rc->data.u_byte.n_obj = n_obj;
    rc->data.u_byte.n_raw_code = n_raw_code;
    #endif

#ifdef DEBUG_PRINT
    DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags);
#endif
#if MICROPY_DEBUG_PRINTERS
    if (mp_verbose_flag >= 2) {
        mp_bytecode_print(rc, code, len, const_table);
    }
#endif
}
Exemple #2
0
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, byte *code, uint len, uint n_pos_args, uint n_kwonly_args, qstr *arg_names, uint scope_flags) {
    rc->kind = MP_CODE_BYTECODE;
    rc->scope_flags = scope_flags;
    rc->n_pos_args = n_pos_args;
    rc->n_kwonly_args = n_kwonly_args;
    rc->arg_names = arg_names;
    rc->u_byte.code = code;
    rc->u_byte.len = len;

#ifdef DEBUG_PRINT
    DEBUG_printf("assign byte code: code=%p len=%u n_pos_args=%d n_kwonly_args=%d flags=%x\n", code, len, n_pos_args, n_kwonly_args, scope_flags);
    DEBUG_printf("  arg names:");
    for (int i = 0; i < n_pos_args + n_kwonly_args; i++) {
        DEBUG_printf(" %s", qstr_str(arg_names[i]));
    }
    DEBUG_printf("\n");
#endif
#if MICROPY_DEBUG_PRINTERS
    if (mp_verbose_flag > 0) {
        for (int i = 0; i < 128 && i < len; i++) {
            if (i > 0 && i % 16 == 0) {
                printf("\n");
            }
            printf(" %02x", code[i]);
        }
        printf("\n");
        mp_bytecode_print(rc, code, len);
    }
#endif
}
Exemple #3
0
void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, byte *code, mp_uint_t len, mp_uint_t n_pos_args, mp_uint_t n_kwonly_args, mp_uint_t scope_flags) {
    rc->kind = MP_CODE_BYTECODE;
    rc->scope_flags = scope_flags;
    rc->n_pos_args = n_pos_args;
    rc->n_kwonly_args = n_kwonly_args;
    rc->u_byte.code = code;
    rc->u_byte.len = len;

#ifdef DEBUG_PRINT
    DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " n_pos_args=" UINT_FMT " n_kwonly_args=" UINT_FMT " flags=%x\n", code, len, n_pos_args, n_kwonly_args, (uint)scope_flags);
#endif
#if MICROPY_DEBUG_PRINTERS
    if (mp_verbose_flag > 0) {
        mp_bytecode_print(rc, n_pos_args + n_kwonly_args, code, len);
    }
#endif
}