Skip to content

Commit 3417bc2

Browse files
committed
py: Rename byte_code to bytecode everywhere.
bytecode is the more widely used. See issue adafruit#590.
1 parent 6e8085b commit 3417bc2

13 files changed

Lines changed: 184 additions & 184 deletions

File tree

examples/micropython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
def nodecor(x):
66
return x
77

8-
byte_code = native = viper = nodecor
8+
bytecode = native = viper = nodecor

py/bc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ typedef struct _mp_exc_stack {
3636
byte opcode;
3737
} mp_exc_stack_t;
3838

39-
mp_vm_return_kind_t mp_execute_byte_code(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret);
40-
mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **ip_in_out, mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, volatile mp_obj_t inject_exc);
41-
void mp_byte_code_print(const byte *code, int len);
42-
void mp_byte_code_print2(const byte *code, int len);
39+
mp_vm_return_kind_t mp_execute_bytecode(const byte *code, const mp_obj_t *args, uint n_args, const mp_obj_t *args2, uint n_args2, mp_obj_t *ret);
40+
mp_vm_return_kind_t mp_execute_bytecode2(const byte *code_info, const byte **ip_in_out, mp_obj_t *fastn, mp_obj_t **sp_in_out, mp_exc_stack_t *exc_stack, mp_exc_stack_t **exc_sp_in_out, volatile mp_obj_t inject_exc);
41+
void mp_bytecode_print(const byte *code, int len);
42+
void mp_bytecode_print2(const byte *code, int len);
4343

4444
// Helper macros to access pointer with least significant bit holding a flag
4545
#define MP_TAGPTR_PTR(x) ((void*)((machine_uint_t)(x) & ~((machine_uint_t)1)))

py/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ STATIC bool compile_built_in_decorator(compiler_t *comp, int name_len, mp_parse_
11461146
}
11471147

