mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py: Add load_const_obj to emitter, add LOAD_CONST_OBJ to bytecode.
This allows to directly load a Python object to the Python stack. See issue #722 for background.
This commit is contained in:
@@ -487,6 +487,11 @@ STATIC void emit_bc_load_const_str(emit_t *emit, qstr qst, bool bytes) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void emit_bc_load_const_obj(emit_t *emit, void *obj) {
|
||||
emit_bc_pre(emit, 1);
|
||||
emit_write_bytecode_byte_ptr(emit, MP_BC_LOAD_CONST_OBJ, obj);
|
||||
}
|
||||
|
||||
STATIC void emit_bc_load_null(emit_t *emit) {
|
||||
emit_bc_pre(emit, 1);
|
||||
emit_write_bytecode_byte(emit, MP_BC_LOAD_NULL);
|
||||
@@ -917,6 +922,7 @@ const emit_method_table_t emit_bc_method_table = {
|
||||
emit_bc_load_const_int,
|
||||
emit_bc_load_const_dec,
|
||||
emit_bc_load_const_str,
|
||||
emit_bc_load_const_obj,
|
||||
emit_bc_load_null,
|
||||
emit_bc_load_fast,
|
||||
emit_bc_load_deref,
|
||||
|
||||
Reference in New Issue
Block a user