Skip to content

Commit ec12cc5

Browse files
committed
docs/develop: Fix mp_compile snippet to match latest code.
Signed-off-by: Damien George <damien.p.george@gmail.com>
1 parent 9c9f06a commit ec12cc5

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

docs/develop/compiler.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,15 @@ The most relevant method you should know about is this:
147147
.. code-block:: c
148148
149149
mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, bool is_repl) {
150+
// Create a context for this module, and set its globals dict.
151+
mp_module_context_t *context = m_new_obj(mp_module_context_t);
152+
context->module.globals = mp_globals_get();
153+
150154
// Compile the input parse_tree to a raw-code structure.
151-
mp_raw_code_t *rc = mp_compile_to_raw_code(parse_tree, source_file, is_repl);
155+
mp_compiled_module_t cm = mp_compile_to_raw_code(parse_tree, source_file, is_repl, context);
156+
152157
// Create and return a function object that executes the outer module.
153-
return mp_make_function_from_raw_code(rc, MP_OBJ_NULL, MP_OBJ_NULL);
158+
return mp_make_function_from_raw_code(cm.rc, cm.context, NULL);
154159
}
155160
156161
The compiler compiles the code in four passes: scope, stack size, code size and emit.

0 commit comments

Comments
 (0)