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
17 17
18type-table: <count> '\n' type*18type-table: <count> '\n' type*
19type:19type:
20 '@' type-index '\n' # Type table reference 20 '@' type-index '\n' # Type table reference
21 'a' adt-item # ADT21 'a' adt-item # ADT
22 'p' adt-item tag-table # ADT-Pick22 'p' adt-item tag-table # ADT-Pick
23 't' size '.' id-table # Tuple23 't' size '.' id-table # Tuple
src/asm/sbl_reader.cpp+6−4
@@ -243,7 +243,7 @@ namespace · 242 unmodified lines
243 source_ref_t src;243 source_ref_t src;
244 244
245 // Initialize the source with the last state245 // Initialize the source with the last state
246 src.source_id = fc.last_file;246 src.begin_source_id = fc.last_file;
247 src.begin_line = fc.last_line;247 src.begin_line = fc.last_line;
248 src.end_line = fc.last_line;248 src.end_line = fc.last_line;
249 for (auto i = std::size_t{ 0 }; i < src_parts.size(); ++i)249 for (auto i = std::size_t{ 0 }; i < src_parts.size(); ++i)
@@ -274,8 +274,10 @@ namespace · 24 unmodified lines
274 }274 }
275 else if (pos[j] == ':')275 else if (pos[j] == ':')
276 {276 {
277 assert((i == 0 || src.source_id == v) && "Source position should not change across statements");277 if (i == 0)
278 src.source_id = v;278 src.begin_source_id = v;
279
280 src.end_source_id = v;
279 fc.last_file = v;281 fc.last_file = v;
280 }282 }
281 }283 }
@@ -310,7 +312,7 @@ namespace · 28 unmodified lines
310 curr_item.debug_statement = std::stoi(pc_item_parts[1]);312 curr_item.debug_statement = std::stoi(pc_item_parts[1]);
311 313
312 // Record the current source and line ID since those are the new default values314 // 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;
314 last_line = curr_item.source.end_line;316 last_line = curr_item.source.end_line;
315 317
316 pc_table[i] = std::move(curr_item);318 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
1064 ss << function_name << " at ";1064 ss << function_name << " at ";
1065 1065
1066 const auto source_loc = d.current_source_location();1066 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)
1068 << ':'1068 << ':'
1069 << source_loc.begin_line;1069 << source_loc.begin_line;
1070 1070
src/include/vm_asm.h+2−1
@@ -64,9 +64,10 @@ namespace disvm · 63 unmodified lines
64 // Reference into source code64 // Reference into source code
65 struct source_ref_t65 struct source_ref_t
66 {66 {
67 int32_t source_id;67 int32_t begin_source_id;
68 int32_t begin_line;68 int32_t begin_line;
69 int32_t begin_column;69 int32_t begin_column;
70 int32_t end_source_id;
70 int32_t end_line;71 int32_t end_line;
71 int32_t end_column;72 int32_t end_column;
72 };73 };