diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-18 23:24:36 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-18 23:24:36 +0000 |
commit | 08335004cfe95048ee06134a3e49b9fb75639139 (patch) | |
tree | 7518a854012938fd70c57b3571a630a142b84f28 /py/compile.c | |
parent | aefe79880f8c5f66132673ccc9be27d2ca29005b (diff) | |
download | micropython-08335004cfe95048ee06134a3e49b9fb75639139.tar.gz micropython-08335004cfe95048ee06134a3e49b9fb75639139.zip |
Add source file name and line number to error messages.
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/py/compile.c b/py/compile.c index b24e94a8dc..cf87e018d9 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2505,6 +2505,7 @@ void compile_node(compiler_t *comp, mp_parse_node_t pn) { } } else { mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn; + EMIT(set_line_number, pns->source_line); compile_function_t f = compile_function[MP_PARSE_NODE_STRUCT_KIND(pns)]; if (f == NULL) { printf("node %u cannot be compiled\n", (uint)MP_PARSE_NODE_STRUCT_KIND(pns)); @@ -3024,7 +3025,7 @@ void compile_scope_compute_things(compiler_t *comp, scope_t *scope) { } } -mp_obj_t mp_compile(mp_parse_node_t pn, bool is_repl) { +mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, bool is_repl) { compiler_t *comp = m_new(compiler_t, 1); comp->is_repl = is_repl; @@ -3131,7 +3132,7 @@ mp_obj_t mp_compile(mp_parse_node_t pn, bool is_repl) { default: if (emit_bc == NULL) { - emit_bc = emit_bc_new(max_num_labels); + emit_bc = emit_bc_new(source_file, max_num_labels); } comp->emit = emit_bc; comp->emit_method_table = &emit_bc_method_table; |