summaryrefslogtreecommitdiff
path: root/py/emitbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-13 15:55:54 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-13 15:55:54 +0000
commitdab1385177558f1d27c03b59e443b6fa25a2cdc0 (patch)
treeda284535f901727c739266c2bf50ed5bbec88f1a /py/emitbc.c
parentd710cef6610eff758e96f351e6b91c1c9d8df9f6 (diff)
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.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r--py/emitbc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index 4560d1ec6..d63739125 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -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,