History

Fix source line assumption in sbl reader. - Statements can cross source line boundaries

arr committed 9 years ago

Commit 5ef656f1 parent 4afaca44 files · +10 −7Browse files

Unified · Split

4 files
  1. limbo/sbl-format-grammar.txt +1 −1
  2. src/asm/sbl_reader.cpp +6 −4
  3. src/exec/debugger.cpp +1 −1
  4. src/include/vm_asm.h +2 −1
limbo/sbl-format-grammar.txt+1−1
@@ -17,7 +17,7 @@ char: <int> · 16 unmodified lines
1717
1818 type-table: <count> '\n' type*
1919 type:
20− '@' type-index '\n' # Type table reference
20+ '@' type-index '\n' # Type table reference
2121 'a' adt-item # ADT
2222 'p' adt-item tag-table # ADT-Pick
2323 't' size '.' id-table # Tuple
src/asm/sbl_reader.cpp+6−4
@@ -243,7 +243,7 @@ namespace · 242 unmodified lines
243243 source_ref_t src;
244244
245245 // Initialize the source with the last state
246− src.source_id = fc.last_file;
246+ src.begin_source_id = fc.last_file;
247247 src.begin_line = fc.last_line;
248248 src.end_line = fc.last_line;
249249 for (auto i = std::size_t{ 0 }; i < src_parts.size(); ++i)
@@ -274,8 +274,10 @@ namespace · 24 unmodified lines
274274 }
275275 else if (pos[j] == ':')
276276 {
277− assert((i == 0 || src.source_id == v) && "Source position should not change across statements");
278− src.source_id = v;
277+ if (i == 0)
278+ src.begin_source_id = v;
279+
280+ src.end_source_id = v;
279281 fc.last_file = v;
280282 }
281283 }
@@ -310,7 +312,7 @@ namespace · 28 unmodified lines
310312 curr_item.debug_statement = std::stoi(pc_item_parts[1]);
311313
312314 // Record the current source and line ID since those are the new default values
313− last_source = curr_item.source.source_id;
315+ last_source = curr_item.source.end_source_id;
314316 last_line = curr_item.source.end_line;
315317
316318 pc_table[i] = std::move(curr_item);
src/exec/debugger.cpp+1−1
@@ -1064,7 +1064,7 @@ std::vector<std::string> debugger::resolve_to_function_source_line( · 1063 unmodified lines
10641064 ss << function_name << " at ";
10651065
10661066 const auto source_loc = d.current_source_location();
1067− ss << d.get_source_by_id(source_loc.source_id)
1067+ ss << d.get_source_by_id(source_loc.begin_source_id)
10681068 << ':'
10691069 << source_loc.begin_line;
10701070
src/include/vm_asm.h+2−1
@@ -64,9 +64,10 @@ namespace disvm · 63 unmodified lines
6464 // Reference into source code
6565 struct source_ref_t
6666 {
67− int32_t source_id;
67+ int32_t begin_source_id;
6868 int32_t begin_line;
6969 int32_t begin_column;
70+ int32_t end_source_id;
7071 int32_t end_line;
7172 int32_t end_column;
7273 };