11481148
qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]);
1149-
if (attr == MP_QSTR_byte_code) {
1149+
if (attr == MP_QSTR_bytecode) {
11501150
*emit_options = MP_EMIT_OPT_BYTE_CODE;
11511151
#if MICROPY_EMIT_NATIVE
11521152
} else if (attr == MP_QSTR_native) {

py/emitbc.c

Lines changed: 147 additions & 147 deletions
Large diffs are not rendered by default.

py/emitcpy.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
struct _emit_t {
4848
int pass;
49-
int byte_code_offset;
49+
int bytecode_offset;
5050
int stack_size;
5151
bool last_emit_was_return_value;
5252

@@ -68,7 +68,7 @@ STATIC void emit_cpy_set_native_types(emit_t *emit, bool do_native_types) {
6868

6969
STATIC void emit_cpy_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
7070
emit->pass = pass;
71-
emit->byte_code_offset = 0;
71+
emit->bytecode_offset = 0;
7272
emit->stack_size = 0;
7373
emit->last_emit_was_return_value = false;
7474
emit->scope = scope;
@@ -108,20 +108,20 @@ STATIC void emit_cpy_delete_id(emit_t *emit, qstr qstr) {
108108
}
109109

110110
// TODO: module-polymorphic function (read: name clash if made global)
111-
static void emit_pre(emit_t *emit, int stack_size_delta, int byte_code_size) {
111+
static void emit_pre(emit_t *emit, int stack_size_delta, int bytecode_size) {
112112
emit->stack_size += stack_size_delta;
113113
if (emit->stack_size > emit->scope->stack_size) {
114114
emit->scope->stack_size = emit->stack_size;
115115
}
116116
emit->last_emit_was_return_value = false;
117-
if (emit->pass == MP_PASS_EMIT && byte_code_size > 0) {
118-
if (emit->byte_code_offset >= 1000) {
119-
printf("%d ", emit->byte_code_offset);
117+
if (emit->pass == MP_PASS_EMIT && bytecode_size > 0) {
118+
if (emit->bytecode_offset >= 1000) {
119+
printf("%d ", emit->bytecode_offset);
120120
} else {
121-
printf("% 4d ", emit->byte_code_offset);
121+
printf("% 4d ", emit->bytecode_offset);
122122
}
123123
}
124-
emit->byte_code_offset += byte_code_size;
124+
emit->bytecode_offset += bytecode_size;
125125
}
126126

127127
STATIC void emit_cpy_label_assign(emit_t *emit, uint l) {
@@ -130,11 +130,11 @@ STATIC void emit_cpy_label_assign(emit_t *emit, uint l) {
130130
if (emit->pass < MP_PASS_EMIT) {
131131
// assign label offset
132132
assert(emit->label_offsets[l] == -1);
133-
emit->label_offsets[l] = emit->byte_code_offset;
133+
emit->label_offsets[l] = emit->bytecode_offset;
134134
} else {
135135
// ensure label offset has not changed from MP_PASS_CODE_SIZE to MP_PASS_EMIT
136-
assert(emit->label_offsets[l] == emit->byte_code_offset);
137-
//printf("l%d: (at %d)\n", l, emit->byte_code_offset);
136+
assert(emit->label_offsets[l] == emit->bytecode_offset);
137+
//printf("l%d: (at %d)\n", l, emit->bytecode_offset);
138138
}
139139
}
140140

@@ -421,7 +421,7 @@ STATIC void emit_cpy_jump(emit_t *emit, uint label) {
421421
emit_pre(emit, 0, 3);
422422
if (emit->pass == MP_PASS_EMIT) {
423423
int dest = emit->label_offsets[label];
424-
if (dest < emit->byte_code_offset) {
424+
if (dest < emit->bytecode_offset) {
425425
printf("JUMP_ABSOLUTE %d\n", emit->label_offsets[label]);
426426
} else {
427427
printf("JUMP_FORWARD %d\n", emit->label_offsets[label]);

py/emitglue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ mp_raw_code_t *mp_emit_glue_new_raw_code(void) {
7373
return rc;
7474
}
7575

76-
void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint n_pos_args, uint n_kwonly_args, qstr *arg_names, uint scope_flags) {
76+
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) {
7777
rc->kind = MP_CODE_BYTE;
7878
rc->scope_flags = scope_flags;
7979
rc->n_pos_args = n_pos_args;
@@ -99,7 +99,7 @@ void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint
9999
#endif
100100
#if MICROPY_DEBUG_PRINTERS
101101
if (mp_verbose_flag > 0) {
102-
mp_byte_code_print(code, len);
102+
mp_bytecode_print(code, len);
103103
}
104104
#endif
105105
}

py/emitglue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void mp_emit_glue_deinit(void);
5959

6060
mp_raw_code_t *mp_emit_glue_new_raw_code(void);
6161

62-
void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint n_pos_args, uint n_kwonly_args, qstr *arg_names, uint scope_flags);
62+
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);
6363
void mp_emit_glue_assign_native_code(mp_raw_code_t *rc, void *f, uint len, int n_args);
6464
void mp_emit_glue_assign_inline_asm_code(mp_raw_code_t *rc, void *f, uint len, int n_args);
6565

py/mpconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100

101101
// Whether to build functions that print debugging info:
102102
// mp_token_show
103-
// mp_byte_code_print
103+
// mp_bytecode_print
104104
// mp_parse_node_print
105105
#ifndef MICROPY_DEBUG_PRINTERS
106106
#define MICROPY_DEBUG_PRINTERS (0)

py/objfun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ continue2:;
378378
DEBUG_printf("Calling: args=%p, n_args=%d, extra_args=%p, n_extra_args=%d\n", args, n_args, extra_args, n_extra_args);
379379
dump_args(args, n_args);
380380
dump_args(extra_args, n_extra_args);
381-
mp_vm_return_kind_t vm_return_kind = mp_execute_byte_code(self->bytecode, args, n_args, extra_args, n_extra_args, &result);
381+
mp_vm_return_kind_t vm_return_kind = mp_execute_bytecode(self->bytecode, args, n_args, extra_args, n_extra_args, &result);
382382
mp_globals_set(old_globals);
383383

384384
if (vm_return_kind == MP_VM_RETURN_NORMAL) {

py/objgenerator.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
118118
}
119119
mp_obj_dict_t *old_globals = mp_globals_get();
120120
mp_globals_set(self->globals);
121-
mp_vm_return_kind_t ret_kind = mp_execute_byte_code_2(self->code_info, &self->ip,
121+
mp_vm_return_kind_t ret_kind = mp_execute_bytecode2(self->code_info, &self->ip,
122122
&self->state[self->n_state - 1], &self->sp, (mp_exc_stack_t*)(self->state + self->n_state),
123123
&self->exc_sp, throw_value);
124124
mp_globals_set(old_globals);
@@ -276,7 +276,7 @@ mp_obj_t mp_obj_new_gen_instance(mp_obj_dict_t *globals, const byte *bytecode, u
276276
o->exc_sp = (mp_exc_stack_t*)(o->state + n_state) - 1;
277277
o->n_state = n_state;
278278

279-
// copy args to end of state array, in reverse (that's how mp_execute_byte_code_2 needs it)
279+
// copy args to end of state array, in reverse (that's how mp_execute_bytecode2 needs it)
280280
for (uint i = 0; i < n_args; i++) {
281281
o->state[n_state - 1 - i] = args[i];
282282
}

0 commit comments

Comments
 (0)