From 2283b6d68fe77b72e7beeb1bf24778834231b190 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 7 Dec 2022 14:42:35 +1100 Subject: py: Pass in address to compiled module instead of returning it. This change makes it so the compiler and persistent code loader take a mp_compiled_module_t* as their last argument, instead of returning this struct. This eliminates a duplicate context variable for all callers of these functions (because the context is now stored in the mp_compiled_module_t by the caller), and also eliminates any confusion about which context to use after the mp_compile_to_raw_code or mp_raw_code_load function returns (because there is now only one context, that stored in mp_compiled_module_t.context). Reduces code size by 16 bytes on ARM Cortex-based ports. Signed-off-by: Damien George --- docs/develop/compiler.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs/develop/compiler.rst') diff --git a/docs/develop/compiler.rst b/docs/develop/compiler.rst index 4b43bc08f..cac92585f 100644 --- a/docs/develop/compiler.rst +++ b/docs/develop/compiler.rst @@ -152,7 +152,9 @@ The most relevant method you should know about is this: context->module.globals = mp_globals_get(); // Compile the input parse_tree to a raw-code structure. - mp_compiled_module_t cm = mp_compile_to_raw_code(parse_tree, source_file, is_repl, context); + mp_compiled_module_t cm; + cm.context = context; + mp_compile_to_raw_code(parse_tree, source_file, is_repl, &cm); // Create and return a function object that executes the outer module. return mp_make_function_from_raw_code(cm.rc, cm.context, NULL); -- cgit v1.2.3