summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitbc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-19 11:48:48 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-19 11:48:48 +0000
commitcbd2f7482c8bf457cc17da763859dbba6e03e2a2 (patch)
tree8d6badc4197fe0d5763d381dd97586176db9fbae /py/emitbc.c
parente02b2d43912d13d216936786e4b7a33918877418 (diff)
downloadmicropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.tar.gz
micropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.zip
py: Add module/function/class name to exceptions.
Exceptions know source file, line and block name. Also tidy up some debug printing functions and provide a global flag to enable/disable them.
Diffstat (limited to 'py/emitbc.c')
-rw-r--r--py/emitbc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index e1a81adac1..1f034e9df1 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -21,7 +21,6 @@ struct _emit_t {
scope_t *scope;
- qstr source_file;
uint last_source_line_offset;
uint last_source_line;
@@ -36,9 +35,8 @@ struct _emit_t {
byte dummy_data[8];
};
-emit_t *emit_bc_new(qstr source_file, uint max_num_labels) {
+emit_t *emit_bc_new(uint max_num_labels) {
emit_t *emit = m_new0(emit_t, 1);
- emit->source_file = source_file;
emit->max_num_labels = max_num_labels;
emit->label_offsets = m_new(uint, emit->max_num_labels);
return emit;
@@ -187,7 +185,8 @@ static void emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
}
// code info
- emit_write_code_info_qstr(emit, emit->source_file);
+ emit_write_code_info_qstr(emit, scope->source_file);
+ emit_write_code_info_qstr(emit, scope->simple_name);
// prelude for initialising closed over variables
int num_cell = 0;
@@ -239,6 +238,7 @@ static void emit_bc_set_stack_size(emit_t *emit, int size) {
}
static void emit_bc_set_source_line(emit_t *emit, int source_line) {
+ //printf("source: line %d -> %d offset %d -> %d\n", emit->last_source_line, source_line, emit->last_source_line_offset, emit->byte_code_offset);
if (source_line > emit->last_source_line) {
int bytes_to_skip = emit->byte_code_offset - emit->last_source_line_offset;
for (; bytes_to_skip > 255; bytes_to_skip -= 255) {
@@ -249,6 +249,7 @@ static void emit_bc_set_source_line(emit_t *emit, int source_line) {
emit_write_code_info_byte_byte(emit, 0, 255);
}
emit_write_code_info_byte_byte(emit, bytes_to_skip, lines_to_skip);
+ //printf(" %d %d\n", bytes_to_skip, lines_to_skip);
emit->last_source_line_offset = emit->byte_code_offset;
emit->last_source_line = source_line;
}