@@ -96,6 +96,7 @@ pub enum SimpleLine {
9696 condition : SimpleExpr ,
9797 then_branch : Vec < Self > ,
9898 else_branch : Vec < Self > ,
99+ line_number : SourceLineNumber ,
99100 } ,
100101 TestZero {
101102 // Test that the result of the given operation is zero
@@ -107,6 +108,7 @@ pub enum SimpleLine {
107108 function_name : String ,
108109 args : Vec < SimpleExpr > ,
109110 return_data : Vec < Var > ,
111+ line_number : SourceLineNumber ,
110112 } ,
111113 FunctionRet {
112114 return_data : Vec < SimpleExpr > ,
@@ -316,7 +318,7 @@ fn simplify_lines(
316318 const_malloc,
317319 ) ;
318320 }
319- Line :: Assert ( boolean) => match boolean {
321+ Line :: Assert ( boolean, line_number ) => match boolean {
320322 Boolean :: Different { left, right } => {
321323 let left = simplify_expr ( left, & mut res, counters, array_manager, const_malloc) ;
322324 let right =
@@ -333,6 +335,7 @@ fn simplify_lines(
333335 condition : diff_var. into ( ) ,
334336 then_branch : vec ! [ ] ,
335337 else_branch : vec ! [ SimpleLine :: Panic ] ,
338+ line_number : * line_number,
336339 } ) ;
337340 }
338341 Boolean :: Equal { left, right } => {
@@ -358,6 +361,7 @@ fn simplify_lines(
358361 condition,
359362 then_branch,
360363 else_branch,
364+ line_number,
361365 } => {
362366 let ( condition_simplified, then_branch, else_branch) = match condition {
363367 Condition :: Comparison ( condition) => {
@@ -468,6 +472,7 @@ fn simplify_lines(
468472 condition : condition_simplified,
469473 then_branch : then_branch_simplified,
470474 else_branch : else_branch_simplified,
475+ line_number : * line_number,
471476 } ) ;
472477 }
473478 Line :: ForLoop {
@@ -477,6 +482,7 @@ fn simplify_lines(
477482 body,
478483 rev,
479484 unroll,
485+ line_number,
480486 } => {
481487 if * unroll {
482488 let ( internal_variables, _) = find_variable_usage ( body) ;
@@ -534,7 +540,7 @@ fn simplify_lines(
534540 const_malloc. counter = loop_const_malloc. counter ;
535541 array_manager. valid = valid_aux_vars_in_array_manager_before; // restore the valid aux vars
536542
537- let func_name = format ! ( "@loop_{}" , counters. loops) ;
543+ let func_name = format ! ( "@loop_{}_line_{} " , counters. loops, line_number ) ;
538544 counters. loops += 1 ;
539545
540546 // Find variables used inside loop but defined outside
@@ -574,6 +580,7 @@ fn simplify_lines(
574580 // Create recursive function body
575581 let recursive_func = create_recursive_function (
576582 func_name. clone ( ) ,
583+ * line_number,
577584 func_args,
578585 iterator. clone ( ) ,
579586 end_simplified,
@@ -590,12 +597,14 @@ fn simplify_lines(
590597 function_name : func_name,
591598 args : call_args,
592599 return_data : vec ! [ ] ,
600+ line_number : * line_number,
593601 } ) ;
594602 }
595603 Line :: FunctionCall {
596604 function_name,
597605 args,
598606 return_data,
607+ line_number,
599608 } => {
600609 let simplified_args = args
601610 . iter ( )
@@ -605,6 +614,7 @@ fn simplify_lines(
605614 function_name : function_name. clone ( ) ,
606615 args : simplified_args,
607616 return_data : return_data. clone ( ) ,
617+ line_number : * line_number,
608618 } ) ;
609619 }
610620 Line :: FunctionRet { return_data } => {
@@ -872,6 +882,7 @@ pub fn find_variable_usage(lines: &[Line]) -> (BTreeSet<Var>, BTreeSet<Var>) {
872882 condition,
873883 then_branch,
874884 else_branch,
885+ line_number : _,
875886 } => {
876887 on_new_condition ( condition, & internal_vars, & mut external_vars) ;
877888
@@ -894,7 +905,7 @@ pub fn find_variable_usage(lines: &[Line]) -> (BTreeSet<Var>, BTreeSet<Var>) {
894905 }
895906 internal_vars. extend ( return_data. iter ( ) . cloned ( ) ) ;
896907 }
897- Line :: Assert ( condition) => {
908+ Line :: Assert ( condition, _line_number ) => {
898909 on_new_condition (
899910 & Condition :: Comparison ( condition. clone ( ) ) ,
900911 & internal_vars,
@@ -941,6 +952,7 @@ pub fn find_variable_usage(lines: &[Line]) -> (BTreeSet<Var>, BTreeSet<Var>) {
941952 body,
942953 rev : _,
943954 unroll : _,
955+ line_number : _,
944956 } => {
945957 let ( body_internal, body_external) = find_variable_usage ( body) ;
946958 internal_vars. extend ( body_internal) ;
@@ -1040,6 +1052,7 @@ pub fn inline_lines(
10401052 condition,
10411053 then_branch,
10421054 else_branch,
1055+ line_number : _,
10431056 } => {
10441057 inline_condition ( condition) ;
10451058
@@ -1058,7 +1071,7 @@ pub fn inline_lines(
10581071 inline_internal_var ( return_var) ;
10591072 }
10601073 }
1061- Line :: Assert ( condition) => {
1074+ Line :: Assert ( condition, _line_number ) => {
10621075 inline_comparison ( condition) ;
10631076 }
10641077 Line :: FunctionRet { return_data } => {
@@ -1112,6 +1125,7 @@ pub fn inline_lines(
11121125 body,
11131126 rev : _,
11141127 unroll : _,
1128+ line_number : _,
11151129 } => {
11161130 inline_lines ( body, args, res, inlining_count) ;
11171131 inline_internal_var ( iterator) ;
@@ -1234,6 +1248,7 @@ fn handle_array_assignment(
12341248
12351249fn create_recursive_function (
12361250 name : String ,
1251+ line_number : SourceLineNumber ,
12371252 args : Vec < Var > ,
12381253 iterator : Var ,
12391254 end : SimpleExpr ,
@@ -1257,6 +1272,7 @@ fn create_recursive_function(
12571272 function_name : name. clone ( ) ,
12581273 args : recursive_args,
12591274 return_data : vec ! [ ] ,
1275+ line_number,
12601276 } ) ;
12611277 body. push ( SimpleLine :: FunctionRet {
12621278 return_data : vec ! [ ] ,
@@ -1277,6 +1293,7 @@ fn create_recursive_function(
12771293 else_branch: vec![ SimpleLine :: FunctionRet {
12781294 return_data: vec![ ] ,
12791295 } ] ,
1296+ line_number,
12801297 } ,
12811298 ] ;
12821299
@@ -1416,7 +1433,10 @@ fn replace_vars_for_unroll(
14161433 internal_vars,
14171434 ) ;
14181435 }
1419- Line :: Assert ( Boolean :: Equal { left, right } | Boolean :: Different { left, right } ) => {
1436+ Line :: Assert (
1437+ Boolean :: Equal { left, right } | Boolean :: Different { left, right } ,
1438+ _line_number,
1439+ ) => {
14201440 replace_vars_for_unroll_in_expr (
14211441 left,
14221442 iterator,
@@ -1436,6 +1456,7 @@ fn replace_vars_for_unroll(
14361456 condition,
14371457 then_branch,
14381458 else_branch,
1459+ line_number : _,
14391460 } => {
14401461 match condition {
14411462 Condition :: Comparison (
@@ -1489,6 +1510,7 @@ fn replace_vars_for_unroll(
14891510 body,
14901511 rev : _,
14911512 unroll : _,
1513+ line_number : _,
14921514 } => {
14931515 assert ! ( other_iterator != iterator) ;
14941516 * other_iterator =
@@ -1519,6 +1541,7 @@ fn replace_vars_for_unroll(
15191541 function_name : _,
15201542 args,
15211543 return_data,
1544+ line_number : _,
15221545 } => {
15231546 // Function calls are not unrolled, so we don't need to change them
15241547 for arg in args {
@@ -1709,6 +1732,7 @@ fn handle_inlined_functions_helper(
17091732 function_name,
17101733 args,
17111734 return_data,
1735+ line_number : _,
17121736 } => {
17131737 if let Some ( func) = inlined_functions. get ( & * function_name) {
17141738 let mut inlined_lines = vec ! [ ] ;
@@ -1860,6 +1884,7 @@ fn handle_const_arguments_helper(
18601884 function_name,
18611885 args,
18621886 return_data : _,
1887+ line_number : _,
18631888 } => {
18641889 if let Some ( func) = constant_functions. get ( function_name) {
18651890 // If the function has constant arguments, we need to handle them
@@ -2051,6 +2076,7 @@ fn replace_vars_by_const_in_lines(lines: &mut [Line], map: &BTreeMap<Var, F>) {
20512076 condition,
20522077 then_branch,
20532078 else_branch,
2079+ line_number : _,
20542080 } => {
20552081 match condition {
20562082 Condition :: Comparison ( Boolean :: Equal { left, right } )
@@ -2072,7 +2098,7 @@ fn replace_vars_by_const_in_lines(lines: &mut [Line], map: &BTreeMap<Var, F>) {
20722098 replace_vars_by_const_in_expr ( end, map) ;
20732099 replace_vars_by_const_in_lines ( body, map) ;
20742100 }
2075- Line :: Assert ( condition) => match condition {
2101+ Line :: Assert ( condition, _line_number ) => match condition {
20762102 Boolean :: Equal { left, right } | Boolean :: Different { left, right } => {
20772103 replace_vars_by_const_in_expr ( left, map) ;
20782104 replace_vars_by_const_in_expr ( right, map) ;
@@ -2212,6 +2238,7 @@ impl SimpleLine {
22122238 condition,
22132239 then_branch,
22142240 else_branch,
2241+ line_number : _,
22152242 } => {
22162243 let then_str = then_branch
22172244 . iter ( )
@@ -2237,6 +2264,7 @@ impl SimpleLine {
22372264 function_name,
22382265 args,
22392266 return_data,
2267+ line_number : _,
22402268 } => {
22412269 let args_str = args
22422270 . iter ( )
0 commit comments