mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
py: Parse big-int/float/imag constants directly in parser.
Previous to this patch, a big-int, float or imag constant was interned (made into a qstr) and then parsed at runtime to create an object each time it was needed. This is wasteful in RAM and not efficient. Now, these constants are parsed straight away in the parser and turned into objects. This allows constants with large numbers of digits (so addresses issue #1103) and takes us a step closer to #722.
This commit is contained in:
@@ -1142,21 +1142,6 @@ STATIC void emit_native_load_const_small_int(emit_t *emit, mp_int_t arg) {
|
||||
}
|
||||
}
|
||||
|
||||
STATIC void emit_native_load_const_int(emit_t *emit, qstr qst) {
|
||||
DEBUG_printf("load_const_int %s\n", qstr_str(qst));
|
||||
// for viper: load integer, check fits in 32 bits
|
||||
emit_native_pre(emit);
|
||||
emit_call_with_imm_arg(emit, MP_F_LOAD_CONST_INT, qst, REG_ARG_1);
|
||||
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
|
||||
}
|
||||
|
||||
STATIC void emit_native_load_const_dec(emit_t *emit, qstr qst) {
|
||||
// for viper, a float/complex is just a Python object
|
||||
emit_native_pre(emit);
|
||||
emit_call_with_imm_arg(emit, MP_F_LOAD_CONST_DEC, qst, REG_ARG_1);
|
||||
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -2317,8 +2302,6 @@ const emit_method_table_t EXPORT_FUN(method_table) = {
|
||||
emit_native_import_star,
|
||||
emit_native_load_const_tok,
|
||||
emit_native_load_const_small_int,
|
||||
emit_native_load_const_int,
|
||||
emit_native_load_const_dec,
|
||||
emit_native_load_const_str,
|
||||
emit_native_load_const_obj,
|
||||
emit_native_load_null,
|
||||
|
||||
Reference in New Issue
Block a user