From bb29546868f5748f1df657687c0405428f971d7d Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 12 Sep 2014 23:15:06 +0100 Subject: [PATCH] py: Load strings as objects when compiling viper. Eventually, viper wants to be able to use raw pointers to strings and arrays for efficient access. But for now, let's just load strings as a Python object so they can be used as normal. This will anyway be compatible with eventual intended viper behaviour. Addresses issue #857. --- py/emitnative.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/py/emitnative.c b/py/emitnative.c index 078ad5fc1..0bddfbaba 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -1017,12 +1017,17 @@ STATIC void emit_native_load_const_dec(emit_t *emit, qstr qst) { STATIC void emit_native_load_const_str(emit_t *emit, qstr qst, bool bytes) { emit_native_pre(emit); + // TODO: Eventually we want to be able to work with raw pointers in viper to + // do native array access. For now we just load them as any other object. + /* if (emit->do_viper_types) { // not implemented properly // load a pointer to the asciiz string? assert(0); emit_post_push_imm(emit, VTYPE_PTR, (mp_uint_t)qstr_str(qst)); - } else { + } else + */ + { if (bytes) { emit_call_with_imm_arg(emit, MP_F_LOAD_CONST_BYTES, qst, REG_ARG_1); } else {