<commit_before>#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

#include "misc.h"
#include "mpyconfig.h"
#include "runtime.h"
#include "bc.h"

#define DECODE_UINT do { unum = *ip++; if (unum > 127) { unum = ((unum & 0x3f) << 8) | (*ip++); } } while (0)
#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
#define DECODE_QSTR do { qstr = *ip++; if (qstr > 127) { qstr = ((qstr & 0x3f) << 8) | (*ip++); } } while (0)

void py_show_byte_code(const byte *ip, int len) {
    const byte *ip_start = ip;
    machine_uint_t unum;
    qstr qstr;
    while (ip - ip_start < len) {
        printf("%02u ", (uint)(ip - ip_start));
        int op = *ip++;
        switch (op) {
            case PYBC_LOAD_CONST_FALSE:
                printf("LOAD_CONST_FALSE");
                break;

            case PYBC_LOAD_CONST_NONE:
                printf("LOAD_CONST_NONE");
                break;

            case PYBC_LOAD_CONST_TRUE:
                printf("LOAD_CONST_TRUE");
                break;

            case PYBC_LOAD_CONST_SMALL_INT:
                unum = (ip[0] | (ip[1] << 8) | (ip[2] << 16)) - 0x800000;
                ip += 3;
                printf("LOAD_CONST_SMALL_INT %d", (int)unum);
                break;

                /*
            case PYBC_LOAD_CONST_DEC:
                DECODE_QSTR;
                PUSH(rt_load_const_dec(qstr));
                break;

            case PYBC_LOAD_CONST_ID:
                DECODE_QSTR;
                PUSH(rt_load_const_str(qstr)); // TODO
                break;

            case PYBC_LOAD_CONST_STRING:
                DECODE_QSTR;
                PUSH(rt_load_const_str(qstr));
                break;
                */

            case PYBC_LOAD_FAST_0:
                printf("LOAD_FAST_0");
                break;

            case PYBC_LOAD_FAST_1:
                printf("LOAD_FAST_1");
                break;

            case PYBC_LOAD_FAST_2:
                printf("LOAD_FAST_2");
                break;

                /*
            case PYBC_LOAD_FAST_N:
                DECODE_UINT;
                PUSH(fastn[unum]);
                break;
                */

            case PYBC_LOAD_NAME:
                DECODE_QSTR;
                printf("LOAD_NAME %s", qstr_str(qstr));
                break;

            case PYBC_LOAD_GLOBAL:
                DECODE_QSTR;
                printf("LOAD_GLOBAL %s", qstr_str(qstr));
                break;

                /*
            case PYBC_LOAD_ATTR:
                DECODE_QSTR;
                *sp = rt_load_attr(*sp, qstr);
                break;
                */

            case PYBC_LOAD_METHOD:
                DECODE_QSTR;
                printf("LOAD_METHOD %s", qstr_str(qstr));
                break;

                /*
            case PYBC_LOAD_BUILD_CLASS:
                PUSH(rt_load_build_class());
                break;
                */

            case PYBC_STORE_FAST_0:
                printf("STORE_FAST_0");
                break;

            case PYBC_STORE_FAST_1:
                printf("STORE_FAST_1");
                break;

            case PYBC_STORE_FAST_2:
                printf("STORE_FAST_2");
                break;

                /*
            case PYBC_STORE_FAST_N:
                DECODE_UINT;
                fastn[unum] = POP();
                break;
                */

            case PYBC_STORE_NAME:
                DECODE_QSTR;
                printf("STORE_NAME %s", qstr_str(qstr));
                break;

                /*
            case PYBC_STORE_GLOBAL:
                DECODE_QSTR;
                rt_store_global(qstr, POP());
                break;

            case PYBC_STORE_ATTR:
                DECODE_QSTR;
                rt_store_attr(sp[0], qstr, sp[1]);
                sp += 2;
                break;

            case PYBC_STORE_SUBSCR:
                rt_store_subscr(sp[1], sp[0], sp[2]);
                sp += 3;
                break;

            case PYBC_DUP_TOP:
                obj1 = *sp;
                PUSH(obj1);
                break;

            case PYBC_DUP_TOP_TWO:
                sp -= 2;
                sp[0] = sp[2];
                sp[1] = sp[3];
                break;
                */

            case PYBC_POP_TOP:
                printf("POP_TOP");
                break;
<commit_msg>py: add some more opcodes to showbc.<commit_after>#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

#include "misc.h"
#include "mpyconfig.h"
#include "runtime.h"
#include "bc.h"

#define DECODE_UINT do { unum = *ip++; if (unum > 127) { unum = ((unum & 0x3f) << 8) | (*ip++); } } while (0)
#define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
#define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
#define DECODE_QSTR do { qstr = *ip++; if (qstr > 127) { qstr = ((qstr & 0x3f) << 8) | (*ip++); } } while (0)

void py_show_byte_code(const byte *ip, int len) {
    const byte *ip_start = ip;
    machine_uint_t unum;
    qstr qstr;
    while (ip - ip_start < len) {
        printf("%02u ", (uint)(ip - ip_start));
        int op = *ip++;
        switch (op) {
            case PYBC_LOAD_CONST_FALSE:
                printf("LOAD_CONST_FALSE");
                break;

            case PYBC_LOAD_CONST_NONE:
                printf("LOAD_CONST_NONE");
                break;

            case PYBC_LOAD_CONST_TRUE:
                printf("LOAD_CONST_TRUE");
                break;

            case PYBC_LOAD_CONST_SMALL_INT:
                unum = (ip[0] | (ip[1] << 8) | (ip[2] << 16)) - 0x800000;
                ip += 3;
                printf("LOAD_CONST_SMALL_INT %d", (int)unum);
                break;

                /*
            case PYBC_LOAD_CONST_DEC:
                DECODE_QSTR;
                PUSH(rt_load_const_dec(qstr));
                break;
                */

            case PYBC_LOAD_CONST_ID:
                DECODE_QSTR;
                printf("LOAD_CONST_ID %s", qstr_str(qstr));
                break;

                /*
            case PYBC_LOAD_CONST_STRING:
                DECODE_QSTR;
                PUSH(rt_load_const_str(qstr));
                break;
                */

            case PYBC_LOAD_FAST_0:
                printf("LOAD_FAST_0");
                break;

            case PYBC_LOAD_FAST_1:
                printf("LOAD_FAST_1");
                break;

            case PYBC_LOAD_FAST_2:
                printf("LOAD_FAST_2");
                break;

                /*
            case PYBC_LOAD_FAST_N:
                DECODE_UINT;
                PUSH(fastn[unum]);
                break;
                */

            case PYBC_LOAD_NAME:
                DECODE_QSTR;
                printf("LOAD_NAME %s", qstr_str(qstr));
                break;

            case PYBC_LOAD_GLOBAL:
                DECODE_QSTR;
                printf("LOAD_GLOBAL %s", qstr_str(qstr));
                break;

            case PYBC_LOAD_ATTR:
                DECODE_QSTR;
                printf("LOAD_ATTR %s", qstr_str(qstr));
                break;

            case PYBC_LOAD_METHOD:
                DECODE_QSTR;
                printf("LOAD_METHOD %s", qstr_str(qstr));
                break;

            case PYBC_LOAD_BUILD_CLASS:
                printf("LOAD_BUILD_CLASS");
                break;

            case PYBC_STORE_FAST_0:
                printf("STORE_FAST_0");
                break;

            case PYBC_STORE_FAST_1:
                printf("STORE_FAST_1");
                break;

            case PYBC_STORE_FAST_2:
                printf("STORE_FAST_2");
                break;

                /*
            case PYBC_STORE_FAST_N:
                DECODE_UINT;
                fastn[unum] = POP();
                break;
                */

            case PYBC_STORE_NAME:
                DECODE_QSTR;
                printf("STORE_NAME %s", qstr_str(qstr));
                break;

                /*
            case PYBC_STORE_GLOBAL:
                DECODE_QSTR;
                rt_store_global(qstr, POP());
                break;
                */

            case PYBC_STORE_ATTR:
                DECODE_QSTR;
                printf("STORE_ATTR %s", qstr_str(qstr));
                break;

                /*
            case PYBC_STORE_SUBSCR:
                rt_store_subscr(sp[1], sp[0], sp[2]);
                sp += 3;
                break;

            case PYBC_DUP_TOP:
                obj1 = *sp;
                PUSH(obj1);
                break;

            case PYBC_DUP_TOP_TWO:
                sp -= 2;
                sp[0] = sp[2];
                sp[1] = sp[3];
                break;
                */

            case PYBC_POP_TOP:
                printf("POP_TOP");
                break;

{'fraction_non_alphanumeric': 0.10681338223852395, 'fraction_numerical': 0.015449594309214183, 'mean_word_length': 1.1423809523809523, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '593452', 'n_tokens_mistral': 3099, 'n_tokens_neox': 2820, 'n_words': 517}